Wave64 on 32-lane hosts: one console wave sharing LDS runs in the console flow (+2 NVIDIA fixes) #68

Open
github-bot wants to merge 2 commits from github-bot/gh-68 into main AGit
Owner

@⁠God489 on GitHub · 2026-11-25 13:17 UTC · original
God489:wave64/one-wave-lds → main · +324 −59 · 5 files · 2 commits · open

On 32-lane hosts (every NVIDIA card) the title's loading never finishes (#9) or the world stays black (#15), and both reports give the same reason. About 90 compute programs stop at translation:

  • 29–30 with a wave64 group sharing LDS without barriers on a host without 64-lane waves;
  • 59–61 with console wave64 lanes on a host without 64-lane waves.

docs/wave64-on-wave32.md lists "one-wave LDS sharing" as the open half of step 6. This PR does that half, and fixes a wrong result the console flow had on the same hosts.

What

1. A console wave sharing LDS runs in the console flow (Lower::lds_meet)

The console runs a wave's lanes in step, so its compiler leaves out barriers inside one wave. Split into two 32-lane halves, those LDS accesses need an order. The halves now meet at a group barrier between any two LDS accesses of which one writes:

  • In the console flow every thread of the group runs every block, so the barrier is uniform. It is placed before the instruction's EXEC guard.
  • Reads after a barrier share it, and a program's own s_barrier counts as a meeting.
  • The exchange slots of Lower::exchange stay a separate group-shared variable.

Eligibility is console_flow_ok: wave64 compute, a host without 64-lane waves, at most 64 threads, no ds_(b)permute, no whole-wave sections. Two kinds of program meet it now that were refused before:

  • a group of one console wave with LDS (it used to declare WaveSize(64) and stop);
  • console-lane programs with LDS (the console flow used to require lds_dwords == 0).

2. Scalars after a divergent loop were per half on 32-lane hosts (bug)

leave_loops takes a loop's scalars from the lane that ran it longest, using a wave maximum. Over a host wave of 32 that covers half the console wave: in scalar_counted_in_a_divergent_loop_read_after_it, lanes 0–31 read 32 where the console reads 64. Such programs (loop_exits with values read after the loop) now go to the console flow where console_flow_ok holds. Where the console flow cannot lower them, they keep the per-lane form as before.

3. A capped view heap keeps the title's own slot count (bug, NVIDIA)

The doubled DYNAMIC (1 << 20) does not fit next to any title heap under NVIDIA's 1,000,000-view cap, so every view heap there takes the capped branch. That branch forced PORTABLE_VIEWS - DYNAMIC_CAPPED - memory::SLOTS title slots whatever the title asked for: a 4-slot heap got 933,440 title slots and its dynamic slots started past them. Now:

  • the title keeps min(wanted, that) slots and the dynamic slots take the rest;
  • the warning's lost no longer underflows for small heaps;
  • for the title's 1,245,184-slot heap nothing changes (933,440 + 65,536 as before).

dynamic_slots_are_held_until_released failed on every NVIDIA machine because of this.

Nothing changes on hosts with 64-lane waves, by construction: (1) and (2) require !target.runs(64), and (3) is only the capped branch.

Tests

On an NVIDIA GeForce RTX 3050 (32-32 lanes, driver 610.88), Windows 11 Pro build 26200, debug build:

  • 5 new tests in split_tests, run on each hardware adapter and checked lane by lane against the console:

    • LDS read across halves without a barrier (64 and 48 threads);
    • read-before-write across halves;
    • LDS writes inside a branch only the lower half takes (64 and 48 threads);
    • v_readlane together with LDS;
    • the RDNA/NVIDIA wave sizes these programs declare (64 / 32). Two console waves per group are still refused.

    On main all 5 fail with exactly the two reasons from #9 and #15. With this PR they pass, exact.

  • valu_tests: the four "counted" tests built their shader for Target::ANY without the console-flow retry, so on a 32-lane card the pipeline was refused or the halves disagreed. They are now built for the host's own target through emit, as the title's programs are. Two of them then pass; the two scalar-loop ones also needed fix 2.

  • Full suite, cargo test --workspace --locked --no-fail-fast, this machine:

