Skip to content

fix(shader): bound image-table snapshots by table-key ranges - #7684

Open
fdfawef324 wants to merge 2 commits into
boykopovar:mainfrom
fdfawef324:codex/table-key-ranges-1018
Open

fdfawef324 wants to merge 2 commits into
boykopovar:mainfrom
fdfawef324:codex/table-key-ranges-1018

Conversation

@fdfawef324

@fdfawef324 fdfawef324 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What

A 32-bit bit-scan key can select image-table records 0–31 or the all-ones sentinel, but capture still visits up to 65,536 records. Unreachable entries can then become invalid resources. Bound snapshots using conservative unsigned ranges through bit scans, bit counts and arithmetic. Masked offsets bound the final record rather than the unmasked key; shared columns retain the larger bound.

Keep the existing fault behavior for address columns and for a sentinel whose wrapped offset lies inside a heap. Records inside the proven bound are still captured and validated. Instruction execution semantics are unchanged. Cross-lane reads and cyclic values remain unbounded by the new range analysis. Serialize the sentinel flag alongside current selection and pointer-hop metadata. This rebase retains main's SharedValues/Seal storage and uses disk cache format 41 after main 40, with a naturally regenerated source fingerprint.

This addresses one table shape used by Demon's Souls (PPSA01342). The unbounded waterfall family, remaining giant-texture allocations and device loss need separate work.

Overlap review found a textual conflict with #7395's nested-table capture refactor, which depends on #7223. Its author agreed to merge #7684 first, then preserve both metadata fields, the sentinel predicate, parent budget and unbounded merged-pointer guard when moving capture into ReadColumn, followed by their combined table tests. There is no build dependency on those PRs. #7388 changes cross-lane known-bit propagation consumed by the existing bits bound; combined masked/empty-exec behavior has not been tested, and needs review before composing them. No defect in that PR is claimed.

Tested

Windows, GCC 15.2 Release/O3, exact head cbc4606a7906 based on main 676d423968a1:

  • CPU: agc_shader_bindless, agc_shader_memory, agc_shader_disk_cache, 3/3 passed without skips in 6.25 seconds. Cases cover masked bit counts with record masks 255 and 31, bit-scan sentinels, heap versus pointer faults, arithmetic overflow, merged columns and cache round trips. The rebase adapts three snapshot-word accesses to main's per-column storage.
  • Adversarial controls on the earlier df6aa653d1d7 head: removing the range proof failed the heap-bound assertion; removing the masked non-sentinel minimum failed the BitCount32 assertion. That exact range-analysis production code is retained through this rebase. Those removal runs are historical evidence; the CPU/GPU checks here were rerun on the current head. A separate independent source review checked unsigned transfer rules, sentinels, overflow, shifts, select/Phi cycles and current memo reuse; unknown/cross-lane cases remain conservative.
  • Regression batch: agc_driver_image_table, agc_driver_image_table_cache, agc_driver_image_table_cache_bounds, agc_driver_image_table_reuse, agc_driver_bindless_images, agc_driver_graphics, agc_driver_compute_table_calls, 7/7 passed without skips in 16.04 seconds. Five suites execute Vulkan on the RTX 3060; graphics and image-table-cache use CPU/mock paths. ANYPS5_REQUIRE_VULKAN=1 was set; executable/library hashes were checked before and after this exact-head run.
  • Conventions passed. Clean merge into main 72a3d9f2a49d checked separately; execution above is the stated 676-based candidate. Later main adds separate F16 conversion, optimizer input-validation and kernel stack changes; the combined merge was not executed. Linux execution was not run.

Encoded shaders are handwritten synthetic extensions of existing project fixtures; no game shader bytes are included. A prior private DS integration on a different stack completed its 3001.5-second cap and traced 32 records for the bit-scan column. That is historical integration evidence, not a controlled FPS, memory or timing comparison for this head. No title performance improvement is claimed.

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
  • 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: PPSA01342 Demon's Souls (PPSA01341) #1283, table-domain capture stop only
  • GPUs tested: NVIDIA GeForce RTX 3060 12 GB, driver 591.86 (32.0.15.9186), Vulkan 1.4.325, Windows Server 2025 10.0.26100
  • AI-assisted: yes

Co-Authored-By: Codex noreply@openai.com

