Native wave64 compute shaders declare WaveSize(64) where the host runs 64 lanes #204

Open
TobiasFornell wants to merge 1 commit from upstream-pr/204 into main
TobiasFornell commented 2026-11-25 21:55:21 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by TobiasFornell on 2026-11-25T21:55:21Z.


lower.rs gives a compute shader a wave size only with console lanes or a one-wave LDS shader. The other native-wave64 compute shaders reach the driver without WaveSize, and RDNA drivers (RADV here) run them as wave32. With this change they declare WaveSize(64) when the host runs 64 lanes. VICTORY_FORCE_WAVE64=0 turns it off; the switch is part of the shader cache key. Diagnostics builds count the compute shaders that declare 64 lanes.

Measured on Linux only (CachyOS, RX 9070 XT, RADV through vkd3d-proton, Proton Experimental), on a Belobug-based tree: 495 compute shaders declare 64 lanes, 319 of them through this change, and no pipeline was refused. The GPU time was not measured (the CPU side dominates the frame there), so this is not shown to be faster; it gives the shaders the lane count they were written for. Not run on Windows.

The branch is one commit on current main; it builds, and clippy finds nothing new in the changed lines.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:issue:5499836588 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/204). Originally posted by [TobiasFornell](https://github.com/TobiasFornell) on 2026-11-25T21:55:21Z. --- `lower.rs` gives a compute shader a wave size only with console lanes or a one-wave LDS shader. The other native-wave64 compute shaders reach the driver without `WaveSize`, and RDNA drivers (RADV here) run them as wave32. With this change they declare `WaveSize(64)` when the host runs 64 lanes. `VICTORY_FORCE_WAVE64=0` turns it off; the switch is part of the shader cache key. Diagnostics builds count the compute shaders that declare 64 lanes. Measured on Linux only (CachyOS, RX 9070 XT, RADV through vkd3d-proton, Proton Experimental), on a Belobug-based tree: 495 compute shaders declare 64 lanes, 319 of them through this change, and no pipeline was refused. The GPU time was not measured (the CPU side dominates the frame there), so this is not shown to be faster; it gives the shaders the lane count they were written for. Not run on Windows. The branch is one commit on current `main`; it builds, and clippy finds nothing new in the changed lines.
MamaLeVrai commented 2026-11-26 00:05:25 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by MamaLeVrai on 2026-11-26T00:05:25Z.


Result on Windows and RDNA2, which the description does not cover: an RX 6950 XT, Windows 11 build 26300, Rust 1.98.1. This PR (bb789c5) merged on main 4f62c2a, cargo test --release -p victory-shader --lib, one run each:

  • main: 275 passed, 2 failed: emit::valu_tests::scalar_counted_in_a_divergent_loop_read_after_it and scalar_counted_in_nested_divergent_loops. These are the wave-size failures of #2; they fail on every run here.
  • With this PR: 277 passed, 0 failed.

victory-gpu and victory-hle tests are the same as on main. For the maintainers: this PR and #144 both change crates/victory-shader/src/emit/mod.rs, and the merge has a conflict there. #110 fixes the same two tests here (278 passed) and merges with #144 cleanly. 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.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:comment:7178383141 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/204#issuecomment-7178383141). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-26T00:05:25Z. --- Result on Windows and RDNA2, which the description does not cover: an RX 6950 XT, Windows 11 build 26300, Rust 1.98.1. This PR (`bb789c5`) merged on `main` `4f62c2a`, `cargo test --release -p victory-shader --lib`, one run each: - `main`: 275 passed, **2 failed**: `emit::valu_tests::scalar_counted_in_a_divergent_loop_read_after_it` and `scalar_counted_in_nested_divergent_loops`. These are the wave-size failures of #2; they fail on every run here. - With this PR: **277 passed, 0 failed**. `victory-gpu` and `victory-hle` tests are the same as on `main`. For the maintainers: this PR and #144 both change `crates/victory-shader/src/emit/mod.rs`, and the merge has a conflict there. #110 fixes the same two tests here (278 passed) and merges with #144 cleanly. 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.
adrianmjim commented 2026-11-26 19:49:01 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by adrianmjim on 2026-11-26T19:49:01Z.


Tested on Windows 11 (26300) with an RX 7900 XT (RDNA3, driver 32.0.32029.2010). Head bb789c5, base 4f62c2a. I ran the whole title shaders.rpf through victory translate --validate --list and compared per-program DXIL hashes against 4f62c2a.

Host lanes 32-64 (RDNA):

  • 747 of 2682 compute programs change. No vertex, pixel or mesh program changes.
  • Each of the 747 goes from no wave size to WaveSize(64). In dxc -dumpbin that is the only difference in all 747. Each one is 8 to 28 bytes bigger.
  • Compute programs that declare 64 lanes go from 404 to 1151. The 898 that declare 32 lanes do not change.
  • IR instruction total, refusals and validation are the same as 4f62c2a. Every emitted program validates.
  • With --pipelines, the RX 7900 XT creates all 2682 compute pipelines on both base and PR. Nothing is refused.
  • With VICTORY_FORCE_WAVE64=0, the output is identical to 4f62c2a.

Other host lane ranges:

  • 64-64: the same 747 compute programs change, with the same refusals as 4f62c2a.
  • 32-32: no program changes.

Tests:

  • cargo test -p victory-shader --lib -- --test-threads=1: 277 passed, 0 failed, 6 ignored. 4f62c2a gives the same counts.
  • I applied the emit/mod.rs part (helpers and test) to 4f62c2a without the lower.rs change. programs_reading_no_other_lanes_translate_for_any_wave_size then fails on the Some(64) assertion. With the lower.rs change it passes.

One small thing: the counters in pipeline.rs and the log line in queue.rs are only behind cfg(windows), not the diagnostics feature. So every Windows build counts them, not only diagnostics builds as the description says. The line is also logged only once, at frame 256, so compute shaders translated after that are not in the number.

Not tested: GPU time or an in-game run on Windows. I also did not check which wave size the Windows driver picks for compute shaders without WaveSize.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:comment:7201991220 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/204#issuecomment-7201991220). Originally posted by [adrianmjim](https://github.com/adrianmjim) on 2026-11-26T19:49:01Z. --- Tested on Windows 11 (26300) with an RX 7900 XT (RDNA3, driver 32.0.32029.2010). Head bb789c5, base 4f62c2a. I ran the whole title shaders.rpf through `victory translate --validate --list` and compared per-program DXIL hashes against 4f62c2a. Host lanes 32-64 (RDNA): - 747 of 2682 compute programs change. No vertex, pixel or mesh program changes. - Each of the 747 goes from no wave size to `WaveSize(64)`. In `dxc -dumpbin` that is the only difference in all 747. Each one is 8 to 28 bytes bigger. - Compute programs that declare 64 lanes go from 404 to 1151. The 898 that declare 32 lanes do not change. - IR instruction total, refusals and validation are the same as 4f62c2a. Every emitted program validates. - With `--pipelines`, the RX 7900 XT creates all 2682 compute pipelines on both base and PR. Nothing is refused. - With `VICTORY_FORCE_WAVE64=0`, the output is identical to 4f62c2a. Other host lane ranges: - 64-64: the same 747 compute programs change, with the same refusals as 4f62c2a. - 32-32: no program changes. Tests: - `cargo test -p victory-shader --lib -- --test-threads=1`: 277 passed, 0 failed, 6 ignored. 4f62c2a gives the same counts. - I applied the `emit/mod.rs` part (helpers and test) to 4f62c2a without the `lower.rs` change. `programs_reading_no_other_lanes_translate_for_any_wave_size` then fails on the `Some(64)` assertion. With the `lower.rs` change it passes. One small thing: the counters in `pipeline.rs` and the log line in `queue.rs` are only behind `cfg(windows)`, not the `diagnostics` feature. So every Windows build counts them, not only diagnostics builds as the description says. The line is also logged only once, at frame 256, so compute shaders translated after that are not in the number. Not tested: GPU time or an in-game run on Windows. I also did not check which wave size the Windows driver picks for compute shaders without `WaveSize`.
WellyngtonSantos commented 2026-11-26 19:54:29 +00:00 (Migrated from github.com)

Imported from Belobug/VIctory-Belobug-AMD. Originally posted by WellyngtonSantos on 2026-11-26T19:54:29Z.


A data point from a host that runs 64-lane waves only: RX 580 (Polaris / GCN4), AMD legacy driver 31.0.21925.1001 (waves of 64 to 64), Windows 11, Rust 1.98.1, cross-compiled victory-shader tests, --test-threads=1.

passed failed ignored
base 4f62c2a (main) 266 11 6
this PR bb789c5 266 11 6

The list of failing tests is identical: no regression, and nothing fixed on this card either. For whoever looks at main on such hosts, the 11 are:

  • 9 memory_tests, with create memory PSO: "Parâmetro incorreto." (E_INVALIDARG);
  • image_tests::texel_offsets_and_levels_sample_the_texels_they_name, E_INVALIDARG at the PSO;
  • lane_read_loop_tests::lane_reads_in_a_loop_lanes_leave_at_different_iterations, with Unsupported { what: "a console wave size the host does not run" }.

None of them fail on the default branch rx9070xt (cd8dfc0) on the same card, where the whole suite is 302/0 with #290. So they look already handled there.

<!-- greyfinch-sync:Belobug/VIctory-Belobug-AMD:comment:7202086534 --> Imported from [Belobug/VIctory-Belobug-AMD](https://github.com/Belobug/VIctory-Belobug-AMD/pull/204#issuecomment-7202086534). Originally posted by [WellyngtonSantos](https://github.com/WellyngtonSantos) on 2026-11-26T19:54:29Z. --- A data point from a host that runs **64-lane waves only**: **RX 580 (Polaris / GCN4), AMD legacy driver 31.0.21925.1001** (waves of 64 to 64), Windows 11, Rust 1.98.1, cross-compiled `victory-shader` tests, `--test-threads=1`. | | passed | failed | ignored | |---|---|---|---| | base `4f62c2a` (main) | 266 | 11 | 6 | | this PR `bb789c5` | 266 | 11 | 6 | The list of failing tests is identical: no regression, and nothing fixed on this card either. For whoever looks at main on such hosts, the 11 are: - 9 `memory_tests`, with `create memory PSO: "Parâmetro incorreto."` (E_INVALIDARG); - `image_tests::texel_offsets_and_levels_sample_the_texels_they_name`, E_INVALIDARG at the PSO; - `lane_read_loop_tests::lane_reads_in_a_loop_lanes_leave_at_different_iterations`, with `Unsupported { what: "a console wave size the host does not run" }`. None of them fail on the default branch `rx9070xt` (`cd8dfc0`) on the same card, where the whole suite is 302/0 with #290. So they look already handled there.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/204:upstream-pr/204'
git switch 'upstream-pr/204'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/204'
git switch 'upstream-pr/204'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/204'
git switch 'upstream-pr/204'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/204'
git switch 'main'
git merge --squash 'upstream-pr/204'
git switch 'main'
git merge --ff-only 'upstream-pr/204'
git switch 'main'
git merge 'upstream-pr/204'
git push origin 'main'
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
Belobug/VIctory-Belobug-AMD!204
No description provided.