passed failed
main 71652a2 549 11
this PR 559 6
  • Fixed: dynamic_slots_are_held_until_released, loop_exit_mask_counted_after_the_loop, mask_grown_inside_a_branch_counted_after_it, scalar_counted_in_a_divergent_loop_read_after_it, scalar_counted_in_nested_divergent_loops.
  • New failures: none.
  • Still failing, as on main: five xmem tests on Windows 26200 (as in #8), and repository_passes_policy (lower.rs is 630 KB on main, over xtask's 512 KiB limit).
  • Clippy: it already fails on main (10 findings in victory-shader, more in victory-gpu). This PR adds none on the lines it changes, checked with both clippy passes and -p victory-gpu on its own.

Not tested

  • The game. I don't know how many of the ~90 programs translate now. With an NVIDIA card, victory translate --host-lanes 32-32 on the title's shaders would count them, and I'd be glad to see that number.
  • An AMD card: these paths are off there by the conditions above.

AI use: Claude Code (Claude Opus 5.5) wrote the change and the tests, ran them on my machine and wrote this description.

🤖 Generated with Claude Code

**@⁠God489** on GitHub · 2026-11-25 13:17 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/68) `God489:wave64/one-wave-lds` → `main` · +324 −59 · 5 files · 2 commits · open On 32-lane hosts (every NVIDIA card) the title's loading never finishes (#9) or the world stays black (#15), and both reports give the same reason. About 90 compute programs stop at translation: - **29–30** with `a wave64 group sharing LDS without barriers on a host without 64-lane waves`; - **59–61** with `console wave64 lanes on a host without 64-lane waves`. `docs/wave64-on-wave32.md` lists "one-wave LDS sharing" as the open half of step 6. This PR does that half, and fixes a wrong result the console flow had on the same hosts. ## What **1. A console wave sharing LDS runs in the console flow** (`Lower::lds_meet`) The console runs a wave's lanes in step, so its compiler leaves out barriers inside one wave. Split into two 32-lane halves, those LDS accesses need an order. The halves now meet at a group barrier between any two LDS accesses of which one writes: - In the console flow every thread of the group runs every block, so the barrier is uniform. It is placed before the instruction's EXEC guard. - Reads after a barrier share it, and a program's own `s_barrier` counts as a meeting. - The exchange slots of `Lower::exchange` stay a separate group-shared variable. Eligibility is `console_flow_ok`: wave64 compute, a host without 64-lane waves, at most 64 threads, no `ds_(b)permute`, no whole-wave sections. Two kinds of program meet it now that were refused before: - a group of one console wave with LDS (it used to declare `WaveSize(64)` and stop); - console-lane programs with LDS (the console flow used to require `lds_dwords == 0`). **2. Scalars after a divergent loop were per half on 32-lane hosts (bug)** `leave_loops` takes a loop's scalars from the lane that ran it longest, using a wave maximum. Over a host wave of 32 that covers half the console wave: in `scalar_counted_in_a_divergent_loop_read_after_it`, lanes 0–31 read 32 where the console reads 64. Such programs (`loop_exits` with values read after the loop) now go to the console flow where `console_flow_ok` holds. Where the console flow cannot lower them, they keep the per-lane form as before. **3. A capped view heap keeps the title's own slot count (bug, NVIDIA)** The doubled `DYNAMIC` (1 << 20) does not fit next to any title heap under NVIDIA's 1,000,000-view cap, so every view heap there takes the capped branch. That branch forced `PORTABLE_VIEWS - DYNAMIC_CAPPED - memory::SLOTS` title slots whatever the title asked for: a 4-slot heap got 933,440 title slots and its dynamic slots started past them. Now: - the title keeps `min(wanted, that)` slots and the dynamic slots take the rest; - the warning's `lost` no longer underflows for small heaps; - for the title's 1,245,184-slot heap nothing changes (933,440 + 65,536 as before). `dynamic_slots_are_held_until_released` failed on every NVIDIA machine because of this. Nothing changes on hosts with 64-lane waves, by construction: (1) and (2) require `!target.runs(64)`, and (3) is only the capped branch. ## Tests On an NVIDIA GeForce RTX 3050 (32-32 lanes, driver 610.88), Windows 11 Pro build 26200, debug build: - **5 new tests** in `split_tests`, run on each hardware adapter and checked lane by lane against the console: - LDS read across halves without a barrier (64 and 48 threads); - read-before-write across halves; - LDS writes inside a branch only the lower half takes (64 and 48 threads); - `v_readlane` together with LDS; - the RDNA/NVIDIA wave sizes these programs declare (64 / 32). Two console waves per group are still refused. On `main` all 5 fail with exactly the two reasons from #9 and #15. With this PR they pass, exact. - **`valu_tests`**: the four "counted" tests built their shader for `Target::ANY` without the console-flow retry, so on a 32-lane card the pipeline was refused or the halves disagreed. They are now built for the host's own target through `emit`, as the title's programs are. Two of them then pass; the two scalar-loop ones also needed fix 2. - **Full suite**, `cargo test --workspace --locked --no-fail-fast`, this machine: | | passed | failed | |---|---:|---:| | `main` 71652a2 | 549 | 11 | | this PR | 559 | 6 | - Fixed: `dynamic_slots_are_held_until_released`, `loop_exit_mask_counted_after_the_loop`, `mask_grown_inside_a_branch_counted_after_it`, `scalar_counted_in_a_divergent_loop_read_after_it`, `scalar_counted_in_nested_divergent_loops`. - New failures: none. - Still failing, as on `main`: five `xmem` tests on Windows 26200 (as in #8), and `repository_passes_policy` (`lower.rs` is 630 KB on `main`, over xtask's 512 KiB limit). - **Clippy**: it already fails on `main` (10 findings in `victory-shader`, more in `victory-gpu`). This PR adds none on the lines it changes, checked with both clippy passes and `-p victory-gpu` on its own. ## Not tested - The game. I don't know how many of the ~90 programs translate now. With an NVIDIA card, `victory translate --host-lanes 32-32` on the title's shaders would count them, and I'd be glad to see that number. - An AMD card: these paths are off there by the conditions above. AI use: Claude Code (Claude Opus 5.5) wrote the change and the tests, ran them on my machine and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A group of one console wave that shares LDS (its compiler leaves out the
barriers inside one wave) stopped at translation on a host without
64-lane waves, as did console-lane programs with LDS. In the console flow
every thread runs every block, so the two 32-lane halves now meet at a
group barrier between any two LDS accesses of which one writes
(Lower::lds_meet): the order of a wave run in step.

