Shaders: NVIctory's split-wave64 lowering as a last-resort fallback on 32-lane hosts #259

Closed
taskywasky wants to merge 1 commit from upstream-pr/259 into main
taskywasky commented 2026-11-27 20:15:28 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by taskywasky on 2026-11-27T20:15:28Z.


What

On a host whose waves have 32 lanes (NVIDIA), 22 console wave64 compute programs of GTA VI 1.0.2.1 still stop with no wave32 lowering for this wave64 program. They read and write LDS inside one lane-branch region, which lds_meetings cannot order. Their dispatches are dropped.

This adds NVIctory's split-wave64 lowering (its commits c41faed..61db46f, emit/split.rs) as a last-resort fallback. It runs only after every existing form (local waves, widen, threading, split_lds/lds_meetings) still leaves a program needing 64-lane waves. It never reaches a program those forms translate. VICTORY_WAVE_SPLIT=0 turns it off, and the switch is part of the shader cache key. VICTORY_WAVE_WHY=1 prints each decision (WAVE64-SPLIT lines).

  • From NVIctory: the convergence fixpoint over half-local scalars, and the proofs that a region's LDS accesses need no fence between them (independent_lds, singleton_lds, thread_zero; one-wave groups only, as in NVIctory). Also NVIctory's retry when a region is refused: forward s_cbranch_execz skips fall through (s_nop), and in one-wave groups the region's scc/vcc/exec branches and loop exits are taken wave-wide (structure_wide), for up to 24 rounds.
  • The lowering stays this fork's: its exchange between the two host halves, and its meetings around the region (lds_meetings now also admits regions that both read and write, when the fallback has proved them).

Upsides

  • 20 more compute programs translate: compute goes from 2655 to 2675 of 2682 emitted. All 2675 validate with dxil.dll and create pipelines on an RTX 3060 (bulk translate --list --validate --pipelines, VICTORY_HOST_WAVE=32).
  • What is new: all 7 GpuParticleEmit CS_Emit*_Dynamic_* programs (particles emitted from moving models and edges, skinned and attached-mesh variants), all 9 vfx_proj_decal_trail programs (projected decal trails, liquid trails, heap defrag), the two hair shadow masks (shadowmask:CS_GenerateShadowMasks*_SampleHairScreenSpace) and two water CS_TransmissionVolumetrics programs.
  • No regressions offline: none of the 25,889 programs in the listing that emitted before changed outcome, and their DXIL hashes are byte-identical to main.
  • Small and gated: the whole fallback is behind a thread-local the retry alone sets, so nothing else changes.
  • Tests: cargo test -p victory-shader passes 295 tests, including NVIctory's LDS-proof tests ported to this lowering (split_tests.rs).

