fix(recompiler): give wave64 vertex programs on 32-lane hosts a 32-lane s3 #3546

Merged
AlxcBTW merged 3 commits from upstream-pr/3546 into main 2026-10-11 21:33:17 +00:00
AlxcBTW commented 2026-10-11 12:57:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by AlxcBTW on 2026-10-11T12:57:07Z.


What

Fixes #2783. A wave64 NGG vertex program on a 32-lane host subgroup stops on current main:

ShaderRecompiler::Recompile: SPIR-V emission failed: hash=0x142147780608 stage=1 opcode=ReadLane reason=v_readlane_b32 of lane 63 is outside the 32-lane host subgroup that runs this wave64 program at one lane per invocation

Titles that stop there on NVIDIA, and get past it with this change:

  • Minecraft Dungeons II (PPSA16064): confirmed by @MisterbALLIN's log (analysis).
  • High on Life (PPSA15388): confirmed by @Tamalero (comment).
  • Palworld (PPSA23126): confirmed by @queeeef on an RTX 2080 Ti, two vertex programs at the character creation screen (comment).
  • Taxi Chaos 2 (PPSA30279) runs the same Unreal culling program, but hasn't been run with this change.

The program keys a full-wave OR on lane < s3's primitive count and reads lanes 31 and 63. At one guest lane per invocation, lanes 32-63 have no invocation on a 32-lane host, but the vertex entry set s3 = 64 | 64 << 8.

  • s3: for a wave64 vertex program on exactly 32 host lanes, emitEntryPrologue sets s3 = 32 | 32 << 8, a wave the console can launch. The host subgroup width reaches ShaderVertexInputInfo as it already reaches the compute and mesh inputs. Every cache key already carries HostSubgroupSize. Wave32 programs and 64-lane hosts are unchanged.

  • The read: with the narrowed s3, the keys are 0 in lanes 32-63. When the strict rules don't match on a 32-lane host, MatchHalfWaveScan also accepts:

    • s_mov_b64 exec, -1;
    • bound_ctrl:1 row_shr steps whose fill is the reduction's identity;
    • keys proven 0 in lanes 32-63.

    Lane 63 then reads the identity, and lane 31 the subgroup reduction. Without subgroup arithmetic, lane 31 stays a shuffle.

  • TechnicalDebt: the two entries (vertex entry s3, lanes outside the host subgroup) describe this.

Related: #2261 (open) would route registered NGG programs to the mesh path, which would also cover this. #1825 only routes unregistered programs that use LDS or s_barrier, and this program is registered.

Tested

