fix(shader): mask EXEC copies to the host subgroup's lanes #1264

Merged
Celegans12 merged 1 commit from upstream-pr/1264 into main 2026-10-08 10:08:54 +00:00
Celegans12 commented 2026-10-07 20:22:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-07T20:22:10Z.


What

On a 32-lane host, wave64 graphics stages run one guest lane per invocation, but an EXEC written as a value still has bits for lanes 32-63. An s_mov_b64 copy of it keeps lanes no ballot clears, so a waterfall loop over the copy never ends.

  • readRawU32 reads EXEC as EXEC & ballot(true) (hostExecWord) for s_mov_b64 sN, exec, ALU sources and EXECZ, and s_*_saveexec and s_*_wrexec store that copy. EXEC's own words, threadBit and the saveexec combination stay raw, so s_orn2_saveexec_b64 vcc, exec still sets all 64 bits.
  • Where the host holds the whole wave (wave32 on 32 lanes, compute at two lanes per invocation) nothing changes. Partly filled or 8-lane llvmpipe subgroups now leave out the lanes they lack, so agc_driver_scalar_sop1 masks its EXEC_LO copies there. TechnicalDebt notes the console's EXEC holds the other lanes too.
  • PPSA26344 v1.008: the G-buffer draws' wave64 NGG vertex shaders 0x806ef8ba00 and 0x806ef34b00 run this loop after the prologue's s_lshr_b64 exec, -1, 64 - count sets EXEC to -1. With our pending null-SRT work those draws run and hung the GPU at about 695 s. Under a 65,536-pass loop guard only these two shaders tripped it (102 times in 2,700 s).
  • #938 and #697 add declarations elsewhere in TranslationContext.hpp without conflicting.

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0, based on main c5e10184: configure -DBUILD_TESTING=ON, full build, --target libs, ctest:
  • 396/396 tests pass (ctest --output-on-failure)
  • Same build on lavapipe (Mesa 26.2.4 llvmpipe, 8-wide subgroups, VK_DRIVER_FILES): 395/395 pass; agc_driver_flat_store is left out there because it takes several minutes on Windows llvmpipe
  • New agc_driver_exec_host_lanes: the title's loop (loads cut to one s_buffer_load_dword, capped at 128 passes) takes at most 6 passes in a 189-vertex wave64 draw (32+ lanes) and a 192-thread wave64 dispatch. It fails on main with 128: the draw on NVIDIA, the dispatch on llvmpipe.
  • PPSA26344 v1.008: in a 2,700 s run with no loop guard, both vertex shaders were recompiled for G-buffer draws (at about 1,410 and 1,650 s) and the GPU did not hang: no batch ran 30 s, the G-buffer pass kept advancing, and the game exited 12 s after the stop.
  • Not tested: Linux (CI), AMD hosts, console behaviour.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4778021063 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1264). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-07T20:22:10Z. --- ### What On a 32-lane host, wave64 graphics stages run one guest lane per invocation, but an EXEC written as a value still has bits for lanes 32-63. An `s_mov_b64` copy of it keeps lanes no ballot clears, so a waterfall loop over the copy never ends. - `readRawU32` reads EXEC as EXEC & ballot(true) (`hostExecWord`) for `s_mov_b64 sN, exec`, ALU sources and EXECZ, and `s_*_saveexec` and `s_*_wrexec` store that copy. EXEC's own words, `threadBit` and the saveexec combination stay raw, so `s_orn2_saveexec_b64 vcc, exec` still sets all 64 bits. - Where the host holds the whole wave (wave32 on 32 lanes, compute at two lanes per invocation) nothing changes. Partly filled or 8-lane llvmpipe subgroups now leave out the lanes they lack, so `agc_driver_scalar_sop1` masks its EXEC_LO copies there. TechnicalDebt notes the console's EXEC holds the other lanes too. - PPSA26344 v1.008: the G-buffer draws' wave64 NGG vertex shaders 0x806ef8ba00 and 0x806ef34b00 run this loop after the prologue's `s_lshr_b64 exec, -1, 64 - count` sets EXEC to -1. With our pending null-SRT work those draws run and hung the GPU at about 695 s. Under a 65,536-pass loop guard only these two shaders tripped it (102 times in 2,700 s). - #938 and #697 add declarations elsewhere in `TranslationContext.hpp` without conflicting. ### Tested - Windows 11, MinGW-w64 GCC 15.2.0, based on `main` c5e10184: configure `-DBUILD_TESTING=ON`, full build, `--target libs`, `ctest`: - 396/396 tests pass (`ctest --output-on-failure`) - Same build on lavapipe (Mesa 26.2.4 llvmpipe, 8-wide subgroups, `VK_DRIVER_FILES`): 395/395 pass; `agc_driver_flat_store` is left out there because it takes several minutes on Windows llvmpipe - New `agc_driver_exec_host_lanes`: the title's loop (loads cut to one `s_buffer_load_dword`, capped at 128 passes) takes at most 6 passes in a 189-vertex wave64 draw (32+ lanes) and a 192-thread wave64 dispatch. It fails on `main` with 128: the draw on NVIDIA, the dispatch on llvmpipe. - PPSA26344 v1.008: in a 2,700 s run with no loop guard, both vertex shaders were recompiled for G-buffer draws (at about 1,410 and 1,650 s) and the GPU did not hang: no batch ran 30 s, the G-buffer pass kept advancing, and the game exited 12 s after the stop. - Not tested: Linux (CI), AMD hosts, console behaviour. ### 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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
