Repository navigation
Conversation
…r-lane lowering
Fix two correctness bugs in the per-lane lowering and lane-mask analysis:
1. `NULL` (`125`) destination/source handling (`recomp/lower.rs`,
`recomp/lane_masks.rs`):
- `Lower::write_num` and `Lower::write_bit` lacked an `r == 125` early
return, so wave64 mask writes to `null` (such as `S_AND_B64 null,
exec, vcc`, `S_WQM_B64 null, exec`, `S_CSELECT_B64 null, ...`, and
VOP3 `V_CMP_* null, ...`) wrote markers to `r + 1 = 126`, clobbering
`EXEC`, and 64-bit scalar writes (`S_GETPC_B64`, `S_MOV_B64`,
`S_CSELECT_B64`, multi-dword `S_LOAD_DWORD*`) wrote `sd + 1 = 126`.
Guard `write_num`, `write_bit`, the 64-bit/SMEM write sites, and
exclude `125` in `reads_mask` and `cmp64`.
- In `lane_masks.rs`, map `125` (`null`) to `Some(FALSE)` in
`mask_src`, avoid writing `st.regs[125]` on `V_CMP_*`,
`saveexec`/`wrexec`, and SALU mask ops while still updating `SCC` on
non-`MOV`/`CSELECT` mask ops to `null`, and exclude `125` when
detecting tracked mask sources.
2. Bridged `lane_mask` input clobbering (`recomp/lower.rs::bridge`):
- Pushing `(Var::S(m), ...)` and `(Var::S(m + 1), ...)` unconditionally
after the `whole` SGPR loop overwrote live scalar operands in
`inputs` (e.g. wave32 `V_ADD_CO_CI_U32 v2, vcc_lo, s1, v1, s0`
clobbered `s1` with `0`, `SRC0 == SRC2` clobbered the scalar addend
with `1 << lane`, and `m == 127` pushed out-of-range `Var::S(128)`).
- Only push `(Var::S(r), val)` when `r < 128` and `Var::S(r)` is not
already present in `inputs`.
Add CPU, DXIL-validation, and CI-WARP-safe GPU parity tests covering
both bugs (wave32 bridged `V_ADD_CO_CI_U32` and wave64 `NULL` dests).
Part of xcl-dev#1269
Assisted-by: Google Antigravity (Gemini 4 Neon)
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
|
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 4 new tests pass, none skipped. Tested
Not tested
AI use
|
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
What is in it
Fixes two correctness bugs in the per-lane lowering (
crates/xcl/src/gpu/recomp/lower.rs) and lane-mask analysis (crates/xcl/src/gpu/recomp/lane_masks.rs):NULL(125) destination & source handling (recomp/lower.rs,recomp/lane_masks.rs):Lower::write_numandLower::write_bitlacked an early return onr == 125. In wave64, mask writes tonull(such asS_AND_B64 null, exec, vcc,S_WQM_B64 null, exec,S_CSELECT_B64 null, ..., and VOP3V_CMP_* null, ...) wrotenum_marker/bit_markertor + 1 = 126(destroyingEXEC), and 64-bit scalar / multi-dword SMEM writes (S_GETPC_B64,S_MOV_B64,S_CSELECT_B64,S_LOAD_DWORD*) wrotesd + 1 = 126. Addedif r == 125 { return; }towrite_numandwrite_bit, guarded the 64-bit scalar and SMEM write sites with!= 125, and excluded125inreads_maskandcmp64.lane_masks.rs, mapped125(null) toSome(FALSE)inmask_src, avoided pushing125intoset(st.regs[125]) onV_CMP_*,saveexec/wrexec, and SALU mask ops while preservingSCCtracking (scc = Some((v, SccKind::Any))) for non-MOV/CSELECTmask ops tonull, and excluded125when detecting tracked mask sources.lane_maskinput clobbering (recomp/lower.rs::bridge):bridge()pushed(Var::S(m), ...)and(Var::S(m + 1), ...)unconditionally after thewholeSGPR loop, overwriting live scalar operands already placed ininputs(for example, wave32V_ADD_CO_CI_U32 v2, vcc_lo, s1, v1, s0clobbereds1with0;SRC0 == SRC2clobbered the scalar addend with1 << lane; andm == 127pushed out-of-rangeVar::S(128)).lane_maskpushes so(Var::S(r), val)is only pushed whenr < 128andVar::S(r)is not already ininputs(in wave32dxil::Lw::lane_ofignoreshi, and a scalar register already present as a number ininputsalready holds its true mask bit for every lane).lane_masks.rs,lower.rs):lane_masks::tests::null_dest_and_source_in_lane_masks: verifiesS_AND_SAVEEXEC_B64 null, vcc+S_OR_B64 s[0:1], null, vccreadsFALSEfornull(keepingMOV2guarded) andS_AND_B64 null, exec, vcc/nullstill tracks maskSCC.lower::tests::null_dest_preserves_exec_and_scc: CPUInterptest covering wave64S_AND_B64, VOP3V_CMP_EQ_U32,S_MOV_B64,S_CSELECT_B64, andS_GETPC_B64tonull(125), verifyingEXECandSCC.lower::tests::bridged_wave32_carry_preserves_scalar_operands_in_dxil: CPU +dxil.dllvalidation test checkinglower_dxil::kernelpreservess1=42(SRC0adjacent toSRC2=s0) ands4=5(SRC0 == SRC2) in the generated DXIL.lower::tests::gpu_null_dest_and_bridged_carry_agree_with_hlsl: CI-WARP-safe (gpu_waves()+dxc::location()) GPU parity test verifying wave32 bridgedV_ADD_CO_CI_U32(lower_dxil::kernel) and wave64 splitNULLdests (lower_dxil::kernel_split) match HLSL on the GPU.Part of #1269
Tested
rustc 1.100.0, DXC1.9.2609.5, release build.6987e496):null_dest_and_source_in_lane_masksfailed (left: [], right: [16]—nullread stalest.regs[125]).null_dest_preserves_exec_and_sccfailed (s126: a mask read as a number—write_bit(125)clobberedEXEC).bridged_wave32_carry_preserves_scalar_operands_in_dxilfailed (adjacent scalar operand s1=42 must not be clobbered by lane_mask).gpu_null_dest_and_bridged_carry_agree_with_hlslfailed (lane 0: v2 (s1 + v0 + cin): left: 0, right: 43).null_dest_and_source_in_lane_masks,null_dest_preserves_exec_and_scc,bridged_wave32_carry_preserves_scalar_operands_in_dxil,gpu_null_dest_and_bridged_carry_agree_with_hlsl): 4 passed, 0 failed, 0 ignored, 0 skipped.XCL_ADAPTER="Microsoft Basic Render Driver"andXCL_ADAPTER=warp): 4 passed, 0 failed (all 3 CPU tests pass; GPU test skips cleanly withno GPU with 32-lane waves).cargo build --release --workspace: exit0.cargo test --release --workspace -- --test-threads=4: 1158 passed, 0 failed, 46 ignored across 21 test binaries, with 25SKIPPEDstderr lines:no wave64(32-lane RTX 4060 hardware)per-lane form: refused(#1426unsupported f16/f32 semantics in per-lane wave32 tests)cannot disable the driver cache (Windows Developer Mode is required)(pso_measurement_compiles_an_exact_synthetic_record)no heap windows(heap_window_out_of_memory_falls_back_to_the_switch_form)Regression run
Paired 60s
scripts/smoke.ps1runs on the same retail title (title: 29640639) and GPU (NVIDIA GeForce RTX 4060):Base (
origin/main,6987e496):This PR (
d758ce8b):No regressions (
1602vs1590frames,14471 MBvs14516 MBpeak commit,60 61 60presents per 2 s,0device removals,0crashes).Not tested
lower_dxil::kernel_split, and wave64 per-lane semantics were verified on the CPU viaInterp.AI use
NULL(125) destination/source and bridgedlane_maskinput-clobbering bugs inrecomp/lower.rsandrecomp/lane_masks.rs, authored the fixes and CPU/GPU regression tests, and ran all build, unit, GPU, WARP, workspace, and paired smoke checks.