Skip to content

fix(agc): poison only the pointer-table records a dispatch writes - #22690

Open
milescoviello wants to merge 11 commits into
boykopovar:mainfrom
milescoviello:fix/agc-image-table-written-keys
Open

milescoviello wants to merge 11 commits into
boykopovar:mainfrom
milescoviello:fix/agc-image-table-written-keys

Conversation

@milescoviello

@milescoviello milescoviello commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What

A dispatch that writes a buffer or storage image overlapping one of its image tables' read range sets that table's TableFault, so selecting any entry faults (table written by its dispatch), even an entry whose record the write misses. The debt entry already says so.

In Crimson Desert (PPSA25286) this hits pointer tables (a column read through a 64-bit address):

  • Their snapshot reads 2 MiB of 32-byte records past the pointer.
  • That range covers seven storage images (256-512 KiB each) that the same dispatches write.
  • The selected descriptor, for example 0x2151d4b5a0 (the first record), lies 84 KiB before the first image.
  • A local diag build showed 4 to 116 of these deferred write-back failed: ... table written by its dispatch lines per run, from up to a dozen shaders.

The change:

  • Materializer. For a pointer table whose record k lies at start + k * stride, ResourceMaterializer records that layout (start, stride, record bytes) with the table snapshot. That covers a column with no indirection, pointer hops or carried offsets, a 4-byte-aligned stride and addend, and no 32-bit offset wrap over the captured keys. ShaderInvocation carries the layouts as imageTableRecords.
  • Driver. ShaderResources::finishImageTables writes the HeapWritten poison into the map codes of just the records a written range overlaps, instead of the table's TableFault. Any other entry still reads its snapshot descriptor. Tables without such a layout (buffer, nested and indirect tables) keep the whole-table fault.
  • Ranges at the top of the address space. The overlapped keys come from ImageTableRecordLayout::KeysOverlapping, which compares inclusive ends (a store's first and last byte against each record's last byte) instead of adding past them, so a store range that reaches the end of the 64-bit address space, or a record that starts at the last address, still poisons the records it overlaps (MarcZX10's reviews of fix(agc): poison only the buffer-table records a dispatch writes #22703).
  • Why it's sound. The shader takes a pointer table's map code only for a record below the key count (LookupTableWord: inMap = aligned && record < keys; otherwise OutsideSnapshot). So the records outside the write are the descriptors they held when the dispatch started.
  • Disk cache. The invocation is serialized in the shader disk cache, so its encoder and decoder carry the new list, the size asserts move, and FormatVersion moves to 104 (main was at 97 then and is at 98 as of 11-27; every number from 96 to 103, and 108 and 110, is used by an open pull request).

Tested

Linux (Ubuntu 26.04.1, kernel 7.0), GCC 15.2, Ninja, Release, -DBUILD_TESTING=ON, RTX 4070 Ti on NVIDIA 615.71:

  • 11-28: Crimson Desert with fix(agc): poison only the buffer-table records a dispatch writes #22703's head (which contains this change) merged onto main 859a238b8, one run: 0 deferred write-back failed: ... is written by its own dispatch lines in 206 s with 118 frames presented. On main that day, runs that presented 45 frames or more logged 52 to 133 such lines, and runs stuck at 0 to 4 frames logged 2 to 8 (including round 108 on the same main); details in fix(agc): poison only the buffer-table records a dispatch writes #22703's Tested. The run was killed at the 20 GiB memory cap, so no title progress is claimed.
  • 12-03: merged main 3ff0401064 as ee03b3fa16. One conflict, FormatVersion: main moved to 99; this change keeps 104, which no other open pull request uses. Of the 36 agc_driver_image_table*, agc_shader_memory and agc_shader_disk_cache* tests, 35 pass in each of 3 runs. The agc_shader_disk_cache_large_file test fails in my batch environment, where the temporary directory is a RAM-backed /tmp (tmpfs, 5.96 GB free) inside a 12 GB memory scope and the 2 GiB write does not complete; with TMPDIR on a disk it passes (run on the fix(agc): poison only the buffer-table records a dispatch writes #22703 head, which contains this change).
  • 11-27 (2nd): merged main 4c7578e0a4 as 0aaaa698c4. One conflict, FormatVersion: main moved to 98; this change keeps 104. The 34 agc_driver_image_table*, agc_shader_memory and agc_shader_disk_cache* tests pass in each of 3 runs.
  • 11-27: merged main 80781a0e94 as 19f7d4a0ab. One conflict, the RecompileResult size check in ShaderDiskCache.cpp: perf(agc): avoid heap allocations and atomic refcounts in draw resource key memo #27273 grew it from 560 to 568 bytes with drawKeyMemo, which is not serialized, and this change adds 24, so the check is now 592, which the build confirms. FormatVersion stays 104. The 34 agc_driver_image_table*, agc_shader_memory and agc_shader_disk_cache* tests pass in each of 3 runs.
  • 11-26: merged main c64b9d323f into the branch as 8920a768b4. One conflict, in FormatVersion: main moved to 97 (perf(shader): keep specialized SPIR-V in the shader disk cache #26800) and the branch kept 100. Since fix(shader): sample a single-texel image with any sampler that keeps X and Y addressing inside #22602 and fix(shader): read a chased pointer's high word at its own offset #9749 now also use 100, 06fae1ad18 moves it to 104, which no open pull request uses. The 34 agc_driver_image_table*, agc_shader_memory and agc_shader_disk_cache* tests pass in each of 3 runs at 8920a768b4, and agc_driver_image_table and agc_shader_disk_cache* pass in each of 3 runs at 06fae1ad18.
  • 11-21 (2nd): rebased onto main ef7dc4452d as 660f02cdd7. One text conflict, in the include list of tests/execution/ImageTable.cpp (main added <mutex>, this branch <limits>), kept both; FormatVersion stays 100 (main is at 96 and no open pull request uses 100). The 33 agc_driver_image_table*, agc_shader_memory and agc_shader_disk_cache* tests pass in each of 3 runs (main 33/33 once). Windows 11 VM (GeForce GT 1030, WinLibs GCC 16.2, Ninja, Release): the same set, 35 tests there, passes in each of 3 runs.
  • 11-21: rebased onto main 70602fcc03 as 74213a85f6. Two text conflicts with main's pointer-keyed record tables (pointerKeyed in ImageTableColumnSnapshot and in ResourceMaterializer) are resolved by keeping both; a pointer-keyed column is always indirect, so it never takes this PR's linear record path. main had reached format 96, this branch's value, so the last commit moves it to 100. The 33 agc_driver_image_table*, agc_shader_memory and agc_shader_disk_cache* tests pass in each of 3 runs (main 33/33 once). Windows 11 VM (GeForce GT 1030, WinLibs GCC 16.2, Ninja, Release): the same set, 35 tests there, passes in each of 3 runs.
  • 11-20, head 8021995a83 (the fix above for the wrapping range): agc_driver_image_table also checks KeysOverlapping directly: a store over records 5 to 7 of 48-byte records gives keys 5 to 7, a store running past the top of the 64-bit address space gives the last record, and a store ending at the top gives all four. Linux (Ubuntu 26.04.1, GCC 15.2, Ninja, Release, RTX 4070 Ti on NVIDIA 615.71, ANYPS5_REQUIRE_VULKAN=1): the 33 tests of ^(agc_driver_image_table.*|agc_shader_memory|agc_shader_disk_cache.*)$ pass 3 runs. Negative control: with the old formula in KeysOverlapping, agc_driver_image_table fails with image table records: a store running past the top of the address space did not select the last record.
  • 11-20, head 2e182729d0 (test only, MarcZX10's suggestion on fix(agc): poison only the buffer-table records a dispatch writes #22703): the same checks also cover records of zero bytes and a store past the last of 64 records, which both select no keys. The 33 tests pass 3 runs.
  • 11-20, head db70e3dceb (MarcZX10's second review of fix(agc): poison only the buffer-table records a dispatch writes #22703): 2e182729d0 saturated the first record's exclusive end at the top of the address space, so a record starting at the last address looked empty. The range now uses inclusive ends, and the checks add a record at the last address with a one-byte store there and a store ending there (both select key 0). The 33 tests pass 3 runs. Negative control: with 2e182729d0's KeysOverlapping, agc_driver_image_table fails with image table records: a one-byte store at the last address did not select the record that starts there.
  • agc_driver_image_table gains two pointer-table cases next to the existing palette run (keys 0-2 select records 0-2):
    • A dispatch whose output buffer lies over palette records 128-223 doesn't fault, and its three groups sample what the plain palette run samples.
    • One whose output starts at record 2 still faults with is written by its own dispatch.
    • The existing buffer-table case, a dispatch storing over its whole table, still faults.
  • ^(agc_driver_image_table.*|agc_shader_memory|agc_shader_disk_cache.*)$ (33 tests) passes, 3 runs. agc_shader_disk_cache now also compares the record layouts after its invocation round trip, and it passes too.
  • Negative control: with main's ShaderResources.cpp and the new test, agc_driver_image_table fails with pointer image table: a store into entries no key of the dispatch selects faulted.

Windows 11 (VM, GeForce GT 1030, WinLibs GCC 16.2, Ninja, Release, ANYPS5_REQUIRE_VULKAN=1): agc_driver_image_table and agc_shader_disk_cache pass 3 runs on this head 746802dc77.

Crimson Desert (PPSA25286), Linux, RTX 4070 Ti: offline (APS5_NET_DISCONNECTED=1), 22G cap. One cold run (420 s) and one warm run (480 s) per arm, with a fresh shader cache per arm.

run table written by its dispatch failures end
base cold 4 ran 426 s
base warm 24 killed at the cap at 464 s
PR cold 0 ran 421 s
PR warm 0 ran 487 s

The screen is still the black loading screen with its spinner in every run. Present counts vary too much between Crimson Desert runs of the same build (2 to 19 in earlier warm runs) to read anything into them here, so I'm only claiming the faults are gone.

  • domx4q's run with the Khronos validation layer (Arch Linux, GCC 16.2.1, RTX 4090, NVIDIA 620.70.06, layer 1.4.363.1), this head merged onto main 1ccc399b17: the 33 image table, shader memory and disk cache tests pass on both main and this PR with no VUID- errors, and the negative control with main's ShaderResources.cpp fails agc_driver_image_table in 2 of 2 runs.
  • git merge-tree against main is clean. tools/check_conventions.py passes on the branch and this body, and tools/debt_fold.py --check reports nothing new for this fragment.
  • Rebased 11-18 onto main d89f26516c as 8b933712e6 (it conflicted with main; FormatVersion is now 91 against main's 90). On Linux (Ubuntu 26.04.1, GCC 15.2, Release, RTX 4070 Ti), the 33 tests of ^(agc_driver_image_table.*|agc_shader_memory|agc_shader_disk_cache.*)$ pass, 3 runs. On the Windows 11 VM (GT 1030, WinLibs GCC 16.2.0, Release), the 35 tests the same pattern selects on Windows pass, 3 runs, on 8b933712e6.
  • Rebased 11-20 onto main 0a025bd3c6 as 742d417e29. It conflicted in the disk cache: main had moved FormatVersion to 95 and grown CompiledShaderArtifact (288 to 296 bytes) and RecompileResult (552 to 560). This head sets FormatVersion 96 and the RecompileResult assert to 584 (main's 560 plus this change's 24), which the build checks. On Linux (Ubuntu 26.04.1, GCC 15.2, Ninja, Release, RTX 4070 Ti on NVIDIA 615.71, ANYPS5_REQUIRE_VULKAN=1), the 33 tests of ^(agc_driver_image_table.*|agc_shader_memory|agc_shader_disk_cache.*)$ pass 3 runs.
  • Colewiz7's RADV run of 8b933712e6 merged onto main d89f26516c as de9fbd7b86 (Linux 7.3.4, GCC 16.2.1, Mesa 26.2.6, RX 7900 XT and the 7800X3D iGPU, Khronos validation layer 1.4.363.1): no new failures against main in the full suite (6171 tests) or in ^agc with the layer, and no VUID- or SYNC-HAZARD lines.
  • rafaconvaitis's Windows + AMD run of 8b933712e6 merged onto main 3c07e1d05e (Radeon 760M, AMD Software 26.11.2, WinLibs GCC 15.2.0, Khronos validation layer 1.4.363): agc_driver_image_table and the three agc_driver_nested_image_table* tests pass 3/3 on both sides with no VUID- lines, and with this PR's tests on main's sources agc_driver_image_table fails. On this device (subgroup size 64) its per-wave key cases are skipped.
  • Windows, run by @B-Howell (comment): Windows 11 Pro 26300, RTX 4080 SUPER (621.14), WinLibs GCC 15.2.0 r7, Release, ee03b3fa16 merged onto main de4730493a: agc_driver_image_table_tests, agc_shader_disk_cache_tests, the five other agc_driver_image_table_* targets and agc_driver_graphics_tests with its neighbours (176 tests, including agc_driver_image_table_reuse_records and _narrow) pass in 3 of 3 runs. Control, this tree with only the per-record branch in finishImageTables disabled: agc_driver_image_table fails with "pointer image table: a store into entries no key of the dispatch selects faulted". With Khronos validation, ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1, no VUID- on main or this change.
  • Run by @ycbuzi (comment): Windows Server 2022 and 2025 (GitHub-hosted runners), WinLibs GCC 15.2.0, ee03b3fa16 merged into main, the whole ctest suite twice per runner: no failures on Server 2025; on Server 2022, 2 and then 3 failures out of 7534, 2 of which also fail on main (the report does not name the third). 5 GPU tests (AGC, shader recompiler) pass twice on Mesa lavapipe 25.2.8 with Khronos validation and the shader cache off, with no validation message that main c1593e4e1d does not also produce.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA RTX 4070 Ti (Linux), NVIDIA GeForce GT 1030 (Windows), AMD RX 7900 XT and the Ryzen 7 7800X3D iGPU (gfx1036) (Linux, RADV, Colewiz7), AMD Radeon 760M (Windows, AMD driver, rafaconvaitis)
  • AI-assisted: yes

Summary by CodeRabbit

  • Bug Fixes
    • Image-table reads now remain available for entries unaffected by overlapping writes when the table layout supports precise tracking. Entries touched by a write still fault, while tables without a supported layout continue to fault as a whole.
  • Reliability
    • Improved handling of image-table record boundaries, including overlapping writes, empty records, and address-range edge cases. Image-table record information is preserved when shader results are saved and loaded, keeping behavior consistent across cached results.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

The inspected changes implement per-record poisoning for eligible pointer tables and add focused tests; I found no verified blocking defect.

What I ran

Reviewed head 746802dc775456e2612ece8fc99bbbab4f8c425f using the prepared diff and repo_read.py for targeted source reads. No tests or build commands were run; test results in the PR description are author-reported.

Results

Check Result Note
Diff and changed code passed Targeted source review completed
Build and tests not run PR reports passing tests
Negative control not run PR reports a failing negative control

Findings

Blocking

None verified.

Non-blocking

None.

Not verified

Full text read for 9 of 10 changed files; ShaderResources.cpp was excluded from the prepared folder because of its size, so I read the relevant implementation range through repo_read.py. In total, all 10 changed files were read at least around their changed hunks; unrelated portions of large files were not read. Build, test, hardware, and console behavior were not independently verified.

To get this to a good state

Nothing is required.

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 20130 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 20248 core/shader/recompiler/Recompiler.cpp L2120
PR 20519 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L1625
core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94
core/shader/recompiler/ShaderDiskCache.hpp L20
PR 21776 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 22583 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 22692 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 23244 core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94
core/shader/recompiler/ShaderDiskCache.hpp L20
PR 23409 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 26630 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 27670 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 28077 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 28296 core/shader/recompiler/ShaderDiskCache.cpp L94
PR 28780 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 28866 core/shader/recompiler/ShaderDiskCache.hpp L20
PR 29042 core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp L22-23
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L1625
core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94
core/shader/recompiler/ShaderDiskCache.hpp L20
PR 29066 core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp L22-23
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L1625
core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94
core/shader/recompiler/ShaderDiskCache.hpp L20
PR 29067 core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp L22-23
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L1625
core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94
core/shader/recompiler/ShaderDiskCache.hpp L20
PR 29076 core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp L22-23
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L1625
core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94
core/shader/recompiler/ShaderDiskCache.hpp L20
PR 29084 core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp L22-23
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L1625
core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94
core/shader/recompiler/ShaderDiskCache.hpp L20
PR 29087 core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp L22-23
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L1625
core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94
core/shader/recompiler/ShaderDiskCache.hpp L20
PR 29089 core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp L22-23
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L1625
core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94
core/shader/recompiler/ShaderDiskCache.hpp L20
PR 29095 core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp L22-23
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L1625
core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94
core/shader/recompiler/ShaderDiskCache.hpp L20
PR 29101 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L1625
core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94
PR 29103 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L1625
core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94
PR 29104 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L1625
core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94
PR 29105 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L1625
core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94
PR 29106 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L1625
core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94
PR 29107 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L1625
core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94
PR 29118 core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp L22-23
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L1625
core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94
core/shader/recompiler/ShaderDiskCache.hpp L20
PR 29121 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L1625
core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94
PR 29123 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp L1625
core/shader/recompiler/ShaderDiskCache.cpp L91-92, L94

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5609 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 5925 core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 6188 core/shader/recompiler/Recompiler.hpp
PR 6192 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6280 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 6340 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6412 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 6488 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 6924 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 7085 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 7684 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 7689 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 9318 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9356 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 9387 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 9508 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 9633 core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 9712 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9790 core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 9852 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 9897 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 9969 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 10193 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 10359 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 10492 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 10497 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 10743 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 10867 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 11444 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 11483 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 11551 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 12324 core/shader/recompiler/Recompiler.cpp
PR 12575 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 12828 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 12944 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 13809 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 13928 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 13929 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 14032 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 14853 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 14944 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 15343 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 15548 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 15555 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 16391 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 16879 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 16935 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 16953 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 17056 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 17611 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 18082 core/shader/recompiler/ShaderDiskCache.cpp
PR 18106 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 18107 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 19710 core/shader/recompiler/Recompiler.hpp
PR 20030 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 20041 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 20111 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 20153 core/shader/recompiler/Recompiler.hpp
PR 20518 core/shader/recompiler/Recompiler.hpp
PR 20728 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 21199 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 21240 core/shader/recompiler/ShaderDiskCache.hpp
PR 21745 core/shader/recompiler/ShaderDiskCache.hpp
PR 21763 core/shader/recompiler/ShaderDiskCache.hpp
PR 21970 core/shader/recompiler/ShaderDiskCache.hpp
PR 21971 core/shader/recompiler/ShaderDiskCache.hpp
PR 22071 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 22251 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 22328 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 22424 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 22439 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 22628 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 22647 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 22675 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 23242 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 23258 core/shader/recompiler/Recompiler.hpp
PR 23281 core/shader/recompiler/Recompiler.hpp
PR 23553 core/shader/recompiler/Recompiler.hpp
PR 23811 core/shader/recompiler/Recompiler.hpp
PR 24049 core/shader/recompiler/Recompiler.hpp
PR 24661 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 24704 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 24714 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 24735 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 24781 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 25010 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 25489 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 26012 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 26686 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 27171 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 28142 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 28176 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 28228 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 28372 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 28376 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 28384 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 28387 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 28400 core/shader/recompiler/Recompiler.hpp
PR 28469 core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
PR 28470 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 28487 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 28488 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 28586 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 28590 core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 28659 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 28668 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
PR 28673 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 28786 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 28787 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 28808 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Recompiler.cpp
core/shader/recompiler/Recompiler.hpp

@domx4q

domx4q commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Ran the description's image table and disk-cache pattern with the Khronos validation layer on NVIDIA's proprietary Linux driver, since the description's Linux run has no layer.

Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor 0x10de, device 0x2684, Ada), proprietary driver 620.70.06, Vulkan 1.4.357, Khronos validation layer 1.4.363.1. Head 746802dc77 merged onto main 1ccc399b17 with --no-ff, clean merge. Main baseline is a Release build of 1ccc399b17 on the same machine.

WAYLAND_DISPLAY=wayland-1 XDG_RUNTIME_DIR=/run/user/1000 DISPLAY=:0 ANYPS5_REQUIRE_DISPLAY=1 \
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer \
ctest --test-dir build -R '^(agc_driver_image_table.*|agc_shader_memory|agc_shader_disk_cache.*)$' -V
main 1ccc399b17 this PR
Result 33/33 passed 33/33 passed
Insert instance layer "VK_LAYER_KHRONOS_validation" 30 30
was not found but was requested by env var VK_INSTANCE_LAYERS 0 0
VUID- none none

Main runs its own ImageTable.cpp, without the two new pointer-table cases. On this PR, agc_driver_image_table with them passes (image table tests passed), and so does agc_shader_disk_cache with its record layout check. Every device selection picked the RTX 4090.

Negative control, as in the description: this PR's build with main's ShaderResources.cpp fails agc_driver_image_table deterministically (2 of 2 runs) with AGC graphics: pointer image table: a store into entries no key of the dispatch selects faulted, and logs no VUID-.

No new VUID- errors; all focused tests pass on Ada.

AI-assisted: yes (Claude Code)

@milescoviello

Copy link
Copy Markdown
Contributor Author

Thanks @domx4q for the validation-layer run on the 4090 and for repeating the negative control. I've added it to the Tested section, linked to your comment.

@milescoviello
milescoviello force-pushed the fix/agc-image-table-written-keys branch from 746802d to 8b93371 Compare November 19, 2026 00:28
milescoviello added a commit to milescoviello/AnyPS5 that referenced this pull request Nov 19, 2026
boykopovar#22690 poisons only the records a dispatch's writes overlap for tables
read through a 64-bit pointer. A table read through a buffer V# still
took the whole-table fault, so a dispatch that writes elsewhere in the
same V# faulted on every entry.

A direct buffer column reads record k at
base + ((addend + k * stride + immediate) & ~3). With a 4-byte-aligned
stride, addend and immediate, no indirection, carried offsets or
selected record, and no 32-bit wrap over the captured keys, that is
start + k * stride, so the materializer records the same layout for it
and finishImageTables poisons just the overlapping records. The shader
takes a buffer table's map code only for a record below the key count,
as for a pointer table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blocking findings

The diff and targeted source context at head 8b933712e66722046de813aa5c5697885c498640 support the per-record poisoning change; this review environment did not provide a way to run checks.

What I ran

Read the prepared description, commits, manifest, diff, and changed-file source ranges using the pinned reader. No tests or build commands were run.

Results

Check Result Note
Diff and source review passed Changed behavior and cache wiring inspected
Build and tests not run No execution performed

Findings

Blocking

None.

Non-blocking

None.

Not verified

The changed ShaderResources.cpp implementation and all other changed files listed as reviewed in the manifest were read at relevant ranges. The full contents of files marked included were not read; the code paths relevant to the diff were inspected. No build, automated tests, hardware behavior, or author-reported runs were independently verified. files.json was not available as a review document; the manifest and review-folder listing were used to identify exclusions. ShaderResources.cpp was excluded from the prepared full-text files because it was too large, and was read through the pinned reader around the changed function.

To get this to a good state

Nothing is required.

@Colewiz7

Copy link
Copy Markdown
Contributor

Head 8b933712e6 merged onto main d89f26516c as de9fbd7b86, no conflict. Linux 7.3.4, GCC 16.2.1 Release, Mesa 26.2.6 RADV, RX 7900 XT (gfx1100) and 7800X3D iGPU (gfx1036).

No new failures and no new validation messages on either GPU.

RX 7900 XT iGPU
full suite (6171 tests), new failures vs main none none
-R '^agc' (1940 tests) with the layer, new failures vs main none none
VUID- / SYNC-HAZARD lines 0 / 0 0 / 0

Layer runs used VK_LAYER_KHRONOS_validation 1.4.363.1 with VK_LOADER_DEBUG=layer and ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1; the loader inserted the layer in every run, and the validation message set matches main.

AI-assisted: yes

@milescoviello

milescoviello commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased onto main d89f26516c as 8b933712e6: it conflicted with main, and FormatVersion is now 91 against main's 90.

  • Linux (Ubuntu 26.04.1, GCC 15.2, Release, RTX 4070 Ti): the 33 tests of ^(agc_driver_image_table.*|agc_shader_memory|agc_shader_disk_cache.*)$ pass, 3 runs.
  • Windows 11 VM (GT 1030, WinLibs GCC 16.2.0, Release): the 35 tests the same pattern selects on Windows pass, 3 runs, on 8b933712e6.

Thanks @Colewiz7 for the RADV run of this head on the RX 7900 XT and the 7800X3D iGPU: no new failures in the full suite and no VUID- or SYNC-HAZARD lines with the layer. I've added it to the Tested section, linked to your comment, and both GPUs to the GPUs tested line.

@rafaconvaitis

Copy link
Copy Markdown
Contributor

Windows + AMD run on the AMD proprietary driver; the AMD run already in the comments is Linux + Mesa RADV. Head 8b933712e6 merged alone onto main 3c07e1d05e with git merge --no-ff (clean merge).

Setup: Windows 11 25H2 (build 26200), AMD Radeon 760M integrated graphics (1002:15bf, Vulkan device name Radeon 5), AMD Software 26.11.2 (driver 32.0.32029.2010, Vulkan 1.4.359), selected with ANYPS5_GPU=Radeon, WinLibs GCC 15.2.0 r7 UCRT, Release, BUILD_TESTING=ON, Khronos validation layer 1.4.363 (LunarG SDK 1.4.363.1). Only the focused test targets were built; the other execution tests were left out with ANYPS5_AGC_EXECUTION_TESTS.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer, ctest -R '^(agc_driver_image_table|agc_driver_nested_image_table|agc_driver_nested_image_table_budget|agc_driver_nested_image_table_large)$' -V -j 1, 3 runs per side.

test main this PR this PR's tests on main's sources (1 run)
agc_driver_image_table passes 3/3 passes 3/3 fails
agc_driver_nested_image_table passes 3/3 passes 3/3 passes
agc_driver_nested_image_table_budget passes 3/3 passes 3/3 passes
agc_driver_nested_image_table_large passes 3/3 passes 3/3 passes
  • Negative control: with the tests of this PR built on main's sources (without the 7 production files this PR changes), agc_driver_image_table does not pass, so on this driver the test detects the change. The failing run of agc_driver_image_table logs AGC graphics: pointer image table: a store into entries no key of the dispatch selects faulted:.
  • On this device agc_driver_image_table logs image table: per-wave key case skipped, subgroup size 64 does not hold exactly one wave32 and image table read: per-wave key case skipped, subgroup size 64 does not hold exactly one wave32, so the per-wave key case did not run here.
  • VUID- lines: 0 in the main and PR logs. Every run logs Selected GPU name=Radeon 5 vendor=0x1002 device=0x15bf and Insert instance layer "VK_LAYER_KHRONOS_validation", and none logs was not found but was requested.

AI-assisted: yes (build and runs scripted with an AI assistant, on the hardware above).

@milescoviello

Copy link
Copy Markdown
Contributor Author

Thanks @rafaconvaitis for the Windows + AMD-driver run with the validation layer and the negative control. I've added it to the Tested section, linked to your comment, and the GPU to the GPUs tested line.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 20, 2026
@milescoviello
milescoviello force-pushed the fix/agc-image-table-written-keys branch from 8b93371 to 742d417 Compare November 20, 2026 14:36
milescoviello added a commit to milescoviello/AnyPS5 that referenced this pull request Nov 20, 2026
boykopovar#22690 poisons only the records a dispatch's writes overlap for tables
read through a 64-bit pointer. A table read through a buffer V# still
took the whole-table fault, so a dispatch that writes elsewhere in the
same V# faulted on every entry.

A direct buffer column reads record k at
base + ((addend + k * stride + immediate) & ~3). With a 4-byte-aligned
stride, addend and immediate, no indirection, carried offsets or
selected record, and no 32-bit wrap over the captured keys, that is
start + k * stride, so the materializer records the same layout for it
and finishImageTables poisons just the overlapping records. The shader
takes a buffer table's map code only for a record below the key count,
as for a pointer table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@milescoviello

Copy link
Copy Markdown
Contributor Author

Rebased onto main 0a025bd3c6 (head 742d417e29). main had moved the shader disk cache to format 95 and grown two encoded structs, so this now sets FormatVersion 96 and updates the size asserts. #22692 also sets 96, so whichever of the two lands second needs a one-line rebase. The 33 image table, shader memory and disk cache tests pass 3 runs on Linux; details are in Tested.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — no blocking findings

Nothing in the code I read shows a verified blocking defect; I could not complete a full review because the repository reader command was unavailable.

What I ran

  • Target head: 742d417e294bb1b22a80984671f85585e16934dd.
  • Read the prepared description, commits, manifest and diff, plus targeted source ranges through the review reader.
  • No tests or builds were run. The reader command was not available in this interface, so I could not run repo_read.py as requested.

Results

Check Result Note
Prepared bundle review passed Diff and metadata read
Targeted source review not run Only selected ranges were accessible
Tests and build not run No commands ran

Findings

Blocking

None verified in the code read.

Non-blocking

None.

Not verified

  • ShaderResources.cpp’s changed range, materializer logic, cache serialization, and relevant test ranges were read. The full changed-file set was not reviewed.
  • files.json was unavailable through the provided reader; the manifest identifies one excluded changed file: core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp (full text too large for the review folder). I read only lines 6810–6875 at the pinned head.
  • No tests, build, conventions check, merged-preview check, negative control, or hardware run was performed in this review. Reported runs in the description are author-supplied and were not independently verified.

To get this to a good state

Nothing is required. The implementation’s selective map poisoning appears consistent with the stated linear record layout for the inspected ranges; review the remaining changed code and run the relevant checks before treating this as a complete approval.

milescoviello added a commit to milescoviello/AnyPS5 that referenced this pull request Nov 20, 2026
boykopovar#22690 poisons only the records a dispatch's writes overlap for tables
read through a 64-bit pointer. A table read through a buffer V# still
took the whole-table fault, so a dispatch that writes elsewhere in the
same V# faulted on every entry.

A direct buffer column reads record k at
base + ((addend + k * stride + immediate) & ~3). With a 4-byte-aligned
stride, addend and immediate, no indirection, carried offsets or
selected record, and no 32-bit wrap over the captured keys, that is
start + k * stride, so the materializer records the same layout for it
and finishImageTables poisons just the overlapping records. The shader
takes a buffer table's map code only for a record below the key count,
as for a pointer table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@milescoviello

Copy link
Copy Markdown
Contributor Author

Pushed 8021995a83: the record keys a store poisons now come from ImageTableRecordLayout::KeysOverlapping, which can't wrap at the top of the address space. MarcZX10 found this while reviewing #22703, which builds on this commit. Tested has the new checks and a negative control.

milescoviello added a commit to milescoviello/AnyPS5 that referenced this pull request Nov 20, 2026
boykopovar#22690 poisons only the records a dispatch's writes overlap for tables
read through a 64-bit pointer. A table read through a buffer V# still
took the whole-table fault, so a dispatch that writes elsewhere in the
same V# faulted on every entry.

A direct buffer column reads record k at
base + ((addend + k * stride + immediate) & ~3). With a 4-byte-aligned
stride, addend and immediate, no indirection, carried offsets or
selected record, and no 32-bit wrap over the captured keys, that is
start + k * stride, so the materializer records the same layout for it
and finishImageTables poisons just the overlapping records. The shader
takes a buffer table's map code only for a record below the key count,
as for a pointer table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

The reviewed changes appear sound at head 2e182729d04d674d982e42a4ee2eada1547ba721; no checks were run in this review, and author-reported test results were not independently verified.

What I ran

No commands or tests were run. I read the prepared diff and changed source through the pinned reader at the stated head.

Results

Check Result Note
Source review passed Reviewed all changed lines and relevant source context.
Tests not run Test results in the description are author-reported.

Findings

Blocking

None.

Non-blocking

None.

Not verified

  • I did not run builds, tests, negative controls, or console and GPU checks.
  • Changed files read: ShaderResources.cpp, ShaderDiskCache.cpp (driver test), ImageTable.cpp, ResourcePlan.hpp, ResourceMaterializer.cpp, Recompiler.cpp, Recompiler.hpp, ShaderDiskCache.cpp (recompiler), ShaderDiskCache.hpp, and fix-agc-image-table-written-keys.md.
  • Excluded changed files: none. ShaderResources.cpp was not present in the review folder but was read through repo_read.py. The remaining changed files were read from the review folder; their changed lines were reviewed.

To get this to a good state

Nothing is required.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change; the inspected code supports per-record poisoning for eligible pointer tables and preserves whole-table faults for unsupported layouts.

What I ran

Reviewed head 19f7d4a0ab5839eb72a80a7246cf28dc76dff84a using the prepared diff and pinned reader. No build or tests were run; reported test results below are author-supplied.

Results

Check Result Note
Code review passed Core changed paths inspected
Automated tests not run No commands run
Author-reported tests passed Targeted tests and negative controls reported

Findings

Blocking

None.

Non-blocking

None.

Not verified

No files were excluded by rule. Read changed files: ShaderResources.cpp (changed hunk), ShaderDiskCache.cpp, ShaderDiskCache.hpp, ImageTable.cpp (changed hunks), ResourcePlan.hpp (changed hunk), ResourceMaterializer.cpp (changed hunk), Recompiler.cpp (changed hunk), Recompiler.hpp (changed hunk), ShaderDiskCache.cpp test (changed hunks), and fix-agc-image-table-written-keys.md. Other unchanged context and runtime behavior were not verified. The tests described in the PR body were not run by this review.

To get this to a good state

Nothing is required.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@milescoviello

Copy link
Copy Markdown
Contributor Author

New head 0aaaa698c4: main (4c7578e0a4) merged in. The only conflict was FormatVersion, which main moved to 98; this change keeps 104. The 34 agc_driver_image_table*, agc_shader_memory and agc_shader_disk_cache* tests pass in each of 3 runs at this head.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks approval; the reviewed changes correctly limit poisoning to overlapping pointer-table records where a supported linear layout is available.

What I ran

Reviewed head 0aaaa698c4a5d42a863c285f671aaad9bf391923. Read the prepared description, commit list, manifest, diff, and relevant changed code through repo_read.py; no build or tests were run in this review.

Results

Check Result Note
Diff and changed-code review passed Targeted code paths inspected
Automated checks not run No commands or tests run

Findings

Blocking

None.

Non-blocking

None.

Not verified

No tests were run here; author-reported tests and runtime results were not independently verified. Read: description.md, commits.md, manifest.json, diff.patch; changed code in ShaderResources.cpp, ImageTable.cpp, ResourceMaterializer.cpp, ImageTableAbi.hpp, Recompiler.cpp, Recompiler.hpp, ShaderDiskCache.cpp, and ShaderDiskCache.hpp. The full text of ShaderResources.cpp was excluded from the prepared review folder, so only the relevant range was read via repo_read.py. All changed files marked included in the manifest were not read in full.

To get this to a good state

Nothing is required.

@milescoviello

milescoviello commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor Author

The failing relinker (macos-latest, clang++) check is one test, frame_capture_minimize_replay: os.killpg raised PermissionError on the macOS runner during replay cleanup (ReplayCleanupError: cannot confirm replay process group cleanup). It is unrelated to this change; mcarkade's open #27860 is aimed at this macOS cleanup failure. The other 1025 tests in that job passed.

One conflict, FormatVersion: main moved to 99; this change keeps 104,
which no other open pull request uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Dec 3, 2026
milescoviello added a commit to milescoviello/AnyPS5 that referenced this pull request Dec 3, 2026
…en-buffer-keys

Restacks on boykopovar#22690's merge of main; FormatVersion stays 104.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@milescoviello

Copy link
Copy Markdown
Contributor Author

New head ee03b3fa16: merged main 3ff0401064. The only conflict was FormatVersion (main 99); this change keeps 104. 35 of the 36 area tests pass in each of 3 runs; agc_shader_disk_cache_large_file fails only with /tmp on tmpfs in my batch environment and passes with TMPDIR on a disk. Details are in the Tested section.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this; the points below are optional.

What I ran

Reviewed head ee03b3fa16b922170513b846d22cfdd44cb69f07 using the pinned repo_read.py reader and the prepared diff. No tests or builds were run.

python3 repo_read.py cat <changed-path> <start> <end>
python3 repo_read.py search "imageTableRecords" core

Results

Check Result Note
Changed source inspection passed All 10 reviewed files were read
Tests and build not run No local execution
Prepared review inputs passed No files excluded

Negative control

Not run locally. The description reports prior negative-control runs; I did not independently verify them.

Findings

Blocking

None.

Non-blocking

None.

Sources

The changed code derives a linear record layout only for supported pointer-table columns, carries it through the invocation and disk cache, and poisons only overlapping keys when that layout is available. The overlap helper handles inclusive address-space ends. Implementation at the reviewed head · Record range helper and tests

Files read: core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp, core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp, core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp, core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hpp, core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp, core/shader/recompiler/Recompiler.cpp, core/shader/recompiler/Recompiler.hpp, core/shader/recompiler/ShaderDiskCache.cpp, core/shader/recompiler/ShaderDiskCache.hpp, and docs/dev/debt/changes/fix-agc-image-table-written-keys.md. Excluded files: none.

Not verified

I did not run tests, builds, or hardware checks. Reported test and game runs in the PR description were not independently verified.

To get this to a good state

Nothing is required.

@ligmaSec ligmaSec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both image-table record-reuse CTests passed on main and aborted on the patched tree, including the narrow case. The scalar-buffer and shader-disk-cache controls passed on both trees. I used the same Linux lavapipe device with Vulkan required, shader cache disabled, and validation layer 1.4.369. Both logs show layer insertion and contain no missing-layer diagnostic or VUID- entry. The two aborts appeared without an assertion message in the CTest log.

AI-assisted: yes.

@milescoviello

Copy link
Copy Markdown
Contributor Author

@ligmaSec thank you, that is the kind of report I want to see. I have not reproduced it yet. On the #22703 head 2a4768003e, which contains all of this change, agc_driver_image_table_reuse_records and agc_driver_image_table_reuse_records_narrow pass on lavapipe (VK_ICD_FILENAMES set to lvp_icd.json, ANYPS5_REQUIRE_VULKAN=1, the tests' own ANYPS5_NO_SHADER_CACHE=1) and on an RTX 4070 Ti. I am building this PR's own head ee03b3fa16 to run the same two there, and I will post the result here.

Two things would help me match your run: was the patched tree this head as is, or merged with other open PRs, and does the test binary print anything to stdout or stderr before it aborts (ctest -V -R '^agc_driver_image_table_reuse_records')?

@milescoviello

Copy link
Copy Markdown
Contributor Author

Follow-up on this head itself: I built ee03b3fa16 and ran agc_driver_image_table_reuse_records and agc_driver_image_table_reuse_records_narrow on lavapipe only (VK_ICD_FILENAMES limited to lvp_icd.json, so llvmpipe (LLVM 21.1.8) is the device selected, ANYPS5_REQUIRE_VULKAN=1, the tests' own ANYPS5_NO_SHADER_CACHE=1 and APS5_PROFILE_DRAW=1). Both pass in each of 3 runs, so I still cannot reproduce the abort. If your patched tree had other PRs merged in, or a different lavapipe version, that would be the difference I am looking for; the -V output of one aborting run would show where it stops.

@B-Howell

B-Howell commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Windows tester result at head ee03b3fa16b9, merged onto main de4730493ab4: pass.

  • Windows 11 Pro 26300, NVIDIA GeForce RTX 4080 SUPER (621.14), WinLibs GCC 15.2.0 r7, Release.
  • agc_driver_image_table_tests, agc_shader_disk_cache_tests, the five other agc_driver_image_table_* targets and agc_driver_graphics_tests and its neighbours (176 tests over two sets, including agc_driver_image_table_reuse_records and _narrow): all pass, 3 runs out of 3. The two reuse_records tests that aborted in the lavapipe report pass here on all three runs.
  • Control: the new ImageTable.cpp and ShaderDiskCache.cpp tests do not compile against main's production files, so I used this PR's tree with only the per-record branch in finishImageTables disabled (whole-table poison, as on main): agc_driver_image_table fails with pointer image table: a store into entries no key of the dispatch selects faulted.
  • With ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: the layer was inserted on main and on the PR (same tests), never "not found", and 0 VUID- on either.

@milescoviello

Copy link
Copy Markdown
Contributor Author

@B-Howell thank you, especially for the control and for running the two reuse_records tests; it is in the Tested section now.

@ycbuzi

ycbuzi commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Tested ee03b3fa16 merged into main, with the whole ctest suite on each machine below. Nothing fails that does not also fail on main on the same machine.

  • Windows Server 2022 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 99% tests passed, 2 tests failed out of 7534; 99% tests passed, 3 tests failed out of 7534. 2 of the failing tests fail on main too. run
  • Windows Server 2025 (GitHub-hosted runner), full build, WinLibs GCC 15.2.0: 100% tests passed, 0 tests failed out of 7534; 100% tests passed, 0 tests failed out of 7534. run

GPU (software Vulkan): 5 GPU tests (AGC, shader recompiler) passed twice on Mesa lavapipe (Mesa 25.2.8-0ubuntu0.24.04.5 (LLVM 20.1.2)) on a GitHub-hosted Ubuntu 24.04 runner, with the Khronos validation layer on and the shader cache off, alongside main c1593e4e1d: no Vulkan validation message appears that main does not also produce. run

Not covered: GPU hardware. lavapipe runs Vulkan on the CPU, so this says nothing about how real GPU drivers handle the changed paths.

AI-assisted: yes (Claude Code); the runs are automated, this summary was written from their reports.

@milescoviello

Copy link
Copy Markdown
Contributor Author

@ycbuzi thank you for the run; it is in the Tested section now.

# Conflicts:
#	core/shader/recompiler/ShaderDiskCache.hpp

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

The reviewed changes at head c52fee17494b8b7b9f06987ce2f6305b28858afd consistently track overlapping pointer-table records through dispatch completion and disk-cache serialization; I found no verified defect.

What I ran

Read the prepared diff and manifest, then inspected the changed dispatch logic and its shader lookup context at the pinned head. I did not run tests or builds.

python3 repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp 7540 7620
python3 repo_read.py cat core/shader/recompiler/SpirvBackend/src/SpirvImageEmitter.cpp 2550 2605
python3 repo_read.py cat core/shader/recompiler/ImageTableAbi.hpp 120 152

Reviewed the hunks for all 10 files listed under files.json → reviewed; files.json lists no excluded files. The full ShaderResources.cpp text was not in the review folder and was read through repo_read.py.

Results

Check Result Note
Source review passed Dispatch poisoning, record lookup, and serialized layout are consistent
Tests and build not run No executable checks were run
Negative control not run The description reports author-run controls

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

No tests, builds, hardware runs, or negative controls were performed for this review. Runtime claims and test results in the PR description are author-reported.

To get this to a good state

Nothing is required.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants