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

Open
fdfawef324 wants to merge 2 commits from upstream-pr/7684 into main
fdfawef324 commented 2026-10-18 22:51:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-18T22:51:10Z.


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 #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 [email protected]

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4913521671 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7684). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-18T22:51:10Z. --- ### 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](https://github.com/boykopovar/AnyPS5/pull/7395#issuecomment-6256187092) 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 <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> 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 <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: PPSA01342 #1283, table-domain capture stop only - [x] 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 - [x] AI-assisted: yes Co-Authored-By: Codex <[email protected]>
klosixgaming-arch commented 2026-10-19 00:52:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-19T00:52:17Z.


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 (a373e85e5); 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6257336580 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7684#issuecomment-6257336580). Originally posted by [klosixgaming-arch](https://github.com/klosixgaming-arch) on 2026-10-19T00:52:17Z. --- 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` (a373e85e5); 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.
Tamalero commented 2026-10-19 04:18:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-19T04:18:30Z.


Tested on Marvel's Guardians of the Galaxy (PPSA01748) for #7362: main 659230f7b + 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6259548861 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7684#issuecomment-6259548861). Originally posted by [Tamalero](https://github.com/Tamalero) on 2026-10-19T04:18:30Z. --- Tested on Marvel's Guardians of the Galaxy (PPSA01748) for #7362: main 659230f7b + 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.*
fdfawef324 commented 2026-10-19 04:48:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-19T04:48:37Z.


@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 [email protected]

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6259897095 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7684#issuecomment-6259897095). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-19T04:48:37Z. --- @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 <[email protected]>
fdfawef324 commented 2026-10-19 05:17:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-19T05:17:00Z.


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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6260228567 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7684#issuecomment-6260228567). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-19T05:17:00Z. --- 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
savvaniss commented 2026-10-19 07:45:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-19T07:45:58Z.


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)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6262292510 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7684#issuecomment-6262292510). Originally posted by [savvaniss](https://github.com/savvaniss) on 2026-10-19T07:45:58Z. --- 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 commented 2026-10-19 15:44:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-19T15:44:29Z.


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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6271205299 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7684#issuecomment-6271205299). Originally posted by [DavidAmsellem](https://github.com/DavidAmsellem) on 2026-10-19T15:44:29Z. --- 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 commented 2026-10-29 04:34:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T04:34:43Z.

Review: CHANGES_REQUESTED


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.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5692898715 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7684#pullrequestreview-5692898715). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-10-29T04:34:43Z. **Review:** CHANGES_REQUESTED --- # 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. ```sh 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 | <details><summary>Conflict hunks (excerpt)</summary> ``` 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. ``` </details> <details><summary>ctest at the head</summary> ``` 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 ``` </details> ## 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: <details><summary>Failures with the range analysis reverted</summary> ``` 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 ``` </details> `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`](https://github.com/boykopovar/AnyPS5/blob/b433c40f2f46aa2e59e19806010a839ac8572d64/core/shader/recompiler/ShaderDiskCache.hpp#L16-L16) 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`](https://github.com/boykopovar/AnyPS5/blob/b433c40f2f46aa2e59e19806010a839ac8572d64/core/shader/recompiler/Optimization/src/ResourceTracker.cpp#L812-L815)). That path also sets `masked = true`, but [`MatchFirstLaneOffset`](https://github.com/boykopovar/AnyPS5/blob/b433c40f2f46aa2e59e19806010a839ac8572d64/core/shader/recompiler/Optimization/src/ResourceTracker.cpp#L613-L626) 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)`](https://github.com/boykopovar/AnyPS5/blob/cbc4606a7906e51c379f8d9552449584398e9e31/core/shader/recompiler/Optimization/src/ResourceTracker.cpp#L830-L834), that resolution would send first-lane columns into [`boundMaskedTableKey`](https://github.com/boykopovar/AnyPS5/blob/cbc4606a7906e51c379f8d9552449584398e9e31/core/shader/recompiler/Optimization/src/ResourceTracker.cpp#L244-L250) 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](https://github.com/boykopovar/AnyPS5/blob/b433c40f2f46aa2e59e19806010a839ac8572d64/docs/dev/debt/shader.md#L55-L55) 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`](https://github.com/boykopovar/AnyPS5/blob/cbc4606a7906e51c379f8d9552449584398e9e31/docs/dev/ARCHITECTURE.md#L159-L159), 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`](https://github.com/boykopovar/AnyPS5/blob/cbc4606a7906e51c379f8d9552449584398e9e31/docs/dev/debt/shader.md#L37-L37) 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.
MarcZX10 commented 2026-11-23 02:36:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T02:36:54Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6015962336 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7684#pullrequestreview-6015962336). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-23T02:36:54Z. **Review:** COMMENTED --- # 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 pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/7684:upstream-pr/7684'
git switch 'upstream-pr/7684'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/7684'
git switch 'upstream-pr/7684'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/7684'
git switch 'upstream-pr/7684'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/7684'
git switch 'main'
git merge --squash 'upstream-pr/7684'
git switch 'main'
git merge --ff-only 'upstream-pr/7684'
git switch 'main'
git merge 'upstream-pr/7684'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!7684
No description provided.