shader: lower v_xnor_b32 and draw the integer e64 forms in pixel_aot #722

Merged
rasptum merged 1 commit from upstream-pr/728 into main 2026-11-22 23:53:08 +00:00
rasptum commented 2026-11-22 23:21:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-22T23:21:20Z.


Change

One translator change and one new draw test.

  • tools/pixel_aot.py: v_xnor_b32 is added to the integer table as ~(src0 ^ src1), so it lowers in the VOP2 (e32) and VOP3 (e64) encodings with the same operand rules as v_xor_b32. Before this it was accepted only as a quad-local DPP form. The operation is taken from the LLVM 15 AMDGPU backend (VOP2Instructions.td selects V_XNOR_B32 for not (xor a, b)), and matches the DPP and scalar xnor lowerings already in the translator. It is not checked against the ISA document here. A float modifier, clamp, a wrong operand count, an unwritten register and the SDWA spelling stay refused, and the test asserts each refusal. The scanner derives its patterns from the same table, so tools/scan_unsupported_shaders.py needs no edit.
  • tests/pixel_aot_check.py: three programs draw v_xnor_b32 together with the eight integer e64 encodings that the translator already accepted but no fixture drew: v_and_b32_e64, v_or_b32_e64, v_xor_b32_e64, v_not_b32_e64, v_lshlrev_b32_e64, v_lshrrev_b32_e64, v_ashrrev_i32_e64 and v_cvt_f32_ubyte2_e64.

The draws export through the R32G32B32A32_UINT readback target and are compared bit for bit. A, B and C are constants s44, s45 and s46.

Group Instructions Expected
shift v_lshlrev_b32_e64, v_lshrrev_b32_e64, v_ashrrev_i32_e64, v_not_b32_e64, sources in SGPRs B << (A & 31), B >> (A & 31) logical, arithmetic, ~B
bitwise v_and_b32_e64, v_or_b32_e64, v_xor_b32_e64, v_xnor_b32_e64, sources in SGPRs A & B, A | B, A ^ B, ~(A ^ B)
xnor_byte v_xnor_b32_e32, v_cvt_f32_ubyte2_e64 from an SGPR, from a VGPR and with clamp ~(A ^ B), byte 2 of C, byte 2 of B, byte 2 of C saturated

Each group runs on two rows. The shift counts are 0x3f800024 and 0x40000023, so a count that is not reduced modulo 32 gives a different word, and B is negative in the first row, so the logical and arithmetic shifts differ. Every input and every expected result is a normal binary32 or zero (asserted), so the draw does not depend on NaN or denormal handling.

Negative controls: fourteen wrong references, each replacing one channel on the first row, must report pixel_mismatch: swapped shift operands, an unreduced shift count, arithmetic for logical shift and the reverse, a dropped not, or for and, and for or, xnor for xor and the reverse (in both encodings), byte 1 and byte 3 for byte 2, the wrong source register, and a dropped clamp.

The draws are registered as their own CTest entries, pixel_aot_e64_integer_hardware and pixel_aot_e64_integer_warp (tests/pixel_aot_check.py draw-e64-integer), each with its own FORM_COVERAGE_RECORD, so nothing is added to pixel_aot_hardware. That is 20 draws from 3 compiles and 3 renderer launches. The three programs are added to the LLVM 15 round trip, tests/form_coverage_check.py asserts the ten forms, and docs/experiments.md has a paragraph.

This advances instruction-form coverage of the pixel translator by ten forms.

Verification

Update before opening: rebased onto main at 121fdc3 as a0726e6. On that commit I reran the LLVM 15 round trip, tests/form_coverage_check.py and the full pixel_aot_check.py draw run on WARP (all pass); the hardware and ctest results below are from the commit named there.

The full ctest run below was made at c7b38cd (this change on main 787ace7). The branch was then rebased onto 7c256c3 (a966e12), which adds only #683 (README and 11 lines of static controls); the two new tests on both backends, the controls, the round trip, form_coverage_check.py, pso_readiness_check.py and docs_links_check.py were rerun there and passed. Windows 10 Pro 22H2 (10.0.19045.6466), Windows SDK 10.0.26100.0 DXC, Debug build, debug layer enabled in every run.

cmake --preset dev
cmake --build --preset dev --target offscreen_check
ctest --preset dev --no-tests=error -R '^pixel_aot_'

24 tests ran. 23 passed, 1 failed, 0 skipped.

Test Adapter Result
pixel_aot_e64_integer_warp Microsoft Basic Render Driver, WARP 10.0.19041.5794 Passed, 0.7 s
pixel_aot_e64_integer_hardware NVIDIA GeForce RTX 3060 (10de:2503), driver 32.0.15.9636 Passed, 1.8 s
the other 11 pixel_aot_*_warp tests WARP 10.0.19041.5794 Passed
10 of the other 11 pixel_aot_*_hardware tests RTX 3060 Passed
pixel_aot_blend_scalar_hardware RTX 3060 Failed. It also fails on untouched main on this machine and this change does not touch it.