@github-actions github-actions Bot added the unblocks title Names a title ID on the Unblocks line label Oct 18, 2026
@fdfawef324
fdfawef324 marked this pull request as ready for review October 18, 2026 22:58
@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

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 5371 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/shader.md
PR 5609 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 5925 core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/ARCHITECTURE.md
PR 6235 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 6743 docs/dev/ARCHITECTURE.md
PR 6924 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/debt/shader.md
PR 7085 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 7392 docs/dev/debt/shader.md
PR 7642 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/ARCHITECTURE.md
PR 7689 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 8939 core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/debt/shader.md
PR 9335 docs/dev/debt/shader.md
PR 9356 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/ARCHITECTURE.md
PR 9387 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/ARCHITECTURE.md
docs/dev/debt/shader.md
PR 9457 core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/debt/shader.md
PR 9508 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/ARCHITECTURE.md
PR 9633 core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/debt/shader.md
PR 9749 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/debt/shader.md
PR 9790 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/debt/shader.md
PR 9852 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 9897 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 9969 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/debt/shader.md
PR 10193 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/ARCHITECTURE.md
PR 10351 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 10359 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 10652 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
docs/dev/debt/shader.md
PR 10867 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 11483 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/debt/shader.md
PR 11551 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 12316 docs/dev/debt/shader.md
PR 12324 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hpp
PR 12828 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 12944 core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/debt/shader.md
PR 13928 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/ARCHITECTURE.md
PR 13929 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/ARCHITECTURE.md
PR 14032 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 14217 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
docs/dev/debt/shader.md
PR 14218 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
docs/dev/debt/shader.md
PR 14853 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/debt/shader.md
PR 14871 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/debt/shader.md
PR 14944 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 15343 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 15456 docs/dev/ARCHITECTURE.md
PR 15488 docs/dev/debt/shader.md
PR 15529 docs/dev/ARCHITECTURE.md
PR 15548 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/ARCHITECTURE.md
docs/dev/debt/shader.md
PR 15555 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/debt/shader.md
PR 15573 docs/dev/debt/shader.md
PR 15948 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/shader.md
PR 16260 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 16321 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/shader.md
PR 16391 core/shader/recompiler/ShaderDiskCache.cpp
PR 16415 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
docs/dev/debt/shader.md
PR 16472 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/debt/shader.md
PR 16571 docs/dev/debt/shader.md
PR 16631 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/debt/shader.md
PR 16812 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/debt/shader.md
PR 16814 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/debt/shader.md
PR 16831 docs/dev/ARCHITECTURE.md
PR 16935 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 16953 docs/dev/ARCHITECTURE.md
PR 17056 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 17606 docs/dev/debt/shader.md
PR 17611 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/ARCHITECTURE.md
PR 17623 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 17943 docs/dev/ARCHITECTURE.md
PR 18029 docs/dev/ARCHITECTURE.md
PR 18082 docs/dev/ARCHITECTURE.md
PR 18106 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/debt/shader.md
PR 18107 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/debt/shader.md
PR 18185 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
PR 18226 docs/dev/ARCHITECTURE.md
PR 18241 docs/dev/debt/shader.md
PR 18244 docs/dev/debt/shader.md
PR 18245 docs/dev/debt/shader.md
PR 18390 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 19096 docs/dev/debt/shader.md
PR 19429 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 19505 docs/dev/debt/shader.md
PR 19564 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
docs/dev/debt/shader.md
PR 19710 docs/dev/debt/shader.md
PR 19821 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 19852 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 19967 core/shader/recompiler/ShaderDiskCache.cpp
PR 20010 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 20030 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 20041 docs/dev/ARCHITECTURE.md
PR 20070 docs/dev/debt/shader.md
PR 20099 docs/dev/debt/shader.md
PR 20111 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 20114 docs/dev/debt/shader.md
PR 20130 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 20131 docs/dev/debt/shader.md
PR 20153 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 20248 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 20315 docs/dev/ARCHITECTURE.md
PR 20518 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 20519 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 20635 docs/dev/debt/shader.md
PR 20686 docs/dev/debt/shader.md
PR 20792 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 20891 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 20909 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 20944 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 21180 core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
PR 21199 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 21240 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 21336 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 21745 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 21749 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 21763 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 21776 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 21961 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 21970 core/shader/recompiler/ShaderDiskCache.hpp
PR 21971 core/shader/recompiler/ShaderDiskCache.hpp
PR 22071 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 22075 docs/dev/ARCHITECTURE.md
PR 22251 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 22328 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 22424 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ControlFlowInfo.hpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/ARCHITECTURE.md
PR 22434 docs/dev/ARCHITECTURE.md
PR 22439 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 22493 core/shader/recompiler/ShaderDiskCache.cpp
PR 22546 docs/dev/ARCHITECTURE.md
PR 22583 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 22602 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 22628 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 22647 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
docs/dev/ARCHITECTURE.md
PR 22665 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 22675 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 22690 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 22692 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 22697 docs/dev/ARCHITECTURE.md
PR 22703 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 22724 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 22767 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 22944 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
PR 23096 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 23103 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 23111 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 23157 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 23242 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 23243 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 23244 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 23343 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 23344 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 23409 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
docs/dev/debt/shader.md
PR 23490 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 23519 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 23545 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 23553 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 23644 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 23701 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 23778 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 23811 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 23818 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 24025 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 24294 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 24523 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/libs/prx/libSceAgcDriver/tests/execution/ImageTable.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 24714 docs/dev/ARCHITECTURE.md
PR 24721 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 24781 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 24906 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 25010 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 25137 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 25374 docs/dev/ARCHITECTURE.md
PR 25422 docs/dev/ARCHITECTURE.md
PR 25489 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 25576 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 25609 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 25660 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 25723 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 25767 docs/dev/ARCHITECTURE.md
PR 25837 docs/dev/ARCHITECTURE.md
PR 25842 core/shader/recompiler/ShaderDiskCache.cpp
PR 25852 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 25967 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 26012 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 26077 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
PR 26100 docs/dev/debt/shader.md
PR 26365 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 26593 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
PR 26601 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 26612 core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp
core/shader/recompiler/ShaderDiskCache.cpp
PR 26630 core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 26645 core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 26691 core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 26716 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
PR 26766 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 26797 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/Optimization/src/ResourceTracker.cpp
PR 26800 core/libs/prx/libSceAgcDriver/tests/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.cpp
core/shader/recompiler/ShaderDiskCache.hpp
PR 26808 core/shader/recompiler/Optimization/src/ResourceTracker.cpp

