fix(shader): sample a single-texel image with any sampler that keeps X and Y addressing inside #22602
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22602"
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 JJenkx on 2026-11-17T23:01:36Z.
What
A 1x1 single-level image returns its one texel whatever the sampler says, as long as the sampler's X and Y addressing does not read the border. Games use such images as placeholders and sometimes pair them with sampler words that are not a sampler at all. Spirit of the North: Enhanced Edition (PPSA02306) samples its 1x1x1 placeholder volume through, among others,
938cfd00 00100010 0000002d 0004dfacandc3218858 00100010 00000003 0004dfac(buffer descriptor words) and10049900 03800000 00000000 a0500f2e(the image's own T# words). Read as samplers these are unnormalized, some with max reduction, and the driver refused them (requires a normalized point sampler,unknown reduction filter mode,unnormalized coordinates with MC_COORD_TRUNC).materializeSingleTexelSamplers(next tomaterializeForcedDegamma, after the snapshot is materialized) replaces a direct sampler's words with a normalized point clamp-to-last-texel sampler (00000092 0 0 0) when:The rewrite preserves FORCE_DEGAMMA and SKIP_DEGAMMA. Anything else keeps the guest sampler. Doing it in the snapshot means the binding plan key, the unnormalized proofs and the Vulkan sampler all see the same words.
Hardware measurement
tools/hw-oracleon an RX 6650 XT (gfx1032, RDNA2, Linux 7.2.14, hsa-rocr 10.1, clang 23.1.5; wave32, IEEE off, DX10 clamp on, denormals preserved, round to nearest even, FP16 overflow off). A 1x1 8_8_8_8_UNORM texel(40, 120, 200, 255)read through a 1x1 2D T# and a 1x1x1 3D T#,image_sampleandimage_sample_lzDIM 2D, 12 coordinates: (0.25, 0.25), (0.5, 0.5), (0.9, 0.1), (0, 0), (0.999, 0.999), (1.5, 0.5), (0.5, 1.5), (-0.3, 0.7), (3.7, -2.2), (100.25, 7.5), (-0.001, 0.5), (1, 1).00000092 00fff000 06500000 0(bilinear, linear Z)938cfd00 00100010 0000002d 0004dfac(PPSA02306, buffer words)920bd300 00100010 0000002d 0004dfac(PPSA02306, buffer words)10049900 03800000 00000000 a0500f2e(PPSA02306, image words)00008600 00fff000 09f00000 0(unnormalized, anisotropic, wrap)00000692 00fff000 0af00000 0(anisotropic, linear mips)00008049 00fff000 05500000 0(unnormalized, mirror, bilinear)00088092 00fff000 05500000 0(unnormalized, MC_COORD_TRUNC)20000092,40000092,60000092 00fff000 06500000 0(min, max, undefined reduction 3)60008000 00100010 0000002d 0004dfac(unnormalized, reduction 3)000081b6 00fff000 05500000 0and600081b6 ...(border X and Y)This is an RDNA2 measurement, not PS5/gfx1013 evidence.
Tested
Linux 7.2.14, Ryzen 9 7950X, RX 6650 XT, RADV (Mesa 26.2.7), GCC 16.2.1, Release,
ANYPS5_ENABLE_SPIRV_TOOLS=OFF.agc_driver_image_single_texel_any_sampler: draws a 1x1 2D image and a 1x1x1 volume through six of the samplers above (two PPSA02306 buffer-word samplers, its image-word sampler, unnormalized anisotropic, anisotropic with linear mips, unnormalized reduction 3) and requires every pixel to be the texel; a 2x1 image with the unnormalized anisotropic sampler is still refused. WithmaterializeSingleTexelSamplersdisabled the test fails on its first sampler (unnormalized coordinates with MC_COORD_TRUNC).ctest -R "single_texel|single_level_volume|^agc_shader_memory|unnormalized": 5 of 5 pass.main8a1f57ac1485and this branch (based on68071834eeb4), alternating, 70 s each, Cross every 15 s from 30 s:main3,127 and 3,312 frames, this branch 3,325 and 3,310; all exit 0. PPSA01886 (3,917 frames) and PPSA02664 (3,620) also exit 0. Frame counts are not a performance claim.buffer descriptor uses an unsupported type) and still stops at 16 s in others, on a reduction-3 sampler that is not paired with a single-texel image. So this does not unblock the title.Independent validation reported by domx4q on RTX 4090, NVIDIA 620.70.06: 5/5 focused tests passed; the new single-texel sampler fixture failed in both negative-control runs with main’s ResourceMaterializer.cpp. Khronos validation was loaded for the GPU cases; no VUID errors were reported. These are contributor-reported results.
Latest test-only update,
3766e0cb59def: adds a sample andimage_get_lodsharing a 1x1 image/sampler, a normalized rendering control, and the exact unnormalized-query refusal. On Linux 7.3.5/RX 6650 XT/RADV Mesa 26.3.1 with validation 1.4.363, the PR passes all seven focused CTest invocations. Main0d1dfba9eca0with the identical fixture passes the LOD-only case and five shared cases; its full matrix has the expected existing sampler refusal. Removing only!image.lodQueriedmakes the new case fail in both wrappers, while the five shared cases pass. All 21 invocations loaded validation and reported no VUID/synchronization hazards. The final CMake-only rename was separately configured; the executed C++ fixture is unchanged. Exact heads, controls and downloadable evidence. Conventions pass; the debt checker reports two unchanged libkernel fragment-selector errors.Independent Windows follow-up reported by Helldiverr: on an AMD Radeon AI PRO R9700, driver 32.0.31044.16, Windows 11 and Khronos validation 1.4.363, head
3766e0cb59merged onto main47e83fc147as121e5709b6passed all seven focused tests in three runs. Removing only!image.lodQueriedmade both wrappers of the new LOD query case fail in all three runs because the unnormalized draw was no longer refused; the other five tests passed. The reviewer verified actual validation-layer insertion and reported no VUID or synchronization hazards. This closes the earlier missing LOD-query coverage on that Windows driver; it is contributor-reported synthetic-test evidence, not console or title-unblocking evidence.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T02:26:16Z.
Review: APPROVED
Reviewed — looks good
Nothing in the inspected changes demonstrates a blocking defect; focused test results and hardware measurements were supplied by the author and were not run in this review.
What I ran
78c7e4e10800a62c09c0af83fbe1a3c7b7faa14from the prepared bundle usingrepo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
files.jsonwas not available through the reader interface; the manifest lists seven changed files, and all seven were read. No excluded-file list was inspected.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T08:06:51Z.
Review: APPROVED
Reviewed — looks good
The change is sound at head
49650f75329ad4a0d6d66741052f9faa9dadd008; the focused behavior and cache metadata changes inspected are consistent, and no blocking defect was found in the files reviewed.What I ran
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T12:18:29Z.
Review: APPROVED
Reviewed — looks good
The change at head
3766e0cb59def45412c85a48cb48beae0b989500guards the sampler rewrite against LOD queries and includes focused coverage; I found no blocking defect in the changed files I read.What I ran
I reviewed the prepared diff and all seven changed files listed in the manifest using
repo_read.pyat the pinned head. I did not run tests or other commands; the reported test and hardware results below are author supplied.Results
Negative control
Not run by me. The author reports that removing the LOD-query guard caused the new LOD-query case to fail on AMD Linux and Windows test environments.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
I did not independently run tests, validate performance, or verify PS5/gfx1013 behavior.
review/files.jsonwas unavailable; the manifest lists seven changed files, all included and read. The full text of each changed file was read:core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_image_single_texel_any_sampler_tests.cmake,core/libs/prx/libSceAgcDriver/tests/execution/ImageSingleTexelAnySampler.cpp,core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hpp,core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp,core/shader/recompiler/Optimization/src/ResourceTracker.cpp,core/shader/recompiler/ShaderDiskCache.cpp,core/shader/recompiler/ShaderDiskCache.hpp, anddocs/dev/debt/changes/fix-agc-single-texel-image-any-sampler.md(eight paths).To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-26T21:50:50Z.
Review: COMMENTED
Actionable comments posted: 1
37a73628-31f3-4181-884e-a2593fcd7b77Reviewing files that changed from the base of the PR and between
ac75555824and52615a4e1f.core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_image_single_texel_any_sampler_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/ImageSingleTexelAnySampler.cppcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/Resources.hppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppdocs/dev/debt/changes/fix-agc-single-texel-image-any-sampler.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T22:27:21Z.
Review: APPROVED
Reviewed — looks good
The change implements single-texel sampler materialization with exclusions for LOD queries and adds focused coverage; no verified blocking defect was found in the reviewed code.
What I ran
Reviewed head
52615a4e1fe7387424756a06aa9841492a695e0eusing the prepared diff and pinned reader. No tests were run. Read all changed lines in the nine files listed underreview/README.md; no changed files were excluded.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Build and runtime tests were not run in this review. Hardware and title behavior are based only on contributor-reported results.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T10:37:02Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected implementation and reported focused checks support the stated single-texel sampler behavior.
What I ran
Read the prepared diff and all nine changed files at head
011409e779197cf54c3b7b60cc753b3ddb559adcusingrepo_read.pytools. No commands or tests were run in this review; test results below are reported by the PR author and contributors.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests were run independently. The described RX 6650 XT and other contributor-reported test runs were not independently verified; PS5/gfx1013 behavior and the title's end-to-end progress remain unverified.
files.jsonwas not available as a review document; the manifest lists all nine changed files as included, and each was read.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T18:27:11Z.
Review: COMMENTED
Actionable comments
c1b7f731-bcdd-4dce-a443-ecea03f6a9c0Reviewing files that changed from the base of the PR and between
011409e779and0b5d7b47a3.core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T18:35:58Z.
Review: COMMENTED
The rewrite applies only when every sampled pair for the sampler passes the single-texel checks. The new LOD-query marker prevents a sample that shares a sampler with
image_get_lodfrom changing that sampler's behavior, and the disk-cache changes carry that marker across a reload. The fixture checks the LOD-query refusal alongside the 2D and one-slice successes, degamma, and the two-texel refusal.The local merge of
0b5d7b47a3ontoa9cbd48cb0was clean. The scalar-buffer, LOD-bias, and shader-disk-cache cases passed on both arms on Linux lavapipe (LLVM 19.1.7, subgroup 8). Both change-only cases,agc_driver_image_single_texel_any_samplerandagc_driver_image_single_texel_lod_query_sampler, failed on the shared normalized sampler case withpixel 20 component 3 is 255, expected 0. Could you check how the LOD-query control writes alpha there? All three verbose logs show Khronos validation 1.4.369 inserted with zero missing-layer orVUID-messages. Hardware coverage is from the runs linked in the PR.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T19:05:39Z.
Review: APPROVED
Reviewed — looks good
The implementation confines sampler replacement to eligible single-texel images, preserves degamma flags, and excludes images used by LOD queries.
What I ran
Reviewed head
0b5d7b47a319cab5a4642c5134580787eaca46c8. No tests or build commands were run. I used the pinnedrepo_read.pyreader for source context.Results
Negative control
Not run by this reviewer. The description reports contributor-run negative controls for the LOD-query case.
Findings
Blocking
None.
Non-blocking
None.
Sources
ImageQueryLod, and that flag participates in the replacement guard. ResourceTracker.cpp at the reviewed headNot verified
Read all changed hunks in the nine files listed under
files.json→reviewed;files.jsonlists no excluded files. Also read pinned reader context inResourceMaterializer.cpp,ResourceTracker.cpp, andCMakeLists.txt. Runtime behavior was not independently tested here; the reported GPU tests and hardware observations are contributor-reported, not reviewer-run. No PS5/gfx1013 measurement was verified.To get this to a good state
No follow-up is required.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.