Windows 11 (26200), WinLibs GCC 15.2.0, Release, RTX 5070 Laptop (NVIDIA 616.92, 32-lane subgroups), on main 0f863c102:

  • agc_shader_memory (verifyNarrowVertexWave): fails on main with the lane-63 error and passes with this branch. It also checks the cases that must still throw: a bound of 33, a count from user data, the vertex index instead of the lane, and a step into another register without bound_ctrl:1.
  • New execution test agc_driver_ngg_vertex_wave_reduction: fails on main with the lane-63 error and passes with this branch. It skips on other subgroup widths.
  • GPU suites: agc_driver* and agc_shader* on NVIDIA: 306/306.
  • Non-GPU suite: 527/528. The one failure, windows_exceptions, fails the same way on main (CI run 38133926187), along with three Linux tests there.
  • Conventions: tools/check_conventions.py --base origin/main passes.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4819211454 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3546). Originally posted by [AlxcBTW](https://github.com/AlxcBTW) on 2026-10-11T12:57:07Z. --- ### What Fixes #2783. A wave64 NGG vertex program on a 32-lane host subgroup stops on current `main`: ``` ShaderRecompiler::Recompile: SPIR-V emission failed: hash=0x142147780608 stage=1 opcode=ReadLane reason=v_readlane_b32 of lane 63 is outside the 32-lane host subgroup that runs this wave64 program at one lane per invocation ``` Titles that stop there on NVIDIA, and get past it with this change: - Minecraft Dungeons II (PPSA16064): confirmed by @MisterbALLIN's log ([analysis](https://github.com/boykopovar/AnyPS5/issues/2783#issuecomment-6104041614)). - High on Life (PPSA15388): confirmed by @Tamalero ([comment](https://github.com/boykopovar/AnyPS5/issues/2783#issuecomment-6107926920)). - Palworld (PPSA23126): confirmed by @queeeef on an RTX 2080 Ti, two vertex programs at the character creation screen ([comment](https://github.com/boykopovar/AnyPS5/issues/2783#issuecomment-6111647998)). - Taxi Chaos 2 (PPSA30279) runs the same Unreal culling program, but hasn't been run with this change. The program keys a full-wave OR on `lane < s3's primitive count` and reads lanes 31 and 63. At one guest lane per invocation, lanes 32-63 have no invocation on a 32-lane host, but the vertex entry set `s3 = 64 | 64 << 8`. - **`s3`:** for a wave64 vertex program on exactly 32 host lanes, `emitEntryPrologue` sets `s3 = 32 | 32 << 8`, a wave the console can launch. The host subgroup width reaches `ShaderVertexInputInfo` as it already reaches the compute and mesh inputs. Every cache key already carries `HostSubgroupSize`. Wave32 programs and 64-lane hosts are unchanged. - **The read:** with the narrowed `s3`, the keys are 0 in lanes 32-63. When the strict rules don't match on a 32-lane host, `MatchHalfWaveScan` also accepts: - `s_mov_b64 exec, -1`; - `bound_ctrl:1` `row_shr` steps whose fill is the reduction's identity; - keys proven 0 in lanes 32-63. Lane 63 then reads the identity, and lane 31 the subgroup reduction. Without subgroup arithmetic, lane 31 stays a shuffle. - **TechnicalDebt:** the two entries (vertex entry `s3`, lanes outside the host subgroup) describe this. Related: #2261 (open) would route registered NGG programs to the mesh path, which would also cover this. #1825 only routes unregistered programs that use LDS or `s_barrier`, and this program is registered. ### Tested Windows 11 (26200), WinLibs GCC 15.2.0, Release, RTX 5070 Laptop (NVIDIA 616.92, 32-lane subgroups), on `main` 0f863c102: - **`agc_shader_memory` (`verifyNarrowVertexWave`):** fails on `main` with the lane-63 error and passes with this branch. It also checks the cases that must still throw: a bound of 33, a count from user data, the vertex index instead of the lane, and a step into another register without `bound_ctrl:1`. - **New execution test `agc_driver_ngg_vertex_wave_reduction`:** fails on `main` with the lane-63 error and passes with this branch. It skips on other subgroup widths. - **GPU suites:** `agc_driver*` and `agc_shader*` on NVIDIA: 306/306. - **Non-GPU suite:** 527/528. The one failure, `windows_exceptions`, fails the same way on `main` (CI run 38133926187), along with three Linux tests there. - **Conventions:** `tools/check_conventions.py --base origin/main` passes. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed 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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
adriadam10 commented 2026-10-11 21:33:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:33:13Z.


Checked the bound_ctrl:1 row_shr scan and the culling program from the test verbatim on the HW oracle (gfx1035 wave64, s3 counts 0/1/31/32/33/64: lane 63 reads 0 whenever the count is ≤ 32, and the bound_ctrl:1 fill is the identity for OR/add/umax; 0 mismatches). agc_shader_memory and agc_driver_ngg_vertex_wave_reduction (forced to a 32-lane target on RADV with RADV_PERFTEST=gewave32) pass here and fail on main with the lane-63 error. Thanks @Tamalero and @MisterbALLIN for the runs on High on Life and Minecraft Dungeons II; merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114015235 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3546#issuecomment-6114015235). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T21:33:13Z. --- Checked the bound_ctrl:1 `row_shr` scan and the culling program from the test verbatim on the HW oracle (gfx1035 wave64, `s3` counts 0/1/31/32/33/64: lane 63 reads 0 whenever the count is ≤ 32, and the bound_ctrl:1 fill is the identity for OR/add/umax; 0 mismatches). `agc_shader_memory` and `agc_driver_ngg_vertex_wave_reduction` (forced to a 32-lane target on RADV with `RADV_PERFTEST=gewave32`) pass here and fail on `main` with the lane-63 error. Thanks @Tamalero and @MisterbALLIN for the runs on High on Life and Minecraft Dungeons II; 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!3546
No description provided.