After a divergent loop the per-lane form takes the console wave's scalars
from the lane that ran longest with a wave maximum, which on 32-lane hosts
covers half the console wave (lanes 0-31 read 32 where the console reads
64). Such programs now go to the console flow where it can run them.

Hosts with 64-lane waves are unchanged: both need !target.runs(64).
The four valu_tests counting after loops and branches are built for the
host's own target through emit, as the title's programs are.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On a host capping view heaps at 1,000,000 (NVIDIA) every view heap takes
the capped branch, since DYNAMIC alone is 1 << 20. That branch forced
933,440 title slots whatever the title asked for, so a small heap's
dynamic slots started past them (dynamic_slots_are_held_until_released
failed on every NVIDIA machine), and the warning's `lost` underflowed.
The title now keeps min(wanted, the cap's share) and the dynamic slots
take the rest; the title's 1,245,184-slot heap is made as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:34:56 +00:00
Author
Owner

@⁠MamaLeVrai on GitHub · 2026-11-25 14:01 UTC · original

Tested on an RX 6950 XT (RDNA2, a host that runs 64-lane waves), Windows 11 build 26300, Rust 1.98.1: this PR merged on main 71652a2 (head 0e9b505, no conflict), cargo test --release -p victory-shader --lib.

  • Result: 269 passed, 2 failed (main: 264 passed, 2 failed; so 5 more tests, all passing). The 2 failures are the same two as on main, valu_tests::scalar_counted_in_a_divergent_loop_read_after_it and scalar_counted_in_nested_divergent_loops (what #92 fixes). This PR is about 32-lane hosts and does not change them here.
  • 1 run of 3 gave a result; the other two ended without a result line (the test binary dies now and then on this machine; the same happened in 1 run of 3 on main). Run directly on this tree, 3 of 6 runs gave the same 269 passed, 2 failed, and 3 exited with 139.

I cannot say anything about the 32-lane case the PR is for: no 32-lane-only host here. Not run in the game.

harness machine: rx6950xt-w11 | AMD Radeon RX 6950 XT (RDNA2), driver 32.0.21045.29003 | 32 GB RAM | Windows 11 build 26300

AI-assisted (Claude Code); no game data.

**@⁠MamaLeVrai** on GitHub · 2026-11-25 14:01 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/68#issuecomment-7164642381) Tested on an RX 6950 XT (RDNA2, a host that runs 64-lane waves), Windows 11 build 26300, Rust 1.98.1: this PR merged on `main` `71652a2` (head `0e9b505`, no conflict), `cargo test --release -p victory-shader --lib`. - Result: **269 passed, 2 failed** (`main`: 264 passed, 2 failed; so 5 more tests, all passing). The 2 failures are the same two as on `main`, `valu_tests::scalar_counted_in_a_divergent_loop_read_after_it` and `scalar_counted_in_nested_divergent_loops` (what #92 fixes). This PR is about 32-lane hosts and does not change them here. - 1 run of 3 gave a result; the other two ended without a result line (the test binary dies now and then on this machine; the same happened in 1 run of 3 on `main`). Run directly on this tree, 3 of 6 runs gave the same 269 passed, 2 failed, and 3 exited with 139. I cannot say anything about the 32-lane case the PR is for: no 32-lane-only host here. Not run in the game. harness machine: rx6950xt-w11 | AMD Radeon RX 6950 XT (RDNA2), driver 32.0.21045.29003 | 32 GB RAM | Windows 11 build 26300 AI-assisted (Claude Code); no game data.
Author
Owner

@⁠Yoshi-233 on GitHub · 2026-11-25 14:23 UTC · original

Tested PR head 0e9b505 independently on an RTX 4070 Ti SUPER, Windows 11, driver 32.0.16.1742. In a fixed set of 285 compute shaders rejected by our previous local build targeting 32 lanes, PR #68 emitted and DXIL-validated 147. Our separate local implementation validated 146, all within those 147. The four existing divergent-loop and mask tests also passed on this GPU with PR #68. This was an offline corpus and GPU readback comparison. The in-game measurements in my local report were taken on a separate build.

**@⁠Yoshi-233** on GitHub · 2026-11-25 14:23 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/68#issuecomment-7165194912) Tested PR head `0e9b505` independently on an RTX 4070 Ti SUPER, Windows 11, driver 32.0.16.1742. In a fixed set of 285 compute shaders rejected by our previous local build targeting 32 lanes, PR #68 emitted and DXIL-validated 147. Our separate local implementation validated 146, all within those 147. The four existing divergent-loop and mask tests also passed on this GPU with PR #68. This was an offline corpus and GPU readback comparison. The in-game measurements in my local report were taken on a separate build.
Author
Owner

@⁠ySKELLETONX on GitHub · 2026-11-25 16:35 UTC · original

Tested on an RX 7600 XT 16 GB (RDNA3, Navi 33), driver 32.0.32015.2008, Windows 11 Pro build 26300, Rust 1.98.1, at 0e9b505: cargo test -p victory-shader --lib --locked: 271 passed, 0 failed, 6 ignored, hardware dispatch tests included (main at 01aadd1: 266 passed). Workspace tests only; not run in the title.

**@⁠ySKELLETONX** on GitHub · 2026-11-25 16:35 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/68#issuecomment-7168233520) Tested on an RX 7600 XT 16 GB (RDNA3, Navi 33), driver 32.0.32015.2008, Windows 11 Pro build 26300, Rust 1.98.1, at `0e9b505`: `cargo test -p victory-shader --lib --locked`: **271 passed, 0 failed, 6 ignored**, hardware dispatch tests included (`main` at `01aadd1`: 266 passed). Workspace tests only; not run in the title.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-25 17:41 UTC · original

Offline numbers for the 32-lane case, from the game's shaders.rpf on an RX 7900 XT, with victory translate --validate --list (no NVIDIA card here, so the 32-lane host is set with --host-lanes 32-32; translation and validation only, no pipelines or readback). Head 0e9b505 on 01aadd1:

--host-lanes 32-32 01aadd1 this PR
compute emitted and validated 2,389 of 2,682 2,544 of 2,682
"a wave64 group sharing LDS without barriers ..." 127 0
"console wave64 lanes on a host without 64-lane waves" 166 138

VS/PS (14,247) and mesh (8,694 of 8,765) are unchanged. So 155 more compute programs translate and validate, which agrees with Yoshi-233's 147 of 285 from a different starting set.

On a 64-lane host (--host-lanes 32-64) the PR changes nothing: a hash of every program's DXIL is the same as on 01aadd1 for all 25,623 emitted programs. cargo test -p victory-shader --lib -- --test-threads=1 gave 271 passed, 0 failed here.

**@⁠adrianmjim** on GitHub · 2026-11-25 17:41 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/68#issuecomment-7169869026) Offline numbers for the 32-lane case, from the game's `shaders.rpf` on an RX 7900 XT, with `victory translate --validate --list` (no NVIDIA card here, so the 32-lane host is set with `--host-lanes 32-32`; translation and validation only, no pipelines or readback). Head `0e9b505` on `01aadd1`: | `--host-lanes 32-32` | `01aadd1` | this PR | |---|---|---| | compute emitted and validated | 2,389 of 2,682 | **2,544** of 2,682 | | "a wave64 group sharing LDS without barriers ..." | 127 | 0 | | "console wave64 lanes on a host without 64-lane waves" | 166 | 138 | VS/PS (14,247) and mesh (8,694 of 8,765) are unchanged. So 155 more compute programs translate and validate, which agrees with Yoshi-233's 147 of 285 from a different starting set. On a 64-lane host (`--host-lanes 32-64`) the PR changes nothing: a hash of every program's DXIL is the same as on `01aadd1` for all 25,623 emitted programs. `cargo test -p victory-shader --lib -- --test-threads=1` gave 271 passed, 0 failed here.
Author
Owner

@⁠gut0to on GitHub · 2026-11-25 16:06 UTC · original · reviewed

AI-assisted static review; I did not run tests or launch the game. For one wave64 console group split across 32-lane host waves, lds_meet inserts group barriers between conflicting LDS accesses in console flow. The checked-in regression cases cover cross-half reads, read-before-write ordering, branch writes, and translation without 64-lane waves. The PR reports GPU execution, which I did not run here.

**@⁠gut0to** on GitHub · 2026-11-25 16:06 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/68#pullrequestreview-6060928481) · **reviewed** AI-assisted static review; I did not run tests or launch the game. For one wave64 console group split across 32-lane host waves, lds_meet inserts group barriers between conflicting LDS accesses in console flow. The checked-in regression cases cover cross-half reads, read-before-write ordering, branch writes, and translation without 64-lane waves. The PR reports GPU execution, which I did not run here.
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/68/head:github-bot/gh-68'
git switch 'github-bot/gh-68'

Merge

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