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

Merged
pablogonz12 merged 1 commit from upstream-pr/530 into main 2026-11-25 01:17:50 +00:00
pablogonz12 commented 2026-11-24 01:26:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by pablogonz12 on 2026-11-24T01:26:18Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:6572492329 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/530). Originally posted by [pablogonz12](https://github.com/pablogonz12) on 2026-11-24T01:26:18Z. --- `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.
towiice commented 2026-11-24 06:58:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by towiice on 2026-11-24T01:32:40Z.

Review: COMMENTED


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), including gpu_f64_roots, gpu_f64_math_random, gpu_f64_compares_with_nan, gpu_f64_class_compare, and gpu_f64_rounding_and_conversions.

All f64 GPU and unit tests pass on Turing.

<!-- greyfinch-sync:ivall/xcl:review:6032290185 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/530#pullrequestreview-6032290185). Originally posted by [towiice](https://github.com/towiice) on 2026-11-24T01:32:40Z. **Review:** COMMENTED --- 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), including `gpu_f64_roots`, `gpu_f64_math_random`, `gpu_f64_compares_with_nan`, `gpu_f64_class_compare`, and `gpu_f64_rounding_and_conversions`. All f64 GPU and unit tests pass on Turing.
thehollowedone commented 2026-11-24 07:05:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-24T01:30:50Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7119172928 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/530#issuecomment-7119172928). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-24T01:30:50Z. --- **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.
arcwiser commented 2026-11-24 07:05:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by arcwiser on 2026-11-24T01:32:19Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7119198749 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/530#issuecomment-7119198749). Originally posted by [arcwiser](https://github.com/arcwiser) on 2026-11-24T01:32:19Z. --- 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.
CryingLaughing commented 2026-11-24 07:05:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CryingLaughing on 2026-11-24T01:33:17Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7119215161 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/530#issuecomment-7119215161). Originally posted by [CryingLaughing](https://github.com/CryingLaughing) on 2026-11-24T01:33:17Z. --- 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.
4MDomo commented 2026-11-24 07:05:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by 4MDomo on 2026-11-24T01:53:36Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7119553806 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/530#issuecomment-7119553806). Originally posted by [4MDomo](https://github.com/4MDomo) on 2026-11-24T01:53:36Z. --- 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.
nullmarsh commented 2026-11-24 07:05:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by nullmarsh on 2026-11-24T02:06:31Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7119761623 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/530#issuecomment-7119761623). Originally posted by [nullmarsh](https://github.com/nullmarsh) on 2026-11-24T02:06:31Z. --- 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.
tugasky commented 2026-11-24 07:05:33 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tugasky on 2026-11-24T02:20:38Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7120041834 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/530#issuecomment-7120041834). Originally posted by [tugasky](https://github.com/tugasky) on 2026-11-24T02:20:38Z. --- 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.
Tjabooo commented 2026-11-24 07:05:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Tjabooo on 2026-11-24T03:01:54Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7120705595 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/530#issuecomment-7120705595). Originally posted by [Tjabooo](https://github.com/Tjabooo) on 2026-11-24T03:01:54Z. --- 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.
Dolaned commented 2026-11-24 07:06:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Dolaned on 2026-11-24T05:12:05Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7122720053 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/530#issuecomment-7122720053). Originally posted by [Dolaned](https://github.com/Dolaned) on 2026-11-24T05:12:05Z. --- 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 commented 2026-11-24 07:06:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Dolaned on 2026-11-24T05:20:56Z.


Also have AI pro 9700s I can test on

<!-- greyfinch-sync:ivall/xcl:comment:7122863043 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/530#issuecomment-7122863043). Originally posted by [Dolaned](https://github.com/Dolaned) on 2026-11-24T05:20:56Z. --- Also have AI pro 9700s I can test on
crastinator commented 2026-11-24 08:03:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by crastinator on 2026-11-24T08:01:46Z.

Review: COMMENTED


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-209 dxgi; 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 main 1ec4c98, gpu_f64_roots and gpu_f64_math_random fail here the same way as in the PR description: v_rsq_f64 of every negative number, -inf and NaN gives 0 (1252 distinct failures in the random test).
  • At e6d5d33, both pass, and they also pass with the PR merged onto 1ec4c98.
  • Whole lib suite, one test per process (see note): main 664 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 to main after its base 508a0c7. The 2 that still fail are gpu_nonfused_mad_and_mac_prevent_fma_contraction (#676) and xma2_source_voice_decodes_and_manages_lifetime (#890), and both fail on main too.

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.
<!-- greyfinch-sync:ivall/xcl:review:6035607860 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/530#pullrequestreview-6035607860). Originally posted by [crastinator](https://github.com/crastinator) on 2026-11-24T08:01:46Z. **Review:** COMMENTED --- 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-209 `dxgi`; `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 `main` `1ec4c98`, `gpu_f64_roots` and `gpu_f64_math_random` fail here the same way as in the PR description: `v_rsq_f64` of every negative number, -inf and NaN gives 0 (`1252 distinct failures` in the random test). - At `e6d5d33`, both pass, and they also pass with the PR merged onto `1ec4c98`. - Whole lib suite, one test per process (see note): `main` 664 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 to `main` after its base `508a0c7`. The 2 that still fail are `gpu_nonfused_mad_and_mac_prevent_fma_contraction` (#676) and `xma2_source_voice_decodes_and_manages_lifetime` (#890), and both fail on `main` too. 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.
upstream-sync closed this pull request 2026-11-25 02:06:43 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!525
No description provided.