Repository navigation
Shaders: replace single-wave Wave64 LDS lockstep with barriers and lower 32-lane swizzle/DPP at WaveSize(32) - #192
Conversation
…wer 32-lane swizzle/DPP at WaveSize(32)
|
Independently validated a6782ee on an RTX 5060 Ti, NVIDIA driver 616.92, and pinned Rust 1.98.1. Using only synthetic fixtures, I ran cargo test -p victory-shader wave64_ -- --test-threads=1. I verified the D3D12 adapter by LUID: all four GPU dispatches ran on the 5060 Ti and passed their readback assertions. The other two cases were CPU-only checks. With VICTORY_WARP=1, three dispatches passed and two CPU-only checks passed. The fixed WaveSize(32) swizzle/DPP case passed its CPU checks and skipped dispatch after WARP rejected pipeline creation. Cargo reported 6 passed in both runs. (Disclosure: ChatGPT 6.2 Sol used to test this and write this) |
|
Tested
No game data used. |
|
Tested the PR head at |
v_readfirstlane reads the console wave's first lane. A wave64 program with DPP or ds_swizzle and a v_readfirstlane was split into two 32-lane waves, where the upper half read its own first lane: with all 64 lanes active, lanes 32 to 63 got lane 32's value where the console gives lane 0's (measured on an RTX 5070). Such programs now take the console flow, which reads the first lane in EXEC of the whole console wave (groups of at most 64 threads, no LDS), or stop with the reason as they did before the split existed. New test, exact on an RTX 5070 and a Radeon iGPU. Found by running the same program against Marvisak#192, which has the same result on both adapters. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Test report on a machine with a 32-lane and a 64-lane adapter, with one wrong result. Tested
The wrong one. All 64 lanes active: The console stores 0 in every lane (lane 0's thread id). Here lanes 32-63 store 32, on both adapters. The program has only DPP as a cross-lane read, so it gets #233 had the same result on the RTX 5070 and fixed it in Not tested: the LDS case is exact in five runs with two groups, which does not rule out a race; release build; the title (no game files used). AI-assisted. |
|
@Raxstreams thanks for testing on the 3080 Ti. Good to hear that 16 of the 96 now pass both checks and that they don't overlap with what #233 fixes. The three 8×8 depth-pyramid shaders are expected to still fail here: they exchange data across the two 32-lane halves, so they need the full cross-half Wave64 emulation in #189 / #233, which this PR doesn't do. It only drops |
A wave64 program split over two 32-lane waves took the DPP row index from the host lane, so the upper half (console rows 2 and 3) read row_mask bits 0 and 1. The row now comes from the console lane there. New test: v_mov_b32_dpp with row_mask:0x3 writes lanes 0 to 31 only, exact on an RTX 5070 (split) and a Radeon iGPU (native). Found in review against #189 and #192, which both get this right. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he whole wave A Wave64 compute program with DPP/ds_swizzle or single-wave LDS that also uses v_readfirstlane_b32 or a whole-wave Active/Prefix reduction was lowered at WaveSize(32) (or had WaveSize(64) replaced by LDS barriers), so lanes 32..63 read their own half-wave's first lane or reduced over half the wave. Such programs now keep the console wave size. Plain v_readfirstlane_b32 shaders without DPP, ds_swizzle or single-wave LDS still get no fixed wave size. Test runs skip WaveSize(64) pipelines that a Wave32-only adapter rejects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @r4tedx, good catch — confirmed and fixed in 4a365e3. A Wave64 CS that needs wave-sized execution (DPP / New synthetic tests:
The test runner now skips (instead of panicking on) Results:
|
|
Thanks for the quick fix in AI-assisted (Claude Code). |
|
Verified
I also checked stacking with #320 in the broader local test tree: the two branches overlap in the LDS and console-flow selection logic, not just in adjacent text. I did not force that combination or claim a real-title result for it; the LDS strategy needs to be coordinated explicitly. No game data used. AI-assisted (Kimi Code). |
A wave64 program split over two 32-lane waves took the DPP row index from the host lane, so the upper half (console rows 2 and 3) read row_mask bits 0 and 1. The row now comes from the console lane there. New test: v_mov_b32_dpp with row_mask:0x3 writes lanes 0 to 31 only, exact on an RTX 5070 (split) and a Radeon iGPU (native). Found in review against Marvisak#189 and Marvisak#192, which both get this right. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v_readfirstlane reads the console wave's first lane. A wave64 program with DPP or ds_swizzle and a v_readfirstlane was split into two 32-lane waves, where the upper half read its own first lane: with all 64 lanes active, lanes 32 to 63 got lane 32's value where the console gives lane 0's (measured on an RTX 5070). Such programs now take the console flow, which reads the first lane in EXEC of the whole console wave (groups of at most 64 threads, no LDS), or stop with the reason as they did before the split existed. New test, exact on an RTX 5070 and a Radeon iGPU. Found by running the same program against Marvisak#192, which has the same result on both adapters. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A wave64 program split over two 32-lane waves took the DPP row index from the host lane, so the upper half (console rows 2 and 3) read row_mask bits 0 and 1. The row now comes from the console lane there. New test: v_mov_b32_dpp with row_mask:0x3 writes lanes 0 to 31 only, exact on an RTX 5070 (split) and a Radeon iGPU (native). Found in review against Marvisak#189 and Marvisak#192, which both get this right. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v_readfirstlane reads the console wave's first lane. A wave64 program with DPP or ds_swizzle and a v_readfirstlane was split into two 32-lane waves, where the upper half read its own first lane: with all 64 lanes active, lanes 32 to 63 got lane 32's value where the console gives lane 0's (measured on an RTX 5070). Such programs now take the console flow, which reads the first lane in EXEC of the whole console wave (groups of at most 64 threads, no LDS), or stop with the reason as they did before the split existed. New test, exact on an RTX 5070 and a Radeon iGPU. Found by running the same program against Marvisak#192, which has the same result on both adapters. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A wave64 program split over two 32-lane waves took the DPP row index from the host lane, so the upper half (console rows 2 and 3) read row_mask bits 0 and 1. The row now comes from the console lane there. New test: v_mov_b32_dpp with row_mask:0x3 writes lanes 0 to 31 only, exact on an RTX 5070 (split) and a Radeon iGPU (native). Found in review against Marvisak#189 and Marvisak#192, which both get this right. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v_readfirstlane reads the console wave's first lane. A wave64 program with DPP or ds_swizzle and a v_readfirstlane was split into two 32-lane waves, where the upper half read its own first lane: with all 64 lanes active, lanes 32 to 63 got lane 32's value where the console gives lane 0's (measured on an RTX 5070). Such programs now take the console flow, which reads the first lane in EXEC of the whole console wave (groups of at most 64 threads, no LDS), or stop with the reason as they did before the split existed. New test, exact on an RTX 5070 and a Radeon iGPU. Found by running the same program against Marvisak#192, which has the same result on both adapters. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A wave64 program split over two 32-lane waves took the DPP row index from the host lane, so the upper half (console rows 2 and 3) read row_mask bits 0 and 1. The row now comes from the console lane there. New test: v_mov_b32_dpp with row_mask:0x3 writes lanes 0 to 31 only, exact on an RTX 5070 (split) and a Radeon iGPU (native). Found in review against Marvisak#189 and Marvisak#192, which both get this right. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v_readfirstlane reads the console wave's first lane. A wave64 program with DPP or ds_swizzle and a v_readfirstlane was split into two 32-lane waves, where the upper half read its own first lane: with all 64 lanes active, lanes 32 to 63 got lane 32's value where the console gives lane 0's (measured on an RTX 5070). Such programs now take the console flow, which reads the first lane in EXEC of the whole console wave (groups of at most 64 threads, no LDS), or stop with the reason as they did before the split existed. New test, exact on an RTX 5070 and a Radeon iGPU. Found by running the same program against Marvisak#192, which has the same result on both adapters. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A wave64 program split over two 32-lane waves took the DPP row index from the host lane, so the upper half (console rows 2 and 3) read row_mask bits 0 and 1. The row now comes from the console lane there. New test: v_mov_b32_dpp with row_mask:0x3 writes lanes 0 to 31 only, exact on an RTX 5070 (split) and a Radeon iGPU (native). Found in review against #189 and #192, which both get this right. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v_readfirstlane reads the console wave's first lane. A wave64 program with DPP or ds_swizzle and a v_readfirstlane was split into two 32-lane waves, where the upper half read its own first lane: with all 64 lanes active, lanes 32 to 63 got lane 32's value where the console gives lane 0's (measured on an RTX 5070). Such programs now take the console flow, which reads the first lane in EXEC of the whole console wave (groups of at most 64 threads, no LDS), or stop with the reason as they did before the split existed. New test, exact on an RTX 5070 and a Radeon iGPU. Found by running the same program against #192, which has the same result on both adapters. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A wave64 program split over two 32-lane waves took the DPP row index from the host lane, so the upper half (console rows 2 and 3) read row_mask bits 0 and 1. The row now comes from the console lane there. New test: v_mov_b32_dpp with row_mask:0x3 writes lanes 0 to 31 only, exact on an RTX 5070 (split) and a Radeon iGPU (native). Found in review against Marvisak#189 and Marvisak#192, which both get this right. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v_readfirstlane reads the console wave's first lane. A wave64 program with DPP or ds_swizzle and a v_readfirstlane was split into two 32-lane waves, where the upper half read its own first lane: with all 64 lanes active, lanes 32 to 63 got lane 32's value where the console gives lane 0's (measured on an RTX 5070). Such programs now take the console flow, which reads the first lane in EXEC of the whole console wave (groups of at most 64 threads, no LDS), or stop with the reason as they did before the split existed. New test, exact on an RTX 5070 and a Radeon iGPU. Found by running the same program against Marvisak#192, which has the same result on both adapters. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Automated triage for the maintainers. Needs rebase. This PR does not merge cleanly into current The content has not been reviewed yet; it will be once the branch is rebased onto Generated by Claude Code |
Summary
Reduces unnecessary
WaveSize(64)requirements on translated Wave64 compute shaders so Wave32-only GPUs (e.g. NVIDIA Ampere/Ada/Blackwell) can create and execute them withoutE_INVALIDARG:Single-wave LDS barrier synchronization (
threads 33..=64):32 < total_threads <= 64) can omits_barrierbetween LDS writes and reads because all 64 lanes execute in lockstep on the console. Previously,lower.rspreserved that lockstep by forcingWaveSize(64), which Wave32-only devices refuse.plan_lds_barriers(p, st)incrates/victory-shader/src/emit/lower.rs:v_readfirstlane_b32of a lane-varying VGPR or scalar phis across divergent branches) so only genuinely threadgroup-uniformAtom::Uniformbranches are treated as uniform.WaveSize(64)).dx.op.barrier(1 | 8)(GroupMemoryBarrierWithGroupSync) only in threadgroup-uniform control flow (lds_barrier_beforeandlds_barrier_end) and dropsWaveSize(64).32-lane-local
ds_swizzle_b32andDPPatWaveSize(32):console_lanesintocross_32_lanes(permute,v_mbcnt,v_readlane_b32,v_writelane_b32, lane-mask data reads, opaque/constant lane masks) vslocal_32_lanes(ds_swizzle_b32andDPP, which never cross the 32-lane half-wave boundary).local_32_lanes(and passes LDS barrier planning if it uses LDS), emitWaveSize(32)instead ofWaveSize(64).Lower::console_flat()soDpp::Rowwithrow_mask != 0xFcomputes the 4-row index (0..3) from the console lane (console_flat >> 4 & 3) rather than hostlane_index >> 4, preserving upper half-wave rows 2 and 3 atWaveSize(32).Testing
crates/victory-shader/src/emit/lower.rs:wave64_single_wave_lds_adds_barriers_and_drops_wave_size(cross-half-wavetid ^ 32LDS exchange with nos_barrier)wave64_single_wave_lds_uniform_loop_syncs_raw_and_war(4-iteration uniform loop verifying both RAW and WAR barriers)wave64_divergent_write_reconverging_before_read_adds_barrier(divergent write reconverging before uniform read)wave64_divergent_lds_hazard_keeps_wave_size_64(negative safety test)wave64_readfirstlane_of_tid_branch_keeps_wave_size_64(negative safety test for half-wave-divergentv_readfirstlane_b32branch)wave64_local_swizzle_and_dpp_row_mask_uses_wave_size_32(ds_swizzle_b32XOR-16 +v_mov_b32_dpprow_shr:1withrow_mask:0xC)cargo test --workspaceon RTX 3090 (Wave32-only): all passed (victory-shader: 75 passed, 0 failed).VICTORY_WARP=1 cargo test -p victory-shader wave64_ -- --test-threads=1: 6 passed, 0 failed.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy:asset policy: 151 files ok.dxil.dll: 22 of 106 previously-refused runtime compute pipelines now validate cleanly withdxil.dlland succeed inCreateComputePipelineState(0 new validation failures across 1,151 Wave64 compute shaders).