test(shader): extend int16 ternary matrix for all orderings, ties and med3 chain #834

Merged
alexander-src merged 1 commit from upstream-pr/840 into main 2026-11-23 11:49:38 +00:00
alexander-src commented 2026-11-23 11:03:06 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by alexander-src on 2026-11-23T11:03:06Z.


Summary

Lower the 6 non-packed 3-operand 16-bit integer VOP3 ops (v_min3_i16, v_max3_i16, v_med3_i16, v_min3_u16, v_max3_u16, and v_med3_u16) in tools/pixel_aot.py under the existing ("low16", alu) contract, with LLVM gfx1013 binary round-trip, draw, scanner, and form coverage checks (+6 forms in gfx1013.tsv and rdna2.tsv).

Changes

  • tools/pixel_aot.py:
    • Add VOP3_INT16_3OP (min3_i16, max3_i16, med3_i16, min3_u16, max3_u16, med3_u16) and the corresponding 3-operand lane expressions in pk_int16_lane_expr.
    • Lower unsuffixed and _e64 spellings under the same ("low16", alu) contract as VOP3_INT16: each operand reads bits [15:0] (sign-extended for i16, zero-extended for u16), accepts VGPR, SGPR, low16 VGPR, inline integers -16..64, or 16-bit literals up to 0xffff, and writes a ("low16", alu) result refused by whole-word and high-half readers until widened or consumed by another 16-bit op.
    • Reject op_sel, clamp, source modifiers, DPP, SDWA, v_{min3,max3,med3}_f16, out-of-range registers, untracked sources, pending scalar loads, pending sample reads/writes, and non-entry execution masks.
  • tools/scan_unsupported_shaders.py: recognize the 6 supported 3-operand 16-bit integer forms using INT16_VGPR and INT16_SOURCE.
  • tests/pixel_aot_check.py, CMakeLists.txt: add check_int16_min3_controls(), 2 LLVM gfx1013 binary round-trip fixtures, and draw-int16-min3 (pixel_aot_int16_min3_{warp,hardware}) lossless R32G32B32A32_UINT draws covering all 6 ops across 6 word sets (all six med3 orderings, ties, 0x7fff/0x8000/0xffff/0x0000 signed/unsigned boundary flips, differing high halves, inline/hex16 constants, and a chained v_add_nc_u16 low16 input), plus 1-bit flip controls and shader mutations (i16/u16 swaps, med3 -> min3, high-half source reads).
  • tests/form_coverage_check.py, tests/rdna2_tools_check.py, docs/experiments.md: assert all 6 new forms in gfx1013.tsv and rdna2.tsv while keeping f16 neighbours excluded, add scanner tests, and document behavior.

Verification

Ran on Linux x86_64 (llvm-mc / libLLVM.so 23.1.4; Windows DXC/D3D12 WARP and hardware draws run in CI):

  • out/pe-env/bin/python -B tests/form_coverage_check.py: passed
  • out/pe-env/bin/python -B tests/pso_readiness_check.py: passed
  • out/pe-env/bin/python -B tests/rdna2_tools_check.py: 67 tests OK (1 skipped)
  • out/pe-env/bin/python -B tests/docs_links_check.py: passed (13 files, 161 links)
  • out/pe-env/bin/python -B tests/bidi_controls_check.py: passed (677 files)
  • pixel_aot_check.check_controls + llvm-mc -mcpu=gfx1013 + libLLVM.so round-trip on both int16_min3_ops(0) and int16_min3_ops(1) + mutation output checks: passed

