Recompiler: guard and scale direct DXIL v_rcp_f64 and v_rsq_f64 #2063
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!2063
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2063/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?
@Decodere on GitHub · 2026-11-25 02:31 UTC · original
Decodere:fix-1269-dxil-rcp-d→main· +155 −4 · 1 files · 1 commits · merged 2026-11-25 10:55 UTCWhat is in it
Bring Direct DXIL
v_rcp_f64andv_rsq_f64into parity with the HLSL path'srcp_dhelper (merged in #530).Part of #1269
crates/xcl/src/gpu/dxil/lower_wide.rs, Direct DXIL lowering ofv_rcp_f64andv_rsq_f64still emitted raw unguardedddiv(1.0, a)/ddiv(1.0, sqrt_d(a)). As documented in #530, drivers can return0for1/NaN(for examplev_rsq_f64on negative inputs) or flush subnormal reciprocals such as1/f64::MAXto0.Lw::rcp_dincrates/xcl/src/gpu/dxil/lower_wide.rsand wire bothv_rcp_f64(self.rcp_d(a)) andv_rsq_f64(self.rcp_d(self.sqrt_d(a))) through it:NaN(preserving the input bits),±0.0 -> ±inf, and±inf -> ±0.0explicitly usingisnan_d,isinf_d,fcmp(Pred::FOEq, x, 0.0), andmkdwith the input sign bit.1.0into the eager division path (safe_x = sel(special, 1.0, x)) so special operands never reachddiv.[0.5, 1)viae = frexp_exp_d(safe_x)andscaled = ldexp_d(safe_x, -e), computer = ddiv(1.0, scaled), and rescale back withldexp_d(r, -e)so subnormal reciprocals are preserved.rcp_d_testsat the end ofcrates/xcl/src/gpu/dxil/lower_wide.rs:v_rcp_f64_and_v_rsq_f64_use_guarded_scaled_rcp_d: validates bothv_rcp_f64andv_rsq_f64(wave32 and wave64) withdxil.dlland checks the DXIL disassembly for the zero guard,frexp_exp_dscaling, and post-divisionldexp_d/ select guards.gpu_direct_rcp_f64_and_rsq_f64_edges: unconditional wave32 Direct DXIL GPU test across 32 edge inputs (±0.0,±inf,±qNaNwith payload, negative values,±f64::MAX,±f64::MIN_POSITIVE, smallest/largest±denormals, and normal floats), verifying exact±inf/±0signs, NaN payload preservation forv_rcp_f64,NaNforv_rsq_f64(-x),<= 1 ULPforv_rcp_f64, and<= 2 ULPforv_rsq_f64.Tested
621.14, wave32), Intel Core i5-11400F, 32 GB RAM, Windows 11 Home build 26200, Rust1.100.0(stable-x86_64-pc-windows-msvc), DXC1.9.2609.5(01b62ad4).origin/main5ce558fwith new test added, debug):cargo test -p xcl --lib gpu::dxil::lower_wide::rcp_d_tests::v_rcp_f64_and_v_rsq_f64_use_guarded_scaled_rcp_d -- --nocapture->0 passed; 1 failed(panicked:v_rcp_f64 must guard ±0 before dividingbecause unfixed Direct DXIL emitted barefdiv double 1.000000e+00, ...with nofcmp oeq doubleor scaling).4510bf84):cargo test --release -p xcl --lib gpu::dxil::lower_wide -- --nocapture->4 passed; 0 failed; 0 ignored(including bothv_rcp_f64_and_v_rsq_f64_use_guarded_scaled_rcp_dandgpu_direct_rcp_f64_and_rsq_f64_edgeson RTX 4060).XCL_DIRECT_DXIL=1 cargo test --release -p xcl --lib gpu_f64_roots -- --nocapture->1 passed; 0 failed; 0 ignored.cargo test --release -p xcl --lib f64_programs_on_the_gpu -- --nocapture->1 passed; 0 failed; 0 ignored(wave32 HLSL vs Direct DXIL bit-for-bit match; wave64 skippedno wave64).4510bf84):cargo build --release --workspace+cargo test --release --workspace -- --test-threads=4 --nocapture->1156 passed, 0 failed, 46 ignoredacross 21 test binaries.SKIPPEDlines (27 total, all pre-existing on this wave32 Windows host without Graphics Tools / Developer Mode / heap windows):no wave64skips (4ingpu::recomp::lower::tests,14ingpu::recomp::lower_dxil::tests,2ingpu::recomp::tests).per-lane form: refusedskips ingpu::recomp::lower_dxil::tests(f16 arithmetic,f16 packed,f32 conversions).test_title_draws_with_a_root_signature_under_the_debug_layer: nod3d12SDKLayers.dll;uploads_start_from_each_subresources_state:0x887A002D).shaders::tests::pso_measurement_compiles_an_exact_synthetic_record: cannot disable driver cache without Windows Developer Mode.heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows.Regression run
Paired 60 s retail title runs with
scripts/smoke.ps1(release build, same title, clean working tree) onorigin/main(cbc296ab) and this PR (4510bf84):main:this PR:
Not tested
1/NaNreturning0and1/DBL_MAXdenormal flushing were originally observed in #530), wave64 hardware, adapters without double-precision support, D3D12 debug layer, heap windows, and Linux/Wine.v_rcp_f64orv_rsq_f64under Direct DXIL; the paired smoke run is a regression check only.AI use
Google Antigravity (Gemini 4 Neon) wrote the fix, tests, and this PR description; all builds, tests, and paired retail smoke runs were executed locally on the hardware listed above.
@JJAutoCompare on GitHub · 2026-11-25 02:43 UTC · original
PR #2063 CPU/DXC verification
Tested
PR #2063 was open at
4510bf849fe4850894ef04ba8a227c2c4a6cd523before and after the run. The public conversation showed no comment or review anchors. The assigned checkout was clean at that SHA.Windows 11 Enterprise Evaluation 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, rustc and Cargo 1.100.0 (x86_64-pc-windows-msvc), unoptimized test profile with debug info disabled. The test logged dxcompiler 1.9.2609.5 (01b62ad4) and dxil 1.9.2609.5 loaded from the explicit DXC directory.
Result: 1 passed, 0 failed, 0 ignored, 0 skipped, 0 measured, 1,125 filtered out. Exit code 0. Cargo reported 1m 00s to finish the build and the harness reported 0.03s for the test. Wall time including build and test was 64.691s.
The fixture assembled separate
V_RCP_F64andV_RSQ_F64kernels and translated, validated, and disassembled both in wave32 and wave64 mode. Split mode was disabled and the fixture used one memory window and sampler base zero. In each wave mode, all five disassembly checks passed.fcmp oeq double(the zero-guard marker),@dx.op.unaryBits.i32(i32 33(the exponent-extraction marker), andfdiv double 1.000000e+00,.fmul doubleandselect i1in the text after the first matching reciprocal division (the rescaling and guard-selection markers).Not tested
GPU dispatch, shader FP64 execution, numerical accuracy, and per-input behavior including signed zero, infinities, NaNs, and subnormals. This Arc has no shader FP64 support. The checked test covers DXIL structure and DXC acceptance. The separate GPU edge-case test, HLSL backend, workspace suite, and title smoke tests were outside this run.
AI use
T3 Code / Codex (gpt-6.2-sol) verified the PR head, ran the checked-in test, and recorded the result.
@JoaoPauluu on GitHub · 2026-11-25 03:14 UTC · original
A run with vkd3d-proton as the host D3D12. The DXIL goes through dxil-spirv and then the NVIDIA Vulkan driver, a different compiler from a native-Windows run: this PR's 2 new tests pass.
Tested
x86_64-pc-windows-gnu.4510bf8as it is (merge base withmaincbc296a), no uncommitted changes. The lib test binary runs under Wine, one test per process.gpu_direct_rcp_f64_and_rsq_f64_edges: ok, not skippedv_rcp_f64_and_v_rsq_f64_use_guarded_scaled_rcp_d: ok, not skippedNot tested
AI use
@DarkPanda69 on GitHub · 2026-11-25 03:28 UTC · original
Native-wave64 AMD run on Windows, which this PR lists as not tested (#530's
1/NaNand denormal cases were seen on AMD; the reports above are CPU/DXC and NVIDIA).Tested: pass, head
4510bf8applied on its basemaincbc296a, debug, Rust 1.100.0, Windows 11 Pro 26200, Ryzen 7 5800X, DXC 1.9.2602.17.cargo test -p xcl --lib -- gpu:: --test-threads=4:gpu_direct_rcp_f64_and_rsq_f64_edgesok on the GPU. The 2 failures aregpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1and_3, the same as onmaincbc296awithout this PR on this card.Not tested: RDNA2/3, RADV.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@Parakeet-Wheat on GitHub · 2026-11-25 04:10 UTC · original
NVIDIA RTX 3070 on native Windows, head
4510bf8on its basecbc296a(currentmain): the DXIL-structure test fails without the change and passes with it, the GPU edge-case test passes either way on this card, the whole suite passes, and the smoke pair is within the limits. This adds a native-Windows FP64 GPU run, the fail-before run, the whole-suite counts and the smoke pair to the reports above.Tested
610.88, 32-lane waves, shader FP64 present), Ryzen 5 5600X, 32 GB, Windows 11 26300, Rust 1.95.0stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11, retail 1.0.2.1. Head4510bf8(one commit onmaincbc296a), checked out clean. Tests in the debug profile, smoke in release.cargo test -p xcl --lib rcp_d_tests -- --nocapture --test-threads=1:cbc296awith the PR'slower_wide.rsbut its threeLwhunks above the test module (v_rcp_f64,v_rsq_f64,rcp_d) reverted: 1 failed, 1 passed.v_rcp_f64_and_v_rsq_f64_use_guarded_scaled_rcp_dfails withv_rcp_f64 must guard ±0 before dividing.gpu_direct_rcp_f64_and_rsq_f64_edgespasses there too, not skipped: this driver returns the expected values for the edge inputs even from the unguarded division, so on this card only the disassembly test tells the two apart;4510bf8: 2 passed, 0 failed, not skipped..\scripts\test.ps1(cargo build --workspace, thencargo test --workspace -- --test-threads=4) on4510bf8: 1156 passed, 0 failed, 46 ignored, exit 0. SKIPPED, 25: 20 ×no wave64, 3 × per-lane form refused (V_CVT_F16_F32,V_PK_MUL_F16,V_MUL_F16: "its #1426 semantics differ from the console's"), 1 ×no heap windows, 1 × cannot disable the driver cache (Windows Developer Mode required).Regression run (
scripts/smoke.ps1 -Game <folder> -Seconds 60, the same title, back to back, menus, no input; unedited).maincbc296a:PR head
4510bf8:That is 100 % of
main's frames and 97 % of its peak commit. One run each; the59 59 17tail of the PR's run (against60 60 60onmain) is not something I repeated.Not tested
no wave64skips above), AMD, a world run (the smoke stays in the menus, so it does not show whether the title reaches av_rcp_f64orv_rsq_f64on an edge operand), the tests on game data (XCL_SAMPLE_*not set).AI use
@DavidM1911 on GitHub · 2026-11-25 04:55 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!
@SlopTart on GitHub · 2026-11-25 10:51 UTC · original
Linux/RADV run, the configuration this PR's tester list is missing.
Tested (RX 7900 XT, RDNA3, RADV NAVI31, Mesa 26.2.5, Proton Experimental wine-11.0, DXC 1.9.2609.5, release build, tests under wine,
vkd3d-proton.cacheremoved before each run; branch head4510bf8merged withmain629a30b2):gpu_f64set: 6 passed, 0 failed, default backendgpu_f64set: 6 passed, 0 failed,XCL_DIRECT_DXIL=1The before/after on this stack is direct. On
mainatcbc296abwithout this PR,gpu_f64_rootsfails deterministically here withv_rsq_f64(-1.5e0) = 0e0, want NaN(same for -1.84e19, -1e-300, -1e300), andgpu_f64_math_randomfails itsbad.is_empty()assertion. With theLw::rcp_dguard both pass. So the1/NaN -> 0behavior #530 describes does happen under Mesa 26.2.5/RADV as well, not only on the stacks reported there, and this PR's guard fixes it on AMD Linux too.Not tested: split-wave64 mode, other Mesa versions, native Linux (non-wine) runs.
Counts only, no game data.
AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.