fix(shader): let a word of a V# read again at dispatch feed a pointer #16814
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16814"
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 mrfelek on 2026-11-07T16:58:23Z.
What
This is stacked on #16812, which is stacked on #28483 (#9457 merged with
main) and carries #9790 and #9969. PPSA03671's compute shader0x11d049aa00walks linked records: the V# at P+0x10, loaded through the record pointer P, is both the buffer of a T# array and, through its words 0 and 1, the next record pointer:TryMakeTableColumnrefuses a parent V# word whose user isn't aGetBufferResource.The change: when the V# is read again at dispatch (
RereadableVsharp), its words are the guest's own. So a word of such a V# may also feed aGetAddressResource, directly or throughPhis only (PointerWordUser). The pointer it forms is planned on its own wherever it's used. A V# that is not read again keeps the earlier rule.docs/dev/debt/shader.mddrops V# words used as a pointer from the refused case, which now reads: data reads or pointer words of a V# not read again at dispatch.Tested
Linux 7.3, RTX 3080 Ti, NVIDIA 615.71.09, Release.
RunPointerSharedVsharpTests,agc_driver_pointer_vsharp_linked_table:PointerSharedVsharpCodewith a few instructions added (assembled withllvm-mc -mcpu=gfx1030). After the V# is loaded through the record pointer P, the next pointer is P or the V#'s words 0 and 1, chosen per group by a key bit. As_load_dwordat that pointer + 0x10 goes to the blue channel.PointerWordUserrule, it fails withGetImageResource dword 0 is not a valid runtime value.^(agc_driver_(image_table|nested|pointer)|agc_shader_(disk_cache|memory|nested_sampler)), withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -V, on this branch at2febe6158e, which holds #28483 andmain93d64f2d1e(59 tests), and onmain93d64f2d1e(50 tests). Each ran on the RTX 3080 Ti (twice on this branch) and on a Radeon 780M (RADV, Mesa 26.0.8, Linux 7.0). All pass on both GPUs, the loader log shows the layer loaded, and no log has aVUID-line.VK_ADD_LAYER_PATH, on this branch at2febe6158e(61 tests on each GPU) and onmain93d64f2d1e(52). All pass on both GPUs with noVUID-line, except on the Intel GPU, where #9969'sagc_driver_pointer_vsharp_child_key_arm_tablefails, as it did when reported on #9969 in November (comment); the RTX A2000 passes it.agc_driver_image_table_vouched_lookupsskips on the Intel GPU onmainas on this branch.0x11d049aa00is planned and runs, and the title reaches its first scene (the forest, then the Screen Reader dialog) about 2 minutes in. That tree is not a review base.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 coptergui-ops on 2026-11-07T20:15:49Z.
Review: APPROVED
Reviewed against head
50f4f71c72; the recompiler change is coherent across all five sites the rule touches.PointerWordUserlets a word of a reread V# feed aGetAddressResourcethrough Phis only, and the walk requires both record words to have real reads (!lowReads.empty() && !highReads.empty()), rejects edges whose low and high halves are both constants, andWrittenThroughrefuses any write/atomic through the same V# — matching the rewritten debt entry's "data reads or pointer words of a V# not reread at dispatch" wording.ApplyToProgramthen copies the buffer handle for the consumers that are not planned table reads, so the original reads stay live for the dispatch re-read.ScalarAddressDwordnow dword-aligns the base before adding the offset, and the same alignment appears in both SPIR-V sites (baseLow & ~3forScalarAddressinGuestAddressBase, and the newdwordOffsetanchor field used byAnchoredBdaRead). Three sites consistent, and the updated tests recompute correctly:aligned(0x1001)+0x20 = 0x1020,aligned(0xfffffffffffffff1)+0x8+4 = 0xfffffffffffffffcand the +8 wrap rejected. The behaviour change is real: main poisoned an unaligned pointer, head reads the records at its dword — thepointer image tabletest block was updated in the same direction, so the test tracks the change rather than rubber-stamping main.KeyDomain,ChildKeyWordOfnormalising AND/shift/AND order into one shift+mask pair, the child branch inTableSnapshotter::Narrow...reading(word >> shift) & maskfrom the parent record) is the new debt bullet about the child T#/S# keyed by its own V# word. Decode validationpointerKeyed && (!indirect || buffer || parent)rejects malformed cached plans, and the plan encoder bumps tags (81→82, 13→22), sizes and field counts in the static_asserts, with a new pointer-keyed round trip inverifyPlanRoundTrip.ImageTableAbi::Version3→4 andFormatVersion57→73 invalidate old disk-cache entries — full recompile cost is expected for a changed resolution ABI.python3 tools/check_conventions.py --base origin/main --head pr-16814reports "All conventions checks passed" on this machine, so debt lengths, links and the unknown-NID checks are clean.GetImageResource dword 0 is not a valid runtime value) is a genuine negative control for exactly this feature.Depends on: #16812line covers the immediate parent; #16812 in turn declares #9969.No blocking findings.
Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-07T21:03:59Z.
Review: COMMENTED
Windows run of head
50f4f71c72, the platform and the Intel cell the description doesn't have. Merged ontomain6b733c4ef2(clean), withmainfrom the same build directory as the control. Windows 11 x64, WinLibs GCC 15.2.0 r7, Release,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest -R '^(agc_driver_(image_table|nested|pointer)|agc_shader_(disk_cache|memory|nested_sampler))', 3 runs per GPU.main(17 tests)agc_driver_pointer_vsharp_child_key_arm_tablefailsagc_driver_pointer_vsharp_linked_tablepasses in every run on both GPUs.agc_driver_image_table_vouched_lookupsskips on the Intel iGPU, onmaintoo.VK_LAYER_KHRONOS_validation.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T04:41:06Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional, and the event stays COMMENT because the build and tests were not run here and no changed file was read in full.
What I ran
d93a2073a9fd0a3b12ff5a2290f503a48e1496e4, basemain. No merged-preview check.reviewedwere read.core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppis too large for the review folder and was not read.Results
static_assertvalues read, not compiledFindings
Blocking
None verified.
Non-blocking
core/shader/recompiler/Optimization/src/ResourceTracker.cpp:1066: a pointer word of a V# that is read again at dispatch is accepted even when the shader stores through that V#.ChildKeyWordrefuses that case throughWrittenThrough, and this gate does not. Possible failure (PLAUSIBLE, not reproduced): the shader stores a new pointer into the record; dispatch rereads the word and forms a different pointer. An uncaptured pointer faults. A captured one selects a child snapshot taken before the store. The entry indocs/dev/debt/shader.mddescribes this staleness for T# and S# words, not for pointer words.Not verified
d261191988merged ontomain7dd6d510da(48 tests) andmainb5a9a4781c(29 tests). None of them is the review head, so no test result here applies tod93a2073a9fd.reviewedwas read only as diff hunks, plus the three reader ranges above.ShaderMemory.cppwas not read at all.RereadableVsharp, the memory index of a read is used without a range check. I did not confirm that every parent read is range-checked upstream.ResourceTracker.cpp(PointerRecordPairs,Precedes,ChildKeyWordOf) was traced only through the diff.static_assertvalues were checked by arithmetic, not by compiling.To get this to a good state
Nothing is required.
Optional: run the focused tests on
d93a2073a9fd0a3b12ff5a2290f503a48e1496e4, since the reported runs were on other revisions. Also decide whether the pointer-word gate should refuse stores through the V# (see the non-blocking finding), or whether the debt entry should name the pointer case.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T13:14:57Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
3ed520f9ba, base main. Read the description, commit list, manifest, file list and the full diff (2,645 lines) from the review folder. No build, no test run.Results
Findings
Blocking
None verified.
Non-blocking
core/shader/recompiler/Optimization/src/ResourceTracker.cpp:1411callsPrecedes(defined at line 1250) once for each candidate read and table argument on the pointer-keyed path. Each call walks the block graph from the entry, so the work is blocks × candidates per plan. This is compile-time only and I have not measured it. A dominance set computed once per program would avoid the repeated walk.Not verified
verifyNestedSnapshotRetry,verifyScalarAddressRule,verifyPointerImageTable) and their call sites were not read.static_assertsizes and field counts in ShaderDiskCache.cpp (DescriptorSource 224, TableColumn 120, KeyDomain 24). Not compiled.ScalarAddressDwordin ImageTableAbi.hpp now aligns the base before adding the offset. Its callers outside the diff were not traced.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T18:48:12Z.
Review: COMMENTED
Reviewed — comments
Nothing blocks this review, but I can’t justify a formal approval because the test suite was not run and one changed file was only partially inspected.
What I ran
0f13ab52edd8162cdfd1ee485b8b662159866500against the prepared diff; no commands or tests were run.description.md,commits.md,manifest.json,diff.patch,README.md, all changed lines in the included files, and targeted ranges fromShaderMemory.cpp,ResourceTracker.cpp,ResourceMaterializer.cpp,ShaderDiskCache.cpp,SpirvImageEmitter.cpp, andSpirvBdaRead.cpp.Results
ImageTable.cppandShaderMemory.cppwere not readFindings
Blocking
None verified.
Non-blocking
None.
Not verified
ImageTable.cppwas included in the review bundle but only selected portions of its added code were inspected; all 1,259 added lines were not read.ShaderMemory.cppwas excluded from the bundle. Its changed hunks were read through the repository reader, but the full file was not reviewed.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T09:50:35Z.
Review: COMMENTED
Reviewed — comments
The change adds nested table planning and scalar address alignment handling; I found one correctness issue in nested descriptor key normalization that needs clarification, so this review does not justify approval.
What I ran
Reviewed head
318e05f411ac19fcf9be3ed39ef6c8f05be33e85. No test commands were run. I read the PR description, commit list, manifest, diff, and the targeted repository code throughrepo_read.py.Results
Findings
Blocking
None verified.
Non-blocking
ChildKeyWordOfrecords the outer mask before shifting, then intersects it directly with the shifted-domain mask; this interprets the outer mask in the wrong bit positions and can under-approximate the possible key set used for snapshot materialization. See the changed logic atcore/shader/recompiler/Optimization/src/ResourceTracker.cpp:1360andcore/shader/recompiler/Optimization/src/ResourceTracker.cpp:1362. Add a case where the shader computes(word >> shift) & maskand confirm all possible selected keys are captured.Not verified
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas excluded from the prepared review folder; only its changed lines were read through the repository reader.To get this to a good state
Nothing is required. The optional key-domain test above would strengthen coverage.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T12:36:23Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change based on the production paths and representative tests inspected; the full review is incomplete because one changed file was excluded as too large.
What I ran
2c4c4232f45513327d4fa620d115dff9424ea965; base:main.repo_read.pyto inspect selected changed code and context at the pinned head. No commands or tests were run.Results
Findings
Blocking
None found in the inspected code.
Non-blocking
None.
Not verified
ShaderMemory.cppwas excluded from the review folder for size. Its changed hunks were visible indiff.patch, but its full source and surrounding context were not read.ImageTable.cppandResourceTracker.cppwere not read; only relevant ranges and changed hunks were inspected.files.jsonwas not available through the reader; the manifest identifies the excludedShaderMemory.cppfile.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T12:31:55Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected code at head
d1dc1e67e6b6f50d422ea85e290c61d6a8d05a4cshowed no verified blocking defect, but this review is incomplete because several changed files were not read. Nothing blocks this partial review; the points below are optional.What I ran
No commands or tests were run. I read the prepared description, commits, manifest, diff, selected changed-file ranges through
repo_read.py, and selected repository code at the pinned head. Author-reported test results in the description were not independently run.Results
Findings
Blocking
None identified in the portions inspected.
Non-blocking
Not verified
This review is incomplete. I inspected the implementation hunks in
ResourceTracker.cpp,ResourceMaterializer.cpp,ImageTableAbi.hpp,SpirvBdaRead.cpp, andSpirvMemoryInstructions.cpp; selected tests inImageTable.cpp,ShaderMemory.cpp,ShaderDiskCache.cpp, and the execution testBdaAnchorReads.cpp; the CMake test registrations; and the documentation change. I did not inspect every changed line in those files. In particular, I did not read the full added execution-test coverage inImageTable.cppor every changed section in the cache and recompiler files. No files were marked excluded by rule in the manifest, thoughShaderMemory.cppwas not included in the review folder and was accessed only through the pinned reader. No build, focused test, Vulkan validation, physical-console test, or title run was performed by this review.To get this to a good state
Nothing is required. Optional: run the focused tests on this exact head and complete review of the remaining changed lines before treating this as a full approval.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T13:01:30Z.
Review: COMMENTED
Actionable comments posted: 4
9a6873a6-050c-47c5-a37c-86b8bcc1c9e9Reviewing files that changed from the base of the PR and between
c8d13657c7and51c7e7fc40.core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_image_table_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/BdaAnchorReads.cppcore/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cppcore/shader/recompiler/ImageTableAbi.hppcore/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hppcore/shader/recompiler/SpirvBackend/src/SpirvBdaRead.cppcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cppdocs/dev/debt/shader.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T13:07:17Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed planner, materializer, cache, and scalar-address paths support the stated behavior, with title behavior still unverified.
What I ran
Reviewed head
51c7e7fc40b309b213829aadfdca4f83dc5e5f9eusing the pinnedrepo_read.pyreader. No commands or tests were run; hardware results below are author-reported.Results
Findings
Blocking
None.
Non-blocking
Not verified
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cppwas read at its changed ranges through the reader; its full text was excluded from the review folder because it is large.ShaderMemory.cpp; excluded files: none.To get this to a good state
Nothing is required. Optional: verify the title behavior on a review-base tree when its remaining changes are available.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T11:34:58Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change based on the source paths inspected; the reported test runs are author-supplied and were not run during this review.
What I ran
Reviewed head
efe80ab743aa50da8891a91b614c64ae57447e49. No commands or tests were run.Results
Findings
Blocking
None in the inspected code.
Non-blocking
None.
Not verified
ShaderMemory.cppwas not read in full; its changed hunks were present in the diff. Test execution, compiler results, and physical GPU behavior were not verified. Other included changed files listed in the review manifest were not all read. The only excluded changed file wascore/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp(too large for the review folder); targeted lines were visible in the diff.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T23:56:21Z.
Review: COMMENTED
Reviewed — no blocking findings
No concrete blocking defect was verified, but the full expanded test body was not inspected and runtime checks were not independently run.
What I ran
Reviewed prepared diff and targeted source context at head
2febe6158e2bb72c5217ba607d1c90c68d722e45against basemain. Usedrepo_read.pyto inspect recompiler, materializer, cache, and BDA code. No build or test command was run.Results
Negative control
Not run; no tests were executed.
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
Runtime behavior on GPUs and the author-reported test results were not independently confirmed. The prepared diff covered all 15 paths listed under
reviewed;ShaderMemory.cppsource context was read throughrepo_read.py. The full 438-lineImageTable.cpptest addition was not inspected line by line.files.jsonlists no excluded paths.To get this to a good state
Nothing is required. Optional: inspect the remaining
ImageTable.cpptest additions and independently run the focused GPU suite before treating this as a complete approval review.Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-30T23:59:19Z.
Review: COMMENTED
Actionable comments posted: 1
Architecture findings (1)
Advisory architecture findings (1)
1e62c5a2-0780-4b8a-b859-71a49b655479Reviewing files that changed from the base of the PR and between
efe80ab743and2febe6158e.core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppcore/shader/recompiler/Optimization/src/ResourceTracker.cppcore/shader/recompiler/ShaderDiskCache.cppcore/shader/recompiler/ShaderDiskCache.hppcore/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T17:10:48Z.
Review: COMMENTED
Actionable comments
0fae2afe-36c7-4aa8-920d-65747c7d21e9Reviewing files that changed from the base of the PR and between
2febe6158eandbf34e25cf1.docs/dev/debt/changes/fix-shader-vsharp-descriptor-reads.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T17:21:25Z.
Review: COMMENTED
Actionable comments
num_records.33534a73-ea23-4d06-8322-185661548898Reviewing files that changed from the base of the PR and between
bf34e25cf1and7e1498aaaa.docs/dev/debt/changes/fix-shader-vsharp-descriptor-reads.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T18:12:15Z.
Review: APPROVED
Reviewed — looks good
The changed resource tracking permits pointer-word uses only for rereadable, unwritten V# descriptors, and the child-key materializer bounds and checks its guest-memory read at head
43a3f8079006233bcfda91af2a1bb227bd4ee497.What I ran
Read-only review at the exact head above, against base
main; no merged-preview check or build was run. The author’s hardware and focused-test results are reported separately and were not independently verified.Results
Negative control
Not run; no source changes or tests were executed in this review.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
Changed hunks were reviewed in all 15 files listed by
manifest.json;files.jsonexcludes no files.ShaderMemory.cppfull text was not included infiles/; its changed ranges were read withrepo_read.py. No tests, hardware behavior, or author-reported runs were independently verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T19:24:30Z.
Review: COMMENTED
On Linux/lavapipe, the scalar-buffer, pointer-hop-table and shader-disk-cache controls passed on main
9fcd37e4eaand with7e1498aaaaapplied. All six branch-only V# table cases passed, including the linked-table fixture, which exercises the pointer selected through a phi and the moved V# without recompiling. All logs show Khronos validation active with zero VUIDs and no missing-layer messages. The current head43a3f80790changes the debt fragment only.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.