shader: lower v_pack_b32_f16 in pixel_aot #994

Merged
rasptum merged 1 commit from upstream-pr/1001 into main 2026-11-23 20:56:03 +00:00
rasptum commented 2026-11-23 20:38:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-23T20:38:09Z.


What changed

Lower the gfx1013 VOP3OpSel form v_pack_b32_f16 in tools/pixel_aot.py through the existing INTEGER table as

(S0 & 0xffff) | ((S1 & 0xffff) << 16)

and list it in INTEGER_VOP3_ONLY, so the _e32 spelling is refused. src0 supplies D[15:0] and src1 D[31:16], copied from each source's low binary16 encoding with no conversion, rounding or NaN handling (AMD RDNA ISA reference: D[15:0].f16 = S0.f16; D[31:16].f16 = S1.f16). tools/ffx_dispatch_aot.py already lowers the same mnemonic with this expression, so this aligns the two translators rather than adding new semantics. Sources go through the existing int_operand path, which refuses float modifiers, wide literals, untracked or unwritten registers, outstanding samples and the whole-quad mask.

tests/pixel_aot_check.py adds a draw-pack-b32 mode:

  • A and B come from constants s44 and s45 into v18 and v19, with distinct noisy upper halves 0xa5a5 and 0x5a5a.
  • Three packs read register/register, SGPR/register and register/SGPR; a fourth writes back to v18, its own src0, so a lowering that writes the destination before reading src0 differs.
  • Five rows vary the low halves: an asymmetric pair, a quiet NaN half, a signed-zero half, a NaN half in src1 (bits 31:16, still a normal binary32 word) and two zero halves that must give zero. All are read back through R32G32B32A32_UINT bit for bit at all 64 texels.
  • Five negative controls, each replacing one channel on the first row, must report pixel_mismatch: swapped halves, src0's high half leaked into the low half, src0 taken from bits 31:16, src1 placed in the low half, and src0 read after the in-place destination write.
  • Static lowering controls pin the emitted expression and refuse _e32, clamp, op_sel, float modifiers, a wrong operand count, v256, s106, an untracked register, an outstanding sample and the SDWA spelling.

tests/form_coverage_check.py counts ("VOP3", "v_pack_b32_f16") in both docs/coverage/gfx1013.tsv and docs/coverage/rdna2.tsv, with a negative control that the form is uncovered without the accepted spelling. CMakeLists.txt registers pixel_aot_pack_b32_warp and pixel_aot_pack_b32_hardware in the existing adapter loop, and docs/experiments.md records the definition, the refused modifiers and the measured result.

Commands run

cmake --preset dev
cmake --build --preset dev
ctest --preset dev --no-tests=error -R "^pixel_aot_pack_b32_" -V
cmake --preset release
cmake --build --preset release
ctest --preset release --no-tests=error -R "^pixel_aot_pack_b32_"
ctest --preset dev -R "^pixel_aot_"
python -B tests/form_coverage_check.py
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py

Results

Commit b6d4151 on top of 185ffbe; build from a VS 2022 x64 developer environment (tools/dev.ps1), Windows 10 (10.0.19045.6466).

  • dev pixel_aot_pack_b32_hardware: pass (2 of 2, NVIDIA GeForce RTX 3060, driver 32.0.15.9636)
  • dev pixel_aot_pack_b32_warp: pass
  • release pixel_aot_pack_b32_hardware: pass
  • release pixel_aot_pack_b32_warp: pass (WARP, Microsoft Basic Render Driver 10.0.19041.5794)
  • python -B tests/form_coverage_check.py: pass
  • python -B tests/docs_links_check.py: pass (13 Markdown files, 195 links)
  • python -B tests/bidi_controls_check.py: pass (796 files)
  • dev ctest -R "^pixel_aot_": see the suite note below

Every negative control was exercised by the passing draws; if a control produced the right word the batch status list would not match and the test would fail.

No capability skips: both adapters ran the tests and neither returned 77.

Suite note

The dev pixel_aot_* suite ran 104 tests. pixel_aot_blend_scalar_hardware and pixel_aot_title_loads_warp failed; both reproduce identically with this branch's Python sources restored to the base commit in the same built tree (same binaries, same adapters), so they are not caused by this change — the first is a one-ULP blend difference on this GPU. A later run also recorded pixel_aot_hardware as a timeout at the 60 s limit under residual load; run alone it passes in 54.5 s, and it passed in the earlier full run. These are listed because a skip, a pass and a failure must stay separate.

The LLVM 15 assemble/disassemble round trip was not run on this machine (no LLVM 15 with gfx1013 here); the new program is added to the round-trip fixture list that the LLVM job runs.

Refs #967

