Direct DXIL: guard dp_mask in s_setreg_b32 when writing MODE[1:0] #2300
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!2300
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2300/head"
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?
@GustavoEllwanger on GitHub · 2026-11-25 13:03 UTC · original
GustavoEllwanger:fix/dxil-setreg-f32-mode-preserves-fp16-rm→main· +53 −2 · 2 files · 1 commits · merged 2026-11-25 18:16 UTCWhen
s_setreg_b32writes only single-precision rounding bits (HW_REG_MODE[1:0], sosp_mask != 0anddp_mask == 0),Lw::setregin the direct DXIL translator entered thedp_maskpath without checkingdp_mask != 0(unlikes_setreg_imm32_b32right above it):self.dyn_rmwas true,match dp_maskfell through0into the_ =>arm (written fordp_mask == 2) and overwrote bit 1 ofVAR_FP16_RMwith(src & 1) << 1, silently corrupting subsequent f16 rounding (e.g., turning RTZ3into RTP1when writing f32 RTN2).self.has_f64_round_opwas true, it falsely returnedErr("dynamic f64 round mode")even thoughMODE[3:2]was untouched.What is in it
crates/xcl/src/gpu/dxil/lower.rs: guard theself.has_f64_round_oprejection andself.dyn_rmVAR_FP16_RMupdate inLw::setregfors_setreg_b32withdp_mask != 0, matchings_setreg_imm32_b32.crates/xcl/src/gpu/dxil/round_tests.rs:gpu_s_setreg_b32_f32_mode_preserves_fp16_round_mode: setsMODE[3:2]to RTZ (3), updates onlyMODE[1:0](SIMM16 = 0x0801) to RTN (2) vias_setreg_b32, and verifies both f32 RTN (v_add_f32) and preserved f16 RTZ (v_cvt_f16_f32) bit-exact on the GPU.direct_s_setreg_b32_f32_mode_allows_f64_ops: verifiess_setreg_b32targetingMODE[1:0](0x0801,0x0001,0x0041) alongsidev_add_f64translates and validates cleanly.Tested
1.95.0 (59807616e 2026-04-14), DXC1.8.2502.11, debug build.32.0.16.1088, split-wave64)32.0.21042.62, native wave64)XCL_ADAPTER=5060 cargo test -p xcl --lib gpu::dxil::round_tests::):gpu_s_setreg_b32_f32_mode_preserves_fp16_round_mode: FAILED (left: 15361[0x3C01],right: 15360[0x3C00]).direct_s_setreg_b32_f32_mode_allows_f64_ops: FAILED (s_setreg_b32 0x801, s0: dynamic f64 round mode).XCL_ADAPTER=5060):gpu::dxil::round_tests::8 passed, 0 failed, 0 ignored (0 skipped);gpu::dxil::core_tests::16 passed, 0 failed, 1 ignored (0 skipped).XCL_ADAPTER=Radeon):gpu::dxil::round_tests::8 passed, 0 failed, 0 ignored (0 skipped);gpu::dxil::core_tests::16 passed, 0 failed, 1 ignored (0 skipped).30.0.13002.13003, courtesy of @luckyteagirl in comment):gpu::dxil::round_tests::8 passed, 0 failed, 0 ignored (0 skipped).XCL_ADAPTER=5060 cargo test --workspace -- --test-threads=4, NVIDIA RTX 5060): 1252 passed, 0 failed, 46 ignored (27 pre-existing runtimeSKIPPEDlines: 20 native-wave64 tests on 32-lane NVIDIA, 3 per-lane#1426f16/f32 refusals, 2 missing D3D12 debug layer, 1 Developer Mode cache-disable, 1 heap windows).Regression run
Paired 60 s
scripts/smoke.ps1regression run on a retail title (release,XCL_NETWORK=0; AMD Radeon RX 9070 RDNA4 driver32.0.32029.2010, Ryzen 7 7800X3D, Windows 11 build 26300, Rust1.100.0), courtesy of @Toons29 (comment):Base (
1a0bbe3a):This PR (
b758a7e8):Not tested
s_setreg_b32onMODE[1:0](that path is verified by the direct GPU and validation tests inround_tests.rs).AI use
crates/xcl/src/gpu/dxil/lower.rsagainstrecomp/emit.rs, wrote the fail-first GPU and validation tests inround_tests.rs, implemented thedp_mask != 0guard inlower.rs, and ran the dual-GPU and workspace test suites.@luckyteagirl on GitHub · 2026-11-25 13:34 UTC · original
Independent focused RX 6800M check of exact PR head
b758a7e82d5ad541d7312c2a933462a865579479.Environment: Windows 11 build 26200; Ryzen 9 5980HX; dedicated Radeon RX 6800M (RDNA2, driver
30.0.13002.13003); Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. Clean detached worktree and isolated Cargo target.XCL_ADAPTER=6800M XCL_REQUIRE_GPU=wave64 XCL_DIRECT_DXIL=1 cargo test --locked -p xcl --lib -j 2 gpu::dxil::round_tests:: -- --test-threads=1 --show-output: 8 passed, 0 failed, 0 ignored, noSKIPPEDlines. This includes the two new cases:gpu_s_setreg_b32_f32_mode_preserves_fp16_round_modepassed its GPU f32/f16 output checks, anddirect_s_setreg_b32_f32_mode_allows_f64_opspassed its three DXIL translation/validation checks. The other six directed-rounding tests also passed.This adds a dedicated RDNA2/RX 6800M check to the author's RTX 5060 and RDNA2 iGPU results. I did not run the full workspace suite, retail-title smoke, or a pre-fix A/B on this card.
AI use: OpenAI Codex (GPT-6; exact variant not exposed in this session) ran the native Windows tests, checked the clean exact head and test output, and drafted this report. No game data was used.
@Toons29 on GitHub · 2026-11-25 13:34 UTC · original
Regression run of
b758a7e8on the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon1a0bbe3a, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 100 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; a script posted this right after the run, with both blocks exactly as printed.@GustavoEllwanger on GitHub · 2026-11-25 13:39 UTC · original
Thanks @Toons29 for the RX 9070 paired smoke run and @luckyteagirl for the RX 6800M check! Added both to the PR description with credit so PR checks can turn green.
@nnonno91 on GitHub · 2026-11-25 14:56 UTC · original
Extended the focused checks on
b758a7e82d5ad541d7312c2a933462a865579479to all 16 combinations of initial f16 and runtime f32 rounding modes.Tested
S_ROUND_MODE, then set only the two f32 mode bits usingS_SETREG_B32with the value supplied in s0. Positive and negative direct-DXIL f32 additions and f16 conversions were checked bit for bit for each mode pair. All 64 outputs matched on both GPUs.cargo test --locked -p xcl --lib gpu::dxil::round_tests:: -- --nocapture --test-threads=1with each GPU selected viaXCL_ADAPTERgave 9 passed, 0 failed, 0 ignored and no skips per GPU (the 8 existing tests plus the matrix). The temporary fixture was removed.Not tested
The parent revision, retail smoke and the full workspace suite.
AI use
OpenAI Codex (GPT-6.2 Sol) added the temporary matrix, ran the checks and wrote this report.
@DavidM1911 on GitHub · 2026-11-25 17:29 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!