feat(shader): sample converted unorm images in the shader #5958
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5958"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-14T17:08:08Z.
What
image_sampleon a 10_11_11_UNORM (format 30) image threwsampling, gathering or querying LOD of a converted unorm image is not implemented. The format has no Vulkan equivalent, so it is bound through an R32_UINT view that cannot be filtered. God of War Ragnarök (PPSA08330) stopped on a converted-image sample in compute shader0x10527dd300, about 60 s in, after its MFSR setup (#5796) and the SINT D16 stores (#5899).These samples now go through the emulation that color comparisons already use (
EmitEmulatedCompareSample, renamedEmitEmulatedSample):One texel (point) or four texels (bilinear) are fetched at LOD 0 through the R32_UINT view.
Each texel is decoded and swizzled like
image_load(UnpackImageTexel), then blended. Bilinear weights are rounded to the hardware's 8-bit grid (roundEven(fraction * 256) / 256), as adriadam10 measured on gfx1035 in this PR.The sampler state (point or bilinear, wrap or clamp-to-edge) reaches the shader through the existing comparison specialization words, or through the runtime metadata for registered shaders.
EmulatedCompareStatenow fills it for these images (convertedSampleState), and the binding builder provides those words whenever the converted-sample mode is compiled in.The tracker sets two new bits in
emulatedCompare:ConvertedSampleUnsupportedfor gathers and LOD queries;ConvertedSampleRequiresSingleLevelfor samples that are not_lz.RuntimeImageModesadds the converted UNORM mode for sampled images that these two bits do not exclude.These cases still throw (
rejectImageat decode, or when the sampler state is built):_lz.The R10_G11_B11 float format (43) is not part of this PR: since #7271 its sampled images use a lossless B10G11R11 copy and the hardware sampler. On the converted path (storage or packed images) a float sample keeps main's refusal.
Cost: none for a title that never samples this format. A shader gets the converted sample mode only once a converted descriptor reaches one of its sampled images:
GuestContext::convertedSamplesadds it (ImageResource::convertedSamples, set when the program is prepared). The flag is part of every cache key, the disk cache included.ConvertedSampleRequired.CaptureInvocation) records the program offset in the registered program'sPreparedShaders, gets the invocation again (now with the flag, so the static key differs and the existing prepare-at-use path builds the new artifact) and repeats the capture.Recompile(request)retries the same way.Tested
BUILD_TESTING=ON, on main91ddd9e3a(head8545c2301).agc_driver_image_converted_unorm:image_sample_lzchecks: point and bilinear filtering, clamp-to-edge and wrap addressing, on-grid and off-grid steps, swizzles X Y Z 1, Z Y X 1 and X 0 1 1. Every component is compared against a decode-and-blend model with 8-bit-grid weights.CheckFloatSample) are kept as they are. Clamp-to-border is refused. The gather and LOD-query refusals stay.off-grid wrapped bilinear image_sample_lz X Y Z 1: thread 2 component 0 is 0.994141, expected 0.992188). With the bilinear neighbours swapped it fails (bilinear image_sample_lz Z Y X 1: thread 0 component 0 is 0.000489, expected 0.000244).ConvertedSampleRequired, while one through the flagged artifact succeeds.pr_overlap_toolsandcheck_main_sync(git 2.30 here lacksmerge-tree --write-tree),guest_sce_net(DNS timeout) andagc_driver_bda_device, which fails the same way on plain main91ddd9e3a(Vulkan result -4; #5859 on NVIDIA, fixed by #7571).tools/check_conventions.py --base origin/mainandtools/check_test_registration.pypass.0x10527dd300and ran to about 180 s, to an unrelated stop (runtime storage image mip capacity exceeded). Those runs used the version that also covered the float format and were not repeated after the rebase.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repository🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-14T17:17:58Z.
Review: COMMENTED
Routing these samples through the existing compare emulation is a sensible way to get exact-format decoding without a Vulkan equivalent. The test is thorough: it fails when the bilinear neighbours are swapped.
The cost section is the part I'd like quantified, since it affects every title, not only those with converted formats: "a sampled image whose format is unknown at registration now also carries the converted modes in its runtime-mode switch", which is one more decode-and-blend path per sample instruction. Specialization folds the branch away at pipeline creation, but the module still grows. The driver parses and optimizes the larger module before dead-code elimination removes the unused path, so pipeline compile time rises for every registered shader with such samples. Earlier PRs that added arms to hot shader paths (#4322) were closed for exactly this kind of compile-time increase.
Two numbers would settle it:
vkCreate*Pipelinestime for a few registered pixel shaders of a title that never uses 10_11_11 (any UE or Unity title), before and after;APS5_TRACE_SECONDS, comparing the shader-compile phases.If the growth is significant, could the converted modes be added only once a converted descriptor has been seen for that shader, for example by preparing it again at that point? The cost would then fall only on titles that use the format.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-14T19:16:27Z.
Review: COMMENTED
Run on an Apple GPU, since the PR was tested only on an RTX 3080.
GPUs tested: Apple M2 Max, MoltenVK 1.4.2 (Vulkan 1.4.357), macOS 27.2, x86-64 under Rosetta
maindoes not run the GPU tests on macOS yet, so I tested onmacos-portatb7eb6b6b(mugurc/AnyPS5) plus theImportWatchedchange from #1, with this PR's own diff (merge-base..head8338defe5) applied. Notmain. Release build, LunarG Vulkan SDK 1.4.363.0. Suite:ctest -R "^agc" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64" -j1 --timeout 30. Without the PR, 13 tests fail on this setup (7 with the #2704 build), all known macOS failures listed in #1.The diff does not apply cleanly to that branch. Two hunks conflict:
ResourceMaterializer.cpp: the branch has neitherrejectImage/PoisonReasonnorImageResource::table.SpirvImageEmitter.cpp: the branch still has the bindless-slot check.I adapted them: the same new checks, written as
throw, withindirectRoot != NoIndirectImagein place oftable != NoTable, and the slot check kept. Treat this as an approximation of the PR, not the PR itself.agc_driver_image_converted_unormpasses. That includes the new point and bilinearimage_sample_lzchecks with clamp-to-edge and wrap, and both formats.samples or gathers a converted float image, or queries its LOD, which is not implemented. So the sample paths run on this device.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-14T21:21:17Z.
Thanks for the Apple GPU run and for adapting the two hunks by hand. Good to see the point and bilinear
image_sample_lzchecks pass on MoltenVK and that the test fails there without the change too.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:12:17Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppL30core/shader/recompiler/Optimization/src/ResourceMaterializer.cppL1567-1570core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hppL49core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppL541-542, L723-725Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hppcore/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppcore/shader/recompiler/Recompiler.hppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/Recompiler.hppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hppcore/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hppcore/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/DataHitVerification.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/Recompiler.hppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Recompiler.hppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Recompiler.hppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Recompiler.hppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cppdocs/dev/debt/shader.mdcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cppdocs/dev/debt/shader.mdcore/shader/recompiler/Optimization/src/ResourceTracker.cppdocs/dev/debt/shader.mdcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/CMakeLists.txtcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/DrawCapture.cppcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppcore/shader/recompiler/CacheKey.hppcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hppcore/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/Recompiler.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cppImported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-15T13:24:51Z.
@CnRJay, thanks for asking for numbers. They confirm your concern, and the growth is large.
Setup. Hollow Knight: Silksong (PPSA12544, Unity) never uses 10_11_11 or 11_11_10: the branch logs no converted image. Cold start to the main menu, 90 s per run, with an empty
ANYPS5_SHADER_CACHE_DIReach run (this also empties thevk-pipelinescache) and__GL_SHADER_DISK_CACHE=0. Runs alternate main, branch, main, branch. Main isf7a90d6fd; the branch is this PR rebased onto it (40704b646, force-pushed now; the only conflict was main's newnullImageDescriptor(image, descriptor)signature). Both builds carry the same local-only hook, which is not part of the PR: it wrapsvkCreateGraphicsPipelines,vkCreateComputePipelinesandvkCreateShaderModuleat the two device-function lookups and sums the call count, wall time and SPIR-V words. Windows 11, RTX 3080, driver 610.74, WinLibs GCC 15.2.0, Release.vkCreateGraphicsPipelines(128 pipelines)vkCreateComputePipelines(14)vkCreateShaderModule(335-337 modules)So for a title that never uses the formats: graphics pipeline creation takes about 4.3 times as long (+6.6 s on a cold start), SPIR-V grows by 71%, and 42 of the 118 cached shaders grow. The frame rate once warm is unchanged (59.9 FPS in all four runs).
That is too much to put on every title. I will rework the PR along the lines you suggest: a shader gets the converted modes only after a converted descriptor has been seen for it, and is then prepared again. Titles without the formats will then compile exactly what they compile on main. I will post the same measurement again for the reworked version.
AI-assisted (Claude Code). I ran the builds and the runs above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-15T17:46:11Z.
@CnRJay, the rework is pushed. A shader now gets the converted sample modes only after a converted descriptor reaches one of its sampled images. That capture throws
ConvertedSampleRequired, the driver records the program, prepares it again withGuestContext::convertedSamples(part of every cache key) and repeats the capture. A title without these formats compiles what main compiles.Same measurement as before: Hollow Knight: Silksong (PPSA12544), cold start to the main menu, 90 s per run, empty
ANYPS5_SHADER_CACHE_DIR, runs alternating main, branch, main, branch. Main is940eba9a2, the branch is this PR rebased onto it. Same local-only hook aroundvkCreateGraphicsPipelines,vkCreateComputePipelinesandvkCreateShaderModule. Windows 11, RTX 3080, driver 610.74, WinLibs GCC 15.2.0, Release.One correction to my earlier numbers: this driver ignores
__GL_SHADER_DISK_CACHE=0(its GLCache folder was written during a run). This time every run had its own empty__GL_SHADER_DISK_CACHE_PATH, so all four are cold. That is why main is slower here than the 1.9-2.0 s I reported before: those main runs were probably served from the driver's cache, while the old branch's different SPIR-V was not. So the old table overstated the time gap (about 3 s cold against 8-9 s, not 2 s). The +71% SPIR-V was real.vkCreateGraphicsPipelines(128 pipelines)vkCreateComputePipelines(14)vkCreateShaderModule(335 modules)SPIR-V is identical, and pipeline creation is within run-to-run noise. The cache grows by 1.8 KB, from the new per-image field. 59.9 FPS in all four runs.
AI-assisted (Claude Code). I ran the builds and the runs above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-15T18:20:58Z.
Thanks for measuring, and for the rework. The first numbers (+71 % SPIR-V and about 3 s more pipeline creation on a cold start for a title that never uses these formats) were exactly the cost I was worried about. The second set shows identical SPIR-V and pipeline creation within noise. Preparing the converted variant only after a converted descriptor reaches a sampled image is the right design. A title that does use these formats pays one re-preparation per affected program, once.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-15T21:27:26Z.
Review: COMMENTED
Linux run of the current head, since the PR has been tested on Windows + RTX 3080 and on our Apple M2 Max run (at
8338defe5).Machine: NVIDIA GeForce RTX 3070, driver 595.99.02, Vulkan 1.4.329, Ubuntu 26.04 (kernel 7.0.0-38), i7-8700. GCC 15.2, Release,
BUILD_TESTING=ON. Head5dd5396bcmerged ontomain44df21632, no conflicts.ANYPS5_GPU="NVIDIA GeForce RTX 3070".GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), Linux
agc_driver_image_converted_unorm: 3/3 pass.ctest -R "^agc|shader|recompiler|image" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64|display|flip" -j1 --timeout 60: 599 pass, 1 skipped, 2 failed out of 602.agc_driver_stencil_ref_export. The 3070 does not exposeVK_EXT_shader_stencil_export.agc_pending_key_storesandagc_driver_store_over_untracked. Both also fail on unchangedmainon this machine, at the same assertions: 20/240 and 64/70 idle runs (see #6500 and #6347).GuestContext::convertedSamplesandConvertedSampleRequired, so it does not compile againstmain's sources. The red check on the Apple run was at8338defe5.Written with AI assistance (Claude Code). I ran the tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T12:32:39Z.
Review: CHANGES_REQUESTED
Measured
image_sample_lzon RDNA2 (gfx1035) with 10_11_11 UNORM (format 30) and FLOAT (format 43) T#s: 64x4 linear, random texels (float ones over the whole exponent range), swizzles X Y Z 1 / Z Y X 1 / X 0 1 1, wrap and clamp-to-edge, point and bilinear, 50 positions each, IEEE=0 DENORM=0.OpFDivdebt line).roundEven(frac * 256) / 256before blending: that model matches every row to 6e-8 relative (unorm) and 3e-6 (float). The PR blends with full float weights (SpirvImageEmitter.cpp:1354-1377), which is off by up to 0.2 % on unorm and much more on float texels with a wide range. Examples (u·W, v·H → X Y Z):0.881418 0.698259 0.162392, PR0.881701 0.698338 0.1618150.696461 322.78 0.0513165, PR0.684964 279.189 0.05103133.48226 1950.03 1.54954, PR3.46977 1939.81 1.55237x = 1.25 * tid + startwith starts 0.75, -3 and 16 gives fractions that are multiples of 0.25, which are already on the 1/256 grid. Please add positions off the grid (e.g. a step of1.3texels, or+ 1/512and+ 3/512to hit the ties) and quantize the weights in the test's model too.weightU/weightV× 256,RoundEven, × 1/256; all exact in f32). Whether the color-compare path should share it is up to you, but it is not needed for this PR.docs/dev/debt/shader.md:122then says the weights follow the hardware's 8-bit grid (measured on gfx1035) instead of "not modelled ... none of this is measured on hardware".Build and the AgcDriver/Agc tests are green here on RADV (only
agc_driver_tessellation, which also fails on main);agc_driver_image_converted_unormpasses. The deferred preparation (ConvertedSampleRequired+GuestContext::convertedSamplesin the key) looks fine to me.Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-16T20:34:47Z.
Thanks for measuring it on gfx1035. Done in 87a9b8d28:
roundEven(fraction * 256) / 256, exact in f32). The color-compare path is unchanged, so shaders without a converted descriptor compile to the same SPIR-V as before.agc_driver_image_converted_unormquantizes the weights in its model and adds three bilinear runs (unorm Z Y X 1, float X Y Z 1, wrapped unorm X Y Z 1) with a step of 1.25 + 3/1024 texels, so the fractions land off the grid and on ties in both directions (193.5 -> 194, 196.5 -> 196, 1.5 -> 2, 4.5 -> 4); every position is exact in f32. Without the shader change the float run fails (thread 1 component 0 is 1.870605, expected 1.869141); with it all runs pass.docs/dev/debt/shader.mdnow says the weights follow the hardware's 8-bit grid as you measured on gfx1035, with point sampling, decode, swizzles and both address modes matching the same measurement.Tested on Windows, RTX 3080 (NVIDIA 610.74), MinGW GCC 15.2 Release: the AgcDriver, shader and recompiler tests pass (605 of 606;
agc_driver_gpu_indirect_arguments_misaligned_writer_aheaddoes not build with MinGW because of itsalignas(65536), the problem in #6716, unrelated to this change).Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T20:58:31Z.
Review: APPROVED
Re-checked 87a9b8d28:
roundEven(fraction * 256) / 256, matching what I measured on gfx1035; the color-compare path is unchanged.off-grid bilinear image_sample_lz of R10_G11_B11_FLOAT: thread 1 component 0 is 1.870605, expected 1.869141).agc_driver_tessellation, which also fails on main). The debt entry is updated.Merging once the full Build is green.
Imported from boykopovar/AnyPS5. Originally posted by keravyn-ops on 2026-10-17T08:55:50Z.
AMD / Windows run of this PR at 87a9b8d28: Radeon 780M (RDNA 3, 0x15bf), AMD driver 25.10.20.01 (32.0.21020.1007), Windows 11 Home 10.0.26100, WinLibs GCC 15.2.0 r7, Release.
agc_driver_image_converted_unorm: pass (image converted unorm tests passed, 11.10 s)AI-assisted: yes (run made on the device above).
Imported from boykopovar/AnyPS5. Originally posted by gjonn on 2026-10-17T19:46:00Z.
Another data point from PPSA01317 on current main, Windows 11, RTX 5090 Laptop: this PR fixes its abort,
shader 0x145628e00 stage 5: samples or gathers a converted float image, or queries its LOD, which is not implemented, which hits on its first presented frames. With this PR's three commits cherry-picked, the title gets past it and boots further.There's one limit for later, not a request for this PR: after a few more fixes the same title samples a format-43 image (packed 11_11_10 float) as a cube and stops on
samples a converted float image that is not a 2D or 2D array view. So the conversion path only covers 2D and 2D-array views.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by gjonn on 2026-10-17T21:01:00Z.
Heads-up: I opened #7271, which samples texture format 43 (10_11_11 float) natively. It copies the texels losslessly into a
VK_FORMAT_B10G11R11_UFLOAT_PACK32image (guest R and B fields swapped, every bit kept) and swaps R and B back in the view. Point and bilinear filtering, every mip and LOD, and cube faces then go through the hardware sampler like any other float texture. This PR stays useful for the other converted formats. Format 43 would just no longer need the in-shader conversion.The two PRs touch the same test. If both merge, the bilinear
R10_G11_B11_FLOATcheck inImageConvertedUnorm.cppthat expects the 8-bit-grid result (1.693848) would have to drop that expectation for format 43. Native filtering gives 1.694336, and since native filtering is what the console's TMU does, 1.694336 is the exact value. Whichever PR merges second can make that change. I'm happy to rebase mine if yours goes in first.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-18T14:24:42Z.
Review: CHANGES_REQUESTED
#7271 is merged, and it overlaps this PR:
R10_G11_B11_FLOAT) sampled images now go through a lossless B10G11R11 copy and the hardware sampler. InResourceMaterializer.cppthey arenativeRepacked(sampled, non-storage, non-packed) and no longer getconversionFormat, so the float half of the converted-sample emulation added here no longer runs for them.ImageConvertedUnorm.cppconflicts with main in three hunks. Main replaces the floatimage_sample_lzrefusal withCheckFloatSample(point sampling, bit-exact). The float bilinear and off-grid checks here model weights quantized toroundEven(frac * 256) / 256; the native sampler does not do that on every GPU, so they cannot be kept as they are.libSceAgcDriver/CMakeLists.txtalso conflicts (adjacenttarget_include_directorieslines, trivial).Please rebase on main and decide the float part explicitly:
The UNORM path itself was already checked (1/256 weights match gfx1035) and needs no change. Re-run
agc_driver_image_converted_unormafter the rebase, with the negative check (bilinear neighbours swapped / rounding removed) still failing.Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-18T16:40:49Z.
@adriadam10 rebased on main (
91ddd9e3a) as one commit,8545c2301, taking the first option: this PR now covers only the 10_11_11 UNORM (format 30) path, and the float emulation is gone.nativeRepackedsince #7271. On the converted path (storage or packed), a float sample keeps main's refusal (samples or gathers a converted float image ...).RuntimeImageModesadds only the UNORM mode once a converted descriptor is seen, andconvertedSampleState, theConvertedSampleRequiredtrigger and the binding builder check format 30 only.ImageConvertedUnorm.cpp: kept main'sCheckFloatSample, and dropped the float bilinear and off-grid runs along with the float expectations on the 8-bit grid. The UNORM point, bilinear, wrapped and off-grid checks are unchanged.CheckConvertedPreparationnow expects exactly one converted mode.CMakeLists.txt: the adjacenttarget_include_directorieslines, both kept.RTX 3080 (NVIDIA 610.74), Windows 11, MinGW GCC 15.2, Release:
agc_driver_image_converted_unormpasses. The negative checks still fail:off-grid wrapped bilinear image_sample_lz X Y Z 1: thread 2 component 0 is 0.994141, expected 0.992188;bilinear image_sample_lz Z Y X 1: thread 0 component 0 is 0.000489, expected 0.000244.In the full CTest,
agc_driver_bda_devicefails here, and also on plain main91ddd9e3a(#5859 on NVIDIA, which #7571 fixes). The title and body are updated to match.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by spiff637 on 2026-10-18T18:27:18Z.
Tested this PR at
8545c2301with another region of the title: God of War Ragnarök PPSA08329 (06.006.000).compute shader 0x1038fdd300: sampling, gathering or querying LOD of a converted unorm image is not implemented. The shader usesimage_sample_lz×5,image_sample_lz_o×7 andimage_gather4_lz×4; there is noget_lod.syscallat code offset 0x116c84, so it was relinked with--skip-syscall-check. That is unrelated to this change.