fix(shader): budget pixel lane proof for NHL 26 replay #6180

Merged
MarcZX10 merged 2 commits from upstream-pr/6180 into main 2026-10-17 10:07:55 +00:00
MarcZX10 commented 2026-10-15 00:44:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T00:44:40Z.


What

Raise the bounded EntryLaneWalk proof budget from 512 to 2048 so a wave64 pixel shader can complete lane-63 analysis on a 32-lane host. Add a generated regression shader with loop-carried saved EXEC masks followed by a wave64 UMin scan; it verifies the 32-lane subgroup reduction is emitted. Resolves #5398.

Tested

Linux x86_64, GCC 12.2, Release. Built tests/agc_shader_memory_tests; ctest --test-dir /tmp/build-6180-proof-budget -R '^agc_shader_entry_lane_proof_budget$' --output-on-failure passed (1/1). With the same generated request, a 512-budget control fails at the lane-63 read and the 2048 budget passes. python3 tools/check_conventions.py --base upstream/main and git diff --check passed.

For the NHL 26 request from #5398, temporary local EntryLaneWalk::Spend instrumentation during agc_shader_replay --prepare recorded 1,369 successful steps in each of its two proof walks, no budget refusals, and 679 steps remaining from the 2,048 budget. The instrumentation and captured request are not part of this PR. The Linux GCC 12 build needed the independent dependent-template compile fix from #6306 temporarily in the local tree; that adjustment is not part of this PR. No GPU runtime validation was performed.

Checklist

  • Based on current main
  • 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
  • New third-party code is a submodule built from source
  • Generic behavior, not specific to one title
  • Depends on: none
  • Conflicts with #6645 in SpirvAluEmitterMath.cpp; coordinate integration with that proof-cache change
  • Unblocks: PPSA26785 #5398
  • GPUs tested: n/a (CPU-side shader emission regression)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4866510364 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6180). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-15T00:44:40Z. --- ### What Raise the bounded `EntryLaneWalk` proof budget from 512 to 2048 so a wave64 pixel shader can complete lane-63 analysis on a 32-lane host. Add a generated regression shader with loop-carried saved EXEC masks followed by a wave64 UMin scan; it verifies the 32-lane subgroup reduction is emitted. Resolves #5398. ### Tested Linux x86_64, GCC 12.2, Release. Built `tests/agc_shader_memory_tests`; `ctest --test-dir /tmp/build-6180-proof-budget -R '^agc_shader_entry_lane_proof_budget$' --output-on-failure` passed (1/1). With the same generated request, a 512-budget control fails at the lane-63 read and the 2048 budget passes. `python3 tools/check_conventions.py --base upstream/main` and `git diff --check` passed. For the NHL 26 request from #5398, temporary local `EntryLaneWalk::Spend` instrumentation during `agc_shader_replay --prepare` recorded 1,369 successful steps in each of its two proof walks, no budget refusals, and 679 steps remaining from the 2,048 budget. The instrumentation and captured request are not part of this PR. The Linux GCC 12 build needed the independent dependent-template compile fix from #6306 temporarily in the local tree; that adjustment is not part of this PR. No GPU runtime validation was performed. ### Checklist - [x] Based on current `main` - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical debt file - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behavior, not specific to one title - [x] Depends on: none - [x] Conflicts with #6645 in `SpirvAluEmitterMath.cpp`; coordinate integration with that proof-cache change - [x] Unblocks: PPSA26785 #5398 - [x] GPUs tested: n/a (CPU-side shader emission regression) - [x] AI-assisted: yes
cookie42073-cmd commented 2026-10-15 02:38:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by cookie42073-cmd on 2026-10-15T02:38:16Z.


Hey Marc, thanks for taking this on. I checked c44c700c on Windows and can confirm it gets the supplied NHL26 capture past the lane-63 stop.

