isa_sweep: 6 single-precision FMA/rounding 1-ULP deviations on Windows 11 WARP (build 26200) #126

Closed
opened 2026-11-26 06:10:54 +00:00 by github-bot · 3 comments
Owner

@⁠ComputerScape04 on GitHub · 2026-11-22 13:40 UTC · original

Environment

- **OS:** Windows 11 Pro (Build 10.0.26200)
- **CPU:** AMD Ryzen 5 7500F
- **Toolchain:** `stable-x86_64-pc-windows-gnu` / rustc 1.100.0
- **DXC:** Microsoft.Direct3D.DXC 1.8.2505 (IDxcCompiler3)

### Description
Per the discussion on PR #1, opening this issue to document the 6 single-precision FMA / rounding 1-ULP
deviations observed when running `cargo test -p tombox-xshader --test isa_sweep` against the host WARP rasterizer
on Windows 11 build 26200.

### Failing Cases (6 of 541 mnemonics)

1. **`v_fma_f32` (VOP3)**
   - `in=[3effffff, 3f000000, 3f7fffff, 20dc3418, 40c40000, c0a70000, 4b800000, 3f400000]`
   - `got=[3f9fffff] (1.249999881)`
   - `want=[3fa00000] (1.250000000)` *(1 ULP difference)*

2. **`v_fmac_f32` (VOP2)**
   - `in=[3effffff, 3f000000, 3f7fffff, 20dc3418, 40c40000, c0a70000, 4b800000, 3f400000]`
   - `got=[3f9fffff]`
   - `want=[3fa00000]` *(1 ULP difference)*

3. **`v_fmaak_f32` (VOP2)**
   - `in=[3effffff, 3effffff, bf000000, ff800000, f8201b1b, b36481b6, 3ec84c16, c2cc0000]`
   - `got=[3fe00000]`
   - `want=[3fdfffff]` *(1 ULP difference)*

4. **`v_fma_mix_f32` (VOP3P)**
   - `in=[3c000200, 77bd3c00, c680c860, 5ff7edb0, 7b417f21, d193c6b0, e42d0001, 83bff566]`
   - `got=[743d3ef5]`
   - `want=[743d3ef4]` *(1 ULP difference)*

5. **`v_fmamk_f32` (VOP2)**
   - `in=[7f7fffff, ff800000, 7f800000, 40000000, 35497f4d, d642a9e1, e18520b0, 00800000]`
   - `got=[ff800000] (-Infinity)`
   - `want=[7fc00000] (NaN)` *(Sign/payload bit difference on overflow input)*

6. **`v_rndne_f32` (VOP1)**
   - `in=[3effffff, 00000000, 2bbf2d02, ffc12345, be82b584, 80000000, d0d8322c, 48aa7217]`
   - `got=[00000000]`
   - `want=[3f800000]` *(Tie-break rounding boundary)*
