fix(shader): track wave width and parked-lane restores in wave barriers #3348

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

@⁠legayclightning22 on GitHub · 2026-11-26 19:30 UTC · original
legayclightning22:fix/narrow-wave-barrier-and-unspill → main · +617 −26 · 7 files · 1 commits · open

Summary

Tracks wave width and parked-lane restores across shader wave barriers and unspill handling (5794ccc), updating shader cache keys and barrier gating/relaxation logic.

Changes

  • Update wave-mode settings, shader cache keys, and gated/relaxed barrier handling to track wave width and parked-lane restores across 7 files (+463/-23)[cite: 26].
  • Add 6 unit tests covering wave barrier width tracking and parked-lane unspill behavior[cite: 26].

Verification

  • cargo test -p victory-shader --lib (297 passed, 6 new tests passing; 11 known baseline hardware failures, 3 ignored)[cite: 26]
  • cargo test -p victory-gpu --lib cache tests[cite: 26]
  • cargo clippy --locked --all-targets -- -D warnings[cite: 26]
  • cargo xtask policy[cite: 26]
**@⁠legayclightning22** on GitHub · 2026-11-26 19:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/3348) `legayclightning22:fix/narrow-wave-barrier-and-unspill` → `main` · +617 −26 · 7 files · 1 commits · open ## Summary Tracks wave width and parked-lane restores across shader wave barriers and unspill handling (`5794ccc`), updating shader cache keys and barrier gating/relaxation logic. ## Changes - Update wave-mode settings, shader cache keys, and gated/relaxed barrier handling to track wave width and parked-lane restores across 7 files (`+463/-23`)[cite: 26]. - Add 6 unit tests covering wave barrier width tracking and parked-lane unspill behavior[cite: 26]. ## Verification - `cargo test -p victory-shader --lib` (297 passed, 6 new tests passing; 11 known baseline hardware failures, 3 ignored)[cite: 26] - `cargo test -p victory-gpu --lib` cache tests[cite: 26] - `cargo clippy --locked --all-targets -- -D warnings`[cite: 26] - `cargo xtask policy`[cite: 26]
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:37:59 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 19:49 UTC · original · approved these changes

LGTM — verified on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).

  • Tracking host wave width in shader cache keys, gating wave64 programs on 32-lane hosts, handling divergent single-wave barriers without group sync, and preserving parked-lane restores in IR all pass cleanly on RTX 5090.
  • cargo test -p victory-shader --lib ir:: -- --test-threads=1: 12 passed, 0 failed.
  • cargo test -p victory-shader --lib structure:: -- --test-threads=1: 13 passed, 0 failed (1 ignored).
  • cargo test -p victory-shader --lib emit::tests:: -- --test-threads=1: 20 passed, 0 failed (barrier_modes_keep_the_shared_and_uav_fences, divergent_barriers_drop_group_sync_in_one_wave, wave64_on_32_lane_host_is_gated).
  • cargo test -p victory-gpu --lib shader_cache:: -- --test-threads=1: 5 passed, 0 failed (wave_settings_have_distinct_cache_keys).
  • cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 19:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/3348#pullrequestreview-6079764121) · **approved these changes** LGTM — verified on RTX 5090 (Windows / D3D12) against `origin/main` (`63bcca4`). - Tracking host wave width in shader cache keys, gating wave64 programs on 32-lane hosts, handling divergent single-wave barriers without group sync, and preserving parked-lane restores in IR all pass cleanly on RTX 5090. - `cargo test -p victory-shader --lib ir:: -- --test-threads=1`: 12 passed, 0 failed. - `cargo test -p victory-shader --lib structure:: -- --test-threads=1`: 13 passed, 0 failed (1 ignored). - `cargo test -p victory-shader --lib emit::tests:: -- --test-threads=1`: 20 passed, 0 failed (`barrier_modes_keep_the_shared_and_uav_fences`, `divergent_barriers_drop_group_sync_in_one_wave`, `wave64_on_32_lane_host_is_gated`). - `cargo test -p victory-gpu --lib shader_cache:: -- --test-threads=1`: 5 passed, 0 failed (`wave_settings_have_distinct_cache_keys`). - `cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠cloph-dsp on GitHub · 2026-11-26 19:55 UTC · original

