DXIL: fix negative preserved denormal qNaN in rm_sqrt and route rm_mad via by_mode #2534
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!2534
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2534"
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 21:48 UTC · original
Decodere:fix-dxil-round-sqrt-denorm-mad→main· +119 −22 · 2 files · 1 commits · openPart of #675
Part of #1833
What is in it
Fixes two direct-DXIL directed f32 rounding bugs in
crates/xcl/src/gpu/dxil/lower_round.rsand expands test coverage incrates/xcl/src/gpu/dxil/round_tests.rs:Lw::rm_sqrt: Previously,rm_sqrtfell back tonative(dx.op.unary.f32(Sqrt, fa)) for nonzero special values (negv || infnan). Under D3D12 / SM 6.x, native f32Sqrtflushes f32 denormals to zero, so a negative preserved denormal (MODE[4] == 1) produced-0.0(0x8000_0000) instead ofqNaN, and static directed modes kept an unused nativeSqrtcall live.rm_sqrtnow computes the special-case result directly from theMODE[4]-filtered bitsu(±0->±0,+inf->+inf, negative nonzero values including preserved denormals and-infand all NaNs -> canonicalqNaN0x7FC0_0000), removing thenativedependency from the directed path so DCE eliminates the dead nativeSqrtin static directed modes.Lw::rm_madthroughLw::by_mode: Replaces the nestedrm_mul+rm_add+ outeris_neselect with a singleself.by_mode(native, mode, ...)(ext_exact->fmul->round_exact->ext_exact->round_sum), matchingrm_add,rm_mul, andrm_fma. ConstantRNEnow folds directly tonative(mad_nf) with zero f64 instructions, and dynamic mode emits only a singlenativemad_nfinstead of duplicate deadfmul float/fadd floatops.crates/xcl/src/gpu/dxil/round_tests.rs):ref_sqrtto returnSome(0x7FC0_0000)for negative nonzero inputs (instead of skipping them withNone) and updateddirected_reference_basicswith preserved/flushed negative-denormalref_sqrtassertions and host NaN comparison.direct_f32_round_sqrt_specials_and_mad_dxil_validate(pure-CPU/WARP0-skip DXC 1.9 validation + disassembly check verifying a singledx.op.unary.f32(i32 24, ...)under static directedv_sqrt_f32, singlefmul float/fadd floatunder dynamicv_mad_f32, and zerofmul doubleunder constant RNEv_mad_f32).gpu_direct_f32_round_sqrt_negative_denormals_and_specialscovering±denorm,±0,-1.0,±inf,±qNaN,±sNaN, andv_mad_f32(+denorm, +inf, 1.0)under boths_denorm_mode 3(preserve) ands_denorm_mode 0(flush) acrossrm in [1, 2, 3](cleanly skipped on WARP/CI viagpu_ready()).Tested
origin/main(lower_round.rsunchanged) with the new tests:direct_f32_round_sqrt_specials_and_mad_dxil_validate): panicked atround_tests.rs:574(expected 1 Sqrt (dead native eliminated): left: 2, right: 1).gpu_direct_f32_round_sqrt_negative_denormals_and_specials): panicked atround_tests.rs:639(rm=1 keep=true lane=0 in=0x80000001: got=0x80000000 want=0x7fc00000).1.9.2609.5,0compiler warnings inlower_round.rsandround_tests.rs):cargo test --release -p xcl --lib gpu::dxil::round_tests -- --test-threads=1 --nocapture:10 passed; 0 failed; 0 ignored(0skipped).XCL_ADAPTER=warp):cargo test --release -p xcl --lib gpu::dxil::round_tests -- --test-threads=1 --nocapture:10 passed; 0 failed; 0 ignored(all 4 CPU/DXC tests ran with0skips; all 6gpu_*tests cleanly reportedSKIPPED: no wave64).cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture):37test binaries:1425 passed; 0 failed; 46 ignored.29pre-existing runtimeSKIPPEDmessages (21no wave64on wave32-only RTX 4060,3per-lane form: refused,3no D3D12 debug layer/no d3d12SDKLayers.dll,1cannot disable the driver cache,1no heap windows).Regression run
Before (
origin/maine1d84b7d9153f86a97d2ec5d209d196046fc0bea):After (
fix-dxil-round-sqrt-denorm-madb3fced11b79fe70204212a03ec78e60dca110eb9):Both 60 s runs reach steady
60presents per 2 s (60 61 60vs60 60 60) with0device removals,0crashes,1593vs1556frames shown (102.4%), and14004 MBvs14015 MBpeak commit.Not tested
direct_kerneltests ran on the split-wave64 path;round_testslowering is wave-width independent).d3d12SDKLayers.dllis not installed on this machine).AI use
Written and verified with Google Antigravity (Gemini 4 Neon). All code changes, CPU/DXIL and RTX 4060 failing-first reproductions, targeted RTX 4060 and WARP test runs, the full release workspace suite, and both paired 60 s GPU smoke runs were executed and checked locally.
@DarkPanda69 on GitHub · 2026-11-25 22:00 UTC · original
Native wave64 run (listed as untested) on AMD RDNA4, plus an RTX 3060: both new tests pass on both cards, and nothing else changes.
Head
b3fced1applied onmaine1d84b7, debug, Windows 11 Pro 26200,XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4onmainand with the PR, card chosen withXCL_ADAPTER:maindirect_kernel_full(.., true)runs native wave64 here)On both cards, the only result changes against
mainare the newgpu_direct_f32_round_sqrt_negative_denormals_and_specialsanddirect_f32_round_sqrt_specials_and_mad_dxil_validate, both ok, with no new skips. The 2 RX 9070 XT failures are the AMD fuzz seeds tracked in #2115, the same onmain. So the expected denormal and NaN results hold on both vendors' hardware, with denormals kept and flushed, for round modes 1–3.Not tested: the D3D12 debug-layer tests (no
d3d12SDKLayers.dllhere either; they skip), RDNA2/3, a title.AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@DavidM1911 on GitHub · 2026-11-25 22:08 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!
@xpatfussy69x on GitHub · 2026-11-25 22:09 UTC · original
Test run on exact head
b3fced1(b3fced11b79fe70204212a03ec78e60dca110eb9, on its basee1d84b7), clean tree.Tested
cargo test --workspace -- --test-threads=4: 1425 passed, 0 failed, 46 ignoredV_MUL_F16/V_PK_MUL_F16/V_CVT_F16_F32(onmaintoo)cargo test -p xcl --lib round: 36 passed, 0 faileddirect_f32_round_sqrt_specials_and_mad_dxil_validate: ok, not skippedgpu_direct_f32_round_sqrt_negative_denormals_and_specials: ok, not skippedRegression run (60 s, default settings)
main:
this PR:
No crash or device removal; frames 101 % of
main's, peak commit 100 %.Not tested
XCL_DIRECT_DXIL=1, and no directed rounding mode: a regression check onlymain(tested on its own base; it merges intoe1d84b7without conflicts)AI use
@emirduran707 on GitHub · 2026-11-25 22:10 UTC · original
Independent AMD RDNA4 (native wave64) test report on exact head
b3fced11b79fe70204212a03ec78e60dca110eb9(clean detached checkout, no local changes).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1423 passed, 2 failed, 46 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpurefused by per-lane form;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.gpu::dxil::round_tests::direct_f32_round_sqrt_specials_and_mad_dxil_validateandgpu_direct_f32_round_sqrt_negative_denormals_and_specials.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599) are pre-existing on unmodifiedmainon this GPU.Regression run (60 s retail-title smoke,
XCL_NETWORK=0, release)(Matched
main68a284abaseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
@SlopTart on GitHub · 2026-11-25 23:07 UTC · original
Tested: current PR head merged onto current
origin/main(clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo targetx86_64-pc-windows-gnurun under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).gpu_suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.Targeted run of the rm_sqrt/rm_mad qNaN/denormal tests: the three matching new-behavior tests passed; the one failure in the same filter is the pre-existing baseline
gpu_nonfused_mad_and_mac_prevent_fma_contraction, which stays red on this lane with this PR (unchanged from main). Flagging that explicitly since this PR touches that machinery.Not tested: retail titles (no title data on this lane, counts only).
AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
@luckyteagirl on GitHub · 2026-11-25 23:31 UTC · original
RX 6800M focused validation on exact PR head
b3fced11b79fe70204212a03ec78e60dca110eb9(Windows 11 build 26200, Radeon RX 6800M driver30.0.13002.13003, Rust 1.99.0 MSVC, DXC/DXIL 1.8.2502.11):XCL_ADAPTER=6800M XCL_REQUIRE_GPU=1 XCL_DIRECT_DXIL=1 cargo test --locked -p xcl --lib -j 1 gpu_direct_f32_round_sqrt_negative_denormals_and_specials -- --test-threads=1 --show-outputpassed on an isolated target directory: 1 passed, 0 failed, 0 ignored, 0 SKIPPED (1,325 filtered out). The fixture ran on native RDNA2 hardware, exercising the new negative-denormal/special-value cases in direct DXIL. The memory guard did not stop this completed run.A prior cold compile stopped at the memory guard before testing. A later attempt with a target directory shared across worktrees incorrectly reused another PR's test binary and selected zero tests; I detected that in the libtest summary, discarded it, and rebuilt in the isolated target for the result above. Neither earlier attempt is counted as a pass.
Not tested: full GPU workspace suite, release binary, paired title smoke, other adapters/drivers, or a full title path through these instructions. No game data was uploaded.
AI use: OpenAI Codex (GPT-6; exact variant unavailable) ran the guarded exact-head test, checked the binary/test selection and logs, and drafted 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.