Shaders: keep 64-lane waves for wave64 programs on a 64-lane host #92

Closed
github-bot wants to merge 1 commit from gh-pr/92/head into gh-pr/92/base
Owner

@⁠dutch2005 on GitHub · 2026-11-25 13:49 UTC · original
fix/shader-wave64-attribute → main · +33 −1 · 1 files · 1 commits · closed without merging

Why

A wave64 compute program on a host that can run 64-lane waves was only given a WaveSize attribute when it also needed console lanes or one-wave LDS. Otherwise the AMD driver may choose 32-lane waves, and a scalar counted in a divergent loop then differs between the halves.

Reproduced on an RX 6700 XT (RDNA2, Windows 11): cargo test -p victory-shader --lib fails

  • emit::valu_tests::scalar_counted_in_a_divergent_loop_read_after_it (lanes 0-31 count 32, lanes 32-63 count 64)
  • emit::valu_tests::scalar_counted_in_nested_divergent_loops (same split)

This is the same finding as the comment on issue #2 from the RX 6950 XT machine.

What

When native.wave64 && target.runs(64), set s.wave_size = Some(64) even if the program does not need console lanes. The console's wave is then requested from the driver instead of leaving it to pick 32.

Testing

  • cargo test -p victory-shader scalar_counted_in_ -- --test-threads=1 on the RX 6700 XT — 2 passed, 0 failed (both were failing before).
  • Full cargo test -p victory-shader --lib -- --test-threads=1 on the RX 6700 XT — 269 passed, 0 failed, 6 ignored with the other shader PRs applied.
  • Independent confirmation on the RX 6950 XT where the finding came from (MamaLeVrai): 266 passed, 0 failed with this PR (2 of 3 runs; that machine's shader test binary intermittently dies without a result line).
  • Brooklyn5points tested the revised head 7a592eb on the integrated Radeon of a Ryzen 9 9900X: 271 enabled shader tests passed with #68 and #92 together, and the new CPU test passed. On WARP the fix alone fails pipeline creation with "The parameter is incorrect"; with #68 both pipelines are created but the counts are still wrong (their fixtures differ on Target::ANY vs host.target()). Hardware behaviour is the target of this PR; WARP remains a known caveat.
  • Mutation coverage: the condition is now a small wants_wave_size helper with a table test; cargo-mutants --in-diff generated 9 mutants, 9 caught. Before the extraction the tool generated no mutants inside Lower::new.

Risk

This is broader than the two tests: every wave64 program on a 64-lane-capable host now asks for 64-lane waves. That is the console's wave size, but it may change compile times and which AMD-compiler pipelines crash. It does not affect 32-lane-only hosts (the runs(64) guard). A title run on the RX 9070 XT is still needed before relying on it.

**@⁠dutch2005** on GitHub · 2026-11-25 13:49 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/92) `fix/shader-wave64-attribute` → `main` · +33 −1 · 1 files · 1 commits · closed without merging ## Why A wave64 compute program on a host that can run 64-lane waves was only given a `WaveSize` attribute when it also needed console lanes or one-wave LDS. Otherwise the AMD driver may choose 32-lane waves, and a scalar counted in a divergent loop then differs between the halves. Reproduced on an RX 6700 XT (RDNA2, Windows 11): `cargo test -p victory-shader --lib` fails - `emit::valu_tests::scalar_counted_in_a_divergent_loop_read_after_it` (lanes 0-31 count 32, lanes 32-63 count 64) - `emit::valu_tests::scalar_counted_in_nested_divergent_loops` (same split) This is the same finding as the comment on issue #2 from the RX 6950 XT machine. ## What When `native.wave64 && target.runs(64)`, set `s.wave_size = Some(64)` even if the program does not need console lanes. The console's wave is then requested from the driver instead of leaving it to pick 32. ## Testing - `cargo test -p victory-shader scalar_counted_in_ -- --test-threads=1` on the RX 6700 XT — 2 passed, 0 failed (both were failing before). - Full `cargo test -p victory-shader --lib -- --test-threads=1` on the RX 6700 XT — **269 passed, 0 failed, 6 ignored** with the other shader PRs applied. - Independent confirmation on the RX 6950 XT where the finding came from (MamaLeVrai): 266 passed, 0 failed with this PR (2 of 3 runs; that machine's shader test binary intermittently dies without a result line). - Brooklyn5points tested the revised head `7a592eb` on the integrated Radeon of a Ryzen 9 9900X: 271 enabled shader tests passed with #68 and #92 together, and the new CPU test passed. On WARP the fix alone fails pipeline creation with "The parameter is incorrect"; with #68 both pipelines are created but the counts are still wrong (their fixtures differ on `Target::ANY` vs `host.target()`). Hardware behaviour is the target of this PR; WARP remains a known caveat. - Mutation coverage: the condition is now a small `wants_wave_size` helper with a table test; `cargo-mutants --in-diff` generated **9 mutants, 9 caught**. Before the extraction the tool generated no mutants inside `Lower::new`. ## Risk This is broader than the two tests: every wave64 program on a 64-lane-capable host now asks for 64-lane waves. That is the console's wave size, but it may change compile times and which AMD-compiler pipelines crash. It does not affect 32-lane-only hosts (the `runs(64)` guard). A title run on the RX 9070 XT is still needed before relying on it.
A wave64 compute program only asked for a WaveSize when it needed console lanes or one-wave LDS; otherwise the AMD driver could pick 32-lane waves and a scalar counted in a divergent loop differed between the halves. Ask for the console's 64 lanes whenever the host runs them, through a small wants_wave_size helper with a table test.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:35:32 +00:00
github-bot closed this pull request 2026-11-26 03:35:32 +00:00
Author
Owner

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

Tested on the machine the finding came from (RX 6950 XT, Windows 11 build 26300, Rust 1.98.1): this PR merged on main 71652a2 (head b3da5ef, no conflict), cargo test --release -p victory-shader --lib.

main 71652a2 with this PR
runs that gave a result 2 of 3: 264 passed, 2 failed (scalar_counted_in_a_divergent_loop_read_after_it, scalar_counted_in_nested_divergent_loops) 2 of 3: 266 passed, 0 failed

One run of each of the three gave no result line (on main the second, with this PR the third): the test binary of victory-shader dies now and then on this machine (run directly on the tree of #68 it exited with 139 in 3 of 6 runs), and I have not looked into why. So these are 2 + 2 results, not 3 + 3. 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/92#issuecomment-7164637067) Tested on the machine the finding came from (RX 6950 XT, Windows 11 build 26300, Rust 1.98.1): this PR merged on `main` `71652a2` (head `b3da5ef`, no conflict), `cargo test --release -p victory-shader --lib`. | | `main` `71652a2` | with this PR | |---|---|---| | runs that gave a result | 2 of 3: 264 passed, **2 failed** (`scalar_counted_in_a_divergent_loop_read_after_it`, `scalar_counted_in_nested_divergent_loops`) | 2 of 3: **266 passed, 0 failed** | One run of each of the three gave no result line (on `main` the second, with this PR the third): the test binary of `victory-shader` dies now and then on this machine (run directly on the tree of #68 it exited with 139 in 3 of 6 runs), and I have not looked into why. So these are 2 + 2 results, not 3 + 3. 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

@⁠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 7a592eb: cargo test -p victory-shader --lib --locked: 267 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/92#issuecomment-7168230819) 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 `7a592eb`: `cargo test -p victory-shader --lib --locked`: **267 passed, 0 failed, 6 ignored**, hardware dispatch tests included (`main` at `01aadd1`: 266 passed). Workspace tests only; not run in the title.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.