fix(agc): read an unnormalized sampler without a mip filter at its base level #5886
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5886"
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 ymatrix1 on 2026-10-14T14:45:29Z.
What
A guest sampler with FORCE_UNNORMALIZED and a mip filter of none reading a multi-level texture is refused: the driver accepts an unnormalized sampler on a view with several levels only when every use is
image_sample_lzand the S# has no minimum LOD and no LOD bias. Kena: Bridge of Spirits (PPSA01746) binds such a sampler (implicit LOD, point filters, mip filter none, LOD bias 7, min-reduction filter mode) to a 9-level texture and stops with:With the mip filter off the sampler reads only level 0, so the base-level path the driver already has for unnormalized samplers is exact for it whatever its uses, minimum LOD or bias. A sampler with a point or linear mip filter is unchanged.
Hardware measurement (PS5, gfx1013)
Through the PS5 Vulkan probe harness (mihawk-99/PS5_Vulkan): a 64x64 texture with four mip levels, each level a distinct marker, sampled by a compute shader through a sampler whose descriptor is rewritten to set FORCE_UNNORMALIZED (S# dword 0 bit 15). Coordinates are in texel units. Each row counts which level the 256 output texels came from.
Also: with a point mip filter the coordinates are read in texel units of the selected level (output texel (5, 2) reads texel (5, 2) at levels 1, 2 and 3 for the same coordinate (5.5, 2.5)); with the mip filter none they are level-0 texels (implicit row: texel (20, 8) for coordinate (20.5, 8.5)). The point-filter rows show the existing rule is exact only when LOD resolves to level 0, so they are not part of this change.
Tested
Windows 11, MinGW-w64 GCC 15.2.0, Release, NVIDIA GeForce RTX 4070 SUPER.
agc_shader_memory_testspasses with the change and fails without it on the new assertion ("an image read through an S# without a mip filter was not flagged as exact at its base level").agc_driver_image_sample_unnormalized_tests,agc_shader_disk_cache_testsandagc_driver_graphics_testspass. Conventions check passes.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 repositoryImported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-15T01:02:58Z.
Ran this on PR head
766f6de92(merge base32421519a, 438 commits behind mainab9a47684).Setup: PR head checked out as-is (not rebased), default CMake build (CMAKE_BUILD_TYPE empty, unoptimized), Linux. The test is CPU-only; no GPU was used.
The test checks the descriptor flag; I did not check rendered output. Main has changed DescriptorBindingBuilder.cpp since the merge base (4 commits), though the old expression is still there, by reading. I did not test the PR rebased onto main. #4943, #5353, #5371, #5609, #5881 and #5958 also touch this file.
Not checked: any title.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:11:10Z.
Some 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/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cppImported from boykopovar/AnyPS5. Originally posted by ymatrix1 on 2026-10-15T19:00:15Z.
Thanks @Dextroid17 for running it and for the mutation check. Reverting the rule and getting the new assertion red 3 of 3 is exactly the proof I wanted the test to give.
On the overlaps the bot listed for
DescriptorBindingBuilder.cpp: I read the two it flags there. #5371 changes the compare and sRGB specialization block inPrepare(and the image metadata flags further down), and #5881 changes the multisampled image-shape helper near the top of the file. My change is one expression inProveUnnormalized, the exactness check for images read through an unnormalized sampler, so neither touches it. I have not read #4943, #5353, #5609 or #5958, so I can't say the same for those.mainstill has the old expression there.The shared
ShaderMemory.cpphits are my ten added test lines in the existing unnormalized-sampler test, which other PRs also extend; if one of them lands first I'll resolve the conflict.Not tested here: a rebase onto current
mainand any game. I verified the sampler semantics on a PS5 (table in the description), and the rule only changes which images the driver binds at their base level. Happy to rebase if a maintainer wants that before review.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T11:13:09Z.
Checked on the HW oracle (T# with 4 levels, unnormalized S# with mip filter none):
image_sample_lz, explicit LOD and implicit LOD all read level 0 for min LOD 0/2/3 and with a LOD bias; with a point mip filter and min LOD 2 level 2 is read, so the old rule stays for that case. The new assertions pass and fail without theDescriptorBindingBuilder.cppchange; scoped build and tests are green. Merging.