fix(shader): plan several descriptors read by one load through a re-read nested V# #18107
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18107"
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:47Z.
What
This is stacked on #18106 (lane spills of a re-read nested V#'s words and keys), and through it on #15555, #9969, #9790, #9457, #8939 and #7395.
With #18106, Marvel's Spider-Man 2 (PPSA03016) gets past
pc=0xa5b0andpc=0xa6acand stops at the first dispatch of the same compute shader, at the next refusal:The V# A at P+0x70 (pc 0xa488) is the one #18106 already handles. Here one
s_buffer_load_dwordx8through A reads two S#s, A+0x90 and A+0xa0, and spills every word:#9790 plans several T#s or S#s from one V#, but only when each comes through its own buffer handle:
TryMakeTableColumnstill requires every read through the child's handle to be a word of the one descriptor it plans. With one wide load, each S# is refused because of the other's four words.The change (
ResourceTracker.cpp):RereadableVsharp). The handle then goes through the check #9790 and #15555 already apply to a V#'s other handles: every read through it is aReadConstBufferwhose value feeds a T# or S# (#9790), or a key word (#15555). Each descriptor is planned at its own offset, and both share the one parent column. A V# that is not read again keeps the old rule.reads. They are now taken from the handle's own uses, so a read through the shared handle that no column consumes (a key word, or a word that also feeds a lane spill) reads the guest's V# instead of the rewritten handle. For the handles accepted before, the two sets are the same, since all their reads were in the one column'sreads.docs/dev/debt/shader.mdgets one entry for this, next to #18106's.Overlap: no open PR changes this check. The
heapHandle->Uses()line is the same on #7395, #8939, #9457, #9633, #9749, #9790, #9969, #14853, #14904, #16472, #16631, #16812, #16814 and #17863 (searched for the message,0xa88c,s_buffer_load_dwordx8, two or several S#s, one handle, again on 2026-11-10). #16812 and #16814 touch the next lines of the same function, so they conflict with this PR as they do with #18106.Tested
Linux 7.2.14, AMD Radeon RX 9070 XT, RADV (Mesa 26.2.6), Release with tests.
ImageTable.cpp), assembled withllvm-mc -triple=amdgcn -mcpu=gfx1030 -mattr=+wavefrontsize64:agc_driver_pointer_vsharp_sampler_pair_table(--pointer-vsharp-sampler-pair): #9790's shared-V# shader with ones_buffer_load_dwordx8at +0x20 of the V# behind the record pointer reading two S#s, each sampling the T# at +0x0 (one PointWrap, one PointClamp). Both samples are checked per lane through the taken records, swapped S#s, a moved record pointer and a moved V#, without a recompile.agc_driver_pointer_vsharp_sampler_pair_spill_table(--pointer-vsharp-sampler-pair-spill): the same with each S#'s word 0 also written to lanes 0 and 1 ofv6(v_writelane_b32), the title's shape. The lanes are checked too: they hold the S# words of the last waterfall iteration's V#, including after the swap. On a device whose subgroup is narrower than 32 lanes, such as lavapipe's 8, the lanes aren't checked, and the texels still are. With no spanned wave there, each host subgroup runs its own pass of the wave64 waterfall, andv_writelane_b32to lane 0 or 1 writes lanes 0 or 1 of every host subgroup (EmitWriteLanecompares withSubgroupLocalInvocationId).main'sagc_driver_write_laneskips below a wave32 for the same reason.agc_driver_pointer_vsharp_sibling_key_wide_table(--pointer-vsharp-sibling-key-wide): #15555's sibling-key shader with the key word (+0x14) and the S# (+0x20) read by ones_buffer_load_dwordx8at +0x10 instead of two loads. #15555's checks run unchanged.ResourceTracker.cppchanged, tests kept):main22e33e9031: all three new tests fail withGetSamplerResource dword 0 is not a valid runtime value; chain: ReadConstBuffer@pc=0x000000a4(GetBufferResource(LoadAddressU32@pc=0x00000090(...(the sibling-key one atpc=0x0000009c), the title's refusal.caf94d99ce), without the rewriting hunk (2): the two S#-pair tests pass, and the sibling-key one faults ("keys 2 and 5 ... faulted"): its key word is read through the rewritten handle.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:agc_driver_image_table_vouched_lookupsskips (the device reports written imported pages);VUID-line or "was not found but was requested".tools/check_conventions.pywith this title and description, against #18106 and againstmain: "All conventions checks passed." (exit 0).agc_shader_replay --prepareof the capturedshader_11e2b64b00.prepare.req: #18106 refuses atpc=0xa88c. With this change it plans past it and refuses atpc=0x1149c,GetImageResource ... ReadConstBuffer@pc=0x0001149c(GetBufferResource(LoadAddressU32@pc=0x00011368(GetAddressResource(Phi(... ReadConstBuffer@pc=0x00010618 ...: a V# behind a pointer that a conditional chase replaces (#9633's shape). With #9633f086739418merged on top, the request prepares (2,240,230 SPIR-V words).APS5_LAZY_TABLES=1 APS5_DIAG_TABLE_USAGE=1, onmaine7c3bfd130+ #15555 + #15710 + #18106 + a local port of mrfelek's lazy-table prototype (#10195):GetSamplerResource dword 0 is not a valid runtime value; chain: ReadConstBuffer@pc=0x0000a88c(...;pc=0xa88c. All three stop at the same dispatch (201, 145 and 143 s; the dispatch came earlier in the last two runs) on the next refusal,GetImageResource dword 0 is not a valid runtime value; chain: ReadConstBuffer@pc=0x0001149c(GetBufferResource(LoadAddressU32@pc=0x00011368(..., #9633's shape;APS5_DUMP_COMPUTE_PIPELINESand built alone, reaches a 12 GB limit in 10 s; it makes 2,719record_bda_faultand 1,831read_bda_spancalls, the shape of #13538. That is outside this PR.On current
main. The head,8733208620, merges #18106's new head734a59bbf2(#15555's215d1820e3, #9969's78bdc14492,mainbfcd717ebc). Its lavapipe commit,ebca9fd5ad, checks the spilled lanes only where the host subgroup holds 32 lanes or more: on lavapipe (Mesa 26.2.7, subgroup 8),agc_driver_pointer_vsharp_sampler_pair_spill_tablefailed 3 of 3 before it and passes 3 of 3 with it, and on the RX 9070 XT it runs the full check. 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 62 tests: 61 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.*)$', 3 runs on each side.main3eb7a74e1c(the merge base): 4 tests, all pass.01dc143652: 25 tests, all pass, #15555's and #18106's included. NoVUID-line, and the layer was found.ImageTable.cppand test CMake file, 2 runs each: on #18106's head284a1fd4fb, the three new tests fail 2 of 2 withGetSamplerResource dword 0 is not a valid runtime value, and #18106's and #15555's sibling-key tests pass; on #15555's head77b4696698, the same three fail, and so does #18106'sagc_driver_pointer_vsharp_sibling_key_spill_table.01dc143652merged ontomain, Windows 11 Enterprise 22621, RX 6700 XT (AMD driver 26.10.1), MinGW-w64 GCC 15.2 UCRT, Release. The 77 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.01dc143652merged 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 22 new tests pass 3 of 3 alone. No validation layer there.ebca9fd5adagainst its merge basemain6db6a3e927, RTX 3070 (NVIDIA 610.57.04, subgroup 32) and lavapipe (Mesa 25.0.7, subgroup 8), Debian 13, GCC 13.3.0, Release, validation layer 1.4.335. It builds with GCC.agc_driver_pointer_vsharp_sampler_pair_spill_tablepasses 50 of 50 on both: the RTX 3070 checks the spilled lanes, and lavapipe skips them. The validation selection passes 3 of 3 on the RTX 3070: 39 tests onmainand 61 here, 22 of them new. NoVUID-line, and the layer is inserted in every log.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=0x1149c)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T06:15:14Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the description and inspected code support the shared-handle re-read behavior, while this review did not run the reported tests.
What I ran
Reviewed head
7781fb42efb44a1933047bdf399f5d3d253e1d64usingrepo_read.pyto inspect the prepared description, commit list, manifest, diff, changed source, and targeted tests. No build or test commands were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The oversized changed file
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas not read. Other changed files were not individually reviewed; in particular, runtime materialization, SPIR-V emission, disk-cache compatibility, and test execution are not verified. The reported test runs were not independently reproduced.Files read:
review/description.md,review/commits.md,review/manifest.json,review/diff.patch,core/shader/recompiler/Optimization/src/ResourceTracker.cpp,core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp,core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_image_table_tests.cmake, andcore/shader/recompiler/Optimization/src/ResourceMaterializer.cpp.Files excluded by the bundle:
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp(too large). The manifest lists additional changed files that were not read.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T11:30:25Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change based on the code inspected; approval is not justified because the broad change is not fully reviewed.
What I ran
8733208620d2d41becf473f2ea87536712ada300.ResourceTracker.cpp,ResourceMaterializer.cpp,ImageTableAbi.hpp,SpirvBdaRead.cpp, and the excludedShaderMemory.cppthroughrepo_read.py.Results
Findings
Blocking
None in the code inspected.
Non-blocking
None.
Not verified
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded fromfiles/as too large; only its changed ranges and targeted context were read throughrepo_read.py.To get this to a good state
Nothing is required. Optional: run the reported validation selection and build against this exact head, then review the remaining changed code before making a formal approval decision.
Files read:
description.md,commits.md,manifest.json,diff.patch,ShaderMemory.cpp(targeted ranges),ResourceTracker.cpp,ResourceMaterializer.cpp,ImageTableAbi.hpp, andSpirvBdaRead.cpp. The other changed files listed inmanifest.jsonwere not read in full;ShaderMemory.cppwas excluded from the preparedfiles/folder.Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:35:45Z.
Review: COMMENTED
The trial merge onto
c1601e56d5conflicts in the image-table test source and registration and inShaderDiskCache.hpp. I verified that this exact head contains #18106. Please retain the case where one vector load supplies distinct sampler descriptors, including distinct keys after the spill. A single-sampler fixture can pass while the new planning still conflates two read consumers. Reconcile the schema and move the direct shader debt edit into a fragment on the resolved head.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.