Repository navigation
Conversation
Fix four bugs in per-lane cross-lane wave lowering (recomp/lower/wave.rs): - V_MBCNT_HI_U32_B32: only use half-wave ballot_half when SRC0 is the upper dword of a wave64 mask pair (so low-half masks like vcc_lo/exec_lo still exchange lanes 0..31 to lanes 32..63), and read SRC1 through word() so a mask SGPR can be passed as the addend. - wave32 64-bit mask counts: let words() read wave32 SGPR pairs (0..=106) dword-by-dword via word() and let wave_salu() detect a mask in the high dword (s[code+1]) so independent high SGPRs are preserved instead of zero-extended or rejected as "a mask read as a number". - V_READFIRSTLANE_B32 / V_READLANE_B32: read SRC0 through word() so mask SGPRs are accepted consistently with V_WRITELANE_B32. - MaskOp::Bcnt: record SCC through write_scc() instead of raw ssa.write() so stale SCC writes inside partial blocks are tracked and refused. Part of xcl-dev#1269 Assisted-by: Google Antigravity (Gemini 4 Neon)
|
Tested:
Head |
|
A run with vkd3d-proton as the host D3D12. The DXIL goes through dxil-spirv and then the NVIDIA Vulkan driver, not the native-Windows path: this PR's 5 new tests pass, none skipped. Tested
Not tested
AI use
|
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Tested
Not tested Native wave64, CPU tests including stale-SCC refusal, overflow or invalid inputs, the workspace suite, retail smoke, and other adapters. AI use T3 Code / Codex (gpt-6.2-sol) built and ran the existing fixture and wrote this report. |
What is in it
Fixes four per-lane cross-lane wave lowering bugs in
crates/xcl/src/gpu/recomp/lower/wave.rs:V_MBCNT_HI_U32_B32half-wave ballot and mask addend (wave_valu):hi_halfwas unconditionallytrueforV_MBCNT_HI_U32_B32, callingballot_halfeven whenSRC0was the lower dword of a wave64 mask (e.g.vcc_loorexec_lo), which left lanes32..63reading their own half's ballot instead of lanes0..31's bits.hi_halfis now only set whenSRC0is the upper dword of a wave64 mask pair (matches!(self.mask_reg(b, s0), Some((_, true)))).SRC1is also now read viaself.word(b, d, s1)?instead ofself.src(...), so a mask SGPR can be used as the addend.words,wave_salu): In wave32, masks are single 32-bit SGPRs, so a 64-bit operands[r:r+1](rin0..=106, includingvcc_lo/vcc_hi) can hold a mask inrwith an independent scalar number inr+1, or a number inrwith a mask inr+1. Previouslywords()zeroed the upper dword wheneverrheld a mask, andwave_salu()skipped instructions where onlyr+1held a mask (causing the fallback path to fail with"a mask read as a number").words()now lowers wave320..=106pairs dword-by-dword viaword(), andwave_salu()checkss0 + 1in wave32_B64mask counts while keepingEXEC(126) mapped to[ballot(exec), 0].V_READFIRSTLANE_B32andV_READLANE_B32maskSRC0(wave_valu): Both instructions readSRC0viaself.src(b, d, s0)?, rejecting mask SGPRs (such asvcc_lo), unlikeV_WRITELANE_B32which already usedself.word(b, d, s0)?. Both now useself.word(b, d, s0)?.MaskOp::Bcntstale-SCC tracking (wave_salu):S_BCNT{0,1}_I32_B{32,64}wroteSCCvia rawself.ssa.write(b, Var::Scc, c)instead ofself.write_scc(b, c), bypassingown()so a staleSCCwritten inside a partial block and read after a lane join was not detected or refused. It now callsself.write_scc(b, c).Adds five regression tests in
gpu::recomp::lower::wave::tests: four deterministic CPU tests covering all four bugs plus a WARP-guarded GPU parity test (gpu_wave_fixes_agree_with_hlsl) comparing per-lane direct DXIL against HLSL on both split-wave64 and wave32.Part of #1269
Tested
Hardware/toolchain: Windows 11 (26200), NVIDIA GeForce RTX 4060 (32-lane waves, driver 621.14), DXC
1.9.2609.5 (01b62ad4), Rust1.100.0.s106: a mask read as a number,unsupported S_BCNT1_I32_B64 (s5: a mask read as a number), wrong upper-half counts / zeroed high SGPR, and unrefused staleSCC).cargo test --release -p xcl --lib gpu::recomp::lower::wave::tests:: -- --nocapture --test-threads=1on RTX 4060: 5 passed, 0 failed, 0 ignored (0 skipped;gpu_wave_fixes_agree_with_hlslran on GPU for split-wave64mbcnt_hi_low_maskand wave32wave32_b64_mixed_mask/readlane_of_mask).XCL_ADAPTER="Microsoft Basic Render Driver"andXCL_ADAPTER=warp) ongpu::recomp::lower::wave::tests::: 5 passed, 0 failed, 0 ignored (4 CPU tests passed;gpu_wave_fixes_agree_with_hlslcleanly reportedSKIPPED ...: no GPU with 32-lane waves).cargo build --release --workspace: exit 0.cargo test --release --workspace -- --test-threads=4: 1159 passed, 0 failed, 46 ignored across 21 test suites, with 25 pre-existing runtimeSKIPPEDlines (23 native wave64 / unsupported per-lane lowering skips on 32-lane RTX 4060, 1 Windows driver-cache skip, 1 heap-window skip; 0 new skips).Regression run
Paired 60-second
scripts/smoke.ps1runs on the same retail title build (29640639) from cleanorigin/main(6020a33) and this branch (9e08a5a):Base (
origin/main):PR (
fix-1269-perlane-wave-bugs):Not tested
V_MBCNT_HI_U32_B32was verified on both the CPU interpreter and the RTX 4060 GPU against HLSL).AI use
Drafted with Google Antigravity (Gemini 4 Neon) and verified locally by reproducing failures before the fix, checking CPU and RTX 4060 GPU parity against HLSL, checking WARP adapter skips, running the full release workspace test suite, and completing the paired 60-second smoke run above.