shader: accept binary16 and binary64 v_cmpx forms as pixel_aot region openers #1424

Merged
Maxim-Root merged 2 commits from upstream-pr/1431 into main 2026-11-24 13:13:59 +00:00
Maxim-Root commented 2026-11-24 11:23:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Maxim-Root on 2026-11-24T11:23:43Z.


Change

Depends on #1411, which adds v_cmpx_class_f32 and is open. This branch includes it, so only the last commit is new: review only that commit. I will rebase once #1411 lands.

The v_cmpx region opener (#932, #1335, #1411) accepted the VOPC _e32 compares on binary32 and integers, plus v_cmpx_class_f32. This PR accepts the remaining VOPC v_cmpx forms. That is 34 forms:

  • all 16 predicates on binary16 (v_cmpx_{f,lt,eq,le,gt,lg,ge,o,u,nge,nlg,ngt,nle,neq,nlt,tru}_f16_e32) and v_cmpx_class_f16_e32;
  • all 16 predicates on binary64 and v_cmpx_class_f64_e32.

With it, form_coverage --gaps gfx1013 lists no VOPC row.

One lowering per kind, shared with v_cmp. The opener does not reimplement anything:

  • f16_comparison and f16_class are moved unchanged out of the v_cmp_<op>_f16 and v_cmp_class_f16 branches, which now call them. The f16_compares() program translates byte for byte as before.
  • f64_comparison is moved out of the v_cmp_*_f64 / v_cmp_class_f64 branch in the same way, next to the existing int64_comparison. The binary64 forms still compare raw words with the cmp_f64 helpers and use no HLSL double. They need the declared binary64 denormal entry state, exactly as v_cmp_*_f64 does.
  • Controls assert that each opener emits the same declarations and predicate as the e32 v_cmp of the same form: 69 binary16 pairs and 4 binary64 pairs, the class tests included.

Operand rules are the existing e32 ones:

  • VSRC1 is a VGPR. For binary64 it is a VGPR pair, but the binary64 class mask is a single VGPR.
  • src0 takes no source modifiers.
  • A binary16 literal must fit in 16 bits.

Refused, with controls: _e64, SDWA, an SGPR or single-VGPR VSRC1 where a pair is required, an SGPR class mask, modifiers, and a binary64 form without the binary64 entry state.

Refs #932.

Verification

Windows 11 Pro 26300.9818, MSVC 14.44.35207, Python 3.12.10, at 8f9faa92 (on 429a8b92). Adapters: NVIDIA GeForce RTX 3070 Ti (10de:2482), driver 32.0.16.2114, and WARP 10.0.26100, with the D3D12 debug layer enabled.

New draws in pixel_aot_cmpx_regions_{warp,hardware}:

  • Four binary16 predicate groups (four regions each, alternating the two restores) on eight operand pairs: lt, eq, -0 against +0, gt, denormals, -inf against +inf, a quiet NaN on the left and a signaling NaN on the right. Every pair has high halves chosen so that a binary32 read of the whole word gives a different relation. A whole-word binary32 reference and a reversed (lt/gt swapped) reference must mismatch.
  • A binary16 class group on +inf, a quiet NaN, -0 against the +0 bit and a positive denormal. A flipped channel, and the binary32 class of the whole words, must mismatch.
  • Five binary64 groups with the operand shapes and class masks of the e32 v_cmp_*_f64 draw, on all 16 CMPF64_WORDS rows against cmpf64_expected. Those rows separate the unsigned integer order, unequal signed zeros, flushed denormals and a high-word-only NaN test. Swapped operands on -1.0 against -2.0 and flipped class channels must mismatch.

Commands and results:

ctest --preset dev --no-tests=error -R '^pixel_aot_(cmpx_regions|cmp_f64|compare|comparisons)_(warp|hardware)$' -j 8
  • That command: 8/8 passed, no skips. cmp_f64, compare and comparisons exercise the moved v_cmp_f16 / v_cmp_f64 lowering.
  • ctest --preset dev --no-tests=error -R '^(pixel_aot_|compute_store_aot_).*_warp$' -j 16: 96/96.
  • python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <LLVM-C.dll>: exit 0. This runs the translator controls and the LLVM 15.0.7 gfx1013 round trip of the ten new programs.
  • All 44 pure-Python checks in AGENTS.md pass, including form_coverage_check (now 95 v_cmpx forms), rdna2_tools_check and docs_links_check.
  • Negative controls, each a temporary edit of the opener only:
    • negating the binary64 opener predicate fails pixel_aot_cmpx_regions_warp at binary64 v_cmpx draw on warp, group=0, where all 16 pass cases mismatch;
    • negating the binary16 comparison fails the first binary16 group, where all 18 cases mismatch;
    • negating the binary16 class fails the class group in all four channels.
  • tools/form_coverage.py on the WARP run above: gfx1013 goes from 1057 to 1091 of 1968 (main + #1411 → this branch) and gfx1030 from 1047 to 1081. The VOPC gap list goes from 34 rows to 0.

Not shown, as before for v_cmpx: the EXEC intersection rule is taken from the ISA text and LLVM, not measured on gfx1013 hardware.

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 (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6580671612 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1431). Originally posted by [Maxim-Root](https://github.com/Maxim-Root) on 2026-11-24T11:23:43Z. --- ## Change **Depends on #1411**, which adds `v_cmpx_class_f32` and is open. This branch includes it, so only the last commit is new: [review only that commit](https://github.com/Maxim-Root/Xbox2Windows/commit/8f9faa92). I will rebase once #1411 lands. The `v_cmpx` region opener (#932, #1335, #1411) accepted the VOPC `_e32` compares on binary32 and integers, plus `v_cmpx_class_f32`. This PR accepts the remaining VOPC `v_cmpx` forms. That is 34 forms: - all 16 predicates on **binary16** (`v_cmpx_{f,lt,eq,le,gt,lg,ge,o,u,nge,nlg,ngt,nle,neq,nlt,tru}_f16_e32`) and `v_cmpx_class_f16_e32`; - all 16 predicates on **binary64** and `v_cmpx_class_f64_e32`. With it, `form_coverage --gaps gfx1013` lists no VOPC row. **One lowering per kind, shared with `v_cmp`.** The opener does not reimplement anything: - `f16_comparison` and `f16_class` are moved unchanged out of the `v_cmp_<op>_f16` and `v_cmp_class_f16` branches, which now call them. The `f16_compares()` program translates byte for byte as before. - `f64_comparison` is moved out of the `v_cmp_*_f64` / `v_cmp_class_f64` branch in the same way, next to the existing `int64_comparison`. The binary64 forms still compare raw words with the `cmp_f64` helpers and use no HLSL double. They need the declared binary64 denormal entry state, exactly as `v_cmp_*_f64` does. - Controls assert that each opener emits the same declarations and predicate as the e32 `v_cmp` of the same form: 69 binary16 pairs and 4 binary64 pairs, the class tests included. **Operand rules** are the existing e32 ones: - VSRC1 is a VGPR. For binary64 it is a VGPR pair, but the binary64 class mask is a single VGPR. - src0 takes no source modifiers. - A binary16 literal must fit in 16 bits. Refused, with controls: `_e64`, SDWA, an SGPR or single-VGPR VSRC1 where a pair is required, an SGPR class mask, modifiers, and a binary64 form without the binary64 entry state. Refs #932. ## Verification Windows 11 Pro 26300.9818, MSVC 14.44.35207, Python 3.12.10, at `8f9faa92` (on `429a8b92`). Adapters: NVIDIA GeForce RTX 3070 Ti (10de:2482), driver 32.0.16.2114, and WARP 10.0.26100, with the D3D12 debug layer enabled. **New draws in `pixel_aot_cmpx_regions_{warp,hardware}`:** - **Four binary16 predicate groups** (four regions each, alternating the two restores) on eight operand pairs: lt, eq, -0 against +0, gt, denormals, -inf against +inf, a quiet NaN on the left and a signaling NaN on the right. Every pair has high halves chosen so that a binary32 read of the whole word gives a different relation. A whole-word binary32 reference and a reversed (lt/gt swapped) reference must mismatch. - **A binary16 class group** on +inf, a quiet NaN, -0 against the +0 bit and a positive denormal. A flipped channel, and the binary32 class of the whole words, must mismatch. - **Five binary64 groups** with the operand shapes and class masks of the e32 `v_cmp_*_f64` draw, on all 16 `CMPF64_WORDS` rows against `cmpf64_expected`. Those rows separate the unsigned integer order, unequal signed zeros, flushed denormals and a high-word-only NaN test. Swapped operands on -1.0 against -2.0 and flipped class channels must mismatch. Commands and results: ```powershell ctest --preset dev --no-tests=error -R '^pixel_aot_(cmpx_regions|cmp_f64|compare|comparisons)_(warp|hardware)$' -j 8 ``` - That command: 8/8 passed, no skips. `cmp_f64`, `compare` and `comparisons` exercise the moved `v_cmp_f16` / `v_cmp_f64` lowering. - `ctest --preset dev --no-tests=error -R '^(pixel_aot_|compute_store_aot_).*_warp$' -j 16`: 96/96. - `python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <LLVM-C.dll>`: exit 0. This runs the translator controls and the LLVM 15.0.7 gfx1013 round trip of the ten new programs. - All 44 pure-Python checks in `AGENTS.md` pass, including `form_coverage_check` (now 95 `v_cmpx` forms), `rdna2_tools_check` and `docs_links_check`. - **Negative controls**, each a temporary edit of the opener only: - negating the binary64 opener predicate fails `pixel_aot_cmpx_regions_warp` at `binary64 v_cmpx draw on warp, group=0`, where all 16 pass cases mismatch; - negating the binary16 comparison fails the first binary16 group, where all 18 cases mismatch; - negating the binary16 class fails the class group in all four channels. - `tools/form_coverage.py` on the WARP run above: gfx1013 goes from **1057 to 1091 of 1968** (`main` + #1411 → this branch) and gfx1030 from 1047 to 1081. The VOPC gap list goes from 34 rows to 0. Not shown, as before for `v_cmpx`: the EXEC intersection rule is taken from the ISA text and LLVM, not measured on gfx1013 hardware. ## 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 (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tedin7 commented 2026-11-24 13:00:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T12:43:16Z.

Review: COMMENTED


Reviewed commit 8f9faa9201eb090d51753c2239a3cea3faae9689 (tools/pixel_aot.py, tests/pixel_aot_check.py, tests/form_coverage_check.py, docs/experiments.md).

Audit notes

  • Lowering & sharing (tools/pixel_aot.py):
    • f16_comparison, f16_class, and f64_comparison are factored out cleanly from v_cmp_*_f16 / v_cmp_*_f64 and shared with the v_cmpx region opener without duplicating predicate logic.
    • Binary64 v_cmpx forms enforce half_denorm == HALF_DENORM_PRESERVE, matching v_cmp_*_f64.
    • VOPC e32 operand guards hold: vsrc1 requires a VGPR pair for binary64 predicates and a single VGPR for v_cmpx_class_f64 and binary16 forms; source modifiers (|...|, abs(, neg(, -[vs]...) are rejected while negative inline literals (e.g. -1.0, -2.0) remain accepted; literals > 16 bits are rejected for binary16.
  • Tests & coverage (tests/pixel_aot_check.py, tests/form_coverage_check.py):
    • Controls verify lowering parity between each v_cmpx opener and its v_cmp counterpart (binary16 predicates + class, binary64 predicates + class) and refusal of _e64, SDWA, SGPR VSRC1, single-VGPR VSRC1 for 64-bit predicates, source modifiers, and >16-bit literals on binary16.
    • WARP draw tests cover 4 binary16 predicate groups (with high-half decoys and reversed/32-bit mismatch controls), binary16 class group, and 5 binary64 groups across CMPF64_WORDS with mismatch controls.
    • form_coverage_check.py updates v_cmpx count from 61 to 95 and clears compare_neighbours.
  • Rebase note: #1411 is now merged on main, and this branch is still based on 429a8b92, so a rebase onto current main is needed before merge (no issues in 8f9faa92 itself).

Verification

Linux (at 8f9faa9201eb090d51753c2239a3cea3faae9689):

  • git diff --check origin/main..HEAD: clean (exit 0).
  • python3 tests/docs_links_check.py: Checked 16 Markdown files and 322 links. (exit 0).
  • python3 tests/bidi_controls_check.py: Checked 1181 tracked source, script and build/CI files: no bidirectional controls. (exit 0).
  • python3 -B tests/pixel_aot_check.py: exit 0.
  • python3 -B tests/rdna2_tools_check.py: Ran 140 tests in 2.692s — OK (skipped=18).

Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP, commit 8f9faa9201eb090d51753c2239a3cea3faae9689):

  • tests/form_coverage_check.py: form coverage checks passed (42.3s, exit 0).
  • Debug (--preset dev):
    • cmake --build --preset dev --target offscreen_check -- -j 6: built cleanly (10.30s).
    • ctest --preset dev -R '^pixel_aot_(cmpx_regions|cmp_f64|compare|comparisons)_warp$' --parallel 4 --no-tests=error --output-on-failure: 4/4 passed (pixel_aot_cmp_f64_warp 4.63s, pixel_aot_cmpx_regions_warp 6.70s, pixel_aot_comparisons_warp 8.30s, pixel_aot_compare_warp 13.63s).
  • Release /O2 (--preset release):
    • cmake --build --preset release --target offscreen_check -- -j 6: built cleanly (7.81s).
    • ctest --preset release -R '^pixel_aot_(cmpx_regions|cmp_f64|compare|comparisons)_warp$' --parallel 4 --no-tests=error --output-on-failure: 4/4 passed (pixel_aot_cmp_f64_warp 4.43s, pixel_aot_cmpx_regions_warp 6.58s, pixel_aot_comparisons_warp 8.26s, pixel_aot_compare_warp 13.79s).
  • Note: *_hardware tests were not run (no physical GPU on the verification node).

Looks solid once rebased onto main.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6039387620 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1431#pullrequestreview-6039387620). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T12:43:16Z. **Review:** COMMENTED --- Reviewed commit `8f9faa9201eb090d51753c2239a3cea3faae9689` (`tools/pixel_aot.py`, `tests/pixel_aot_check.py`, `tests/form_coverage_check.py`, `docs/experiments.md`). ### Audit notes - **Lowering & sharing (`tools/pixel_aot.py`)**: - `f16_comparison`, `f16_class`, and `f64_comparison` are factored out cleanly from `v_cmp_*_f16` / `v_cmp_*_f64` and shared with the `v_cmpx` region opener without duplicating predicate logic. - Binary64 `v_cmpx` forms enforce `half_denorm == HALF_DENORM_PRESERVE`, matching `v_cmp_*_f64`. - VOPC e32 operand guards hold: `vsrc1` requires a VGPR pair for binary64 predicates and a single VGPR for `v_cmpx_class_f64` and binary16 forms; source modifiers (`|...|`, `abs(`, `neg(`, `-[vs]...`) are rejected while negative inline literals (e.g. `-1.0`, `-2.0`) remain accepted; literals > 16 bits are rejected for binary16. - **Tests & coverage (`tests/pixel_aot_check.py`, `tests/form_coverage_check.py`)**: - Controls verify lowering parity between each `v_cmpx` opener and its `v_cmp` counterpart (binary16 predicates + class, binary64 predicates + class) and refusal of `_e64`, SDWA, SGPR `VSRC1`, single-VGPR `VSRC1` for 64-bit predicates, source modifiers, and >16-bit literals on binary16. - WARP draw tests cover 4 binary16 predicate groups (with high-half decoys and reversed/32-bit mismatch controls), binary16 class group, and 5 binary64 groups across `CMPF64_WORDS` with mismatch controls. - `form_coverage_check.py` updates `v_cmpx` count from 61 to 95 and clears `compare_neighbours`. - **Rebase note**: `#1411` is now merged on `main`, and this branch is still based on `429a8b92`, so a rebase onto current `main` is needed before merge (no issues in `8f9faa92` itself). ### Verification **Linux** (at `8f9faa9201eb090d51753c2239a3cea3faae9689`): - `git diff --check origin/main..HEAD`: clean (exit 0). - `python3 tests/docs_links_check.py`: `Checked 16 Markdown files and 322 links.` (exit 0). - `python3 tests/bidi_controls_check.py`: `Checked 1181 tracked source, script and build/CI files: no bidirectional controls.` (exit 0). - `python3 -B tests/pixel_aot_check.py`: exit 0. - `python3 -B tests/rdna2_tools_check.py`: `Ran 140 tests in 2.692s — OK (skipped=18)`. **Windows Server 2025** (Build 26100, MSVC 14.44.35207 + D3D12 WARP, commit `8f9faa9201eb090d51753c2239a3cea3faae9689`): - `tests/form_coverage_check.py`: `form coverage checks passed` (`42.3s`, exit 0). - **Debug (`--preset dev`)**: - `cmake --build --preset dev --target offscreen_check -- -j 6`: built cleanly (`10.30s`). - `ctest --preset dev -R '^pixel_aot_(cmpx_regions|cmp_f64|compare|comparisons)_warp$' --parallel 4 --no-tests=error --output-on-failure`: **4/4 passed** (`pixel_aot_cmp_f64_warp` `4.63s`, `pixel_aot_cmpx_regions_warp` `6.70s`, `pixel_aot_comparisons_warp` `8.30s`, `pixel_aot_compare_warp` `13.63s`). - **Release `/O2` (`--preset release`)**: - `cmake --build --preset release --target offscreen_check -- -j 6`: built cleanly (`7.81s`). - `ctest --preset release -R '^pixel_aot_(cmpx_regions|cmp_f64|compare|comparisons)_warp$' --parallel 4 --no-tests=error --output-on-failure`: **4/4 passed** (`pixel_aot_cmp_f64_warp` `4.43s`, `pixel_aot_cmpx_regions_warp` `6.58s`, `pixel_aot_comparisons_warp` `8.26s`, `pixel_aot_compare_warp` `13.79s`). - Note: `*_hardware` tests were not run (no physical GPU on the verification node). Looks solid once rebased onto `main`.
upstream-sync closed this pull request 2026-11-24 14:02:43 +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!1424
No description provided.