Independent local verification of PR #3348 (fix(shader): track wave width and parked-lane restores in wave barriers), head 5794ccca63.

  • Windows, Rust 1.100.0/MSVC, cargo test --locked, CARGO_BUILD_JOBS=2, per-worktree CARGO_TARGET_DIR (D:\Victory-Contrib\target-3348).
  • cargo test --locked -p victory-shader --lib -- --exact ir::tests::parked_lane_restores_look_past_other_registers -> 1 passed, 0 failed, 310 filtered, exit 0.
  • git diff --check origin/main HEAD -> clean.
  • Negative control: the test name is absent from the merge base 63bcca43..., so it is genuinely added by this PR.
  • CPU-side IR test only; the barrier/hardware and shader-cache tests in this 7-file PR were not exercised here.

AI-assisted (Hy4 flash). GPU/driver: N/A for this CPU test. No game data used.

**@⁠cloph-dsp** on GitHub · 2026-11-26 19:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/3348#issuecomment-7202106989) Independent local verification of PR #3348 (`fix(shader): track wave width and parked-lane restores in wave barriers`), head 5794ccca63ddc1efe46e122366280f7d35699b13. - Windows, Rust 1.100.0/MSVC, `cargo test --locked`, `CARGO_BUILD_JOBS=2`, per-worktree `CARGO_TARGET_DIR` (`D:\Victory-Contrib\target-3348`). - `cargo test --locked -p victory-shader --lib -- --exact ir::tests::parked_lane_restores_look_past_other_registers` -> 1 passed, 0 failed, 310 filtered, exit 0. - `git diff --check origin/main HEAD` -> clean. - Negative control: the test name is absent from the merge base 63bcca43..., so it is genuinely added by this PR. - CPU-side IR test only; the barrier/hardware and shader-cache tests in this 7-file PR were not exercised here. AI-assisted (Hy4 flash). GPU/driver: N/A for this CPU test. No game data used.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 20:38 UTC · original · requested changes

Tested locally merged onto origin/main (63bcca43) at PR head 5794ccca across three adapters on Windows 11 x64 (NVIDIA GeForce RTX 5090, AMD Radeon Graphics gfx1036, Microsoft WARP; VICTORY_D3D12_DEBUG=1).

Baseline build checks pass (cargo xtask policy: 191 files ok, emit/lower.rs is 522,803 B < 524,288 B; clippy default & --all-features clean; shader_cache key hashing covers host_lanes/wide64/group_sync), but there are three blocking correctness bugs reproduced locally:

1. Unconditional rejection of all wave64 programs on 32-lane hosts (emit/lower.rs:250, 290, shader_cache.rs:74)

On NVIDIA adapters (WaveLaneCountMax == 32, VICTORY_WAVE_WIDE unset), wave64_unsupported = x.native.wave64 && wave.host_lanes < 64 && !wave.wide64 rejects every wave64 shader before lowering — including completely unrestricted wave64 programs with no wave ops and no LDS (which already lower to unrestricted DXIL and run natively in Wave32 on main).

Reproduced locally with a minimal unrestricted wave64 compute shader (rsrc2 = 0, s_endpgm) under WaveMode::with(32, false, GroupSync::Auto):
Err(Unsupported { offset: 0, what: "a wave64 program on a 32-lane host (VICTORY_WAVE_WIDE=1)" }).

Any 32-lane host gating should only apply to programs that actually require 64-lane wave semantics, not every native.wave64 shader.

2. Unsound single_wave barrier relaxation from WaveLaneCountMax (host.rs:19-34, emit/lower.rs:257-272)

host.rs derives max_wave_lanes from WaveLaneCountMax (clamping values < 32 up to 32), and lower.rs drops SYNC_THREAD_GROUP (bit 1) from divergent s_barriers whenever group_lanes <= wave.host_lanes.

Measured D3D12_FEATURE_DATA_D3D12_OPTIONS1 across three real adapters on this machine:

  • NVIDIA GeForce RTX 5090: WaveLaneCountMin = 32, WaveLaneCountMax = 32 (host_lanes = 32)
  • AMD Radeon Graphics: WaveLaneCountMin = 32, WaveLaneCountMax = 64 (host_lanes = 64)
  • Microsoft WARP: WaveLaneCountMin = 4, WaveLaneCountMax = 4 (clamped up to host_lanes = 32)