@github-actions github-actions Bot added shader core/shader docs agc libSceAgc* labels Oct 18, 2026
@klosixgaming-arch

Copy link
Copy Markdown
Contributor

Tested on Windows 11, MinGW-w64 GCC 15.2.0, NVIDIA GeForce RTX 5090 (driver 617.42), Ryzen 9 9950X3D. Head df6aa653d merged onto current main (a373e85); the merge is clean.

  • agc_shader_memory, agc_shader_bindless and agc_driver_image_table pass with the change (17 tests of the agc_shader_* group that I built all pass; the ones that were not built here were not run).
  • On main with only this PR's three test files, agc_driver_image_table and agc_shader_memory fail with GetImageResource dword 0 is not a valid runtime value; chain: Phi(ReadConstBuffer@pc=0x00000028(..., so the new cases do depend on the change.

Not tested: Demon's Souls (PPSA01342), so the claim that the table shape is fixed for the title is unchecked. The range analysis in ResourceTracker.cpp (about 190 lines) I did not review closely, and it decides which table records are captured; I would want a second reviewer on the range arithmetic through bit scans and masked offsets. The description's note on the agreed merge order with #7395 is useful. I am not approving; this is a test report only.

AI-assisted: yes. Written with AI assistance and reviewed by me.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@Tamalero

Copy link
Copy Markdown
Contributor

Tested on Marvel's Guardians of the Galaxy (PPSA01748) for #7362: main 659230f + the fix commit of #6606 + this PR (92e37f735). It still stops at the same place, about 4.5 minutes in after the opening menus (language, brightness, adjustments → Start Game):

compute shader 0x3b91c3e00: ... GetImageResource dword 0 is not a valid runtime value; chain: LoadAddressU32@pc=0x00004380(GetAddressResource(ReadConst(GetSrtResource, Immediate), ReadConst(GetSrtResource, Immediate)), ShiftLeftLogical32(ReadFirstLane(SelectU32(Phi(...), FindILsb32(Phi(...)), Phi(SelectU32(..., BitCastU32F32(FPMax32(...)), ...), SelectU32(..., FindILsb32(...), ...)))), Immediate), ...)

From reading KeyRange::Compute, I think two things keep this key unbounded, so it never gets the 0–31 / −1 bound:

  • The key is wrapped in ReadFirstLane, and ReadFirstLane falls through to default (unbounded).
  • One Phi arm of the SelectU32 carries BitCastU32F32(FPMax32(...)), a float's bit pattern, not a bit-scan result.

