fix(shader): reuse completed pixel lane proofs #6645

Merged
DangerChamp merged 1 commit from upstream-pr/6645 into main 2026-10-22 20:34:51 +00:00
DangerChamp commented 2026-10-16 01:10:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DangerChamp on 2026-10-16T01:10:16Z.


What

Fixes #6582 by memoizing completed entry-lane proofs by value and proof type, while avoiding cached results that depend on active Phi cycles.

Adds regression coverage for saved EXEC-mask loops and helper-lane safety on wave64 shaders running on 32-lane host subgroups.

Tested

Windows host with MinGW Release build:

  • agc_shader_memory passed
  • git diff --check passed
  • GPUs tested: not run

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
  • No notes, investigation .md files or images added
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: not run
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4881956695 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6645). Originally posted by [DangerChamp](https://github.com/DangerChamp) on 2026-10-16T01:10:16Z. --- ### What Fixes #6582 by memoizing completed entry-lane proofs by value and proof type, while avoiding cached results that depend on active Phi cycles. Adds regression coverage for saved EXEC-mask loops and helper-lane safety on wave64 shaders running on 32-lane host subgroups. ### Tested Windows host with MinGW Release build: - `agc_shader_memory` passed - `git diff --check` passed - GPUs tested: not run ### Checklist - [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 - [x] Unimplemented paths throw - [x] No notes, investigation `.md` files or images added - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: not run - [x] AI-assisted: yes
cookie42073-cmd commented 2026-10-16 04:45:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by cookie42073-cmd on 2026-10-16T04:45:32Z.


Hey @DangerChamp, I've been testing this same proof-cache path. EntryLaneWalk at e6f33ead matches the earlier published candidate apart from prove → Prove, including the 512-step budget and cycle guard.

There's a new reporter comparison worth linking here: the exact earlier candidate passes the NHL26 capture and added synthetic CPU controls, but the retained PRAGMATA request still exhausts its budget at 512. I haven't built your whole branch, so this isn't a run of #6645, but I don't think Fixes #6582 is demonstrated by the current evidence. Could we keep that claim pending a successful replay of that request?

The next comparison I'm requesting on #6582 is the same cached proof at 2,048 steps, with the cycle-safety checks unchanged. Can we coordinate this PR's ordering with @MarcZX100's #6180 before any further code submission? I'll keep our follow-up work coordinated here rather than open another matching PR.

AI-assisted investigation and write-up, independently reviewed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6208281071 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6645#issuecomment-6208281071). Originally posted by [cookie42073-cmd](https://github.com/cookie42073-cmd) on 2026-10-16T04:45:32Z. --- Hey @DangerChamp, I've been testing this same proof-cache path. `EntryLaneWalk` at `e6f33ead` matches the [earlier published candidate](https://github.com/boykopovar/AnyPS5/pull/5189#issuecomment-6160879528) apart from `prove` → `Prove`, including the 512-step budget and cycle guard. There's a new [reporter comparison](https://github.com/boykopovar/AnyPS5/issues/6582#issuecomment-6207242266) worth linking here: the exact earlier candidate passes the NHL26 capture and added synthetic CPU controls, but the retained PRAGMATA request still exhausts its budget at 512. I haven't built your whole branch, so this isn't a run of #6645, but I don't think `Fixes #6582` is demonstrated by the current evidence. Could we keep that claim pending a successful replay of that request? The next comparison I'm requesting on #6582 is the same cached proof at 2,048 steps, with the cycle-safety checks unchanged. Can we coordinate this PR's ordering with @MarcZX100's #6180 before any further code submission? I'll keep our follow-up work coordinated here rather than open another matching PR. AI-assisted investigation and write-up, independently reviewed.
blawesom commented 2026-10-17 11:26:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-17T11:26:22Z.


Rebase handoff — rebased onto current main cleanly (authorship unchanged).

Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON, AMD RX 9070 XT / RADV):

  • builds; tools/check_conventions.py --base origin/main passes
  • full suite: 1338/1339 — the only failure is the known main regression (agc_driver_tessellation segfault, #4727), not this PR

To pick it up:

git fetch https://github.com/blawesom/AnyPS5 rebase/6645
git checkout <your branch>
git merge --ff-only FETCH_HEAD

Head is 13cde0efd.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6233333642 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6645#issuecomment-6233333642). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-17T11:26:22Z. --- **Rebase handoff** — rebased onto current `main` cleanly (authorship unchanged). Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`, AMD RX 9070 XT / RADV): - builds; `tools/check_conventions.py --base origin/main` passes - **full suite: 1338/1339** — the only failure is the known `main` regression (`agc_driver_tessellation` segfault, #4727), not this PR **To pick it up:** ``` git fetch https://github.com/blawesom/AnyPS5 rebase/6645 git checkout <your branch> git merge --ff-only FETCH_HEAD ``` Head is `13cde0efd`.
MarcZX10 commented 2026-10-17 13:14:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T13:14:46Z.


Coordination update from #6582: on refreshed main ca82d7d with the existing 2,048-step budget and SPIRV-Tools enabled, the retained PRAGMATA request fails on unmodified main with the lane-63 refusal, then passes with overlordxrz-source’s b76d8d31 EntryLaneWalk helper (534,483 optimized SPIR-V words; validation passes before and after optimization). Both public CPU controls pass on that comparison. This is stronger evidence for that captured failure than the older same-base 512-step comparison, but the live title still did not reach a confirmed menu/scene and hit host memory pressure. Since #6645 is already open for the same cache topic, I’m not opening a parallel PR. Could you and @overlordxrz-source coordinate whether to replace this implementation with the verified helper or rework #6645 against the refreshed capture?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6234313549 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6645#issuecomment-6234313549). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-17T13:14:46Z. --- Coordination update from #6582: on refreshed main `ca82d7d` with the existing 2,048-step budget and SPIRV-Tools enabled, the retained PRAGMATA request fails on unmodified main with the lane-63 refusal, then passes with overlordxrz-source’s `b76d8d31` EntryLaneWalk helper (534,483 optimized SPIR-V words; validation passes before and after optimization). Both public CPU controls pass on that comparison. This is stronger evidence for that captured failure than the older same-base 512-step comparison, but the live title still did not reach a confirmed menu/scene and hit host memory pressure. Since #6645 is already open for the same cache topic, I’m not opening a parallel PR. Could you and @overlordxrz-source coordinate whether to replace this implementation with the verified helper or rework #6645 against the refreshed capture?
Ondra97 commented 2026-10-19 02:41:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-19T02:41:21Z.


I tested the current #6645 implementation against the retained #6582 shader request. After rebasing its original commit onto main 40393b0 and keeping #6180's 2,048-step budget, the request still failed with the lane-63 refusal (exit 1). An eight-round saved-EXEC CPU regression also failed; the PR's existing three-round test passed.

I prepared a branch for this PR at 99ed46c854a38e27f8c96abe6d83caa1fc30722c, based on main ccbd40240f. It preserves DangerChamp's original commit and tests, replaces the provisional cycle cache with overlordxrz-source's settled per-(value, proof) algorithm from b76d8d31, retains the 2,048-step budget, and extends the saved-EXEC test to eight rounds. The second commit credits the helper's source.

On Windows 11 Pro (Ryzen 9 7900X, RTX 4070 Ti SUPER, NVIDIA driver 32.0.16.1742), Release relinker, libs, and the affected test executables built. Four CPU CTests and the native agc_driver_pixel_wave_reduction test passed with no skips; that test selected the RTX GPU with subgroup size 32. The unchanged private request (SHA-256 a9f1f0318f46c97929ccebfffcfd8d9bebc8cbcfab132cabd4369bcc52f4a82e) replayed successfully, producing 491,708 SPIR-V words with SPIRV-Tools validation enabled. Conventions, whitespace, and main-sync checks passed. I did not run the title from this branch.

The hosted PR still points to e6f33ead and conflicts with main. This is a handoff for the existing PR, not a separate PR. Please review and coordinate whether to integrate the branch into #6645. AI-assisted integration and testing: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6258501519 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6645#issuecomment-6258501519). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-19T02:41:21Z. --- I tested the current #6645 implementation against the retained #6582 shader request. After rebasing its original commit onto main `40393b0` and keeping #6180's 2,048-step budget, the request still failed with the lane-63 refusal (exit 1). An eight-round saved-EXEC CPU regression also failed; the PR's existing three-round test passed. I prepared [a branch for this PR](https://github.com/Ondra97/AnyPS5/tree/codex/pr6645-repair-20261019) at `99ed46c854a38e27f8c96abe6d83caa1fc30722c`, based on main `ccbd40240f`. It preserves DangerChamp's original commit and tests, replaces the provisional cycle cache with overlordxrz-source's settled per-(value, proof) algorithm from `b76d8d31`, retains the 2,048-step budget, and extends the saved-EXEC test to eight rounds. The second commit credits the helper's source. On Windows 11 Pro (Ryzen 9 7900X, RTX 4070 Ti SUPER, NVIDIA driver 32.0.16.1742), Release `relinker`, `libs`, and the affected test executables built. Four CPU CTests and the native `agc_driver_pixel_wave_reduction` test passed with no skips; that test selected the RTX GPU with subgroup size 32. The unchanged private request (SHA-256 `a9f1f0318f46c97929ccebfffcfd8d9bebc8cbcfab132cabd4369bcc52f4a82e`) replayed successfully, producing 491,708 SPIR-V words with SPIRV-Tools validation enabled. Conventions, whitespace, and main-sync checks passed. I did not run the title from this branch. The hosted PR still points to `e6f33ead` and conflicts with main. This is a handoff for the existing PR, not a separate PR. Please review and coordinate whether to integrate the branch into #6645. AI-assisted integration and testing: yes.
adriadam10 commented 2026-10-19 07:33:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T07:33:32Z.

Review: CHANGES_REQUESTED


Thanks for the work here. Reading the diff against the evidence in the thread, this doesn't yet fix #6582, so I can't merge it as is:

  • SpirvAluEmitterMath.cpp:347 (Prove): a result is cached only if cycleGeneration didn't move while proving it. Inside a loop-carried saved EXEC mask every sub-proof crosses the Phi back edge, so none of them is cached and the loop is walked again for every use. That is the case the issue is about. Ondra97 measured it: with this commit rebased on main and the 2,048-step budget, the retained #6582 request still fails with the lane-63 refusal, and an eight-round saved-EXEC regression fails (the three-round test in ShaderMemory.cpp:2306 passes). Please extend the test to eight rounds so it pins what the PR claims (it has to fail on current main).
  • Please cache by (value, proof type) as in overlordxrz-source's b76d8d31, with the cycle handling it settled on. Ondra97 published a repair branch for this PR that does that and keeps your commit and tests: https://github.com/Ondra97/AnyPS5/tree/codex/pr6645-repair-20261019 (99ed46c85). Taking it (or equivalent) fits better than the provisional generation counter.
  • The branch conflicts with main: #6180 raised the budget to 2,048 and EntryLaneWalk still has budget = 512u here (SpirvAluEmitterMath.cpp:412). Please rebase and keep 2,048.
  • Fixes #6582 should wait until the retained request replays successfully with your change; the CPU tests alone don't show it.

Not checked by us: the Windows/NVIDIA replay of the PRAGMATA request (relying on Ondra97's report above).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5568275344 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6645#pullrequestreview-5568275344). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T07:33:32Z. **Review:** CHANGES_REQUESTED --- Thanks for the work here. Reading the diff against the evidence in the thread, this doesn't yet fix #6582, so I can't merge it as is: - `SpirvAluEmitterMath.cpp:347` (`Prove`): a result is cached only if `cycleGeneration` didn't move while proving it. Inside a loop-carried saved EXEC mask every sub-proof crosses the Phi back edge, so none of them is cached and the loop is walked again for every use. That is the case the issue is about. Ondra97 measured it: with this commit rebased on main and the 2,048-step budget, the retained #6582 request still fails with the lane-63 refusal, and an eight-round saved-EXEC regression fails (the three-round test in `ShaderMemory.cpp:2306` passes). Please extend the test to eight rounds so it pins what the PR claims (it has to fail on current main). - Please cache by (value, proof type) as in overlordxrz-source's `b76d8d31`, with the cycle handling it settled on. Ondra97 published a repair branch for this PR that does that and keeps your commit and tests: https://github.com/Ondra97/AnyPS5/tree/codex/pr6645-repair-20261019 (`99ed46c85`). Taking it (or equivalent) fits better than the provisional generation counter. - The branch conflicts with main: #6180 raised the budget to 2,048 and `EntryLaneWalk` still has `budget = 512u` here (`SpirvAluEmitterMath.cpp:412`). Please rebase and keep 2,048. - `Fixes #6582` should wait until the retained request replays successfully with your change; the CPU tests alone don't show it. Not checked by us: the Windows/NVIDIA replay of the PRAGMATA request (relying on Ondra97's report above).
Ondra97 commented 2026-10-19 12:49:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-19T12:49:40Z.


@adriadam10 I updated the repair branch to 07a36519c450807ef0f82b6f63608d7c4091d0db, synced with main b106f6f8c04cb619fb12c8b22bcedae36c6c67ac. It preserves DangerChamp's original commit and tests, with credit to overlordxrz-source for the settled proof algorithm.

The branch contains the requested eight-round saved-EXEC regression, caches by (value, proof type) with the settled cycle handling from b76d8d31, and keeps the 2,048-step budget.

I repeated the comparison on that exact main and repair head:

Check Before (main b106f6f8c0) After (repair 07a36519c4)
Eight-round saved-EXEC regression Fails with the lane-63 refusal when only the regression test is added Passes, including helper-lane rejection controls
Retained #6582 PRAGMATA request Lane-63 refusal, exit 1 Replay succeeds, exit 0; 484,635 SPIR-V words with SPIRV-Tools validation enabled

The request is unchanged: SHA-256 a9f1f0318f46c97929ccebfffcfd8d9bebc8cbcfab132cabd4369bcc52f4a82e.

Release relinker, libs, and the affected test executables built with MinGW-w64 GCC 15.2.0. The same five focused CTests passed on main and the repair: agc_shader_entry_lane_proof_budget, agc_shader_memory, agc_shader_replay_requests, agc_shader_replay_tool, and agc_driver_pixel_wave_reduction. Both runs used ctest -V, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. The logs confirm that layer loaded and the RTX GPU was selected with subgroup size 32; neither run reported a VUID- error or skipped test. Conventions and whitespace checks also passed.

Environment: Windows 11 Pro, Ryzen 9 7900X, 32 GB RAM, NVIDIA GeForce RTX 4070 Ti SUPER, driver 32.0.16.1742.

These results verify the captured shader failure; I did not run the title from this branch. #6645 still points to e6f33ead, so the repair needs to be integrated by the PR author before these changes and results apply to the PR head.

AI-assisted integration, testing, and write-up: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6267603921 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6645#issuecomment-6267603921). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-19T12:49:40Z. --- @adriadam10 I updated the [repair branch](https://github.com/Ondra97/AnyPS5/tree/codex/pr6645-repair-20261019) to [`07a36519c450807ef0f82b6f63608d7c4091d0db`](https://github.com/Ondra97/AnyPS5/commit/07a36519c450807ef0f82b6f63608d7c4091d0db), synced with main `b106f6f8c04cb619fb12c8b22bcedae36c6c67ac`. It preserves DangerChamp's original commit and tests, with credit to overlordxrz-source for the settled proof algorithm. The branch contains the requested eight-round saved-EXEC regression, caches by `(value, proof type)` with the settled cycle handling from `b76d8d31`, and keeps the 2,048-step budget. I repeated the comparison on that exact main and repair head: | Check | Before (main `b106f6f8c0`) | After (repair `07a36519c4`) | |---|---|---| | Eight-round saved-EXEC regression | Fails with the lane-63 refusal when only the regression test is added | Passes, including helper-lane rejection controls | | Retained #6582 PRAGMATA request | Lane-63 refusal, exit 1 | Replay succeeds, exit 0; 484,635 SPIR-V words with SPIRV-Tools validation enabled | The request is unchanged: SHA-256 `a9f1f0318f46c97929ccebfffcfd8d9bebc8cbcfab132cabd4369bcc52f4a82e`. Release `relinker`, `libs`, and the affected test executables built with MinGW-w64 GCC 15.2.0. The same five focused CTests passed on main and the repair: `agc_shader_entry_lane_proof_budget`, `agc_shader_memory`, `agc_shader_replay_requests`, `agc_shader_replay_tool`, and `agc_driver_pixel_wave_reduction`. Both runs used `ctest -V`, `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`. The logs confirm that layer loaded and the RTX GPU was selected with subgroup size 32; neither run reported a `VUID-` error or skipped test. Conventions and whitespace checks also passed. Environment: Windows 11 Pro, Ryzen 9 7900X, 32 GB RAM, NVIDIA GeForce RTX 4070 Ti SUPER, driver `32.0.16.1742`. These results verify the captured shader failure; I did not run the title from this branch. #6645 still points to `e6f33ead`, so the repair needs to be integrated by the PR author before these changes and results apply to the PR head. AI-assisted integration, testing, and write-up: yes.
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!6645
No description provided.