On AMD RDNA2/3 (host_lanes = 64), a [64, 1, 1] wave32 (or unrestricted) compute shader executes as two 32-lane waves, yet 64 <= 64 marks single_wave = true and strips SYNC_THREAD_GROUP (reproduced locally: barrier_modes = [8] instead of [9]). Likewise on WARP (Min = Max = 4), [32, 1, 1] is eight 4-lane waves, yet 32 <= 32 strips group sync. Dropping SYNC_THREAD_GROUP is only sound when group_lanes <= WaveLaneCountMin (or when DXIL explicitly declares a fixed WaveSize >= group_lanes).

3. Soundness bugs in ir.rs::restores (crates/victory-shader/src/ir.rs:599-643)

  1. Missing invalidation on v_writelane_b32 (L599-L607): When v_writelane_b32 writes a non-SGPR value (e.g. an inline constant/literal) or uses a dynamic lane operand, parked_scalar/operand_number returns None and the early continue at L606 skips invalidating parked. Reproduced locally with v_writelane_b32 v1, s0, 0 followed by v_writelane_b32 v1, 0, 0 and v_readlane_b32 s5, v1, 0: p.restored still maps s5 to the overwritten s0 (Some(Value(4))).
  2. Incorrect vector semantics for v_movrels_b32 / v_movreld_b32 / v_swaprel_b32 (L620-L638): These are per-lane VGPR vector moves, not scalar broadcasts of one parked lane (and v_movreld_b32 indexes the destination v[dst + m0], not v.src[0], nor does the loop at L639-L643 invalidate v[dst + m0]). Reproduced locally with v_writelane_b32 v7, s0, 3 (only lane 3 parked) + s_mov_b32 m0, 3 + v_movrels_b32 v0, v4: p.restored falsely maps the entire vector result v0 to scalar s0 (Some(Value(255))), which then propagates into resource.rs and structure.rs (l.restored).