fisherjoey commented 2026-10-08 07:52:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-08T07:52:26Z.


Tested on Linux and an AMD host, both listed as not tested.

Nobara 44 (Linux 7.2), GCC 16.2.1, Release, BUILD_TESTING=ON. This PR merged onto main df16c4c2, plus #1329 (without it the NVIDIA proprietary driver fails 100 GPU tests on main from the dma-buf probe).

result
CPU tests (-E agc_driver) 241 / 242, only guest_force_tls_destructor, which fails on main too
RTX 5070 Ti, driver 595.91.07, -R agc_driver -j1 167 / 167
RADV, Ryzen 5 7600X iGPU (gfx1036, pixel subgroup 64, compute wave32 on 32), Mesa 26.2.1 167 / 167

agc_driver_exec_host_lanes and agc_driver_scalar_sop1 pass on both GPUs.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6055352957 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1264#issuecomment-6055352957). Originally posted by [fisherjoey](https://github.com/fisherjoey) on 2026-10-08T07:52:26Z. --- Tested on Linux and an AMD host, both listed as not tested. Nobara 44 (Linux 7.2), GCC 16.2.1, Release, `BUILD_TESTING=ON`. This PR merged onto `main` df16c4c2, plus #1329 (without it the NVIDIA proprietary driver fails 100 GPU tests on `main` from the dma-buf probe). | | result | |---|---| | CPU tests (`-E agc_driver`) | 241 / 242, only `guest_force_tls_destructor`, which fails on `main` too | | RTX 5070 Ti, driver 595.91.07, `-R agc_driver -j1` | 167 / 167 | | RADV, Ryzen 5 7600X iGPU (gfx1036, pixel subgroup 64, compute wave32 on 32), Mesa 26.2.1 | 167 / 167 | `agc_driver_exec_host_lanes` and `agc_driver_scalar_sop1` pass on both GPUs.
Celegans12 commented 2026-10-08 07:54:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-08T07:54:51Z.


Thanks for running this on the 7600X. A 64-lane pixel subgroup is the case I can't reach on my NVIDIA laptop, so it's good to see agc_driver_exec_host_lanes pass there. I'm looking at the RADV failure you found on #1268 next.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6055390116 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1264#issuecomment-6055390116). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-08T07:54:51Z. --- Thanks for running this on the 7600X. A 64-lane pixel subgroup is the case I can't reach on my NVIDIA laptop, so it's good to see `agc_driver_exec_host_lanes` pass there. I'm looking at the RADV failure you found on #1268 next.
adriadam10 commented 2026-10-08 10:08:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T10:08:51Z.


Checked: merged onto current main, full build and ctest 434/434 green. agc_driver_exec_host_lanes fails with the source change reverted (waterfall never terminates) and passes with it. CI is green on this head (linux, windows, conventions), and fisherjoey's NVIDIA and RADV (64-lane pixel subgroup) runs also pass. No conflicts with #1217 or #1268. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6057553467 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1264#issuecomment-6057553467). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T10:08:51Z. --- Checked: merged onto current `main`, full build and ctest 434/434 green. `agc_driver_exec_host_lanes` fails with the source change reverted (waterfall never terminates) and passes with it. CI is green on this head (linux, windows, conventions), and fisherjoey's NVIDIA and RADV (64-lane pixel subgroup) runs also pass. No conflicts with #1217 or #1268. Merging.
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!1264
No description provided.