**@⁠ComputerScape04** on GitHub · 2026-11-22 13:40 UTC · [original](https://github.com/omonkeyz/xbox-emulator/issues/126) ### Environment - **OS:** Windows 11 Pro (Build 10.0.26200) - **CPU:** AMD Ryzen 5 7500F - **Toolchain:** `stable-x86_64-pc-windows-gnu` / rustc 1.100.0 - **DXC:** Microsoft.Direct3D.DXC 1.8.2505 (IDxcCompiler3) ### Description Per the discussion on PR #1, opening this issue to document the 6 single-precision FMA / rounding 1-ULP deviations observed when running `cargo test -p tombox-xshader --test isa_sweep` against the host WARP rasterizer on Windows 11 build 26200. ### Failing Cases (6 of 541 mnemonics) 1. **`v_fma_f32` (VOP3)** - `in=[3effffff, 3f000000, 3f7fffff, 20dc3418, 40c40000, c0a70000, 4b800000, 3f400000]` - `got=[3f9fffff] (1.249999881)` - `want=[3fa00000] (1.250000000)` *(1 ULP difference)* 2. **`v_fmac_f32` (VOP2)** - `in=[3effffff, 3f000000, 3f7fffff, 20dc3418, 40c40000, c0a70000, 4b800000, 3f400000]` - `got=[3f9fffff]` - `want=[3fa00000]` *(1 ULP difference)* 3. **`v_fmaak_f32` (VOP2)** - `in=[3effffff, 3effffff, bf000000, ff800000, f8201b1b, b36481b6, 3ec84c16, c2cc0000]` - `got=[3fe00000]` - `want=[3fdfffff]` *(1 ULP difference)* 4. **`v_fma_mix_f32` (VOP3P)** - `in=[3c000200, 77bd3c00, c680c860, 5ff7edb0, 7b417f21, d193c6b0, e42d0001, 83bff566]` - `got=[743d3ef5]` - `want=[743d3ef4]` *(1 ULP difference)* 5. **`v_fmamk_f32` (VOP2)** - `in=[7f7fffff, ff800000, 7f800000, 40000000, 35497f4d, d642a9e1, e18520b0, 00800000]` - `got=[ff800000] (-Infinity)` - `want=[7fc00000] (NaN)` *(Sign/payload bit difference on overflow input)* 6. **`v_rndne_f32` (VOP1)** - `in=[3effffff, 00000000, 2bbf2d02, ffc12345, be82b584, 80000000, d0d8322c, 48aa7217]` - `got=[00000000]` - `want=[3f800000]` *(Tie-break rounding boundary)*
github-bot 2026-11-26 06:10:54 +00:00
  • closed this issue
  • added the
    question
    label
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:10:54 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 13:48 UTC · original

Thanks for writing this up! On our side the same isa_sweep passes on WARP on Windows 11 build 26200 with the MSVC toolchain and DXC 1.9.2609, with none of these six on the known list. The main difference from your setup is DXC 1.8.2505 (and the GNU toolchain), so a different FMA contraction / rounding in the older compiler is the first suspect. Could you rerun with DXC 1.9 (current Windows SDK or the DXC 1.9 release) and post whether the six still deviate, plus the generated HLSL for one failing case (v_fma_f32)? That tells us whether it is the compiler or WARP.

**@⁠omonkeyz** on GitHub · 2026-11-22 13:48 UTC · [original](https://github.com/omonkeyz/xbox-emulator/issues/126#issuecomment-7080077338) Thanks for writing this up! On our side the same isa_sweep passes on WARP on Windows 11 build 26200 with the MSVC toolchain and DXC 1.9.2609, with none of these six on the known list. The main difference from your setup is DXC 1.8.2505 (and the GNU toolchain), so a different FMA contraction / rounding in the older compiler is the first suspect. Could you rerun with DXC 1.9 (current Windows SDK or the DXC 1.9 release) and post whether the six still deviate, plus the generated HLSL for one failing case (v_fma_f32)? That tells us whether it is the compiler or WARP.
Author
Owner

@⁠ComputerScape04 on GitHub · 2026-11-22 15:09 UTC · original

Investigated the setup, verified DXC, and ran isolated comparisons across toolchains. Here are the findings:

  1. Environment & DXC Version
  • OS: Windows 11 Build 26200.9711 (25H2)
  • WARP (d3d10warp.dll): 10.0.26100.9711
  • DXC (dxcompiler.dll / dxil.dll): Version 1.9.2609.5 (ProductVersion 1.9.2609.5 (01b62ad47) staged at tools/dxc/)
  1. Outcome with DXC 1.9 & Root Cause Identified
    The deviation is neither in WARP nor in DXC. It was caused by the host reference calculation in isa_sweep/ops_v.rs (fma32(a, b, c) -> f(a).mul_add(f(b), f(c))) when compiled under the GNU toolchain (x86_64-pc-windows-gnu):
  • Under x86_64-pc-windows-gnu without explicit target CPU features (baseline x86-64), Rust delegates f32::mul_add to MinGW-w64's software fmaf libm implementation.
  • For the failing test case (a = 0x3effffff, b = 0x3f000000, c = 0x3f7fffff):
    • Exact math: a * b + c = 1.25 - 5 * 2^-26 = 1.249999925494...
    • Closest single-precision IEEE-754 float: 0x3f9fffff (1.24999988..., error = 3 * 2^-26) vs 0x3fa00000 (1.25, error = 5 * 2^-26). The mathematically correct nearest float is 0x3f9fffff.
    • WARP execution: Computes 0x3f9fffff (correct).
    • Hardware CPU FMA (vfmadd213ss) / MSVC CRT fmaf: Computes 0x3f9fffff (correct).
    • MinGW software fmaf (GNU baseline): Computes 0x3fa00000 (rounding off-by-one ULP in the test reference).

When compiled with native CPU instructions (RUSTFLAGS="-C target-cpu=native" or -C target-cpu=x86-64-v3), fma32 emits hardware vfmadd213ss, the reference produces 0x3f9fffff, and:

All 6 previously failing operations pass on WARP with 0 failures:
SOP1: 29 pass, 0 fail, 0 known WARP deviations
SOP2: 51 pass, 0 fail, 0 known WARP deviations
SOPC: 18 pass, 0 fail, 0 known WARP deviations
SOPK: 21 pass, 0 fail, 0 known WARP deviations
VOP1: 71 pass, 0 fail, 7 known WARP deviations
VOP2: 46 pass, 0 fail, 2 known WARP deviations
VOP3: 96 pass, 0 fail, 2 known WARP deviations
VOP3P: 8 pass, 0 fail, 0 known WARP deviations
VOPC: 190 pass, 0 fail, 0 known WARP deviations
isa_sweep on WARP: 541 mnemonics, 530 pass, 0 fail, 11 known WARP deviations (the original main list), 28 skipped, 94 compiles, 19.3s
test result: ok. 2 passed; 0 failed

  1. Generated HLSL for v_fma_f32

Instruction Emission (v_fma_f32 slot):
// 0x0074 v_fma_f32
v20 = TB_WV(asuint(tb_fma((-asfloat(v10)), abs(asfloat(v11)), (-asfloat(v12)))), v20);

Helper Definition (tb_fma in shader prologue):
float tb_fma(float a, float b, float c) {
precise double p = (double)a * (double)b;
precise double dc = (double)c;
precise double s = p + dc;
precise double bb = s - p;
precise double e = (p - (s - bb)) + (dc - bb);
uint lo, hi;
asuint(s, lo, hi);
uint fin = (uint)(abs(s) < 1.0e300);
uint adj = fin & (uint)(e != 0.0) & (~lo & 1u);
uint dn = adj & (uint)((e > 0.0) != (s > 0.0));
precise float r = (float)asdouble(lo + adj - 2u * dn, hi - (dn & (uint)(lo == 0u)));
uint m = 0x7fffffffu;
float q = ((asuint(r) & m) > 0x7f800000u) ? asfloat(0x7fc00000u) : r;
float sp = (max(max(asuint(a) & m, asuint(b) & m), asuint(c) & m) > 0x7f800000u) ? asfloat((((asuint(a) & m) > 0x7f800000u) ? asuint(a) : (((asuint(b) & m) > 0x7f800000u) ? asuint(b) : asuint(c))) | 0x400000u) : q;
return ((fin | (uint)(abs(p) < 1.0e300)) != 0u) ? r : sp;
}

**@⁠ComputerScape04** on GitHub · 2026-11-22 15:09 UTC · [original](https://github.com/omonkeyz/xbox-emulator/issues/126#issuecomment-7081091854) Investigated the setup, verified DXC, and ran isolated comparisons across toolchains. Here are the findings: 1. Environment & DXC Version - OS: Windows 11 Build 26200.9711 (25H2) - WARP (d3d10warp.dll): 10.0.26100.9711 - DXC (dxcompiler.dll / dxil.dll): Version 1.9.2609.5 (ProductVersion 1.9.2609.5 (01b62ad47) staged at tools/dxc/) 2. Outcome with DXC 1.9 & Root Cause Identified The deviation is neither in WARP nor in DXC. It was caused by the host reference calculation in isa_sweep/ops_v.rs (fma32(a, b, c) -> f(a).mul_add(f(b), f(c))) when compiled under the GNU toolchain (x86_64-pc-windows-gnu): - Under x86_64-pc-windows-gnu without explicit target CPU features (baseline x86-64), Rust delegates f32::mul_add to MinGW-w64's software fmaf libm implementation. - For the failing test case (a = 0x3effffff, b = 0x3f000000, c = 0x3f7fffff): - Exact math: a * b + c = 1.25 - 5 * 2^-26 = 1.249999925494... - Closest single-precision IEEE-754 float: 0x3f9fffff (1.24999988..., error = 3 * 2^-26) vs 0x3fa00000 (1.25, error = 5 * 2^-26). The mathematically correct nearest float is 0x3f9fffff. - WARP execution: Computes 0x3f9fffff (correct). - Hardware CPU FMA (vfmadd213ss) / MSVC CRT fmaf: Computes 0x3f9fffff (correct). - MinGW software fmaf (GNU baseline): Computes 0x3fa00000 (rounding off-by-one ULP in the test reference). When compiled with native CPU instructions (RUSTFLAGS="-C target-cpu=native" or -C target-cpu=x86-64-v3), fma32 emits hardware vfmadd213ss, the reference produces 0x3f9fffff, and: All 6 previously failing operations pass on WARP with 0 failures: SOP1: 29 pass, 0 fail, 0 known WARP deviations SOP2: 51 pass, 0 fail, 0 known WARP deviations SOPC: 18 pass, 0 fail, 0 known WARP deviations SOPK: 21 pass, 0 fail, 0 known WARP deviations VOP1: 71 pass, 0 fail, 7 known WARP deviations VOP2: 46 pass, 0 fail, 2 known WARP deviations VOP3: 96 pass, 0 fail, 2 known WARP deviations VOP3P: 8 pass, 0 fail, 0 known WARP deviations VOPC: 190 pass, 0 fail, 0 known WARP deviations isa_sweep on WARP: 541 mnemonics, 530 pass, 0 fail, 11 known WARP deviations (the original main list), 28 skipped, 94 compiles, 19.3s test result: ok. 2 passed; 0 failed 3. Generated HLSL for v_fma_f32 Instruction Emission (v_fma_f32 slot): // 0x0074 v_fma_f32 v20 = TB_WV(asuint(tb_fma((-asfloat(v10)), abs(asfloat(v11)), (-asfloat(v12)))), v20); Helper Definition (tb_fma in shader prologue): float tb_fma(float a, float b, float c) { precise double p = (double)a * (double)b; precise double dc = (double)c; precise double s = p + dc; precise double bb = s - p; precise double e = (p - (s - bb)) + (dc - bb); uint lo, hi; asuint(s, lo, hi); uint fin = (uint)(abs(s) < 1.0e300); uint adj = fin & (uint)(e != 0.0) & (~lo & 1u); uint dn = adj & (uint)((e > 0.0) != (s > 0.0)); precise float r = (float)asdouble(lo + adj - 2u * dn, hi - (dn & (uint)(lo == 0u))); uint m = 0x7fffffffu; float q = ((asuint(r) & m) > 0x7f800000u) ? asfloat(0x7fc00000u) : r; float sp = (max(max(asuint(a) & m, asuint(b) & m), asuint(c) & m) > 0x7f800000u) ? asfloat((((asuint(a) & m) > 0x7f800000u) ? asuint(a) : (((asuint(b) & m) > 0x7f800000u) ? asuint(b) : asuint(c))) | 0x400000u) : q; return ((fin | (uint)(abs(p) < 1.0e300)) != 0u) ? r : sp; }
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 15:29 UTC · original

Great investigation, thank you! That settles it: the translator and WARP are right, and the reference value in the test was off by one ULP because the x86_64-pc-windows-gnu target takes f32::mul_add from MinGW's software fmaf, which doesn't round correctly in this halfway-adjacent case. With hardware FMA or the MSVC CRT, the reference matches WARP and the whole sweep passes.

The supported toolchain is MSVC (see CONTRIBUTING.md). I added a note there in 7e41abe that the GNU target's software fmaf breaks the FMA reference values. I'm closing this as not an emulator bug. If you run into anything else with the MSVC toolchain, please reopen.

**@⁠omonkeyz** on GitHub · 2026-11-22 15:29 UTC · [original](https://github.com/omonkeyz/xbox-emulator/issues/126#issuecomment-7081339519) Great investigation, thank you! That settles it: the translator and WARP are right, and the reference value in the test was off by one ULP because the `x86_64-pc-windows-gnu` target takes `f32::mul_add` from MinGW's software `fmaf`, which doesn't round correctly in this halfway-adjacent case. With hardware FMA or the MSVC CRT, the reference matches WARP and the whole sweep passes. The supported toolchain is MSVC (see CONTRIBUTING.md). I added a note there in 7e41abe that the GNU target's software `fmaf` breaks the FMA reference values. I'm closing this as not an emulator bug. If you run into anything else with the MSVC toolchain, please reopen.
This discussion has been locked. Commenting is limited to contributors.
No description provided.