Synthetic tests only.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 20:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/3348#pullrequestreview-6080265883) · **requested changes** Tested locally merged onto `origin/main` (`63bcca43`) at PR head `5794ccca` across three adapters on Windows 11 x64 (NVIDIA GeForce RTX 5090, AMD Radeon Graphics `gfx1036`, Microsoft WARP; `VICTORY_D3D12_DEBUG=1`). Baseline build checks pass (`cargo xtask policy`: 191 files ok, `emit/lower.rs` is 522,803 B < 524,288 B; clippy default & `--all-features` clean; `shader_cache` key hashing covers `host_lanes`/`wide64`/`group_sync`), **but there are three blocking correctness bugs reproduced locally**: ### 1. Unconditional rejection of all `wave64` programs on 32-lane hosts (`emit/lower.rs:250, 290`, `shader_cache.rs:74`) On NVIDIA adapters (`WaveLaneCountMax == 32`, `VICTORY_WAVE_WIDE` unset), `wave64_unsupported = x.native.wave64 && wave.host_lanes < 64 && !wave.wide64` rejects **every** `wave64` shader before lowering — including completely unrestricted `wave64` programs with no wave ops and no LDS (which already lower to unrestricted DXIL and run natively in Wave32 on `main`). Reproduced locally with a minimal unrestricted `wave64` compute shader (`rsrc2 = 0`, `s_endpgm`) under `WaveMode::with(32, false, GroupSync::Auto)`: `Err(Unsupported { offset: 0, what: "a wave64 program on a 32-lane host (VICTORY_WAVE_WIDE=1)" })`. Any 32-lane host gating should only apply to programs that actually require 64-lane wave semantics, not every `native.wave64` shader. ### 2. Unsound `single_wave` barrier relaxation from `WaveLaneCountMax` (`host.rs:19-34`, `emit/lower.rs:257-272`) `host.rs` derives `max_wave_lanes` from `WaveLaneCountMax` (clamping values `< 32` up to `32`), and `lower.rs` drops `SYNC_THREAD_GROUP` (bit 1) from divergent `s_barrier`s whenever `group_lanes <= wave.host_lanes`. Measured `D3D12_FEATURE_DATA_D3D12_OPTIONS1` across three real adapters on this machine: - NVIDIA GeForce RTX 5090: `WaveLaneCountMin = 32, WaveLaneCountMax = 32` (`host_lanes = 32`) - AMD Radeon Graphics: `WaveLaneCountMin = 32, WaveLaneCountMax = 64` (`host_lanes = 64`) - Microsoft WARP: `WaveLaneCountMin = 4, WaveLaneCountMax = 4` (clamped up to `host_lanes = 32`) On AMD RDNA2/3 (`host_lanes = 64`), a `[64, 1, 1]` `wave32` (or unrestricted) compute shader executes as **two 32-lane waves**, yet `64 <= 64` marks `single_wave = true` and strips `SYNC_THREAD_GROUP` (reproduced locally: `barrier_modes = [8]` instead of `[9]`). Likewise on WARP (`Min = Max = 4`), `[32, 1, 1]` is eight 4-lane waves, yet `32 <= 32` strips group sync. Dropping `SYNC_THREAD_GROUP` is only sound when `group_lanes <= WaveLaneCountMin` (or when DXIL explicitly declares a fixed `WaveSize >= group_lanes`). ### 3. Soundness bugs in `ir.rs::restores` (`crates/victory-shader/src/ir.rs:599-643`) 1. **Missing invalidation on `v_writelane_b32` (`L599-L607`):** When `v_writelane_b32` writes a non-SGPR value (e.g. an inline constant/literal) or uses a dynamic lane operand, `parked_scalar`/`operand_number` returns `None` and the early `continue` at `L606` skips invalidating `parked`. Reproduced locally with `v_writelane_b32 v1, s0, 0` followed by `v_writelane_b32 v1, 0, 0` and `v_readlane_b32 s5, v1, 0`: `p.restored` still maps `s5` to the overwritten `s0` (`Some(Value(4))`). 2. **Incorrect vector semantics for `v_movrels_b32` / `v_movreld_b32` / `v_swaprel_b32` (`L620-L638`):** These are per-lane VGPR vector moves, not scalar broadcasts of one parked lane (and `v_movreld_b32` indexes the *destination* `v[dst + m0]`, not `v.src[0]`, nor does the loop at `L639-L643` invalidate `v[dst + m0]`). Reproduced locally with `v_writelane_b32 v7, s0, 3` (only lane 3 parked) + `s_mov_b32 m0, 3` + `v_movrels_b32 v0, v4`: `p.restored` falsely maps the entire vector result `v0` to scalar `s0` (`Some(Value(255))`), which then propagates into `resource.rs` and `structure.rs` (`l.restored`). Synthetic tests only.
github-bot force-pushed github-bot/gh-3348 from 5794ccca63 to 8013170d80 2026-11-27 01:10:46 +00:00 Compare
Author
Owner

@⁠legayclightning22 on GitHub · 2026-11-26 22:30 UTC · original

Pushed d4bfcbd fixing all three blocking issues:

  1. Scoped 32-lane host wave64 gating so unrestricted wave64 shaders without 64-lane wave semantics lower normally on 32-lane hosts, with a unit test under WaveMode::with(32, false, GroupSync::Auto).
  2. Switched single_wave barrier relaxation to check group_lanes <= WaveLaneCountMin (without clamping values < 32 up to 32) so AMD (Min=32, Max=64) and WARP (Min=Max=4) preserve SYNC_THREAD_GROUP, with regression tests for both.
  3. Fixed ir.rs::restores to invalidate parked entries on non-SGPR/dynamic-lane v_writelane_b32 writes and removed the unsound scalar-broadcast mapping on v_movrels_b32/v_movreld_b32/v_swaprel_b32 with proper VGPR invalidation and regression tests.

Re-verified victory-shader tests, shader_cache::, clippy --all-features -- -D warnings, and cargo xtask policy.

