Shaders: do not require a fixed WaveSize for 1-thread LDS compute shaders #78

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

@⁠vicennpacheco on GitHub · 2026-11-24 21:17 UTC · original
vicennpacheco:fix/single-thread-lds-wave-size → main · +50 −6 · 2 files · 1 commits · open

Problem

In crates/victory-shader/src/emit/lower.rs, one_wave was computed as group <= wave, so a 1-thread compute shader ([1, 1, 1]) that allocates LDS still emitted WaveSize(32) even when console_lanes is false.

A single-thread group has no other threads sharing LDS without barriers, so requiring a fixed WaveSize(32) is unnecessary and causes CreateComputePipelineState to fail with E_INVALIDARG on:

  • 64-lane-only AMD GCN GPUs (e.g., AMD Radeon Vega 8 iGPU, GCN 5 / gfx90c, where WaveLaneCountMin = WaveLaneCountMax = 64), making emit::valu_tests::ds_min_max_f32_order_floats_and_return_the_old_value fail on hardware.
  • WARP (for which the test previously had to skip WARP via run_cases_on(..., &[("hardware", false)])).

Fix

  • crates/victory-shader/src/emit/lower.rs: change one_wave to group > 1 && group <= wave. Multi-thread single-wave LDS shaders (2..=wave) and any shader with console_lanes == true keep the exact same WaveSize metadata as before.
  • crates/victory-shader/src/emit/lower.rs: add unit test emit::lower::tests::single_thread_lds_omits_wave_size verifying wave_size == None for threads = [1, 1, 1] and wave_size == Some(32) for threads = [2, 1, 1].
  • crates/victory-shader/src/emit/valu_tests.rs: run ds_min_max_f32_order_floats_and_return_the_old_value via run_cases on both hardware and WARP now that neither rejects it.

Tested

Setup: Windows 11, Ryzen 7 5825U, AMD Radeon Vega 8 iGPU (GCN 5 / gfx90c, PCI 1002:15E7, AMD Windows driver 31.0.21921.13001), Rust 1.98.1 (x86_64-pc-windows-msvc), MSVC 19.44.35230.0, Windows SDK 10.0.26100.0. No game files.

  • Before (main 4e17478): ds_min_max_f32_order_floats_and_return_the_old_value failed on hardware (compute_pipeline failed: E_INVALIDARG) and did not run on WARP.
  • After:
    • cargo test -p victory-shader --lib -- ds_min_max_f32: 2/2 passed (both hardware Vega 8 and WARP).
    • cargo test -p victory-shader --lib -- single_thread_lds_omits_wave_size: 1/1 passed.
    • cargo clippy -p victory-shader --tests -- -D warnings: clean (0 warnings).
    • cargo test --workspace --no-fail-fast -j 2: 496 passed, 1 failed, 7 ignored (+2 passed vs baseline 494/2: the fixed ds_min_max_f32 test and the new unit test; the 1 remaining failure is the unrelated pre-existing GCN 5 waterfall_tests::lanes_load_from_the_buffer_their_nested_arms_chose hardware mismatch).

AI-assisted.

