tests: keep two hardware negative controls meaningful on RDNA 1 (#2730) #2836

Merged
ColorMeBoom merged 2 commits from upstream-pr/2844 into main 2026-11-26 13:41:24 +00:00
ColorMeBoom commented 2026-11-26 13:20:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ColorMeBoom on 2026-11-26T13:20:16Z.


Refs #2730

These are the test-only changes requested in #2730. Two hardware negative controls had stopped catching anything on an RX 5700 XT, because their mutated code is non-precise and the driver lowers it to the same result as the correct translation. Nothing changes in the translator, the shim or the reference models.

Changes

startup_gfx2hlsl_f32_med3. The restored branchless helper in the draw control is now computed as precise:

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

Without precise, this adapter folded the median against the fixture's constant bounds into a clamp. It drew the ISA value 0x3f800000 on the NaN lane with both FXC and DXC, so the control could not detect the defect it exists for. With precise, the NaN lane draws 0x40000000 and the other three lanes match, on this adapter and on WARP. The text mutation that the translator must reject still uses the plain helper.

compute_store_aot_mac_f32. Before the hardware mutation fused mad() instead of unfused multiply+add is required to fail, the new mac_f32_mad_fusion() runs the mutated shader against two models: the fused model and the unfused model. The models differ at word 0 (4097 * 4097 - 16785408 is 1 when fused and 0 when unfused).

  • If only the fused model matches, the mutation keeps its strict check, as before.
  • If only the unfused model matches, the mutation computes the same thing as the lowering on this adapter. The test logs that this one mutation is inapplicable and continues.
  • Any other outcome fails the test. That includes both models matching, neither matching, and a compile, dispatch or readback failure.

The full 320-word comparison, the four reference controls and the other two mutations are unchanged and still required. The test never skips.

docs/experiments.md describes both controls.

Evidence

Commit 5f4932c8 on main 4992a46e.

Environment:

  • Windows 11 Home build 26200.9974, VS 2022 Build Tools (MSVC 19.44.35230), Windows SDK 10.0.26100.0.
  • Compilers: DXC 1.9.2602.17 and FXC, both from the SDK.
  • Hardware: AMD Radeon RX 5700 XT (RDNA 1, 1002:731f), driver 32.0.21045.29003.
  • WARP 10.0.26100.9818.
  • Debug layer unavailable.
ctest --preset dev --no-tests=error -R '^(startup_gfx2hlsl_f32_med3_(controls|warp|hardware)|compute_store_aot_mac_f32_(warp|hardware)|docs_links|bidi_controls)$' -V

Result: 100% tests passed, 0 tests failed out of 7. git diff --check is clean.

Test RX 5700 XT WARP
startup_gfx2hlsl_f32_med3 Passed. FXC and DXC: branchless lowering on hardware mismatched on the NaN lane (40000000,40000000,3fc00000,3f800000) and matched the other three: ok Passed
compute_store_aot_mac_f32 Passed. mac_f32: mad() fusion probe (hardware): unfused, then mutation 'fused mad() instead of unfused multiply+add' is inapplicable on this adapter: mad() reads back the unfused model on all 320 words Passed. The fused mad() mutation runs only on the hardware backend, so WARP is unchanged
startup_gfx2hlsl_f32_med3_controls Passed

Before this change, the same commands on the RX 5700 XT failed at the two controls (escaped detection), as reported in #2730.

Probe controls without a GPU. I called mac_f32_mad_fusion() with a simulated renderer:

Simulated mutated readback Result
Unfused model Returns unfused
Fused model Returns fused
Neither model (word 1 changed) Raises
Renderer exit 3 Raises

After both returned results, the case file held the expected model again. I did not run the probe on an adapter that actually fuses mad(), so that branch is tested only through the simulation.

AI-assisted: I used Claude to write and run these changes and checks. I reviewed the results.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6627541086 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2844). Originally posted by [ColorMeBoom](https://github.com/ColorMeBoom) on 2026-11-26T13:20:16Z. --- Refs #2730 These are the test-only changes requested in #2730. Two hardware negative controls had stopped catching anything on an RX 5700 XT, because their mutated code is non-`precise` and the driver lowers it to the same result as the correct translation. Nothing changes in the translator, the shim or the reference models. ## Changes **`startup_gfx2hlsl_f32_med3`.** The restored branchless helper in the draw control is now computed as `precise`: ```hlsl float med3_32(float a, float b, float c) { precise float r = max(min(a, b), min(max(a, b), c)); return r; } ``` Without `precise`, this adapter folded the median against the fixture's constant bounds into a clamp. It drew the ISA value `0x3f800000` on the NaN lane with both FXC and DXC, so the control could not detect the defect it exists for. With `precise`, the NaN lane draws `0x40000000` and the other three lanes match, on this adapter and on WARP. The text mutation that the translator must reject still uses the plain helper. **`compute_store_aot_mac_f32`.** Before the hardware mutation `fused mad() instead of unfused multiply+add` is required to fail, the new `mac_f32_mad_fusion()` runs the mutated shader against two models: the fused model and the unfused model. The models differ at word 0 (`4097 * 4097 - 16785408` is 1 when fused and 0 when unfused). - If only the fused model matches, the mutation keeps its strict check, as before. - If only the unfused model matches, the mutation computes the same thing as the lowering on this adapter. The test logs that this one mutation is inapplicable and continues. - Any other outcome fails the test. That includes both models matching, neither matching, and a compile, dispatch or readback failure. The full 320-word comparison, the four reference controls and the other two mutations are unchanged and still required. The test never skips. `docs/experiments.md` describes both controls. ## Evidence Commit `5f4932c8` on `main` `4992a46e`. **Environment:** - Windows 11 Home build 26200.9974, VS 2022 Build Tools (MSVC 19.44.35230), Windows SDK 10.0.26100.0. - Compilers: DXC 1.9.2602.17 and FXC, both from the SDK. - Hardware: AMD Radeon RX 5700 XT (RDNA 1, `1002:731f`), driver 32.0.21045.29003. - WARP 10.0.26100.9818. - Debug layer unavailable. ```powershell ctest --preset dev --no-tests=error -R '^(startup_gfx2hlsl_f32_med3_(controls|warp|hardware)|compute_store_aot_mac_f32_(warp|hardware)|docs_links|bidi_controls)$' -V ``` Result: `100% tests passed, 0 tests failed out of 7`. `git diff --check` is clean. | Test | RX 5700 XT | WARP | |---|---|---| | `startup_gfx2hlsl_f32_med3` | Passed. FXC and DXC: `branchless lowering on hardware mismatched on the NaN lane (40000000,40000000,3fc00000,3f800000) and matched the other three: ok` | Passed | | `compute_store_aot_mac_f32` | Passed. `mac_f32: mad() fusion probe (hardware): unfused`, then `mutation 'fused mad() instead of unfused multiply+add' is inapplicable on this adapter: mad() reads back the unfused model on all 320 words` | Passed. The `fused mad()` mutation runs only on the hardware backend, so WARP is unchanged | | `startup_gfx2hlsl_f32_med3_controls` | Passed | | Before this change, the same commands on the RX 5700 XT failed at the two controls (`escaped detection`), as reported in #2730. **Probe controls without a GPU.** I called `mac_f32_mad_fusion()` with a simulated renderer: | Simulated mutated readback | Result | |---|---| | Unfused model | Returns `unfused` | | Fused model | Returns `fused` | | Neither model (word 1 changed) | Raises | | Renderer exit 3 | Raises | After both returned results, the case file held the expected model again. I did not run the probe on an adapter that actually fuses `mad()`, so that branch is tested only through the simulation. AI-assisted: I used Claude to write and run these changes and checks. I reviewed the results.
upstream-sync closed this pull request 2026-11-26 14:00:31 +00:00
tedin7 commented 2026-11-26 14:00:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T13:41:03Z.

Review: COMMENTED


Review of head bd596df4 (code + tests; comment only).

Question checked: do the two hardware negative controls still fail when they should, or were they only loosened?

startup_gfx2hlsl_f32_med3 (tests/startup_gfx2hlsl_f32_med3_check.py): not loosened. The control is the same branchless helper, now computed as precise. The expectation is unchanged (mismatch on the NaN lane, 0x40000000 vs 0x3f800000, other three lanes match). Mutation run on WARP: making naive() return the unchanged ISA-correct HLSL (no defect) makes startup_gfx2hlsl_f32_med3_warp fail with fxc/dxc branchless lowering on warp was accepted: the draw does not catch the defect. So the control still rejects a lowering that does not show the defect.

compute_store_aot_mac_f32 (tests/compute_store_check.py): the exemption is narrow. The mad() mutation is only added for backend == "hardware", so WARP behaves exactly as before. On hardware, the mutated shader is read back against both the fused and the unfused model, and exactly one must match all 320 words; compile/dispatch/readback errors or "neither" or "both" raise. The mutation is skipped only when the unfused model matches (where the mutation equals the lowering and cannot be caught by any readback). The reference controls and the other two mutations (p - c, accumulator dropped) still run on every adapter. That is a fair narrowing, not a blanket relax.

Not verified by me: both RX 5700 XT / RX 9070 XT outcomes (no hardware here; real-GPU run not available). That precise restores the med3 control on the RX 5700 XT rests on the table in #2730. Worth a confirming run on that adapter by the author.

Checks run: git diff --check origin/main...HEAD, python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py (all clean). Win2025 WARP dev+release 2/2 on both tests (receipt posted separately). Docs (docs/experiments.md) match the new behavior. No other open or merged PR covers this slice.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6075130317 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2844#pullrequestreview-6075130317). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T13:41:03Z. **Review:** COMMENTED --- Review of head bd596df4 (code + tests; comment only). Question checked: do the two hardware negative controls still fail when they should, or were they only loosened? **`startup_gfx2hlsl_f32_med3` (`tests/startup_gfx2hlsl_f32_med3_check.py`)**: not loosened. The control is the same branchless helper, now computed as `precise`. The expectation is unchanged (mismatch on the NaN lane, 0x40000000 vs 0x3f800000, other three lanes match). Mutation run on WARP: making `naive()` return the unchanged ISA-correct HLSL (no defect) makes `startup_gfx2hlsl_f32_med3_warp` fail with `fxc/dxc branchless lowering on warp was accepted: the draw does not catch the defect`. So the control still rejects a lowering that does not show the defect. **`compute_store_aot_mac_f32` (`tests/compute_store_check.py`)**: the exemption is narrow. The `mad()` mutation is only added for `backend == "hardware"`, so WARP behaves exactly as before. On hardware, the mutated shader is read back against both the fused and the unfused model, and exactly one must match all 320 words; compile/dispatch/readback errors or "neither" or "both" raise. The mutation is skipped only when the unfused model matches (where the mutation equals the lowering and cannot be caught by any readback). The reference controls and the other two mutations (`p - c`, accumulator dropped) still run on every adapter. That is a fair narrowing, not a blanket relax. **Not verified by me**: both RX 5700 XT / RX 9070 XT outcomes (no hardware here; real-GPU run not available). That `precise` restores the med3 control on the RX 5700 XT rests on the table in #2730. Worth a confirming run on that adapter by the author. **Checks run**: `git diff --check origin/main...HEAD`, `python3 tests/docs_links_check.py`, `python3 tests/bidi_controls_check.py` (all clean). Win2025 WARP dev+release 2/2 on both tests (receipt posted separately). Docs (`docs/experiments.md`) match the new behavior. No other open or merged PR covers this slice. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 14:00:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T13:41:02Z.


Win2025 WARP receipt for head bd596df4 after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit bd596df48d4f90809842eca6885149e72da9f5d1:

  • Debug (--preset dev): ctest --preset dev -R '^(startup_gfx2hlsl_f32_med3|compute_store_aot_mac_f32)_warp$' --parallel 5 --no-tests=error --output-on-failure: 2/2 passed (startup_gfx2hlsl_f32_med3_warp, compute_store_aot_mac_f32_warp)
  • Release /O2 (--preset release): same regex: 2/2 passed
  • Windows Python checks: PYCHECK name=tests/startup_gfx2hlsl_f32_med3_check.py rc=0
  • Real-GPU run not available (RunPod stopped); the RX 5700 XT / RX 9070 XT behavior is not re-verified here.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7193691962 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2844#issuecomment-7193691962). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T13:41:02Z. --- Win2025 WARP receipt for head bd596df4 after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `bd596df48d4f90809842eca6885149e72da9f5d1`: - **Debug (`--preset dev`)**: `ctest --preset dev -R '^(startup_gfx2hlsl_f32_med3|compute_store_aot_mac_f32)_warp$' --parallel 5 --no-tests=error --output-on-failure`: **2/2 passed** (`startup_gfx2hlsl_f32_med3_warp`, `compute_store_aot_mac_f32_warp`) - **Release `/O2` (`--preset release`)**: same regex: **2/2 passed** - **Windows Python checks**: `PYCHECK name=tests/startup_gfx2hlsl_f32_med3_check.py rc=0` - Real-GPU run not available (RunPod stopped); the RX 5700 XT / RX 9070 XT behavior is not re-verified here. AI-assisted; commands listed were executed locally.
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
R0Y00/Xbox2Windows!2836
No description provided.