shader: lower gfx1013 v_fmaak_f32 and v_fmamk_f32 in pixel_aot #288

Merged
Its3rr0rsWRLD merged 2 commits from upstream-pr/292 into main 2026-11-21 21:56:35 +00:00
Its3rr0rsWRLD commented 2026-11-21 21:01:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Its3rr0rsWRLD on 2026-11-21T21:01:56Z.


Change

pixel_aot rejected v_fmaak_f32 and v_fmamk_f32, the VOP2 multiply-adds with a 32-bit literal K: v_fmaak_f32 computes S0 × S1 + K and v_fmamk_f32 computes S0 × K + S1. Both now use the existing v_fma_f32 lowering with their operands in source order. The translator accepts only a hexadecimal literal in the K position, which is how LLVM prints it, and refuses a register there or a missing operand. Independent problem: it widens the arithmetic the pixel translator accepts. It touches lower() in tools/pixel_aot.py and adds a draw to tests/pixel_aot_check.py; I found no open PR that lowers either instruction.

Overlap: #288 also edits tools/pixel_aot.py, tests/pixel_aot_check.py and docs/experiments.md. The two branches touch separate lines; I merged them in both orders onto d311159 without conflicts, and the combined controls pass. Neither depends on the other.

Verification

Commit d311159 plus this change, Windows 10 Enterprise 26H2 build 26300.9974, MSVC 14.51.36231, Windows SDK 10.0.26100.0 DXC.

ctest --preset dev --no-tests=error -R '^pixel_aot_' -V
  • pixel_aot_hardware: Passed on NVIDIA GeForce RTX 4070 Ti (10de:2782), driver 32.0.16.1088.
  • pixel_aot_warp: Passed on WARP 10.0.26100.9818.
  • Every draw reports debug_errors=0 and max_absolute_error=0. Each test runs 41 draws with this change and 40 on d311159; the extra draw is the new one.
  • tests/docs_links_check.py and tests/bidi_controls_check.py pass.
  • tests/pixel_aot_check.py binary passes with the program added to the binary fixtures: LLVM 15.0.6 llvm-mc and llvm-objcopy, disassembled through libLLVM-17.so and libLLVM-18.so on Linux (no shared LLVM 15 library was available). Unchanged main passes the same check with both libraries. The Ubuntu CI job runs it with LLVM 15.

Evidence and follow-up

