fix(shader): read a 2D MSAA T# through image_sample_a as its sample 0 #12561
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12561"
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 milescoviello on 2026-10-28T20:18:56Z.
What
Ghost of Tsushima Director's Cut (PPSA02225 02.024.000) stops in its opening, 10 to 14 minutes into a run (606, 744 and 806 s in three runs here):
The pixel shader samples a two-sample 32-bit float T# (the 1920x2160 checkerboard depth at 0x1544ed0000) through a DIM 2D
image_sample_a: the MIMG word0xf0800109with OPM set, which the decoder reads asimage_samplewithRdnaImageSampleFlagAdjust. thuanquang's0a3ea213e1already reads a DIM 2D sample of a 2D MSAA T# as its sample 0, but only for an image whose accessesResourceTracker::MergemarkscubeFaceCompatible, and that check compares the whole sample flags against 0,LevelZeroandLod. The adjust bit fails it, so no 2D mode reads the T# and the draw throws.How
MergeleavesRdnaImageSampleFlagAdjustout of the flags its plain-sample check compares. An_aform only changes how the tracker reads dword 3 of the S# (canonicalizeSampleAdjustDword3), not the image address, soimage_sample_anow takes the same sample-0 path asimage_sample. That check also feeds the cube-face mode and the 2D-array-through-3D mode, which nothing has measured with_a. SoResourceTrackernow setsadjustedSampleon an image when any of its samples has the adjust bit, andRuntimeImageModesleaves both of those modes out for such an image: animage_sample_athere still throws, as onmain.adjustedSampleis a newImageResourcefield, so the shader disk cache format goes from 49 to 50.The
docs/dev/debt/shader.mdentry for this read namesimage_sample_aand says that the gfx1031 measurement behind it has no_aread.Tested
Linux (Ubuntu 26.04.1, GCC 15.2), RTX 4070 Ti (NVIDIA 615.71.09), on
main319621ba2e:f27177dd9b), which keeps_aout of the cube-face and 2D-array-through-3D modes:agc_shader_memory:image_sample_aof the two-sample T# still selects the 2D mode._aread of a cube T# is refused. The same read without_aselects a cube-face mode.image_sample_aof a 3D T# is refused.^agc_shader_|^agc_driver_sample_multisample_target$|^agc_driver_native_fmask$|^agc_multisample_guest_access$(42 tests,agc_shader_memoryamong them) pass 3 of 3.main319621ba2evsf27177dd9b, one run each:VUID-messages on either side.maindc38224141(merge696f0dd9fd, clean):^agc_shader|^shader_|^agc_driver_sample_multisample_target$|^agc_driver_native_fmask$|^agc_multisample_guest_access$(54 tests) pass 3 of 3.agc_driver_sample_multisample_target: the plane read of the two-sample target throughimage_sample_a(the existing case's MIMG word with OPM set) must return sample 0, like the existingimage_sample_lzread. The test alone onmain(61b0579a3b) fails withimage descriptor is incompatible with the static runtime image interface: descriptor format 71 decodes to {class 1, dim 6, ...}. At1273808212it passes.^agc_shader|^shader_|^agc_driver_sample_multisample_target$|^agc_driver_native_fmask$|^agc_multisample_guest_access$(53 tests) pass 3 of 3.VK_LAYER_KHRONOS_validation1.4.363 from the LunarG SDK, same RTX 4070 Ti), onmain319621ba2eand at1273808212:VK_LAYER_PATH=<sdk>/layers VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest -R '^agc_driver_sample_multisample_target$|^agc_driver_native_fmask$|^agc_multisample_guest_access$' -Vwas not found but was requested by env var VK_INSTANCE_LAYERS.VUID-message (0 onmain, 0 at1273808212).agc_driver_sample_multisample_target, including the newimage_sample_aread, andagc_driver_native_fmask.agc_multisample_guest_accesscreates no Vulkan device.agc_shader_replay --materializeof the request GoT dumped at the stop (shader0x20054f4e00). Onmain319621ba2ethe capture fails with the title's error (descriptor format 22 decodes to {class 1, dim 6, ...}), 2 of 2. At1273808212it materializes 13,180 SPIR-V words, 2 of 2.reading sample 0 of a multisampled depth surface through a 2D image is not implemented. That is the same kind of read, made when a native multisample depth surface lives at the T#'s address. This PR doesn't cover that case; #12612 does.Windows 11 VM (GeForce GT 1030, WinLibs GCC 15.2, Release):
agc_driver_sample_multisample_target,agc_driver_native_fmaskandagc_multisample_guest_accesspass 3 of 3 at1273808212and onmain319621ba2e. Atf27177dd9b, withagc_shader_memoryadded, all 4 pass 3 of 3, and on its base319621ba2etoo.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T20:35:43Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The source change looks narrowly scoped, but the PR does not report the Vulkan-validation runs required for shader-recompiler changes, so I cannot verify the asserted GPU behavior under the repository's test conditions.
What I ran
1273808212c8407ee030e164df7517f6aa896d5eagainst base319621ba2e578bd053b0baba2877fe70520e0737.git diff --check upstream/main...refs/review/pr-12561-current— passed.git merge-tree --write-tree upstream/main refs/review/pr-12561-current— clean, tree9d0cb9dad631c95ce76cb568e2ad10df5eb4c0a5.ResourceTrackerflag predicate and the newimage_sample_atest. I did not run the GPU tests locally.Results
Merge and diff-check output
git diff --checkproduced no output.Negative control
Not run locally. The PR reports a base failure for the new
image_sample_acase and success on the head, but I did not independently rerun that GPU control.Findings
Blocking
mainand the PR withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1, andANYPS5_REQUIRE_VULKAN=1, then confirm the requested layer was found and the change adds noVUID-errors. The PR describes several GPU results and lists hardware, but does not record these required run settings or the validation-log comparison. Please add the exactctest -Vcommands and relevant outputs for base and head, including the requested-layer and VUID checks. I have not found a code correctness blocker in the changed predicate itself.Non-blocking
The current-main merge preview is clean, and the hosted build/policy checks that ran have passed. The report's Windows and title runs are author-provided evidence; I did not reproduce them.
Sources
image_sample_atest invocation at this PR headNot verified
I did not run the focused CTest selection, Vulkan Validation, console behavior, or a full project build. The host has no supported GPU for this test.
To get this to a good state
Attach the same-machine, same-GPU base/head validation runs and confirm the layer-load message is absent and no new
VUID-errors appear. I can then recheck the exact head and supplied outputs.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-28T20:54:40Z.
Review: CHANGES_REQUESTED
The change reads correctly: ignoring
RdnaImageSampleFlagAdjustin thecubeFaceSamplecheck (ResourceTracker.cpp:2197) makesimage_sample_atake the same sample-0 path asimage_sample, and the newAdjustedPlaneCodecase inSampleMultisampleTarget.cpppins it. One thing is missing before it can merge:mainand on this head withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(ctest --test-dir build -R <pattern> -V, same machine and GPU). Please add the commands, confirm neither log containswas not found but was requested by env var VK_INSTANCE_LAYERS, and confirm the head adds no newVUID-errors. Useagc_driver_sample_multisample_target,agc_driver_native_fmaskandagc_multisample_guest_access. You said in your reply to @MarcZX10 that this is queued.Not blocking, but note it in the description: the change also gives
image_sample_athe cube-face and volume-array modes, which the gfx1031 measurement doesn't cover. The debt entry already says so for the 2D read.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T21:14:08Z.
Review: APPROVED
Re-checked — new head, looks good
The missing same-GPU Vulkan-validation evidence is now reported for both
mainand this head, and the focused code change and tests are consistent with the stated sample-0 behavior.What I ran
1273808212c8407ee030e164df7517f6aa896d5eagainst base319621ba2e578bd053b0baba2877fe70520e0737; merge preview clean (9d0cb9dad631c95ce76cb568e2ad10df5eb4c0a5).Results
mainVUID-messagesCommands and output from this review
Negative control
image_sample_apath accepts the two-sample target as sample 0mainwithout this PRI did not run this negative control locally; the result is reported in the PR's test evidence.
Findings
Blocking
None found in the reviewed change.
Non-blocking
_abehavior is not measured.Sources
AGENTS.mdlines 15–16, pinned to current baseResourceTracker.cppSampleMultisampleTarget.cppNot verified
I did not run the Vulkan tests locally, reproduce the offline replay, or run Ghost of Tsushima. The author-reported tests and title runs are described in the PR. macOS jobs were queued, and hosted product Linux/specialized jobs were skipped.
To get this to a good state
No code change is needed based on the reviewed evidence. If the code head changes, I will review the new diff and rerun the same diff and merge checks.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T04:23:48Z.
Review: APPROVED
Reviewed — approved
image_sample_aof a 2D MSAA T# now takes the existing sample-0 plane path. The new test case fails without the tracker change and passes with it, and I see no new validation messages onmainor on this head.What I ran
1273808212c8407ee030e164df7517f6aa896d5e, merged with--no-ffontomainb433c40f2f46aa2e59e19806010a839ac8572d64in a clean worktree. The merge was clean:docs/dev/debt/shader.mdauto-merged.VK_LAYER_KHRONOS_validation.Along with the tests the PR names, I added the cube-face, volume-array and plane tests, because
cubeFaceSamplealso gates those modes (ResourceMaterializer.cpp:2021,:2056).Results
maingit diff --checkcheck_conventions.pydebt-length, see Non-blocking)main)mainVUID-lines, merged /mainwas not found but was requested by env var VK_INSTANCE_LAYERSInsert instance layer "VK_LAYER_KHRONOS_validation"appears for the 9 Vulkan tests in both logs (image_msaa_loadcreates no Vulkan instance)Merged tree, ctest summary
check_conventions.py
Negative control
I restored only
core/shader/recompiler/Optimization/src/ResourceTracker.cppfrommain, kept the PR's test, rebuilt and ranagc_driver_sample_multisample_target. It fails on the newimage_sample_aread, with the error the PR describes:Output
I then restored the PR's file.
Findings
Blocking
None.
On the validation runs that MarcZX10 and adriadam10 asked for: I ran them myself on
mainand on this head, on a different machine from the author's, and they match what the PR now reports.Non-blocking
docs/dev/debt/shader.md:58grows from 995 to 1139 characters, so the conventions check now warns (debt-length, limit 1000). CONTRIBUTING's Documentation section asks an entry to state the gap first and keep only the behaviour the gap needs. The clause explaining why the_aform keeps the address describes behaviour rather than a gap. A shorter version keeps the gap: "…image_sample_lof a direct sampled image, orimage_sample_a(unmeasured: gfx1031 has no_aread); …".ResourceTracker.cpp:2197-2198also lets animage_sample_aget the cube-face mode (ResourceMaterializer.cpp:2056) and the volume-array mode (ResourceMaterializer.cpp:2021). No test exercises_ain those modes. The description and adriadam10's review already note this. These modes are only added to the list (RuntimeImageModespushes extra entries), so no access that worked before changes. Those that threw before now resolve, and the existing cube, volume and plane tests above still pass. A cube-faceimage_sample_acase inImagePlaneAddressOnCube.cppwould pin it; this can be a follow-up.Not verified
_aform on gfx1013. The PR records this as debt; I have no console measurement.agc_shader_replayof the dumped request: I have neither the title nor the dump.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T04:31:39Z.
Review: APPROVED
Re-checked — approved
The new commit
90efd76e2achanges only the docs: it moves theimage_sample_aclause into a debt entry of its own, which resolves thedebt-lengthwarning from my last review. The code and tests are the same as at the head I approved.What changed since my last review
90efd76e2a(docs(shader): give image_sample_a of a 2D MSAA T# its own debt entry). It touches onlydocs/dev/debt/shader.md, andgit diff 1273808212 90efd76e2a -- coreis empty.main(995 characters). The new entrydocs/dev/debt/shader.md:59has 305 characters. It states the gap: the_aread is served as sample 0 and is unmeasured.What I ran
90efd76e2a408560e874872a57bc38b9b91bc295, merged with--no-ffontomainb433c40f2f46aa2e59e19806010a839ac8572d64in a clean worktree. This is the samemainas in my last review. The merge was clean:docs/dev/debt/shader.mdauto-merged.I did not rebuild or rerun tests. No code, test or build file changed since
1273808212, andmainhas not moved, so the merged code is identical to the tree I built and tested last time.Previous findings
check_conventions.pynow printsAll conventions checks passed.The two entries are 995 and 305 characters._ain the cube-face and volume-array modes: Still open, non-blocking, and acknowledged. The author replied that these modes are only added to the list of modes an_aread may take, so nothing that worked before changes. That matches what I found last time, and I accept a follow-up when a title needs it.New findings
Blocking
None.
Non-blocking
None.
Not verified
_aform on gfx1013, the Ghost of Tsushima runs, the offline replay, Windows, and AMD or Intel GPUs.1273808212as the head. The only change since then is the docs commit, so the reported runs still apply to the code.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T10:27:38Z.
Review: APPROVED
Re-reviewed — approved
The head adds only the requested debt-entry split; the production change and test diff are unchanged from the revision I approved. I checked exact head
90efd76e2a408560e874872a57bc38b9b91bc295against currentmainbc3e33f4e334996ab9ba5cbf8544942465be18f3.What I checked
afc9087818406bbb329bc4b8dab3e4bf75c2314f).git diff --checkpasses.python3 tools/check_conventions.py --base refs/review/live-main --head refs/review/upstream-12561passes.image_sample_adebt entry. It now separates the unmeasured_amode from the evidence-backedimage_samplewording.I found no remaining blocker on this head.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-29T22:09:46Z.
Review: CHANGES_REQUESTED
The plane read itself is fine:
image_sample_aalready samples likeimage_samplewith dword 3 of the S# canonicalized, so the 2D MSAA read taking sample 0 is in line with that, and the newAdjustedPlaneCodecase pins it. One thing is broader than the PR needs, though:ResourceTracker.cpp:2197-2198:cubeFaceSamplealso feedscubeFaceCompatiblefor the cube-face mode (ResourceMaterializer.cpp:2081) andvolumeArraySampleCompatiblefor the 2D-array-through-3D mode (ResourceMaterializer.cpp:2046, viaResourceTracker.cpp:2201). With the adjust bit masked,image_sample_anow takes both of those modes as well. No one has measured them, and no title in the PR needs them. The twodocs/dev/debt/shader.mdentries for those modes become false: the 2D-array-through-3D entry (line 79) lists_aamong the samples that throw, and the cube entry (line 81) says onlyimage_sample_lz, plainimage_sample,image_sample_land mip-less loads and stores take that mode. Per "exact or throw", please limit the_arelaxation to the DIM 2D read of a 2D MSAA T#, soimage_sample_astill throws in the cube-face and volume-array modes, and add a test case showing that it does. If you'd rather keep them, those two entries need to say thatimage_sample_atakes those modes unmeasured.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T22:12:15Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
I confirmed the new finding on the unchanged head; my earlier approval was premature because
_ais admitted for cube-face and volume-array shader modes that the PR neither tests nor documents as supported.What I ran
Exact PR head:
90efd76e2a408560e874872a57bc38b9b91bc295. PR base:mainatb433c40f2f46aa2e59e19806010a839ac8572d64; refreshed currentmain:4c8cff191609bc5f28bf9ee2f93672b531285aa4. The current-main merge preview is clean (62a8661c938b040cd692e40a8c49fa6293060a16). Environment: Linux x86_64; no compiler or GPU test run.Results
mainADJUSTflag makescubeFaceSampletrue for_a; that predicate feeds both cube-face and volume-array compatibility. The debt entries still say_athrows for those modes.Exact output from local checks
git diff --checkexited 0 and produced no output.Findings
Blocking
ResourceTracker.cppremovesRdnaImageSampleFlagAdjustbefore decidingcubeFaceSample.ResourceMaterializer.cppuses the resulting compatibility flags to add cube-face and 2D-array-through-3D modes. This means the PR's newimage_sample_aallowance is broader than the tested 2D MSAA plane read. The existing debt entries for cube-face and volume-array access still list_aamong the cases that throw, so both the supported behavior and documented limitation are now inconsistent. Please restrict the relaxation to the intended DIM 2D read of a 2D MSAA T# and add regression checks that_astill rejects the unmeasured cube-face and volume-array modes, or explicitly implement and document those modes with evidence. ResourceTracker at this head, mode generation at this head, debt entries at this headNon-blocking
The focused 2D MSAA sample-0 test and the reported matched validation runs remain useful evidence for the intended case. They do not cover the two newly admitted modes described above.
Not verified
I did not build or run CTest, GPU validation, or console tests. The author-reported GPU validation is not independently reproduced here. Linux and specialized hosted jobs were skipped.
To get this to a good state
Please narrow the compatibility change to the measured/tested 2D MSAA path and add coverage that the cube-face and volume-array
_amodes still throw, or provide tested and documented behavior for those modes. I will re-run the same static checks and merge preview on the new head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T23:16:58Z.
Review: APPROVED
Re-checked — new head, looks good
The updated head narrows the
image_sample_aexception to the tested 2D MSAA path and adds rejection coverage for cube-face and volume-array modes.What I ran
Reviewed exact PR head
f27177dd9b6b6b73d8cf543701230e261f93edb0against baseb433c40f2f46aa2e59e19806010a839ac8572d64; refreshed currentmainisdc38224141e0b6096007b876b4c42fc9144d11b8. The merge preview against currentmainis clean (tree1bacb9bbe3dfdef82c21571116d347f2f3545917). Environment: Linux x86_64; no local compiler, build, or tests run.Results
mainUnedited output from local and hosted checks
The focused test results above are author-reported in the update comment, not a local run.
Findings
Blocking
None found in the updated head. It now sets
adjustedSamplewhen an adjusted image sample is tracked, excludes that image from cube-face and volume-array runtime modes, and adds regression assertions for those two rejected cases.Non-blocking
The new behavior remains unmeasured on console hardware. The author’s GPU tests and current hosted results support the change, while the remaining skipped and pending jobs are listed above.
Sources
Not verified
I did not build or run tests locally, run Linux or macOS product tests, independently reproduce the author’s RTX 4070 Ti results, or test console behavior. The two macOS relinker jobs were pending when checked; Linux and specialized hosted jobs were skipped.