AI-assisted: yes

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6557822535 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/840). Originally posted by [alexander-src](https://github.com/alexander-src) on 2026-11-23T11:03:06Z. --- ### Summary Lower the 6 non-packed 3-operand 16-bit integer VOP3 ops (`v_min3_i16`, `v_max3_i16`, `v_med3_i16`, `v_min3_u16`, `v_max3_u16`, and `v_med3_u16`) in `tools/pixel_aot.py` under the existing `("low16", alu)` contract, with LLVM `gfx1013` binary round-trip, draw, scanner, and form coverage checks (+6 forms in `gfx1013.tsv` and `rdna2.tsv`). ### Changes - `tools/pixel_aot.py`: - Add `VOP3_INT16_3OP` (`min3_i16`, `max3_i16`, `med3_i16`, `min3_u16`, `max3_u16`, `med3_u16`) and the corresponding 3-operand lane expressions in `pk_int16_lane_expr`. - Lower unsuffixed and `_e64` spellings under the same `("low16", alu)` contract as `VOP3_INT16`: each operand reads bits `[15:0]` (sign-extended for `i16`, zero-extended for `u16`), accepts VGPR, SGPR, `low16` VGPR, inline integers `-16..64`, or 16-bit literals up to `0xffff`, and writes a `("low16", alu)` result refused by whole-word and high-half readers until widened or consumed by another 16-bit op. - Reject `op_sel`, `clamp`, source modifiers, DPP, SDWA, `v_{min3,max3,med3}_f16`, out-of-range registers, untracked sources, pending scalar loads, pending sample reads/writes, and non-entry execution masks. - `tools/scan_unsupported_shaders.py`: recognize the 6 supported 3-operand 16-bit integer forms using `INT16_VGPR` and `INT16_SOURCE`. - `tests/pixel_aot_check.py`, `CMakeLists.txt`: add `check_int16_min3_controls()`, 2 LLVM `gfx1013` binary round-trip fixtures, and `draw-int16-min3` (`pixel_aot_int16_min3_{warp,hardware}`) lossless `R32G32B32A32_UINT` draws covering all 6 ops across 6 word sets (all six `med3` orderings, ties, `0x7fff`/`0x8000`/`0xffff`/`0x0000` signed/unsigned boundary flips, differing high halves, inline/hex16 constants, and a chained `v_add_nc_u16` `low16` input), plus 1-bit flip controls and shader mutations (`i16`/`u16` swaps, `med3 -> min3`, high-half source reads). - `tests/form_coverage_check.py`, `tests/rdna2_tools_check.py`, `docs/experiments.md`: assert all 6 new forms in `gfx1013.tsv` and `rdna2.tsv` while keeping `f16` neighbours excluded, add scanner tests, and document behavior. ### Verification Ran on Linux x86_64 (`llvm-mc` / `libLLVM.so` 23.1.4; Windows DXC/D3D12 WARP and hardware draws run in CI): - `out/pe-env/bin/python -B tests/form_coverage_check.py`: passed - `out/pe-env/bin/python -B tests/pso_readiness_check.py`: passed - `out/pe-env/bin/python -B tests/rdna2_tools_check.py`: 67 tests OK (1 skipped) - `out/pe-env/bin/python -B tests/docs_links_check.py`: passed (13 files, 161 links) - `out/pe-env/bin/python -B tests/bidi_controls_check.py`: passed (677 files) - `pixel_aot_check.check_controls` + `llvm-mc -mcpu=gfx1013` + `libLLVM.so` round-trip on both `int16_min3_ops(0)` and `int16_min3_ops(1)` + mutation output checks: passed AI-assisted: yes
upstream-sync closed this pull request 2026-11-24 06:45:01 +00:00
R0Y00 commented 2026-11-24 06:49:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T11:16:36Z.


The six lowering forms are already on main through #834, with the same low16 contract and LLVM/readback controls. Please keep your authorship and rebase this as a focused test follow-up. The all-six-orderings/ties matrix and chaining a low16 producer into the median are candidates if they exercise cases the current ternary fixture misses. Extend that fixture and its independent reference in place, retaining its MAD and high-half rejection controls. With the lowering already shared, a second dispatch table and duplicate CTests would give the same coverage.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7099357899 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/840#issuecomment-7099357899). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T11:16:36Z. --- The six lowering forms are already on main through #834, with the same low16 contract and LLVM/readback controls. Please keep your authorship and rebase this as a focused test follow-up. The all-six-orderings/ties matrix and chaining a low16 producer into the median are candidates if they exercise cases the current ternary fixture misses. Extend that fixture and its independent reference in place, retaining its MAD and high-half rejection controls. With the lowering already shared, a second dispatch table and duplicate CTests would give the same coverage.
alexander-src commented 2026-11-24 06:49:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by alexander-src on 2026-11-23T11:34:37Z.


Rebased onto current main (527a255) in 856061c as a focused test follow-up touching only tests/pixel_aot_check.py, dropping the duplicate lowering table and CTests while keeping all of #834's MAD and high-half rejection controls intact.

Specifically, #834's 6-set INT16_TERNARY_WORDS missed the signed (1, 2, 0) ordering (c < a < b), the unsigned (2, 0, 1) ordering (b < c < a), all four tie shapes (a == b, b == c, a == c, a == b == c), and chaining a low16 producer into v_med3_u16. This follow-up extends INT16_TERNARY_WORDS to 12 sets with assertions covering all six strict signed and unsigned orderings plus all four tie shapes, adds group 4 (v_sub_nc_u16 -> v_med3_u16 -> v_med3_i16 -> v_min3_i16) to the existing binary round-trip and draw-int16-ternary fixture/reference (with signed_as_unsigned and med3_as_min3 draw mutations), and adds v_med3_u16 full-word and WORD_1 refusal checks.

Re-ran all 5 Linux test suites, check_controls, and LLVM gfx1013 binary round-trips on groups 0..4; Windows DXC/D3D12 WARP and hardware draws run in CI.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7099819626 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/840#issuecomment-7099819626). Originally posted by [alexander-src](https://github.com/alexander-src) on 2026-11-23T11:34:37Z. --- Rebased onto current `main` (`527a255`) in `856061c` as a focused test follow-up touching only `tests/pixel_aot_check.py`, dropping the duplicate lowering table and CTests while keeping all of `#834`'s MAD and high-half rejection controls intact. Specifically, `#834`'s 6-set `INT16_TERNARY_WORDS` missed the signed `(1, 2, 0)` ordering (`c < a < b`), the unsigned `(2, 0, 1)` ordering (`b < c < a`), all four tie shapes (`a == b`, `b == c`, `a == c`, `a == b == c`), and chaining a `low16` producer into `v_med3_u16`. This follow-up extends `INT16_TERNARY_WORDS` to 12 sets with assertions covering all six strict signed and unsigned orderings plus all four tie shapes, adds `group 4` (`v_sub_nc_u16 -> v_med3_u16 -> v_med3_i16 -> v_min3_i16`) to the existing binary round-trip and `draw-int16-ternary` fixture/reference (with `signed_as_unsigned` and `med3_as_min3` draw mutations), and adds `v_med3_u16` full-word and `WORD_1` refusal checks. Re-ran all 5 Linux test suites, `check_controls`, and LLVM `gfx1013` binary round-trips on groups 0..4; Windows DXC/D3D12 WARP and hardware draws run in CI.
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!834
No description provided.