Current issues and limits

  • Mostly untested in game. A 9-minute run on an RTX 3060 hit only one of the 20 new programs, the water volumetrics, which created its pipeline and ran without errors. It caused no timeout and no device removal. The particle and decal-trail programs never dispatched in that run, so their output has not been seen yet.
  • Approximations carried over from NVIctory: outside code the whole group runs together, ballots, SCC-of-mask, wave reductions, v_readlane and v_readfirstlane use this host half's 32 lanes only (NVIctory's documented shortcut). That is exact when one half is idle or the value is uniform, and wrong when a single value is needed across all 64 lanes.
  • Larger groups: for groups of more than 64 threads (the 128- and 512-thread decal trail programs), the LDS race proof is skipped, as in NVIctory. The program's own s_barriers are relied on instead.
  • Beyond NVIctory:
    • When the retry is stuck, the lane branches that split the group at convergent blocks are taken wave-wide. NVIctory ballots the later scalar test instead, which this lowering has no form for. The emitter particle programs need this.
    • A first-lane read that is exchanged in an all-lane block is treated as the same in both halves.
  • NVIctory refuses these four, here they translate: the hair shadow masks and the water volumetrics. They are the riskiest of the 20.
  • Performance cost: the fallback adds group barriers, and its wave-wide branches run every lane of a loop until the whole wave is done, so these programs cost more than on a 64-lane host.
  • Still refused: vfx_triangleClip:CS_CollectTriangles{,_Meshlets}, which has no room for the exchange in 32 KiB of LDS.
  • Unrelated, already in main: pink and black surfaces in some scenes show up both with and without this change. They are being looked at separately.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5532564073 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/259). Originally posted by [taskywasky](https://github.com/taskywasky) on 2026-11-27T20:15:28Z. --- ## What On a host whose waves have 32 lanes (NVIDIA), 22 console wave64 compute programs of GTA VI 1.0.2.1 still stop with `no wave32 lowering for this wave64 program`. They read and write LDS inside one lane-branch region, which `lds_meetings` cannot order. Their dispatches are dropped. This adds NVIctory's split-wave64 lowering (its commits `c41faed..61db46f`, `emit/split.rs`) as a **last-resort fallback**. It runs only after every existing form (local waves, `widen`, threading, `split_lds`/`lds_meetings`) still leaves a program needing 64-lane waves. It never reaches a program those forms translate. `VICTORY_WAVE_SPLIT=0` turns it off, and the switch is part of the shader cache key. `VICTORY_WAVE_WHY=1` prints each decision (`WAVE64-SPLIT` lines). - **From NVIctory:** the convergence fixpoint over half-local scalars, and the proofs that a region's LDS accesses need no fence between them (`independent_lds`, `singleton_lds`, `thread_zero`; one-wave groups only, as in NVIctory). Also NVIctory's retry when a region is refused: forward `s_cbranch_execz` skips fall through (`s_nop`), and in one-wave groups the region's scc/vcc/exec branches and loop exits are taken wave-wide (`structure_wide`), for up to 24 rounds. - **The lowering stays this fork's:** its exchange between the two host halves, and its meetings around the region (`lds_meetings` now also admits regions that both read and write, when the fallback has proved them). ## Upsides - **20 more compute programs translate**: compute goes from 2655 to 2675 of 2682 emitted. All 2675 validate with `dxil.dll` and create pipelines on an RTX 3060 (bulk `translate --list --validate --pipelines`, `VICTORY_HOST_WAVE=32`). - **What is new:** all 7 `GpuParticleEmit` `CS_Emit*_Dynamic_*` programs (particles emitted from moving models and edges, skinned and attached-mesh variants), all 9 `vfx_proj_decal_trail` programs (projected decal trails, liquid trails, heap defrag), the two hair shadow masks (`shadowmask:CS_GenerateShadowMasks*_SampleHairScreenSpace`) and two water `CS_TransmissionVolumetrics` programs. - **No regressions offline:** none of the 25,889 programs in the listing that emitted before changed outcome, and their DXIL hashes are byte-identical to `main`. - **Small and gated:** the whole fallback is behind a thread-local the retry alone sets, so nothing else changes. - **Tests:** `cargo test -p victory-shader` passes 295 tests, including NVIctory's LDS-proof tests ported to this lowering (`split_tests.rs`). ## Current issues and limits - **Mostly untested in game.** A 9-minute run on an RTX 3060 hit only one of the 20 new programs, the water volumetrics, which created its pipeline and ran without errors. It caused no timeout and no device removal. The particle and decal-trail programs never dispatched in that run, so their output has not been seen yet. - **Approximations carried over from NVIctory:** outside code the whole group runs together, ballots, SCC-of-mask, wave reductions, `v_readlane` and `v_readfirstlane` use this host half's 32 lanes only (NVIctory's documented shortcut). That is exact when one half is idle or the value is uniform, and wrong when a single value is needed across all 64 lanes. - **Larger groups:** for groups of more than 64 threads (the 128- and 512-thread decal trail programs), the LDS race proof is skipped, as in NVIctory. The program's own `s_barrier`s are relied on instead. - **Beyond NVIctory:** - When the retry is stuck, the lane branches that split the group at convergent blocks are taken wave-wide. NVIctory ballots the later scalar test instead, which this lowering has no form for. The emitter particle programs need this. - A first-lane read that is exchanged in an all-lane block is treated as the same in both halves. - **NVIctory refuses these four, here they translate:** the hair shadow masks and the water volumetrics. They are the riskiest of the 20. - **Performance cost:** the fallback adds group barriers, and its wave-wide branches run every lane of a loop until the whole wave is done, so these programs cost more than on a 64-lane host. - **Still refused:** `vfx_triangleClip:CS_CollectTriangles{,_Meshlets}`, which has no room for the exchange in 32 KiB of LDS. - **Unrelated, already in `main`:** pink and black surfaces in some scenes show up both with and without this change. They are being looked at separately.
starnotes-xj commented 2026-11-28 07:24:21 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by starnotes-xj on 2026-11-28T07:24:21Z.


Tested on an 8 GB 32-lane host — reporting what it does and does not reach there, since it turned out not to be needed for the face-relocation program this time.

Card: RTX 4060 Laptop 8 GB, GTA VI 1.0.2.1, latest main (55 commits, 8fc2254), VICTORY_HOST_WAVE=32.

I merged this together with #560 into a build that also carries #490 (the launchers stop leaving CS_DefragHeap_ComputeRelocations out of VICTORY_LEAVE_OUT) and #669. The motivation was 02384a60fda6f2d0 (vfx_triangleClip:CS_DefragHeap_ComputeRelocations), which is refused with no wave32 lowering for this wave64 program and whose dispatches being dropped is why characters had no faces.

Attribution, with this PR's fallback switched off and the translator run on that program alone:

$ VICTORY_WAVE_SPLIT=0 VICTORY_HOST_WAVE=32 victory translate <game dir> --warm hashes.txt --list
warm-up  1 hashes asked, 1 found: 1 translated now, 0 in the cache already, 0 do not translate

So with #560 merged, that program is taken by the existing forms and your fallback is never reached for it — no problem with the ordering as written, just noting that the two PRs overlap on this program and #560 alone covers it.

What is left in a whole run afterwards is 6b82bc7d22016cb5 (the meshlet collector, groups of 1024, LDS past the host's 32 KiB) and nothing else, which matches #101's note.

No behaviour change was visible otherwise: same scenes, same frame times within run-to-run noise (about 18 fps on this card, 2560x1440 output, Series S, DLSS Quality).

Also: VICTORY_WAVE_WHY=1 was useful for this — the WAVE64-SPLIT round N lines make it obvious when the fallback is not entered at all.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7235918040 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/259#issuecomment-7235918040). Originally posted by [starnotes-xj](https://github.com/starnotes-xj) on 2026-11-28T07:24:21Z. --- Tested on an 8 GB 32-lane host — reporting what it does and does not reach there, since it turned out not to be needed for the face-relocation program this time. Card: RTX 4060 Laptop 8 GB, GTA VI 1.0.2.1, latest `main` (55 commits, `8fc2254`), `VICTORY_HOST_WAVE=32`. I merged this together with #560 into a build that also carries #490 (the launchers stop leaving `CS_DefragHeap_ComputeRelocations` out of `VICTORY_LEAVE_OUT`) and #669. The motivation was `02384a60fda6f2d0` (`vfx_triangleClip:CS_DefragHeap_ComputeRelocations`), which is refused with `no wave32 lowering for this wave64 program` and whose dispatches being dropped is why characters had no faces. Attribution, with this PR's fallback switched off and the translator run on that program alone: ``` $ VICTORY_WAVE_SPLIT=0 VICTORY_HOST_WAVE=32 victory translate <game dir> --warm hashes.txt --list warm-up 1 hashes asked, 1 found: 1 translated now, 0 in the cache already, 0 do not translate ``` So with #560 merged, that program is taken by the existing forms and your fallback is never reached for it — no problem with the ordering as written, just noting that the two PRs overlap on this program and #560 alone covers it. What is left in a whole run afterwards is `6b82bc7d22016cb5` (the meshlet collector, groups of 1024, LDS past the host's 32 KiB) and nothing else, which matches #101's note. No behaviour change was visible otherwise: same scenes, same frame times within run-to-run noise (about 18 fps on this card, 2560x1440 output, Series S, DLSS Quality). Also: `VICTORY_WAVE_WHY=1` was useful for this — the `WAVE64-SPLIT round N` lines make it obvious when the fallback is not entered at all.
trustno1-coder commented 2026-11-28 19:23:08 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by trustno1-coder on 2026-11-28T19:23:08Z.


Thanks for this. I'm closing it without merging because it conflicts with the current main in several places (main has moved a lot since it was opened, with about 100 pull requests merged today), and I can't resolve that safely on your behalf. If you'd still like it in, please rebase it on the current main and open a new pull request.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7244504075 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/259#issuecomment-7244504075). Originally posted by [trustno1-coder](https://github.com/trustno1-coder) on 2026-11-28T19:23:08Z. --- Thanks for this. I'm closing it without merging because it conflicts with the current main in several places (main has moved a lot since it was opened, with about 100 pull requests merged today), and I can't resolve that safely on your behalf. If you'd still like it in, please rebase it on the current main and open a new pull request.

Pull request closed

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
trustno1-coder/VIctory-NVIDIA!259
No description provided.