shader: lower v_min_f64 and v_max_f64 in the direct compute path #3532

Manually merged
github merged 1 commit from github-bot/gh-3530 into gh-pr/3530/base 2026-11-30 09:03:47 +00:00 AGit
Owner

@⁠legacy-code-archaeologist on GitHub · 2026-11-29 23:34 UTC · original
legacy-code-archaeologist:shader/direct-minmax-f64 → main · +334 −0 · 4 files · 1 commits · merged 2026-11-30 09:01 UTC

Summary

Lowers v_min_f64 and v_max_f64 in the direct C++ compute path. They were refused with direct DXIL lowering for <name> (VOP3 probe, see #3520). The lowering uses 32-bit integer operations only (no double, no 64-bit integer shader ops), so it does not depend on the approach #3520 settles for binary64 arithmetic.

  • For a NaN and a number, and for signed zeros, the rules are the ones the f32 forms are checked against in tests/shader_signed_zero_minmax_check.py (reference_word): the number wins over a NaN, and -0 orders below +0.
  • Two NaNs give a NaN. The f32 reference has no such case, so returning the first operand quieted is an assumption here, and the doc says so.
  • Each pair maps to an unsigned two-word key in numeric order: a negative value has all its bits inverted, a positive one gets its sign bit set.
  • Abs/neg act on bit 63.
  • The ops are accepted only under the default MODE for the shared f16/f64 fields; the binary16 MODE tracking now also covers them.
  • Refused: clamp, omod, op_sel, constants, literals, an odd SGPR source.

Refs #3520, refs #2935. Independent of #3531 (v_ldexp_f64); git merge-tree against it and main is clean.

Tests

tests/native_minmax_f64_check.py (ir, controls, hardware), tests/cmake/native_minmax_f64.cmake, docs/experiments/native-direct-minmax-f64.md. The VOP3 words were assembled with LLVM 15.0.7.

On main 2ff74a6a plus this change, Windows 10.0.26100:

  • ctest --preset dev --no-tests=error -R '^native_minmax_f64_' -V:
    • ir passed: 161 cases, 966 words bit for bit through the IR interpreter of native_f16_alu_check.py, NaN included. The cases are 5 readback cases, 6 edge cases and a seeded sweep of 150, many with equal high words.
    • controls passed: no double, no i64 and no float compare in the module; 4 refusals; zero-equal, NaN-preferring and high-word-only references each differ.
    • hardware skipped (77). This machine's only D3D12 FL 12_0 adapter does not report SM 6.6 with wave32, so the readback is unmeasured.
  • Source mutants of native_compute_ir_dump, each rebuilt and then restored: comparing only the high words, letting a NaN win, or comparing the keys signed each fails ir.
  • ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' -j 2: 139/139 passed.

Not established: whether gfx1013 returns a signalling NaN operand quieted instead of the number. The f32 reference ignores any NaN, and so does this lowering.

AI-assisted: written with Claude Code. I reviewed it and ran the commands above.

🤖 Generated with Claude Code

**@⁠legacy-code-archaeologist** on GitHub · 2026-11-29 23:34 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3530) `legacy-code-archaeologist:shader/direct-minmax-f64` → `main` · +334 −0 · 4 files · 1 commits · merged 2026-11-30 09:01 UTC ## Summary Lowers `v_min_f64` and `v_max_f64` in the direct C++ compute path. They were refused with `direct DXIL lowering for <name>` (VOP3 probe, see #3520). The lowering uses **32-bit integer operations only** (no double, no 64-bit integer shader ops), so it does not depend on the approach #3520 settles for binary64 arithmetic. - For a NaN and a number, and for signed zeros, the rules are the ones the f32 forms are checked against in `tests/shader_signed_zero_minmax_check.py` (`reference_word`): the number wins over a NaN, and -0 orders below +0. - Two NaNs give a NaN. The f32 reference has no such case, so returning the first operand quieted is an assumption here, and the doc says so. - Each pair maps to an unsigned two-word key in numeric order: a negative value has all its bits inverted, a positive one gets its sign bit set. - Abs/neg act on bit 63. - The ops are accepted only under the default MODE for the shared f16/f64 fields; the binary16 MODE tracking now also covers them. - Refused: clamp, omod, op_sel, constants, literals, an odd SGPR source. Refs #3520, refs #2935. Independent of #3531 (`v_ldexp_f64`); `git merge-tree` against it and `main` is clean. ## Tests `tests/native_minmax_f64_check.py` (`ir`, `controls`, `hardware`), `tests/cmake/native_minmax_f64.cmake`, `docs/experiments/native-direct-minmax-f64.md`. The VOP3 words were assembled with LLVM 15.0.7. On `main` `2ff74a6a` plus this change, Windows 10.0.26100: - `ctest --preset dev --no-tests=error -R '^native_minmax_f64_' -V`: - `ir` **passed**: 161 cases, 966 words bit for bit through the IR interpreter of `native_f16_alu_check.py`, NaN included. The cases are 5 readback cases, 6 edge cases and a seeded sweep of 150, many with equal high words. - `controls` **passed**: no double, no i64 and no float compare in the module; 4 refusals; zero-equal, NaN-preferring and high-word-only references each differ. - `hardware` **skipped (77)**. This machine's only D3D12 FL 12_0 adapter does not report SM 6.6 with wave32, so the readback is unmeasured. - Source mutants of `native_compute_ir_dump`, each rebuilt and then restored: comparing only the high words, letting a NaN win, or comparing the keys signed each fails `ir`. - `ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' -j 2`: 139/139 passed. Not established: whether gfx1013 returns a signalling NaN operand quieted instead of the number. The f32 reference ignores any NaN, and so does this lowering. AI-assisted: written with Claude Code. I reviewed it and ran the commands above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
32-bit integer operations only, under the rules the f32 forms are
checked against: a NaN operand loses to a number, -0 orders below +0,
two NaNs give the first operand quieted. Each pair maps to an unsigned
two-word key in numeric order. Only under the default MODE for the
shared f16/f64 fields. An ir mode checks 161 cases bit for bit.

