shader: lower v_fma_f64 #3667

Manually merged
github merged 4 commits from github-bot/gh-3665 into gh-pr/3665/base 2026-12-01 12:39:17 +00:00 AGit
Owner

@⁠lambirou on GitHub · 2026-11-30 22:20 UTC · original
lambirou:shader/f64-fma → main · +2084 −6 · 7 files · 4 commits · merged 2026-12-01 12:34 UTC

Problem

v_fma_f64 (VOP3 0x14c on gfx1013/gfx1030) is still unobserved in the pixel AOT coverage: no fixture draws it and the translator refuses it. No open PR covers this form.

Change

Lowers the unmodified VOP3 v_fma_f64 on the raw low/high words, without an HLSL binary64 type. It reuses the r64a_* helpers from #3652: r64a_mul32 builds the exact 53x53-bit product, the addend is aligned in a 256-bit window anchored 128 bits below the product LSB, the exact sum or difference is formed with the 128-bit integer primitives, and r64a_round rounds once to nearest even. r64a_round gains a tail argument that is nonzero only when a fractional part falls below the window; the existing v_add_f64 and v_mul_f64 calls pass 0 and their behavior is unchanged (their CTest passes below).

Handled: signed zeros, subnormal inputs and results under the preserve profile, exact cancellation, significand carry, overflow to signed infinity, infinities, and NaN quieting with the first NaN in src0/src1/src2 order. 0*inf and opposing infinities give 0x7ff8000000000000.

Refused: source modifiers, clamp/omod/op_sel, DPP/SDWA, literals and inline constants, malformed or misaligned pairs, untracked pairs, an SGPR pair read before its load, a sample in flight on the destination, a non-entry mask, and a partly overlapping source/destination. An identical source/destination pair is accepted after the source words are captured, including the third source.

Coverage is pinned to exactly v_fma_f64; no other f64 form (div, rcp, rsq, sqrt, trig, min/max/ldexp, frexp, conversions, DS) is touched.

Tests

  • python -B tests/pixel_aot_check.py -- pass. The new check_f64_fma_controls covers the lowering structure, the pair rules, all refusals, and reference pins.
  • python -B tests/form_coverage_check.py -- pass (check_f64_fma_forms: the record is exactly {("VOP3","v_fma_f64")}).
  • python -B tests/rdna2_tools_check.py -- pass, 164 tests, 19 skips (unchanged capability skips).
  • python -B tests/docs_links_check.py -- pass.
  • cmake --preset dev and cmake --build --preset dev --target offscreen_check -- pass.
  • ctest --preset dev --no-tests=error -R '^pixel_aot_f64_(arith|fma)_' -V -- 4/4 pass:
    • pixel_aot_f64_arith_hardware and pixel_aot_f64_arith_warp: the #3652 forms still pass after the r64a_round signature change.
    • pixel_aot_f64_fma_hardware (AMD Radeon RX 9060 XT, driver 32.0.32029.2010, Windows 11 build 26300.10075, debug layer unavailable) and pixel_aot_f64_fma_warp (Microsoft Basic Render Driver, driver 10.0.26100.10068): all 31 rows match and all six mutants report pixel_mismatch; no skips.

The draw (draw-f64-fma) builds the shader, exports both result words through R32G32B32A32_UINT, and compares them with the exact rational a*b + c converted once through struct.pack('<d'). Rows cover signed zeros, subnormals, cancellation, fused-vs-unfused discriminants, ties, carry, overflow, infinities, and NaNs. Mutations: product rounded before the add, truncated final rounding, ignored sign, unbiased exponent, lost carry, non-quiet NaN.

Coverage delta

Expected +1 gfx1013 and +1 gfx1030 (one VOP3 form); the FORM_COVERAGE_RECORD contains exactly v_fma_f64.

Limits

This shows the translated shader computes the stated operation on desktop adapters. It does not establish the console's NaN payload selection, subnormal behavior, or rounding behavior for binary64, which remain unmeasured.

Stack

Stacked on #3645 (9601449e) and #3652 (98f1bee0), both merged with origin/main at a3bfd019. This branch is ade732fd.

AI-assisted: the implementation, tests, and PR text were prepared with an AI coding agent.

CI: run 46526099845 is green (gfx1013 assembly, Linux Python checks, and Windows build/test; /O2 and the coverage chart are skipped on pull requests).

Merge with origin/main (2026-12-01)