AI-assisted (OpenCode)

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6568354500 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1001). Originally posted by [rasptum](https://github.com/rasptum) on 2026-11-23T20:38:09Z. --- ## What changed Lower the gfx1013 VOP3OpSel form `v_pack_b32_f16` in `tools/pixel_aot.py` through the existing `INTEGER` table as ``` (S0 & 0xffff) | ((S1 & 0xffff) << 16) ``` and list it in `INTEGER_VOP3_ONLY`, so the `_e32` spelling is refused. src0 supplies D[15:0] and src1 D[31:16], copied from each source's low binary16 encoding with no conversion, rounding or NaN handling (AMD RDNA ISA reference: `D[15:0].f16 = S0.f16; D[31:16].f16 = S1.f16`). `tools/ffx_dispatch_aot.py` already lowers the same mnemonic with this expression, so this aligns the two translators rather than adding new semantics. Sources go through the existing `int_operand` path, which refuses float modifiers, wide literals, untracked or unwritten registers, outstanding samples and the whole-quad mask. `tests/pixel_aot_check.py` adds a `draw-pack-b32` mode: - A and B come from constants s44 and s45 into v18 and v19, with distinct noisy upper halves 0xa5a5 and 0x5a5a. - Three packs read register/register, SGPR/register and register/SGPR; a fourth writes back to v18, its own src0, so a lowering that writes the destination before reading src0 differs. - Five rows vary the low halves: an asymmetric pair, a quiet NaN half, a signed-zero half, a NaN half in src1 (bits 31:16, still a normal binary32 word) and two zero halves that must give zero. All are read back through `R32G32B32A32_UINT` bit for bit at all 64 texels. - Five negative controls, each replacing one channel on the first row, must report `pixel_mismatch`: swapped halves, src0's high half leaked into the low half, src0 taken from bits 31:16, src1 placed in the low half, and src0 read after the in-place destination write. - Static lowering controls pin the emitted expression and refuse `_e32`, ` clamp`, ` op_sel`, float modifiers, a wrong operand count, `v256`, `s106`, an untracked register, an outstanding sample and the SDWA spelling. `tests/form_coverage_check.py` counts `("VOP3", "v_pack_b32_f16")` in both `docs/coverage/gfx1013.tsv` and `docs/coverage/rdna2.tsv`, with a negative control that the form is uncovered without the accepted spelling. `CMakeLists.txt` registers `pixel_aot_pack_b32_warp` and `pixel_aot_pack_b32_hardware` in the existing adapter loop, and `docs/experiments.md` records the definition, the refused modifiers and the measured result. ## Commands run ``` cmake --preset dev cmake --build --preset dev ctest --preset dev --no-tests=error -R "^pixel_aot_pack_b32_" -V cmake --preset release cmake --build --preset release ctest --preset release --no-tests=error -R "^pixel_aot_pack_b32_" ctest --preset dev -R "^pixel_aot_" python -B tests/form_coverage_check.py python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py ``` ## Results Commit `b6d4151` on top of `185ffbe`; build from a VS 2022 x64 developer environment (`tools/dev.ps1`), Windows 10 (10.0.19045.6466). - dev `pixel_aot_pack_b32_hardware`: **pass** (2 of 2, NVIDIA GeForce RTX 3060, driver 32.0.15.9636) - dev `pixel_aot_pack_b32_warp`: **pass** - release `pixel_aot_pack_b32_hardware`: **pass** - release `pixel_aot_pack_b32_warp`: **pass** (WARP, Microsoft Basic Render Driver 10.0.19041.5794) - `python -B tests/form_coverage_check.py`: **pass** - `python -B tests/docs_links_check.py`: **pass** (13 Markdown files, 195 links) - `python -B tests/bidi_controls_check.py`: **pass** (796 files) - dev `ctest -R "^pixel_aot_"`: see the suite note below Every negative control was exercised by the passing draws; if a control produced the right word the batch status list would not match and the test would fail. No capability skips: both adapters ran the tests and neither returned 77. ## Suite note The dev `pixel_aot_*` suite ran 104 tests. `pixel_aot_blend_scalar_hardware` and `pixel_aot_title_loads_warp` failed; both reproduce identically with this branch's Python sources restored to the base commit in the same built tree (same binaries, same adapters), so they are not caused by this change — the first is a one-ULP blend difference on this GPU. A later run also recorded `pixel_aot_hardware` as a **timeout** at the 60 s limit under residual load; run alone it passes in 54.5 s, and it passed in the earlier full run. These are listed because a skip, a pass and a failure must stay separate. The LLVM 15 assemble/disassemble round trip was not run on this machine (no LLVM 15 with gfx1013 here); the new program is added to the round-trip fixture list that the LLVM job runs. Refs #967 AI-assisted (OpenCode)
upstream-sync closed this pull request 2026-11-24 06:45:47 +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!994
No description provided.