**@⁠legayclightning22** on GitHub · 2026-11-26 22:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/3348#issuecomment-7204740031) Pushed `d4bfcbd` fixing all three blocking issues: 1. Scoped 32-lane host wave64 gating so unrestricted `wave64` shaders without 64-lane wave semantics lower normally on 32-lane hosts, with a unit test under `WaveMode::with(32, false, GroupSync::Auto)`. 2. Switched `single_wave` barrier relaxation to check `group_lanes <= WaveLaneCountMin` (without clamping values `< 32` up to `32`) so AMD (`Min=32, Max=64`) and WARP (`Min=Max=4`) preserve `SYNC_THREAD_GROUP`, with regression tests for both. 3. Fixed `ir.rs::restores` to invalidate `parked` entries on non-SGPR/dynamic-lane `v_writelane_b32` writes and removed the unsound scalar-broadcast mapping on `v_movrels_b32`/`v_movreld_b32`/`v_swaprel_b32` with proper VGPR invalidation and regression tests. Re-verified `victory-shader` tests, `shader_cache::`, `clippy --all-features -- -D warnings`, and `cargo xtask policy`.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 23:02 UTC · original · requested changes

Thanks for updating ir::restores (crates/victory-shader/src/ir.rs:317-364) and narrowing the wave64 rejection to programs that actually set s.wave_size == Some(64) (emit/lower.rs:650-653). Verified on three live D3D12 adapters (RTX 5090, AMD gfx1036 iGPU, and WARP with VICTORY_D3D12_DEBUG=1): both previous ir::restores soundness bugs are resolved and unrestricted wave64 compute shaders now compile and create PSOs cleanly on all three adapters with 0 Debug Layer errors.

However, two blocking issues remain on the updated head (d4bfcbd6):

1. declared_wave_size(c) trusts the console container's PSV0 as the host's wave size, stripping SYNC_THREAD_GROUP from multi-wave threadgroups (emit/mod.rs:454-459, 536 + emit/lower.rs:585-598)

emit_with_wave (crates/victory-shader/src/emit/mod.rs:536) extracts PSV0 bytes 20..28 from the console input container c and passes it as wave.fixed_wave_size. Lower::new (crates/victory-shader/src/emit/lower.rs:585-598) then computes single_wave before s.wave_size (lower.rs:647) using:

let single_wave = group_lanes.is_some_and(|n| {
    n > 0 && (n <= wave.min_lanes || wave.fixed_wave_size.is_some_and(|size| size >= n))
});

Because this inspects the console container's PSV0 rather than the emitted host DXIL's s.wave_size (and never checks size <= wave.host_lanes), a compute shader whose emitted host DXIL declares no WaveSize (PSV0 = 0..=4294967295) still has SYNC_THREAD_GROUP (bit 0) stripped whenever the console container had min == max:

  • RTX 5090 (min=32, max=32), console wave64 CS (threads=[64, 1, 1], console PSV0=64, divergent s_barrier with s_and_saveexec_b64, s.wave_size = None): lowers to barrier_modes = [8] (bit 0 stripped) and emitted host PSV0 = (0..=4294967295), even though 64 threads execute as 2 waves of 32 lanes on RTX 5090.
  • WARP (min=4, max=4), console wave32 CS (threads=[32, 1, 1], console PSV0=32, divergent s_barrier, s.wave_size = None): lowers to barrier_modes = [8] with emitted host PSV0 = (0..=4294967295), even though WARP runs 8 waves of 4 lanes.
  • AMD gfx1036 (min=32, max=64), console wave64 CS (threads=[64, 1, 1], console PSV0=64, divergent s_barrier, s.wave_size = None): lowers to barrier_modes = [8] with emitted host PSV0 = (0..=4294967295), where the driver is free to dispatch 2× Wave32 waves.

Suggested fix: Do not derive single_wave from the console input container's PSV0. Compute single_wave after s.wave_size (lower.rs:647) and only relax divergent barriers when the host is genuinely guaranteed to run one wave: n <= wave.min_lanes || s.wave_size.is_some_and(|w| w >= n && w <= wave.host_lanes).

