Skip to content

fix(agc): poison only the buffer-table records a dispatch writes - #22703

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

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

Conversation

@milescoviello

@milescoviello milescoviello commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What

#22690 poisons only the records a dispatch's writes overlap, for image tables read through a 64-bit pointer. A table read through a buffer V# still takes the whole-table TableFault. So a dispatch that writes elsewhere in the same V# (a heap V# that also covers the dispatch's output, for example) faults on every entry it selects.

This extends the same per-key poison to direct buffer tables:

  • Layout. A buffer column reads record k at base + ((addend + k * stride + immediate) & ~3) (ScalarBufferDword). With a 4-byte-aligned stride, addend and immediate, that's start + k * stride with start = base + addend + immediate. The column must also have no indirection, carried offsets or selected record, and no 32-bit wrap over the captured keys.
  • Materializer. ResourceMaterializer now records that layout for such a column too.
  • Driver. finishImageTables (from fix(agc): poison only the pointer-table records a dispatch writes #22690) then poisons just the overlapping records, unchanged.
  • Why it's sound. The shader takes a buffer table's map code only for a record below the key count (LookupTableWord: inMap = aligned && record < keys), as for a pointer table. So the records outside the write are the descriptors they held when the dispatch started.
  • Still whole-table. Nested and indirect tables, and tables without such a layout, keep the whole-table fault.
  • Debt. fix(agc): poison only the pointer-table records a dispatch writes #22690's debt fragment is updated in place, since both change the same entry.

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-22, a title data point, one run per build: Crimson Desert (PPSA25286). On main, the run logs deferred write-back failed: image table: ... is written by its own dispatch 33 times on e3f556c718 (killed at the 20 GiB memory cap at 98 s), and 4 times on 608ea91728 (606 s, still compiling pipelines on a cold driver cache). With this head merged onto main 10a9c248ff (e126821865), the run logs it 0 times. That run is still killed at the same cap, at 483 s, after the same 10464 MiB texture-cache request as the e3f556c718 run. So this PR does not move the title past that memory cap.
  • 11-28, a second title data point: Crimson Desert again, one run with the change and no repeat. With this head merged onto main 859a238b8 (33a597a22ed), the run presented 118 frames and logged that line 0 times in its 206 s; it was then killed at the 20 GiB memory cap, so it says nothing about the title getting further. For comparison, the eleven rotation runs on main from 11-28 to 11-29 (rounds 99-109, on that day's main heads; six of them with my local log-only diagnostic builds, which do not touch image tables): the five that presented 45 frames or more logged it 52 to 133 times each (56 frames: 76, 150: 120, 63: 92, 278: 133, 45: 52), and the six that stopped at 0 to 4 frames logged it 2 to 8 times, including round 108 on the same main 859a238b8 (0 frames, 2 lines).
  • 12-03: restacked as 2a4768003e on fix(agc): poison only the pointer-table records a dispatch writes #22690's ee03b3fa16 (main 3ff0401064), with no other conflict. Of the 36 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.
  • 11-27 (2nd): restacked as 6c1a013010 on fix(agc): poison only the pointer-table records a dispatch writes #22690's 0aaaa698c4 (main 4c7578e0a4), with no other conflict. The 34 tests pass in each of 3 runs.
  • 11-27: restacked as 415d4f0079 on fix(agc): poison only the pointer-table records a dispatch writes #22690's 19f7d4a0ab (main 80781a0e94, RecompileResult check 592), with no other conflict. The 34 tests pass in each of 3 runs.
  • 11-26 (2nd): head a1e2375961 adds CodeRabbit's guard: a buffer column whose dwords would wrap past 32 bits (column.offset + dwordCount * 4 over 2^32) records no layout and keeps the whole-table fault. The 34 tests pass in each of 3 runs.
  • 11-26: restacked as a264f28535 on fix(agc): poison only the pointer-table records a dispatch writes #22690's 06fae1ad18 (main c64b9d323f merged in, FormatVersion 104), with no further conflict. The 34 tests pass in each of 3 runs at 601743d76b (the same change with FormatVersion 100), and agc_driver_image_table and agc_shader_disk_cache* pass in each of 3 runs at a264f28535.
  • 11-21 (2nd): restacked as 4d04241bf3 on fix(agc): poison only the pointer-table records a dispatch writes #22690's rebased 660f02cdd7 (main ef7dc4452d), with no conflict. The 33 tests pass in each of 3 runs. 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: restacked as 97bd69a994 on fix(agc): poison only the pointer-table records a dispatch writes #22690's rebased 74213a85f6 (main 70602fcc03). The one conflict, with main's pointerKeyed line in ResourceMaterializer, is resolved by keeping both. The 33 tests pass in each of 3 runs. Windows 11 VM (GeForce GT 1030, WinLibs GCC 16.2, Ninja, Release): 35 tests pass in each of 3 runs.
  • 11-20: restacked as dba3d1fdd4 on fix(agc): poison only the pointer-table records a dispatch writes #22690's 8021995a83, which makes the overlapped record range safe at the top of the 64-bit address space (the change MarcZX10 asked for here; the arithmetic is in fix(agc): poison only the pointer-table records a dispatch writes #22690's commit). 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.
  • 11-20: restacked again as 5b065573b2 on fix(agc): poison only the pointer-table records a dispatch writes #22690's 2e182729d0, which only adds the two boundary checks MarcZX10 suggested. The 33 tests pass 3 runs.
  • 11-20: restacked as 237fc86c74 on fix(agc): poison only the pointer-table records a dispatch writes #22690's db70e3dceb, which fixes the last-address case MarcZX10 found in 5b065573b2. The 33 tests pass 3 runs.
  • agc_driver_image_table gains a 64-record copy of its buffer table (WideTable, 48-byte records), next to the existing case where a dispatch stores over its whole 12-record table:
    • A TableCode dispatch for key 0 whose output buffer lies over records 32-53 of the same V# doesn't fault, and samples what the run without the store samples.
    • The same dispatch with its output over record 0 still faults with is written by its own dispatch.
  • ^(agc_driver_image_table.*|agc_shader_memory|agc_shader_disk_cache.*)$ (33 tests) passes, 3 runs.
  • Negative control: with fix(agc): poison only the pointer-table records a dispatch writes #22690's ResourceMaterializer.cpp (pointer tables only) and the new test, agc_driver_image_table fails with image table: a dispatch storing into records no key of it 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 242a66e434.
  • 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 fix(agc): poison only the pointer-table records a dispatch writes #22690's ResourceMaterializer.cpp fails agc_driver_image_table in 2 of 2 runs.
  • git merge-tree against main is clean. tools/check_conventions.py passes on both commits and this body, and tools/debt_fold.py --check reports nothing new for the fragment.
  • Rebased 11-18 onto main d89f26516c as aaa04676a3 (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 aaa04676a3.
  • Rebased 11-20 onto main 0a025bd3c6 as 07b2ea76cc. 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 aaa04676a3 merged onto main d89f26516c as 682bde0727 (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 aaa04676a3 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.
  • Run by @ycbuzi (comment): Windows Server 2022 and 2025 (GitHub-hosted runners), WinLibs GCC 15.2.0, 2a4768003e merged into main, the whole ctest suite twice per runner: no failures on Server 2025; on Server 2022, 2 and then 4 failures out of 7534, 2 of which also fail on main (the report does not name the other two). 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

Summary by CodeRabbit

  • Bug Fixes
    • Writes that overlap specific shader image-table records now flag only the affected records, leaving unaffected records usable.
    • Writes outside selected records no longer cause those records to fault; writes that overlap selected records still do.
    • Invalid or unrecognized record layouts continue to trigger a table-wide fault when the affected records cannot be reliably identified.

@github-actions github-actions Bot added shader core/shader docs agc libSceAgc* labels Nov 18, 2026
@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, L1189-1190
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, L1189-1190
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, L1189-1190
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, L1189-1190
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, L1189-1190
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, L1189-1190
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, L1189-1190
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, L1189-1190
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, L1189-1190
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 242a66e434 (#22690's commit plus this one) 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 WideTable cases. On this PR, agc_driver_image_table with them passes (image table tests passed), and so does agc_shader_disk_cache with its extra layout check. Every device selection picked the RTX 4090.

Negative control, as in the description: this PR's build with #22690's ResourceMaterializer.cpp fails agc_driver_image_table deterministically (2 of 2 runs) with AGC graphics: image table: a dispatch storing into records no key of it 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.

@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 blocks this change; the points below are optional.

What I ran

Reviewed head 242a66e434c8c77293544ed7ddbceabd2b127e38. I read the prepared description, commits, manifest and diff, plus the changed ShaderResources.cpp and ResourceMaterializer.cpp ranges through repo_read.py. No commands or tests were run in this environment; test results in the description are author-reported.

Results

Check Result Note
Patch review passed Inspected changed logic and tests
Automated checks not run No command runner available

Findings

Blocking

None found in the inspected code.

Non-blocking

None.

Not verified

Full text of ShaderResources.cpp was excluded from the review bundle; only lines 6780–6850 were read. Other changed files were included in the bundle but their full text was not read. The repository-wide call paths, test execution, and author-reported CI/device results were not independently verified.

To get this to a good state

Nothing is required.

@milescoviello
milescoviello force-pushed the fix/agc-image-table-written-buffer-keys branch from 242a66e to aaa0467 Compare November 19, 2026 00:28

@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 — comments

This review covers head aaa04676a39b4c9c4d8cfa5b88f3cffd0165e07d; code behavior looks sound in the inspected paths, but the oversized ShaderResources.cpp change was not run or fully verified here.

What I ran

Read the prepared diff and targeted files at the pinned head. No commands or tests were run.

Results

Check Result Note
Diff and targeted source review passed Core layout and poisoning paths inspected
Tests not run Only author-reported results are available

Findings

Blocking

None in the code inspected.

Non-blocking

  • The output-buffer overlap calculations use address + bytes and records.start + records.bytes without checked addition (ShaderResources.cpp:6827-6829). Address ranges near UINT64_MAX can wrap and produce incorrect record selection. Consider using overflow-safe overlap and endpoint calculations.

Not verified

  • ShaderResources.cpp is excluded from files/ because it is too large; its changed lines were read through the pinned-head reader, but surrounding callers and the full file were not reviewed.
  • ShaderDiskCache.cpp, ShaderDiskCache.hpp, the test file ShaderDiskCache.cpp, ImageTable.cpp, ResourcePlan.hpp, Recompiler.cpp, Recompiler.hpp, ResourceMaterializer.cpp, and the debt fragment were read in the relevant ranges. The other unchanged context and all excluded files were not reviewed.
  • No tests, build, precheck, negative control, merge preview, or hardware run was performed. Results reported in the PR description were not independently verified.

To get this to a good state

Nothing is required. Optional: use checked arithmetic for the range endpoints and add an edge-case test for wrapping address ranges.

@milescoviello

Copy link
Copy Markdown
Contributor Author

Thanks @MarcZX10 for the review of aaa04676a3. On the optional overflow point at ShaderResources.cpp:6827-6829: those sums can't wrap for the ranges that reach that loop.

  • Every [address, bytes) there is a written guest allocation or storage texture that has already passed overlaps(...) against the table (the subtraction-based check at line 6794), and records.start/records.bytes describe the table's own record column inside that table.
  • All of these are guest GPU addresses. They lie in the 48-bit GPU address space the driver already enforces elsewhere (for example Pm4.cpp:514, "ACQUIRE_MEM range exceeds 48-bit address space"), so address + bytes and records.start + records.bytes stay below 2^49.

I'd rather keep the loop as it is, but I can switch it to subtraction-only endpoints with a wrap test if you'd prefer that for consistency.

@Colewiz7

Copy link
Copy Markdown
Contributor

Head aaa04676a3 merged onto main d89f26516c as 682bde0727, 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. agc_driver_pm4_order_signal fails solo on main at the same commit too, so it comes from this machine, not the PR.

AI-assisted: yes

@milescoviello

milescoviello commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased onto main d89f26516c as aaa04676a3: 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 aaa04676a3.

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 aaa04676a3 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: image table: a dispatch storing into records no key of it 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-buffer-keys branch from aaa0467 to 07b2ea7 Compare November 20, 2026 14:36
@milescoviello

Copy link
Copy Markdown
Contributor Author

Rebased onto main 0a025bd3c6 with #22690 (head 07b2ea76cc). The only conflict was the disk cache format and size asserts, now FormatVersion 96 against main's 95. 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 — comments

Changes are required before merge: verify the record-overlap math against writes at the end of the 64-bit address space; the current arithmetic can wrap and poison unrelated map entries.

What I ran

  • Reviewed head 07b2ea76cc60695e22ba87f73972a89edd8fd0d5; base is main. No merged-preview check was run.
  • Read the prepared description, commits, manifest, and diff. Read the full changed source ranges for ResourceMaterializer.cpp, ShaderResources.cpp, ShaderDiskCache.cpp, and ShaderDiskCache.hpp, plus relevant ranges in the test, Recompiler.hpp, and Recompiler.cpp.
  • No commands or tests were run; repo_read.py was unavailable as a command. Author-reported test results were not independently verified.

Results

Check Result Note
Diff and targeted source review passed One arithmetic concern found
Tests not run Results in description are author reported
Full changed-file coverage not run ShaderResources.cpp was excluded from the prepared full texts

Findings

Blocking

  • In core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp:6854-6856, the overlap calculation adds bytes to an arbitrary store address and subtracts records.start from that sum without guarding overflow. A write range near UINT64_MAX can wrap address + bytes, making the calculated past small and potentially making an overlapping write appear not to poison the affected records. Use overflow-safe interval endpoints or saturating/clamped arithmetic before deriving the key interval.

Non-blocking

None.

Not verified

  • The full changed contents of ShaderResources.cpp were excluded because the file was too large; only the relevant changed range was read. files.json was not available through the reader.
  • Full contents of ImageTable.cpp and ShaderDiskCache.cpp were not read; targeted ranges around the changes were inspected. The remaining changes in ShaderDiskCache.cpp, Recompiler.cpp, Recompiler.hpp, ResourcePlan.hpp, and the debt fragment were not fully read.
  • No tests, build, or negative control were run. Test results in the description are author reported.

To get this to a good state

Guard the store-range endpoint arithmetic in the changed overlap calculation, then rerun the relevant image-table tests on the updated head.

@milescoviello

Copy link
Copy Markdown
Contributor Author

Thanks @MarcZX10, you're right. address + bytes wraps for a store range that reaches the end of the 64-bit address space, and then the <= records.start check skips records the store overlaps. That arithmetic is in #22690's commit, so the fix is there: 8021995a83 moves the range into ImageTableRecordLayout::KeysOverlapping, which clamps the store's last byte and the first record's end instead of adding past them.

agc_driver_image_table now checks it directly, including a store running past the top of the address space and one ending exactly at it. With the old formula the test fails on the first of those. This PR is restacked on it as dba3d1fdd4, and the 33 image table, shader memory and disk cache tests pass 3 runs on both heads.

@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 dba3d1fdd4df16f88a806423600b1c1abb24dedd using repo_read.py to inspect the prepared diff and targeted source ranges. No tests or build checks were run.

Results

Check Result Note
Diff and targeted source review passed Core changed paths inspected
Build and tests not run Author-reported runs not independently verified

Findings

Blocking

None found in the code inspected.

Non-blocking

  • The range tests cover ordinary overlap and the top of the address space, but do not cover empty records (bytes == 0) or an address range that begins beyond the final key. Consider adding cases for those boundaries to ImageTable.cpp.

Not verified

No code defect was identified in the inspected hunks. The full ShaderResources.cpp was excluded by the review bundle size limit; only lines 6800–6880 containing the changed function were read through repo_read.py. Read the included full text for ShaderDiskCache.cpp, ImageTable.cpp, ResourcePlan.hpp, ResourceMaterializer.cpp, Recompiler.cpp, Recompiler.hpp, ShaderDiskCache.hpp, and the debt fragment only at the relevant ranges, not in full. No files were excluded by the change bundle other than ShaderResources.cpp. Builds, tests, GPU behavior, cache compatibility, and the author-reported platform runs were not independently verified.

To get this to a good state

Nothing is required. Optional: extend range tests to cover zero-byte records and writes beyond the last key.

@milescoviello
milescoviello force-pushed the fix/agc-image-table-written-buffer-keys branch from dba3d1f to 5b06557 Compare November 20, 2026 15:52
@milescoviello

Copy link
Copy Markdown
Contributor Author

Thanks @MarcZX10. Both cases are in now: #22690's 2e182729d0 checks that records of zero bytes and a store past the last of 64 records select no keys, and this PR is restacked on it as 5b065573b2. The 33 image table, shader memory and disk cache tests pass 3 runs on both heads.

@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 — changes requested

Changes are required before merge: fix the overlap calculation for a record range that reaches the maximum address.

What I ran

No commands or tests were run. I read the prepared diff and targeted source ranges at head 5b065573b2f3b18e7adaa59206b2164f4f2f89ae; the repository reader was used for context.

Results

Check Result Note
Source review failed Maximum-address overlap can be missed
Tests not run Reported runs were not independently verified

Findings

Blocking

  • core/shader/recompiler/Recompiler.hpp:961: firstEnd is intended to be the exclusive end of the first record, but saturating it at UINT64_MAX loses the representable one-past-the-end value. For a layout starting at UINT64_MAX with nonzero bytes, and a one-byte store at UINT64_MAX, lastKey selects key 0 while address < firstEnd is false; skipped then yields first == 1, so the function returns an empty range and the record is not poisoned. This contradicts the stated maximum-address handling. Compute overlap without relying on an unrepresentable exclusive endpoint, and add a boundary case for a record beginning at the maximum address.

Non-blocking

None.

Not verified

  • Tests and reported CI runs were not executed or independently confirmed.
  • Full-file text was not read. The changed ShaderResources.cpp was excluded from the prepared files bundle because it was too large; its changed hunk was read through the reader. Other changed files were included, and the relevant changed ranges were inspected. The complete contents of ShaderDiskCache.cpp and ImageTable.cpp were not read.

To get this to a good state

Fix the maximum-address range calculation and add a regression test for a record starting at UINT64_MAX; rerun the reported image-table and shader-memory/disk-cache checks on the updated head.

@milescoviello
milescoviello force-pushed the fix/agc-image-table-written-buffer-keys branch from 5b06557 to 237fc86 Compare November 20, 2026 16:11
@milescoviello

Copy link
Copy Markdown
Contributor Author

Thanks @MarcZX10, that's right: saturating the first record's exclusive end at UINT64_MAX made a record that starts at the last address look empty. #22690's db70e3dceb now compares inclusive ends, the store's first byte against the first record's last byte, which is always representable. agc_driver_image_table checks a record at UINT64_MAX with a one-byte store there and with a store ending there, and both select key 0. With the previous KeysOverlapping the test fails on the first of those. This PR is restacked on it as 237fc86c74, and the 33 image table, shader memory and disk cache tests pass 3 runs on both heads.

@milescoviello

Copy link
Copy Markdown
Contributor Author

New head 415d4f0079, restacked on #22690's 19f7d4a0ab (main 80781a0e94), with no other conflict. The 34 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 this change; the targeted code paths and added tests support the described per-record poisoning behavior.

What I ran

Reviewed head 415d4f00792a195dcebd96d432980e6a3711ab99. I read the prepared description, commit list, manifest, diff, and all included changed files; I also read the changed ShaderResources.cpp hunk through repo_read.py and targeted shader lookup and address calculation code. No commands or tests were run in this review.

Results

Check Result Note
Change review passed Targeted logic and tests inspected
Tests not run Reported runs are author supplied
Full file coverage not run One changed file was excluded for size

Findings

Blocking

None.

Non-blocking

None.

Not verified

The full ShaderResources.cpp file was excluded by the review bundle; only lines 6979–7039 containing its changed hunk were read through repo_read.py. The other changed files listed in the manifest were read. I did not independently verify the author-reported builds, runtime behavior, or test results.

To get this to a good state

Nothing is required.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Nov 27, 2026
@milescoviello

Copy link
Copy Markdown
Contributor Author

The failing relinker (macos-latest, clang++) check is one test, frame_capture_minimize_replay (test_owned_descendant_is_drained_after_parent_exit): os.killpg(pid, 0) in tools/frame_capture_minimize.py raised PermissionError on the macOS runner, as on #27716. This pull request does not touch that tool; mcarkade's open #27860 looks like the fix. The other 1,023 tests in that job passed.

milescoviello and others added 2 commits November 27, 2026 23:45
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…en-buffer-keys

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

Copy link
Copy Markdown
Contributor Author

New head 6c1a013010, restacked on #22690's 0aaaa698c4 (main 4c7578e0a4), with no other conflict. The 34 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 — no blocking findings

Nothing blocks this change; the points below are optional.

What I ran

No commands were run; the reader interface was used to inspect the prepared diff and repository context at head 6c1a013010c134a84da81a55e4296968a50d3fa8.

Results

Check Result Note
Prepared diff inspection passed Read the complete prepared diff
Runtime tests not run No command runner was available

Findings

Blocking

None in the code inspected.

Non-blocking

None.

Not verified

  • The changed-line implementation in ResourceMaterializer.cpp, ResourcePlan.hpp, Recompiler.hpp, Recompiler.cpp, ShaderDiskCache.cpp, ShaderDiskCache.hpp, and the debt fragment was not retrieved: the reader returned the start of each file despite requested line ranges. ShaderResources.cpp full-text access was also unavailable through the reader, so its changed implementation was checked only against the prepared diff. These implementation details remain unverified.
  • The changed-line text of ShaderDiskCache.cpp and ImageTable.cpp was not independently retrieved from the repository. The prepared diff was read, but the changed test execution and cache serialization behavior were not verified.
  • No tests or negative control were run. Reported runs in the PR description are author-supplied and were not independently confirmed.
  • The review bundle's files/ entries could not be read through the available reader interface. Its listing reports eight included changed files and one excluded file; none of those full-file entries were successfully retrieved here.

To get this to a good state

Nothing is required.

milescoviello and others added 2 commits December 3, 2026 08:53
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>
…en-buffer-keys

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

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

Copy link
Copy Markdown
Contributor Author

New head 2a4768003e, restacked on #22690's ee03b3fa16 (main 3ff0401064) with no other conflict. 35 of the 36 area tests pass in each of 3 runs; the large-file cache test passes with TMPDIR on a disk (it fails only with /tmp on tmpfs in my batch environment).

@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 reviewed code and available evidence support merging.

What I ran

Reviewed head 2a4768003ed2c3cbde3888a16a7aff573b937e8f using read-only repo_read.py source reads and the prepared diff. No tests or build commands were run. The author reports targeted test runs; those are not reviewer-run results.

Results

Check Result Note
Changed code review passed All 10 changed paths reviewed
Tests and build not run Author reports targeted runs

Negative control

Not run by the reviewer. The author reports that the new buffer-table test fails with the earlier pointer-only materializer.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

Tests, builds, and console behavior were not independently run. Read all 10 changed paths. ShaderResources.cpp was too large for the review folder; its changed function was read through repo_read.py. No changed paths were listed as excluded by review rules.

To get this to a good state

Nothing is required.

@ycbuzi

ycbuzi commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Tested 2a4768003e 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, 4 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.

@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.

The narrow poisoning path requires a proved linear, aligned layout with no selected key, pointer hops, carried offset, or 32-bit wrap. The fixture checks a write elsewhere in the same wide buffer and a write over the selected descriptor. Please retain the uncertain-layout whole-table refusal as a negative control when rebasing the cache version. The paired image-table cases are queued on lavapipe.

AI-assisted: yes.

@milescoviello

Copy link
Copy Markdown
Contributor Author

Thanks @ligmaSec. A table whose record layout is not proved keeps main's path unchanged: in ShaderResources.cpp, when the program carries no record layout (records.stride == 0) or its key map does not fit the table map, the store still sets TableFault for the whole table, as before this PR. I would rather not pin that refusal in a test, though: the tests here pin what valid input does, and a later change that proves more layouts should be free to narrow those tables too without deleting a case. The two cases in the fixture cover the narrow path's guard (a store over a selected record still faults) and what it changes (a store beside it no longer does); I will keep both when the cache version is rebased.

# 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 preserve unaffected image-table entries and fault when a write overlaps a selected record.

What I ran

Head: 280189acd27a70472272ff601315b449f8dfdc98. No merged-preview check was run. No compiler or build system was used.

repo_read.py cat core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp 7530 7625
repo_read.py cat core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp 1590 1655
repo_read.py cat core/shader/recompiler/ImageTableAbi.hpp 100 160
repo_read.py cat core/shader/recompiler/ShaderDiskCache.cpp 700 810

Results

Check Result Note
Changed code review passed Diff and targeted context inspected
Tests and build not run Author-reported results not independently checked
Merged preview not run No merge check performed

Negative control

Not run in this review. The description reports a negative-control run; I did not independently verify it.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

The prepared diff hunks were reviewed for all 10 paths listed as reviewed in files.json. ShaderResources.cpp full text was excluded from the prepared folder because of its size; its changed region and context were read through the pinned repo_read.py. files.json lists no paths excluded by review rules. Tests, hardware behavior, and author-reported runs were not independently verified.

To get this to a good state

No follow-up is required for this review. If the head changes, review the new diff and rerun relevant checks on that head.

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.

7 participants