Refs #3518

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 23:38:21 +00:00
Author
Owner

@⁠Alexofbulgaria on GitHub · 2026-11-30 04:13 UTC · original

Intel Arc A770 readback passed for v_min_f64 and v_max_f64

Tested on my Intel Arc A770 (8086:56a0), driver 32.0.101.9175, Windows build 26300.10075. Release build with MSVC 14.44.35207 and DXC 1.9.2602.17. I used the repository's synthetic fixtures. Source commit 7cc9994ad150af7133bf3204a15d90b6f111fb0a.

I ran ctest --test-dir <release-build> --no-tests=error -R '^native_minmax_f64_(ir|controls|hardware)$' -V. All three tests passed with zero skips.

  • IR: 966 words matched bit for bit across 161 cases.
  • DXIL controls: Passed, including the invalid-form checks.
  • A770 hardware: All 2,064 readback words matched the reference across the five-case fixture, including guard words. NaNs matched by class.

WARP: The same fixture and reference, run with --direct-warp, skipped with exit 77 at the Shader Model 6.6 and wave32 capability check. WARP arithmetic remains unverified.

AI assisted with setup and reporting. The test runs executed locally.

**@⁠Alexofbulgaria** on GitHub · 2026-11-30 04:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3530#issuecomment-7268579637) ### Intel Arc A770 readback passed for `v_min_f64` and `v_max_f64` Tested on my Intel Arc A770 (`8086:56a0`), driver `32.0.101.9175`, Windows build `26300.10075`. Release build with MSVC `14.44.35207` and DXC `1.9.2602.17`. I used the repository's synthetic fixtures. Source commit `7cc9994ad150af7133bf3204a15d90b6f111fb0a`. I ran `ctest --test-dir <release-build> --no-tests=error -R '^native_minmax_f64_(ir|controls|hardware)$' -V`. All three tests passed with zero skips. - **IR:** 966 words matched bit for bit across 161 cases. - **DXIL controls:** Passed, including the invalid-form checks. - **A770 hardware:** All 2,064 readback words matched the reference across the five-case fixture, including guard words. NaNs matched by class. **WARP:** The same fixture and reference, run with `--direct-warp`, skipped with exit 77 at the Shader Model 6.6 and wave32 capability check. WARP arithmetic remains unverified. AI assisted with setup and reporting. The test runs executed locally.
github-bot changed target branch from main to gh-pr/3530/base 2026-11-30 09:03:46 +00:00
github manually merged commit 7cc9994ad1 into gh-pr/3530/base 2026-11-30 09:03:47 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.