2. VICTORY_WAVE_WIDE=1 still emits DXIL WaveSize(64) (rejected by 32-lane/4-lane adapters) and host.rs:24-32 misclamps WARP's WaveLaneCountMax = 4 to 32

  • When a wave64 shader sets s.wave_size = Some(64) on a host with host_lanes < 64, lower.rs:1349 directs the user to VICTORY_WAVE_WIDE=1. However, setting wide64 = true only clears wave64_unsupported (lower.rs:650-653) while lower.rs:647 still sets s.wave_size = Some(64) (writing WaveSize(64) and PSV0 min=64, max=64) without any wave64 emulation.
  • Live CreateComputePipelineState verification with VICTORY_D3D12_DEBUG=1 on the lowered wide64 = true DXIL (v_readlane_b32 + s_endpgm, wave64 = true):
    • NVIDIA GeForce RTX 5090 (WaveLaneCountMin=32, WaveLaneCountMax=32): Err(E_INVALIDARG / 0x80070057) — ID3D12Device::CreateComputeShader: Shader wants wave lane count of 64 but maximum wave lane count for device is 32.
    • Microsoft Basic Render Driver (WARP) (WaveLaneCountMin=4, WaveLaneCountMax=4): Err(E_INVALIDARG / 0x80070057) — ID3D12Device::CreateComputeShader: Shader wants wave lane count of 64 but maximum wave lane count for device is 4.
    • AMD Radeon(TM) Graphics (gfx1036) (WaveLaneCountMin=32, WaveLaneCountMax=64): Ok (0 Debug Layer messages).
  • Also in crates/victory-gpu/src/host.rs:24-32, when WaveLaneCountMax < 32 (observed on WARP: WaveLaneCountMin=4, WaveLaneCountMax=4), max_wave_lanes is clamped up to 32 (Host reported min_wave_lanes=4, max_wave_lanes=32). Please preserve the actual reported WaveLaneCountMax (e.g., wave_options.WaveLaneCountMax when lanes.is_ok() && wave_options.WaveLaneCountMax > 0) and either implement/drop the VICTORY_WAVE_WIDE=1 switch or avoid emitting an unsupported WaveSize(64) tag under it.

