shader: lower gfx1013 v_mad_legacy_f32 in pixel_aot #352

Merged
denn0x merged 6 commits from upstream-pr/358 into main 2026-11-22 16:53:16 +00:00
denn0x commented 2026-11-21 23:16:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-21T23:16:19Z.


Change

Advances an independent problem: gfx1013 instruction coverage in pixel_aot. It adds one ALU table entry, extends the unary/binary/ternary regex in tools/pixel_aot.py, and adds a draw check in tests/pixel_aot_check.py. No open PR claims v_mad_legacy_f32. #288 lowers v_mad_f32 and v_mac_f32 and does not include the legacy form, and no prerequisite PR is needed.

v_mad_legacy_f32 computes S0 * S1 + S2 with the legacy (DX9) multiply rule that 0 * x is 0 for any x, including inf and NaN. It reuses the existing mul_legacy expression and follows it with an add in the same precise statement, so DXC does not contract it into an FMA.

Fixture legacy_multiply_add(). Four lanes with e64 negation, absolute value and clamp.

Draw check check_legacy_multiply_add_draws.

  • Four constant sets pair a zero with +inf and with NaN, and also use finite values.
  • Every product and sum is exact in binary32, so rounding or fusion cannot hide a fault.
  • Each set is compared bit for bit over the 64×64 target on the selected backend. The fixture is also added to check_binary.

Negative control: replacing it with v_fma_f32 must produce pixel_mismatch, because 0 * inf is NaN there.

Verification

Windows 11 build 26200, MSVC 19.50.35720, Windows SDK 10.0.26100.0, DXC 1.8.2502.11, D3D12 debug layer enabled.

  • AMD Radeon RX 9070 XT (vendor 1002, device 7550), driver 32.0.32015.7029
  • WARP: Microsoft Basic Render Driver 10.0.26100.9818
ctest --preset dev --no-tests=error -R '^pixel_aot_' -V
1/2 Test #129: pixel_aot_hardware ...............   Passed   10.66 sec
2/2 Test #132: pixel_aot_warp ...................   Passed    4.41 sec
100% tests passed, 0 tests failed out of 2
  • Mutation check (local, reverted): lowering as a plain {0} * {1} + {2} makes pixel_aot_warp fail with pixel_mismatch x=0 y=0 in the new draw.
  • Full suite: ctest --preset dev --no-tests=error gives 146 passed, 0 failed, with the bvh_wave64_warp and wave_shuffle_warp capability skips.

Not run locally: tests/pixel_aot_check.py binary, because this machine has no LLVM with gfx1013. Ubuntu CI covers it.

This is independent of #350, #353 and #356. All of them add a fixture next to the ceiling fixture, and #288 edits the same regex, so later merges need a trivial rebase.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6535676789 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/358). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-21T23:16:19Z. --- ## Change Advances an independent problem: gfx1013 instruction coverage in `pixel_aot`. It adds one `ALU` table entry, extends the unary/binary/ternary regex in `tools/pixel_aot.py`, and adds a draw check in `tests/pixel_aot_check.py`. No open PR claims `v_mad_legacy_f32`. #288 lowers `v_mad_f32` and `v_mac_f32` and does not include the legacy form, and no prerequisite PR is needed. `v_mad_legacy_f32` computes `S0 * S1 + S2` with the legacy (DX9) multiply rule that `0 * x` is 0 for any x, including inf and NaN. It reuses the existing `mul_legacy` expression and follows it with an add in the same `precise` statement, so DXC does not contract it into an FMA. **Fixture `legacy_multiply_add()`.** Four lanes with e64 negation, absolute value and `clamp`. **Draw check `check_legacy_multiply_add_draws`.** - Four constant sets pair a zero with +inf and with NaN, and also use finite values. - Every product and sum is exact in binary32, so rounding or fusion cannot hide a fault. - Each set is compared bit for bit over the 64×64 target on the selected backend. The fixture is also added to `check_binary`. **Negative control:** replacing it with `v_fma_f32` must produce `pixel_mismatch`, because 0 * inf is NaN there. ## Verification Windows 11 build 26200, MSVC 19.50.35720, Windows SDK 10.0.26100.0, DXC 1.8.2502.11, D3D12 debug layer enabled. - AMD Radeon RX 9070 XT (vendor 1002, device 7550), driver 32.0.32015.7029 - WARP: Microsoft Basic Render Driver 10.0.26100.9818 ```powershell ctest --preset dev --no-tests=error -R '^pixel_aot_' -V ``` ```text 1/2 Test #129: pixel_aot_hardware ............... Passed 10.66 sec 2/2 Test #132: pixel_aot_warp ................... Passed 4.41 sec 100% tests passed, 0 tests failed out of 2 ``` - **Mutation check (local, reverted):** lowering as a plain `{0} * {1} + {2}` makes `pixel_aot_warp` fail with `pixel_mismatch x=0 y=0` in the new draw. - **Full suite:** `ctest --preset dev --no-tests=error` gives 146 passed, 0 failed, with the `bvh_wave64_warp` and `wave_shuffle_warp` capability skips. Not run locally: `tests/pixel_aot_check.py binary`, because this machine has no LLVM with gfx1013. Ubuntu CI covers it. This is independent of #350, #353 and #356. All of them add a fixture next to the ceiling fixture, and #288 edits the same regex, so later merges need a trivial rebase. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. _AI-assisted (Claude Code)._
upstream-sync closed this pull request 2026-11-24 06:42:37 +00:00
denn0x commented 2026-11-24 06:48:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-21T23:22:42Z.


Updated to df922c4:

  • 4e223ba adds legacy_multiply_add() to check_binary. The original commit left it out, so the LLVM round trip did not cover it.
  • df922c4 fixes what that round trip then caught. The Linux job failed with invalid operand (violates constant bus restrictions), because gfx10 VOP3 accepts at most two scalar operands and the fixture used three SGPRs per instruction. The fixture now moves s46 and s47 to v18 and v19 first. The operand values and expected results are unchanged.

Rerun on df922c4, with the RX 9070 XT (driver 32.0.32015.7029) and WARP 10.0.26100.9818 and the debug layer on: ctest --preset dev --no-tests=error -R '^pixel_aot_' passes 2/2.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7070833427 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/358#issuecomment-7070833427). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-21T23:22:42Z. --- Updated to `df922c4`: - **`4e223ba`** adds `legacy_multiply_add()` to `check_binary`. The original commit left it out, so the LLVM round trip did not cover it. - **`df922c4`** fixes what that round trip then caught. The Linux job failed with `invalid operand (violates constant bus restrictions)`, because gfx10 VOP3 accepts at most two scalar operands and the fixture used three SGPRs per instruction. The fixture now moves `s46` and `s47` to `v18` and `v19` first. The operand values and expected results are unchanged. Rerun on `df922c4`, with the RX 9070 XT (driver 32.0.32015.7029) and WARP 10.0.26100.9818 and the debug layer on: `ctest --preset dev --no-tests=error -R '^pixel_aot_'` passes 2/2. _AI-assisted (Claude Code)._
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!352
No description provided.