In both new tests every right reference reports max_absolute_error=0, every draw reports debug_errors=0 debug_warnings=0, and the 14 wrong references each report mismatch.

Other checks, all passed:

  • python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <LLVM-C.dll> with LLVM 15.0.7. LLVM 15 prints all twelve new instructions exactly as written, for -mcpu=gfx1013 and -mcpu=gfx1030.
  • python -B tests/pixel_aot_check.py (controls).
  • The 22 pure-Python checks listed in AGENTS.md, including tests/form_coverage_check.py, tests/pso_readiness_check.py and tests/docs_links_check.py.

Evidence and follow-up

Coverage, counted with tools/form_coverage.py from the records of the run above. The baseline is the union of the seven record-writing shader tests run on WARP from a clean copy of 787ace7.

gfx1013 gfx1030 (RDNA2)
main at 787ace7 515 of 1968 510 of 1863
this change 525 of 1968 520 of 1863

The forms added are exactly v_xnor_b32, v_xnor_b32_e64, v_and_b32_e64, v_or_b32_e64, v_xor_b32_e64, v_not_b32_e64, v_lshlrev_b32_e64, v_lshrrev_b32_e64, v_ashrrev_i32_e64 and v_cvt_f32_ubyte2_e64, on both lists. None is removed. docs/coverage/dashboard.svg is not regenerated here.

What this does not show: that the console computes the same results (the draws run on desktop GPUs), and the v_xnor_b32 semantics against the ISA document.

Overlap with open pull requests: #340 (which drew the other accepted e64 forms) is merged and does not contain these. The diffs of the open shader pull requests (38 read) were searched for the ten form names on added lines; none adds them. The closest is #678 (three-operand integer ALU), which uses different instructions. Like every open shader pull request, this one appends a line to the check_binary fixture list, so a textual conflict there with whichever lands first is expected and trivial.