Minor cleanup

  • crates/victory-shader/src/resource.rs:2079 still matches "v_movrels_b32" even though ir::restores no longer inserts v_movrels_b32 entries.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 23:02 UTC · [original](https://github.com/Marvisak/VIctory/pull/3348#pullrequestreview-6081324324) · **requested changes** Thanks for updating `ir::restores` (`crates/victory-shader/src/ir.rs:317-364`) and narrowing the `wave64` rejection to programs that actually set `s.wave_size == Some(64)` (`emit/lower.rs:650-653`). Verified on three live D3D12 adapters (RTX 5090, AMD `gfx1036` iGPU, and WARP with `VICTORY_D3D12_DEBUG=1`): both previous `ir::restores` soundness bugs are resolved and unrestricted `wave64` compute shaders now compile and create PSOs cleanly on all three adapters with 0 Debug Layer errors. However, two blocking issues remain on the updated head (`d4bfcbd6`): ### 1. `declared_wave_size(c)` trusts the console container's `PSV0` as the host's wave size, stripping `SYNC_THREAD_GROUP` from multi-wave threadgroups (`emit/mod.rs:454-459, 536` + `emit/lower.rs:585-598`) `emit_with_wave` (`crates/victory-shader/src/emit/mod.rs:536`) extracts `PSV0` bytes `20..28` from the **console** input container `c` and passes it as `wave.fixed_wave_size`. `Lower::new` (`crates/victory-shader/src/emit/lower.rs:585-598`) then computes `single_wave` **before** `s.wave_size` (`lower.rs:647`) using: ```rust let single_wave = group_lanes.is_some_and(|n| { n > 0 && (n <= wave.min_lanes || wave.fixed_wave_size.is_some_and(|size| size >= n)) }); ``` Because this inspects the console container's `PSV0` rather than the **emitted host DXIL's** `s.wave_size` (and never checks `size <= wave.host_lanes`), a compute shader whose emitted host DXIL declares **no** `WaveSize` (`PSV0 = 0..=4294967295`) still has `SYNC_THREAD_GROUP` (bit 0) stripped whenever the console container had `min == max`: - **RTX 5090 (`min=32, max=32`)**, console `wave64` CS (`threads=[64, 1, 1]`, console `PSV0=64`, divergent `s_barrier` with `s_and_saveexec_b64`, `s.wave_size = None`): lowers to `barrier_modes = [8]` (bit 0 stripped) and emitted host `PSV0 = (0..=4294967295)`, even though 64 threads execute as **2 waves of 32 lanes** on RTX 5090. - **WARP (`min=4, max=4`)**, console `wave32` CS (`threads=[32, 1, 1]`, console `PSV0=32`, divergent `s_barrier`, `s.wave_size = None`): lowers to `barrier_modes = [8]` with emitted host `PSV0 = (0..=4294967295)`, even though WARP runs **8 waves of 4 lanes**. - **AMD `gfx1036` (`min=32, max=64`)**, console `wave64` CS (`threads=[64, 1, 1]`, console `PSV0=64`, divergent `s_barrier`, `s.wave_size = None`): lowers to `barrier_modes = [8]` with emitted host `PSV0 = (0..=4294967295)`, where the driver is free to dispatch 2× Wave32 waves. **Suggested fix:** Do not derive `single_wave` from the console input container's `PSV0`. Compute `single_wave` **after** `s.wave_size` (`lower.rs:647`) and only relax divergent barriers when the host is genuinely guaranteed to run one wave: `n <= wave.min_lanes || s.wave_size.is_some_and(|w| w >= n && w <= wave.host_lanes)`. ### 2. `VICTORY_WAVE_WIDE=1` still emits DXIL `WaveSize(64)` (rejected by 32-lane/4-lane adapters) and `host.rs:24-32` misclamps WARP's `WaveLaneCountMax = 4` to `32` - When a `wave64` shader sets `s.wave_size = Some(64)` on a host with `host_lanes < 64`, `lower.rs:1349` directs the user to `VICTORY_WAVE_WIDE=1`. However, setting `wide64 = true` only clears `wave64_unsupported` (`lower.rs:650-653`) while `lower.rs:647` still sets `s.wave_size = Some(64)` (writing `WaveSize(64)` and `PSV0 min=64, max=64`) without any wave64 emulation. - Live `CreateComputePipelineState` verification with `VICTORY_D3D12_DEBUG=1` on the lowered `wide64 = true` DXIL (`v_readlane_b32` + `s_endpgm`, `wave64 = true`): - **NVIDIA GeForce RTX 5090** (`WaveLaneCountMin=32, WaveLaneCountMax=32`): `Err(E_INVALIDARG / 0x80070057)` — `ID3D12Device::CreateComputeShader: Shader wants wave lane count of 64 but maximum wave lane count for device is 32.` - **Microsoft Basic Render Driver (WARP)** (`WaveLaneCountMin=4, WaveLaneCountMax=4`): `Err(E_INVALIDARG / 0x80070057)` — `ID3D12Device::CreateComputeShader: Shader wants wave lane count of 64 but maximum wave lane count for device is 4.` - **AMD Radeon(TM) Graphics (`gfx1036`)** (`WaveLaneCountMin=32, WaveLaneCountMax=64`): `Ok` (0 Debug Layer messages). - Also in `crates/victory-gpu/src/host.rs:24-32`, when `WaveLaneCountMax < 32` (observed on WARP: `WaveLaneCountMin=4, WaveLaneCountMax=4`), `max_wave_lanes` is clamped **up** to `32` (`Host` reported `min_wave_lanes=4, max_wave_lanes=32`). Please preserve the actual reported `WaveLaneCountMax` (e.g., `wave_options.WaveLaneCountMax` when `lanes.is_ok() && wave_options.WaveLaneCountMax > 0`) and either implement/drop the `VICTORY_WAVE_WIDE=1` switch or avoid emitting an unsupported `WaveSize(64)` tag under it. ### Minor cleanup - `crates/victory-shader/src/resource.rs:2079` still matches `"v_movrels_b32"` even though `ir::restores` no longer inserts `v_movrels_b32` entries.
This pull request can be merged automatically.
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/3348/head:github-bot/gh-3348'
git switch 'github-bot/gh-3348'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3348'
git switch 'github-bot/gh-3348'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3348'
git switch 'github-bot/gh-3348'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3348'
git switch 'main'
git merge --squash 'github-bot/gh-3348'
git switch 'main'
git merge --ff-only 'github-bot/gh-3348'
git switch 'main'
git merge 'github-bot/gh-3348'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3348
No description provided.