fix(shader): follow a pointer loaded straight through a pointer-keyed record pointer #16472
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16472"
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-06T19:38:56Z.
What
#28483 (which carried #9457) was merged into
mainon 2026-12-03, so this PR now applies directly tomain. It also carries @EagleBearerYS's #9633 and #9749 unchanged, with their authorship, since those branches have been inactive since Nov 26 and conflict withmain.e5d87326aachanges two of the carried tests, the conditional and the edited chase relink tests (node 3 now holds the other image), and the carriedChaseClosure(it only remembers a destination it admits), for CodeRabbit's review. Stacking on #9749 was EagleBearerYS's suggestion in #7395 (our findings, their reply).#9633 follows a conditional chase whose next pointer is read from a buffer whose V# is loaded through the current pointer. A shader can also load the next 64-bit pointer straight through the current pointer, with
s_loadat a fixed offset and no V# in between. PPSA03671's compute shader0x11d049aa00does this atpc=0xb6a0(P+0x30/0x34). With #9969 merged on, that is where it stops:The change:
PointerChasegainsdirect. A direct step's low word is at (offset,immediate) of the current pointer, and its high word at (offset,readHighImmediate).readOffset,readImmediateandeditsstay empty.The tracker:
PointerRecordPairs' walk takes two address loads through oneGetAddressResourceas a chase arm, before it tries a buffer chase arm:The arm's site is that
GetAddressResource, so the inner walk goes on from its words, as for the V# arms.The snapshot:
Chase()reads a direct step's two words at the pointer and records both in the snapshot ranges. It ends the chase at an unaligned or inaccessible word, as for the buffer arms.The disk cache: carries
direct, refuses a direct step that keeps buffer-read fields or edits, or whose high word sits at its low word's immediate. Format 99 → 100: #28483 takes 99, and this PR, with #9633 and #9749, takes 100.docs/dev/debt/shader.md: the chase entry names the direct arm.Not in this PR: after this step, PPSA03671 stops at
pc=0xd0f0(records linked through words that are also a V#'s base) and then atpc=0xef7c(pointers from a second record table), both described in #7395.Tested
Linux 7.3, RTX 3080 Ti, NVIDIA 615.71.09, Release.
The new test,
agc_driver_pointer_chase_direct_table, is #9633's conditional-chase shader with each step's pointer loaded by twos_load_dwords at P+0x60 and P+0x68, so a high word read at low + 4 fails. It checks:Without the tracker hunk, it fails with
GetImageResource dword 0 is not a valid runtime value.The disk cache test round-trips a direct chase and refuses one that keeps a buffer read.
Focused tests:
^(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 ate5d87326aa, which holds #28483 andmain93d64f2d1e(58 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.Windows: the same tests on NVIDIA RTX A2000 Laptop GPU (610.60) and Intel UHD Graphics 0x9a60 (32.0.101.7092), Windows 11 26200, WinLibs GCC, run as a normal user so the loader takes the validation layer from
VK_ADD_LAYER_PATH, on this branch ate5d87326aa(60 tests on each GPU) and onmain93d64f2d1e(52). All pass on both GPUs with noVUID-line.agc_driver_image_table_vouched_lookupsskips on the Intel GPU onmainas on this branch.PPSA03671 (01.001.005):
agc_shader_replayof the captured0x11d049aa00request, on this branch with #9969 merged on: it plans pastpc=0xb9f8and stops atpc=0xd0f0.pc=0xb9f8and stops 168 s in atpc=0xd0f0, as the replay predicts.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)mainholds #9633, #9749 and this changeSummary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-07T23:10:44Z.
Review: COMMENTED
Read
14a45d1ce1againstmain.Scope. Only
cebac8da3bis new here; the rest is #9749 and its stack, so this can only land after them.Soundness.
DirectChaseReadtakes only aLoadAddressU32pair through oneGetAddressResource, at the same offset operand and two different 4-aligned immediates, and the inner walk then has to reach a record or another site. A loop still shows up as a cycle indepthOfand is refused.ChaseClosureapplies every chase at every level, and each pointer it captures maps to the T# read at that address, so a step modelled too broadly only adds entries and a pointer the snapshot misses faults instead of reading a wrong T#. I found no input that gives a wrong read.Cache.
directis encoded and decoded, the format moves to 75, and the decoder refuses a direct step that keeps buffer-read fields or edits, has an unaligned immediate, or reads its high word at the low word's immediate.Non-blocking. No
rejectscase covers a direct step whosereadHighImmediateequalsimmediate; one next to "a direct pointer chase with a buffer read" would pin it. CI skippedagc_driver_pointer_chase_direct_table(no Vulkan device on the Windows runner, and the Linux job doesn't run on pull requests), so the runs in Tested are the only evidence it passes.Conflicts. This stack and #9969's both edit the one-line
set_tests_propertieslist inagc_driver_image_table_tests.cmakeandFormatVersion, so whichever lands second resolves them by hand.Not run here; this is from reading the code.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T10:58:00Z.
Review: COMMENTED
Reviewed — comments
The review is incomplete because
ShaderMemory.cppwas excluded from the review folder and the changed implementation files were not inspected at the pinned head.What I ran
No build or tests were run. I inspected the prepared description, commit list, manifest, file listing, and portions of the diff for PR #16472 at head
327846b19f39bb1127c407e63c2c88b2fa686cc5.Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
The changed implementation files—including
ResourceTracker.cpp,ResourceMaterializer.cpp, andShaderDiskCache.cpp—were not read from the repository at the pinned head.ShaderMemory.cppwas excluded from the review folder because it was too large; its changes were not inspected. The diff was read only in portions, so not all changed hunks were examined. No author-reported test results were independently verified.Files inspected:
description.md,commits.md,manifest.json, the file listing, and portions ofdiff.patch.ShaderMemory.cppwas excluded; other changed files were not read at the pinned head.To get this to a good state
Complete the review of all changed files, including the excluded
ShaderMemory.cpp, and verify the reported focused tests before making a formal decision.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T09:57:06Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change based on the source reviewed; the reported checks were not run by me.
What I ran
Reviewed head
db74b835af080460ef12183a69e3fc636a51c24aagainst the prepared diff and repository files throughrepo_read.py. No commands or tests were run. The description reports Linux 7.3, RTX 3080 Ti, NVIDIA 615.71.09 tests and replay/game checks; those are author-reported.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests or builds were run. Console behavior and the hardware, replay, and CTest results in the description were not independently verified. No files were excluded: all nine files marked changed in the manifest were read, including all listed changed-line ranges. The review folder contained no separate
files.json; its file listing showed the changed files as included.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T11:09:07Z.
Review: APPROVED
Reviewed — looks good
The change at head
c075748254592cb219ad35c03dac9487a62a4f88adds direct pointer chasing to pointer-keyed image tables; I found no verified blocking defect in the code reviewed. Nothing blocks this; the points below are optional.What I ran
repo_read.py.ShaderDiskCache.cpp(tests),agc_driver_image_table_tests.cmake,ImageTable.cpp,ControlFlowInfo.hpp,ResourceMaterializer.cpp,ResourceTracker.cpp,ShaderDiskCache.cpp(recompiler),ShaderDiskCache.hpp, anddocs/dev/debt/shader.md. (Correction: this is eight files; the manifest contains eight reviewed files.)Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
review/files.jsonwas not available as a reader path; the manifest lists all eight changed files as included, and none as excluded.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T12:39:51Z.
Review: COMMENTED
Reviewed — comments
The direct pointer chase has focused coverage in the supplied diff, but I did not complete a read of every changed file or run the reported checks, so a formal decision is not justified.
What I ran
No commands or tests were run. I inspected the prepared description, commit list, manifest, diff, and targeted changed hunks at head
91a5c3b620ab40037f6e4cd6057ce1ba7800322d.Results
Findings
Blocking
None identified in the inspected hunks.
Non-blocking
Not verified
I did not read every changed file end to end or verify all changed hunks. The manifest lists nine changed files, all marked included; the file listing showed no excluded changed files. I read targeted portions of
core/shader/recompiler/Optimization/src/ResourceTracker.cpp,core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp, the cache and metadata hunks, and the direct pointer chase test incore/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp. Other changed-file content and reported runtime behavior remain unverified.To get this to a good state
Nothing is required. Optional: independently run the reported focused tests and complete review of the remaining changed-file content.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T12:34:54Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the review evidence supports merging, with the optional scope note below.
What I ran
Reviewed head
7cf2f499afb652a1905577b2b20e6f0ac2428d2f; no commands or tests were run. Read the PR description, commits, diff, manifest, and all nine changed files listed in the manifest. The only reported test results are the author’s, in the description.Results
Findings
Blocking
None.
Non-blocking
Not verified
files.jsonwas not available through the reader. The review-folder README and manifest list nine changed files, all marked included, and all nine were read. Excluded-by-rule file details are not independently verified.To get this to a good state
Nothing is required. The scope note above is optional.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T13:04:27Z.
Review: COMMENTED
Actionable comments posted: 8
05f41d1c-74fe-444b-a5d6-5e8b55297c37Reviewing files that changed from the base of the PR and between
c8d13657c7and8ab6c0fe07.core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_image_table_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cppcore/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.hppdocs/dev/debt/shader.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T13:05:48Z.
Review: COMMENTED
Reviewed — comments
The review found an invalid descriptor edit composition in the new pointer chase handling; the review is incomplete because I did not run the test suite.
What I ran
Reviewed head
8ab6c0fe07e845ca52a19b381401fdd5efe31bc4from the prepared diff and pinned repository reader. No tests or build commands were run.Results
Findings
Blocking
None verified.
Non-blocking
EditedWordstrips a single outer shift, AND, or OR and stores each operation in the sameDescriptorWordEdit. If generated IR nests these operations (for example, OR over an AND), the later inner operation overwrites the outer operation's field, whileApplyalways evaluates shift, then mask, then bits. The resulting captured descriptor word can differ from the shader's value and cause incorrect table materialization. The current tests exercise an edited chase but this review did not verify coverage of compound operations. Consider composing the operations algebraically or refusing combinations that cannot be represented exactly. Evidence:core/shader/recompiler/Optimization/src/ResourceTracker.cpp:1127andcore/shader/recompiler/Optimization/src/ResourceMaterializer.cpp:1190.Not verified
review/description.md,review/commits.md,review/manifest.json,review/diff.patch, plus changed code inResourceTracker.cpp,ResourceMaterializer.cpp,ShaderDiskCache.cpp, and the materializer accessibility helpers.ShaderDiskCache.cpptests,agc_driver_image_table_tests.cmake,ImageTable.cpp,ControlFlowInfo.hpp,ShaderDiskCache.hpp, anddocs/dev/debt/shader.md; these were represented in the prepared diff but not read from their repository files.To get this to a good state
Nothing is required. Optional: preserve the exact order of descriptor word operations, and add coverage for nested shift/AND/OR edits.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T21:50:24Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the author’s reported tests support the implementation, but I did not run them.
What I ran
Reviewed head
b9b9768b2437ba5e1ad62914b9ade8f7d7a53b5eusing the prepared diff andrepo_read.pyfor targeted source ranges. No build or test commands were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Builds, tests, physical-console behavior, and author-reported GPU runs were not independently verified. Read:
description.md,commits.md,manifest.json,diff.patch; changed source files read throughrepo_read.py:ResourceMaterializer.cpp,ResourceTracker.cpp,ShaderDiskCache.hpp. All eight changed files are marked included in the manifest; full file contents were not read. No exclusions were listed in the manifest.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T11:37:34Z.
Review: COMMENTED
Reviewed — no blocking findings
The inspected implementation and tests support the stated pointer-chase behavior; the prepared review bundle marks all nine changed files as included, but this review did not read every changed file or run checks, so approval is not justified.
What I ran
The prepared bundle pins the change to
447e7ee8edd7b940307bf71a7c82ae57a6cdbad9with basemain. I readdescription.md,commits.md,manifest.json, and targeted ranges ofdiff.patch, then searched and read targeted source context throughrepo_read.py. I did not run commands or tests.Results
Findings
Blocking
None identified in the code inspected.
Non-blocking
None.
Not verified
The following changed files were listed as included in the manifest:
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp,core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_image_table_tests.cmake,core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp,core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.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/shader.md. I read targeted hunks and source context, not every changed line or full text of each file. Runtime tests and author-reported GPU/game results were not independently verified.To get this to a good state
Nothing blocks this; the points below are optional. For a formal approval, complete review of all changed files and run the relevant checks on this head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-30T23:55:56Z.
Review: APPROVED
Reviewed — looks good
The reviewed change adds bounded pointer chasing for pointer-keyed image tables and cache validation; I found no blocking defects in the inspected code.
What I ran
Reviewed head
57527ab7f9af8b3dca47312902fdfc90bd0125a6. Usedrepo_read.pyto search and read pinned source ranges. No tests, builds, or merged-preview checks were run. All nine files listed underreviewedinfiles.jsonwere read;files.jsonlists no excluded files.Results
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
Runtime behavior on GPUs and the tests reported in the PR description were not independently verified. Files read:
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp,core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_image_table_tests.cmake,core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp,core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.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/shader.md.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-01T00:02:51Z.
Review: COMMENTED
Actionable comments posted: 2
Architecture findings (2)
Advisory architecture findings (2)
80eb3a21-3cc4-4315-853f-fc6b916d846eReviewing files that changed from the base of the PR and between
447e7ee8edand57527ab7f9.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.hppIncluded 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 MarcZX10 on 2026-12-01T00:47:56Z.
Review: APPROVED
Reviewed — looks good
The reviewed changes add direct pointer chasing for pointer-keyed image tables and validate and cache the new chase metadata; I found no blocking defects in the inspected code.
What I ran
Reviewed head
e5d87326aa37d583e4401742ab27df1c9b56f117. I usedrepo_read.pyto inspect targeted source ranges; I did not run tests, builds, or a merged-preview check. The author reports GPU tests and a game replay in the PR description; those were not run by me.Results
Negative Control
Not run; the negative control requires executing the test, which I did not do.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
I did not run the reported GPU tests, game replay, or console behavior. The nine files listed under
files.json→reviewedwere inspected:ShaderDiskCache.cpp,agc_driver_image_table_tests.cmake,ImageTable.cpp,ControlFlowInfo.hpp,ResourceMaterializer.cpp,ResourceTracker.cpp,ShaderDiskCache.cpp,ShaderDiskCache.hpp, andshader.md.files.jsonlists no excluded files; the bundle omits lockfiles, minified files,dist/,build/, and.svgfiles by rule.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-01T00:53:22Z.
Review: COMMENTED
Architecture findings (1)
Advisory architecture findings (1)
2ff368a6-9971-43fc-9266-9a9af84455a7Reviewing files that changed from the base of the PR and between
57527ab7f9ande5d87326aa.core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cppcore/shader/recompiler/Optimization/src/ResourceMaterializer.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T17:34:55Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
91bd01aef58f9c3fc2367d781fc13fa2d90de538againstmainfrom the prepared diff and changed-file copies. No tests or other executable checks were run. The prepared files contain all nine changed files; no files were excluded.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The reported automated and GPU test results were not independently verified. The repository reader could not complete because it requires writing a run-folder log; review was based on the prepared diff and changed-file copies. No excluded files were listed.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T19:04:02Z.
Review: COMMENTED
On Linux/lavapipe,
agc_driver_pointer_hop_table,agc_driver_gcn_scalar_buffer_base, andagc_shader_disk_cachepassed on main at9fcd37e4eaand with91bd01aef5applied. The branch-onlyagc_driver_pointer_chase_direct_tablealso passed. All three logs show the Khronos validation layer inserted and contain no missing-layer messages or VUIDs. The direct-table fixture covers the separate low and high offsets and updates the link without recompiling the shader.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.