Recompiler: v_rcp_f64 and v_rsq_f64 keep NaN, infinities and denormals #530

Manually merged
github merged 1 commit from gh-pr/530/head into gh-pr/530/base 2026-11-26 04:24:44 +00:00
Owner

@⁠pablogonz12 on GitHub · 2026-11-24 01:26 UTC · original
pablogonz12:recomp-f64-rcp-rsq → main · +19 −4 · 2 files · 1 commits · merged 2026-11-25 01:17 UTC

v_rcp_f64 was translated as (1.0 / x) and v_rsq_f64 as (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_f64 of every negative number and of NaN was 0 instead of NaN, which is what gpu_f64_roots and gpu_f64_math_random report on main on 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: an rcp_d helper next to sqrt_d. It returns NaN, ±inf for ±0 and ±0 for ±inf itself (on the bits, with isnan_d / isinf_d), and for the rest divides the mantissa (x scaled into [0.5, 1) with frexp_exp_d / ldexp_d) as a precise divide and scales back with ldexp_d, so a result below 2^-1022 is a denormal. v_rcp_f64 is rcp_d(x), v_rsq_f64 is rcp_d(sqrt_d(x)).
  • crates/xcl/src/gpu/recomp/tests.rs: gpu_f64_roots also checks v_rcp_f64 over F64_EDGES (1 ulp); the translation test counts rcp_d(sqrt_d( instead of (double)1 / sqrt_d(.

Tested

  • AMD Radeon RX 9070 XT (RADV GFX1201, Mesa), AMD Ryzen 9 9900X, CachyOS (Linux 7.3), Wine 11.0 (Proton CachyOS) with vkd3d-proton v3.1 + the patch from #257, DXC 1.9.2609, Rust stable, release.
  • cargo test -p xcl --lib --release --target x86_64-pc-windows-gnu (llvm-mingw), test binary run under Wine with --test-threads=4:
    • this PR (e6d5d33): 637 passed, 3 failed, 21 ignored, no SKIPPED lines. Failing: gpu_nonfused_mad_and_mac_prevent_fma_contraction (#472), xma2_source_voice_decodes_and_manages_lifetime, pe::tests::parses_own_test_binary_tls (#464) – all three fail on main too.
    • main (508a0c7): 632 passed, 8 failed, 21 ignored: the same three, gpu_f64_roots and gpu_f64_math_random (fixed here), and placed_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 #343).
  • The 13 f64 tests (cargo test ... f64) with XCL_REQUIRE_GPU=1: 13 passed. The new gpu_f64_roots on main's emit.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.sh from #257 under Wine (not smoke.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 -eu instead of set -euo pipefail; the data: fallback as an if).

xcl-smoke v1
commit: 508a0c74d7c0625d6d2de8d24494e69dc2e1926f
gpu: AMD Radeon RX 9070 XT (RADV GFX1201)
title: Build
seconds: 60
exit: 0x0
frames shown: 11 (PresentX 17)
presents per 2 s (last 3): 0 1 1
device removals: 0
crashes: 0
peak commit: 0 MB
xcl-smoke v1
commit: e6d5d332b9787c59951194ee1d3066cb081a9e89
gpu: AMD Radeon RX 9070 XT (RADV GFX1201)
title: Build
seconds: 60
exit: 0x0
frames shown: 18 (PresentX 27)
presents per 2 s (last 3): 2 0 1
device removals: 0
crashes: 0
peak commit: 0 MB

Not tested

  • Windows, NVIDIA and Intel GPUs, and the native Windows AMD driver: only RADV through vkd3d-proton.
  • Whether any retail shader uses v_rcp_f64 / v_rsq_f64 on NaN or infinities; the frame counts above are not evidence either way.

AI use

  • Claude Code (Claude Opus 5.5): found the cause, wrote the change, the test changes and this description, and ran the commands above on the machine described.
**@⁠pablogonz12** on GitHub · 2026-11-24 01:26 UTC · [original](https://github.com/xcl-dev/xcl/pull/530) `pablogonz12:recomp-f64-rcp-rsq` → `main` · +19 −4 · 2 files · 1 commits · merged 2026-11-25 01:17 UTC `v_rcp_f64` was translated as `(1.0 / x)` and `v_rsq_f64` as `(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_f64` of every negative number and of NaN was 0 instead of NaN, which is what `gpu_f64_roots` and `gpu_f64_math_random` report on `main` on 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`: an `rcp_d` helper next to `sqrt_d`. It returns NaN, ±inf for ±0 and ±0 for ±inf itself (on the bits, with `isnan_d` / `isinf_d`), and for the rest divides the mantissa (x scaled into [0.5, 1) with `frexp_exp_d` / `ldexp_d`) as a `precise` divide and scales back with `ldexp_d`, so a result below 2^-1022 is a denormal. `v_rcp_f64` is `rcp_d(x)`, `v_rsq_f64` is `rcp_d(sqrt_d(x))`. - `crates/xcl/src/gpu/recomp/tests.rs`: `gpu_f64_roots` also checks `v_rcp_f64` over `F64_EDGES` (1 ulp); the translation test counts `rcp_d(sqrt_d(` instead of `(double)1 / sqrt_d(`. **Tested** - AMD Radeon RX 9070 XT (RADV GFX1201, Mesa), AMD Ryzen 9 9900X, CachyOS (Linux 7.3), Wine 11.0 (Proton CachyOS) with vkd3d-proton v3.1 + the patch from #257, DXC 1.9.2609, Rust stable, release. - `cargo test -p xcl --lib --release --target x86_64-pc-windows-gnu` (llvm-mingw), test binary run under Wine with `--test-threads=4`: - this PR (`e6d5d33`): 637 passed, 3 failed, 21 ignored, no `SKIPPED` lines. Failing: `gpu_nonfused_mad_and_mac_prevent_fma_contraction` (#472), `xma2_source_voice_decodes_and_manages_lifetime`, `pe::tests::parses_own_test_binary_tls` (#464) – all three fail on `main` too. - `main` (`508a0c7`): 632 passed, 8 failed, 21 ignored: the same three, `gpu_f64_roots` and `gpu_f64_math_random` (fixed here), and `placed_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 #343). - The 13 f64 tests (`cargo test ... f64`) with `XCL_REQUIRE_GPU=1`: 13 passed. The new `gpu_f64_roots` on `main`'s `emit.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.sh` from #257 under Wine (not `smoke.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 -eu` instead of `set -euo pipefail`; the `data:` fallback as an `if`). ``` xcl-smoke v1 commit: 508a0c74d7c0625d6d2de8d24494e69dc2e1926f gpu: AMD Radeon RX 9070 XT (RADV GFX1201) title: Build seconds: 60 exit: 0x0 frames shown: 11 (PresentX 17) presents per 2 s (last 3): 0 1 1 device removals: 0 crashes: 0 peak commit: 0 MB ``` ``` xcl-smoke v1 commit: e6d5d332b9787c59951194ee1d3066cb081a9e89 gpu: AMD Radeon RX 9070 XT (RADV GFX1201) title: Build seconds: 60 exit: 0x0 frames shown: 18 (PresentX 27) presents per 2 s (last 3): 2 0 1 device removals: 0 crashes: 0 peak commit: 0 MB ``` **Not tested** - Windows, NVIDIA and Intel GPUs, and the native Windows AMD driver: only RADV through vkd3d-proton. - Whether any retail shader uses `v_rcp_f64` / `v_rsq_f64` on NaN or infinities; the frame counts above are not evidence either way. **AI use** - Claude Code (Claude Opus 5.5): found the cause, wrote the change, the test changes and this description, and ran the commands above on the machine described.
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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:24:42 +00:00
github manually merged commit e6d5d332b9 into gh-pr/530/base 2026-11-26 04:24:44 +00:00
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-24 01:30 UTC · original

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 cargo test --offline --locked -p xcl --lib f64 -- --test-threads=1 --nocapture with XCL_REQUIRE_GPU=1 and separate build directories.

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.

**@⁠thehollowedone** on GitHub · 2026-11-24 01:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/530#issuecomment-7119172928) **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](https://github.com/ivall/xcl/commit/508a0c74d7c0625d6d2de8d24494e69dc2e1926f) and [PR head e6d5d33](https://github.com/ivall/xcl/commit/e6d5d332b9787c59951194ee1d3066cb081a9e89), I ran `cargo test --offline --locked -p xcl --lib f64 -- --test-threads=1 --nocapture` with `XCL_REQUIRE_GPU=1` and separate build directories. 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.
Author
Owner

@⁠arcwiser on GitHub · 2026-11-24 01:32 UTC · original

Tested exact head e6d5d332b9787c59951194ee1d3066cb081a9e89 on native Windows / NVIDIA.

  • With XCL_REQUIRE_GPU=1, cargo test -p xcl --lib f64 -- --test-threads=4 --nocapture: 13 passed, 0 failed, 0 ignored. This includes gpu_f64_roots and gpu_f64_math_random; the randomized test reported 0 distinct failures (rsq ulps 0/1/2/>2: [1584, 16, 0, 0]).
  • .\scripts\test.ps1: workspace build passed; 680 passed, 0 failed, 41 ignored.
  • GPU tests reported 2 skips (both no wave64): gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware. These skips are not counted as coverage.
  • XCL_SAMPLE_* variables were unset, so optional game-data tests did not run. I did not run a retail-title smoke comparison.

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.

**@⁠arcwiser** on GitHub · 2026-11-24 01:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/530#issuecomment-7119198749) Tested exact head `e6d5d332b9787c59951194ee1d3066cb081a9e89` on native Windows / NVIDIA. - With `XCL_REQUIRE_GPU=1`, `cargo test -p xcl --lib f64 -- --test-threads=4 --nocapture`: **13 passed, 0 failed, 0 ignored**. This includes `gpu_f64_roots` and `gpu_f64_math_random`; the randomized test reported **0 distinct failures** (`rsq` ulps 0/1/2/>2: `[1584, 16, 0, 0]`). - `.\scripts\test.ps1`: workspace build passed; **680 passed, 0 failed, 41 ignored**. - GPU tests reported **2 skips** (both `no wave64`): `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware`. These skips are not counted as coverage. - `XCL_SAMPLE_*` variables were unset, so optional game-data tests did not run. I did not run a retail-title smoke comparison. 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.
Author
Owner

@⁠CryingLaughing on GitHub · 2026-11-24 01:33 UTC · original

The exact head e6d5d332b9787c59951194ee1d3066cb081a9e89 passed the Windows workspace suite on an RTX 4080. I also ran the expanded reciprocal edge-case fixture with the parent emitter restored. It passed on both, so I did not reproduce the RADV edge-case failures on this Windows driver.

Tested

  • RTX 4080 (Ada), NVIDIA driver 621.01, Core i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 MSVC x64, DXC 1.8.2502.11, debug. XCL_ADAPTER=4080, XCL_REQUIRE_GPU=1, synthetic fixtures, all XCL_SAMPLE_* variables unset. Separate Cargo target directories.
  • cargo test -p xcl --lib --locked -j 4 gpu_f64_roots -- --show-output passed 1/1 at the exact head and 1/1 with only crates/xcl/src/gpu/recomp/emit.rs restored from parent 508a0c74d7c0625d6d2de8d24494e69dc2e1926f. The PR fixture and reciprocal inputs were identical in both runs. Neither run skipped.
  • At the exact head, cargo build --workspace --locked -j 4 passed. cargo test --workspace --locked -j 4 -- --test-threads=4 --show-output reported 680 passed, 0 failed, 41 ignored, including all 13 tests with f64 in the name. The pass count includes opt-in game-data tests that returned early and four explicit skips.
  • SKIPPED for native wave64: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware. SKIPPED for D3D12 debug-layer availability: test_title_draws_with_a_root_signature_under_the_debug_layer and uploads_start_from_each_subresources_state.

Not tested

  • Release builds, retail smoke, native wave64, or other adapters on this machine.

AI use

  • OpenAI Codex (GPT-6 family, exact variant unavailable) ran the tests and drafted this report.
**@⁠CryingLaughing** on GitHub · 2026-11-24 01:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/530#issuecomment-7119215161) The exact head `e6d5d332b9787c59951194ee1d3066cb081a9e89` passed the Windows workspace suite on an RTX 4080. I also ran the expanded reciprocal edge-case fixture with the parent emitter restored. It passed on both, so I did not reproduce the RADV edge-case failures on this Windows driver. **Tested** - RTX 4080 (Ada), NVIDIA driver 621.01, Core i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 MSVC x64, DXC 1.8.2502.11, debug. `XCL_ADAPTER=4080`, `XCL_REQUIRE_GPU=1`, synthetic fixtures, all `XCL_SAMPLE_*` variables unset. Separate Cargo target directories. - `cargo test -p xcl --lib --locked -j 4 gpu_f64_roots -- --show-output` passed 1/1 at the exact head and 1/1 with only `crates/xcl/src/gpu/recomp/emit.rs` restored from parent `508a0c74d7c0625d6d2de8d24494e69dc2e1926f`. The PR fixture and reciprocal inputs were identical in both runs. Neither run skipped. - At the exact head, `cargo build --workspace --locked -j 4` passed. `cargo test --workspace --locked -j 4 -- --test-threads=4 --show-output` reported 680 passed, 0 failed, 41 ignored, including all 13 tests with `f64` in the name. The pass count includes opt-in game-data tests that returned early and four explicit skips. - `SKIPPED` for native wave64: `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware`. `SKIPPED` for D3D12 debug-layer availability: `test_title_draws_with_a_root_signature_under_the_debug_layer` and `uploads_start_from_each_subresources_state`. **Not tested** - Release builds, retail smoke, native wave64, or other adapters on this machine. **AI use** - OpenAI Codex (GPT-6 family, exact variant unavailable) ran the tests and drafted this report.
Author
Owner

@⁠4MDomo on GitHub · 2026-11-24 01:53 UTC · original

NVIDIA test report for e6d5d33 (this PR's head), native Windows D3D12.

Tested

  • NVIDIA GeForce RTX 3070, driver 32.0.16.1742; Intel i9-9900K, 32 GB; Windows 11 Home 10.0.26300 (native D3D12, no Wine); rustc 1.98.1 stable-x86_64-pc-windows-msvc; DXC 1.8.2502.11 (Windows SDK 10.0.26100.0); debug.
  • cargo test --workspace -- --test-threads=4 at e6d5d33: 680 passed, 0 failed, 41 ignored. gpu_f64_roots (with the new v_rcp_f64 checks over F64_EDGES) and gpu_f64_math_random pass.
  • On main 508a0c7 the same machine also passes gpu_f64_roots and gpu_f64_math_random (680 passed, 0 failed, 41 ignored), so the 1/NaN = 0 result does not show on NVIDIA's native driver. The PR keeps it passing there.
  • SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, as on main.

Not tested

  • A retail title; DXC 1.9 (this run used 1.8.2502).

AI use

  • Claude Code (Claude Opus 5.5) ran the suite and wrote this report; checked by me.
**@⁠4MDomo** on GitHub · 2026-11-24 01:53 UTC · [original](https://github.com/xcl-dev/xcl/pull/530#issuecomment-7119553806) NVIDIA test report for e6d5d33 (this PR's head), native Windows D3D12. **Tested** - NVIDIA GeForce RTX 3070, driver 32.0.16.1742; Intel i9-9900K, 32 GB; Windows 11 Home 10.0.26300 (native D3D12, no Wine); rustc 1.98.1 `stable-x86_64-pc-windows-msvc`; DXC 1.8.2502.11 (Windows SDK 10.0.26100.0); debug. - `cargo test --workspace -- --test-threads=4` at e6d5d33: 680 passed, 0 failed, 41 ignored. `gpu_f64_roots` (with the new `v_rcp_f64` checks over `F64_EDGES`) and `gpu_f64_math_random` pass. - On `main` 508a0c7 the same machine also passes `gpu_f64_roots` and `gpu_f64_math_random` (680 passed, 0 failed, 41 ignored), so the 1/NaN = 0 result does not show on NVIDIA's native driver. The PR keeps it passing there. - SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`, as on `main`. **Not tested** - A retail title; DXC 1.9 (this run used 1.8.2502). **AI use** - Claude Code (Claude Opus 5.5) ran the suite and wrote this report; checked by me.
Author
Owner

@⁠ghost on GitHub · 2026-11-24 02:06 UTC · original

Native Windows AMD run, since Not tested lists the native AMD driver: e6d5d33 merged onto main 9ce2070 (clean merge): pass. The negative control may matter for how this is tested, though.

Tested

  • AMD Radeon RX 9060 XT (RDNA4, native 64-lane waves), driver 32.0.32029.2010; Ryzen 7 5800X3D; Windows 11 Pro 26200; Rust 1.100.0 MSVC; DXC 1.9.2602.17; debug.
  • .\scripts\test.ps1: 684 passed, 0 failed, 41 ignored; no SKIPPED GPU tests.
  • XCL_REQUIRE_GPU=wave64,mesh cargo test -p xcl --lib f64: 13 passed, including gpu_f64_roots (this PR's rcp / rsq checks) and gpu_f64_math_random.
  • Negative control, merged tree with only emit.rs back on main: only unary_f64_math_vop1_and_vop3 (the HLSL text check, rcp_d(sqrt_d( count 0 vs 2) fails. All 9 gpu_f64_* tests still pass, including gpu_f64_roots with this PR's checks. So on the native AMD driver the old emission already gives the expected values for these inputs. The GPU test doesn't separate old from new here, and the difference you saw may be specific to RADV through vkd3d-proton. If the RADV failure has an input that isn't in gpu_f64_roots yet, adding it would tell us whether native AMD is affected.

AI use

  • Claude Code (Claude Opus 5.5) ran the commands and wrote this report from the logs; I checked it before posting.
**@⁠ghost** on GitHub · 2026-11-24 02:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/530#issuecomment-7119761623) Native Windows AMD run, since **Not tested** lists the native AMD driver: `e6d5d33` merged onto `main` `9ce2070` (clean merge): **pass**. The negative control may matter for how this is tested, though. **Tested** - AMD Radeon RX 9060 XT (RDNA4, native 64-lane waves), driver 32.0.32029.2010; Ryzen 7 5800X3D; Windows 11 Pro 26200; Rust 1.100.0 MSVC; DXC 1.9.2602.17; debug. - `.\scripts\test.ps1`: 684 passed, 0 failed, 41 ignored; no `SKIPPED` GPU tests. - `XCL_REQUIRE_GPU=wave64,mesh cargo test -p xcl --lib f64`: 13 passed, including `gpu_f64_roots` (this PR's `rcp` / `rsq` checks) and `gpu_f64_math_random`. - Negative control, merged tree with only `emit.rs` back on `main`: only `unary_f64_math_vop1_and_vop3` (the HLSL text check, `rcp_d(sqrt_d(` count 0 vs 2) fails. **All 9 `gpu_f64_*` tests still pass**, including `gpu_f64_roots` with this PR's checks. So on the native AMD driver the old emission already gives the expected values for these inputs. The GPU test doesn't separate old from new here, and the difference you saw may be specific to RADV through vkd3d-proton. If the RADV failure has an input that isn't in `gpu_f64_roots` yet, adding it would tell us whether native AMD is affected. **AI use** - Claude Code (Claude Opus 5.5) ran the commands and wrote this report from the logs; I checked it before posting.
Author
Owner

@⁠tugasky on GitHub · 2026-11-24 02:20 UTC · original

Your "Not tested" list names the native Windows driver, and that is what this machine is:
the same GPU as yours (RX 9070 XT, GFX1201) but Windows 11 and AMD's own driver through
Vulkan, not RADV/vkd3d-proton.

Machine: Windows 11 Pro 26300, Ryzen 7 9700X (8C/16T), Rust 1.98.0
x86_64-pc-windows-msvc, DXC 1.9.2602.17, Radeon RX 9070 XT (RDNA4, 16 GB), driver
32.0.32029.2010. Release build. Head e6d5d33 already has main (7ebf1b8) as an
ancestor, so nothing had to be merged.

The f64 GPU tests pass here. XCL_REQUIRE_GPU=1 cargo test -p xcl --lib --release -- f64 -- --test-threads=4 → 13 passed, 0 failed, including the extended gpu_f64_roots
(rcp over F64_EDGES at 1 ulp) and gpu_f64_math_random.

But the fix changes nothing on this driver, and that is the interesting part. main's
f64 tests pass here too, which by itself means little (they do not check v_rcp_f64), so
I took only your tests.rs onto main's emit.rs – a worktree at 7ebf1b8 with
git checkout e6d5d33 -- crates/xcl/src/gpu/recomp/tests.rs, nothing else, rebuilt – and
ran the same two tests against the old (1.0 / x): both pass. On the native AMD Windows
driver that divide already gives NaN for NaN, −0 for ±inf and a denormal for 1/DBL_MAX, so
the flush you measured on RADV does not exist here. That supports your diagnosis rather
than contradicting it: this is a portability fix, and my machine is the case where the old
translation happened to be right. A 1-ulp tolerance cannot be hiding your failure, which
was 0 instead of NaN, so the new test would have caught it here if it were reachable.

Does this title use the instruction at all? No. A throwaway scanner (decode the way the
recompiler does, count by opcode name) over the whole carved pack, all stages:

opcode programs uses
v_rcp_f64 0 0
v_rsq_f64 0 0
v_sqrt_f64 0 0
v_rcp_f32 (control) 17 393 424 863
v_rsq_f32 (control) 17 221 269 310

of 26 698 programs (26 503 containers, 0 undecoded dwords; the 13 210 wave64 VS/PS from
the #517 census are inside). f64 code does exist in this pack, but only in 5 compute
programs, and only as v_add_f64 (216 uses). So v_rcp_f64 and v_rsq_f64 never run for
this title on any driver – nor does v_sqrt_f64, which main already translates with
sqrt_d. The PR is right for the recompiler and for the test suite, but it cannot move a
frame of this title, and neither can the RADV bug it fixes.

Suite: cargo build --workspace --release, then
cargo test --workspace --release -- --test-threads=4 → 680 passed, 0 failed, 41
ignored
, no test skipped (701 on the #341/#517/#528 stack, which main does not have
yet). Without the workspace build first, the two e2e tests fail on the missing
xcl_testtitle.exe – their own guard, not your change.

Not tested: the Windows smoke run (needs the retail title on this machine), NVIDIA and
Intel, and anything on RADV.

No game data in this comment – only counts printed by the tool.

AI use: written with Cline; the runs are from my machine.

**@⁠tugasky** on GitHub · 2026-11-24 02:20 UTC · [original](https://github.com/xcl-dev/xcl/pull/530#issuecomment-7120041834) Your "Not tested" list names the native Windows driver, and that is what this machine is: the same GPU as yours (RX 9070 XT, GFX1201) but Windows 11 and AMD's own driver through Vulkan, not RADV/vkd3d-proton. **Machine:** Windows 11 Pro 26300, Ryzen 7 9700X (8C/16T), Rust 1.98.0 `x86_64-pc-windows-msvc`, DXC 1.9.2602.17, Radeon RX 9070 XT (RDNA4, 16 GB), driver 32.0.32029.2010. Release build. Head `e6d5d33` already has `main` (`7ebf1b8`) as an ancestor, so nothing had to be merged. **The f64 GPU tests pass here.** `XCL_REQUIRE_GPU=1 cargo test -p xcl --lib --release -- f64 -- --test-threads=4` → 13 passed, 0 failed, including the extended `gpu_f64_roots` (rcp over `F64_EDGES` at 1 ulp) and `gpu_f64_math_random`. **But the fix changes nothing on this driver**, and that is the interesting part. `main`'s f64 tests pass here too, which by itself means little (they do not check `v_rcp_f64`), so I took only your `tests.rs` onto `main`'s `emit.rs` – a worktree at `7ebf1b8` with `git checkout e6d5d33 -- crates/xcl/src/gpu/recomp/tests.rs`, nothing else, rebuilt – and ran the same two tests against the old `(1.0 / x)`: both pass. On the native AMD Windows driver that divide already gives NaN for NaN, −0 for ±inf and a denormal for 1/DBL_MAX, so the flush you measured on RADV does not exist here. That supports your diagnosis rather than contradicting it: this is a portability fix, and my machine is the case where the old translation happened to be right. A 1-ulp tolerance cannot be hiding your failure, which was 0 instead of NaN, so the new test would have caught it here if it were reachable. **Does this title use the instruction at all?** No. A throwaway scanner (decode the way the recompiler does, count by opcode name) over the whole carved pack, all stages: | opcode | programs | uses | |:--|--:|--:| | `v_rcp_f64` | 0 | 0 | | `v_rsq_f64` | 0 | 0 | | `v_sqrt_f64` | 0 | 0 | | `v_rcp_f32` (control) | 17 393 | 424 863 | | `v_rsq_f32` (control) | 17 221 | 269 310 | of 26 698 programs (26 503 containers, 0 undecoded dwords; the 13 210 wave64 VS/PS from the #517 census are inside). f64 code does exist in this pack, but only in 5 compute programs, and only as `v_add_f64` (216 uses). So `v_rcp_f64` and `v_rsq_f64` never run for this title on any driver – nor does `v_sqrt_f64`, which `main` already translates with `sqrt_d`. The PR is right for the recompiler and for the test suite, but it cannot move a frame of this title, and neither can the RADV bug it fixes. **Suite:** `cargo build --workspace --release`, then `cargo test --workspace --release -- --test-threads=4` → **680 passed, 0 failed, 41 ignored**, no test skipped (701 on the #341/#517/#528 stack, which `main` does not have yet). Without the workspace build first, the two `e2e` tests fail on the missing `xcl_testtitle.exe` – their own guard, not your change. **Not tested:** the Windows smoke run (needs the retail title on this machine), NVIDIA and Intel, and anything on RADV. No game data in this comment – only counts printed by the tool. **AI use:** written with Cline; the runs are from my machine.
Author
Owner

@⁠Tjabooo on GitHub · 2026-11-24 03:01 UTC · original

The setup this PR targets, RADV through vkd3d-proton, hasn't been tested yet. Here it is: e6d5d33 merged onto main dd2ae9a (clean merge), pass: it fixes both f64 failures there.

Tested

  • AMD Radeon RX 9070 XT (RDNA4, GFX1201), RADV / Mesa 26.2.6; Arch Linux; Wine 11.21 (Arch package, has kernel write watches); vkd3d-proton v3.1 with #257's vkd3d-proton-xcl.patch and -Db_ndebug=true, Wine's own dxgi; DXC 2026_09_29 (XCL_DXC_DIR); VKD3D_CONFIG=ignore_shared_fence.
  • Rust 1.100.0, cross-built for x86_64-pc-windows-gnu (mingw-w64 gcc 16.2), debug; tests run under Wine via CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER=wine.
  • cargo test -p xcl --lib --locked --target x86_64-pc-windows-gnu -- --test-threads=4, 0 GPU tests SKIPPED:
gpu_f64_roots gpu_f64_math_random lib suite
main dd2ae9a FAILED: v_rsq_f64 of every negative input, -inf and NaN gives 0e0, want NaN FAILED: 1,252 distinct failures, all rsq(<negative>) = 0e0, want NaN (at bdab194: 644 passed, 3 failed)
this PR on dd2ae9a ok ok 649 passed, 1 failed, 21 ignored

The one failure left with this PR, gpu_nonfused_mad_and_mac_prevent_fma_contraction, is unrelated and fails on main too: v_fma_f32 overflow control should stay fused, left: 2139095040 (+inf) / right: 1946157055. RADV through dxil-spirv computes that fma unfused, so it overflows.

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.

**@⁠Tjabooo** on GitHub · 2026-11-24 03:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/530#issuecomment-7120705595) The setup this PR targets, RADV through vkd3d-proton, hasn't been tested yet. Here it is: `e6d5d33` merged onto `main` `dd2ae9a` (clean merge), **pass**: it fixes both f64 failures there. **Tested** - AMD Radeon RX 9070 XT (RDNA4, GFX1201), RADV / Mesa 26.2.6; Arch Linux; Wine 11.21 (Arch package, has kernel write watches); vkd3d-proton v3.1 with #257's `vkd3d-proton-xcl.patch` and `-Db_ndebug=true`, Wine's own dxgi; DXC 2026_09_29 (`XCL_DXC_DIR`); `VKD3D_CONFIG=ignore_shared_fence`. - Rust 1.100.0, cross-built for `x86_64-pc-windows-gnu` (mingw-w64 gcc 16.2), debug; tests run under Wine via `CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER=wine`. - `cargo test -p xcl --lib --locked --target x86_64-pc-windows-gnu -- --test-threads=4`, 0 GPU tests SKIPPED: | | `gpu_f64_roots` | `gpu_f64_math_random` | lib suite | |---|---|---|---| | `main` `dd2ae9a` | FAILED: `v_rsq_f64` of every negative input, `-inf` and NaN gives `0e0`, want NaN | FAILED: 1,252 distinct failures, all `rsq(<negative>) = 0e0, want NaN` | (at `bdab194`: 644 passed, 3 failed) | | this PR on `dd2ae9a` | ok | ok | **649 passed, 1 failed**, 21 ignored | The one failure left with this PR, `gpu_nonfused_mad_and_mac_prevent_fma_contraction`, is unrelated and fails on `main` too: `v_fma_f32 overflow control should stay fused`, `left: 2139095040` (+inf) / `right: 1946157055`. RADV through dxil-spirv computes that fma unfused, so it overflows. **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.
Author
Owner

@⁠Dolaned on GitHub · 2026-11-24 05:12 UTC · original

Tested on RDNA2 as well: same fix, same result.

  • Steam Deck LCD (Van Gogh, RDNA2), SteamOS 3.9.5, Mesa 26.2.0-devel (RADV), stock Proton Experimental 11.0-20261112 (unpatched vkd3d-proton), DXC 1.9.2609
  • cross-built x86_64-pc-windows-msvc debug (Rust 1.100, clang-cl/lld-link, xwin SDK), each lib test run on its own under Proton
test 508a0c7 e6d5d33 (this PR)
gpu_f64_roots fail (v_rsq_f64(-1.5e0) = 0e0, want NaN, ...) pass, including the new v_rcp_f64 checks
gpu_f64_math_random fail (1252 distinct rsq failures) pass
unary_f64_math_vop1_and_vop3 pass pass

Whole lib suite on this PR: 633 passed, 2 failed, 21 ignored, 5 aborted. The failures and aborts are the ones main already has on this setup and aren't touched by this change: gpu_format_stores_atomics_global_lds (wave64 ds_bpermute, passes with XCL_SPLIT_WAVE64=1), xma2_source_voice_decodes_and_manages_lifetime, and five vkd3d-proton vtable asserts (heap, root signature, resource, fence x2). gpu_nonfused_mad_and_mac_prevent_fma_contraction and pe::tests::parses_own_test_binary_tls pass here.

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.

**@⁠Dolaned** on GitHub · 2026-11-24 05:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/530#issuecomment-7122720053) Tested on RDNA2 as well: same fix, same result. - Steam Deck LCD (Van Gogh, RDNA2), SteamOS 3.9.5, Mesa 26.2.0-devel (RADV), stock Proton Experimental 11.0-20261112 (unpatched vkd3d-proton), DXC 1.9.2609 - cross-built `x86_64-pc-windows-msvc` debug (Rust 1.100, clang-cl/lld-link, xwin SDK), each lib test run on its own under Proton | test | `508a0c7` | `e6d5d33` (this PR) | |---|---|---| | `gpu_f64_roots` | fail (`v_rsq_f64(-1.5e0) = 0e0, want NaN`, ...) | pass, including the new `v_rcp_f64` checks | | `gpu_f64_math_random` | fail (1252 distinct rsq failures) | pass | | `unary_f64_math_vop1_and_vop3` | pass | pass | Whole lib suite on this PR: 633 passed, 2 failed, 21 ignored, 5 aborted. The failures and aborts are the ones `main` already has on this setup and aren't touched by this change: `gpu_format_stores_atomics_global_lds` (wave64 `ds_bpermute`, passes with `XCL_SPLIT_WAVE64=1`), `xma2_source_voice_decodes_and_manages_lifetime`, and five vkd3d-proton vtable asserts (heap, root signature, resource, fence x2). `gpu_nonfused_mad_and_mac_prevent_fma_contraction` and `pe::tests::parses_own_test_binary_tls` pass here. 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.
Author
Owner

@⁠Dolaned on GitHub · 2026-11-24 05:20 UTC · original

Also have AI pro 9700s I can test on

**@⁠Dolaned** on GitHub · 2026-11-24 05:20 UTC · [original](https://github.com/xcl-dev/xcl/pull/530#issuecomment-7122863043) Also have AI pro 9700s I can test on
This discussion has been locked. Commenting is limited to contributors.
No description provided.