shader: lower gfx1013 v_madak_f32 and v_madmk_f32 in pixel_aot #589

Merged
JB2WIN merged 2 commits from upstream-pr/595 into main 2026-11-22 15:29:41 +00:00
JB2WIN commented 2026-11-22 14:49:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-22T14:49:33Z.


Change

tools/pixel_aot.py now lowers the VOP2 literal multiply-adds v_madak_f32 (S0·S1 + K) and v_madmk_f32 (S0·K + S1) in the same branch as v_fmaak_f32/v_fmamk_f32. The operand rules are the same: K must be a 32-bit hex literal, in the last position for madak and the second for madmk; the entry mask applies; and no write may land on an outstanding sample. Unlike the fused forms, these go through the existing non-fused mad32 helper (ALU mad, as for v_mad_f32/v_mac_f32). They therefore round the product before the add and flush binary32 denormals as that helper does.

  • Rejections: a register in the K position, and the e64/DPP/SDWA spellings. LLVM 15 itself refuses v_madak_f32_e64 ("e64 variant of this instruction is not supported").
  • The scanner accepts madak/madmk only with a hex K in that position, so v_madak_f32 v5, v1, v2, v3 stays unsupported, matching lower(). The existing fmaak/fmamk scanner pattern is coarser (it allows any K). I left it unchanged because that is outside this change.

Fixes #590. AI-assisted (Claude Code).

Verification

Windows 11 (10.0.26200.9974), NVIDIA GeForce RTX 3080 (driver 32.0.16.2124) and WARP 10.0.26100.9818, head rebased on 8ae1377.

  • New draw check_mad_literal_draw in the blend-scalar mode, next to check_mad_draw. Channels 0/1 are madak/madmk on 4097·4097 − 16785408, which gives 0.0 non-fused and 1.0 fused. Channels 2/3 are madak/madmk on 2⁻¹²⁷·2¹²⁶ + 0.5, which gives 0.5 with the denormal flush and 1.0 without. A reference expecting the fused or denormal-preserving result in any one channel must report pixel_mismatch, and it does. A dev-time mutation (not part of CI) that lowered both through fma made the draw fail with pixel_mismatch.
  • ctest --preset dev --no-tests=error -R "^(pixel_aot_|rdna2_tools_check$|pso_readiness)" gives 20/20 on the rebased head. pixel_aot_blend_scalar_hardware takes about 35 s, under the 60 s timeout.
  • Full ctest --preset dev --no-tests=error (before the last trivial rebase) gives 278/278, with skips bvh_wave64_hardware, bvh_wave64_warp and wave_shuffle_warp.
  • tests/pixel_aot_check.py binary with LLVM 15.0.7, locally: exit 0. pixel_aot_check.py (controls), rdna2_tools_check.py, form_coverage_check.py and docs_links_check.py all pass.

Evidence and follow-up

  • Synthetic inputs only.
  • Not measured: whether Scarlett flushes denormals for these forms the same way the helper does. docs/experiments.md says so.
  • Gap noticed in passing: tools/disasm_rdna2.py does not know VOP2 opcodes 0x20/0x21, so binary scanning of madak/madmk shows v_vop2_20/21. That is a separate fix.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6543780194 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/595). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-22T14:49:33Z. --- ## Change `tools/pixel_aot.py` now lowers the VOP2 literal multiply-adds `v_madak_f32` (S0·S1 + K) and `v_madmk_f32` (S0·K + S1) in the same branch as `v_fmaak_f32`/`v_fmamk_f32`. The operand rules are the same: K must be a 32-bit hex literal, in the last position for madak and the second for madmk; the entry mask applies; and no write may land on an outstanding sample. Unlike the fused forms, these go through the existing non-fused `mad32` helper (ALU `mad`, as for `v_mad_f32`/`v_mac_f32`). They therefore round the product before the add and flush binary32 denormals as that helper does. - Rejections: a register in the K position, and the e64/DPP/SDWA spellings. LLVM 15 itself refuses `v_madak_f32_e64` ("e64 variant of this instruction is not supported"). - The scanner accepts madak/madmk only with a hex K in that position, so `v_madak_f32 v5, v1, v2, v3` stays unsupported, matching `lower()`. The existing fmaak/fmamk scanner pattern is coarser (it allows any K). I left it unchanged because that is outside this change. Fixes #590. AI-assisted (Claude Code). ## Verification Windows 11 (10.0.26200.9974), NVIDIA GeForce RTX 3080 (driver 32.0.16.2124) and WARP 10.0.26100.9818, head rebased on `8ae1377`. - New draw `check_mad_literal_draw` in the `blend-scalar` mode, next to `check_mad_draw`. Channels 0/1 are madak/madmk on 4097·4097 − 16785408, which gives 0.0 non-fused and 1.0 fused. Channels 2/3 are madak/madmk on 2⁻¹²⁷·2¹²⁶ + 0.5, which gives 0.5 with the denormal flush and 1.0 without. A reference expecting the fused or denormal-preserving result in any one channel must report `pixel_mismatch`, and it does. A dev-time mutation (not part of CI) that lowered both through `fma` made the draw fail with `pixel_mismatch`. - `ctest --preset dev --no-tests=error -R "^(pixel_aot_|rdna2_tools_check$|pso_readiness)"` gives 20/20 on the rebased head. `pixel_aot_blend_scalar_hardware` takes about 35 s, under the 60 s timeout. - Full `ctest --preset dev --no-tests=error` (before the last trivial rebase) gives 278/278, with skips `bvh_wave64_hardware`, `bvh_wave64_warp` and `wave_shuffle_warp`. - `tests/pixel_aot_check.py binary` with LLVM 15.0.7, locally: exit 0. `pixel_aot_check.py` (controls), `rdna2_tools_check.py`, `form_coverage_check.py` and `docs_links_check.py` all pass. ## Evidence and follow-up - Synthetic inputs only. - Not measured: whether Scarlett flushes denormals for these forms the same way the helper does. `docs/experiments.md` says so. - Gap noticed in passing: `tools/disasm_rdna2.py` does not know VOP2 opcodes 0x20/0x21, so binary scanning of madak/madmk shows `v_vop2_20/21`. That is a separate fix. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:43:51 +00:00
alexander-src commented 2026-11-24 06:48:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by alexander-src on 2026-11-22T15:11:57Z.


Independent Linux x64 + LLVM 23.1.4 check on e17124b:

  • v_madak_f32 and v_madmk_f32 route cleanly through the existing unfused denormal-flushing mad32 helper with literal placement validated at operand 2 (ak) or operand 1 (mk), matching the updated regexes in tools/scan_unsupported_shaders.py.
  • Local checks passing on e17124b: pixel_aot_check.py binary (LLVM 23), rdna2_tools_check.py, pso_readiness_check.py, form_coverage_check.py, docs_links_check.py, and bidi_controls_check.py.

Windows DXC/WARP and hardware draws were not run locally on Linux.

AI-assisted: yes

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7081118921 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/595#issuecomment-7081118921). Originally posted by [alexander-src](https://github.com/alexander-src) on 2026-11-22T15:11:57Z. --- Independent Linux x64 + LLVM 23.1.4 check on `e17124b`: - `v_madak_f32` and `v_madmk_f32` route cleanly through the existing unfused denormal-flushing `mad32` helper with literal placement validated at operand 2 (`ak`) or operand 1 (`mk`), matching the updated regexes in `tools/scan_unsupported_shaders.py`. - Local checks passing on `e17124b`: `pixel_aot_check.py binary` (LLVM 23), `rdna2_tools_check.py`, `pso_readiness_check.py`, `form_coverage_check.py`, `docs_links_check.py`, and `bidi_controls_check.py`. Windows DXC/WARP and hardware draws were not run locally on Linux. AI-assisted: yes
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!589
No description provided.