tests: two hardware negative controls are not caught on RDNA 1 (f32_med3 branchless control, mac_f32 fused mad() mutation) #2722

Closed
opened 2026-11-26 04:14:10 +00:00 by ColorMeBoom · 4 comments
ColorMeBoom commented 2026-11-26 04:14:10 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by ColorMeBoom on 2026-11-26T04:14:10Z.


Commit or build

2215c26d (main)

Reproduction

ctest --preset dev --no-tests=error -R '^(startup_gfx2hlsl_f32_med3|compute_store_aot_mac_f32)_(warp|hardware)$' -V

Expected behavior

Each test's negative control produces a mismatch on hardware. The translated results themselves are correct on the RX 5700 XT in both tests, so only the controls fail.

Observed behavior

Both tests pass on WARP and fail on the RX 5700 XT, each at its negative control. In both, the control is non-precise (or FMad) code whose result HLSL does not pin down, and this driver resolves it the same way as the correct lowering.

startup_gfx2hlsl_f32_med3_hardware. The translated med3_32 draws the ISA words 3f800000,40000000,3fc00000,3f800000 with FXC and DXC, also after #2044. The restored branchless helper max(min(a, b), min(max(a, b), c)) also draws 3f800000 on the NaN lane, so the check reports fxc/dxc branchless lowering on hardware was accepted: the draw does not catch the defect. In the fixture b and c are the literals 2.0 and 1.0. In a DXC cs_6_0 probe with inputs read at run time (offscreen_check --raw-uav-dump):

Expression, a = NaN RX 5700 XT WARP
branchless with b, c read at run time 40000000 40000000
branchless with literals 2.0, 1.0 (the fixture) 3f800000 40000000
same, precise float o = ... 40000000 40000000
clamp(a, 1.0, 2.0) 3f800000 3f800000

With constant bounds, the non-precise median folds to a clamp, whose NaN result is not fixed (WARP returns 1.0 for clamp too). Through the fixture's own --startup-entry-words draw at 2215c26d, a precise branchless helper restores the control:

float med3_32(float a, float b, float c) {
    precise float r = max(min(a, b), min(max(a, b), c));
    return r;
}

With it, the NaN lane draws 40000000 and the other three lanes match. That holds on the RX 5700 XT and WARP, with FXC ps_5_1 and DXC ps_6_0.

compute_store_aot_mac_f32_hardware. The translated shader matches all 320 words. The hardware mutation precise float r = mad(...) then escapes with mutation 'fused mad() instead of unfused multiply+add' escaped detection. DXC emits it as FMad (op 46), which the driver may fuse or not. Probe with 4097 * 4097 - 16785408 (1 if fused, 0 if unfused):

Expression RX 5700 XT WARP
precise float m = mad(a, a, c) 0 (unfused) 0 (unfused)
mad(a, a, c) 0 (unfused) 0 (unfused)

RDNA 1 still has the unfused v_mad_f32, so on this adapter the mutation computes what the correct shader computes. The review of #2164 found the same equivalent mutant on WARP and suggested not requiring mad detection on every backend. The mutation is now hardware-only, but this hardware does not fuse either. One option is a first dispatch that measures whether the adapter fuses mad(), with this one mutation reported as a capability skip when it does not. The other three controls would stay strict.

I can send the med3 change as a PR, and the mac_f32 change once you pick the approach.

Environment

Windows 11 Home build 26200.9974, VS 2022 Build Tools (MSVC 19.44.35230), Windows SDK 10.0.26100.0, DXC 1.9.2602.17 and FXC from the SDK. AMD Radeon RX 5700 XT (RDNA 1, 1002:731f), driver 32.0.21045.29003, hardware backend; WARP 10.0.26100.9818. Debug layer unavailable.

AI-assisted with Claude Code (Claude Opus 5.5).

