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

Open
github-bot wants to merge 1 commit from github-bot/gh-259 into main AGit
Owner

@⁠taskywasky on GitHub · 2026-11-27 20:15 UTC · original
taskywasky:wave64-split → main · +1198 −17 · 4 files · 1 commits · open

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.
**@⁠taskywasky** on GitHub · 2026-11-27 20:15 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/259) `taskywasky:wave64-split` → `main` · +1198 −17 · 4 files · 1 commits · open ## 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.
A console wave64 compute program that every existing form (local waves,
widen, threading, split_lds/lds_meetings) still leaves needing 64-lane
waves on a 32-lane host gets one more try (emit::split_waves); nothing it
does reaches a program those forms translate. VICTORY_WAVE_SPLIT=0 turns
it off.

Ported from NVIctory c41faed..61db46f (emit/split.rs): the optimistic
convergence fixpoint over half-local scalars, and the proofs that the LDS
accesses of a lane-branch region need no fence between them
(independent_lds, singleton_lds, thread_zero; one-wave groups only, as
NVIctory). Lowering stays the fork's: its exchange between the halves and
its meetings around the region (lds_meetings, now also for regions that
read and write). Where a region is refused, NVIctory's retry: 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), up to 24 rounds.

Under the fallback, as NVIctory does outside convergent code: ballots,
SCC-of-mask, wave reductions, readlane and readfirstlane take this half's
lanes only. Fork adaptations: a first-lane read exchanged in an all-lane
block is not half-local; when stuck, 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); no fallback without
room for the exchange in 32 KiB.

GTA VI 1.0.2.1 shaders.rpf, VICTORY_HOST_WAVE=32, --validate --pipelines
on an RTX 3060: compute 2655 -> 2675 emitted of 2682, all 2675 validate
and make pipelines; no program that emitted before changed its DXIL. New:
the 14 GpuParticleEmit / vfx_proj_decal_trail targets, both
UpdateProjDecalTrailAttachment variants, and the two hair shadow-mask and
two water TransmissionVolumetrics programs NVIctory refuses (untested in
game). triangleClip CollectTriangles stays refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 20:16:09 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/259/head:github-bot/gh-259'
git switch 'github-bot/gh-259'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-259'
git switch 'github-bot/gh-259'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-259'
git switch 'github-bot/gh-259'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-259'
git switch 'main'
git merge --squash 'github-bot/gh-259'
git switch 'main'
git merge --ff-only 'github-bot/gh-259'
git switch 'main'
git merge 'github-bot/gh-259'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.