fix(shader): let a re-read nested V#'s words and keys be spilled to VGPR lanes #18106
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18106"
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 hugodearaujo on 2026-11-10T12:42:31Z.
What
This is stacked on #15555 at
77b4696698(and through it on #9969, #9790, #9457, #8939 and #7395).Marvel's Spider-Man 2 (PPSA03016) gets past its VRAM stop with mrfelek's lazy-table prototype (#10195). It then stops at 185-229 s in a compute shader:
It's #15555's shape: a record pointer P, a V# A at P+0x70 (pc 0xa488) whose buffer holds keys, and a V# B at P+0x10 (pc 0xa4b4) whose T# array the key
(A[0x18] >> 16) << 5indexes (pc 0xa5b0). What's new is register pressure. The shader spills the words of both V#s, and some key words, into VGPR lanes withv_writelane_b32:ReadLaneEliminatoralready forwards the restores (v_readlane) to the original values. TheWriteLanes stay, held by the loop's Phis. So:TryMakeTableColumnrefuses B's T# column, because a word of B, its parent, has a user that isn't aGetBufferResource(pc 0xa5b0, above);ChildKeyWordrefuses a key read through A that is spilled, soDescriptorWordReadsrefuses A's handle and the S# column through A (pc 0xa6ac, the next refusal once the first is fixed).The change. When the V# is read again at dispatch (
RereadableVsharp), its words and the key words read through it are the guest's own values, so a lane write of one of them copies a real value.LaneSpillmatches aWriteLanewhose written value (argument 0) is the word:TryMakeTableColumnaccepts it for a re-read V#;ChildKeyWordskips it while it follows a key, when the caller passes the V# as re-read. #15555'ssiblingsparameter becomesrereadable, since both the sibling and the spill rule rely on the V# being read again;DescriptorWordReadspasses it as before, andMatchChildKeykeeps the default.A V# that is not read again keeps the earlier rule. A word used as the lane index, or as the vector written into, stays refused.
docs/dev/debt/shader.mdgets one entry for this, next to #15555's sibling-key entry.Overlap. mrfelek's #16812 (on #9969) makes
DescriptorWordReadsaccept every read through a re-read V#, which would also cover the spilled key words; it drops theChildKeyWordbranch there. It doesn't cover the parent-word check, and neither does #16814, which addsGetAddressResourceusers of those words. #16812 and #15555 already conflict on theDescriptorWordReadsline, so this PR conflicts with #16812 there too (and in the test list and the debt file); whichever lands second resolves it. No open PR handlesWriteLaneusers of descriptor words (searched for the message,WriteLane,writelane, spill,ReadConstBuffer, the pcs, again on 2026-11-10).Tested
Linux 7.2.14, AMD Radeon RX 9070 XT, RADV (Mesa 26.2.6), Release with tests.
agc_driver_pointer_vsharp_sibling_key_spill_table(--pointer-vsharp-sibling-key-spill): #15555'sPointerSiblingKeyCodewith threev_writelane_b32added to the loop body after the sample: B's word 0 (s68), A's word 0 (s52) and the key word (s64) go to lanes 0-2 ofv6, which the shader stores. Assembled withllvm-mc -triple=amdgcn -mcpu=gfx1030; the loop branch moves from -31 to -37 dwords. It runs #15555's checks unchanged: keys 2 and 5, the largest key inside B, swapped S#s, a moved record pointer and keys past B, without a recompile.ResourceTracker.cppchanged, test kept):77b4696698merged withmain22e33e9031: the new test fails withGetImageResource dword 0 is not a valid runtime value; chain: ReadConstBuffer@pc=0x000000b8(GetBufferResource(LoadAddressU32@pc=0x000000a4(..., the title's refusal; #15555's own sibling test passes.caf94d99ce: without the parent-word hunk, the same failure; without theChildKeyWordhunk,GetSamplerResource dword 0 is not a valid runtime value; chain: ReadConstBuffer@pc=0x000000c0(GetBufferResource(LoadAddressU32@pc=0x00000090(..., the shape of the title's second refusal (pc 0xa6ac).VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -V -R '^(agc_driver_(image_table|nested|pointer)|agc_shader_(disk_cache|memory|nested_sampler)|spanned_uniformity|shader_memory_decoder_tolerance)'), each merged withmain22e33e9031:77b4696698: 49 tests, all pass (agc_driver_image_table_vouched_lookupsskips, as on any device that reports written imported pages);VUID-line or "was not found but was requested".tools/check_conventions.pyagainst #15555's head, and againstmainfor the stack: "All conventions checks passed."agc_shader_replay --prepareof the capturedshader_11e2b64b00.prepare.req: #15555 (withmaine7c3bfd130, #15710 and the lazy-table port) refuses atpc=0xa5b0. With this change it plans pastpc=0xa5b0andpc=0xa6acand refuses atpc=0xa88c, a different shape (see below).APS5_LAZY_TABLES=1 APS5_DIAG_TABLE_USAGE=1, onmaine7c3bfd130+ #15555 + #15710 + a local port of mrfelek's lazy-table prototype:GetImageResource dword 0 is not a valid runtime value; chain: ReadConstBuffer@pc=0x0000a5b0(...(a fourth run, withAPS5_DUMP_SHADERS=1for the capture, at 229 s);pc=0xa5b0orpc=0xa6ac. All three stop at the same point, at 214, 216 and 213 s, on the next refusal in the same shader:GetSamplerResource dword 0 is not a valid runtime value; chain: ReadConstBuffer@pc=0x0000a88c(GetBufferResource(LoadAddressU32@pc=0x0000a488(...;On current
main. The head,734a59bbf2, merges #15555's new head215d1820e3(with #9969's78bdc14492andmainbfcd717ebc). With the validation layer andctest -V -R '^(agc_driver_(image_table|nested|pointer)|agc_shader_(disk_cache|memory|nested_sampler|sampler_limits)|spanned_uniformity|shader_memory_decoder_tolerance)'on the RX 9070 XT, it gives 59 tests: 58 pass andagc_driver_image_table_vouched_lookupsskips. Onmainbfcd717ebcthe same command gives 45 tests: 44 pass and the same skip. No log has aVUID-line or "was not found but was requested".Runs by others.
ctest -R '^(agc_driver_nested_.*|agc_driver_pointer_.*|agc_shader_memory.*)$', 2 runs on each side.main3eb7a74e1c(the merge base): 4 tests, all pass.284a1fd4fb: 22 tests, all pass, #15555's andagc_driver_pointer_vsharp_sibling_key_spill_tableincluded. NoVUID-line, and the layer was found.ImageTable.cppand test CMake file on #15555's head77b4696698: the new test fails 2 of 2 withGetImageResource dword 0 is not a valid runtime value, and #15555'sagc_driver_pointer_vsharp_sibling_key_tablepasses.284a1fd4fbmerged ontomain, Windows 11 Enterprise 22621, RX 6700 XT (AMD driver 26.10.1), MinGW-w64 GCC 15.2 UCRT, Release. The 74 tests ofagc_shader_disk_cache_tests,agc_shader_memory_tests,agc_driver_bda_anchor_reads_testsandagc_driver_image_table_testspass 3 of 3 on the GPU, none skipped.284a1fd4fbmerged ontomainb8194198cf, CachyOS (Linux 7.3.1), GCC 16.2.1, Release, compared withmainon the same machine,ctest -R '^(agc|video_out|shader)'. On an RTX 3070 Ti (NVIDIA 615.78.08) and an Intel UHD Graphics 630 (Mesa 26.2.6, ANV): no difference frommain, and the 19 new tests pass. No validation layer there.2c75702742merged ontomaine1ab104e0a, Arch Linux, RTX 4090 (NVIDIA 620.70.06), GCC 16.2.1, Release, validation layer 1.4.363.1, the command above.main40 of 40, this PR 59 of 59,agc_driver_pointer_vsharp_sibling_key_spill_tableincluded; no skip, noVUID-line, and the layer is inserted.Not in this PR (#18107): the title's next refusal, at
pc=0xa88c, is two S#s (A+0x90 and A+0xa0) read by ones_buffer_load_dwordx8through A's handle.TryMakeTableColumnrequires every read of the parent handle to be a word of the one descriptor it plans, so each S# is refused for the other's reads. Accepting reads whose users are only descriptors or lane spills takes the replay pastpc=0xa88ctopc=0x1149c, a record pointer whose Phi has an arm read at P+0x1b0 through a V# loaded at P'+0x20 (#9633's conditional chase).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)pc=0xa88candpc=0x1149csteps too)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T06:15:55Z.
Review: COMMENTED
Reviewed — comments
The prepared description reports broad GPU and validation testing, but I could not verify the full change or those runs from the available reader output.
What I ran
No test or build commands were run. I read the PR description, commits list, the first 400 lines of the manifest, and portions of the diff at head
ef0cd48fbba606d9c6645de9b89383463e8437c1.Results
Findings
Blocking
None verified.
Non-blocking
The review is incomplete; the source and test changes need inspection before a formal approval decision.
Not verified
The manifest is 2,175 lines and was only read through line 400. The diff is 2,779 lines and was only read through line 500 and lines 2,000–2,779; intervening changes were not inspected.
ShaderMemory.cppis excluded from the prepared files because it is too large, and its relevant source was not read. The reader invocation was unavailable, so I could not run the requested targeted repository searches or tests. I did not independently verify the author-reported GPU, validation-layer, or negative-control runs.To get this to a good state
Nothing is required. Optional: complete targeted inspection of the remaining changed code and verify the reported checks before approval.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T11:31:58Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the inspected implementation and reported validation support merging, with one changed test file excluded from the review bundle.
What I ran
Reviewed head
734a59bbf2477404fbe717c364eae4cfad400ab6. No commands or tests were run in this read-only review; the description’s test results are author-reported.Results
Findings
Blocking
None in the inspected code.
Non-blocking
None.
Sources
Not verified
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded from the review bundle because it was too large; only the targeted changed ranges were read throughrepo_read.py. Other changed files and hunks outside the targeted ranges were not read. Runtime behavior, builds, and reported test runs were not independently verified. The other changed files reviewed wereShaderDiskCache.cpp,agc_driver_image_table_tests.cmake,BdaAnchorReads.cpp,ImageTable.cpp,ImageTableAbi.hpp,ControlFlowInfo.hpp,ResourceMaterializer.cpp,ResourceTracker.cpp,ShaderDiskCache.hpp,SpirvEmitterState.hpp,SpirvBdaRead.cpp,SpirvMemoryInstructions.cpp, anddocs/dev/debt/shader.md.To get this to a good state
Nothing is required. Optional: include the excluded
ShaderMemory.cppchanges in a reviewable bundle.Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:35:47Z.
Review: COMMENTED
The trial merge onto
c1601e56d5conflicts in the image-table test source and registration and inShaderDiskCache.hpp. Please keep both lane-spilled descriptor words and lane-spilled keys in the focused check. Reusing the right descriptor with the wrong key can still select the wrong image. Reconcile cache format changes before running the composed shader-memory and BDA-anchor controls. Move the direct shader debt edit into a fragment.AI-assisted: yes.
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.