shader: lower one-armed pixel CMPX skips with scalar loads and SALU #3828

Merged
timbot103 merged 1 commit from upstream-pr/3828 into main 2026-12-02 10:11:23 +00:00
timbot103 commented 2026-12-02 07:15:49 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T07:15:49Z.


Lowers wave64 pixel one-armed v_cmpx_* skips with scalar loads and SALU inside the arm, in the scalar tail between the skip target and EXEC restore, and after the restore (item W2 of #3814).

Part of #3814. Refs #3640, #3641, #3703.

Summary

  • src/gfx1013_direct_graphics.inl (pixel_readonly_arms):
    • Added wave_scalar(const Inst&) accepting scalar loads (Encoding::Smem with dst + memory_count <= 106; decoder only admits loads) and ordinary Sop1/Sop2/Sopk/Sopc SALU on SGPRs/constants while rejecting exec, movrel, pc, reg, wqm, rfe, loop, vskip, waitcnt, call, branch, fork, join, and special-register operands (VCC, EXEC, M0, VCCZ, EXECZ, SCC).
    • Generalized arm scalar support from Smem (op >= 8) / s_mov_b32 to wave_scalar; all arm-written scalars and SCC remain expired at the join so arm-conditional scalar writes cannot leak into the tail or post-restore code.
    • Added one-armed v_cmpx_* scalar-tail recognition between the s_cbranch_execz join and restore (wave_scalar, s_waitcnt, s_nop, s_clause), emitting scalar_tail_merges at the join so tail results stay live past the restore while the restore itself is a no-op.
    • Accepted s_or_b64 exec, exec, parent (either operand order) as a one-armed CMPX restore, expiring SCC at the restore.
    • Fail-closed guards: refuses tail or arm clobbers of the saved pair, vector/EXEC writes or EXEC/VCC reads or branches in the tail, non-skip branches entering the arm or tail, and tail/OR-restore forms combined with ELSE arms, inner s_and_saveexec, or s_and_saveexec masks.
  • tests/offscreen_check.cpp, tests/startup_flat_param.cpp, tests/desktop_gpu.h:
    • Extended --startup-pixel-words with an optional 6th argument (1..64 comma-separated hex words) bound as a root SRV at t0 so pixel stages loading from a root address can be read back on WARP and hardware GPUs; added CLI self-test cases.
  • tests/native_pixel_cmpx_scalar_tail_check.py + tests/cmake/native_pixel_cmpx_scalar_tail.cmake:
    • 5 positive shapes (salu-tail, arm-loads, tail-loads, after-restore-loads, or-restore-tail) verified for DXIL structure (br i1, phi, no wave ops, rawBufferLoad placement in arm vs post-join) and GPU readback (including swapped/all-arm/none-arm mismatch controls and whole-wave all-arm/none-arm tail runs).
    • 26 fail-closed refusal controls (arm scalar/load leaks including pre-defined SGPRs, SCC leaks across join and OR restore, saved-pair clobbers, vector/EXEC/VCC/branch in tail, branches into arm or tail, skip past restore, side-effecting arm ops).

Verification

Host: Windows 11 (10.0.26200.9974), MSVC C++20 /W4 (zero warnings on edited targets), inbox WARP (10.0.26100.9818), NVIDIA GeForce RTX 5080 (32.0.16.2140).

  • Debug (dev) & Release (release):
    • native_pixel_cmpx_scalar_tail_controls: passed in both configs (5 positive + 26 refusals).
    • native_pixel_cmpx_scalar_tail_warp: passed in both configs (WARP readback + negative mismatch controls + whole-wave runs).
    • native_pixel_cmpx_scalar_tail_hardware: passed in both configs (RTX 5080 readback + negative mismatch controls + whole-wave runs).
    • offscreen_check --self-test: passed in both configs.
    • Regression pass in both configs: native_direct_container, native_pixel_dxil, native_pixel_cmpx_discard_warp, native_pixel_cmpx_if_else_{controls,warp}, native_pixel_compare_mask_{warp,hardware,container,ir}, native_graphics_wqm_{hardware,warp,ir}, native_graphics_sampler_heap_{warp,hardware}, native_graphics_interface_library, native_graphics_vertex_vcc_join_{warp,hardware}, startup_flat_param_{controls,warp,hardware} (23/23 built pixel/graphics tests passed in both Debug and Release).
  • tests/bidi_controls_check.py, tests/docs_links_check.py, git diff --check origin/main..HEAD: all clean.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5601729620 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3828). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T07:15:49Z. --- Lowers wave64 pixel one-armed `v_cmpx_*` skips with scalar loads and SALU inside the arm, in the scalar tail between the skip target and EXEC restore, and after the restore (item **W2** of #3814). Part of #3814. Refs #3640, #3641, #3703. ## Summary - **`src/gfx1013_direct_graphics.inl` (`pixel_readonly_arms`):** - Added `wave_scalar(const Inst&)` accepting scalar loads (`Encoding::Smem` with `dst + memory_count <= 106`; decoder only admits loads) and ordinary `Sop1`/`Sop2`/`Sopk`/`Sopc` SALU on SGPRs/constants while rejecting `exec`, `movrel`, `pc`, `reg`, `wqm`, `rfe`, `loop`, `vskip`, `waitcnt`, `call`, `branch`, `fork`, `join`, and special-register operands (`VCC`, `EXEC`, `M0`, `VCCZ`, `EXECZ`, `SCC`). - Generalized arm scalar support from `Smem (op >= 8)` / `s_mov_b32` to `wave_scalar`; all arm-written scalars and SCC remain expired at the join so arm-conditional scalar writes cannot leak into the tail or post-restore code. - Added one-armed `v_cmpx_*` scalar-tail recognition between the `s_cbranch_execz` join and restore (`wave_scalar`, `s_waitcnt`, `s_nop`, `s_clause`), emitting `scalar_tail_merges` at the join so tail results stay live past the restore while the restore itself is a no-op. - Accepted `s_or_b64 exec, exec, parent` (either operand order) as a one-armed CMPX restore, expiring SCC at the restore. - Fail-closed guards: refuses tail or arm clobbers of the saved pair, vector/EXEC writes or EXEC/VCC reads or branches in the tail, non-skip branches entering the arm or tail, and tail/OR-restore forms combined with ELSE arms, inner `s_and_saveexec`, or `s_and_saveexec` masks. - **`tests/offscreen_check.cpp`, `tests/startup_flat_param.cpp`, `tests/desktop_gpu.h`:** - Extended `--startup-pixel-words` with an optional 6th argument (`1..64` comma-separated hex words) bound as a root SRV at `t0` so pixel stages loading from a root address can be read back on WARP and hardware GPUs; added CLI self-test cases. - **`tests/native_pixel_cmpx_scalar_tail_check.py` + `tests/cmake/native_pixel_cmpx_scalar_tail.cmake`:** - 5 positive shapes (`salu-tail`, `arm-loads`, `tail-loads`, `after-restore-loads`, `or-restore-tail`) verified for DXIL structure (`br i1`, `phi`, no wave ops, `rawBufferLoad` placement in arm vs post-join) and GPU readback (including swapped/all-arm/none-arm mismatch controls and whole-wave all-arm/none-arm tail runs). - 26 fail-closed refusal controls (arm scalar/load leaks including pre-defined SGPRs, SCC leaks across join and OR restore, saved-pair clobbers, vector/EXEC/VCC/branch in tail, branches into arm or tail, skip past restore, side-effecting arm ops). ## Verification Host: Windows 11 (`10.0.26200.9974`), MSVC C++20 `/W4` (zero warnings on edited targets), inbox WARP (`10.0.26100.9818`), NVIDIA GeForce RTX 5080 (`32.0.16.2140`). - **Debug (`dev`) & Release (`release`):** - `native_pixel_cmpx_scalar_tail_controls`: passed in both configs (5 positive + 26 refusals). - `native_pixel_cmpx_scalar_tail_warp`: passed in both configs (WARP readback + negative mismatch controls + whole-wave runs). - `native_pixel_cmpx_scalar_tail_hardware`: passed in both configs (RTX 5080 readback + negative mismatch controls + whole-wave runs). - `offscreen_check --self-test`: passed in both configs. - Regression pass in both configs: `native_direct_container`, `native_pixel_dxil`, `native_pixel_cmpx_discard_warp`, `native_pixel_cmpx_if_else_{controls,warp}`, `native_pixel_compare_mask_{warp,hardware,container,ir}`, `native_graphics_wqm_{hardware,warp,ir}`, `native_graphics_sampler_heap_{warp,hardware}`, `native_graphics_interface_library`, `native_graphics_vertex_vcc_join_{warp,hardware}`, `startup_flat_param_{controls,warp,hardware}` (23/23 built pixel/graphics tests passed in both Debug and Release). - `tests/bidi_controls_check.py`, `tests/docs_links_check.py`, `git diff --check origin/main..HEAD`: all clean.
lukaslw-lab commented 2026-12-02 07:31:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T07:31:45Z.

Review: APPROVED


Reviewed 733f6b27 by reading the diff; not built or run.

Verdict: approve. The tail is wave-level scalar work that the guest runs on both paths of the skip. Arm results expire at the join, and the OR restore equals the parent. Each guard fails closed. No MUST.

  • SHOULD No docs update. docs/experiments/mesh86-pixel-execz.md describes these read-only arms. The new forms are not mentioned there: scalar loads and SALU in the arm, a scalar tail before the restore, and the s_or_b64 exec, exec, sN restore.
  • SHOULD No measured stage count. The ~550 figure is the #3814 W2 shape tally, not translated stages. A ps86 census on f365f125 before and after would show the real gain. This can come in a follow-up.
  • NIT CI runs only _controls: native_pixel_cmpx_scalar_tail_warp is not in the pr preset filter.
  • NIT This PR and #3826 both change pixel_readonly_arms, around the saved-compare block and the if (!closed || inner…) line (gfx1013_direct_graphics.inl:927). Whichever merges second needs a rebase.
  • NIT scalar_width counts SOPK s_cmpk_* (whose dst is a source) as a write. This refuses more than needed, but nothing is wrong.
  • Checked, no finding:
    • The tail range is covered by the existing branch-target check (:878, through restore.pc). wave_scalar excludes SOPP, so no branch fits in the tail.
    • expired is applied at :2412, before the no-op return at :2470. So SCC really expires at the skipped OR restore, and the tail's first instruction is not expired.
    • Arm clobbers of the saved pair are still refused (:892). The tail gets its own clobber check (:925).

Tests: _controls reaches the tail scan, the OR restore and 26 refusals, including tail reads of arm scalars, SCC across the OR restore and branches into the tail. _warp/_hardware read back arm and tail values with swapped, all-arm and none-arm controls. CI ran _controls only.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6146447708 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3828#pullrequestreview-6146447708). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T07:31:45Z. **Review:** APPROVED --- Reviewed `733f6b27` by reading the diff; not built or run. **Verdict: approve.** The tail is wave-level scalar work that the guest runs on both paths of the skip. Arm results expire at the join, and the OR restore equals the parent. Each guard fails closed. No MUST. - **SHOULD** No docs update. `docs/experiments/mesh86-pixel-execz.md` describes these read-only arms. The new forms are not mentioned there: scalar loads and SALU in the arm, a scalar tail before the restore, and the `s_or_b64 exec, exec, sN` restore. - **SHOULD** No measured stage count. The ~550 figure is the #3814 W2 shape tally, not translated stages. A `ps86` census on `f365f125` before and after would show the real gain. This can come in a follow-up. - **NIT** CI runs only `_controls`: `native_pixel_cmpx_scalar_tail_warp` is not in the `pr` preset filter. - **NIT** This PR and #3826 both change `pixel_readonly_arms`, around the saved-compare block and the `if (!closed || inner…)` line (`gfx1013_direct_graphics.inl:927`). Whichever merges second needs a rebase. - **NIT** `scalar_width` counts SOPK `s_cmpk_*` (whose `dst` is a source) as a write. This refuses more than needed, but nothing is wrong. - Checked, no finding: - The tail range is covered by the existing branch-target check (`:878`, through `restore.pc`). `wave_scalar` excludes SOPP, so no branch fits in the tail. - `expired` is applied at `:2412`, before the no-op return at `:2470`. So SCC really expires at the skipped OR restore, and the tail's first instruction is not expired. - Arm clobbers of the saved pair are still refused (`:892`). The tail gets its own clobber check (`:925`). Tests: `_controls` reaches the tail scan, the OR restore and 26 refusals, including tail reads of arm scalars, SCC across the OR restore and branches into the tail. `_warp`/`_hardware` read back arm and tail values with swapped, all-arm and none-arm controls. CI ran `_controls` only.
timbot103 commented 2026-12-02 08:33:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T08:33:17Z.


@lukaslw-lab Thanks for the review and approval! Understood on updating docs/experiments/mesh86-pixel-execz.md and the ps86 census follow-up.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7339609099 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3828#issuecomment-7339609099). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T08:33:17Z. --- @lukaslw-lab Thanks for the review and approval! Understood on updating `docs/experiments/mesh86-pixel-execz.md` and the `ps86` census follow-up.
R0Y00 commented 2026-12-02 10:07:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T10:07:19Z.

Review: APPROVED


Independent Windows Debug result at 733f6b27: ctest --preset dev --no-tests=error -j 1 -R '^native_pixel_cmpx_scalar_tail_(controls|warp|hardware)$' --output-on-failure passed 3/3. The positive scalar tails, refusal controls and both pixel readbacks passed. Windows 11 26300.9974, WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, with the offscreen fixture's D3D12 debug layer enabled.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6148696423 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3828#pullrequestreview-6148696423). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T10:07:19Z. **Review:** APPROVED --- Independent Windows Debug result at `733f6b27`: `ctest --preset dev --no-tests=error -j 1 -R '^native_pixel_cmpx_scalar_tail_(controls|warp|hardware)$' --output-on-failure` passed 3/3. The positive scalar tails, refusal controls and both pixel readbacks passed. Windows 11 26300.9974, WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, with the offscreen fixture's D3D12 debug layer enabled.
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!3828
No description provided.