The T# address here is also loaded through a pointer (LoadAddressU32 of a GetAddressResource) rather than read directly from the image table, so this might be outside the PR's scope anyway. No regression seen up to the stop (one run).

Tested and written by Claude (AI assistant) on a contributor's machine.

… reach

An image table key with no key domain kept every record of the snapshot
domain: 65,536 records for a T# column read by s_load through a 64-bit
pointer, whether or not a lane could select them. Demon's Souls
(PPSA01342) pixel shader 0x248a7e700 walks a 32-bit set of lanes with
s_ff1_i32_b32 and loads the T# at key * 32 from its table, so the
hardware reads records 0-31 at most. Every capture still read 2 MiB of
records and resolved each distinct decodable record as a table element;
in run ds-tsharp-c01 the suspect-record report log, which stops at 1,000
reports per kind (both kinds reached it), held 1,978 distinct records of
the three shaders with this loop (0x248a7e700, 0x248a8fa00, 0x248a8bc00),
4 of them below 32.

The tracker now also bounds a key by its value range (KeyRange): s_ff1
is 0-31 or -1 (0-63 or -1 for a 64-bit source), s_flbit is 32 or -1
(the hardware returns 0-31 or -1; the bound takes 31 - msb before the
select against -1) and 64 or -1 for a 64-bit source (63 - msb), a bit
count 0-32 or 0-64, and the bound follows masks, minimums, shifts by
constants, adds, multiplies by and subtractions from constants, selects
and phis. Each rule holds for every u32 value. Cross-lane reads are not
followed, since the lane they read may be inactive, and a value that
depends on itself through a loop stays unbounded. The column keeps the
smaller of this bound and the known-bits bound.