Merged origin/main at a3bfd019 into this branch; head is ade732fd. The shared CMake, docs and test files keep both the #3609/#3623 additions and the PR additions. Local post-merge: pixel_aot_check.py, form_coverage_check.py and rdna2_tools_check.py pass (165 tests, 19 skips); CTest pixel_aot_f64_arith_warp, pixel_aot_f64_round_warp, pixel_aot_f64_minmax_ldexp_warp and pixel_aot_f64_fma_warp pass (4/4). The FMA WARP draw takes about 98 s, so its timeout is 240 s.

**@⁠lambirou** on GitHub · 2026-11-30 22:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3665) `lambirou:shader/f64-fma` → `main` · +2084 −6 · 7 files · 4 commits · merged 2026-12-01 12:34 UTC ## Problem `v_fma_f64` (VOP3 0x14c on gfx1013/gfx1030) is still `unobserved` in the pixel AOT coverage: no fixture draws it and the translator refuses it. No open PR covers this form. ## Change Lowers the unmodified VOP3 `v_fma_f64` on the raw low/high words, without an HLSL binary64 type. It reuses the `r64a_*` helpers from #3652: `r64a_mul32` builds the exact 53x53-bit product, the addend is aligned in a 256-bit window anchored 128 bits below the product LSB, the exact sum or difference is formed with the 128-bit integer primitives, and `r64a_round` rounds once to nearest even. `r64a_round` gains a `tail` argument that is nonzero only when a fractional part falls below the window; the existing `v_add_f64` and `v_mul_f64` calls pass 0 and their behavior is unchanged (their CTest passes below). Handled: signed zeros, subnormal inputs and results under the preserve profile, exact cancellation, significand carry, overflow to signed infinity, infinities, and NaN quieting with the first NaN in src0/src1/src2 order. `0*inf` and opposing infinities give `0x7ff8000000000000`. Refused: source modifiers, clamp/omod/op_sel, DPP/SDWA, literals and inline constants, malformed or misaligned pairs, untracked pairs, an SGPR pair read before its load, a sample in flight on the destination, a non-entry mask, and a partly overlapping source/destination. An identical source/destination pair is accepted after the source words are captured, including the third source. Coverage is pinned to exactly `v_fma_f64`; no other f64 form (div, rcp, rsq, sqrt, trig, min/max/ldexp, frexp, conversions, DS) is touched. ## Tests - `python -B tests/pixel_aot_check.py` -- pass. The new `check_f64_fma_controls` covers the lowering structure, the pair rules, all refusals, and reference pins. - `python -B tests/form_coverage_check.py` -- pass (`check_f64_fma_forms`: the record is exactly `{("VOP3","v_fma_f64")}`). - `python -B tests/rdna2_tools_check.py` -- pass, 164 tests, 19 skips (unchanged capability skips). - `python -B tests/docs_links_check.py` -- pass. - `cmake --preset dev` and `cmake --build --preset dev --target offscreen_check` -- pass. - `ctest --preset dev --no-tests=error -R '^pixel_aot_f64_(arith|fma)_' -V` -- 4/4 pass: - `pixel_aot_f64_arith_hardware` and `pixel_aot_f64_arith_warp`: the #3652 forms still pass after the `r64a_round` signature change. - `pixel_aot_f64_fma_hardware` (AMD Radeon RX 9060 XT, driver 32.0.32029.2010, Windows 11 build 26300.10075, debug layer unavailable) and `pixel_aot_f64_fma_warp` (Microsoft Basic Render Driver, driver 10.0.26100.10068): all 31 rows match and all six mutants report `pixel_mismatch`; no skips. The draw (`draw-f64-fma`) builds the shader, exports both result words through `R32G32B32A32_UINT`, and compares them with the exact rational `a*b + c` converted once through `struct.pack('<d')`. Rows cover signed zeros, subnormals, cancellation, fused-vs-unfused discriminants, ties, carry, overflow, infinities, and NaNs. Mutations: product rounded before the add, truncated final rounding, ignored sign, unbiased exponent, lost carry, non-quiet NaN. ## Coverage delta Expected +1 gfx1013 and +1 gfx1030 (one VOP3 form); the `FORM_COVERAGE_RECORD` contains exactly `v_fma_f64`. ## Limits This shows the translated shader computes the stated operation on desktop adapters. It does not establish the console's NaN payload selection, subnormal behavior, or rounding behavior for binary64, which remain unmeasured. ## Stack Stacked on #3645 (`9601449e`) and #3652 (`98f1bee0`), both merged with `origin/main` at `a3bfd019`. This branch is `ade732fd`. AI-assisted: the implementation, tests, and PR text were prepared with an AI coding agent. CI: run [46526099845](https://github.com/R0Y00/Xbox2Windows/actions/runs/46526099845) is green (gfx1013 assembly, Linux Python checks, and Windows build/test; `/O2` and the coverage chart are skipped on pull requests). ## Merge with origin/main (2026-12-01) Merged `origin/main` at `a3bfd019` into this branch; head is `ade732fd`. The shared CMake, docs and test files keep both the #3609/#3623 additions and the PR additions. Local post-merge: `pixel_aot_check.py`, `form_coverage_check.py` and `rdna2_tools_check.py` pass (165 tests, 19 skips); CTest `pixel_aot_f64_arith_warp`, `pixel_aot_f64_round_warp`, `pixel_aot_f64_minmax_ldexp_warp` and `pixel_aot_f64_fma_warp` pass (4/4). The FMA WARP draw takes about 98 s, so its timeout is 240 s.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 22:21:59 +00:00
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-12-01 02:44 UTC · original · approved these changes

