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

Open
vicennpacheco wants to merge 1 commit from upstream-pr/78 into main
vicennpacheco commented 2026-11-24 21:17:38 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by vicennpacheco on 2026-11-24T21:17:38Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:issue:6591600688 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/78). Originally posted by [vicennpacheco](https://github.com/vicennpacheco) on 2026-11-24T21:17:38Z. --- ## 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.*
arminkhaleghirod commented 2026-11-24 22:07:35 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by arminkhaleghirod on 2026-11-24T21:42:36Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7145286372 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/78#issuecomment-7145286372). Originally posted by [arminkhaleghirod](https://github.com/arminkhaleghirod) on 2026-11-24T21:42:36Z. --- 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.
adriaespii commented 2026-11-24 22:07:36 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by adriaespii on 2026-11-24T21:43:58Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7145315326 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/78#issuecomment-7145315326). Originally posted by [adriaespii](https://github.com/adriaespii) on 2026-11-24T21:43:58Z. --- 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.*
GeaorgeAyvazov commented 2026-11-24 22:07:39 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by GeaorgeAyvazov on 2026-11-24T21:58:50Z.


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.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7145642257 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/78#issuecomment-7145642257). Originally posted by [GeaorgeAyvazov](https://github.com/GeaorgeAyvazov) on 2026-11-24T21:58:50Z. --- 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 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/78:upstream-pr/78'
git switch 'upstream-pr/78'

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/78'
git switch 'upstream-pr/78'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/78'
git switch 'upstream-pr/78'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/78'
git switch 'main'
git merge --squash 'upstream-pr/78'
git switch 'main'
git merge --ff-only 'upstream-pr/78'
git switch 'main'
git merge 'upstream-pr/78'
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
fxceless/victory-fork!78
No description provided.