fix(shader): bind an unnormalized S# normalized when it samples only null images #7296
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7296"
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 gjonn on 2026-10-17T22:01:54Z.
What
A compute shader that does
image_sample_lzthrough an S# forcing unnormalized coordinates was refused when that S# is paired with a T# the shader declares 3D, 2D-array, cube or multisampled:DescriptorBindingBuilder::Populate unnormalized guest sampler samples a 1D-array, 2D-array, 3D, cube or multisampled image, which is not implemented;guest sampler descriptor uses unnormalized coordinates which are not implemented.Vulkan allows unnormalized coordinates only on a single-level 1D or 2D view, so a real T# of those shapes still cannot take such a sampler. But a null T# reads zeros at any coordinate, and a T# whose four channel selects are all constants is emitted as those constants without a sample. When an unnormalized S# samples nothing else, its coordinates cannot change any result.
PPSA01317 compute shader
0x1258d12200does exactly this during boot: S#00008092 00fff000 02500000 00000000(clamp on all axes, bilinear, explicit LOD) is paired only with a null T# and a 1x1x1 R8 3D T# whose channel selects are all 0.Change:
ProveUnnormalizedskips a sampled pair whose shape mismatch comes from a null T#. If the S# then samples no real T#, its binding element gets the newsamplerCoordinatesIgnoredflag instead ofsamplerUnnormalized.ShaderResources::addImageBindingclears the force-unnormalized bit of such an S# before creating the sampler.FormatVersiongoes 37 -> 38 (main is at 37 since #7207), as earlier binding-flag additions (e.g.samplerIntegerBorder) did.Tested
Windows 11, MinGW-w64 GCC, NVIDIA GeForce RTX 5090 Laptop GPU (driver 616.92). Rebased on
mainatc0a7468f6.agc_shader_memory(newverifyNullVolumeUnnormalizedSampler, which runsDescriptorBindingBuilder::Populatewith the S# above):samplerCoordinatesIgnored = {true},samplerUnnormalized = {false}.main(only the newDescriptorBinding::samplerCoordinatesIgnoredfield kept so the test compiles): fails withDescriptorBindingBuilder::Populate unnormalized guest sampler samples a 1D-array, 2D-array, 3D, cube or multisampled image, which is not implemented.agc_shader_disk_cache(binding round-trip now coverssamplerCoordinatesIgnored),agc_shader_disk_cache_large_file,agc_driver_graphics: pass.python tools/check_conventions.py --base origin/mainandpython tools/check_test_registration.pypass.Not tested: AMD, Intel, Linux, macOS. The title was not re-run on this exact branch.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T22:12:26Z.
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/shader/recompiler/ShaderDiskCache.cppL88-90core/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hppL58core/shader/recompiler/ShaderDiskCache.hppL16core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppL87core/shader/recompiler/ShaderDiskCache.cppL90core/shader/recompiler/ShaderDiskCache.hppL16core/shader/recompiler/ShaderDiskCache.hppL16core/shader/recompiler/ShaderDiskCache.hppL16core/shader/recompiler/ShaderDiskCache.cppL89-90core/shader/recompiler/ShaderDiskCache.cppL88-90core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppL4116core/shader/recompiler/ShaderDiskCache.cppL88-90core/shader/recompiler/ShaderDiskCache.hppL16core/shader/recompiler/Recompiler.hppL428-432core/shader/recompiler/ShaderDiskCache.cppL90Some 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/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.hppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Recompiler.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/shader/recompiler/Recompiler.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Recompiler.hppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Recompiler.hppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Recompiler.hppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Optimization/include/Optimization/ResourceMaterializer.hppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/shader/recompiler/Recompiler.hppcore/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Recompiler.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/shader/recompiler/Recompiler.hppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/shader/recompiler/Recompiler.hppImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T22:44:13Z.
Full CI on 6bbbf0a52 (merged into main) fails to compile on Linux only:
The new
std::vector<bool> samplerCoordinatesIgnoredfield inDescriptorBinding(Recompiler.hpp:429) adds 40 bytes under libstdc++. The size check atShaderDiskCache.cpp:90is compiled only for__linux__ && __x86_64__ && __GLIBCXX__, so it still says 592 and Windows passes. The encoder and decoder already carry the new flag, so only the number is out of date.DescriptorBindinghasn't changed on main since this PR's base.Fix: change the assert to
static_assert(sizeof(DescriptorBinding) == 632, ...). This is the same one-line change05b3f6e40dmade forsamplerIntegerBorder(488 -> 528).Separately, #7085, #6959, #6941, #7223 and #6924 also raise
ShaderDiskCacheFormatVersionfrom 36 to 37. Whichever of them lands after this PR needs 38 instead (or this PR does, if one of them lands first).Imported from boykopovar/AnyPS5. Originally posted by gjonn on 2026-10-17T22:49:51Z.
Thanks. Fixed in ec2453d51: the assert now expects 632, the same one-line change as
05b3f6e40d. I couldn't build the Linux-only assert here, so the value comes from your CI output.On FormatVersion: noted. If one of #7085, #6959, #6941, #7223 or #6924 lands first, I'll rebase and move this one to 38.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by gjonn on 2026-10-18T13:21:31Z.
Rebased onto main
385ed71f2(force-push, headca7f2f60b). Git merged cleanly, but main is already atShaderDiskCacheFormatVersion37 since #7207, so the identical 36 -> 37 change merged away silently. This PR now raises it to 38.DescriptorBindinghasn't changed on main since the old base, so the Linux size assert stays at 632.agc_shader_memory,agc_shader_disk_cacheandagc_shader_disk_cache_large_filepass (Windows, MinGW GCC, Release).check_conventions.py --base origin/mainandcheck_test_registration.pyare clean.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-18T16:33:19Z.
AMD on Windows: the tests this PR names pass on an RDNA 3.5 GPU.
Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release.
main6efb7261bwith this PR (ca7f2f60b) merged, together with #7446, #7377, #7445, #6708, #6748, #6785, #6706, #6613, #7449, #7391, #7489, #7484, #7514. They were built once, so the result is for the combination; each merge was clean.agc_driver_graphics,agc_shader_disk_cache,agc_shader_disk_cache_large_file,agc_shader_memory: pass, 3 runs of 3.agc_*test on the combined build: 713 of 716 pass. The 3 that fail,agc_driver_host_import_lifetime,agc_driver_quad_pixel_maskandagc_driver_layered_volume_vertex_no_gpl, fail the same way on unchangedmainhere, so none comes from these PRs.AI-assisted