Reviewed ade732fd by reading the diff; not built or run. Stacked on #3645 and #3652, so I read this PR's own change against #3652's head 98f1bee0.

Verdict: approve. r64a_fma forms the exact product plus addend and rounds once. Add and multiply are unchanged (they pass tail = 0). No MUST, no SHOULD. Merge after #3652.

  • NIT r64a_round's new tail (tools/pixel_aot.py:1394, :1423) only becomes sticky when the guard bit is set inside exact. That is right for r64a_fma, whose window always holds 128 significant bits. A future caller passing a 53-bit exact with tail != 0 would truncate a fraction ≥ ½. Worth a comment.
  • Checked, no finding:
    • Special cases (:1508): the first NaN in src0/src1/src2 order wins. inf·0 and inf − inf give the canonical NaN. A zero product returns c exactly, or the IEEE signed zero when c is zero too. A zero c reuses r64a_mul, which keeps the product's sign on underflow.
    • Ordering: the larger magnitude is chosen by the top bit, then by an exact aligned compare on a tie. It sits at bits 128+ of a 256-bit window, and the smaller one at 128 + distance.
    • Lost bits: bits below bit 0 only occur when the result's top bit is ≥ 127, so they are pure sticky. In a subtraction, the extra −1 makes the value its floor plus sticky, which is correct for ties-to-even. An exact cancellation gives +0.
    • Lowering: the third source gets the same pair, overlap, pending-load and sample rules as #3652, and the identical-pair case reads all three sources before writing.

Tests: the draw-f64-fma rows compare against the exact rational a·b + c and the six mutations show the rows can fail. CI ran pixel_aot_check.py, form_coverage_check.py and rdna2_tools_check.py at this head. The draws are outside the pr filter.

**@⁠lukaslw-lab** on GitHub · 2026-12-01 02:44 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3665#pullrequestreview-6124240821) · **approved these changes** Reviewed `ade732fd` by reading the diff; not built or run. Stacked on #3645 and #3652, so I read this PR's own change against #3652's head `98f1bee0`. **Verdict: approve.** `r64a_fma` forms the exact product plus addend and rounds once. Add and multiply are unchanged (they pass `tail = 0`). No MUST, no SHOULD. Merge after #3652. - **NIT** `r64a_round`'s new `tail` (`tools/pixel_aot.py:1394`, `:1423`) only becomes sticky when the guard bit is set inside `exact`. That is right for `r64a_fma`, whose window always holds 128 significant bits. A future caller passing a 53-bit `exact` with `tail != 0` would truncate a fraction ≥ ½. Worth a comment. - Checked, no finding: - **Special cases** (`:1508`): the first NaN in src0/src1/src2 order wins. inf·0 and inf − inf give the canonical NaN. A zero product returns c exactly, or the IEEE signed zero when c is zero too. A zero c reuses `r64a_mul`, which keeps the product's sign on underflow. - **Ordering:** the larger magnitude is chosen by the top bit, then by an exact aligned compare on a tie. It sits at bits 128+ of a 256-bit window, and the smaller one at `128 + distance`. - **Lost bits:** bits below bit 0 only occur when the result's top bit is ≥ 127, so they are pure sticky. In a subtraction, the extra −1 makes the value its floor plus sticky, which is correct for ties-to-even. An exact cancellation gives +0. - **Lowering:** the third source gets the same pair, overlap, pending-load and sample rules as #3652, and the identical-pair case reads all three sources before writing. Tests: the `draw-f64-fma` rows compare against the exact rational `a·b + c` and the six mutations show the rows can fail. CI ran `pixel_aot_check.py`, `form_coverage_check.py` and `rdna2_tools_check.py` at this head. The draws are outside the `pr` filter.
github-bot changed target branch from main to gh-pr/3665/base 2026-12-01 12:39:16 +00:00
github manually merged commit ade732fd4b into gh-pr/3665/base 2026-12-01 12:39:17 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.