Recompiler: fix per-lane cross-lane mask lowering bugs #2128
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2128
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2128"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Decodere on GitHub · 2026-11-25 05:27 UTC · original
Decodere:fix-1269-perlane-wave-bugs→main· +133 −9 · 1 files · 1 commits · openWhat 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.
@DarkPanda69 on GitHub · 2026-11-25 05:51 UTC · original
Tested:
gpu_wave_fixes_agree_with_hlslpasses on an AMD D3D12 driver and on an RTX 3060.gpu::filter: 589 passed, 2 failed, 22 ignored. The 2 failures are the AMD fuzz seeds 722 and 1599 tracked in #2115, which fail the same way onmain.Head
9e08a5aapplied onmain6e1e2be,cargo test -p xcl --lib -- gpu:: --test-threads=4withXCL_ADAPTERset to each card.The test's wave64 cases use the split form (
kernel_split,split_wave64: true), so even on the 9070 XT they do not run in native 64-lane waves. This is an AMD driver result, not the native wave64 check the PR lists as untested.Not tested: native wave64 per-lane, retail runs.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@JoaoPauluu on GitHub · 2026-11-25 06:12 UTC · original
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
x86_64-pc-windows-gnu.9e08a5aas it is (merge base withmain6020a33), no uncommitted changes. The lib test binary runs under Wine, one test per process.bcnt_scc_written_in_partial_block_is_detected_as_stale: okgpu_wave_fixes_agree_with_hlsl: okmbcnt_hi_of_low_mask_and_mask_addend_on_cpu: okreadfirstlane_and_readlane_accept_mask_sgpr_on_cpu: okwave32_b64_mask_counts_preserve_independent_high_sgpr_on_cpu: okNot tested
AI use
@DavidM1911 on GitHub · 2026-11-25 06:32 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@JJAutoCompare on GitHub · 2026-11-25 07:12 UTC · original
Tested
9e08a5a82b408f3272f7e340f56795946ba249acon Windows 11 Enterprise Evaluation 25H2 (26200.9974), Ryzen 7 3800X, Intel Arc A770 driver32.0.101.9175. Rust/Cargo1.100.0(x86_64-pc-windows-msvc), DXC/DXIL1.9.2609.5. Debug/test profile with debuginfo and incremental compilation disabled.cargo test --locked -p xcl --lib --no-run --jobs 2 --message-format=json-render-diagnostics. Under the Arc mutex withXCL_ADAPTER=A770, ran the pinned Cargo artifact asxcl-97fdf2b9ff8e1482.exe gpu::recomp::lower::wave::tests::gpu_wave_fixes_agree_with_hlsl --exact --nocapture --test-threads=1. The binary digest matched before and after lock acquisition and after exit.V_MBCNT_HI_U32_B32across all 64 logical lanes. Wave32 covered mixed mask/scalar B64 counts and find-first-bit, plusV_READFIRSTLANE_B32andV_READLANE_B32with a mask source. The fixture reports equality without printing passing readback values.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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.