Repository navigation
shader: support 32-lane host wave execution for console wave64 comput… - #3301
AdvaitPalve11 wants to merge 1 commit into
Conversation
…e shaders Xbox Series X|S consoles (AMD RDNA 2) frequently run compute shaders in Wave64 mode (wave64: true). In the host DXIL container emission: - container::psv set MinimumWaveLaneCount and MaximumWaveLaneCount strictly to (64, 64). - Shader::finish emitted DXIL entry-point tag 11 (kDxilWaveSizeTag) with 64. On PC hardware with 32-lane execution units (NVIDIA GeForce RTX 20/30/40/50 series and Intel Arc), D3D12 CreateComputePipelineState unconditionally rejects pipelines requiring WaveSize(64) with 0x80070057 (E_INVALIDARG) because WaveLaneCountMax is 32. Fix this by: 1. Setting PSV0 runtime info MinimumWaveLaneCount to 32.min(wave_size) and MaximumWaveLaneCount to wave_size, exposing the [32, 64] range to D3D12 runtime validators. 2. Clamping tag 11 entry-point wave size metadata to 32.min(n) so 32-lane hardware adapters accept compute PSOs while preserving valid lane sizing. 3. Clamping wave stride to 32.min(wave_size) when reconstructing flat thread IDs in lower::thread_id, ensuring consecutive 32-lane host warps (e.g. lanes 32..63 in warp 1) receive non-overlapping, contiguous thread IDs (base & !31) + lane. 4. Updating synthetic test annotations for WaveSize(64) execution on hardware devices.
AurumCarlos
left a comment
There was a problem hiding this comment.
This makes the pipelines get created, but I don't think the shaders stay correct.
- The lowering still assumes 64 host lanes per console wave. Programs with
wave_size = 64are lowered with console-lane semantics (console_lanes: 64-lane EXEC/VCC masks, ballots and cross-lane reads, andthread_idbuilt fromwaveReadLaneFirst+ lane index). DeclaringWaveSize(32)lets the driver split each console wave into two independent host waves, so every cross-lane op sees only half the wave, silently. That's why 64-lane programs are refused on 32-lane hosts today, and why the wave64-on-32 work (#3179, #189/#192, issue #2688) pairs or widens waves instead. Clampingthread_id's stride hides the symptom in one place but not in the masks. - It also changes AMD. Tag 11 is now 32 for every wave64 program, so RDNA hosts that ran them natively at 64 lanes would run them split too.
- PSV and the entry tag disagree: PSV says
[32, 64]while tag 11 says exactly 32. The test only got a comment change, so nothing checks a wave64 program's results on a 32-lane adapter.
Dukestar69
left a comment
There was a problem hiding this comment.
Ran local verification on Windows 11 x64 (RTX 5090 + dxil.dll validator):
cargo test -p victory-shader --lib emit::synthetic_tests:: -- --test-threads=1 --skip gathers_at_a_level_match_the_hardware: 8 passed, 2 failed — both Wave64 permute tests fail DXIL validation:emit::synthetic_tests::wave64_permutes_check_exec_within_each_halfemit::synthetic_tests::wave64_permutes_stay_within_each_32_lane_half- Exact error:
DXIL container mismatch for 'PSVRuntimeInfo' between 'PSV0' part (WaveSize=32) and DXIL module (MinimumExpectedWaveLaneCount: 32, MaximumExpectedWaveLaneCount: 64)—container.rswrites(min=32, max=64)intoPSV0whileshader.rswrites single-valueWaveSize(32)into DXIL metadata (note: wave-size ranges[WaveSize(min, max)]require SM 6.8dx.entryPointstag 23, not SM 6.6 tag 11).
cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
|
I tested exact
The opt-in regression Please retain the test's Git author if you reuse it, or add |
|
The same mismatch shows up on the title's own shaders. Census of the whole
AMD RDNA hosts run 64-lane waves, so there the clamp only removes programs that The repository's own tests on an RX 7900 XTX (driver 32.0.32029.2010): |
fuzeofficlal
left a comment
There was a problem hiding this comment.
Requesting changes based on static audit and local verification against origin/main (63bcca43) on Windows x64 (RTX 5090 + dxil.dll and WARP):
Blocking issues
- [P1] DXIL metadata and
PSV0wave-size bounds contradict each other (fails DXIL validation):crates/victory-shader/src/emit/container.rs:199writesPSV0MinimumWaveLaneCount/MaximumWaveLaneCountas(32.min(n), n)((32, 64)forwave_size = 64), whereascrates/victory-shader/src/emit/shader.rs:885writes SM 6.6 entry-point tag 11 (kDxilWaveSizeTag) with a single scalar32.min(n)(32).- Running the shader test suite locally on both
VICTORY_WARP=0andVICTORY_WARP=1failsdxil.dllvalidation (0 passed, 3 failed):emit::lower::tests::ds_bpermute_wave64_preserves_32_lane_halfemit::synthetic_tests::wave64_permutes_check_exec_within_each_halfemit::synthetic_tests::wave64_permutes_stay_within_each_32_lane_half- Error:
DXIL container mismatch for 'PSVRuntimeInfo' between 'PSV0' part:('... WaveSize=32 ...') and DXIL module:('... MinimumExpectedWaveLaneCount: 32\n MaximumExpectedWaveLaneCount: 64 ...').
- In addition, clamping tag 11 unconditionally to
32forces Wave64-capable hardware onto split 32-lane waves as well.
- [P1] Clamping
thread_idstride does not preserve Wave64 guest semantics across split 32-lane host waves:- Even if
PSV0and DXIL metadata both declared 32 lanes, only adjustingthread_idincrates/victory-shader/src/emit/lower.rs:2937leaves cross-lane and 64-lane mask operations operating only on a single 32-lane physical wave:lane_bit(lower.rs:2644), numericEXEC/VCCmasks (lower.rs:1843),s_bcnt1_i32_b64(lower.rs:3720),v_mbcnt_lo/v_mbcnt_hi(lower.rs:7794),v_readfirstlane_b32(lower.rs:6650),v_readlane_b32/v_writelane_b32(lower.rs:6688),wave::sectionsreductions/prefix sums (wave.rs:131,lower.rs:1245), and barrier-free intra-wave LDS communication between lanes0..31and32..63(lower.rs:566,3380,3436,3531).
- Even if
Additional note
- [P2]
crates/victory-shader/src/emit/synthetic_tests.rs:407silently skips anyhost.compute_pipeline(&shader)failure, and the existingwave64_permutes_*tests only verify intra-half behavior rather than cross-half (0..31<->32..63) communication on 32-lane devices.
Synthetic tests only; no game data used.
|
Ran the victory-shader library suite at System
Results
What this adds Not tested AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used. |
…e shaders
Xbox Series X|S consoles (AMD RDNA 2) frequently run compute shaders in Wave64 mode (wave64: true). In the host DXIL container emission:
On PC hardware with 32-lane execution units (NVIDIA GeForce RTX 20/30/40/50 series and Intel Arc), D3D12 CreateComputePipelineState unconditionally rejects pipelines requiring WaveSize(64) with 0x80070057 (E_INVALIDARG) because WaveLaneCountMax is 32.
Fix this by: