shader: lower v_mac_legacy_f32 in pixel_aot #775

Merged
JB2WIN merged 2 commits from upstream-pr/781 into main 2026-11-23 05:01:42 +00:00
JB2WIN commented 2026-11-23 02:57:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-23T02:57:09Z.


Change

tools/pixel_aot.py now lowers v_mac_legacy_f32: the e32 form, and e64 with clamp and source modifiers. The result is D = legacy_mul(S0, S1) + D, with the destination as the tied accumulator. It reuses the existing mad_legacy expression, so 0 * x is 0 even for an infinite or NaN x, and the add is unfused.

Semantics source is LLVM 15.0.7 VOP2Instructions.td:

  • L416: let HasExtDPP = 0, HasExt32BitDPP = 0 in def VOP_MAC_LEGACY_F32 : VOP_MAC <f32>;
  • L630: defm V_MAC_LEGACY_F32 : VOP2Inst <"v_mac_legacy_f32", VOP_MAC_LEGACY_F32>;, under Constraints = "$vdst = $src2" and isGFX6GFX7GFX10.

Encodings. On gfx1013, LLVM 15 prints v_mac_legacy_f32_e32 v1, v2, v3 with the suffix: [0x02,0x07,0x02,0x0c]. The e64 form is [0x01,0x00,0x06,0xd5,0x02,0x07,0x02,0x00].

Refused. These stay refused:

  • the DPP spelling, since LLVM has none; it is excluded from DPP_ALU;
  • the SDWA spelling;
  • v_fmac_legacy_f32, which is "not supported on this GPU" for gfx1013;
  • wrong operand counts.

An untracked accumulator is refused the same way as for v_mac_f32.

AI-assisted (Claude Code).

Verification

Environment: Windows 11 10.0.26200.9974, NVIDIA GeForce RTX 3080 (driver 32.0.16.2124) and WARP 10.0.26100.9818. The D3D12 debug layer was enabled. Head is rebased on current main.

  • New draw draw-mac-legacy (pixel_aot_mac_legacy_{hardware,warp}):
    • Channel 0 is e32. Channels 1–3 are e64 with negation, absolute value and clamp.
    • The constant sets pair a zero factor with +inf and with NaN, use non-zero accumulators, and include a case where the unfused result is 0 but a fused one would be −2^-46.
    • Results are checked against an independent Python reference. A fused reference must mismatch, and it does.
  • Mutations. Each must report a mismatch, and each does:
    • the legacy zero rule removed;
    • the accumulator ignored;
    • src1 as the accumulator;
    • src0 as the accumulator.
  • Dev-time checks (not committed):
    • Without the new ALU entry, the controls and rdna2_tools_check.py fail.
    • Without the DPP_ALU exclusion, the table assertion fails.
  • Commands:
    • ctest --preset dev --no-tests=error -R "^pixel_aot_mac_legacy_": 2/2 passed. It takes 5.4 s on the RTX 3080 and 1.9 s on WARP.
    • Full ctest --preset dev --no-tests=error: 346/346 passed. Skipped: bvh_wave64_hardware, bvh_wave64_warp and wave_shuffle_warp.
    • tests/pixel_aot_check.py binary with LLVM 15.0.7, through a local clang -cc1as shim for llvm-mc: exit 0.
    • The controls, form_coverage_check.py, rdna2_tools_check.py, pso_readiness_check.py and docs_links_check.py pass.
  • docs/coverage/rdna2.tsv does not list this form. gfx1030 has v_fmac_legacy_f32 instead, so the coverage counts only for gfx1013.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6551314121 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/781). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-23T02:57:09Z. --- ## Change `tools/pixel_aot.py` now lowers `v_mac_legacy_f32`: the e32 form, and e64 with `clamp` and source modifiers. The result is `D = legacy_mul(S0, S1) + D`, with the destination as the tied accumulator. It reuses the existing `mad_legacy` expression, so `0 * x` is 0 even for an infinite or NaN `x`, and the add is unfused. **Semantics source** is LLVM 15.0.7 [`VOP2Instructions.td`](https://github.com/llvm/llvm-project/blob/llvmorg-15.0.7/llvm/lib/Target/AMDGPU/VOP2Instructions.td): - L416: `let HasExtDPP = 0, HasExt32BitDPP = 0 in def VOP_MAC_LEGACY_F32 : VOP_MAC <f32>;` - L630: `defm V_MAC_LEGACY_F32 : VOP2Inst <"v_mac_legacy_f32", VOP_MAC_LEGACY_F32>;`, under `Constraints = "$vdst = $src2"` and `isGFX6GFX7GFX10`. **Encodings.** On gfx1013, LLVM 15 prints `v_mac_legacy_f32_e32 v1, v2, v3` with the suffix: `[0x02,0x07,0x02,0x0c]`. The e64 form is `[0x01,0x00,0x06,0xd5,0x02,0x07,0x02,0x00]`. **Refused.** These stay refused: - the DPP spelling, since LLVM has none; it is excluded from `DPP_ALU`; - the SDWA spelling; - `v_fmac_legacy_f32`, which is "not supported on this GPU" for gfx1013; - wrong operand counts. An untracked accumulator is refused the same way as for `v_mac_f32`. AI-assisted (Claude Code). ## Verification Environment: Windows 11 10.0.26200.9974, NVIDIA GeForce RTX 3080 (driver 32.0.16.2124) and WARP 10.0.26100.9818. The D3D12 debug layer was enabled. Head is rebased on current `main`. - **New draw `draw-mac-legacy`** (`pixel_aot_mac_legacy_{hardware,warp}`): - Channel 0 is e32. Channels 1–3 are e64 with negation, absolute value and `clamp`. - The constant sets pair a zero factor with +inf and with NaN, use non-zero accumulators, and include a case where the unfused result is 0 but a fused one would be −2^-46. - Results are checked against an independent Python reference. A fused reference must mismatch, and it does. - **Mutations.** Each must report a mismatch, and each does: - the legacy zero rule removed; - the accumulator ignored; - src1 as the accumulator; - src0 as the accumulator. - **Dev-time checks (not committed):** - Without the new ALU entry, the controls and `rdna2_tools_check.py` fail. - Without the `DPP_ALU` exclusion, the table assertion fails. - **Commands:** - `ctest --preset dev --no-tests=error -R "^pixel_aot_mac_legacy_"`: 2/2 passed. It takes 5.4 s on the RTX 3080 and 1.9 s on WARP. - Full `ctest --preset dev --no-tests=error`: 346/346 passed. Skipped: `bvh_wave64_hardware`, `bvh_wave64_warp` and `wave_shuffle_warp`. - `tests/pixel_aot_check.py binary` with LLVM 15.0.7, through a local `clang -cc1as` shim for `llvm-mc`: exit 0. - The controls, `form_coverage_check.py`, `rdna2_tools_check.py`, `pso_readiness_check.py` and `docs_links_check.py` pass. - `docs/coverage/rdna2.tsv` does not list this form. gfx1030 has `v_fmac_legacy_f32` instead, so the coverage counts only for gfx1013. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:44:45 +00:00
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!775
No description provided.