A key that can be -1 (TableColumn::allOnesKey) selects a record past the
snapshot. It keeps the fault check only where that record can fault: for
an address column, and for a V# heap column when the offset of key -1
(addend - stride, modulo 2^32, plus the instruction's immediate offset)
lies inside the V#. Past the V# the lane reads the column's outside
record and raises no fault, so a heap keyed by s_ff1 does not turn on
fault checks, completion callbacks or recipe exclusion that main does
not have. The guarantee covers a column whose every access carries the
bound: mergeTableKey drops allOnesKey when another access to the same
column has no bound, and that column then raises no fault check for key
-1, as on main (documented in docs/dev/debt/shader.md).

A table read at (key << n) & mask selects the record key & (mask >> n),
which is at most mask >> n for every key, including -1. Such a column is
bounded by that record instead of the unmasked key: mask >> n when the
key can be -1, the smaller of that and the key's bound otherwise, and it
carries no allOnesKey. Bounding the unmasked key refused a record the
hardware reads, for example (s_ff1 << 5) & 0x1fe0 of an empty set, which
loads entry 255. The flag is part of the plan's disk-cache encoding, and
APS5_TRACE_IMAGE_TABLE prints each column's key bound.

Records inside the bound are still snapshotted whether or not a lane
selects them. The four suspect records below 32 in that run (11, 13
and 15 of 0x248a7e700, 11 of 0x248a8fa00) have invalid format fields,
so they are poisoned and never become textures. Keys made uniform by
v_readfirstlane, the more common shape in the same title's cache, stay
unbounded.

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

Co-Authored-By: Codex <noreply@openai.com>
@fdfawef324

Copy link
Copy Markdown
Contributor Author

@klosixgaming-arch thank you for the RTX 5090 test report and the removal controls. I am keeping those results attributed to your df6aa653d composition. An independent review of the bit-scan, mask and wrapping-arithmetic bounds is in progress alongside the rebase onto 676d42396; the update also preserves main's shared column snapshots and resolution reuse. I will include the exact updated-head checks with that update.

@Tamalero the remaining stop is consistent with this PR's conservative boundary. A ReadFirstLane wrapper or a value arm with an unbounded float bit pattern does not establish the bounded integer key this analysis needs. Pointer-based descriptor addressing also needs its own supported plan. I am retaining those refusals during the rebase; your run does not establish a Guardians milestone or a regression from this change. Thank you for recording that limit.

AI-assisted: yes (Codex)

Co-Authored-By: Codex noreply@openai.com

Adapt the range regressions to per-column descriptor storage and advance the plan codec format for allOnesKey.

Co-Authored-By: Codex <noreply@openai.com>
@fdfawef324
fdfawef324 force-pushed the codex/table-key-ranges-1018 branch from df6aa65 to cbc4606 Compare October 19, 2026 05:16
@fdfawef324

Copy link
Copy Markdown
Contributor Author

Rebased to cbc4606a7906e51c379f8d9552449584398e9e31 on main 676d423968a1, preserving the newer per-column SharedValues/Seal implementation and refreshing the three affected snapshot-word test accesses. The serialized sentinel field now uses format 41 after main 40; source/cache and clean revision identities were regenerated normally.

The requested second source review found no defect in the conservative unsigned transfer rules, sentinel handling, overflow/shift bounds, select/Phi cycle handling or current memo reuse. Current CPU suites pass 3/3; the sequential regression batch passes 7/7 in 16.04 seconds (five actual Vulkan cases and two CPU/mock cases) on the RTX 3060. The earlier exact removal controls are retained and qualified by their earlier head. A clean merge into 72a3d9f2a49d is checked separately from this runtime result.

The external RTX 5090 report remains attributed to the earlier df6aa653d1d7 plus its stated main. The Guardians report does not establish a regression or a new boot here: cross-lane values, mixed float/Phi cases and pointer chains without a proof remain unbounded. #7395's agreed landing order and the fields/guards to preserve during its follow-up rebase remain in the description.

AI-assisted: yes

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@savvaniss

Copy link
Copy Markdown
Contributor

Intel and AMD Windows data: with this PR, the 18 tests built from its test files pass on an AMD RX 9070 XT. On an Intel UHD 770, all pass except agc_driver_image_table, which fails there on main too.

Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built, ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, with VkCache emptied first. This head cbc4606a7 merged into main 6b8228b2b.

Tests, ×3 UHD 770 RX 9070 XT
This head: 18 tests from tests/ShaderDiskCache.cpp, tests/ShaderMemory.cpp and tests/execution/ImageTable.cpp 17 pass; agc_driver_image_table fails: sampler tables need runtimeDescriptorArray and descriptorBindingPartiallyBound, which the device lacks 18 of 18 pass

The UHD 770 failure is the descriptor-limit refusal that #6647 addresses, and main alone fails the same way. tests/ShaderMemory.cpp has changed on main since this branch's base, so I have no clean before-run.

AI-assisted: yes (Claude Code)

@DavidAmsellem

Copy link
Copy Markdown
Contributor

First AMD-on-Linux (RADV) run of this PR. Merged onto main 43a2abaf7 (clean merge), built in full and compared with the same main, on the same machine.

AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, GCC 13.3, Release.

Full suite (ANYPS5_REQUIRE_VULKAN=1 ctest -j8): 1636/1638 with this PR, against 1636/1638 on main. The failures are the same two on both, so this PR adds none: agc_driver_image_table_vouched_lookups (#7766, fixed by #7916) and agc_driver_guest_memory_lifetime (#7784). The PR adds no new ctest entry; every existing test it touches passed.

GPUs tested: AMD Radeon RX 7900 XT (RADV NAVI31, gfx1100), Mesa 25.2.8, Linux Mint 22.3 / kernel 7.0.0-38

AI-assisted: yes

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

At its own base the range analysis looks sound and its tests depend on it, but the branch no longer merges into current main: it conflicts in four files, and one of the conflicts would silently break main's first-lane table path if it is resolved naively.

What I ran

  • PR head: cbc4606a7906e51c379f8d9552449584398e9e31
  • main: b433c40f2f46aa2e59e19806010a839ac8572d64
  • PR base (merge-base): 676d423968a1a8fcc79c6247020ce22090a8e0d4

The merge into main conflicted, so I built and tested the PR head itself, compared it with its base for validation output, and ran a negative control on the head.

git fetch -q origin main pull/7684/head:refs/review/7684
git checkout -q --detach origin/main
git merge -q --no-ff --no-edit refs/review/7684     # conflicts, aborted
git checkout -q --detach refs/review/7684
git diff --check origin/main...refs/review/7684
python3 tools/check_conventions.py --base origin/main
cmake --build build -j10 --target agc_shader_memory_tests agc_shader_disk_cache_tests agc_driver_image_table_tests
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 VK_LOADER_DEBUG=error,warn,layer \
  ctest --test-dir build -j4 -V --output-on-failure \
  -R '^(agc_shader_memory|agc_shader_bindless|agc_shader_disk_cache|agc_driver_image_table)$'
# negative control: head + ResourceTracker.cpp and ResourceMaterializer.cpp from 676d423968a1, rebuild, same ctest
# comparison: 676d423968a1 checked out, rebuild, same ctest

Machine: Arch Linux 7.2.11-zen, GCC 16.2.1 Release, Intel Core i9-14900KF, NVIDIA GeForce RTX 4070 Ti SUPER (driver 615.78.08).

Results

Check Result
Merge into main b433c40f2f Conflicts in core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp, core/shader/recompiler/Optimization/src/ResourceTracker.cpp, core/shader/recompiler/ShaderDiskCache.hpp, docs/dev/debt/shader.md (GitHub also reports CONFLICTING)
git diff --check clean
check_conventions.py --base origin/main All conventions checks passed.
Build of the three test targets at the head OK
agc_shader_bindless, agc_shader_memory, agc_shader_disk_cache, agc_driver_image_table at the head 4/4 passed, longest 1.70 s
Validation layer loaded yes, on both the head and the base (Inserted device layer "VK_LAYER_KHRONOS_validation"); no was not found but was requested by env var VK_INSTANCE_LAYERS
VUID- lines, head vs base 676d423968a1 both runs: 2 × VUID-vkCmdDispatch-magFilter-04553 in agc_driver_image_table, so the error already exists at the base and the PR adds none
Conflict hunks (excerpt)
ShaderDiskCache.hpp
<<<<<<< HEAD
inline constexpr std::uint32_t FormatVersion = 49;
=======
inline constexpr std::uint32_t FormatVersion = 41;
>>>>>>> refs/review/7684

ResourceTracker.cpp
<<<<<<< HEAD
            if (!MatchMaskedOffset(offset, key, stride) && (address || !MatchFirstLaneOffset(offset, key, stride))) {
=======
            if (!MatchMaskedOffset(offset, key, stride, recordMask)) {
>>>>>>> refs/review/7684

docs/dev/debt/shader.md: main's "Image table pointer indexing ... propagates 32-bit value bounds
through ReadFirstLane and SelectU32" paragraph against the PR's rewritten key-bound paragraphs.
ctest at the head
1/4 Test #336: agc_shader_bindless ..............   Passed    0.06 sec
2/4 Test #355: agc_shader_memory ................   Passed    0.19 sec
3/4 Test #368: agc_shader_disk_cache ............   Passed    1.12 sec
4/4 Test #580: agc_driver_image_table ...........   Passed    1.70 sec
100% tests passed out of 4

Negative control

The new tests use the new TableColumn::allOnesKey field, so restoring every production file from the base does not compile (TableColumn has no member allOnesKey). I kept the PR's ControlFlowInfo.hpp and ShaderDiskCache.* and reverted only ResourceTracker.cpp and ResourceMaterializer.cpp to 676d423968a1. Three of the four tests then fail:

Failures with the range analysis reverted
336: image table masked offset: the record mask did not bound the loaded key
355: image table bit-scan heap: the column lost its bit-scan bound or affine offset
580: AGC graphics: pointer image table set-bit key: the snapshot read entries an s_ff1 key cannot select
25% tests passed, 3 tests failed out of 4

agc_shader_disk_cache still passes in this control, as expected: the encoder lines it round-trips were kept. After the control I restored the PR's files.

This agrees with the removal results that klosixgaming-arch reported on the earlier df6aa653d head, now checked on cbc4606a79 on Linux.

Findings

Blocking

  1. The branch conflicts with main. main has moved on in the same code since 676d423968a1:
    • ShaderDiskCache.hpp:16 is at format 49. Encoding allOnesKey needs a fresh bump on top of that (50 or later), not 41.
    • #10228 added a first-lane offset path to the same branch in MakeTableColumn (ResourceTracker.cpp:812-815 on main). That path also sets masked = true, but MatchFirstLaneOffset never writes a record mask. The obvious resolution is if (!MatchMaskedOffset(offset, key, stride, recordMask) && (address || !MatchFirstLaneOffset(offset, key, stride))). Combined with if (masked) boundMaskedTableKey(column, key, recordMask), that resolution would send first-lane columns into boundMaskedTableKey with recordMask == 0. Their maxKey would become 0, so the snapshot would keep only record 0, and every other key would read the outside record. It still compiles, and nothing in the current test set obviously guards against it. Please keep the first-lane path on its own bound, either boundTableKey or main's possibleU32Bits, rather than the masked one, and add a case for a first-lane column to the PR's tests.
    • docs/dev/debt/shader.md on main now has the ReadFirstLane/SelectU32 bound paragraph from #7388. Two lines of the PR still say a key with no bound includes "a lane value made uniform by v_readfirstlane": its debt paragraph, and its ARCHITECTURE.md line (ARCHITECTURE.md:159, which auto-merges). Both need to match main's behaviour after the rebase.
    • The ShaderMemory.cpp test conflict is in the same table-test area, so the new cases need re-running on the rebased tree.

Non-blocking

  1. The checklist's Unblocks: PPSA01342 #1283 points at discussion #1283, whose title is "Demon's Souls (PPSA01341)". Please use the title ID of the build you tested and its discussion, or say why the two IDs refer to the same title.
  2. docs/dev/debt/shader.md:37 ends a sentence with "Main behaves the same way." Once merged, this paragraph is main, so the sentence only makes sense as part of a PR description. I suggest dropping it, or saying the gap predates the key-range bound.

On the code itself, I checked the KeyRange transfer rules at the head and found no defect:

  • AND/UMin take the minimum of the tops, and OR smears.
  • Constant shifts, adds and multiplies go to unbounded on 64-bit overflow, and a left shift or multiply of a -1-capable key is unbounded.
  • c - x requires x.max <= c and gives c + 1 for the sentinel.
  • Phi/Select join, and a cycle reads the unbounded placeholder.
  • FindUMsb64 gives {63, -1}, which matches EmitFindUMsb64, and s_ff1_i32_b64's highLsb + 32 gives 63.
  • boundTableKey drops the sentinel when known bits exclude 0xffffffff.
  • boundMaskedTableKey bounds by recordMask when the key can be -1.

Not verified

  • The rebased tree: the merge conflicts, so nothing here was built or run on top of b433c40f2f.
  • The other regression suites in the description (agc_driver_image_table_cache*, agc_driver_image_table_reuse, agc_driver_bindless_images, agc_driver_graphics, agc_driver_compute_table_calls); I did not build them.
  • Demon's Souls itself; I did not run the title.
  • VUID- comparison against current main (only against the PR's base, 676d423968a1).

To get this to a good state

  1. Rebase onto current main, and bump FormatVersion above 49.
  2. Resolve the MakeTableColumn branch so that MatchFirstLaneOffset columns do not go through boundMaskedTableKey with an unset recordMask, and add a test for that case.
  3. Reconcile the debt and architecture text with main's ReadFirstLane/SelectU32 bounds (#7388).
  4. Re-run the focused tests on the rebased head, and post the head and main SHAs.
  5. Fix the title ID / discussion on the Unblocks line.

@Sam-mon7

Sam-mon7 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Data point for this PR from Demon's Souls (PPSA01341), measured on a fork, not on main.

The tutorial "zoo" scene has a CPU-path indirect draw whose pixel shader picks a T# with FindILsb32 over a wave mask and loads it from ptr + key * 32. The tracker left that column unkeyed, so every frame's snapshot read all 65,536 records (513 page queries) on queue 0. That is the shape this PR bounds.

We tried a narrower local change, bounding columns whose every key site is FindILsb32 to 32 keys (the all-ones result still lands outside). On a frame replay of the scene: snapshot time 6.71 -> 0.57 ms per frame, records 65,536 -> 32, exported frames byte-identical, and a verify mode that rebuilt the full snapshot found 0 mismatches. In game, an alternating A/B run in one boot (switch flipped at presents, 12 pairs, other local fixes on in both legs) gave 1.160x frame time (90% interval 1.118-1.203).

Those numbers come from our fork (main 4971b380b3 plus local Demon's Souls changes), RTX 4070, driver 610.88, Windows 11. They are not summary lines of this PR against main. We won't open a duplicate; this PR's range analysis covers the same case more generally. If a rebase would help, I'm happy to help with it.

AI-assisted: yes (Claude Code)

@sherySJ

sherySJ commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

@fdfawef324 thanks for #7684. XairRrR reproduced it on Linux with the validation layer (4/4 tests pass, no new VUID-, and reverting ResourceTracker.cpp and ResourceMaterializer.cpp fails 3 of the 4) and found one blocker: the branch conflicts with main in ShaderDiskCache.hpp (format 49 and rising), ResourceTracker.cpp (the first-lane offset path from #10228 sets masked without writing a record mask), ShaderMemory.cpp and docs/dev/debt/shader.md. I have an Intel HD Graphics 520 (Mesa ANV, no mesh shaders) and llvmpipe with the Khronos validation layer loaded, so I can run agc_shader_bindless, agc_shader_memory, agc_shader_disk_cache and the agc_driver_image_table* suite on main and on the merged head and post both logs. If you are rebasing this, say so and I will only test your push. If I hear nothing in 48 hours I will merge current main into your head without rewriting history, keep your commits and authorship (plus a Co-authored-by trailer on mine), take the cache FormatVersion from live main plus one, resolve the first-lane case the way XairRrR described and add a test that fails if the record mask is zero, and push it for review. #7395 was agreed to land after this one, so I will keep both metadata fields intact for it.

@sherySJ

sherySJ commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

@fdfawef324 an update on the carry I offered here: I did not push a merge of main into your branch after the 48 hours, and I want to explain why. Since then edubox opened #17863, which bounds the same FindILsb32/FindUMsb32 key shape in ResourceTracker.cpp, and it is under review and merges cleanly into main. On an Intel HD 520 with the Khronos validation layer, your set-bit pointer table test from this PR passes with #17863's change alone and fails on main at the 65536-record read range, so the key bound itself is covered there. Landing both would put two range analyses on column.maxKey, so I am not carrying this as is; what #17863 does not cover is the all-ones sentinel flag (heap-table fault readback and the cache field) and XairRrR's masked-offset record mask, whose first-lane case from #10228 still needs the zero-mask test he described. If you want to rebase onto #17863 and keep only that remainder, reusing possibleU32UpperBound, say so and I will run the CPU suites and the agc_driver_image_table* suite with the validation layer on both sides and post the logs. Thank you to XairRrR for the review that mapped the first-lane and format-version traps, and to edubox for the work on #17863.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

@fdfawef324, this no longer merges with main: it conflicts in ShaderDiskCache.cpp and .hpp, ResourceTracker.cpp, ResourceMaterializer.cpp, the two test files and docs/dev/debt/shader.md. The disk cache format number and the table tracking in ResourceTracker.cpp both moved, so this needs a rebase by hand rather than a mechanical merge. Could you rebase onto current main, take the next disk cache format number, and rerun the image table tests on the new head? I will review the source once it merges cleanly.

@Serph91P

Copy link
Copy Markdown
Contributor

Overlap coordination for #21586: I have a minimal TryMakeTableColumn fix that peels an outer constant addend before the masked-offset fallback, with synthetic pointer-image and buffer-sampler table coverage. On pinned main e4caa07, the new regression fails with a missing-table/runtime-value error; the narrow correction passes the seven focused tests.

Your PR adds recordMask to MatchMaskedOffset at the same call site. The changes address different behavior: the combined call would be MatchMaskedOffset(SplitImmediateAddend(offset, addend), key, stride, recordMask), retaining your mask-bound handling rather than discarding it. #9457 also changes the surrounding fallback block. I am not proposing a parallel implementation of the key-range analysis.

For landing order, I can keep the addend correction as a narrow follow-up and adapt it if this PR lands first. Alternatively, would you prefer to incorporate it and the synthetic coverage here? This is coordination before publication, not a merge request or a verified-gameplay claim; raw title data stays private.

@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 inspected changes support the stated bounded image-table snapshot behavior; no concrete blocking defect was found in the source read.

What I ran

Reviewed head cbc4606a7906e51c379f8d9552449584398e9e31. No commands or tests were run. Read the prepared description, commits, manifest, diff, and targeted source ranges through repo_read.py.

Results

Check Result Note
Source review passed Core range and snapshot logic inspected
Tests not run Runs described in the PR body were not independently run
Full-file review not run Manifest and bundle reads were partial

Findings

Blocking

None in the inspected code.

Non-blocking

None.

Not verified

The manifest was read only through its first 200 lines of 524, and the diff only through line 599 of 690; therefore the complete changed-file list, remaining diff, and whether every changed file was reviewed are not verified. review/files.json was unavailable through the reader. No repository tests, build, merge preview, Linux run, or hardware behavior were independently verified.

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 needs rebase Conflicts with main, rebase needed shader core/shader unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.