This was on main 760ffa683 (including #6015), Release/MinGW GCC 15.2, with SPIRV-Tools enabled and shader caches disabled. I used milescoviello's #6125 at 686ea1d3 for the replay-tool build repair in every comparison. Your fixture matches the decoded capture from @milchgeldkassierer in #5398 byte for byte.

I also reran the saved-EXEC loop tests from the earlier patch attached to #5189, keeping those test additions identical across all three runs:

Compiler variant NHL26 capture test Added CPU loop test Added GPU loop test
Original 512 budget Lane-63 refusal Lane-63 refusal Refused during compilation
This PR's 2048 budget Pass Lane-63 refusal Refused during compilation
Earlier completed-proof cache, budget 512 Pass Pass Rendered values match CPU expectations

The added case is a synthetic saved-EXEC loop before UMin, with three mask round trips per iteration and four loop iterations. It fails before this PR too, so this is a remaining case, not a regression introduced here. With caching, the helper-inclusive and asymmetric-upper-mask controls still refuse compilation. The GPU run covered partial waves, four draws per layout, on an NVIDIA RTX 4070 SUPER, driver 617.42, Windows 11 build 26300. The 64-lane layout was still running on 32-lane hardware; this is not native 64-lane validation.

Both variants passed the full Windows build. This PR passed all 75 selected tests before the loop additions; the cached variant passed all 75 with them, with no skips. That selection includes the new quad/sample-mask tests and request serialization from #6015. Direct replay emitted identical 70,935-word SPIR-V in both successful variants; the separate PrepareShader path emitted 74,546 words in each.

I haven't run NHL26 itself or checked its images, other GPU vendors, arbitrary changing masks, a dedicated mutually dependent-Phi cache case, or the saved loop combined with non-default quad/sample masks. The earlier cached approach remains local, with no competing PR opened. Would you prefer the broader loop case as a follow-up after this lands, or to discuss it here first?

For the next title check, the useful evidence is the tested revision, any other local patches, GPU/driver/OS, and a log through the next stopping point. If another shader fails, its complete RecompileRequest would help. We already have the capture needed for this stop.

AI-assisted testing and write-up, with an independent review of the changes and before/after evidence.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6183136525 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6180#issuecomment-6183136525). Originally posted by [cookie42073-cmd](https://github.com/cookie42073-cmd) on 2026-10-15T02:38:16Z. --- Hey Marc, thanks for taking this on. I checked c44c700c on Windows and can confirm it gets the supplied NHL26 capture past the lane-63 stop. This was on main 760ffa683 (including #6015), Release/MinGW GCC 15.2, with SPIRV-Tools enabled and shader caches disabled. I used milescoviello's #6125 at 686ea1d3 for the replay-tool build repair in every comparison. Your fixture matches the decoded capture from @milchgeldkassierer in #5398 byte for byte. I also reran the saved-EXEC loop tests from the [earlier patch attached to #5189](https://github.com/boykopovar/AnyPS5/pull/5189#issuecomment-6160879528), keeping those test additions identical across all three runs: | Compiler variant | NHL26 capture test | Added CPU loop test | Added GPU loop test | | --- | --- | --- | --- | | Original 512 budget | Lane-63 refusal | Lane-63 refusal | Refused during compilation | | This PR's 2048 budget | Pass | Lane-63 refusal | Refused during compilation | | Earlier completed-proof cache, budget 512 | Pass | Pass | Rendered values match CPU expectations | The added case is a synthetic saved-EXEC loop before UMin, with three mask round trips per iteration and four loop iterations. It fails before this PR too, so this is a remaining case, not a regression introduced here. With caching, the helper-inclusive and asymmetric-upper-mask controls still refuse compilation. The GPU run covered partial waves, four draws per layout, on an NVIDIA RTX 4070 SUPER, driver 617.42, Windows 11 build 26300. The 64-lane layout was still running on 32-lane hardware; this is not native 64-lane validation. Both variants passed the full Windows build. This PR passed all 75 selected tests before the loop additions; the cached variant passed all 75 with them, with no skips. That selection includes the new quad/sample-mask tests and request serialization from #6015. Direct replay emitted identical 70,935-word SPIR-V in both successful variants; the separate PrepareShader path emitted 74,546 words in each. I haven't run NHL26 itself or checked its images, other GPU vendors, arbitrary changing masks, a dedicated mutually dependent-Phi cache case, or the saved loop combined with non-default quad/sample masks. The earlier cached approach remains local, with no competing PR opened. Would you prefer the broader loop case as a follow-up after this lands, or to discuss it here first? For the next title check, the useful evidence is the tested revision, any other local patches, GPU/driver/OS, and a log through the next stopping point. If another shader fails, its complete RecompileRequest would help. We already have the capture needed for this stop. AI-assisted testing and write-up, with an independent review of the changes and before/after evidence.
github-actions[bot] commented 2026-10-15 12:16:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:16:12Z.


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

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6645 core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp L390-391

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 1341 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 1368 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 1395 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 2434 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 4072 core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
PR 4339 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 4650 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 4891 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5021 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
PR 5371 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 5426 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5431 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5499 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5500 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 5925 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6044 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6176 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6177 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6188 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6215 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6222 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp
PR 6235 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6259 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6320 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6373 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6412 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6451 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6470 core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6503 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6535 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6683 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6718 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6747 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6808 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6937 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6946 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
PR 6947 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191823642 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6180#issuecomment-6191823642). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:16:12Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 6645](https://www.github.com/boykopovar/AnyPS5/pull/6645) | `core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp` [L390-391](https://github.com/boykopovar/AnyPS5/blob/d7262bd6d6f394fc534001bee7bf8b160f3404bf/core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp#L390-L391) | | | 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 1341](https://www.github.com/boykopovar/AnyPS5/pull/1341) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 1368](https://www.github.com/boykopovar/AnyPS5/pull/1368) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 1395](https://www.github.com/boykopovar/AnyPS5/pull/1395) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 2434](https://www.github.com/boykopovar/AnyPS5/pull/2434) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 4072](https://www.github.com/boykopovar/AnyPS5/pull/4072) | `core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp` | | [PR 4339](https://www.github.com/boykopovar/AnyPS5/pull/4339) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 4650](https://www.github.com/boykopovar/AnyPS5/pull/4650) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 4891](https://www.github.com/boykopovar/AnyPS5/pull/4891) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp` | | [PR 5371](https://www.github.com/boykopovar/AnyPS5/pull/5371) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 5426](https://www.github.com/boykopovar/AnyPS5/pull/5426) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5431](https://www.github.com/boykopovar/AnyPS5/pull/5431) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5499](https://www.github.com/boykopovar/AnyPS5/pull/5499) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5500](https://www.github.com/boykopovar/AnyPS5/pull/5500) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 5925](https://www.github.com/boykopovar/AnyPS5/pull/5925) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6176](https://www.github.com/boykopovar/AnyPS5/pull/6176) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6177](https://www.github.com/boykopovar/AnyPS5/pull/6177) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6188](https://www.github.com/boykopovar/AnyPS5/pull/6188) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6215](https://www.github.com/boykopovar/AnyPS5/pull/6215) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6222](https://www.github.com/boykopovar/AnyPS5/pull/6222) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp`<br>`core/shader/recompiler/SpirvBackend/src/SpirvAlu/SpirvAluEmitterMath.cpp` | | [PR 6235](https://www.github.com/boykopovar/AnyPS5/pull/6235) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6259](https://www.github.com/boykopovar/AnyPS5/pull/6259) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6320](https://www.github.com/boykopovar/AnyPS5/pull/6320) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6373](https://www.github.com/boykopovar/AnyPS5/pull/6373) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6412](https://www.github.com/boykopovar/AnyPS5/pull/6412) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6451](https://www.github.com/boykopovar/AnyPS5/pull/6451) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6470](https://www.github.com/boykopovar/AnyPS5/pull/6470) | `core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6503](https://www.github.com/boykopovar/AnyPS5/pull/6503) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6535](https://www.github.com/boykopovar/AnyPS5/pull/6535) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6683](https://www.github.com/boykopovar/AnyPS5/pull/6683) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6718](https://www.github.com/boykopovar/AnyPS5/pull/6718) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6747](https://www.github.com/boykopovar/AnyPS5/pull/6747) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6808](https://www.github.com/boykopovar/AnyPS5/pull/6808) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6937](https://www.github.com/boykopovar/AnyPS5/pull/6937) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6946](https://www.github.com/boykopovar/AnyPS5/pull/6946) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` | | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt`<br>`core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp` |
MarcZX10 commented 2026-10-15 13:27:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T13:27:21Z.


Thanks for the detailed comparison. I suggest keeping this PR focused on the lane-63 budget and its captured replay. The saved-EXEC loop case fails for a separate reason and the cached-proof approach changes the analysis mechanism, so it is better discussed and validated as a separate follow-up after this PR is resolved. The evidence you posted is useful for defining that follow-up’s regression cases.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6193203459 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6180#issuecomment-6193203459). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-15T13:27:21Z. --- Thanks for the detailed comparison. I suggest keeping this PR focused on the lane-63 budget and its captured replay. The saved-EXEC loop case fails for a separate reason and the cached-proof approach changes the analysis mechanism, so it is better discussed and validated as a separate follow-up after this PR is resolved. The evidence you posted is useful for defining that follow-up’s regression cases.
MarcZX10 commented 2026-10-15 13:28:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T13:28:03Z.


Rebased this PR onto current main (head 99500f9d) and resolved the CMake test-list conflict while retaining current-main test setup. The PR is mergeable; eligibility, conventions, and progress-report checks pass. I attempted the focused Linux build, but GCC 12 stops in unchanged core/shader/recompiler/Optimization/src/SrtWalker/SrtDescriptorEvaluation.cpp:183 (read.read->Flags<MemoryFlags>(), missing dependent-template parse); the target test did not run on this rebased tree. git diff --check passes. The local failure is outside this PR’s four changed files.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6193217305 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6180#issuecomment-6193217305). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-15T13:28:03Z. --- Rebased this PR onto current `main` (head `99500f9d`) and resolved the CMake test-list conflict while retaining current-main test setup. The PR is mergeable; eligibility, conventions, and progress-report checks pass. I attempted the focused Linux build, but GCC 12 stops in unchanged `core/shader/recompiler/Optimization/src/SrtWalker/SrtDescriptorEvaluation.cpp:183` (`read.read->Flags<MemoryFlags>()`, missing dependent-template parse); the target test did not run on this rebased tree. `git diff --check` passes. The local failure is outside this PR’s four changed files.
MarcZX10 commented 2026-10-15 13:28:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-15T13:28:37Z.


Correction to my previous note: the exact GCC 12 compile failure is already addressed by open PR #6306, which adds the missing template disambiguator at this call site. That fix is outside #6180’s diff; I’ll rerun the focused build once #6306 is merged rather than duplicate it here. #6180’s hosted eligibility, conventions, and report checks pass, and the rebased PR is mergeable.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6193228957 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6180#issuecomment-6193228957). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-15T13:28:37Z. --- Correction to my previous note: the exact GCC 12 compile failure is already addressed by open PR #6306, which adds the missing `template` disambiguator at this call site. That fix is outside #6180’s diff; I’ll rerun the focused build once #6306 is merged rather than duplicate it here. #6180’s hosted eligibility, conventions, and report checks pass, and the rebased PR is mergeable.
Dextroid17 commented 2026-10-16 15:14:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-16T15:14:44Z.


Ran the focused test on Linux, since your GCC 12 build stopped before it on the rebased head. GCC 16.2.1 compiles SrtDescriptorEvaluation.cpp:183 unchanged on 99500f9d4, so #6306 was not needed here. Release, BUILD_TESTING=ON, SPIRV-Tools off, clean environment (env -i), head 99500f9d4. ctest -R '^agc_shader_entry_lane_pixel_replay$' --no-tests=error -V:

  • As is: passes 3 of 3 and prints The NHL 26 wave64 pixel lane-63 shader compiles for a 32-lane host.
  • With the EntryLaneWalk budget set back to 512u (only that line changed): fails 3 of 3 with v_readlane_b32 of lane 63 is outside the 32-lane host subgroup that runs this wave64 program at one lane per invocation. Restored to 2048u, it passes again (1 run).
  • Merged with main at 896e1b2b7 (clean merge): passes 3 of 3. I did not run the 512u control on the merged tree.

So on 99500f9d4 the replay test fails without the budget change and passes with it, and it still passes merged with main at 896e1b2b7. Your c44c700c and 99500f9d4 change the same lines apart from the rebased Windows test list in CMakeLists.txt, so this adds Linux and the rebased head to cookie42073's Windows check of c44c700c. It is the CPU-side replay only; I did not run NHL 26 or anything on a GPU.

Heads-up: #6645 edits EntryLaneWalk next to the same budget line (it keeps 512u and adds a proof cache), and git merge-tree of 99500f9d4 with its head reports a conflict in SpirvAluEmitterMath.cpp.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6218566335 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6180#issuecomment-6218566335). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-16T15:14:44Z. --- Ran the focused test on Linux, since your GCC 12 build stopped before it on the rebased head. GCC 16.2.1 compiles `SrtDescriptorEvaluation.cpp:183` unchanged on 99500f9d4, so #6306 was not needed here. Release, `BUILD_TESTING=ON`, SPIRV-Tools off, clean environment (`env -i`), head 99500f9d4. `ctest -R '^agc_shader_entry_lane_pixel_replay$' --no-tests=error -V`: - As is: passes 3 of 3 and prints `The NHL 26 wave64 pixel lane-63 shader compiles for a 32-lane host`. - With the `EntryLaneWalk` budget set back to `512u` (only that line changed): fails 3 of 3 with `v_readlane_b32 of lane 63 is outside the 32-lane host subgroup that runs this wave64 program at one lane per invocation`. Restored to `2048u`, it passes again (1 run). - Merged with `main` at 896e1b2b7 (clean merge): passes 3 of 3. I did not run the `512u` control on the merged tree. So on 99500f9d4 the replay test fails without the budget change and passes with it, and it still passes merged with `main` at 896e1b2b7. Your c44c700c and 99500f9d4 change the same lines apart from the rebased Windows test list in `CMakeLists.txt`, so this adds Linux and the rebased head to cookie42073's Windows check of c44c700c. It is the CPU-side replay only; I did not run NHL 26 or anything on a GPU. Heads-up: #6645 edits `EntryLaneWalk` next to the same `budget` line (it keeps `512u` and adds a proof cache), and `git merge-tree` of 99500f9d4 with its head reports a conflict in `SpirvAluEmitterMath.cpp`. AI-assisted: yes
MarcZX10 commented 2026-10-16 15:59:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T15:59:28Z.


Thanks for running the focused replay on the rebased head with the 2048 budget and the 512 negative control. The 3/3 pass/fail result confirms the budget change is necessary on Linux, and the clean merge with main still passes. I noted the adjacent #6645 conflict for coordination.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6219416205 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6180#issuecomment-6219416205). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T15:59:28Z. --- Thanks for running the focused replay on the rebased head with the 2048 budget and the 512 negative control. The 3/3 pass/fail result confirms the budget change is necessary on Linux, and the clean merge with main still passes. I noted the adjacent #6645 conflict for coordination.
oneandonlydean commented 2026-10-17 02:17:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T02:17:49Z.


The budget change and its 512/2048 control look right. One request: could the regression test build the IR in code (like verifyHalfWaveReduction, with a chain that needs more than 512 steps) instead of committing NHL 26's captured shader as tests/data/*.req? Nothing else in the tree ships a title's shader binary, and it can stay attached here for the replay check. Also, how many steps does that shader need? If it's close to 2048, the next title will hit the limit.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6228408085 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6180#issuecomment-6228408085). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-17T02:17:49Z. --- The budget change and its 512/2048 control look right. One request: could the regression test build the IR in code (like `verifyHalfWaveReduction`, with a chain that needs more than 512 steps) instead of committing NHL 26's captured shader as `tests/data/*.req`? Nothing else in the tree ships a title's shader binary, and it can stay attached here for the replay check. Also, how many steps does that shader need? If it's close to 2048, the next title will hit the limit.
MarcZX10 commented 2026-10-17 03:06:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T03:06:34Z.


Thanks. I agree the committed title capture is not a good permanent test fixture. The attached capture has been independently checked against the decoded #5398 request, and the Linux 512/2048 control shows the replay fails with 512 and passes with 2048, but we have not instrumented EntryLaneWalk to report its exact number of Spend() visits. I therefore can't give a trustworthy step count or claim how close it is to 2048.

I started replacing the capture with a generated chain, but couldn't validate that the generated IR actually crosses the 512 proof-visit boundary on this rebased tree, so I have not kept that speculative test. Would you prefer I leave the verified capture replay in place for now, with the request attached to the PR, or hold this PR while I build and validate a synthetic >512-visit case? I can also add temporary instrumentation locally to measure the capture's exact visit count before deciding whether a generated case can represent it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6228851956 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6180#issuecomment-6228851956). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-17T03:06:34Z. --- Thanks. I agree the committed title capture is not a good permanent test fixture. The attached capture has been independently checked against the decoded #5398 request, and the Linux 512/2048 control shows the replay fails with 512 and passes with 2048, but we have not instrumented `EntryLaneWalk` to report its exact number of `Spend()` visits. I therefore can't give a trustworthy step count or claim how close it is to 2048. I started replacing the capture with a generated chain, but couldn't validate that the generated IR actually crosses the 512 proof-visit boundary on this rebased tree, so I have not kept that speculative test. Would you prefer I leave the verified capture replay in place for now, with the request attached to the PR, or hold this PR while I build and validate a synthetic >512-visit case? I can also add temporary instrumentation locally to measure the capture's exact visit count before deciding whether a generated case can represent it.
MarcZX10 commented 2026-10-17 03:22:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T03:22:31Z.


I replaced the committed NHL capture regression with a generated saved-EXEC test. It builds three loop-carried saved-EXEC masks before a wave64 pixel UMin scan. On Linux, the focused CTest passes with the 2048 budget; with only EntryLaneWalk reset to 512, the same test fails at the expected lane-63 read.

I also measured the attached NHL 26 request with temporary Spend() instrumentation in the local replay tool: each of its two entry-lane proof walks consumes 1,369 successful steps, with no budget refusals and 679 of 2,048 remaining. I restored the instrumentation afterward; the request and instrumentation are not committed. The captured-request replay is no longer a repository test fixture.

The updated PR description records the test setup and the overlap with #6645. Thanks for asking for a generated regression and the count; both points are now addressed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6228990020 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6180#issuecomment-6228990020). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-17T03:22:31Z. --- I replaced the committed NHL capture regression with a generated saved-EXEC test. It builds three loop-carried saved-EXEC masks before a wave64 pixel UMin scan. On Linux, the focused CTest passes with the 2048 budget; with only `EntryLaneWalk` reset to 512, the same test fails at the expected lane-63 read. I also measured the attached NHL 26 request with temporary `Spend()` instrumentation in the local replay tool: each of its two entry-lane proof walks consumes 1,369 successful steps, with no budget refusals and 679 of 2,048 remaining. I restored the instrumentation afterward; the request and instrumentation are not committed. The captured-request replay is no longer a repository test fixture. The updated PR description records the test setup and the overlap with #6645. Thanks for asking for a generated regression and the count; both points are now addressed.
MarcZX10 commented 2026-10-17 04:26:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T04:26:06Z.


Coordination update: the follow-up on #6582 now reports that the proof-cache candidate from #6645 compiles the retained PRAGMATA request at the original 512-step budget, and that both CPU control tests pass on the reported exact commit. This is reporter validation, not an independent run of #6645, but it materially changes the overlap picture: #6180's budget increase fixes the generated/NHL capture, while the cache proposal may also complete the harder PRAGMATA walk without raising the cap.

Both changes touch EntryLaneWalk; please compare the proof-cache implementation and its cycle handling against this PR's generated regression before deciding how to sequence or combine them. I have not independently validated #6645 or its full test suite.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6229615067 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6180#issuecomment-6229615067). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-17T04:26:06Z. --- Coordination update: the follow-up on #6582 now reports that the proof-cache candidate from #6645 compiles the retained PRAGMATA request at the original 512-step budget, and that both CPU control tests pass on the reported exact commit. This is reporter validation, not an independent run of #6645, but it materially changes the overlap picture: #6180's budget increase fixes the generated/NHL capture, while the cache proposal may also complete the harder PRAGMATA walk without raising the cap. Both changes touch `EntryLaneWalk`; please compare the proof-cache implementation and its cycle handling against this PR's generated regression before deciding how to sequence or combine them. I have not independently validated #6645 or its full test suite.
cookie42073-cmd commented 2026-10-17 06:18:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by cookie42073-cmd on 2026-10-17T06:18:28Z.


Hey folks, small commit clarification on the coordination update above: Ondra97's successful retained PRAGMATA comparison tested overlordxrz-source's b76d8d31bf4cf97d53ec52f45b0dc3937fac5532. It explicitly excluded #6645's production changes. At the time of this check, #6645 still points to e6f33ead6115c06fc58cbde29efb9d2e7e4f284e, which has the earlier cycle-generation-guarded cache, rather than the new active/assumed/settled implementation. Thanks to overlordxrz-source for the rewrite and Ondra97 for running the private capture.

I checked b76 against its parent 93e54cedd3, keeping the cap at 512. Windows 11 Pro build 26300, MinGW GCC 15.2, Release, SPIRV-Tools ON, shader cache disabled. Test and tool additions were identical between the two production variants.

Check Parent production source b76 production source
Public NHL26 request from #5398 Exit 1, lane-63 refusal Exit 0, 71,903 SPIR-V words; validation/optimization enabled
#6180's current generated agc_shader_entry_lane_proof_budget case Lane-63 refusal Pass
agc_shader_memory with the saved-EXEC loop and helper/asymmetric-half negatives Refuses the positive loop case Pass, including the negatives
agc_driver_pixel_wave_reduction with the saved-EXEC loop Lane-63 refusal Rendered-value checks pass

The GPU was an NVIDIA GeForce RTX 4070 SUPER, driver 617.42, with a 32-lane host subgroup. The loop passed four draws for each 32- and 64-lane shader layout, with 840 partial waves per layout. This does not cover a native 64-lane host GPU.

After restoring b76 and rebuilding, the NHL output was byte-identical to the first successful run, and the selected CTest set passed again: 16/16, zero skips. Both production variants completed the default full build with the shared prerequisites below. I did not run the entire 1,330-test suite. A separate exact-source IR cycle audit found no defect in its tested proof rules; it also detected deliberately unsafe caching mutations. That is supporting coverage, not a proof of arbitrary shader correctness.

Exact setup, build prerequisites, and test-only diff

The candidate changes only SpirvAluEmitterMath.cpp. For the parent control I replaced that file with its exact parent version, rebuilt, ran the controls, then restored the exact b76 source and rebuilt/retested. No #6180 budget change or #6645 production code was applied. The b76 production Git blob is 9f59064e2e08a50a71fe77f10c9a08309cf9d4e9.

I reused MarcZX100's generated test from #6180 head ec780d902fd5b9439975a213f4360b18dd0fb8b7, plus the saved-EXEC CPU/GPU controls from our earlier public evidence. The public NHL request's trimmed text SHA-256 is 10e4baf422516704748773bd95fcbf423eb3ef7808c6e2e8f2e9242e6d3d8adb; decoded bytes are 4451ff47decb5d5e313b2150be20316c558ad87aaa81b09a33a98c47d3adf90b. Those are two representations of the same request. The successful SPIR-V SHA-256 is 2882bd86eabbd649b2d0dd3ad4e232cdbd050fafbf7c6efefc8439c7bfc159bd.

The initial candidate default build stopped because an existing GPU test used 65,536-byte static alignment, above MinGW's 8,192-byte object limit, and the output path was too long. I reproduced both errors by building that same failing target with the parent production source. I retained those failure logs, used a shorter build path, and applied the same already-upstream test/tool repairs to both:

  • Adrià Franch's replay-tool Disassemble(data(), size(), ...) repair: f1905053.
  • Romans Pokrovskis's GPU-test runtime alignment repair: 4fe92c9c.

These repairs and the added tests do not change the shader production algorithm. The complete shared additions are below, including the new helper header.

diff --git a/core/libs/prx/libSceAgcDriver/CMakeLists.txt b/core/libs/prx/libSceAgcDriver/CMakeLists.txt
index f112af6ad..a36f2f5b5 100644
--- a/core/libs/prx/libSceAgcDriver/CMakeLists.txt
+++ b/core/libs/prx/libSceAgcDriver/CMakeLists.txt
@@ -1526,8 +1526,10 @@ if(BUILD_TESTING)
     add_test(NAME agc_shader_layout_pair_off COMMAND agc_shader_memory_tests --layout-pair)
     set_tests_properties(agc_shader_layout_pair PROPERTIES ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
     set_tests_properties(agc_shader_layout_pair_off PROPERTIES ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1;APS5_NO_PERF_LAYOUT_PAIR=1" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
+    add_test(NAME agc_shader_entry_lane_proof_budget COMMAND agc_shader_memory_tests --entry-lane-proof-budget)
+    set_tests_properties(agc_shader_entry_lane_proof_budget PROPERTIES ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
     if(WIN32)
-        set_tests_properties(agc_shader_bindless agc_shader_srt_read_patching agc_shader_type_zero_image_materialization agc_shader_frontend_pair agc_shader_frontend_pair_off agc_shader_layout_pair agc_shader_layout_pair_off PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
+        set_tests_properties(agc_shader_bindless agc_shader_srt_read_patching agc_shader_type_zero_image_materialization agc_shader_frontend_pair agc_shader_frontend_pair_off agc_shader_layout_pair agc_shader_layout_pair_off agc_shader_entry_lane_proof_budget PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
     endif()
     foreach(agcTest IN ITEMS agc_vertex_input_tests agc_shared_write_tests agc_driver_tests agc_shader_memory_tests agc_structurizer_tests agc_spirv_module_tests agc_dpp_write_tests agc_masked_select_tests agc_ir_reclaim_tests agc_vector_window_tests agc_constant_bit_test_tests agc_integer_narrowing_tests agc_scalar_select_mask_tests agc_vop1_control_decode_tests agc_validate_program_tests agc_pass_hazards_tests agc_shader_disk_cache_tests agc_shader_device_profile_tests agc_placeholder_images_tests agc_shader_control_flow_tests agc_driver_flip_tests agc_driver_pm4_tests agc_driver_graphics_tests agc_driver_bda_device_tests agc_driver_mesh_tests agc_driver_cmask_fast_clear_tests agc_formatted_buffer_once_tests agc_formatted_buffer_byte_stores_tests ${agcExecutionTests} agc_fma_mix_once_tests)
         if(agcTest STREQUAL "agc_driver_constant_store_tests" OR agcTest STREQUAL "agc_driver_flat_apertures_tests" OR agcTest STREQUAL "agc_driver_pipeline_optimized_readback_tests")
diff --git a/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp b/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
index 86f21811f..f895373e9 100644
--- a/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
+++ b/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
@@ -14,6 +14,7 @@
 #include "IntermediateRepresentation/IrBuilder.hpp"
 #include "IntermediateRepresentation/IrProgram.hpp"
 #include "SpirvBackend/SpirvAnalysis.hpp"
+#include "SavedExecMaskLoop.hpp"
 #if ANYPS5_ENABLE_SPIRV_TOOLS
 #include "SpirvBackend/SpirvOptimizer.hpp"
 #endif
@@ -2311,6 +2312,18 @@ void verifyHalfWaveReduction() {
         {0u, 0x38000000u, 0x88000000u, spv::OpGroupNonUniformBitwiseOr, "half-wave reduction: the wave64 OR scan did not read lane 31 as a subgroup OR on 32 lanes"},
     }};
     for (const auto& reduction : scans) require(reductions(pixel(scan(reduction.identity, reduction.vector, reduction.scalar), 32u, true), reduction.reduce) == 1u, reduction.message);
+    auto loopScan = scan(0xffffffffu, 0x26000000u, 0x83800000u);
+    const auto savedMaskLoop = AgcTest::SavedExecMaskLoop(3u);
+    loopScan.insert(loopScan.begin(), savedMaskLoop.begin(), savedMaskLoop.end());
+    auto helperLoop = loopScan;
+    helperLoop[0] = 0xbea204c1u;
+    expectFailure([&] { static_cast<void>(pixel(helperLoop, 32u, true)); }, "v_readlane_b32 of lane 63 is outside the 32-lane host subgroup", "half-wave reduction: a loop initialized with helper lanes was proven to exclude them");
+    auto upperHelperLoop = loopScan;
+    upperHelperLoop[0] = 0xbea2037eu;
+    upperHelperLoop.insert(upperHelperLoop.begin() + 1, 0xbea303c1u);
+    expectFailure([&] { static_cast<void>(pixel(upperHelperLoop, 32u, true)); }, "v_readlane_b32 of lane 63 is outside the 32-lane host subgroup", "half-wave reduction: the low-word loop proof was reused for helper-inclusive upper lanes");
+    require(reductions(pixel(loopScan, 32u, true), spv::OpGroupNonUniformUMin) == 1u, "half-wave reduction: a loop-carried saved EXEC mask exhausted the entry-lane proof on 32 lanes");
+    require(halves(pixel(loopScan, 64u, true), spv::OpGroupNonUniformUMin, 0xffffffffu), "half-wave reduction: a loop-carried saved EXEC mask did not preserve the two half-wave UMin reductions");
     auto comparedScan = scan(0u, 0x38000000u, 0x88000000u);
     *std::find(comparedScan.begin(), comparedScan.end(), 0xbe98047eu) = 0x8a986a7eu;
     comparedScan.insert(comparedScan.begin(), 0x7c080080u);
@@ -2428,6 +2441,46 @@ void verifyHalfWaveReduction() {
     expectFailure([&] { static_cast<void>(pixel(umin, 8u, true)); }, "v_permlanex16_b32 from lanes 16-31 is outside the 8-lane host subgroup", "half-wave reduction: the scan built on an 8-lane subgroup");
 }
 
+void verifyEntryLaneProofBudget() {
+    using namespace ShaderRecompiler;
+    static constexpr std::array<std::uint32_t, 5> capabilities{spv::CapabilityGroupNonUniform, spv::CapabilityGroupNonUniformBallot, spv::CapabilityGroupNonUniformShuffle, spv::CapabilityGroupNonUniformArithmetic, spv::CapabilityClipDistance};
+    std::vector<std::uint32_t> code{0xbe98047eu, 0x7e160f00u, 0x8786187eu, 0xbeea287eu, 0xd501000du, 0x001a16c1u};
+    for (const auto control : {0xff01110du, 0xff01120du, 0xff01140du, 0xff01180du}) code.insert(code.end(), {0x261a1afau, control});
+    code.insert(code.end(), {0xd778100cu, 0x0305830du, 0x261a190du, 0xbefe046au, 0xd7600006u, 0x00013f0du, 0xd7600007u, 0x00017f0du, 0x83880706u, 0x7e020208u, 0xf800180fu, 0x01010101u, 0xbf810000u});
+    std::vector<std::uint32_t> savedMaskLoops;
+    for (std::uint32_t loop = 0; loop < 3u; ++loop) {
+        std::vector<std::uint32_t> savedMaskLoop{0xbea2047eu, 0xbea40380u};
+        savedMaskLoop.insert(savedMaskLoop.end(), {0xbefe0422u, 0x7c080080u, 0x8aa26a7eu});
+        const auto branch = 0xbf850000u | static_cast<std::uint16_t>(2 - static_cast<int>(savedMaskLoop.size() + 3u));
+        savedMaskLoop.insert(savedMaskLoop.end(), {0x80248124u, 0xbf0a8424u, branch, 0xbefe0422u});
+        savedMaskLoops.insert(savedMaskLoops.end(), savedMaskLoop.begin(), savedMaskLoop.end());
+    }
+    code.insert(code.begin(), savedMaskLoops.begin(), savedMaskLoops.end());
+
+    ShaderPixelStageInfo pixel{};
+    pixel.inputAddr = PixelInputBit(PixelInput::PositionX);
+    pixel.posX = true;
+    pixel.targetOutputMode[0] = 9u;
+    pixel.targetExportMapping.fill(0xe4u);
+    RecompileRequest request{};
+    request.shader = {ShaderStage::Fragment, 0x30000u, code, 0, {}};
+    request.context.waveSize = 64u;
+    request.context.pixel = pixel;
+    request.target.vulkanVersion = 0x00401000u;
+    request.target.spirvVersion = 0x00010300u;
+    request.target.subgroupSize = 32u;
+    request.target.supportedCapabilities = capabilities;
+    request.layout.pushConstantSizeBytes = 128u;
+    request.useCache = false;
+    const auto spirv = Recompile(request).spirv;
+    std::uint32_t reductions = 0;
+    for (std::size_t cursor = 5; cursor < spirv.size() && (spirv[cursor] >> 16u) != 0u; cursor += spirv[cursor] >> 16u) {
+        if ((spirv[cursor] & 0xffffu) == static_cast<std::uint32_t>(spv::OpGroupNonUniformUMin) && (spirv[cursor] >> 16u) == 6u && spirv[cursor + 4u] == spv::GroupOperationReduce) ++reductions;
+    }
+    require(reductions == 1u, "a wave64 pixel UMin scan after loop-carried saved EXEC masks did not use a 32-lane subgroup reduction");
+}
+
+
 void verifyNarrowVertexWave() {
     using namespace ShaderRecompiler;
     static constexpr std::array<std::uint32_t, 5> capabilities{spv::CapabilityGroupNonUniform, spv::CapabilityGroupNonUniformBallot, spv::CapabilityGroupNonUniformShuffle, spv::CapabilityGroupNonUniformArithmetic, spv::CapabilityClipDistance};
@@ -5158,6 +5211,11 @@ int main(int argc, char** argv) {
             std::cout << "Both push-constant layouts of a pixel shader compile from one program unchanged\n";
             return 0;
         }
+        if (argc == 2 && std::string_view(argv[1]) == "--entry-lane-proof-budget") {
+            verifyEntryLaneProofBudget();
+            std::cout << "The wave64 pixel entry-lane proof handles loop-carried saved EXEC masks on a 32-lane host\n";
+            return 0;
+        }
         if (argc == 2 && std::string_view(argv[1]) == "--bindless") {
             verifyImageTableKeys();
             verifyImageTables();
diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/GpuIndirectArgumentsMisalignedWriterAhead.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/GpuIndirectArgumentsMisalignedWriterAhead.cpp
index 704f0fa84..d676613e0 100644
--- a/core/libs/prx/libSceAgcDriver/tests/execution/GpuIndirectArgumentsMisalignedWriterAhead.cpp
+++ b/core/libs/prx/libSceAgcDriver/tests/execution/GpuIndirectArgumentsMisalignedWriterAhead.cpp
@@ -7,6 +7,7 @@
 #include <cstring>
 #include <initializer_list>
 #include <iostream>
+#include <span>
 #include <stdexcept>
 #include <string>
 #include <vector>
@@ -22,7 +23,8 @@ alignas(256) std::array<std::uint32_t, 7> CounterCode{0xf4080200u, 0xfa000000u,
 
 constexpr std::size_t BlockBytes = 65536;
 constexpr std::uint32_t ArgumentsOffset = 4;
-alignas(BlockBytes) std::array<std::uint8_t, BlockBytes> Block{};
+std::array<std::uint8_t, BlockBytes * 2 - 1> BlockStorage{};
+const std::span<std::uint8_t, BlockBytes> Block{reinterpret_cast<std::uint8_t*>((reinterpret_cast<std::uintptr_t>(BlockStorage.data()) + BlockBytes - 1) & ~(BlockBytes - 1)), BlockBytes};
 alignas(256) std::array<std::uint32_t, 4> WriterDescriptor{};
 alignas(256) std::array<std::uint32_t, 4> Counter{};
 alignas(256) std::array<std::uint32_t, 4> CounterDescriptor{};
diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/PixelWaveReduction.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/PixelWaveReduction.cpp
index 7c007900a..a9e7de6c2 100644
--- a/core/libs/prx/libSceAgcDriver/tests/execution/PixelWaveReduction.cpp
+++ b/core/libs/prx/libSceAgcDriver/tests/execution/PixelWaveReduction.cpp
@@ -2,6 +2,7 @@
 #include "prx/libSceAgcDriver/Graphics/include/Draw.hpp"
 #include "Recompiler.hpp"
 #include "VulkanTestDevice.hpp"
+#include "../SavedExecMaskLoop.hpp"
 #include <algorithm>
 #include <array>
 #include <cstdio>
@@ -193,6 +194,15 @@ int main() {
             {"OR", 0u, 0x38000000u, 0x88000000u, [](std::uint32_t left, std::uint32_t right) { return left | right; }},
         }};
         for (const auto& layout : layouts) {
+            auto loopCode = PixelCode(reductions[0]);
+            const auto maskLoop = AgcTest::SavedExecMaskLoop(3u);
+            loopCode.insert(loopCode.begin(), maskLoop.begin(), maskLoop.end());
+            std::uint32_t loopPartial = 0;
+            for (std::uint32_t pass = 0; pass < 4; ++pass) {
+                Draw(*device, loopCode, layout);
+                loopPartial += Check(reductions[0], target.subgroupSize);
+            }
+            std::printf("UMin through a saved EXEC loop, laid out for %u lanes on %u-lane subgroups: %u partial waves over 4 draws\n", layout.subgroupSize, target.subgroupSize, loopPartial);
             for (const auto& reduction : reductions) {
                 for (const bool windowed : {false, true}) {
                     auto code = PixelCode(reduction);
diff --git a/core/libs/prx/libSceAgcDriver/tools/ShaderReplay.cpp b/core/libs/prx/libSceAgcDriver/tools/ShaderReplay.cpp
index 524575eef..9d5378691 100644
--- a/core/libs/prx/libSceAgcDriver/tools/ShaderReplay.cpp
+++ b/core/libs/prx/libSceAgcDriver/tools/ShaderReplay.cpp
@@ -147,7 +147,7 @@ bool Replay(const char* path) {
         if (g_disassemble) {
             spvtools::SpirvTools tools(SPV_ENV_VULKAN_1_2);
             std::string text;
-            if (tools.Disassemble(result.spirv, &text, SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES)) std::printf("%s\n", text.c_str());
+            if (tools.Disassemble(result.spirv.data(), result.spirv.size(), &text, SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES)) std::printf("%s\n", text.c_str());
         }
 #else
         if (g_disassemble) std::printf("  (--dis needs ANYPS5_ENABLE_SPIRV_TOOLS=ON)\n");
diff --git a/core/libs/prx/libSceAgcDriver/tests/SavedExecMaskLoop.hpp b/core/libs/prx/libSceAgcDriver/tests/SavedExecMaskLoop.hpp
new file mode 100644
--- /dev/null
+++ b/core/libs/prx/libSceAgcDriver/tests/SavedExecMaskLoop.hpp
@@ -0,0 +1,19 @@
+#ifndef CORE_LIBS_PRX_LIBSCEAGCDRIVER_TESTS_SAVEDEXECMASKLOOP_HPP
+#define CORE_LIBS_PRX_LIBSCEAGCDRIVER_TESTS_SAVEDEXECMASKLOOP_HPP
+
+#include <cstdint>
+#include <vector>
+
+namespace AgcTest {
+
+inline std::vector<std::uint32_t> SavedExecMaskLoop(std::uint32_t rounds) {
+    std::vector<std::uint32_t> code{0xbea2047eu, 0xbea40380u};
+    for (std::uint32_t step = 0; step < rounds; ++step) code.insert(code.end(), {0xbefe0422u, 0x7c080080u, 0x8aa26a7eu});
+    const auto branch = 0xbf850000u | static_cast<std::uint16_t>(2 - static_cast<int>(code.size() + 3));
+    code.insert(code.end(), {0x80248124u, 0xbf0a8424u, branch, 0xbefe0422u});
+    return code;
+}
+
+}
+
+#endif

The selected CTest expression was:

^agc_(shader_memory$|shader_entry_lane_proof_budget$|structurizer|spirv_module|masked_select|scalar_select_mask|validate_program|pass_hazards|shader_control_flow|shader_device_profile|driver_pixel_wave_reduction)

I configured BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=ON, Release; built the default targets and explicitly built agc_shader_replay; ran CTest with --no-tests=error --timeout 30 --parallel 4, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1, and ANYPS5_GPU=NVIDIA GeForce RTX 4070 SUPER. Direct replay used agc_shader_replay --spv <public-request.b64>.

The clean merge-tree check against upstream 6a32550fd18606452187c557a8be29a427cc2141 succeeds, but I have not built or tested that combined tree. No game startup, gameplay, cloth-hang fix, AMD/Intel/Linux result, or title-unblocked claim follows from these checks.

@Ondra97, could you repeat the retained PRAGMATA request on b76 with SPIRV-Tools ON, keeping the same private input, and report the validator result, exit status and word count? The payload can stay private. That would close the remaining capture-validation gap before deciding who carries the rewrite and how #6180/#6645 should be sequenced.

AI-assisted testing and write-up: Codex, with a separate Codex review.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6230604577 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6180#issuecomment-6230604577). Originally posted by [cookie42073-cmd](https://github.com/cookie42073-cmd) on 2026-10-17T06:18:28Z. --- Hey folks, small commit clarification on the coordination update above: [Ondra97's successful retained PRAGMATA comparison](https://github.com/boykopovar/AnyPS5/issues/6582#issuecomment-6223065307) tested **overlordxrz-source's [b76d8d31bf4cf97d53ec52f45b0dc3937fac5532](https://github.com/overlordxrz-source/AnyPS5/commit/b76d8d31bf4cf97d53ec52f45b0dc3937fac5532)**. It explicitly excluded #6645's production changes. At the time of this check, #6645 still points to [e6f33ead6115c06fc58cbde29efb9d2e7e4f284e](https://github.com/DangerChamp/AnyPS5/commit/e6f33ead6115c06fc58cbde29efb9d2e7e4f284e), which has the earlier cycle-generation-guarded cache, rather than the new active/assumed/settled implementation. Thanks to overlordxrz-source for the rewrite and Ondra97 for running the private capture. I checked b76 against its parent **93e54cedd3dd49eabf1c589f020b54758e0b6461**, keeping the cap at **512**. Windows 11 Pro build 26300, MinGW GCC 15.2, Release, SPIRV-Tools **ON**, shader cache disabled. Test and tool additions were identical between the two production variants. | Check | Parent production source | b76 production source | | --- | --- | --- | | Public NHL26 request from #5398 | Exit 1, lane-63 refusal | Exit 0, 71,903 SPIR-V words; validation/optimization enabled | | #6180's current generated `agc_shader_entry_lane_proof_budget` case | Lane-63 refusal | Pass | | `agc_shader_memory` with the saved-EXEC loop and helper/asymmetric-half negatives | Refuses the positive loop case | Pass, including the negatives | | `agc_driver_pixel_wave_reduction` with the saved-EXEC loop | Lane-63 refusal | Rendered-value checks pass | The GPU was an **NVIDIA GeForce RTX 4070 SUPER, driver 617.42**, with a **32-lane host subgroup**. The loop passed four draws for each 32- and 64-lane shader layout, with 840 partial waves per layout. This does not cover a native 64-lane host GPU. After restoring b76 and rebuilding, the NHL output was byte-identical to the first successful run, and the selected CTest set passed again: **16/16, zero skips**. Both production variants completed the default full build with the shared prerequisites below. I did not run the entire 1,330-test suite. A separate exact-source IR cycle audit found no defect in its tested proof rules; it also detected deliberately unsafe caching mutations. That is supporting coverage, not a proof of arbitrary shader correctness. <details> <summary>Exact setup, build prerequisites, and test-only diff</summary> The candidate changes only `SpirvAluEmitterMath.cpp`. For the parent control I replaced that file with its exact parent version, rebuilt, ran the controls, then restored the exact b76 source and rebuilt/retested. No #6180 budget change or #6645 production code was applied. The b76 production Git blob is `9f59064e2e08a50a71fe77f10c9a08309cf9d4e9`. I reused MarcZX100's generated test from #6180 head `ec780d902fd5b9439975a213f4360b18dd0fb8b7`, plus the saved-EXEC CPU/GPU controls from our earlier public evidence. The public NHL request's trimmed text SHA-256 is `10e4baf422516704748773bd95fcbf423eb3ef7808c6e2e8f2e9242e6d3d8adb`; decoded bytes are `4451ff47decb5d5e313b2150be20316c558ad87aaa81b09a33a98c47d3adf90b`. Those are two representations of the same request. The successful SPIR-V SHA-256 is `2882bd86eabbd649b2d0dd3ad4e232cdbd050fafbf7c6efefc8439c7bfc159bd`. The initial candidate default build stopped because an existing GPU test used 65,536-byte static alignment, above MinGW's 8,192-byte object limit, and the output path was too long. I reproduced both errors by building that same failing target with the parent production source. I retained those failure logs, used a shorter build path, and applied the same already-upstream test/tool repairs to both: - Adrià Franch's replay-tool `Disassemble(data(), size(), ...)` repair: [f1905053](https://github.com/boykopovar/AnyPS5/commit/f19050534e94f85b858cf233bef450a603d42415). - Romans Pokrovskis's GPU-test runtime alignment repair: [4fe92c9c](https://github.com/boykopovar/AnyPS5/commit/4fe92c9c23c7bd861d63664d4efde3033b6226f6). These repairs and the added tests do not change the shader production algorithm. The complete shared additions are below, including the new helper header. ```diff diff --git a/core/libs/prx/libSceAgcDriver/CMakeLists.txt b/core/libs/prx/libSceAgcDriver/CMakeLists.txt index f112af6ad..a36f2f5b5 100644 --- a/core/libs/prx/libSceAgcDriver/CMakeLists.txt +++ b/core/libs/prx/libSceAgcDriver/CMakeLists.txt @@ -1526,8 +1526,10 @@ if(BUILD_TESTING) add_test(NAME agc_shader_layout_pair_off COMMAND agc_shader_memory_tests --layout-pair) set_tests_properties(agc_shader_layout_pair PROPERTIES ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}") set_tests_properties(agc_shader_layout_pair_off PROPERTIES ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1;APS5_NO_PERF_LAYOUT_PAIR=1" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}") + add_test(NAME agc_shader_entry_lane_proof_budget COMMAND agc_shader_memory_tests --entry-lane-proof-budget) + set_tests_properties(agc_shader_entry_lane_proof_budget PROPERTIES ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}") if(WIN32) - set_tests_properties(agc_shader_bindless agc_shader_srt_read_patching agc_shader_type_zero_image_materialization agc_shader_frontend_pair agc_shader_frontend_pair_off agc_shader_layout_pair agc_shader_layout_pair_off PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>") + set_tests_properties(agc_shader_bindless agc_shader_srt_read_patching agc_shader_type_zero_image_materialization agc_shader_frontend_pair agc_shader_frontend_pair_off agc_shader_layout_pair agc_shader_layout_pair_off agc_shader_entry_lane_proof_budget PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>") endif() foreach(agcTest IN ITEMS agc_vertex_input_tests agc_shared_write_tests agc_driver_tests agc_shader_memory_tests agc_structurizer_tests agc_spirv_module_tests agc_dpp_write_tests agc_masked_select_tests agc_ir_reclaim_tests agc_vector_window_tests agc_constant_bit_test_tests agc_integer_narrowing_tests agc_scalar_select_mask_tests agc_vop1_control_decode_tests agc_validate_program_tests agc_pass_hazards_tests agc_shader_disk_cache_tests agc_shader_device_profile_tests agc_placeholder_images_tests agc_shader_control_flow_tests agc_driver_flip_tests agc_driver_pm4_tests agc_driver_graphics_tests agc_driver_bda_device_tests agc_driver_mesh_tests agc_driver_cmask_fast_clear_tests agc_formatted_buffer_once_tests agc_formatted_buffer_byte_stores_tests ${agcExecutionTests} agc_fma_mix_once_tests) if(agcTest STREQUAL "agc_driver_constant_store_tests" OR agcTest STREQUAL "agc_driver_flat_apertures_tests" OR agcTest STREQUAL "agc_driver_pipeline_optimized_readback_tests") diff --git a/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp b/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp index 86f21811f..f895373e9 100644 --- a/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp @@ -14,6 +14,7 @@ #include "IntermediateRepresentation/IrBuilder.hpp" #include "IntermediateRepresentation/IrProgram.hpp" #include "SpirvBackend/SpirvAnalysis.hpp" +#include "SavedExecMaskLoop.hpp" #if ANYPS5_ENABLE_SPIRV_TOOLS #include "SpirvBackend/SpirvOptimizer.hpp" #endif @@ -2311,6 +2312,18 @@ void verifyHalfWaveReduction() { {0u, 0x38000000u, 0x88000000u, spv::OpGroupNonUniformBitwiseOr, "half-wave reduction: the wave64 OR scan did not read lane 31 as a subgroup OR on 32 lanes"}, }}; for (const auto& reduction : scans) require(reductions(pixel(scan(reduction.identity, reduction.vector, reduction.scalar), 32u, true), reduction.reduce) == 1u, reduction.message); + auto loopScan = scan(0xffffffffu, 0x26000000u, 0x83800000u); + const auto savedMaskLoop = AgcTest::SavedExecMaskLoop(3u); + loopScan.insert(loopScan.begin(), savedMaskLoop.begin(), savedMaskLoop.end()); + auto helperLoop = loopScan; + helperLoop[0] = 0xbea204c1u; + expectFailure([&] { static_cast<void>(pixel(helperLoop, 32u, true)); }, "v_readlane_b32 of lane 63 is outside the 32-lane host subgroup", "half-wave reduction: a loop initialized with helper lanes was proven to exclude them"); + auto upperHelperLoop = loopScan; + upperHelperLoop[0] = 0xbea2037eu; + upperHelperLoop.insert(upperHelperLoop.begin() + 1, 0xbea303c1u); + expectFailure([&] { static_cast<void>(pixel(upperHelperLoop, 32u, true)); }, "v_readlane_b32 of lane 63 is outside the 32-lane host subgroup", "half-wave reduction: the low-word loop proof was reused for helper-inclusive upper lanes"); + require(reductions(pixel(loopScan, 32u, true), spv::OpGroupNonUniformUMin) == 1u, "half-wave reduction: a loop-carried saved EXEC mask exhausted the entry-lane proof on 32 lanes"); + require(halves(pixel(loopScan, 64u, true), spv::OpGroupNonUniformUMin, 0xffffffffu), "half-wave reduction: a loop-carried saved EXEC mask did not preserve the two half-wave UMin reductions"); auto comparedScan = scan(0u, 0x38000000u, 0x88000000u); *std::find(comparedScan.begin(), comparedScan.end(), 0xbe98047eu) = 0x8a986a7eu; comparedScan.insert(comparedScan.begin(), 0x7c080080u); @@ -2428,6 +2441,46 @@ void verifyHalfWaveReduction() { expectFailure([&] { static_cast<void>(pixel(umin, 8u, true)); }, "v_permlanex16_b32 from lanes 16-31 is outside the 8-lane host subgroup", "half-wave reduction: the scan built on an 8-lane subgroup"); } +void verifyEntryLaneProofBudget() { + using namespace ShaderRecompiler; + static constexpr std::array<std::uint32_t, 5> capabilities{spv::CapabilityGroupNonUniform, spv::CapabilityGroupNonUniformBallot, spv::CapabilityGroupNonUniformShuffle, spv::CapabilityGroupNonUniformArithmetic, spv::CapabilityClipDistance}; + std::vector<std::uint32_t> code{0xbe98047eu, 0x7e160f00u, 0x8786187eu, 0xbeea287eu, 0xd501000du, 0x001a16c1u}; + for (const auto control : {0xff01110du, 0xff01120du, 0xff01140du, 0xff01180du}) code.insert(code.end(), {0x261a1afau, control}); + code.insert(code.end(), {0xd778100cu, 0x0305830du, 0x261a190du, 0xbefe046au, 0xd7600006u, 0x00013f0du, 0xd7600007u, 0x00017f0du, 0x83880706u, 0x7e020208u, 0xf800180fu, 0x01010101u, 0xbf810000u}); + std::vector<std::uint32_t> savedMaskLoops; + for (std::uint32_t loop = 0; loop < 3u; ++loop) { + std::vector<std::uint32_t> savedMaskLoop{0xbea2047eu, 0xbea40380u}; + savedMaskLoop.insert(savedMaskLoop.end(), {0xbefe0422u, 0x7c080080u, 0x8aa26a7eu}); + const auto branch = 0xbf850000u | static_cast<std::uint16_t>(2 - static_cast<int>(savedMaskLoop.size() + 3u)); + savedMaskLoop.insert(savedMaskLoop.end(), {0x80248124u, 0xbf0a8424u, branch, 0xbefe0422u}); + savedMaskLoops.insert(savedMaskLoops.end(), savedMaskLoop.begin(), savedMaskLoop.end()); + } + code.insert(code.begin(), savedMaskLoops.begin(), savedMaskLoops.end()); + + ShaderPixelStageInfo pixel{}; + pixel.inputAddr = PixelInputBit(PixelInput::PositionX); + pixel.posX = true; + pixel.targetOutputMode[0] = 9u; + pixel.targetExportMapping.fill(0xe4u); + RecompileRequest request{}; + request.shader = {ShaderStage::Fragment, 0x30000u, code, 0, {}}; + request.context.waveSize = 64u; + request.context.pixel = pixel; + request.target.vulkanVersion = 0x00401000u; + request.target.spirvVersion = 0x00010300u; + request.target.subgroupSize = 32u; + request.target.supportedCapabilities = capabilities; + request.layout.pushConstantSizeBytes = 128u; + request.useCache = false; + const auto spirv = Recompile(request).spirv; + std::uint32_t reductions = 0; + for (std::size_t cursor = 5; cursor < spirv.size() && (spirv[cursor] >> 16u) != 0u; cursor += spirv[cursor] >> 16u) { + if ((spirv[cursor] & 0xffffu) == static_cast<std::uint32_t>(spv::OpGroupNonUniformUMin) && (spirv[cursor] >> 16u) == 6u && spirv[cursor + 4u] == spv::GroupOperationReduce) ++reductions; + } + require(reductions == 1u, "a wave64 pixel UMin scan after loop-carried saved EXEC masks did not use a 32-lane subgroup reduction"); +} + + void verifyNarrowVertexWave() { using namespace ShaderRecompiler; static constexpr std::array<std::uint32_t, 5> capabilities{spv::CapabilityGroupNonUniform, spv::CapabilityGroupNonUniformBallot, spv::CapabilityGroupNonUniformShuffle, spv::CapabilityGroupNonUniformArithmetic, spv::CapabilityClipDistance}; @@ -5158,6 +5211,11 @@ int main(int argc, char** argv) { std::cout << "Both push-constant layouts of a pixel shader compile from one program unchanged\n"; return 0; } + if (argc == 2 && std::string_view(argv[1]) == "--entry-lane-proof-budget") { + verifyEntryLaneProofBudget(); + std::cout << "The wave64 pixel entry-lane proof handles loop-carried saved EXEC masks on a 32-lane host\n"; + return 0; + } if (argc == 2 && std::string_view(argv[1]) == "--bindless") { verifyImageTableKeys(); verifyImageTables(); diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/GpuIndirectArgumentsMisalignedWriterAhead.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/GpuIndirectArgumentsMisalignedWriterAhead.cpp index 704f0fa84..d676613e0 100644 --- a/core/libs/prx/libSceAgcDriver/tests/execution/GpuIndirectArgumentsMisalignedWriterAhead.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/execution/GpuIndirectArgumentsMisalignedWriterAhead.cpp @@ -7,6 +7,7 @@ #include <cstring> #include <initializer_list> #include <iostream> +#include <span> #include <stdexcept> #include <string> #include <vector> @@ -22,7 +23,8 @@ alignas(256) std::array<std::uint32_t, 7> CounterCode{0xf4080200u, 0xfa000000u, constexpr std::size_t BlockBytes = 65536; constexpr std::uint32_t ArgumentsOffset = 4; -alignas(BlockBytes) std::array<std::uint8_t, BlockBytes> Block{}; +std::array<std::uint8_t, BlockBytes * 2 - 1> BlockStorage{}; +const std::span<std::uint8_t, BlockBytes> Block{reinterpret_cast<std::uint8_t*>((reinterpret_cast<std::uintptr_t>(BlockStorage.data()) + BlockBytes - 1) & ~(BlockBytes - 1)), BlockBytes}; alignas(256) std::array<std::uint32_t, 4> WriterDescriptor{}; alignas(256) std::array<std::uint32_t, 4> Counter{}; alignas(256) std::array<std::uint32_t, 4> CounterDescriptor{}; diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/PixelWaveReduction.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/PixelWaveReduction.cpp index 7c007900a..a9e7de6c2 100644 --- a/core/libs/prx/libSceAgcDriver/tests/execution/PixelWaveReduction.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/execution/PixelWaveReduction.cpp @@ -2,6 +2,7 @@ #include "prx/libSceAgcDriver/Graphics/include/Draw.hpp" #include "Recompiler.hpp" #include "VulkanTestDevice.hpp" +#include "../SavedExecMaskLoop.hpp" #include <algorithm> #include <array> #include <cstdio> @@ -193,6 +194,15 @@ int main() { {"OR", 0u, 0x38000000u, 0x88000000u, [](std::uint32_t left, std::uint32_t right) { return left | right; }}, }}; for (const auto& layout : layouts) { + auto loopCode = PixelCode(reductions[0]); + const auto maskLoop = AgcTest::SavedExecMaskLoop(3u); + loopCode.insert(loopCode.begin(), maskLoop.begin(), maskLoop.end()); + std::uint32_t loopPartial = 0; + for (std::uint32_t pass = 0; pass < 4; ++pass) { + Draw(*device, loopCode, layout); + loopPartial += Check(reductions[0], target.subgroupSize); + } + std::printf("UMin through a saved EXEC loop, laid out for %u lanes on %u-lane subgroups: %u partial waves over 4 draws\n", layout.subgroupSize, target.subgroupSize, loopPartial); for (const auto& reduction : reductions) { for (const bool windowed : {false, true}) { auto code = PixelCode(reduction); diff --git a/core/libs/prx/libSceAgcDriver/tools/ShaderReplay.cpp b/core/libs/prx/libSceAgcDriver/tools/ShaderReplay.cpp index 524575eef..9d5378691 100644 --- a/core/libs/prx/libSceAgcDriver/tools/ShaderReplay.cpp +++ b/core/libs/prx/libSceAgcDriver/tools/ShaderReplay.cpp @@ -147,7 +147,7 @@ bool Replay(const char* path) { if (g_disassemble) { spvtools::SpirvTools tools(SPV_ENV_VULKAN_1_2); std::string text; - if (tools.Disassemble(result.spirv, &text, SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES)) std::printf("%s\n", text.c_str()); + if (tools.Disassemble(result.spirv.data(), result.spirv.size(), &text, SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES)) std::printf("%s\n", text.c_str()); } #else if (g_disassemble) std::printf(" (--dis needs ANYPS5_ENABLE_SPIRV_TOOLS=ON)\n"); diff --git a/core/libs/prx/libSceAgcDriver/tests/SavedExecMaskLoop.hpp b/core/libs/prx/libSceAgcDriver/tests/SavedExecMaskLoop.hpp new file mode 100644 --- /dev/null +++ b/core/libs/prx/libSceAgcDriver/tests/SavedExecMaskLoop.hpp @@ -0,0 +1,19 @@ +#ifndef CORE_LIBS_PRX_LIBSCEAGCDRIVER_TESTS_SAVEDEXECMASKLOOP_HPP +#define CORE_LIBS_PRX_LIBSCEAGCDRIVER_TESTS_SAVEDEXECMASKLOOP_HPP + +#include <cstdint> +#include <vector> + +namespace AgcTest { + +inline std::vector<std::uint32_t> SavedExecMaskLoop(std::uint32_t rounds) { + std::vector<std::uint32_t> code{0xbea2047eu, 0xbea40380u}; + for (std::uint32_t step = 0; step < rounds; ++step) code.insert(code.end(), {0xbefe0422u, 0x7c080080u, 0x8aa26a7eu}); + const auto branch = 0xbf850000u | static_cast<std::uint16_t>(2 - static_cast<int>(code.size() + 3)); + code.insert(code.end(), {0x80248124u, 0xbf0a8424u, branch, 0xbefe0422u}); + return code; +} + +} + +#endif ``` The selected CTest expression was: ```text ^agc_(shader_memory$|shader_entry_lane_proof_budget$|structurizer|spirv_module|masked_select|scalar_select_mask|validate_program|pass_hazards|shader_control_flow|shader_device_profile|driver_pixel_wave_reduction) ``` I configured `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=ON`, Release; built the default targets and explicitly built `agc_shader_replay`; ran CTest with `--no-tests=error --timeout 30 --parallel 4`, `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_REQUIRE_VULKAN=1`, and `ANYPS5_GPU=NVIDIA GeForce RTX 4070 SUPER`. Direct replay used `agc_shader_replay --spv <public-request.b64>`. </details> The clean merge-tree check against upstream `6a32550fd18606452187c557a8be29a427cc2141` succeeds, but I have not built or tested that combined tree. No game startup, gameplay, cloth-hang fix, AMD/Intel/Linux result, or title-unblocked claim follows from these checks. @Ondra97, could you repeat the retained PRAGMATA request on b76 with **SPIRV-Tools ON**, keeping the same private input, and report the validator result, exit status and word count? The payload can stay private. That would close the remaining capture-validation gap before deciding who carries the rewrite and how #6180/#6645 should be sequenced. AI-assisted testing and write-up: Codex, with a separate Codex review.
cookie42073-cmd commented 2026-10-17 06:40:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by cookie42073-cmd on 2026-10-17T06:40:09Z.


Quick follow-up on the b76 comparison above: I reran it against current upstream 6a32550fd18606452187c557a8be29a427cc2141. The public NHL 26 request still fails there, and passes with overlordxrz-source's b76d8d31bf4cf97d53ec52f45b0dc3937fac5532 applied. The cap stays at 512.

Check Upstream 6a32550 Upstream + b76
Default full Windows build Pass Pass
Public NHL 26 request from #5398, SPIRV-Tools ON Exit 1, lane-63 refusal Exit 0, 71,903 SPIR-V words
Selected regression set 36/39 pass; entry-lane budget, shader-memory positive loop and pixel-wave reduction fail 39/39 pass
Six repeats with APS5_SPANNED_WAVE=1 5/6 pass; pixel-wave reduction fails 6/6 pass

Both test sets had zero skips. The execution-test filter was empty and the build contained no ExecutionTestNotBuilt fixtures. This is the selected set below, not the entire 1,375 registered tests. The default run had APS5_SPANNED_WAVE genuinely unset; setting it to 0 would still enable it.

The integration retains upstream's state.spannedWave reduction guard and ShuffleInHalf changes. The LDS waterfall fixture explicitly completed both two-lane and spanned execution in both arms. The six opt-in repeats also include pixel/wave32 exclusion checks; I am not claiming all six execute the compute-spanning path. Request serialization, shader-cache separation, capture/replay and neighboring lane/helper-mask tests passed in both arms.

Tested on NVIDIA GeForce RTX 4070 SUPER, driver 617.42, Windows 11 Pro build 26300, MinGW GCC 15.2, Release, SPIRV-Tools ON, shader cache disabled. The saved-EXEC pixel loop passed rendered-value checks for both 32- and 64-lane shader layouts on 32-lane host subgroups: four draws and 840 partial waves per layout. This does not test a native 64-lane host GPU.

Only SpirvAluEmitterMath.cpp changed in the production integration. Its Git blob is 88e85477cce1d1baf0a3700d6823d7157ae648c7; the production tree is 1e513ac835893a8abc8b59a9c4cb35073eb587b1. The original author is preserved in the local cherry-pick. EntryLaneWalk is identical to original b76. The successful NHL output is byte-identical to the earlier b76 run: SHA-256 2882bd86eabbd649b2d0dd3ad4e232cdbd050fafbf7c6efefc8439c7bfc159bd.

The test additions were identical between arms: MarcZX100's generated case from #6180 head ec780d902fd5b9439975a213f4360b18dd0fb8b7, plus the saved-EXEC CPU/GPU controls in the earlier comment. Only its four test files were carried; Adrià Franch's replay-tool fix and Romans Pokrovskis's alignment fix are already in this upstream. A fresh audit of the exact merged helper source passed the earlier cyclic-proof controls and detected both deliberately unsafe cache mutations. Those extracted helpers are unchanged from the first audit, so this refresh verifies integration identity rather than adding new proof-rule coverage. Conventions checks passed too.

Selected CTest names
agc_shader_entry_lane_proof_budget
agc_shader_memory
agc_structurizer
agc_spirv_module
agc_masked_select
agc_scalar_select_mask
agc_validate_program
agc_pass_hazards
agc_shader_device_profile
agc_shader_control_flow
agc_driver_pixel_wave_reduction
agc_structurizer_intersection_off
agc_structurizer_iteration_selection_off
agc_shader_control_flow_iteration_selection_off
agc_structurizer_forced_fallback
agc_shader_control_flow_forced_fallback
agc_shader_quad_mask_no_demote
agc_shader_disk_cache
request_serializer
agc_dpp_write
agc_vector_window
agc_vector_window_stage_inputs
scalar_saveexec
wave32_wide_subgroup
agc_driver_pixel_helper_lanes
agc_driver_pixel_valid_mask
agc_driver_quad_pixel_mask
agc_driver_lds_mask_waterfall
agc_driver_wave32_exec_lane_bits
agc_driver_read_first_lane
agc_driver_dpp16_inactive_source
agc_driver_sample_mask_draw
agc_driver_sample_mask_multisample
agc_driver_sample_mask_depth_stencil
agc_wave_control_decode
agc_driver_permlane16
agc_compute_pipeline_capture
agc_compute_pipeline_replay
agc_compute_pipeline_capture_run

The opt-in repeats were agc_driver_lds_mask_waterfall, agc_driver_read_first_lane, agc_driver_dpp16_inactive_source, agc_driver_wave32_exec_lane_bits, agc_driver_pixel_wave_reduction and agc_driver_pixel_helper_lanes.

This adds current-main integration evidence for the existing #6180/#6645 discussion; no duplicate PR. It does not demonstrate NHL 26 gameplay or a title unblock, and I have not run the private PRAGMATA capture, AMD or Linux here. AI assistance was used for the validation setup and write-up, with an independent review before posting.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6230786549 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6180#issuecomment-6230786549). Originally posted by [cookie42073-cmd](https://github.com/cookie42073-cmd) on 2026-10-17T06:40:09Z. --- Quick follow-up on the [b76 comparison above](https://github.com/boykopovar/AnyPS5/pull/6180#issuecomment-6230604577): I reran it against current upstream **[6a32550fd18606452187c557a8be29a427cc2141](https://github.com/boykopovar/AnyPS5/commit/6a32550fd18606452187c557a8be29a427cc2141)**. The public NHL 26 request still fails there, and passes with **overlordxrz-source's [b76d8d31bf4cf97d53ec52f45b0dc3937fac5532](https://github.com/overlordxrz-source/AnyPS5/commit/b76d8d31bf4cf97d53ec52f45b0dc3937fac5532)** applied. The cap stays at **512**. | Check | Upstream 6a32550 | Upstream + b76 | | --- | --- | --- | | Default full Windows build | Pass | Pass | | Public NHL 26 request from #5398, SPIRV-Tools ON | Exit 1, lane-63 refusal | Exit 0, 71,903 SPIR-V words | | Selected regression set | 36/39 pass; entry-lane budget, shader-memory positive loop and pixel-wave reduction fail | 39/39 pass | | Six repeats with `APS5_SPANNED_WAVE=1` | 5/6 pass; pixel-wave reduction fails | 6/6 pass | Both test sets had **zero skips**. The execution-test filter was empty and the build contained no `ExecutionTestNotBuilt` fixtures. This is the selected set below, not the entire 1,375 registered tests. The default run had `APS5_SPANNED_WAVE` genuinely unset; setting it to `0` would still enable it. The integration retains upstream's `state.spannedWave` reduction guard and `ShuffleInHalf` changes. The LDS waterfall fixture explicitly completed **both two-lane and spanned execution** in both arms. The six opt-in repeats also include pixel/wave32 exclusion checks; I am not claiming all six execute the compute-spanning path. Request serialization, shader-cache separation, capture/replay and neighboring lane/helper-mask tests passed in both arms. Tested on **NVIDIA GeForce RTX 4070 SUPER, driver 617.42, Windows 11 Pro build 26300**, MinGW GCC 15.2, Release, SPIRV-Tools ON, shader cache disabled. The saved-EXEC pixel loop passed rendered-value checks for both 32- and 64-lane shader layouts on **32-lane host subgroups**: four draws and 840 partial waves per layout. This does not test a native 64-lane host GPU. Only `SpirvAluEmitterMath.cpp` changed in the production integration. Its Git blob is `88e85477cce1d1baf0a3700d6823d7157ae648c7`; the production tree is `1e513ac835893a8abc8b59a9c4cb35073eb587b1`. The original author is preserved in the local cherry-pick. `EntryLaneWalk` is identical to original b76. The successful NHL output is byte-identical to the earlier b76 run: SHA-256 `2882bd86eabbd649b2d0dd3ad4e232cdbd050fafbf7c6efefc8439c7bfc159bd`. The test additions were identical between arms: MarcZX100's generated case from #6180 head `ec780d902fd5b9439975a213f4360b18dd0fb8b7`, plus the saved-EXEC CPU/GPU controls in the earlier comment. Only its four test files were carried; Adrià Franch's replay-tool fix and Romans Pokrovskis's alignment fix are already in this upstream. A fresh audit of the exact merged helper source passed the earlier cyclic-proof controls and detected both deliberately unsafe cache mutations. Those extracted helpers are unchanged from the first audit, so this refresh verifies integration identity rather than adding new proof-rule coverage. Conventions checks passed too. <details> <summary>Selected CTest names</summary> ```text agc_shader_entry_lane_proof_budget agc_shader_memory agc_structurizer agc_spirv_module agc_masked_select agc_scalar_select_mask agc_validate_program agc_pass_hazards agc_shader_device_profile agc_shader_control_flow agc_driver_pixel_wave_reduction agc_structurizer_intersection_off agc_structurizer_iteration_selection_off agc_shader_control_flow_iteration_selection_off agc_structurizer_forced_fallback agc_shader_control_flow_forced_fallback agc_shader_quad_mask_no_demote agc_shader_disk_cache request_serializer agc_dpp_write agc_vector_window agc_vector_window_stage_inputs scalar_saveexec wave32_wide_subgroup agc_driver_pixel_helper_lanes agc_driver_pixel_valid_mask agc_driver_quad_pixel_mask agc_driver_lds_mask_waterfall agc_driver_wave32_exec_lane_bits agc_driver_read_first_lane agc_driver_dpp16_inactive_source agc_driver_sample_mask_draw agc_driver_sample_mask_multisample agc_driver_sample_mask_depth_stencil agc_wave_control_decode agc_driver_permlane16 agc_compute_pipeline_capture agc_compute_pipeline_replay agc_compute_pipeline_capture_run ``` The opt-in repeats were `agc_driver_lds_mask_waterfall`, `agc_driver_read_first_lane`, `agc_driver_dpp16_inactive_source`, `agc_driver_wave32_exec_lane_bits`, `agc_driver_pixel_wave_reduction` and `agc_driver_pixel_helper_lanes`. </details> This adds current-main integration evidence for the existing #6180/#6645 discussion; no duplicate PR. It does not demonstrate NHL 26 gameplay or a title unblock, and I have not run the private PRAGMATA capture, AMD or Linux here. AI assistance was used for the validation setup and write-up, with an independent review before posting.
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!6180
No description provided.