Shaders: omit unnecessary fixed WaveSize for single-wave LDS compute shaders #22

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

@⁠vicennpacheco on GitHub · 2026-11-25 12:27 UTC · original
vicennpacheco:fix/single-thread-lds-wave-size → main · +77 −2 · 2 files · 1 commits · open

Problem

On 64-lane-only AMD GCN GPUs (e.g. Radeon Vega 8 / gfx90c), all 9 hardware tests in victory-shader's emit::memory_tests fail CreateComputePipelineState with E_INVALIDARG (0x80070057).

Root cause

In crates/victory-shader/src/emit/lower.rs, one_wave && s.lds_dwords > 0 emitted [WaveSize(32)] whenever threads <= 32 and rsrc2 reserved LDS — even when:

  1. group == 1 (a single thread never needs wave lockstep),
  2. the shader executes no LDS instructions (Fields::Ds / Fields::Buffer { lds: true }), or
  3. the host's minimum wave width already fits the whole group (target.lanes_min >= group, e.g. <= 32 threads on a 64-lane-only GCN GPU).

Drivers that only support 64-lane waves reject [WaveSize(32)] with E_INVALIDARG.

Fix

  • Restrict one_wave in crates/victory-shader/src/emit/lower.rs to group > 1 && group <= wave && uses_lds && x.target.lanes_min < group.
  • Add unit test emit::memory_tests::one_wave_lds_wave_size_policy covering all four cases (placed in memory_tests.rs so lower.rs does not grow further).

Verification

Tested on Windows 11, AMD Radeon Vega 8 iGPU (Ryzen 7 5825U, GCN 5 / gfx90c, PCI 1002:15E7, AMD driver 31.0.21921.13001), Rust 1.98.1 (x86_64-pc-windows-msvc), without game files:

  • cargo test -p victory-shader --lib -- emit::memory_tests: 10 passed, 0 failed, 1 ignored (was 0 passed, 9 failed)
  • VICTORY_D3D12_DEBUG=1 cargo test -p victory-shader --lib -- emit::memory_tests: 10 passed, 0 failed, no debug-layer errors

(AI-assisted investigation and patch.)

**@⁠vicennpacheco** on GitHub · 2026-11-25 12:27 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/22) `vicennpacheco:fix/single-thread-lds-wave-size` → `main` · +77 −2 · 2 files · 1 commits · open ### Problem On 64-lane-only AMD GCN GPUs (e.g. Radeon Vega 8 / `gfx90c`), all 9 hardware tests in `victory-shader`'s `emit::memory_tests` fail `CreateComputePipelineState` with `E_INVALIDARG` (`0x80070057`). ### Root cause In `crates/victory-shader/src/emit/lower.rs`, `one_wave && s.lds_dwords > 0` emitted `[WaveSize(32)]` whenever `threads <= 32` and `rsrc2` reserved LDS — even when: 1. `group == 1` (a single thread never needs wave lockstep), 2. the shader executes no LDS instructions (`Fields::Ds` / `Fields::Buffer { lds: true }`), or 3. the host's minimum wave width already fits the whole group (`target.lanes_min >= group`, e.g. `<= 32` threads on a 64-lane-only GCN GPU). Drivers that only support 64-lane waves reject `[WaveSize(32)]` with `E_INVALIDARG`. ### Fix - Restrict `one_wave` in `crates/victory-shader/src/emit/lower.rs` to `group > 1 && group <= wave && uses_lds && x.target.lanes_min < group`. - Add unit test `emit::memory_tests::one_wave_lds_wave_size_policy` covering all four cases (placed in `memory_tests.rs` so `lower.rs` does not grow further). ### Verification Tested on Windows 11, AMD Radeon Vega 8 iGPU (Ryzen 7 5825U, GCN 5 / `gfx90c`, PCI `1002:15E7`, AMD driver `31.0.21921.13001`), Rust `1.98.1` (`x86_64-pc-windows-msvc`), without game files: - `cargo test -p victory-shader --lib -- emit::memory_tests`: **10 passed, 0 failed, 1 ignored** (was 0 passed, 9 failed) - `VICTORY_D3D12_DEBUG=1 cargo test -p victory-shader --lib -- emit::memory_tests`: **10 passed, 0 failed**, no debug-layer errors *(AI-assisted investigation and patch.)*
`one_wave && s.lds_dwords > 0` forced `WaveSize(32)` even when a compute
shader has only 1 thread, executes no LDS instructions (`ds_*` /
`buffer_* lds`), or targets a host whose minimum wave width already fits
the entire thread group (`target.lanes_min >= group`, such as 64-lane-only
AMD GCN GPUs).

Only require `WaveSize(wave)` for single-wave LDS lockstep when
`group > 1 && group <= wave && uses_lds && x.target.lanes_min < group`.
This fixes all 9 `emit::memory_tests` PSO creation failures (`E_INVALIDARG`)
on AMD GCN 5 (Vega 8).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:33:16 +00:00
Author
Owner

@⁠Ekabusto on GitHub · 2026-11-25 12:47 UTC · original

Checked locally: cargo test -p victory-shader --lib passes (267 passed, 6 ignored, including the new test). This host supports 32-lane waves, so I could not reproduce the E_INVALIDARG on a 64-lane-only GCN part. No conflicts with main or the other open PRs.

On coverage: uses_lds counts Fields::Ds and Fields::Buffer { lds: true } but not Fields::Flat { lds: true }. That is fine, because Lower::flat (lower.rs:1584) already refuses a global load into LDS, so no translated program can reach LDS that way. Checking lanes_min < group is also the right condition: when the host's smallest wave already holds the whole group, the group runs as one wave without the attribute. Looks good to me.

Reviewed on Windows 11 (build 26300), Rust 1.98.1, each PR in its own worktree; no game data, not run in the game. AI-assisted (Claude Code).

**@⁠Ekabusto** on GitHub · 2026-11-25 12:47 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/pull/22#issuecomment-7162865177) Checked locally: `cargo test -p victory-shader --lib` passes (267 passed, 6 ignored, including the new test). This host supports 32-lane waves, so I could not reproduce the `E_INVALIDARG` on a 64-lane-only GCN part. No conflicts with `main` or the other open PRs. On coverage: `uses_lds` counts `Fields::Ds` and `Fields::Buffer { lds: true }` but not `Fields::Flat { lds: true }`. That is fine, because `Lower::flat` (`lower.rs:1584`) already refuses a global load into LDS, so no translated program can reach LDS that way. Checking `lanes_min < group` is also the right condition: when the host's smallest wave already holds the whole group, the group runs as one wave without the attribute. Looks good to me. Reviewed on Windows 11 (build 26300), Rust 1.98.1, each PR in its own worktree; no game data, not run in the game. AI-assisted (Claude Code).
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 72c7b01: 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/22#issuecomment-7168232868) 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 `72c7b01`: `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.
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/22/head:github-bot/gh-22'
git switch 'github-bot/gh-22'

Merge

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