Checklist

  • I reproduced this on a source-built input.
  • I did not include game files, dumps, distribution links or credentials.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6619357330 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2730). Originally posted by [ColorMeBoom](https://github.com/ColorMeBoom) on 2026-11-26T04:14:10Z. --- ### Commit or build 2215c26d (main) ### Reproduction ```shell ctest --preset dev --no-tests=error -R '^(startup_gfx2hlsl_f32_med3|compute_store_aot_mac_f32)_(warp|hardware)$' -V ``` ### Expected behavior Each test's negative control produces a mismatch on hardware. The translated results themselves are correct on the RX 5700 XT in both tests, so only the controls fail. ### Observed behavior Both tests pass on WARP and fail on the RX 5700 XT, each at its negative control. In both, the control is non-`precise` (or `FMad`) code whose result HLSL does not pin down, and this driver resolves it the same way as the correct lowering. **`startup_gfx2hlsl_f32_med3_hardware`.** The translated `med3_32` draws the ISA words `3f800000,40000000,3fc00000,3f800000` with FXC and DXC, also after #2044. The restored branchless helper `max(min(a, b), min(max(a, b), c))` also draws `3f800000` on the NaN lane, so the check reports `fxc/dxc branchless lowering on hardware was accepted: the draw does not catch the defect`. In the fixture `b` and `c` are the literals 2.0 and 1.0. In a DXC `cs_6_0` probe with inputs read at run time (`offscreen_check --raw-uav-dump`): | Expression, a = NaN | RX 5700 XT | WARP | |---|---|---| | branchless with b, c read at run time | `40000000` | `40000000` | | branchless with literals 2.0, 1.0 (the fixture) | `3f800000` | `40000000` | | same, `precise float o = ...` | `40000000` | `40000000` | | `clamp(a, 1.0, 2.0)` | `3f800000` | `3f800000` | With constant bounds, the non-`precise` median folds to a clamp, whose NaN result is not fixed (WARP returns 1.0 for `clamp` too). Through the fixture's own `--startup-entry-words` draw at 2215c26d, a `precise` branchless helper restores the control: ```hlsl float med3_32(float a, float b, float c) { precise float r = max(min(a, b), min(max(a, b), c)); return r; } ``` With it, the NaN lane draws `40000000` and the other three lanes match. That holds on the RX 5700 XT and WARP, with FXC `ps_5_1` and DXC `ps_6_0`. **`compute_store_aot_mac_f32_hardware`.** The translated shader matches all 320 words. The hardware mutation `precise float r = mad(...)` then escapes with `mutation 'fused mad() instead of unfused multiply+add' escaped detection`. DXC emits it as `FMad` (op 46), which the driver may fuse or not. Probe with `4097 * 4097 - 16785408` (1 if fused, 0 if unfused): | Expression | RX 5700 XT | WARP | |---|---|---| | `precise float m = mad(a, a, c)` | 0 (unfused) | 0 (unfused) | | `mad(a, a, c)` | 0 (unfused) | 0 (unfused) | RDNA 1 still has the unfused `v_mad_f32`, so on this adapter the mutation computes what the correct shader computes. The review of #2164 found the same equivalent mutant on WARP and suggested not requiring `mad` detection on every backend. The mutation is now hardware-only, but this hardware does not fuse either. One option is a first dispatch that measures whether the adapter fuses `mad()`, with this one mutation reported as a capability skip when it does not. The other three controls would stay strict. I can send the `med3` change as a PR, and the `mac_f32` change once you pick the approach. ### Environment Windows 11 Home build 26200.9974, VS 2022 Build Tools (MSVC 19.44.35230), Windows SDK 10.0.26100.0, DXC 1.9.2602.17 and FXC from the SDK. AMD Radeon RX 5700 XT (RDNA 1, 1002:731f), driver 32.0.21045.29003, hardware backend; WARP 10.0.26100.9818. Debug layer unavailable. AI-assisted with Claude Code (Claude Opus 5.5). ### Checklist - [x] I reproduced this on a source-built input. - [x] I did not include game files, dumps, distribution links or credentials.
RonLogic commented 2026-11-26 05:02:26 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-26T04:27:23Z.


Cross-adapter comparison on Windows 26300.10075, MSVC Release, with the relevant source unchanged from 2215c26d and the D3D12 debug layer enabled: all four CTests passed on in-box WARP (10.0.26100.10068) and physical RTX 4070 (32.0.16.2124). Both FXC and DXC med3 mutations changed only the NaN lane to 40000000 on the RTX 4070. The hardware mac_f32 run also caught its fused mad mutation here. The translated shaders matched their references on both backends. These are comparison results for the reported RDNA 1 control behavior.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7182610903 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2730#issuecomment-7182610903). Originally posted by [RonLogic](https://github.com/RonLogic) on 2026-11-26T04:27:23Z. --- Cross-adapter comparison on Windows `26300.10075`, MSVC Release, with the relevant source unchanged from `2215c26d` and the D3D12 debug layer enabled: all four CTests passed on in-box WARP (`10.0.26100.10068`) and physical RTX 4070 (`32.0.16.2124`). Both FXC and DXC `med3` mutations changed only the NaN lane to `40000000` on the RTX 4070. The hardware `mac_f32` run also caught its fused `mad` mutation here. The translated shaders matched their references on both backends. These are comparison results for the reported RDNA 1 control behavior.
R0Y00 commented 2026-11-26 05:02:26 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T04:28:11Z.


Please send the test-only changes. The precise branchless median is an appropriate negative control if the same draw keeps the expected NaN-lane mismatch and the other three lanes on both FXC and DXC. For MAC, measure whether the actual shader target fuses mad using the same cancellation input. If readback reports the unfused value, log that this one mutation is inapplicable. Keep the translated shader's full word comparison and the other three mutations mandatory, and fail on probe compilation, dispatch, readback or any unexpected probe value. This should never skip the whole CTest. Please include the RX 5700 XT and WARP results. HLSL mad

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7182622418 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2730#issuecomment-7182622418). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-26T04:28:11Z. --- Please send the test-only changes. The `precise` branchless median is an appropriate negative control if the same draw keeps the expected NaN-lane mismatch and the other three lanes on both FXC and DXC. For MAC, measure whether the actual shader target fuses `mad` using the same cancellation input. If readback reports the unfused value, log that this one mutation is inapplicable. Keep the translated shader's full word comparison and the other three mutations mandatory, and fail on probe compilation, dispatch, readback or any unexpected probe value. This should never skip the whole CTest. Please include the RX 5700 XT and WARP results. [HLSL mad](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/mad)
thepatrickworld commented 2026-11-26 05:02:26 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-26T04:28:44Z.


AMD RDNA 4 (1002:7550) on main f14219f2: the mac_f32 mutation escapes here too, the f32_med3 control does not. Not a code change; measurements only.

Environment

  • Windows build 10.0.26200.9974 (UBR 0x26f6, DisplayVersion 25H2); MSVC 19.44.35230; DXC and FXC from Windows Kits\10\bin\10.0.26100.0\x64\.
  • Adapter AMD Radeon RX 9070 XT, vendor=1002 device=7550, driver 32.0.32029.2010. The warp backend selects an adapter reported as Microsoft Basic Render Driver, driver 10.0.26100.9818.
  • Every mode line reports debug layer unavailable, so no API validation is involved.
  • main f14219f2 (f14219f220df38ac3ee2be9a06b5527b48de63d5).

Commands

set "XBOX2WINDOWS_ADAPTER=AMD Radeon RX 9070 XT"
ctest --preset dev --no-tests=error -R "^(startup_gfx2hlsl_f32_med3|compute_store_aot_mac_f32)_(warp|hardware)$" -V

Observed

1/4 Test  #838: startup_gfx2hlsl_f32_med3_warp .......   Passed    1.20 sec
2/4 Test  #839: startup_gfx2hlsl_f32_med3_hardware ...   Passed    1.59 sec
3/4 Test #1777: compute_store_aot_mac_f32_hardware ...***Failed    3.11 sec
4/4 Test #2020: compute_store_aot_mac_f32_warp .......   Passed    2.01 sec
75% tests passed, 1 tests failed out of 4
Total Test time (real) =   7.98 sec

The two controls split on this adapter: the branchless med3 helper is caught (that entry passes), and only the mad() mutation escapes, at tests/compute_store_check.py:3784 with mutation 'fused mad() instead of unfused multiply+add' escaped detection. Before it, the hardware run prints groups=1 compared_words=320 mismatches=0.

What that says about fusion here, without needing the mutation: on the correct shader the fixture first requires the fused model to be detected at word 0 (mac_f32_words(fused=True), lines 3755-3764), and this run reached line 3784, so all those reference controls were rejected. The adapter therefore matched the unfused model on all 320 words and differed from the fused one at word 0. The translated source is precise on both products, so what this measures is that the driver honours precise here, not a general property of the adapter.

The assertion at 3784 fires when the mutated draw does not come back as a clean difference (returncode 1 with Compute readback differs on stderr). So on this card the mad() source produced no reported difference: the control could not separate it, the same outcome as the RX 5700 XT report above.

That makes three adapters in this thread: the RX 5700 XT and this card report the unfused value, the RTX 4070 above catches the mutation. Under the rule described in the reply above, this readback means that one mutation is inapplicable on this adapter rather than a defect of the lowering; the full 320-word comparison and the four reference controls ran and passed before it.

Limits

  • One adapter and one driver. No first-dispatch fusion probe, so "this driver does not fuse mad()" is read from the readbacks, not measured as a capability.
  • The mutation check cannot distinguish "no difference" from a crashed draw (any return code other than 1 also raises), so the mechanism behind the escape is not pinned here.
  • One preset, no debug layer.
  • "f32_med3 passes" says that entry's control is caught on this adapter; it says nothing about which rows of the RX 5700 XT table above would reproduce.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7182630213 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2730#issuecomment-7182630213). Originally posted by [thepatrickworld](https://github.com/thepatrickworld) on 2026-11-26T04:28:44Z. --- **AMD RDNA 4 (`1002:7550`) on `main` `f14219f2`: the `mac_f32` mutation escapes here too, the `f32_med3` control does not.** Not a code change; measurements only. ### Environment - Windows build `10.0.26200.9974` (UBR `0x26f6`, `DisplayVersion` `25H2`); MSVC `19.44.35230`; DXC and FXC from `Windows Kits\10\bin\10.0.26100.0\x64\`. - Adapter `AMD Radeon RX 9070 XT`, `vendor=1002 device=7550`, driver `32.0.32029.2010`. The `warp` backend selects an adapter reported as `Microsoft Basic Render Driver`, driver `10.0.26100.9818`. - Every mode line reports `debug layer unavailable`, so no API validation is involved. - `main` `f14219f2` (`f14219f220df38ac3ee2be9a06b5527b48de63d5`). ### Commands ``` set "XBOX2WINDOWS_ADAPTER=AMD Radeon RX 9070 XT" ctest --preset dev --no-tests=error -R "^(startup_gfx2hlsl_f32_med3|compute_store_aot_mac_f32)_(warp|hardware)$" -V ``` ### Observed ``` 1/4 Test #838: startup_gfx2hlsl_f32_med3_warp ....... Passed 1.20 sec 2/4 Test #839: startup_gfx2hlsl_f32_med3_hardware ... Passed 1.59 sec 3/4 Test #1777: compute_store_aot_mac_f32_hardware ...***Failed 3.11 sec 4/4 Test #2020: compute_store_aot_mac_f32_warp ....... Passed 2.01 sec 75% tests passed, 1 tests failed out of 4 Total Test time (real) = 7.98 sec ``` The two controls split on this adapter: the branchless `med3` helper is caught (that entry passes), and only the `mad()` mutation escapes, at `tests/compute_store_check.py:3784` with `mutation 'fused mad() instead of unfused multiply+add' escaped detection`. Before it, the hardware run prints `groups=1 compared_words=320 mismatches=0`. What that says about fusion here, without needing the mutation: on the correct shader the fixture first requires the fused model to be detected at word 0 (`mac_f32_words(fused=True)`, lines 3755-3764), and this run reached line 3784, so all those reference controls were rejected. The adapter therefore matched the unfused model on all 320 words and differed from the fused one at word 0. The translated source is `precise` on both products, so what this measures is that the driver honours `precise` here, not a general property of the adapter. The assertion at 3784 fires when the mutated draw does not come back as a clean difference (`returncode 1` with `Compute readback differs` on stderr). So on this card the `mad()` source produced no reported difference: the control could not separate it, the same outcome as the RX 5700 XT report above. That makes three adapters in this thread: the RX 5700 XT and this card report the unfused value, the RTX 4070 above catches the mutation. Under the rule described in the reply above, this readback means that one mutation is inapplicable on this adapter rather than a defect of the lowering; the full 320-word comparison and the four reference controls ran and passed before it. ### Limits - One adapter and one driver. No first-dispatch fusion probe, so "this driver does not fuse `mad()`" is read from the readbacks, not measured as a capability. - The mutation check cannot distinguish "no difference" from a crashed draw (any return code other than 1 also raises), so the mechanism behind the escape is not pinned here. - One preset, no debug layer. - "`f32_med3` passes" says that entry's control is caught on this adapter; it says nothing about which rows of the RX 5700 XT table above would reproduce. _AI-assisted._
stan495 commented 2026-11-26 14:00:36 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-26T13:26:35Z.


AMD Radeon RX 7900 XTX (RDNA 3, 1002:744c) comparison on 174f963d: startup_gfx2hlsl_f32_med3_hardware passes (both FXC and DXC), while compute_store_aot_mac_f32_hardware fails at the same fused mad() mutation (escaped detection).

Measurements only; no repository files modified.

Environment

  • OS: Windows 10 Pro 25H2 (Build 10.0.26200.9974)
  • Commit / Preset: 174f963d (working tree has an unrelated pre-existing modification in tools/startup/debug_launch.py), preset release
  • Compiler / Shader Toolchain: Windows SDK 10.0.26100.0 FXC and DXC (dxcompiler.dll 1.8.2502.11)
  • Hardware ($env:XBOX2WINDOWS_ADAPTER = "7900"): AMD Radeon RX 7900 XTX (vendor=1002 device=744c), driver 32.0.32029.2010, debug_layer=enabled
  • WARP: Microsoft Basic Render Driver (vendor=1414 device=008c), driver 10.0.26100.9818, debug_layer=enabled

Commands

.\tools\dev.ps1
$env:XBOX2WINDOWS_ADAPTER = "7900"
ctest --preset release --no-tests=error -j 1 -R '^(startup_gfx2hlsl_f32_med3|compute_store_aot_mac_f32)_(warp|hardware)$' -V

Observed

  • startup_gfx2hlsl_f32_med3_warp: Passed (0.98 sec, debug_errors=0 debug_warnings=0)
  • startup_gfx2hlsl_f32_med3_hardware: Passed (1.37 sec, debug_errors=0 debug_warnings=0)
    • Both FXC and DXC returned 3f800000,40000000,3fc00000,3f800000 for the translated lowering and 40000000,40000000,3fc00000,3f800000 (mismatched only on the NaN lane) for the branchless control.
  • compute_store_aot_mac_f32_warp: Passed (4.00 sec, groups=1 compared_words=320 mismatches=0, debug_errors=0 debug_warnings=0; the mad() mutation only runs on backend == "hardware")
  • compute_store_aot_mac_f32_hardware: Failed (4.85 sec)
    • Translated readback passed (groups=1 compared_words=320 mismatches=0, debug_errors=0 debug_warnings=0), and all four reference controls failed as expected before reaching the hardware-only mutation at tests/compute_store_check.py:3784:
      AssertionError: mac_f32: mutation 'fused mad() instead of unfused multiply+add' escaped detection
      

This places RDNA 3 (RX 7900 XTX) alongside RDNA 1 (RX 5700 XT) and RDNA 4 (RX 9070 XT) for compute_store_aot_mac_f32_hardware, while startup_gfx2hlsl_f32_med3_hardware catches its branchless control on this adapter.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7193357833 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2730#issuecomment-7193357833). Originally posted by [stan495](https://github.com/stan495) on 2026-11-26T13:26:35Z. --- **AMD Radeon RX 7900 XTX (RDNA 3, `1002:744c`) comparison on `174f963d`: `startup_gfx2hlsl_f32_med3_hardware` passes (both FXC and DXC), while `compute_store_aot_mac_f32_hardware` fails at the same `fused mad()` mutation (`escaped detection`).** Measurements only; no repository files modified. ### Environment - **OS:** Windows 10 Pro 25H2 (Build `10.0.26200.9974`) - **Commit / Preset:** `174f963d` (working tree has an unrelated pre-existing modification in `tools/startup/debug_launch.py`), preset `release` - **Compiler / Shader Toolchain:** Windows SDK `10.0.26100.0` FXC and DXC (`dxcompiler.dll` `1.8.2502.11`) - **Hardware (`$env:XBOX2WINDOWS_ADAPTER = "7900"`):** `AMD Radeon RX 7900 XTX` (`vendor=1002 device=744c`), driver `32.0.32029.2010`, `debug_layer=enabled` - **WARP:** `Microsoft Basic Render Driver` (`vendor=1414 device=008c`), driver `10.0.26100.9818`, `debug_layer=enabled` ### Commands ```powershell .\tools\dev.ps1 $env:XBOX2WINDOWS_ADAPTER = "7900" ctest --preset release --no-tests=error -j 1 -R '^(startup_gfx2hlsl_f32_med3|compute_store_aot_mac_f32)_(warp|hardware)$' -V ``` ### Observed - `startup_gfx2hlsl_f32_med3_warp`: **Passed** (`0.98 sec`, `debug_errors=0 debug_warnings=0`) - `startup_gfx2hlsl_f32_med3_hardware`: **Passed** (`1.37 sec`, `debug_errors=0 debug_warnings=0`) - Both FXC and DXC returned `3f800000,40000000,3fc00000,3f800000` for the translated lowering and `40000000,40000000,3fc00000,3f800000` (mismatched only on the NaN lane) for the branchless control. - `compute_store_aot_mac_f32_warp`: **Passed** (`4.00 sec`, `groups=1 compared_words=320 mismatches=0`, `debug_errors=0 debug_warnings=0`; the `mad()` mutation only runs on `backend == "hardware"`) - `compute_store_aot_mac_f32_hardware`: **Failed** (`4.85 sec`) - Translated readback passed (`groups=1 compared_words=320 mismatches=0`, `debug_errors=0 debug_warnings=0`), and all four reference controls failed as expected before reaching the hardware-only mutation at `tests/compute_store_check.py:3784`: ```text AssertionError: mac_f32: mutation 'fused mad() instead of unfused multiply+add' escaped detection ``` This places RDNA 3 (`RX 7900 XTX`) alongside RDNA 1 (`RX 5700 XT`) and RDNA 4 (`RX 9070 XT`) for `compute_store_aot_mac_f32_hardware`, while `startup_gfx2hlsl_f32_med3_hardware` catches its branchless control on this adapter. _AI-assisted; commands listed were executed locally._
Sign in to join this conversation.
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
R0Y00/Xbox2Windows#2722
No description provided.