shader: pixel_aot wave32 masked regions (s_and_saveexec_b32, b32 closes and else) #2129

Closed
opened 2026-11-25 01:25:56 +00:00 by legacy-code-archaeologist · 3 comments
legacy-code-archaeologist commented 2026-11-25 01:25:56 +00:00 (Migrated from github.com)
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-25T01:25:56Z.


pixel_aot lowers the structured masked region only in its wave64 spellings (#651, #1315 stages A and B). #1315 measured that wave32 regions are common in the same input. Its author counted 11,723 simple regions in 967 PS records opening with s_and_saveexec_b32 saved, vcc_lo and closing with s_mov_b32 exec_lo, saved; 3,117 of them (805 records) have an s_andn2_b32 exec_lo, saved, exec_lo else. Today lower(..., wave_size=32) refuses the opener as an unsupported instruction, and docs/experiments.md lists the wave32 close and else as rejected.

Proposed scope (one PR, all gated on the existing wave_size=32 guest profile)

  • Opener: s_and_saveexec_b32 sN, vcc_lo|sM, under the same preconditions as the b64 opener: no open region, the entry mask, a save register that is valid and not pending, and a condition tracked in exactly one register. Every other spelling, and any failed precondition, is refused as Unsupported execution mask save.
  • Closes: s_mov_b32 exec_lo, sN and s_or_b32 exec_lo, exec_lo, sN on the saved register.
  • Else: s_andn2_b32 exec_lo, sN, exec_lo, once per region.
  • Skips: s_cbranch_execz targets in their b32 spellings.
  • Width: a region accepts only the close and else spellings of its own width. A b32 line in a wave64 region keeps today's refusal, so no existing control changes.
  • SCC: as after the b64 MOV close, an SCC reader after either b32 close is refused. The opener has already made SCC unknown.
  • Unchanged: the arm, join, wait, scalar-load and scalar-ALU rules. The HLSL of wave64 programs does not change.

Evidence plan

  • HLSL equality: each wave32 fixture is derived line by line from a wave64 fixture: the plain region, the complementary pair, the skip, all saveexec if/else shapes, and the saveexec variants of the wait, scalar-ALU and scalar-load region families. It must translate to exactly the same HLSL. The per-lane condition is the same single-register compare, and HLSL names come from instruction indices, not SGPR names.
  • Refusals: every refusal is pinned with its exact message, and the mutants of each new branch must fail.
  • Draws: the pixel_aot_exec_regions_{warp,hardware} draws gain the wave32 variants, run on WARP, a Quadro M1000M and an Intel HD 530.
  • LLVM round trip: the LLVM 15 round trip covers the wave32 programs with +wavefrontsize32.

Out of scope

  • The wave32 v_cmpx opener after s_mov_b32 saved, exec_lo (4,681 regions in #1315).
  • Nesting, s_or_saveexec_b32, s_xor_b32 exec_lo and the other saveexec or wrexec variants.
  • A CLI flag, the other translators, and the scan_unsupported_shaders support list.

I'll take this unless someone already has it. I'll link the PR here.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6594980595 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2137). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-25T01:25:56Z. --- `pixel_aot` lowers the structured masked region only in its wave64 spellings (#651, #1315 stages A and B). #1315 measured that wave32 regions are common in the same input. Its author counted 11,723 simple regions in 967 PS records opening with `s_and_saveexec_b32 saved, vcc_lo` and closing with `s_mov_b32 exec_lo, saved`; 3,117 of them (805 records) have an `s_andn2_b32 exec_lo, saved, exec_lo` else. Today `lower(..., wave_size=32)` refuses the opener as an unsupported instruction, and `docs/experiments.md` lists the wave32 close and else as rejected. ## Proposed scope (one PR, all gated on the existing `wave_size=32` guest profile) - **Opener:** `s_and_saveexec_b32 sN, vcc_lo|sM`, under the same preconditions as the b64 opener: no open region, the entry mask, a save register that is valid and not pending, and a condition tracked in exactly one register. Every other spelling, and any failed precondition, is refused as `Unsupported execution mask save`. - **Closes:** `s_mov_b32 exec_lo, sN` and `s_or_b32 exec_lo, exec_lo, sN` on the saved register. - **Else:** `s_andn2_b32 exec_lo, sN, exec_lo`, once per region. - **Skips:** `s_cbranch_execz` targets in their b32 spellings. - **Width:** a region accepts only the close and else spellings of its own width. A b32 line in a wave64 region keeps today's refusal, so no existing control changes. - **SCC:** as after the b64 MOV close, an SCC reader after either b32 close is refused. The opener has already made SCC unknown. - **Unchanged:** the arm, join, wait, scalar-load and scalar-ALU rules. The HLSL of wave64 programs does not change. ## Evidence plan - **HLSL equality:** each wave32 fixture is derived line by line from a wave64 fixture: the plain region, the complementary pair, the skip, all saveexec if/else shapes, and the saveexec variants of the wait, scalar-ALU and scalar-load region families. It must translate to exactly the same HLSL. The per-lane condition is the same single-register compare, and HLSL names come from instruction indices, not SGPR names. - **Refusals:** every refusal is pinned with its exact message, and the mutants of each new branch must fail. - **Draws:** the `pixel_aot_exec_regions_{warp,hardware}` draws gain the wave32 variants, run on WARP, a Quadro M1000M and an Intel HD 530. - **LLVM round trip:** the LLVM 15 round trip covers the wave32 programs with `+wavefrontsize32`. ## Out of scope - The wave32 `v_cmpx` opener after `s_mov_b32 saved, exec_lo` (4,681 regions in #1315). - Nesting, `s_or_saveexec_b32`, `s_xor_b32 exec_lo` and the other saveexec or wrexec variants. - A CLI flag, the other translators, and the `scan_unsupported_shaders` support list. I'll take this unless someone already has it. I'll link the PR here. _AI-assisted._
tedin7 commented 2026-11-25 02:02:07 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:40:56Z.


Picking up wave32 masked regions (s_and_saveexec_b32, b32 closes and else) per the proposed scope, with Linux + Win2025 verification tests.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7149832392 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2137#issuecomment-7149832392). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:40:56Z. --- Picking up wave32 masked regions (`s_and_saveexec_b32`, b32 closes and else) per the proposed scope, with Linux + Win2025 verification tests.
legacy-code-archaeologist commented 2026-11-25 02:02:09 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-25T01:50:28Z.


@tedin7 thanks, but please hold off: I opened this issue as a claim and the implementation is already done locally. It is in its final pre-commit review, and the PR follows within the hour.

The branch already covers:

  • the opener, both closes, the else and the width-gated skip target in tools/pixel_aot.py;
  • check_wave32_region_controls, which asserts HLSL equality against each wave64 twin across the plain, else, wait, scalar-ALU, scalar-load and body families and pins every refusal with its message;
  • the wave32 twins in pixel_aot_exec_regions_{warp,hardware}, passing on WARP, a Quadro M1000M and an Intel HD 530;
  • the LLVM 15 round trip with +wavefrontsize32;
  • the deliberate form_coverage_check update.

If you want to help, a Linux or Win2025 run of the PR once it is up would be useful. A second implementation would only duplicate it.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7150018719 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2137#issuecomment-7150018719). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-25T01:50:28Z. --- @tedin7 thanks, but please hold off: I opened this issue as a claim and the implementation is already done locally. It is in its final pre-commit review, and the PR follows within the hour. The branch already covers: - the opener, both closes, the else and the width-gated skip target in `tools/pixel_aot.py`; - `check_wave32_region_controls`, which asserts HLSL equality against each wave64 twin across the plain, else, wait, scalar-ALU, scalar-load and body families and pins every refusal with its message; - the wave32 twins in `pixel_aot_exec_regions_{warp,hardware}`, passing on WARP, a Quadro M1000M and an Intel HD 530; - the LLVM 15 round trip with `+wavefrontsize32`; - the deliberate `form_coverage_check` update. If you want to help, a Linux or Win2025 run of the PR once it is up would be useful. A second implementation would only duplicate it. _AI-assisted._
legacy-code-archaeologist commented 2026-11-25 03:01:20 +00:00 (Migrated from github.com)
Author
Contributor

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-25T02:03:57Z.


PR: #2163 (opener, both closes, else, width-gated skip target; controls with HLSL equality against each wave64 twin; draws on WARP, Quadro M1000M and Intel HD 530; LLVM 15 round trip with +wavefrontsize32).

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7150275574 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/issues/2137#issuecomment-7150275574). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-25T02:03:57Z. --- PR: #2163 (opener, both closes, else, width-gated skip target; controls with HLSL equality against each wave64 twin; draws on WARP, Quadro M1000M and Intel HD 530; LLVM 15 round trip with +wavefrontsize32). _AI-assisted._
Sign in to join this conversation.
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#2129
No description provided.