The fixture is synthetic: inputs 1.5, 2.5, -3.0 and 0.75, literals 0.25, 3.0, -0.5 and 0.5, each instruction drawn twice. Every product and sum is exact in binary32 and in the half export, so the reference does not depend on fusion, following the existing arithmetic fixtures. Negative controls: for each channel, a reference that swaps the literal with S1 must report pixel_mismatch, and all four do. The controls also check that the four results lower through mad( with the literal decoded as a bit pattern, and that a register in the literal position or a missing operand is refused. The translator on d311159 rejects the program at its first v_fmaak_f32.

Whether the existing v_fma_f32 lowering is fused on every adapter is not measured by this fixture, as for the other arithmetic draws.

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: yes. Written with Claude; verified on the hardware listed above.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6534347673 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/292). Originally posted by [Its3rr0rsWRLD](https://github.com/Its3rr0rsWRLD) on 2026-11-21T21:01:56Z. --- ## Change `pixel_aot` rejected `v_fmaak_f32` and `v_fmamk_f32`, the VOP2 multiply-adds with a 32-bit literal K: `v_fmaak_f32` computes S0 × S1 + K and `v_fmamk_f32` computes S0 × K + S1. Both now use the existing `v_fma_f32` lowering with their operands in source order. The translator accepts only a hexadecimal literal in the K position, which is how LLVM prints it, and refuses a register there or a missing operand. Independent problem: it widens the arithmetic the pixel translator accepts. It touches `lower()` in `tools/pixel_aot.py` and adds a draw to `tests/pixel_aot_check.py`; I found no open PR that lowers either instruction. Overlap: #288 also edits `tools/pixel_aot.py`, `tests/pixel_aot_check.py` and `docs/experiments.md`. The two branches touch separate lines; I merged them in both orders onto d311159 without conflicts, and the combined controls pass. Neither depends on the other. ## Verification Commit d311159 plus this change, Windows 10 Enterprise 26H2 build 26300.9974, MSVC 14.51.36231, Windows SDK 10.0.26100.0 DXC. ```powershell ctest --preset dev --no-tests=error -R '^pixel_aot_' -V ``` - `pixel_aot_hardware`: Passed on NVIDIA GeForce RTX 4070 Ti (10de:2782), driver 32.0.16.1088. - `pixel_aot_warp`: Passed on WARP 10.0.26100.9818. - Every draw reports `debug_errors=0` and `max_absolute_error=0`. Each test runs 41 draws with this change and 40 on d311159; the extra draw is the new one. - `tests/docs_links_check.py` and `tests/bidi_controls_check.py` pass. - `tests/pixel_aot_check.py binary` passes with the program added to the binary fixtures: LLVM 15.0.6 `llvm-mc` and `llvm-objcopy`, disassembled through `libLLVM-17.so` and `libLLVM-18.so` on Linux (no shared LLVM 15 library was available). Unchanged main passes the same check with both libraries. The Ubuntu CI job runs it with LLVM 15. ## Evidence and follow-up The fixture is synthetic: inputs 1.5, 2.5, -3.0 and 0.75, literals 0.25, 3.0, -0.5 and 0.5, each instruction drawn twice. Every product and sum is exact in binary32 and in the half export, so the reference does not depend on fusion, following the existing arithmetic fixtures. Negative controls: for each channel, a reference that swaps the literal with S1 must report `pixel_mismatch`, and all four do. The controls also check that the four results lower through `mad(` with the literal decoded as a bit pattern, and that a register in the literal position or a missing operand is refused. The translator on d311159 rejects the program at its first `v_fmaak_f32`. Whether the existing `v_fma_f32` lowering is fused on every adapter is not measured by this fixture, as for the other arithmetic draws. ## 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: yes. Written with Claude; verified on the hardware listed above.
upstream-sync closed this pull request 2026-11-24 06:42:16 +00:00
R0Y00 commented 2026-11-24 06:48:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T21:28:25Z.


At 21ed15a, the merge conflicts are in tests/pixel_aot_check.py. Please retain the fmaak/fmamk literal-position cases and landed ceiling draw in the combined runner.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7069498283 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/292#issuecomment-7069498283). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T21:28:25Z. --- At `21ed15a`, the merge conflicts are in `tests/pixel_aot_check.py`. Please retain the fmaak/fmamk literal-position cases and landed ceiling draw in the combined runner.
Its3rr0rsWRLD commented 2026-11-24 06:48:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Its3rr0rsWRLD on 2026-11-21T21:41:59Z.


Rebased onto b53bfb0 after #270 and #299. The only conflict was the check_binary fixture list: it keeps the fixture loop on main and adds the fmaak/fmamk program. Nothing else changed.

ctest --preset dev --no-tests=error -R '^pixel_aot_' -V

At 99b69d2 (b53bfb0 plus this change), Windows 10 Enterprise 26H2 build 26300.9974, MSVC 14.51.36231, Windows SDK 10.0.26100.0 DXC:

  • pixel_aot_hardware: Passed, NVIDIA GeForce RTX 4070 Ti (10de:2782), driver 32.0.16.1088.
  • pixel_aot_warp: Passed, WARP 10.0.26100.9818.
  • 51 draws on each adapter against 50 on b53bfb0, every one debug_errors=0 and max_absolute_error=0.
  • tests/pixel_aot_check.py binary, the controls, docs_links_check.py and bidi_controls_check.py pass on Linux with LLVM 15.0.6 tools and libLLVM 17 and 18.

This branch merges cleanly with each of my other open pixel_aot pull requests.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7069657178 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/292#issuecomment-7069657178). Originally posted by [Its3rr0rsWRLD](https://github.com/Its3rr0rsWRLD) on 2026-11-21T21:41:59Z. --- Rebased onto b53bfb0 after #270 and #299. The only conflict was the `check_binary` fixture list: it keeps the fixture loop on main and adds the fmaak/fmamk program. Nothing else changed. ```powershell ctest --preset dev --no-tests=error -R '^pixel_aot_' -V ``` At 99b69d2 (b53bfb0 plus this change), Windows 10 Enterprise 26H2 build 26300.9974, MSVC 14.51.36231, Windows SDK 10.0.26100.0 DXC: - `pixel_aot_hardware`: Passed, NVIDIA GeForce RTX 4070 Ti (10de:2782), driver 32.0.16.1088. - `pixel_aot_warp`: Passed, WARP 10.0.26100.9818. - 51 draws on each adapter against 50 on b53bfb0, every one `debug_errors=0` and `max_absolute_error=0`. - `tests/pixel_aot_check.py binary`, the controls, `docs_links_check.py` and `bidi_controls_check.py` pass on Linux with LLVM 15.0.6 tools and libLLVM 17 and 18. This branch merges cleanly with each of my other open pixel_aot pull requests.
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!288
No description provided.