**@⁠vicennpacheco** on GitHub · 2026-11-24 21:17 UTC · [original](https://github.com/fxceless/victory-fork/pull/78) `vicennpacheco:fix/single-thread-lds-wave-size` → `main` · +50 −6 · 2 files · 1 commits · open ## Problem In `crates/victory-shader/src/emit/lower.rs`, `one_wave` was computed as `group <= wave`, so a 1-thread compute shader (`[1, 1, 1]`) that allocates LDS still emitted `WaveSize(32)` even when `console_lanes` is false. A single-thread group has no other threads sharing LDS without barriers, so requiring a fixed `WaveSize(32)` is unnecessary and causes `CreateComputePipelineState` to fail with `E_INVALIDARG` on: - **64-lane-only AMD GCN GPUs** (e.g., AMD Radeon Vega 8 iGPU, GCN 5 / `gfx90c`, where `WaveLaneCountMin = WaveLaneCountMax = 64`), making `emit::valu_tests::ds_min_max_f32_order_floats_and_return_the_old_value` fail on hardware. - **WARP** (for which the test previously had to skip WARP via `run_cases_on(..., &[("hardware", false)])`). ## Fix - `crates/victory-shader/src/emit/lower.rs`: change `one_wave` to `group > 1 && group <= wave`. Multi-thread single-wave LDS shaders (`2..=wave`) and any shader with `console_lanes == true` keep the exact same `WaveSize` metadata as before. - `crates/victory-shader/src/emit/lower.rs`: add unit test `emit::lower::tests::single_thread_lds_omits_wave_size` verifying `wave_size == None` for `threads = [1, 1, 1]` and `wave_size == Some(32)` for `threads = [2, 1, 1]`. - `crates/victory-shader/src/emit/valu_tests.rs`: run `ds_min_max_f32_order_floats_and_return_the_old_value` via `run_cases` on both hardware and WARP now that neither rejects it. ## Tested **Setup:** Windows 11, Ryzen 7 5825U, AMD Radeon Vega 8 iGPU (GCN 5 / `gfx90c`, PCI `1002:15E7`, AMD Windows driver `31.0.21921.13001`), Rust `1.98.1` (`x86_64-pc-windows-msvc`), MSVC `19.44.35230.0`, Windows SDK `10.0.26100.0`. No game files. - Before (`main` `4e17478`): `ds_min_max_f32_order_floats_and_return_the_old_value` failed on hardware (`compute_pipeline failed: E_INVALIDARG`) and did not run on WARP. - After: - `cargo test -p victory-shader --lib -- ds_min_max_f32`: **2/2 passed** (both hardware Vega 8 and WARP). - `cargo test -p victory-shader --lib -- single_thread_lds_omits_wave_size`: **1/1 passed**. - `cargo clippy -p victory-shader --tests -- -D warnings`: clean (0 warnings). - `cargo test --workspace --no-fail-fast -j 2`: **496 passed, 1 failed, 7 ignored** (+2 passed vs baseline 494/2: the fixed `ds_min_max_f32` test and the new unit test; the 1 remaining failure is the unrelated pre-existing GCN 5 `waterfall_tests::lanes_load_from_the_buffer_their_nested_arms_chose` hardware mismatch). *AI-assisted.*
A 1-thread compute group has no peers sharing LDS without barriers, so
declaring WaveSize(32) for `group == 1` is unnecessary and causes
CreateComputePipelineState to fail with E_INVALIDARG on 64-lane-only AMD GCN
GPUs (e.g. Vega 8 / gfx90c) and on WARP.

Restrict `one_wave` in `crates/victory-shader/src/emit/lower.rs` to
`group > 1 && group <= wave`, add a unit test pinning `threads = [1, 1, 1]`
vs `[2, 1, 1]`, and run `ds_min_max_f32_order_floats_and_return_the_old_value`
on both hardware and WARP.

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:35:46 +00:00
Author
Owner

@⁠arminkhaleghirod on GitHub · 2026-11-24 21:42 UTC · original

Merged onto main 90228a7 and ran victory translate --validate over the full title (26,148 programs) on Windows 11 / RTX 4080. Changes against main, by failure reason:

No change: every failure count is the same as main, and no new reason appears. So no regression in translation. What this PR changes at run time isn't covered by this check.

**@⁠arminkhaleghirod** on GitHub · 2026-11-24 21:42 UTC · [original](https://github.com/fxceless/victory-fork/pull/78#issuecomment-7145286372) Merged onto main 90228a7 and ran `victory translate --validate` over the full title (26,148 programs) on Windows 11 / RTX 4080. Changes against main, by failure reason: No change: every failure count is the same as main, and no new reason appears. So no regression in translation. What this PR changes at run time isn't covered by this check.
Author
Owner

@⁠adriaespii on GitHub · 2026-11-24 21:43 UTC · original

Independent test run on commit 39350ca (AMD RDNA4):

  • Hardware: AMD Radeon RX 9070 (driver 32.0.32015.7029), AMD Ryzen 5 7600, Windows 11 Pro, Rust 1.98.1 (x86_64-pc-windows-msvc)
  • cargo clippy --workspace --all-targets -- -D warnings: 0 warnings
  • cargo test --workspace: 497 passed, 0 failed, 7 ignored (victory-shader: 211 passed, 0 failed, 2 ignored; victory-gpu: 110 passed, 0 failed, 1 ignored)
  • Not tested: live game run (no game files on this machine)

AI use: Antigravity (Gemini 4 Neon) ran clippy/tests locally and wrote this report.

**@⁠adriaespii** on GitHub · 2026-11-24 21:43 UTC · [original](https://github.com/fxceless/victory-fork/pull/78#issuecomment-7145315326) Independent test run on commit `39350ca` (AMD RDNA4): - **Hardware:** AMD Radeon RX 9070 (driver 32.0.32015.7029), AMD Ryzen 5 7600, Windows 11 Pro, Rust 1.98.1 (`x86_64-pc-windows-msvc`) - `cargo clippy --workspace --all-targets -- -D warnings`: 0 warnings - `cargo test --workspace`: 497 passed, 0 failed, 7 ignored (`victory-shader`: 211 passed, 0 failed, 2 ignored; `victory-gpu`: 110 passed, 0 failed, 1 ignored) - **Not tested:** live game run (no game files on this machine) *AI use: Antigravity (Gemini 4 Neon) ran clippy/tests locally and wrote this report.*
Author
Owner

@⁠GeaorgeAyvazov on GitHub · 2026-11-24 21:58 UTC · original

Hardware compatibility check for the proposed change on Intel Iris Xe (30.0.101.1029) and RTX 3070 Ti Laptop (32.0.15.9186). I compiled a standalone cs_6_6 one-thread shader using DXC, with and without [WaveSize(32)]. The shader initialized a groupshared uint from UAV input 3, synchronized, executed InterlockedMax with UAV input 5, then wrote both the old and final value to the UAV. All four dispatches succeeded and returned (3,5). This checks the hardware behavior relevant to dropping the attribute on these two drivers. It is a standalone DXIL probe; the PR-specific emitter tests were not run here. Tested with Codex assistance.

**@⁠GeaorgeAyvazov** on GitHub · 2026-11-24 21:58 UTC · [original](https://github.com/fxceless/victory-fork/pull/78#issuecomment-7145642257) Hardware compatibility check for the proposed change on Intel Iris Xe (30.0.101.1029) and RTX 3070 Ti Laptop (32.0.15.9186). I compiled a standalone cs_6_6 one-thread shader using DXC, with and without [WaveSize(32)]. The shader initialized a groupshared uint from UAV input 3, synchronized, executed InterlockedMax with UAV input 5, then wrote both the old and final value to the UAV. All four dispatches succeeded and returned (3,5). This checks the hardware behavior relevant to dropping the attribute on these two drivers. It is a standalone DXIL probe; the PR-specific emitter tests were not run here. Tested with Codex assistance.
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/78/head:github-bot/gh-78'
git switch 'github-bot/gh-78'

Merge

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