shader: lower gfx1013 s_bfm_b32 in pixel_aot #595

Merged
JB2WIN merged 3 commits from upstream-pr/601 into main 2026-11-22 15:48:10 +00:00
JB2WIN commented 2026-11-22 15:08:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-22T15:08:43Z.


Change

tools/pixel_aot.py now lowers s_bfm_b32 through the SCALAR table: ((1u << (S0 & 31u)) - 1u) << (S1 & 31u), with no SCC write. s_bfm_b64 was already lowered (SALU_HELPERS["s_bfm_b64"]); this follows its count-mask convention (& 63u there). The scanner picks the form up from the table.

  • Semantics source: LLVM 15 selects S_BFM_B32 for (shl (add (shl 1, a), -1), b) (SIInstructions.td, BFMPatterns). The 5-/6-bit count masking is the usual SOP2 convention and an assumption. I could not check it against the RDNA 2 ISA PDF, and docs/experiments.md says so.
  • Changed expectations: s_bfm_b32 s70, 4, 8 moves from the rejected to the supported list, and s_bfm_b32 leaves rejected_forms in tests/form_coverage_check.py. Five new rejections are added: VGPR source or destination, pair destination, s106, wrong operand count, and reads of pending scalar loads.

Fixes #596. AI-assisted (Claude Code).

Verification

Windows 11 (10.0.26200.9974), NVIDIA GeForce RTX 3080 (driver 32.0.16.2124) and WARP 10.0.26100.9818, head on c8a3fd9.

  • Static checks: the formula is emitted as shown. A following s_cselect_b32 keeps selecting on the earlier compare, which shows SCC is unchanged. This is checked statically only, and the docs say so.
  • New integer-export draw check_bfm_draw in the blend-scalar mode. Channels: two s_bfm_b32 results, plus s_bfm_b64 lo/hi. Five word sets cover counts 0, 1, 31, 32, 33, 63 and 64, plus wrapping offsets. Generated-HLSL controls narrow the count mask to 4 bits, or swap count and offset; each gives pixel_mismatch. Removing the mask entirely is not observable on the GPU, because DXIL masks shift amounts itself; the static check catches that case.
  • Targeted ctest: ctest --preset dev --no-tests=error -R "^(pixel_aot_|rdna2_tools_check$|pso_readiness)" passed 22/22. pixel_aot_blend_scalar_hardware took 36.7 s (timeout 60 s).
  • Full ctest: ctest --preset dev --no-tests=error passed 278/278, with skips bvh_wave64_hardware, bvh_wave64_warp and wave_shuffle_warp.
  • LLVM 15 round trip: tests/pixel_aot_check.py binary with LLVM 15.0.7 exited 0, run locally (fixture bfm_scalar_ops). The controls, form_coverage_check.py, docs_links_check.py and rdna2_tools_check.py pass.

Evidence and follow-up

  • Synthetic inputs only.
  • Timing note: #595 also adds a draw to the blend-scalar mode (34.7 s on its own branch). If both land, pixel_aot_blend_scalar_hardware on this RTX 3080 may get close to the 45 s budget the suite keeps under its 60 s timeout. Splitting one of them into its own mode would be the fix. I can do that in whichever PR lands second.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6543977631 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/601). Originally posted by [JB2WIN](https://github.com/JB2WIN) on 2026-11-22T15:08:43Z. --- ## Change `tools/pixel_aot.py` now lowers `s_bfm_b32` through the `SCALAR` table: `((1u << (S0 & 31u)) - 1u) << (S1 & 31u)`, with no SCC write. `s_bfm_b64` was already lowered (`SALU_HELPERS["s_bfm_b64"]`); this follows its count-mask convention (`& 63u` there). The scanner picks the form up from the table. - Semantics source: LLVM 15 selects `S_BFM_B32` for `(shl (add (shl 1, a), -1), b)` (`SIInstructions.td`, `BFMPatterns`). The 5-/6-bit count masking is the usual SOP2 convention and an **assumption**. I could not check it against the RDNA 2 ISA PDF, and `docs/experiments.md` says so. - **Changed expectations:** `s_bfm_b32 s70, 4, 8` moves from the rejected to the supported list, and `s_bfm_b32` leaves `rejected_forms` in `tests/form_coverage_check.py`. Five new rejections are added: VGPR source or destination, pair destination, `s106`, wrong operand count, and reads of pending scalar loads. Fixes #596. AI-assisted (Claude Code). ## Verification Windows 11 (10.0.26200.9974), NVIDIA GeForce RTX 3080 (driver 32.0.16.2124) and WARP 10.0.26100.9818, head on `c8a3fd9`. - **Static checks:** the formula is emitted as shown. A following `s_cselect_b32` keeps selecting on the earlier compare, which shows SCC is unchanged. This is checked statically only, and the docs say so. - **New integer-export draw `check_bfm_draw`** in the `blend-scalar` mode. Channels: two `s_bfm_b32` results, plus `s_bfm_b64` lo/hi. Five word sets cover counts 0, 1, 31, 32, 33, 63 and 64, plus wrapping offsets. Generated-HLSL controls narrow the count mask to 4 bits, or swap count and offset; each gives `pixel_mismatch`. Removing the mask entirely is not observable on the GPU, because DXIL masks shift amounts itself; the static check catches that case. - **Targeted ctest:** `ctest --preset dev --no-tests=error -R "^(pixel_aot_|rdna2_tools_check$|pso_readiness)"` passed 22/22. `pixel_aot_blend_scalar_hardware` took 36.7 s (timeout 60 s). - **Full ctest:** `ctest --preset dev --no-tests=error` passed 278/278, with skips `bvh_wave64_hardware`, `bvh_wave64_warp` and `wave_shuffle_warp`. - **LLVM 15 round trip:** `tests/pixel_aot_check.py binary` with LLVM 15.0.7 exited 0, run locally (fixture `bfm_scalar_ops`). The controls, `form_coverage_check.py`, `docs_links_check.py` and `rdna2_tools_check.py` pass. ## Evidence and follow-up - Synthetic inputs only. - **Timing note:** #595 also adds a draw to the `blend-scalar` mode (34.7 s on its own branch). If both land, `pixel_aot_blend_scalar_hardware` on this RTX 3080 may get close to the 45 s budget the suite keeps under its 60 s timeout. Splitting one of them into its own mode would be the fix. I can do that in whichever PR lands second. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:43:53 +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!595
No description provided.