shader: lower the remaining no-carry 32-bit add and sub forms in pixel_aot #576

Merged
JB2WIN merged 3 commits from upstream-pr/582 into main 2026-11-22 15:08:29 +00:00
JB2WIN commented 2026-11-22 14:06:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-22T14:06:46Z.


Change

tools/pixel_aot.py now lowers the remaining 32-bit no-carry add/sub forms. This builds on #495 (VOP2 v_add/sub_nc_u32_e32) and #570 (v_subrev_nc_u32_e32):

  • v_add_nc_u32_e64, v_sub_nc_u32_e64, v_subrev_nc_u32_e64
  • the VOP3-only v_add_nc_i32 and v_sub_nc_i32, in the unsuffixed spelling LLVM 15 prints. These are 32-bit wraparound with no clamp, so they produce the same bits as the u32 forms.

The add/sub/subrev lowering is now one table branch (subrev = b - a) instead of #570's separate subrev branch. #570's check_subrev_u32_draw is unchanged.

Refused and tested as rejections, each paired with its accepted spelling:

  • clamp on these forms
  • abs/neg on an e64 source
  • v_add_nc_i32_e64: the explicit suffix is not the printed form, and gfx1013.tsv has no row for it
  • SDWA
  • DPP controls other than quad_perm/dpp8, which the existing DPP table already lowers

Float-written inline constants are taken as their binary32 bits, as for the #495 forms. This is now pinned for 1.0 and -1.0. The scanner pattern and KNOWN_RDNA2_BASE_OPCODES cover the family. The scanner's INTEGER_SOURCE class is coarser than the translator and also accepts v106, as before.

Changed expectation: the e64 rows in the bad_vop2 rejection list (from #495/#570) are removed because e64 is now accepted. The new static group asserts their lowering.

Semantics: subrev = src1 − src0 follows the translator's existing convention. It matches LLVM 15 TableGen (VOP2Instructions.td: V_SUBREV_U32 has revOp v_sub_u32, and the REV patterns swap operands; gfx10 V_SUBREV_NC_U32 encodes that pseudo). The draws check consistency with this convention on desktop GPUs. I could not check it against the RDNA 2 ISA PDF.

AI-assisted (Claude Code).

Verification

Head is rebased on bbebcad. Windows 11 (10.0.26200.9974), NVIDIA GeForce RTX 3080 (driver 32.0.16.2124, debug layer on) and WARP 10.0.26100.9818.

  • New mode draw-integer-nc with CTest pixel_aot_integer_nc_{hardware,warp} (about 3.3 s / 0.8 s). It uses lossless integer readback and 11 draws: 3 groups × 5 rows (A, B). Every input and result is a normal binary32 pattern or ±0, and the test asserts this. The rows cover unsigned wrap, signed overflow, borrow, sub ≠ subrev, high-bit wrap, inline constants and VGPR-first operands.
  • Negative control: swapping the sub/subrev expected words gives pixel_mismatch on both adapters. Dev-time mutation (subrev as a - b) fails both tests and was reverted.
  • ctest --preset dev --no-tests=error -R "^(pixel_aot_|rdna2_tools_check$|pso_readiness)": 22/22.
  • Full ctest --preset dev --no-tests=error (on d4c7656, before the last trivial rebase): 279 tests, 0 failed. Skips: bvh_wave64_hardware, bvh_wave64_warp, wave_shuffle_warp.
  • tests/pixel_aot_check.py binary with LLVM 15.0.7, locally: exit 0. tests/pixel_aot_check.py (controls), rdna2_tools_check.py, form_coverage_check.py and docs_links_check.py all pass.

Evidence and follow-up

  • Synthetic shader literals and constants only. No game data.
  • Possible textual overlap with #576 (it also edits KNOWN_RDNA2_BASE_OPCODES).
  • dashboard.svg is not regenerated.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6543324671 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/582). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-22T14:06:46Z. --- ## Change `tools/pixel_aot.py` now lowers the remaining 32-bit no-carry add/sub forms. This builds on #495 (VOP2 `v_add/sub_nc_u32_e32`) and #570 (`v_subrev_nc_u32_e32`): - `v_add_nc_u32_e64`, `v_sub_nc_u32_e64`, `v_subrev_nc_u32_e64` - the VOP3-only `v_add_nc_i32` and `v_sub_nc_i32`, in the unsuffixed spelling LLVM 15 prints. These are 32-bit wraparound with no clamp, so they produce the same bits as the u32 forms. The add/sub/subrev lowering is now one table branch (subrev = `b - a`) instead of #570's separate subrev branch. #570's `check_subrev_u32_draw` is unchanged. Refused and tested as rejections, each paired with its accepted spelling: - ` clamp` on these forms - `abs`/`neg` on an e64 source - `v_add_nc_i32_e64`: the explicit suffix is not the printed form, and `gfx1013.tsv` has no row for it - SDWA - DPP controls other than `quad_perm`/`dpp8`, which the existing DPP table already lowers Float-written inline constants are taken as their binary32 bits, as for the #495 forms. This is now pinned for `1.0` and `-1.0`. The scanner pattern and `KNOWN_RDNA2_BASE_OPCODES` cover the family. The scanner's `INTEGER_SOURCE` class is coarser than the translator and also accepts `v106`, as before. **Changed expectation:** the e64 rows in the `bad_vop2` rejection list (from #495/#570) are removed because e64 is now accepted. The new static group asserts their lowering. Semantics: `subrev` = src1 − src0 follows the translator's existing convention. It matches LLVM 15 TableGen (`VOP2Instructions.td`: `V_SUBREV_U32` has revOp `v_sub_u32`, and the REV patterns swap operands; gfx10 `V_SUBREV_NC_U32` encodes that pseudo). The draws check consistency with this convention on desktop GPUs. I could not check it against the RDNA 2 ISA PDF. AI-assisted (Claude Code). ## Verification Head is rebased on `bbebcad`. Windows 11 (10.0.26200.9974), NVIDIA GeForce RTX 3080 (driver 32.0.16.2124, debug layer on) and WARP 10.0.26100.9818. - New mode `draw-integer-nc` with CTest `pixel_aot_integer_nc_{hardware,warp}` (about 3.3 s / 0.8 s). It uses lossless integer readback and 11 draws: 3 groups × 5 rows (A, B). Every input and result is a normal binary32 pattern or ±0, and the test asserts this. The rows cover unsigned wrap, signed overflow, borrow, sub ≠ subrev, high-bit wrap, inline constants and VGPR-first operands. - Negative control: swapping the sub/subrev expected words gives `pixel_mismatch` on both adapters. Dev-time mutation (subrev as `a - b`) fails both tests and was reverted. - `ctest --preset dev --no-tests=error -R "^(pixel_aot_|rdna2_tools_check$|pso_readiness)"`: 22/22. - Full `ctest --preset dev --no-tests=error` (on `d4c7656`, before the last trivial rebase): 279 tests, 0 failed. Skips: `bvh_wave64_hardware`, `bvh_wave64_warp`, `wave_shuffle_warp`. - `tests/pixel_aot_check.py binary` with LLVM 15.0.7, locally: exit 0. `tests/pixel_aot_check.py` (controls), `rdna2_tools_check.py`, `form_coverage_check.py` and `docs_links_check.py` all pass. ## Evidence and follow-up - Synthetic shader literals and constants only. No game data. - Possible textual overlap with #576 (it also edits `KNOWN_RDNA2_BASE_OPCODES`). - `dashboard.svg` is not regenerated. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:43:48 +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!576
No description provided.