Repository navigation
Recompiler: v_rcp_f64 and v_rsq_f64 keep NaN, infinities and denormals - #530
Conversation
v_rcp_f64 was (1.0 / x) and v_rsq_f64 (1 / sqrt_d(x)). DXC marks a plain divide fast (no NaN, no infinities), and RADV (through vkd3d-proton) then gave 0 for 1/NaN: v_rsq_f64 of every negative number and of NaN was 0, not NaN (gpu_f64_roots, gpu_f64_math_random). 1/-inf was +0, and 1/DBL_MAX was flushed to 0 instead of a denormal. rcp_d takes NaN, ±0 and ±inf itself and divides the mantissa, precise, scaling back with ldexp_d; v_rsq_f64 is rcp_d(sqrt_d(x)). gpu_f64_roots checks v_rcp_f64 too.
|
Tested Native Windows D3D12 on RTX 3080 Ti (621.35), Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC, DXC 1.8.2502.11, debug. On both exact parent 508a0c7 and PR head e6d5d33, I ran Both revisions reported 13 passed, 0 failed, 0 ignored and no reported skips. The PR head passed the expanded root test with reciprocal edge cases. The randomized wave32 test covered 1,600 lanes on each revision. Reciprocal square root was exact on 1,584 lanes and within one ULP on the remaining 16 on both revisions. Not tested Full workspace, retail titles, native wave64, and identical reciprocal edge-case inputs on the old lowering. The parent ran its own unmodified tests. AI use Codex with GPT-6.2 Sol ran the tests and drafted this report. |
|
Tested exact head
Machine: Windows 11 Home build 26200; AMD Ryzen 5 7500F; NVIDIA GeForce RTX 4070 SUPER 12 GB, driver 610.88; Rust 1.100.0 MSVC; DXC 1.9.2602.17 from Windows SDK 10.0.28000.0; debug profile. AI use: OpenAI Codex with GPT-5 selected the verification scope, ran the commands, and drafted this report; I am posting only the measured results above. |
towiice
left a comment
There was a problem hiding this comment.
Tested PR head e6d5d33 on NVIDIA GeForce GTX 1650 SUPER (Turing / TU116, wave32, driver 610.88), Windows 11 build 10.0.26300 (26H2), Rust 1.100.0 (stable-x86_64-pc-windows-gnullvm), DXC v1.9.2609:
cargo test -p xcl --lib f64 -- --test-threads=4: 13 passed, 0 failed (1.25 s), includinggpu_f64_roots,gpu_f64_math_random,gpu_f64_compares_with_nan,gpu_f64_class_compare, andgpu_f64_rounding_and_conversions.
All f64 GPU and unit tests pass on Turing.
|
The exact head Tested
Not tested
AI use
|
|
NVIDIA test report for e6d5d33 (this PR's head), native Windows D3D12. Tested
Not tested
AI use
|
|
Native Windows AMD run, since Not tested lists the native AMD driver: Tested
AI use
|
|
Your "Not tested" list names the native Windows driver, and that is what this machine is: Machine: Windows 11 Pro 26300, Ryzen 7 9700X (8C/16T), Rust 1.98.0 The f64 GPU tests pass here. But the fix changes nothing on this driver, and that is the interesting part. Does this title use the instruction at all? No. A throwaway scanner (decode the way the
of 26 698 programs (26 503 containers, 0 undecoded dwords; the 13 210 wave64 VS/PS from Suite: Not tested: the Windows smoke run (needs the retail title on this machine), NVIDIA and No game data in this comment – only counts printed by the tool. AI use: written with Cline; the runs are from my machine. |
|
The setup this PR targets, RADV through vkd3d-proton, hasn't been tested yet. Here it is: Tested
The one failure left with this PR, Not tested: native Windows (others covered it above), NVIDIA under Wine, a retail title. No game files used. AI-assisted (Claude); every number above is from a run on this machine. |
|
Tested on RDNA2 as well: same fix, same result.
Whole lib suite on this PR: 633 passed, 2 failed, 21 ignored, 5 aborted. The failures and aborts are the ones Not tested: Windows, NVIDIA, a release build, any retail title. AI use: Claude (Claude Code) built and ran the tests on the Deck and drafted this; I checked it. |
|
Also have AI pro 9700s I can test on |
crastinator
left a comment
There was a problem hiding this comment.
Tested on RDNA2 under Wine (RADV), the GPU this PR wasn't run on.
Tested (head e6d5d33, and merged onto main 1ec4c98: no conflicts)
- AMD Radeon RX 6700 XT (RDNA2, gfx1031, RADV NAVI22, Mesa 26.3.1), Ryzen 7 5700X, Linux 7.3.5 (CachyOS)
- Wine: Proton Experimental 11.0-20261112 (its
files/bin/wine, kernel write watches), with its own vkd3d-proton (stock, not the #257 patch) and DXVK v3.1.1-209dxgi;VKD3D_CONFIG=ignore_shared_fence; DXC 1.9.2609 - Cross-built on Linux for
x86_64-pc-windows-msvc(clang-cl / lld-link 23.1.5, xwin SDK 10.0.26100), Rust 1.99.1, debug; the lib test binary run under Wine - On
main1ec4c98,gpu_f64_rootsandgpu_f64_math_randomfail here the same way as in the PR description:v_rsq_f64of every negative number, -inf and NaN gives 0 (1252 distinct failuresin the random test). - At
e6d5d33, both pass, and they also pass with the PR merged onto1ec4c98. - Whole lib suite, one test per process (see note):
main664 ok / 4 failed / 21 ignored / 5 aborted at the #241 assertion / 1 exits with code 5 (mid_list_write64_wait64_split_avoids_cycle_and_reuses_spares, right after its mid-list split; newer than this PR and probably the same stock-vkd3d-proton limit); PR head 633 ok / 2 failed / 21 ignored / 5 aborted. The only status changes in tests present on both sides are the two above, FAILED -> ok. The tests missing on the PR side were added tomainafter its base508a0c7. The 2 that still fail aregpu_nonfused_mad_and_mac_prevent_fma_contraction(#676) andxma2_source_voice_decodes_and_manages_lifetime(#890), and both fail onmaintoo.
Under stock vkd3d-proton, D3D12.X tests take down the test process (iface->lpVtbl == &d3d12_heap_vtbl, #241), so the suite was run one test per process: every test in the binary, each with --exact <name> --test-threads=1, compared against main the same way.
Not tested
- Windows, NVIDIA, a retail title. The full suite with a patched vkd3d-proton (the 5 aborting tests).
AI use
- Claude Code (Claude Opus 5.5) built the branches, ran the tests and wrote this report; I checked the results.
v_rcp_f64was translated as(1.0 / x)andv_rsq_f64as(1 / sqrt_d(x)). DXC marks a plain divide fast (no NaN, no infinities), and on RADV (through vkd3d-proton) the divide then gives 0 for 1/NaN:v_rsq_f64of every negative number and of NaN was 0 instead of NaN, which is whatgpu_f64_rootsandgpu_f64_math_randomreport onmainon this GPU. The same divide gave +0 for 1/-inf and flushed 1/DBL_MAX to 0 instead of a denormal.What is in it
crates/xcl/src/gpu/recomp/emit.rs: anrcp_dhelper next tosqrt_d. It returns NaN, ±inf for ±0 and ±0 for ±inf itself (on the bits, withisnan_d/isinf_d), and for the rest divides the mantissa (x scaled into [0.5, 1) withfrexp_exp_d/ldexp_d) as aprecisedivide and scales back withldexp_d, so a result below 2^-1022 is a denormal.v_rcp_f64isrcp_d(x),v_rsq_f64isrcp_d(sqrt_d(x)).crates/xcl/src/gpu/recomp/tests.rs:gpu_f64_rootsalso checksv_rcp_f64overF64_EDGES(1 ulp); the translation test countsrcp_d(sqrt_d(instead of(double)1 / sqrt_d(.Tested
cargo test -p xcl --lib --release --target x86_64-pc-windows-gnu(llvm-mingw), test binary run under Wine with--test-threads=4:e6d5d33): 637 passed, 3 failed, 21 ignored, noSKIPPEDlines. Failing:gpu_nonfused_mad_and_mac_prevent_fma_contraction(Recompiler: v_fma_f32 is not fused on AMD's RDNA1 driver (mad() left unfused) #472),xma2_source_voice_decodes_and_manages_lifetime,pe::tests::parses_own_test_binary_tls(TLS: xcl.exe built with MinGW and lld keeps its TLS directory #464) – all three fail onmaintoo.main(508a0c7): 632 passed, 8 failed, 21 ignored: the same three,gpu_f64_rootsandgpu_f64_math_random(fixed here), andplaced_title_textures_share_vram_and_preserve_pixels,transitions_apply_when_their_list_is_submitted,d32s8_targets_take_their_own_size_of_video_memory, which this PR does not touch and which passed in the PR's run (they look like the cross-test interference in Tests: gpu_sparse_vram_descriptors_buffers_and_xmem fails beside the title-texture tests since #288 #343).cargo test ... f64) withXCL_REQUIRE_GPU=1: 13 passed. The newgpu_f64_rootsonmain'semit.rs: FAILED –v_rcp_f64(NaN) = 0,v_rcp_f64(-inf) = 0(want -0),v_rcp_f64(DBL_MAX) = 0(want 5.56e-309),v_rsq_f64(<negative>) = 0(want NaN).Regression run
Made with
scripts/linux/smoke.shfrom #257 under Wine (notsmoke.ps1), MSVC builds (cargo xwin) of both commits, with a local copy of the script in which two lines are changed so that a run which does not reach its end still prints its block (set -euinstead ofset -euo pipefail; thedata:fallback as anif).Not tested
v_rcp_f64/v_rsq_f64on NaN or infinities; the frame counts above are not evidence either way.AI use