AI-assisted (Claude Code). The Windows results were measured locally.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6549144206 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/728). Originally posted by [rasptum](https://github.com/rasptum) on 2026-11-22T23:21:20Z. --- ## Change One translator change and one new draw test. - `tools/pixel_aot.py`: `v_xnor_b32` is added to the integer table as `~(src0 ^ src1)`, so it lowers in the VOP2 (e32) and VOP3 (e64) encodings with the same operand rules as `v_xor_b32`. Before this it was accepted only as a quad-local DPP form. The operation is taken from the LLVM 15 AMDGPU backend (`VOP2Instructions.td` selects `V_XNOR_B32` for `not (xor a, b)`), and matches the DPP and scalar `xnor` lowerings already in the translator. It is not checked against the ISA document here. A float modifier, ` clamp`, a wrong operand count, an unwritten register and the SDWA spelling stay refused, and the test asserts each refusal. The scanner derives its patterns from the same table, so `tools/scan_unsupported_shaders.py` needs no edit. - `tests/pixel_aot_check.py`: three programs draw `v_xnor_b32` together with the eight integer e64 encodings that the translator already accepted but no fixture drew: `v_and_b32_e64`, `v_or_b32_e64`, `v_xor_b32_e64`, `v_not_b32_e64`, `v_lshlrev_b32_e64`, `v_lshrrev_b32_e64`, `v_ashrrev_i32_e64` and `v_cvt_f32_ubyte2_e64`. The draws export through the `R32G32B32A32_UINT` readback target and are compared bit for bit. A, B and C are constants s44, s45 and s46. | Group | Instructions | Expected | |---|---|---| | shift | `v_lshlrev_b32_e64`, `v_lshrrev_b32_e64`, `v_ashrrev_i32_e64`, `v_not_b32_e64`, sources in SGPRs | `B << (A & 31)`, `B >> (A & 31)` logical, arithmetic, `~B` | | bitwise | `v_and_b32_e64`, `v_or_b32_e64`, `v_xor_b32_e64`, `v_xnor_b32_e64`, sources in SGPRs | `A & B`, `A \| B`, `A ^ B`, `~(A ^ B)` | | xnor_byte | `v_xnor_b32_e32`, `v_cvt_f32_ubyte2_e64` from an SGPR, from a VGPR and with ` clamp` | `~(A ^ B)`, byte 2 of C, byte 2 of B, byte 2 of C saturated | Each group runs on two rows. The shift counts are 0x3f800024 and 0x40000023, so a count that is not reduced modulo 32 gives a different word, and B is negative in the first row, so the logical and arithmetic shifts differ. Every input and every expected result is a normal binary32 or zero (asserted), so the draw does not depend on NaN or denormal handling. Negative controls: fourteen wrong references, each replacing one channel on the first row, must report `pixel_mismatch`: swapped shift operands, an unreduced shift count, arithmetic for logical shift and the reverse, a dropped not, or for and, and for or, xnor for xor and the reverse (in both encodings), byte 1 and byte 3 for byte 2, the wrong source register, and a dropped clamp. The draws are registered as their own CTest entries, `pixel_aot_e64_integer_hardware` and `pixel_aot_e64_integer_warp` (`tests/pixel_aot_check.py draw-e64-integer`), each with its own `FORM_COVERAGE_RECORD`, so nothing is added to `pixel_aot_hardware`. That is 20 draws from 3 compiles and 3 renderer launches. The three programs are added to the LLVM 15 round trip, `tests/form_coverage_check.py` asserts the ten forms, and `docs/experiments.md` has a paragraph. This advances instruction-form coverage of the pixel translator by ten forms. ## Verification Update before opening: rebased onto `main` at 121fdc3 as a0726e6. On that commit I reran the LLVM 15 round trip, `tests/form_coverage_check.py` and the full `pixel_aot_check.py draw` run on WARP (all pass); the hardware and ctest results below are from the commit named there. The full `ctest` run below was made at c7b38cd (this change on `main` 787ace7). The branch was then rebased onto 7c256c3 (a966e12), which adds only #683 (README and 11 lines of static controls); the two new tests on both backends, the controls, the round trip, `form_coverage_check.py`, `pso_readiness_check.py` and `docs_links_check.py` were rerun there and passed. Windows 10 Pro 22H2 (10.0.19045.6466), Windows SDK 10.0.26100.0 DXC, Debug build, debug layer enabled in every run. ```powershell cmake --preset dev cmake --build --preset dev --target offscreen_check ctest --preset dev --no-tests=error -R '^pixel_aot_' ``` 24 tests ran. 23 passed, 1 failed, 0 skipped. | Test | Adapter | Result | |---|---|---| | `pixel_aot_e64_integer_warp` | Microsoft Basic Render Driver, WARP 10.0.19041.5794 | Passed, 0.7 s | | `pixel_aot_e64_integer_hardware` | NVIDIA GeForce RTX 3060 (10de:2503), driver 32.0.15.9636 | Passed, 1.8 s | | the other 11 `pixel_aot_*_warp` tests | WARP 10.0.19041.5794 | Passed | | 10 of the other 11 `pixel_aot_*_hardware` tests | RTX 3060 | Passed | | `pixel_aot_blend_scalar_hardware` | RTX 3060 | Failed. It also fails on untouched `main` on this machine and this change does not touch it. | In both new tests every right reference reports `max_absolute_error=0`, every draw reports `debug_errors=0 debug_warnings=0`, and the 14 wrong references each report `mismatch`. Other checks, all passed: - `python -B tests/pixel_aot_check.py binary <llvm-mc> <llvm-objcopy> <LLVM-C.dll>` with LLVM 15.0.7. LLVM 15 prints all twelve new instructions exactly as written, for `-mcpu=gfx1013` and `-mcpu=gfx1030`. - `python -B tests/pixel_aot_check.py` (controls). - The 22 pure-Python checks listed in `AGENTS.md`, including `tests/form_coverage_check.py`, `tests/pso_readiness_check.py` and `tests/docs_links_check.py`. ## Evidence and follow-up Coverage, counted with `tools/form_coverage.py` from the records of the run above. The baseline is the union of the seven record-writing shader tests run on WARP from a clean copy of 787ace7. | | gfx1013 | gfx1030 (RDNA2) | |---|---|---| | `main` at 787ace7 | 515 of 1968 | 510 of 1863 | | this change | 525 of 1968 | 520 of 1863 | The forms added are exactly `v_xnor_b32`, `v_xnor_b32_e64`, `v_and_b32_e64`, `v_or_b32_e64`, `v_xor_b32_e64`, `v_not_b32_e64`, `v_lshlrev_b32_e64`, `v_lshrrev_b32_e64`, `v_ashrrev_i32_e64` and `v_cvt_f32_ubyte2_e64`, on both lists. None is removed. `docs/coverage/dashboard.svg` is not regenerated here. What this does not show: that the console computes the same results (the draws run on desktop GPUs), and the `v_xnor_b32` semantics against the ISA document. Overlap with open pull requests: #340 (which drew the other accepted e64 forms) is merged and does not contain these. The diffs of the open shader pull requests (38 read) were searched for the ten form names on added lines; none adds them. The closest is #678 (three-operand integer ALU), which uses different instructions. Like every open shader pull request, this one appends a line to the `check_binary` fixture list, so a textual conflict there with whichever lands first is expected and trivial. _AI-assisted (Claude Code). The Windows results were measured locally._ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:44:32 +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!722
No description provided.