Recompiler: f16 results round to nearest even in the default mode (#111) #836

Open
joeypercia wants to merge 2 commits from upstream-pr/842 into main
joeypercia commented 2026-11-24 06:39:48 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by joeypercia on 2026-11-24T06:39:48Z.


In the default mode every f16 result narrowed from binary32 went through HLSL f32tof16, which rounds toward zero, so every inexact v_add/sub/sqrt/rcp/rsq/exp/log/ldexp_f16 result came out one binary16 step low and an overflow stopped at 65504 instead of inf. Native RDNA2 rounds to nearest even (@luckyteagirl's raw-ISA measurements on #672: ldexp(1, 20) = inf, subnormal ties to even). to_f16_expr now narrows with f32_to_f16_rm(e, 0u) in the default mode, the helper the multiplies already use (#166); under a dynamic rounding mode nothing changes. Part of #111.

Since #3243 every stage goes through the direct DXIL translator by default, and its to_f16 (dxil/prelude.rs) still narrowed with legacyF32ToF16: on main b10cc4c6 this PR's own tests failed on the default path and passed only with XCL_DIRECT_DXIL=0. A second commit gives the direct translator the same change: to_f16 rounds in the shader's mode, nearest even by default, and v_fract_f16 keeps its result below 1.0.

v_fract_f16 needs one extra step: fract_f clamps its binary32 result below 1.0, and 1 - 2^-24 narrows to 1.0 by nearest even, so its binary16 result is kept at 0x3BFF (#655 found this).

This supersedes #696 (add / sub only), as its author suggested on #111; its cases are covered by the census test below.

In a retail title. The same to_f16_expr narrows v_interp_p2_f16, v_fma_mixlo_f16 and v_fma_mixhi_f16, so in a program that does not change the rounding mode they round toward zero on main too, and this PR makes them round to nearest even. They are most of what it changes in a retail game: in the newer retail title's shaders.rpf (xcl shaders --json, 26 503 shaders) there are 59 367 v_interp_p2_f16 (4 776 shaders), 33 900 v_fma_mixlo_f16 (6 155) and 2 135 v_fma_mixhi_f16 (842), against a few hundred v_add/sub/mul/fma_f16 and no v_ldexp_f16 or v_fract_f16. (v_cvt_f16_f32, 38 871, already rounds to nearest even on main.) gpu_s_round_mode_controls_f16_rounding_across_modes checks v_fma_mixlo_f16 only in a program that changes the mode, where it already took the rounding path.

Measured for the mix ops (a local test, not in this PR, so the regression runs below stay on its head): v_fma_mixlo_f16 / v_fma_mixhi_f16 of x·1 + 0 with x = 1 + 2^-11 + 2^-20, no mode change in the program, give 0x3C00 (toward zero) on main 037aecd and 0x3C01 (nearest even) with this PR merged on it, on both GPUs below. v_interp_p2_f16 is from reading the emitter, not measured.

What is in it

  • crates/xcl/src/gpu/dxil/prelude.rs, crates/xcl/src/gpu/dxil/lower_wide.rs (second commit): the same two changes in the direct DXIL translator
  • crates/xcl/src/gpu/recomp/emit.rs: to_f16_expr rounds to nearest even in the default mode; v_fract_f16 keeps its result below 1.0 (only without OMOD)
  • crates/xcl/src/gpu/recomp/tests.rs:
    • gpu_f16_results_round_to_nearest_even_by_default: random inputs against an exact reference for add, sqrt, rcp, rsq, exp, log, ldexp and mul; fails on any toward-zero result of the exact ones (add, ldexp, mul) and prints the counts for the approximate ones
    • gpu_f16_unary_results_round_to_nearest_even: fixed inputs whose exact result sits 0.69–0.88 of a step above the lower neighbour (so a 1-ulp binary32 approximation can't change it), plus @upipibi's two ldexp cases from #672 (overflow to inf, a subnormal tie to even)
    • gpu_fract_f16_stays_below_one_with_nearest_even: -2^-14 and -2^-24 give 0x3BFF, NaN stays NaN

Tested

  • NVIDIA GeForce RTX 4070 Ti (Ada, wave32), driver 616.56; AMD Radeon iGPU (Ryzen 7 7800X3D, RDNA2, native wave64, no mesh shaders), driver 26.11.2; Windows 11 Pro 26200; Rust 1.100.0 MSVC; DXC 1.8.2502.11 (SDK 10.0.26100); debug for the tests, release for the smoke runs
  • On 86c32c31 (this PR rebased onto main b10cc4c6):
    • cargo test -p xcl --lib f16: 24 passed, 0 failed on both GPUs
    • negative control: without the second commit, on main's default path, gpu_f16_results_round_to_nearest_even_by_default and gpu_f16_unary_results_round_to_nearest_even fail on both GPUs (sqrt(0x3420) = 0x380F, want 0x3810); with XCL_DIRECT_DXIL=0 they pass
    • cargo test --workspace --no-fail-fast -- --test-threads=4, RTX 4070 Ti: 2607 passed, 4 failed, 49 ignored. The failures were e2e's two title tests and gpu_two_pass_cache_e2e, which need cargo build --workspace first; after it, cargo test -p xcl --test e2e --test gpu_two_pass_cache_e2e: 6 passed, 0 failed on both GPUs
    • RDNA2: the lib test binary is ended by XCL's fail-stop ("sparse upload preparation still failed after bounded retries", exit 0x80004005) partway through the suite, single-threaded too and with the test running then skipped; main b10cc4c6 ends the same way on this GPU. gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 783) fails here and on main alike. So the RDNA2 counts are not complete for this head
  • SKIPPED on the RTX 4070 Ti: 30, 21 of them no wave64; the rest no d3d12SDKLayers.dll (2), no heap windows, and direct-DXIL f16 / f32 per-lane forms refused for #1426's semantics

Regression run

RTX 4070 Ti, release builds, 60 s each, with XCL_PREPARE=0 on both (main's launch preparation of this title takes over 15 minutes on a cold cache here):

main:

xcl-smoke v1
commit: b10cc4c6766adc947c2054ada4a2af98be15108d
gpu: NVIDIA GeForce RTX 4070 Ti
title: e61570a3
seconds: 60
exit: 0x0
frames shown: 1489 (PresentX 1489)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15943 MB

PR:

xcl-smoke v1
commit: 86c32c314c0dfff72500893ed776357ab414e8ed
gpu: NVIDIA GeForce RTX 4070 Ti
title: e61570a3
seconds: 60
exit: 0x0
frames shown: 1616 (PresentX 1616)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15787 MB

Not tested

  • Whether the title's frames show a visible difference: the smoke runs stay in the menus and loading
  • v_fma_f16 / v_fmac_f16 / v_pk_fma_f16: rounding the f32 result to nearest even is closer than toward zero, but still not always single rounding (#111's FMA point; #128 handles the exact sum for directed modes)
  • v_fract_f16 with OMOD: narrowed to nearest even without the below-1.0 step (a scaled fraction can legitimately reach 1.0 or more); not checked on hardware
  • The RDNA2 suite past XCL's fail-stop (see Tested)
  • A run with the title's launch preparation (XCL_PREPARE on)

AI use

  • Claude Code with Claude Opus 5.5: wrote the fix (both commits), the tests and this description, and ran the tests and smoke runs above on my machine.
<!-- greyfinch-sync:ivall/xcl:issue:5467405956 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/842). Originally posted by [joeypercia](https://github.com/joeypercia) on 2026-11-24T06:39:48Z. --- In the default mode every f16 result narrowed from binary32 went through HLSL `f32tof16`, which rounds toward zero, so every inexact `v_add/sub/sqrt/rcp/rsq/exp/log/ldexp_f16` result came out one binary16 step low and an overflow stopped at 65504 instead of inf. Native RDNA2 rounds to nearest even (@luckyteagirl's raw-ISA measurements on #672: `ldexp(1, 20)` = inf, subnormal ties to even). `to_f16_expr` now narrows with `f32_to_f16_rm(e, 0u)` in the default mode, the helper the multiplies already use (#166); under a dynamic rounding mode nothing changes. Part of #111. Since #3243 every stage goes through the direct DXIL translator by default, and its `to_f16` (`dxil/prelude.rs`) still narrowed with `legacyF32ToF16`: on `main` `b10cc4c6` this PR's own tests failed on the default path and passed only with `XCL_DIRECT_DXIL=0`. A second commit gives the direct translator the same change: `to_f16` rounds in the shader's mode, nearest even by default, and `v_fract_f16` keeps its result below 1.0. `v_fract_f16` needs one extra step: `fract_f` clamps its binary32 result below 1.0, and `1 - 2^-24` narrows to 1.0 by nearest even, so its binary16 result is kept at `0x3BFF` (#655 found this). This supersedes #696 (add / sub only), as its author suggested on #111; its cases are covered by the census test below. **In a retail title.** The same `to_f16_expr` narrows `v_interp_p2_f16`, `v_fma_mixlo_f16` and `v_fma_mixhi_f16`, so in a program that does not change the rounding mode they round toward zero on `main` too, and this PR makes them round to nearest even. They are most of what it changes in a retail game: in the newer retail title's `shaders.rpf` (`xcl shaders --json`, 26 503 shaders) there are 59 367 `v_interp_p2_f16` (4 776 shaders), 33 900 `v_fma_mixlo_f16` (6 155) and 2 135 `v_fma_mixhi_f16` (842), against a few hundred `v_add/sub/mul/fma_f16` and no `v_ldexp_f16` or `v_fract_f16`. (`v_cvt_f16_f32`, 38 871, already rounds to nearest even on `main`.) `gpu_s_round_mode_controls_f16_rounding_across_modes` checks `v_fma_mixlo_f16` only in a program that changes the mode, where it already took the rounding path. Measured for the mix ops (a local test, not in this PR, so the regression runs below stay on its head): `v_fma_mixlo_f16` / `v_fma_mixhi_f16` of x·1 + 0 with x = 1 + 2^-11 + 2^-20, no mode change in the program, give `0x3C00` (toward zero) on `main` `037aecd` and `0x3C01` (nearest even) with this PR merged on it, on both GPUs below. `v_interp_p2_f16` is from reading the emitter, not measured. **What is in it** - `crates/xcl/src/gpu/dxil/prelude.rs`, `crates/xcl/src/gpu/dxil/lower_wide.rs` (second commit): the same two changes in the direct DXIL translator - `crates/xcl/src/gpu/recomp/emit.rs`: `to_f16_expr` rounds to nearest even in the default mode; `v_fract_f16` keeps its result below 1.0 (only without OMOD) - `crates/xcl/src/gpu/recomp/tests.rs`: - `gpu_f16_results_round_to_nearest_even_by_default`: random inputs against an exact reference for add, sqrt, rcp, rsq, exp, log, ldexp and mul; fails on any toward-zero result of the exact ones (add, ldexp, mul) and prints the counts for the approximate ones - `gpu_f16_unary_results_round_to_nearest_even`: fixed inputs whose exact result sits 0.69–0.88 of a step above the lower neighbour (so a 1-ulp binary32 approximation can't change it), plus @upipibi's two ldexp cases from #672 (overflow to inf, a subnormal tie to even) - `gpu_fract_f16_stays_below_one_with_nearest_even`: `-2^-14` and `-2^-24` give `0x3BFF`, NaN stays NaN **Tested** - NVIDIA GeForce RTX 4070 Ti (Ada, wave32), driver 616.56; AMD Radeon iGPU (Ryzen 7 7800X3D, RDNA2, native wave64, no mesh shaders), driver 26.11.2; Windows 11 Pro 26200; Rust 1.100.0 MSVC; DXC 1.8.2502.11 (SDK 10.0.26100); debug for the tests, release for the smoke runs - On `86c32c31` (this PR rebased onto `main` `b10cc4c6`): - `cargo test -p xcl --lib f16`: 24 passed, 0 failed on both GPUs - negative control: without the second commit, on `main`'s default path, `gpu_f16_results_round_to_nearest_even_by_default` and `gpu_f16_unary_results_round_to_nearest_even` fail on both GPUs (`sqrt(0x3420)` = `0x380F`, want `0x3810`); with `XCL_DIRECT_DXIL=0` they pass - `cargo test --workspace --no-fail-fast -- --test-threads=4`, RTX 4070 Ti: 2607 passed, 4 failed, 49 ignored. The failures were `e2e`'s two title tests and `gpu_two_pass_cache_e2e`, which need `cargo build --workspace` first; after it, `cargo test -p xcl --test e2e --test gpu_two_pass_cache_e2e`: 6 passed, 0 failed on both GPUs - RDNA2: the lib test binary is ended by XCL's fail-stop ("sparse upload preparation still failed after bounded retries", exit `0x80004005`) partway through the suite, single-threaded too and with the test running then skipped; `main` `b10cc4c6` ends the same way on this GPU. `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` (seed 783) fails here and on `main` alike. So the RDNA2 counts are not complete for this head - `SKIPPED` on the RTX 4070 Ti: 30, 21 of them `no wave64`; the rest `no d3d12SDKLayers.dll` (2), `no heap windows`, and direct-DXIL f16 / f32 per-lane forms refused for #1426's semantics **Regression run** RTX 4070 Ti, release builds, 60 s each, with `XCL_PREPARE=0` on both (`main`'s launch preparation of this title takes over 15 minutes on a cold cache here): main: ``` xcl-smoke v1 commit: b10cc4c6766adc947c2054ada4a2af98be15108d gpu: NVIDIA GeForce RTX 4070 Ti title: e61570a3 seconds: 60 exit: 0x0 frames shown: 1489 (PresentX 1489) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15943 MB ``` PR: ``` xcl-smoke v1 commit: 86c32c314c0dfff72500893ed776357ab414e8ed gpu: NVIDIA GeForce RTX 4070 Ti title: e61570a3 seconds: 60 exit: 0x0 frames shown: 1616 (PresentX 1616) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15787 MB ``` **Not tested** - Whether the title's frames show a visible difference: the smoke runs stay in the menus and loading - `v_fma_f16` / `v_fmac_f16` / `v_pk_fma_f16`: rounding the f32 result to nearest even is closer than toward zero, but still not always single rounding (#111's FMA point; #128 handles the exact sum for directed modes) - `v_fract_f16` with OMOD: narrowed to nearest even without the below-1.0 step (a scaled fraction can legitimately reach 1.0 or more); not checked on hardware - The RDNA2 suite past XCL's fail-stop (see Tested) - A run with the title's launch preparation (`XCL_PREPARE` on) **AI use** - Claude Code with Claude Opus 5.5: wrote the fix (both commits), the tests and this description, and ran the tests and smoke runs above on my machine.
Anon64 commented 2026-11-24 07:06:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Anon64 on 2026-11-24T06:51:20Z.


Regression runs for this PR's head feaeb7b and for its base main beaa245, on a retail title (same title, 60 s each), made with scripts/smoke.ps1 (release, clean tree at each commit) and pasted unedited, for Regression run.

main:

xcl-smoke v1
commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1636 (PresentX 1637)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18113 MB

this PR:

xcl-smoke v1
commit: feaeb7b0b437abfddcb6612f9d4bd1c853ebfb6a
gpu: NVIDIA GeForce RTX 3060
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1633 (PresentX 1633)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17753 MB

Tested

  • NVIDIA GeForce RTX 3060 12 GB (Ampere, driver 581.80, wave32), Intel Core i9-14900KF, Windows 11 25H2 26200.9974, Rust 1.90.0
  • cargo test -p xcl --lib f16 (debug) on feaeb7b: 15 passed, 0 failed, including gpu_f16_results_round_to_nearest_even_by_default, gpu_f16_unary_results_round_to_nearest_even and gpu_fract_f16_stays_below_one_with_nearest_even

Not tested

  • the whole suite on this machine
  • whether the title reaches these f16 results; this is a regression check only

Since this covers #696's add / sub, I'll close #696 once this one is merged.

Report written with Claude Code (Claude Opus 5.5) from runs on this machine.

<!-- greyfinch-sync:ivall/xcl:comment:7124359817 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/842#issuecomment-7124359817). Originally posted by [Anon64](https://github.com/Anon64) on 2026-11-24T06:51:20Z. --- Regression runs for this PR's head `feaeb7b` and for its base `main` `beaa245`, on a retail title (same title, 60 s each), made with `scripts/smoke.ps1` (release, clean tree at each commit) and pasted unedited, for **Regression run**. main: ``` xcl-smoke v1 commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2 gpu: NVIDIA GeForce RTX 3060 title: retail-title seconds: 60 exit: 0x0 frames shown: 1636 (PresentX 1637) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 18113 MB ``` this PR: ``` xcl-smoke v1 commit: feaeb7b0b437abfddcb6612f9d4bd1c853ebfb6a gpu: NVIDIA GeForce RTX 3060 title: retail-title seconds: 60 exit: 0x0 frames shown: 1633 (PresentX 1633) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 17753 MB ``` **Tested** - NVIDIA GeForce RTX 3060 12 GB (Ampere, driver 581.80, wave32), Intel Core i9-14900KF, Windows 11 25H2 26200.9974, Rust 1.90.0 - `cargo test -p xcl --lib f16` (debug) on `feaeb7b`: 15 passed, 0 failed, including `gpu_f16_results_round_to_nearest_even_by_default`, `gpu_f16_unary_results_round_to_nearest_even` and `gpu_fract_f16_stays_below_one_with_nearest_even` **Not tested** - the whole suite on this machine - whether the title reaches these f16 results; this is a regression check only Since this covers #696's add / sub, I'll close #696 once this one is merged. Report written with Claude Code (Claude Opus 5.5) from runs on this machine.
futurepro62 commented 2026-11-24 07:06:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T07:04:10Z.


Full-suite run to go with the smoke runs above, so the new GPU tests have a result on hardware. Tested exact head feaeb7b (on its base beaa245).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 716 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: gpu_f16_results_round_to_nearest_even_by_default, gpu_f16_unary_results_round_to_nearest_even, gpu_fract_f16_stays_below_one_with_nearest_even.

Not tested

  • AMD, a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7124580750 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/842#issuecomment-7124580750). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T07:04:10Z. --- Full-suite run to go with the smoke runs above, so the new GPU tests have a result on hardware. Tested exact head `feaeb7b` (on its base `beaa245`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4`: **716 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - The new tests ran and passed: `gpu_f16_results_round_to_nearest_even_by_default`, `gpu_f16_unary_results_round_to_nearest_even`, `gpu_fract_f16_stays_below_one_with_nearest_even`. **Not tested** - AMD, a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
zhouzhidong3-hash commented 2026-11-24 07:06:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by zhouzhidong3-hash on 2026-11-24T07:04:55Z.


Paired RTX 5070 Release check of the 11 raw binary16/exponent pairs from the native gfx1031 reference, using the same wave32 probe, driver 591.86 and DXC 1.8.2502.11 across runs.

Emitter Native matches Differences
#672 at 6ec4036 8/11 Both finite overflows and the 0x0003 / 2 halfway case
#842 at feaeb7b 8/11 ldexp(+0,32767), ldexp(+inf,-32768), ldexp(-inf,-32768) gave 0x7fff
#842 plus only the v_ldexp_f16 emitter arm from #672 11/11 None in this fixture

The #842 head corrects all three rounding differences from the #672 baseline. Its checked-in gpu_f16_results_round_to_nearest_even_by_default test also passed. The #842 emitter still calls HLSL ldexp for the f16 instruction; the third row locally substituted #672's ldexp_f call, leaving #842's narrowing in place. This is a focused combination check, not evidence that #842 introduced the extreme-exponent behavior. Default-mode synthetic cases only; no full-branch merge, wave64 or game run tested here. OpenAI Codex ran the comparison and drafted the report.

Integration check: the complete two-file #672 patch applied cleanly to feaeb7b. The Release f16 name-filtered suite on this local combination passed 16/16, with 681 filtered out and no runtime skip reported. The filter also matches UTF-16 tests. The relevant passes include the original ldexp, rounding census, unary rounding and fract fixtures from these two PRs. Full workspace and retail runs remain untested here.

<!-- greyfinch-sync:ivall/xcl:comment:7124594681 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/842#issuecomment-7124594681). Originally posted by [zhouzhidong3-hash](https://github.com/zhouzhidong3-hash) on 2026-11-24T07:04:55Z. --- Paired RTX 5070 Release check of the 11 raw binary16/exponent pairs from [the native gfx1031 reference](https://github.com/ivall/xcl/pull/672#issuecomment-7123466880), using the same wave32 probe, driver 591.86 and DXC 1.8.2502.11 across runs. | Emitter | Native matches | Differences | |---|---:|---| | #672 at 6ec4036 | 8/11 | Both finite overflows and the 0x0003 / 2 halfway case | | #842 at feaeb7b | 8/11 | ldexp(+0,32767), ldexp(+inf,-32768), ldexp(-inf,-32768) gave 0x7fff | | #842 plus only the v_ldexp_f16 emitter arm from #672 | 11/11 | None in this fixture | The #842 head corrects all three rounding differences from the #672 baseline. Its checked-in gpu_f16_results_round_to_nearest_even_by_default test also passed. The #842 emitter still calls HLSL ldexp for the f16 instruction; the third row locally substituted #672's ldexp_f call, leaving #842's narrowing in place. This is a focused combination check, not evidence that #842 introduced the extreme-exponent behavior. Default-mode synthetic cases only; no full-branch merge, wave64 or game run tested here. OpenAI Codex ran the comparison and drafted the report. Integration check: the complete two-file #672 patch applied cleanly to feaeb7b. The Release f16 name-filtered suite on this local combination passed 16/16, with 681 filtered out and no runtime skip reported. The filter also matches UTF-16 tests. The relevant passes include the original ldexp, rounding census, unary rounding and fract fixtures from these two PRs. Full workspace and retail runs remain untested here.
SlopTart commented 2026-11-24 08:03:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-24T07:17:40Z.


Linux / AMD RDNA3 datapoint.

Merged state: head feaeb7b onto main beaa245, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 706 passed, 10 failed, 41 ignored. Failures are the known Wine-lane set from my #42 rows plus #718 trio members; nothing here fails because of your change. Your three f16 round-to-nearest-even tests all pass on RDNA3 native wave64: gpu_f16_results_round_to_nearest_even_by_default, gpu_f16_unary_results_round_to_nearest_even, gpu_fract_f16_stays_below_one_with_nearest_even ok. Follow-on datapoint to my #696 row for the same f16 axis.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7124831543 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/842#issuecomment-7124831543). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-24T07:17:40Z. --- Linux / AMD RDNA3 datapoint. **Merged state:** head `feaeb7b` onto main `beaa245`, clean merge. **Full suite, `cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4`:** **706 passed, 10 failed, 41 ignored**. Failures are the known Wine-lane set from my #42 rows plus #718 trio members; nothing here fails because of your change. Your three f16 round-to-nearest-even tests all pass on RDNA3 native wave64: `gpu_f16_results_round_to_nearest_even_by_default`, `gpu_f16_unary_results_round_to_nearest_even`, `gpu_fract_f16_stays_below_one_with_nearest_even` ok. Follow-on datapoint to my #696 row for the same f16 axis. **Not tested:** retail titles (none here), Windows, RDNA4. Counts only, no game data. **Machine:** RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross `x86_64-pc-windows-gnu`, `XCL_NETWORK=0`, release profile, `--test-threads=4`. Linux rows: #42 / #718. AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.
eizispark commented 2026-11-24 09:07:00 +00:00 (Migrated from github.com)

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


Hardware check of feaeb7b0b437abfddcb6612f9d4bd1c853ebfb6a (verified clean merge with main 1c87b1d): pass.

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11, rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profile
  • cargo test --workspace -- --test-threads=4: 716 passed, 0 failed, 41 ignored (GPU tests skipped on this adapter: none)
  • Verified f16 nearest-even rounding & wave64 GPU tests (gpu_f16_results_round_to_nearest_even_by_default, gpu_f16_unary_results_round_to_nearest_even, gpu_fract_f16_stays_below_one_with_nearest_even, gpu_f16_defaults_to_round_to_nearest_even, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware): all ok; --nocapture census on RX 9070 XT recorded [N, 0, 0] ([nearest even, toward zero, neither]) across all 8 ops (add, sqrt, rcp, rsq, exp, log, ldexp, mul) in both wave64 and wave32

Regression run
main (beaa245):

xcl-smoke v1
commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1660 (PresentX 1660)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14862 MB

PR (feaeb7b):

xcl-smoke v1
commit: feaeb7b0b437abfddcb6612f9d4bd1c853ebfb6a
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1665 (PresentX 1665)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14858 MB

(Note: an initial cold-shader-cache smoke run exited early with 0xc0000409, presents per 2 s (last 3): 0 21 59, device removals: 0, crashes: 0, peak commit: 9490 MB during first-run DXC compilation; the immediate rerun above ran the full 60 s cleanly.)

Not tested

  • wave32-only GPUs (NVIDIA / Intel); gameplay past the menus

AI use

  • Antigravity (Gemini 4 Carbon) ran the build, test suite, and scripts/smoke.ps1 harness on this machine and formatted this report.
<!-- greyfinch-sync:ivall/xcl:comment:7125764218 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/842#issuecomment-7125764218). Originally posted by [eizispark](https://github.com/eizispark) on 2026-11-24T08:08:01Z. --- Hardware check of `feaeb7b0b437abfddcb6612f9d4bd1c853ebfb6a` (verified clean merge with `main` `1c87b1d`): **pass**. **Tested** - Hardware: AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11, `rustc 1.100.0 (0ef1bc386 2026-11-09)`, release + test profile - `cargo test --workspace -- --test-threads=4`: `716 passed, 0 failed, 41 ignored` (GPU tests skipped on this adapter: `none`) - Verified f16 nearest-even rounding & wave64 GPU tests (`gpu_f16_results_round_to_nearest_even_by_default`, `gpu_f16_unary_results_round_to_nearest_even`, `gpu_fract_f16_stays_below_one_with_nearest_even`, `gpu_f16_defaults_to_round_to_nearest_even`, `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`): all `ok`; `--nocapture` census on RX 9070 XT recorded `[N, 0, 0]` (`[nearest even, toward zero, neither]`) across all 8 ops (`add`, `sqrt`, `rcp`, `rsq`, `exp`, `log`, `ldexp`, `mul`) in both `wave64` and `wave32` **Regression run** `main` (`beaa245`): ``` xcl-smoke v1 commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2 gpu: AMD Radeon RX 9070 XT title: GTA6.Xbox.v1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1660 (PresentX 1660) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14862 MB ``` PR (`feaeb7b`): ``` xcl-smoke v1 commit: feaeb7b0b437abfddcb6612f9d4bd1c853ebfb6a gpu: AMD Radeon RX 9070 XT title: GTA6.Xbox.v1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1665 (PresentX 1665) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14858 MB ``` *(Note: an initial cold-shader-cache smoke run exited early with `0xc0000409`, `presents per 2 s (last 3): 0 21 59`, `device removals: 0`, `crashes: 0`, `peak commit: 9490 MB` during first-run DXC compilation; the immediate rerun above ran the full 60 s cleanly.)* **Not tested** - wave32-only GPUs (NVIDIA / Intel); gameplay past the menus **AI use** - Antigravity (Gemini 4 Carbon) ran the build, test suite, and `scripts/smoke.ps1` harness on this machine and formatted this report.
KENAJBBY commented 2026-11-24 10:04:43 +00:00 (Migrated from github.com)

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


Native RDNA2 (gfx1036): f16 add / sub round once, in every rounding mode

This is a hardware reference for the add / sub part of this PR (which covers #696 / #685). I ran the instructions on raw bits on an RDNA2 GPU under an explicitly set MODE (s_setreg_b32, read back with s_getreg_b32 before the instruction). Every result was compared with an exact integer reference: an f16 sum is exact in units of 2^-24, rounded once in the mode under test.

  • v_add_f16, v_sub_f16, v_subrev_f16 and v_pk_add_f16 (both halves) show 0 differences from a single correct rounding on 60,000 operand pairs, in each of 37 modes. The pairs lean towards ones that need rounding, plus ties, overflow, zero signs and subnormals. The modes are every f16 round mode × every f16 denorm mode × IEEE 0/1, plus f32 round, f32 denorm and DX10_CLAMP variations, which change nothing.
  • In the default mode (f16 RNE, f16 denormals on), this PR's binary32-sum-then-nearest-even model differs from the hardware on 0 of the 60,000 pairs, for all four instructions.
  • #696's five vectors, raw on the hardware at MODE 0x1C0, give exactly #696's expected bits:
a, b add sub subrev pk_add lo / hi
0x3C00, 0x1200 0x3C01 0x3BFE 0xBBFE 0x3C01 / 0x3C01
0x3C00, 0x0800 0x3C00 0x3C00 0xBC00 0x3C00 / 0x3C00
0xBC00, 0x9200 0xBC01 0xBBFE 0x3BFE 0xBC01 / 0xBC01
0x3C00, 0x1000 0x3C00 0x3BFF 0xBBFF 0x3C00 / 0x3C00
0x7BFF, 0x5000 0x7C00 0x7BFE 0xFBFE 0x7C00 / 0x7C00

Outside this PR's scope, for #111 and #73:

  • s_round_mode: the hardware writes MODE[3:0] = the immediate. s_round_mode 0..15 read back as MODE[3:0] = 0..15 with MODE[9:4] untouched, and s_denorm_mode n writes MODE[7:4] = n. So 0xC is f16/f64 round toward zero with f32 RNE, as #91 assumes; #73 listed this as unconfirmed. In 0xC the hardware rounds the f16 sum once toward zero. The dynamic-mode path (binary32 sum, then f32_to_f16_rm(…, 3)), as I model it, differs on 601 of the 60,000 pairs for v_add_f16, always where the binary32 sum is inexact. #111's three cases give the values #111 calls correct: 0x3C00 + 0x0001 toward +inf = 0x3C01, 0x4000 + 0x8001 RTZ = 0x3FFF, v_fma_f16(0x4000, 0x3C00, 0x8001) RTZ = 0x3FFF.
  • f16 denormal mode: with MODE[6] = 0 the hardware reads denormal f16 inputs as zero, and with MODE[7] = 0 it flushes denormal results. XCL always keeps f16 denormals, which is right if console shaders start with MODE[7:6] = 3. XCL does not read the entry mode (#73), and the pack has no s_denorm_mode.

Tested

  • AMD Radeon iGPU of a Ryzen 7 9800X3D (gfx1036, RDNA2), driver 32.0.21030.2001, AMD OpenCL 3652.0 (PAL,LC), native wave64; Windows 11 Pro 26200.
  • Inline asm in OpenCL C, one block per lane. It saves MODE, sets it with s_setreg_b32 hwreg(HW_REG_MODE, 0, 10), reads it back with s_getreg_b32 (checked against the requested value in every run), runs the instruction and restores MODE. Inputs: 4 instructions × 37 modes × 60,000 pairs.

Not tested

  • This PR's HLSL on my GPUs: I compared against a model of it (binary32 sum, then nearest even).
  • The PR's unary f16 results (sqrt, rcp, rsq, exp, log, ldexp), v_fma_f16, NaN / inf inputs; console hardware and its entry MODE.

AI use

  • Claude Code (Claude Opus 5.5) wrote the probe and the reference, ran them on this machine and drafted this comment.
<!-- greyfinch-sync:ivall/xcl:comment:7127524349 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/842#issuecomment-7127524349). Originally posted by [KENAJBBY](https://github.com/KENAJBBY) on 2026-11-24T09:31:06Z. --- **Native RDNA2 (`gfx1036`): f16 add / sub round once, in every rounding mode** This is a hardware reference for the add / sub part of this PR (which covers #696 / #685). I ran the instructions on raw bits on an RDNA2 GPU under an explicitly set MODE (`s_setreg_b32`, read back with `s_getreg_b32` before the instruction). Every result was compared with an exact integer reference: an f16 sum is exact in units of 2^-24, rounded once in the mode under test. - `v_add_f16`, `v_sub_f16`, `v_subrev_f16` and `v_pk_add_f16` (both halves) show **0 differences from a single correct rounding** on 60,000 operand pairs, in each of 37 modes. The pairs lean towards ones that need rounding, plus ties, overflow, zero signs and subnormals. The modes are every f16 round mode × every f16 denorm mode × IEEE 0/1, plus f32 round, f32 denorm and DX10_CLAMP variations, which change nothing. - In the default mode (f16 RNE, f16 denormals on), this PR's binary32-sum-then-nearest-even model differs from the hardware on **0 of the 60,000** pairs, for all four instructions. - #696's five vectors, raw on the hardware at MODE `0x1C0`, give exactly #696's expected bits: | a, b | add | sub | subrev | pk_add lo / hi | |---|---|---|---|---| | `0x3C00`, `0x1200` | `0x3C01` | `0x3BFE` | `0xBBFE` | `0x3C01` / `0x3C01` | | `0x3C00`, `0x0800` | `0x3C00` | `0x3C00` | `0xBC00` | `0x3C00` / `0x3C00` | | `0xBC00`, `0x9200` | `0xBC01` | `0xBBFE` | `0x3BFE` | `0xBC01` / `0xBC01` | | `0x3C00`, `0x1000` | `0x3C00` | `0x3BFF` | `0xBBFF` | `0x3C00` / `0x3C00` | | `0x7BFF`, `0x5000` | `0x7C00` | `0x7BFE` | `0xFBFE` | `0x7C00` / `0x7C00` | Outside this PR's scope, for #111 and #73: - **`s_round_mode`**: the hardware writes MODE[3:0] = the immediate. `s_round_mode 0..15` read back as MODE[3:0] = 0..15 with MODE[9:4] untouched, and `s_denorm_mode n` writes MODE[7:4] = n. So `0xC` is f16/f64 round toward zero with f32 RNE, as #91 assumes; #73 listed this as unconfirmed. In `0xC` the hardware rounds the f16 sum once toward zero. The dynamic-mode path (binary32 sum, then `f32_to_f16_rm(…, 3)`), as I model it, differs on 601 of the 60,000 pairs for `v_add_f16`, always where the binary32 sum is inexact. #111's three cases give the values #111 calls correct: `0x3C00 + 0x0001` toward +inf = `0x3C01`, `0x4000 + 0x8001` RTZ = `0x3FFF`, `v_fma_f16(0x4000, 0x3C00, 0x8001)` RTZ = `0x3FFF`. - **f16 denormal mode**: with MODE[6] = 0 the hardware reads denormal f16 inputs as zero, and with MODE[7] = 0 it flushes denormal results. XCL always keeps f16 denormals, which is right if console shaders start with MODE[7:6] = 3. XCL does not read the entry mode (#73), and the pack has no `s_denorm_mode`. **Tested** - AMD Radeon iGPU of a Ryzen 7 9800X3D (`gfx1036`, RDNA2), driver 32.0.21030.2001, AMD OpenCL `3652.0 (PAL,LC)`, native wave64; Windows 11 Pro 26200. - Inline asm in OpenCL C, one block per lane. It saves MODE, sets it with `s_setreg_b32 hwreg(HW_REG_MODE, 0, 10)`, reads it back with `s_getreg_b32` (checked against the requested value in every run), runs the instruction and restores MODE. Inputs: 4 instructions × 37 modes × 60,000 pairs. **Not tested** - This PR's HLSL on my GPUs: I compared against a model of it (binary32 sum, then nearest even). - The PR's unary f16 results (sqrt, rcp, rsq, exp, log, ldexp), `v_fma_f16`, NaN / inf inputs; console hardware and its entry MODE. **AI use** - Claude Code (Claude Opus 5.5) wrote the probe and the reference, ran them on this machine and drafted this comment.
JJAutoCompare commented 2026-11-25 07:05:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T06:57:31Z.


Tested

Clean detached PR head feaeb7b0b437abfddcb6612f9d4bd1c853ebfb6a on STOR-WINLAB. Windows 11 Enterprise Evaluation 25H2 x64 build 26200.9974, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust/Cargo 1.100.0 MSVC, DXC/DXIL 1.9.2609.5.

cargo test --locked -p xcl --lib --no-run built outside the Arc mutex in 1m 13s, exit 0. With XCL_ADAPTER=A770, XCL_DIRECT_DXIL=0 and DXC/DXIL 1.9.2609.5 configured, the following exact filters were run under Invoke-ArcTest.ps1 -Test.

$exe = 'L:/XclTooling/pr1801-e00963f-t3-3c561aa2/target/debug/build/xcl/77aca8ccb20e299f/out/xcl-77aca8ccb20e299f.exe'
& $exe gpu::recomp::tests::gpu_f16_results_round_to_nearest_even_by_default --exact --nocapture --test-threads=1
& $exe gpu::recomp::tests::gpu_f16_unary_results_round_to_nearest_even --exact --nocapture --test-threads=1
& $exe gpu::recomp::tests::gpu_fract_f16_stays_below_one_with_nearest_even --exact --nocapture --test-threads=1

3 passed, 0 failed, 0 ignored, 0 skipped, 695 filtered out per invocation. Native and wrapper exits were 0. On standalone wave32, 4,727 inexact results matched nearest-even across eight operations, with assertions enforcing 2,041 add/ldexp/multiply cases. The unary and fract fixtures passed 224 and 32 lane comparisons respectively, including overflow, a subnormal tie, clamping below one and NaN preservation.

Not tested

Split or native wave64, direct DXIL, other adapters, negative controls, full workspace suite, and retail smoke.

AI use

T3 Code / Codex (gpt-6.2-sol) ran the verification and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7155336091 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/842#issuecomment-7155336091). Originally posted by [JJAutoCompare](https://github.com/JJAutoCompare) on 2026-11-25T06:57:31Z. --- **Tested** Clean detached PR head `feaeb7b0b437abfddcb6612f9d4bd1c853ebfb6a` on STOR-WINLAB. Windows 11 Enterprise Evaluation 25H2 x64 build 26200.9974, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust/Cargo 1.100.0 MSVC, DXC/DXIL 1.9.2609.5. `cargo test --locked -p xcl --lib --no-run` built outside the Arc mutex in 1m 13s, exit 0. With `XCL_ADAPTER=A770`, `XCL_DIRECT_DXIL=0` and DXC/DXIL 1.9.2609.5 configured, the following exact filters were run under `Invoke-ArcTest.ps1 -Test`. ```powershell $exe = 'L:/XclTooling/pr1801-e00963f-t3-3c561aa2/target/debug/build/xcl/77aca8ccb20e299f/out/xcl-77aca8ccb20e299f.exe' & $exe gpu::recomp::tests::gpu_f16_results_round_to_nearest_even_by_default --exact --nocapture --test-threads=1 & $exe gpu::recomp::tests::gpu_f16_unary_results_round_to_nearest_even --exact --nocapture --test-threads=1 & $exe gpu::recomp::tests::gpu_fract_f16_stays_below_one_with_nearest_even --exact --nocapture --test-threads=1 ``` **3 passed, 0 failed, 0 ignored, 0 skipped**, 695 filtered out per invocation. Native and wrapper exits were 0. On standalone wave32, 4,727 inexact results matched nearest-even across eight operations, with assertions enforcing 2,041 add/ldexp/multiply cases. The unary and fract fixtures passed 224 and 32 lane comparisons respectively, including overflow, a subnormal tie, clamping below one and NaN preservation. **Not tested** Split or native wave64, direct DXIL, other adapters, negative controls, full workspace suite, and retail smoke. **AI use** T3 Code / Codex (`gpt-6.2-sol`) ran the verification and wrote this report.
DavidM1911 commented 2026-11-25 11:09:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T10:27:48Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7159729041 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/842#issuecomment-7159729041). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T10:27:48Z. --- 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!
throny commented 2026-11-28 02:13:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-28T02:13:54Z.


merge-check claim
head: feaeb7b0b4

<!-- greyfinch-sync:ivall/xcl:comment:7232221982 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/842#issuecomment-7232221982). Originally posted by [throny](https://github.com/throny) on 2026-11-28T02:13:54Z. --- merge-check claim head: feaeb7b0b437abfddcb6612f9d4bd1c853ebfb6a
throny commented 2026-11-28 02:30:28 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-28T02:30:28Z.


merge-check
base: 753e8b1a
head: feaeb7b0b4
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1515 passed, 0 failed, 47 ignored (the suite runs the HLSL backend; see the review for the other one) (26 SKIPPED lines); base alone: 1512 passed, 0 failed, 47 ignored
review: one thing to fix: the direct-DXIL backend is not updated. gpu/dxil/prelude.rs Lw::to_f16, which is documented to compute the same bits as the HLSL helper, still converts with f32_to_f16 (round toward zero), and the fract change is not mirrored either; the PR does not touch that file. With XCL_DIRECT_DXIL=1 the two backends would then disagree on every default-mode f16 result, and the PR's three new tests would fail in that mode (by reading the code; not run here). The rounding helper itself is right: ties to even, the carry to infinity just below 65536, subnormal ties; double rounding through binary32 is harmless for add, mul and sqrt. Open from the thread, not caused by this PR: ldexp at extreme exponents.
performance: default path, and not measured beyond a 60 s run in the thread: every default-mode f16 result (the PR counts about 95,000 instances across the title's shaders, interpolation and fused multiply-add included) now goes through a software conversion of about 20 ALU operations with branches instead of the intrinsic, which can cost pixel-shader time. It changes a translator source: every tester re-translates all shaders once.
verdict: not yet: mirror the change in the direct-DXIL helper (and its fract path), and a longer frame-time comparison on a title. I will rerun on the new head and can add a world run on NVIDIA.
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K (no SSE4a), Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

<!-- greyfinch-sync:ivall/xcl:comment:7232407981 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/842#issuecomment-7232407981). Originally posted by [throny](https://github.com/throny) on 2026-11-28T02:30:28Z. --- merge-check base: 753e8b1a head: feaeb7b0b437abfddcb6612f9d4bd1c853ebfb6a merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 1515 passed, 0 failed, 47 ignored (the suite runs the HLSL backend; see the review for the other one) (26 SKIPPED lines); base alone: 1512 passed, 0 failed, 47 ignored review: one thing to fix: the direct-DXIL backend is not updated. gpu/dxil/prelude.rs Lw::to_f16, which is documented to compute the same bits as the HLSL helper, still converts with f32_to_f16 (round toward zero), and the fract change is not mirrored either; the PR does not touch that file. With XCL_DIRECT_DXIL=1 the two backends would then disagree on every default-mode f16 result, and the PR's three new tests would fail in that mode (by reading the code; not run here). The rounding helper itself is right: ties to even, the carry to infinity just below 65536, subnormal ties; double rounding through binary32 is harmless for add, mul and sqrt. Open from the thread, not caused by this PR: ldexp at extreme exponents. performance: default path, and not measured beyond a 60 s run in the thread: every default-mode f16 result (the PR counts about 95,000 instances across the title's shaders, interpolation and fused multiply-add included) now goes through a software conversion of about 20 ALU operations with branches instead of the intrinsic, which can cost pixel-shader time. It changes a translator source: every tester re-translates all shaders once. verdict: not yet: mirror the change in the direct-DXIL helper (and its fract path), and a longer frame-time comparison on a title. I will rerun on the new head and can add a world run on NVIDIA. hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K (no SSE4a), Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
KOLESNiii commented 2026-11-28 10:19:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T10:19:29Z.


merge-check claim
head: feaeb7b0b4

<!-- greyfinch-sync:ivall/xcl:comment:7237821467 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/842#issuecomment-7237821467). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-28T10:19:29Z. --- merge-check claim head: feaeb7b0b437abfddcb6612f9d4bd1c853ebfb6a
KOLESNiii commented 2026-11-28 11:37:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-28T11:37:49Z.


merge-check
base: e429936c10
head: feaeb7b0b4
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2129 passed, 9 failed, 48 ignored, 25 SKIPPED: 21 no wave64, 3 per-lane f16/f32 forms refused (#1426 semantics), 1 no heap windows; failing: gpu::dxil::module::split::tests::dispatch_chain_oversized_loop_matches_whole, gpu::dxil::module::split::tests::dispatch_chain_wave32_live_loops, gpu::dxil::module::split::tests::dispatch_chain_wave64_live_loops_and_exchange, gpu::recomp::heap_window_tests::gpu_heap_flat_reads_match_guarded_and_root_output, gpu::recomp::tests::gpu_compute_mode_dispatch_abi, gpu::recomp::tests::gpu_float_cas_uses_ieee_equality, test_title_draws_with_a_root_signature_under_the_debug_layer, test_title_runs_and_game_folder_is_untouched, test_title_runs_under_the_debug_layer_with_dred: these 9 fail on the base too (the base e429936c's suite, run alone on this PC with the same command: 2126 passed, 9 failed, 48 ignored, 25 SKIPPED, these same 9 failing), and each also failed when rerun alone on this merge (the two debug-layer e2e tests stop on the D3D12 debug layer rejecting a pixel shader as corrupt or unsigned, and test_title_runs_and_game_folder_is_untouched on the test title's console command list memory-methods check, "post-Wait32/64 write failed"); not caused by this PR. The suite ran on this PC at the same time as 3 other PRs' suites, in one queued job.
review: none. Whole diff read (emit.rs: to_f16_expr always narrows through f32_to_f16_rm, nearest even in the default mode instead of legacy f32tof16's toward zero, the dynamic mode unchanged; v_fract_f16 without omod keeps a result that narrows to 1.0 at 0x3BFF; tests.rs: an exact binary16 rounding reference, a census of add / sqrt / rcp / rsq / exp / log / ldexp / mul that fails only on the exact ops, fixed unary cases and fract cases). Every f16 result that went through to_f16_expr (VOP1/2/3 f16 arithmetic, v_interp_p2_f16, fma_mix, the f16 add helper) now rounds like v_mul_f16 already did; v_cvt_pkrtz_f16_f32 keeps its own toward-zero form; f32_to_f16_rm is in the always-included PRELUDE. Only the HLSL path changes; the direct DXIL path is not in this diff.
performance: reasoned, not measured: f32_to_f16_rm costs a few more ALU ops per f16 result than f32tof16, in shaders using f16 ops; translator output changes, so such shaders are translated again once.
verdict: safe to merge
hardware / tool and model: Windows 11 build 26300.9974, NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40, wave32 only), AMD Ryzen 5 3600XT; rustc 1.100.1 (20ddd0171 2026-11-25) x86_64-pc-windows-msvc, debug test profile; trial merge 3465b5a847f189eaca26d05f5f4a0549f898a05c (local, not pushed). Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft).
correction (2026-11-28): the base counts above were first given as 2128 passed: that base run reused this PC's merge test binary (one cargo target dir for both sides). The base was rerun with its own target dir; the same 9 tests fail on it, so the classification and the verdict stand.

<!-- greyfinch-sync:ivall/xcl:comment:7238678151 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/842#issuecomment-7238678151). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-28T11:37:49Z. --- merge-check base: e429936c10a5b8aa09470ff99dfc8c8d3d8c56fd head: feaeb7b0b437abfddcb6612f9d4bd1c853ebfb6a merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2129 passed, 9 failed, 48 ignored, 25 SKIPPED: 21 no wave64, 3 per-lane f16/f32 forms refused (#1426 semantics), 1 no heap windows; failing: gpu::dxil::module::split::tests::dispatch_chain_oversized_loop_matches_whole, gpu::dxil::module::split::tests::dispatch_chain_wave32_live_loops, gpu::dxil::module::split::tests::dispatch_chain_wave64_live_loops_and_exchange, gpu::recomp::heap_window_tests::gpu_heap_flat_reads_match_guarded_and_root_output, gpu::recomp::tests::gpu_compute_mode_dispatch_abi, gpu::recomp::tests::gpu_float_cas_uses_ieee_equality, test_title_draws_with_a_root_signature_under_the_debug_layer, test_title_runs_and_game_folder_is_untouched, test_title_runs_under_the_debug_layer_with_dred: these 9 fail on the base too (the base e429936c's suite, run alone on this PC with the same command: 2126 passed, 9 failed, 48 ignored, 25 SKIPPED, these same 9 failing), and each also failed when rerun alone on this merge (the two debug-layer e2e tests stop on the D3D12 debug layer rejecting a pixel shader as corrupt or unsigned, and test_title_runs_and_game_folder_is_untouched on the test title's console command list memory-methods check, "post-Wait32/64 write failed"); not caused by this PR. The suite ran on this PC at the same time as 3 other PRs' suites, in one queued job. review: none. Whole diff read (emit.rs: to_f16_expr always narrows through f32_to_f16_rm, nearest even in the default mode instead of legacy f32tof16's toward zero, the dynamic mode unchanged; v_fract_f16 without omod keeps a result that narrows to 1.0 at 0x3BFF; tests.rs: an exact binary16 rounding reference, a census of add / sqrt / rcp / rsq / exp / log / ldexp / mul that fails only on the exact ops, fixed unary cases and fract cases). Every f16 result that went through to_f16_expr (VOP1/2/3 f16 arithmetic, v_interp_p2_f16, fma_mix, the f16 add helper) now rounds like v_mul_f16 already did; v_cvt_pkrtz_f16_f32 keeps its own toward-zero form; f32_to_f16_rm is in the always-included PRELUDE. Only the HLSL path changes; the direct DXIL path is not in this diff. performance: reasoned, not measured: f32_to_f16_rm costs a few more ALU ops per f16 result than f32tof16, in shaders using f16 ops; translator output changes, so such shaders are translated again once. verdict: safe to merge hardware / tool and model: Windows 11 build 26300.9974, NVIDIA GeForce RTX 2070 SUPER 8 GB (driver 621.40, wave32 only), AMD Ryzen 5 3600XT; rustc 1.100.1 (20ddd0171 2026-11-25) x86_64-pc-windows-msvc, debug test profile; trial merge 3465b5a847f189eaca26d05f5f4a0549f898a05c (local, not pushed). Claude Code: Claude Opus 5.5 (coordination, full-diff review, draft). correction (2026-11-28): the base counts above were first given as 2128 passed: that base run reused this PC's merge test binary (one cargo target dir for both sides). The base was rerun with its own target dir; the same 9 tests fail on it, so the classification and the verdict stand.
Foniass commented 2026-12-01 04:17:15 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:17:15Z.


Triage (#1607) – head 86c32c3

Overlap: #1841 targets the same #111 default-mode truncation, but only for add/sub/fma/ldexp, and replaces mad with an fma_rto round-to-odd so fma is not double-rounded. This PR instead makes to_f16_expr (and Direct DXIL to_f16) round to nearest even for every f16 result, plus the v_fract_f16 0x3BFF clamp. The earlier group members #515 and #696 (single ops only) are closed. Main still uses f32tof16 in the non-dynamic to_f16_expr.
Two points: v_fma_f16/v_fmac_f16/v_pk_fma_f16 still go through mad in f32 and then RNE to f16, so a double rounding remains there (#1841 handles it); and every f16 result now takes the software f32_to_f16_rm(.., 0u) instead of the native conversion, a per-op ALU cost that is not measured in the description.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7300574387 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/842#issuecomment-7300574387). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T04:17:15Z. --- **Triage (#1607)** – head 86c32c3 Overlap: #1841 targets the same #111 default-mode truncation, but only for add/sub/fma/ldexp, and replaces `mad` with an `fma_rto` round-to-odd so fma is not double-rounded. This PR instead makes `to_f16_expr` (and Direct DXIL `to_f16`) round to nearest even for every f16 result, plus the `v_fract_f16` 0x3BFF clamp. The earlier group members #515 and #696 (single ops only) are closed. Main still uses `f32tof16` in the non-dynamic `to_f16_expr`. Two points: `v_fma_f16`/`v_fmac_f16`/`v_pk_fma_f16` still go through `mad` in f32 and then RNE to f16, so a double rounding remains there (#1841 handles it); and every f16 result now takes the software `f32_to_f16_rm(.., 0u)` instead of the native conversion, a per-op ALU cost that is not measured in the description. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
fromthemoonx commented 2026-12-03 10:35:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-03T10:35:51Z.


merge-check
base: 16c2fd082a
head: 86c32c314c
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3015 passed, 0 failed, 56 ignored (base: 3012 passed, 0 failed, 56 ignored, counted on 395405e4; only docs and scripts changed since); SKIPPED: 25, the same as base (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none
review: read the whole diff (4 files, +186 -14). No correctness finding; one open point, the cost (see performance).

  1. The results are right on this card in both translators. cargo test -p xcl --lib f16: 27 passed, 0 failed with XCL_DIRECT_DXIL=1 and with =0. The census test shows every inexact result of add, sqrt, rcp, rsq, exp, log, ldexp and mul at nearest even, none toward zero.
  2. throny's first point, the direct translator, is done: Lw::to_f16 and the v_fract_f16 step now match the HLSL side.
  3. Still open and named in the description: v_fma_f16 and its relatives round twice (#1841 is about that).
  4. Not tested: a retail title (none on this machine), AMD.
    performance: it adds shader work by default. I timed the HLSL helper alone on this RTX 3060: one group of 1024 threads, 1 million conversions each, whole dispatch by wall clock, best of 12.
conversion in the loop time added to the empty loop
none 89 ms
f32tof16 (main) 89 ms nothing measurable
f32_to_f16_rm(f, 0) (this PR) 357 ms 268 ms
a branch-free nearest-even form (below) 173 ms 84 ms

This says what one conversion costs, not what a frame costs. The default direct translator emits its own select-only version, which I did not time; it also computes the normal and the subnormal case for every value. The smoke pair in the description is at the 60 fps cap in the menus, so it cannot show the cost. The longer frame-time comparison throny asked for is still missing.

If the cost matters in a title, this form gives the same bits as f32_to_f16_rm(f, 0u) for all 4,294,967,296 binary32 inputs on this card (checked on the GPU; f32tof16 as a control differs for 2,248,098,814):

uint f32_to_f16_rne(float f) {
    uint x = asuint(f), ax = x & 0x7FFFFFFFu, sign = (x >> 16) & 0x8000u;
    uint n = (ax + 0xC8000FFFu + ((ax >> 13) & 1u)) >> 13;   // normal: rebias, ties to even
    precise float d = asfloat(ax) + 0.5f;                    // subnormal: the add does the rounding
    uint h = select(ax < 0x38800000u, asuint(d) - 0x3F000000u, n);
    h = select(ax >= 0x47800000u, 0x7C00u, h);
    h = select(ax > 0x7F800000u, 0x7E00u | ((ax >> 13) & 0x1FFu), h);
    return sign | h;
}

It is checked on NVIDIA only. It could also be a follow-up.
verdict: not yet: the rounding is correct, but the frame-time cost in a title's world is not measured (main against this head, below the 60 fps cap). With that comparison showing no real loss, I would call it safe to merge.
hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)

@joeypercia, the missing piece is that frame-time comparison, from anyone with a title that reaches the world.

<!-- greyfinch-sync:ivall/xcl:comment:7375469969 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/842#issuecomment-7375469969). Originally posted by [fromthemoonx](https://github.com/fromthemoonx) on 2026-12-03T10:35:51Z. --- merge-check base: 16c2fd082ae2e96967a2ab553bc2e1032e491f70 head: 86c32c314c0dfff72500893ed776357ab414e8ed merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3015 passed, 0 failed, 56 ignored (base: 3012 passed, 0 failed, 56 ignored, counted on 395405e4; only docs and scripts changed since); SKIPPED: 25, the same as base (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps); failing: none review: read the whole diff (4 files, +186 -14). No correctness finding; one open point, the cost (see performance). 1) The results are right on this card in both translators. `cargo test -p xcl --lib f16`: 27 passed, 0 failed with `XCL_DIRECT_DXIL=1` and with `=0`. The census test shows every inexact result of add, sqrt, rcp, rsq, exp, log, ldexp and mul at nearest even, none toward zero. 2) throny's first point, the direct translator, is done: `Lw::to_f16` and the `v_fract_f16` step now match the HLSL side. 3) Still open and named in the description: `v_fma_f16` and its relatives round twice (#1841 is about that). 4) Not tested: a retail title (none on this machine), AMD. performance: it adds shader work by default. I timed the HLSL helper alone on this RTX 3060: one group of 1024 threads, 1 million conversions each, whole dispatch by wall clock, best of 12. | conversion in the loop | time | added to the empty loop | |---|---|---| | none | 89 ms | | | `f32tof16` (main) | 89 ms | nothing measurable | | `f32_to_f16_rm(f, 0)` (this PR) | 357 ms | 268 ms | | a branch-free nearest-even form (below) | 173 ms | 84 ms | This says what one conversion costs, not what a frame costs. The default direct translator emits its own select-only version, which I did not time; it also computes the normal and the subnormal case for every value. The smoke pair in the description is at the 60 fps cap in the menus, so it cannot show the cost. The longer frame-time comparison throny asked for is still missing. If the cost matters in a title, this form gives the same bits as `f32_to_f16_rm(f, 0u)` for all 4,294,967,296 binary32 inputs on this card (checked on the GPU; `f32tof16` as a control differs for 2,248,098,814): ```hlsl uint f32_to_f16_rne(float f) { uint x = asuint(f), ax = x & 0x7FFFFFFFu, sign = (x >> 16) & 0x8000u; uint n = (ax + 0xC8000FFFu + ((ax >> 13) & 1u)) >> 13; // normal: rebias, ties to even precise float d = asfloat(ax) + 0.5f; // subnormal: the add does the rounding uint h = select(ax < 0x38800000u, asuint(d) - 0x3F000000u, n); h = select(ax >= 0x47800000u, 0x7C00u, h); h = select(ax > 0x7F800000u, 0x7E00u | ((ax >> 13) & 0x1FFu), h); return sign | h; } ``` It is checked on NVIDIA only. It could also be a follow-up. verdict: not yet: the rounding is correct, but the frame-time cost in a title's world is not measured (main against this head, below the 60 fps cap). With that comparison showing no real loss, I would call it safe to merge. hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5) @joeypercia, the missing piece is that frame-time comparison, from anyone with a title that reaches the world.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/842:upstream-pr/842'
git switch 'upstream-pr/842'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/842'
git switch 'upstream-pr/842'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/842'
git switch 'upstream-pr/842'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/842'
git switch 'main'
git merge --squash 'upstream-pr/842'
git switch 'main'
git merge --ff-only 'upstream-pr/842'
git switch 'main'
git merge 'upstream-pr/842'
git push origin 'main'
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!836
No description provided.