shader: lower pixel EXEC masks and scalar lane spills (Part of #3814) #3836

Manually merged
github merged 4 commits from github-bot/gh-3834 into gh-pr/3834/base 2026-12-03 04:43:05 +00:00 AGit
Owner

@⁠timbot103 on GitHub · 2026-12-02 08:09 UTC · original
timbot103:shader/pixel-entry-exec-writelane-vcc → main · +489 −39 · 4 files · 4 commits · merged 2026-12-03 04:34 UTC

Lowers wave64 pixel entry/post-branch EXEC mask combines (undefined graphics register 126, ~212 stages), G4 (s_and_b64 vcc, exec, vcc in both operand orders, 16 stages), and G3 (v_writelane_b32/v_readlane_b32 dedicated VGPR scalar spills at constant lanes 0–31, 21 stages) in the direct C++ pixel frontend.

Part of #3816. Refs #3642, #3643, #3705.
(Opened as Draft per #3516 until an active review slot frees.)

Summary

  • src/gfx1013_direct_graphics.inl:
    • Entry/post-branch EXEC masks (undefined graphics register 126): Accepts s_mov_b64 s[dst:dst+1], exec in uniform-EXEC CFGs, exposes per-invocation EXEC/saved-EXEC lane bits (exec_bit_available, exec_bit, saved_exec_bit) to v_cndmask_b32, s_mov_b64, and s_and/or/xor/andn2_b64 mask logic, while nulling numeric SGPR pairs and SCC so numeric reads stay fail-closed.
    • G4 (s_and_b64 vcc, exec, vcc / vcc, vcc, exec): Lowers both operand orders under entry, WQM, and exact predicates while marking SCC undefined (compare_scc_unknown = true) and keeping varying VCC branches refused.
    • G3 (v_writelane_b32 / v_readlane_b32 scalar lane spills): Tracks (vgpr, lane) -> scalar SSA within a single unpartitioned block for constant lanes 0..31 on dedicated non-entry VGPRs never touched as ordinary vectors, requiring wave-uniform numeric scalar sources. Refuses lane ≥ 32, non-constant lanes, vector aliasing, unwritten slots, and partitioned/looping regions.
  • tests/native_pixel_exec_writelane_vcc_check.py + tests/cmake/native_pixel_exec_writelane_vcc.cmake + docs/experiments/native-pixel-exec-writelane-vcc.md:
    • native_pixel_exec_writelane_vcc_controls (runs in pr CTest preset) + _warp + _hardware (11 draws matching all 16 pixels on WARP and RTX 5080, plus wrong-EXEC-mask and swapped-spill-slot mismatch controls and thorough fail-closed refusals).

Verification

Host: Windows 11 (10.0.26200.9974), MSVC C++20 /W4 (zero warnings in edited lines), inbox WARP (10.0.26100.9818), NVIDIA GeForce RTX 5080 (32.0.16.2140; D3D12 debug layer unavailable). Base origin/main f365f125.

  • ctest --preset pr --no-tests=error -R "^native_pixel_exec_writelane_vcc_controls$": 1/1 passed.
  • Debug (dev) & Release (release): 15/15 passed in both configs with zero skips.
  • tests/bidi_controls_check.py, tests/docs_links_check.py, git diff --check origin/main..HEAD: all clean.
**@⁠timbot103** on GitHub · 2026-12-02 08:09 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3834) `timbot103:shader/pixel-entry-exec-writelane-vcc` → `main` · +489 −39 · 4 files · 4 commits · merged 2026-12-03 04:34 UTC Lowers wave64 pixel entry/post-branch `EXEC` mask combines (`undefined graphics register 126`, ~212 stages), G4 (`s_and_b64 vcc, exec, vcc` in both operand orders, 16 stages), and G3 (`v_writelane_b32`/`v_readlane_b32` dedicated VGPR scalar spills at constant lanes 0–31, 21 stages) in the direct C++ pixel frontend. Part of #3816. Refs #3642, #3643, #3705. *(Opened as Draft per #3516 until an active review slot frees.)* ## Summary - **`src/gfx1013_direct_graphics.inl`:** - **Entry/post-branch EXEC masks (`undefined graphics register 126`):** Accepts `s_mov_b64 s[dst:dst+1], exec` in uniform-EXEC CFGs, exposes per-invocation EXEC/saved-EXEC lane bits (`exec_bit_available`, `exec_bit`, `saved_exec_bit`) to `v_cndmask_b32`, `s_mov_b64`, and `s_and/or/xor/andn2_b64` mask logic, while nulling numeric SGPR pairs and SCC so numeric reads stay fail-closed. - **G4 (`s_and_b64 vcc, exec, vcc` / `vcc, vcc, exec`):** Lowers both operand orders under entry, WQM, and exact predicates while marking SCC undefined (`compare_scc_unknown = true`) and keeping varying VCC branches refused. - **G3 (`v_writelane_b32` / `v_readlane_b32` scalar lane spills):** Tracks `(vgpr, lane) -> scalar SSA` within a single unpartitioned block for constant lanes `0..31` on dedicated non-entry VGPRs never touched as ordinary vectors, requiring wave-uniform numeric scalar sources. Refuses lane ≥ 32, non-constant lanes, vector aliasing, unwritten slots, and partitioned/looping regions. - **`tests/native_pixel_exec_writelane_vcc_check.py` + `tests/cmake/native_pixel_exec_writelane_vcc.cmake` + `docs/experiments/native-pixel-exec-writelane-vcc.md`:** - `native_pixel_exec_writelane_vcc_controls` (runs in `pr` CTest preset) + `_warp` + `_hardware` (11 draws matching all 16 pixels on WARP and RTX 5080, plus wrong-EXEC-mask and swapped-spill-slot mismatch controls and thorough fail-closed refusals). ## Verification Host: Windows 11 (`10.0.26200.9974`), MSVC C++20 `/W4` (zero warnings in edited lines), inbox WARP (`10.0.26100.9818`), NVIDIA GeForce RTX 5080 (`32.0.16.2140`; D3D12 debug layer unavailable). Base `origin/main` `f365f125`. - `ctest --preset pr --no-tests=error -R "^native_pixel_exec_writelane_vcc_controls$"`: **1/1 passed**. - **Debug (`dev`) & Release (`release`):** 15/15 passed in both configs with zero skips. - `tests/bidi_controls_check.py`, `tests/docs_links_check.py`, `git diff --check origin/main..HEAD`: all clean.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 08:15:56 +00:00
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-12-02 08:12 UTC · original · approved these changes

Reviewed afc80395 (draft) by reading the diff; not built or run.

Verdict: approve. The EXEC bit, mask combines and lane spills are exact for each invocation, and the numeric pairs stay unavailable. No MUST.

  • SHOULD Run a before/after ps86 census on f365f125. Besides the 249 targeted stages, this widens shared paths for every wave64 pixel stage, not only the compare tail: compare bits are now recorded, v_cndmask/s_mov_b64/s_mov_b32 track masks, and the unclaimed-mask release runs. s_and_b64 vcc, exec, x is now taken by the new block (gfx1013_direct_graphics.inl:2942) ahead of the existing WQM reduction. The census would show that no stage that translates today changes its refusal.
  • Checked, no finding:
    • exec_bit (:2165): the predicate when one is set; 1 under whole-quad EXEC, where helpers are in the guest EXEC too; otherwise !IsHelperLane. Per-lane AND, OR, XOR and ANDN2 against it give each lane its own guest bit, active or not. It is disabled with kills, discards, packed WQM and loops.
    • SCC: every setter of compare_scc_unknown also clears 128, so the relaxed s_cselect and branch checks (:2756, :3271) accept only an SCC written later.
    • Spills (:2682): a dedicated VGPR is refused if it is also used as a vector, in either order, because the read and write hooks cover inputs and interpolation. A constant lane, a dependency-free scalar, the same block, no predicate, no exact mode and no full-wave island make v_readlane of the written slot equal to the scalar.
    • check_graphics_read has no other user in graphics, and the graphics_input override keeps graphics.input.

Tests: _controls is in the pr filter. _warp/_hardware (11 draws, wrong-EXEC and swapped-slot controls) ran only locally.

**@⁠lukaslw-lab** on GitHub · 2026-12-02 08:12 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3834#pullrequestreview-6146922076) · **approved these changes** Reviewed `afc80395` (draft) by reading the diff; not built or run. **Verdict: approve.** The EXEC bit, mask combines and lane spills are exact for each invocation, and the numeric pairs stay unavailable. No MUST. - **SHOULD** Run a before/after `ps86` census on `f365f125`. Besides the 249 targeted stages, this widens shared paths for every wave64 pixel stage, not only the compare tail: compare bits are now recorded, `v_cndmask`/`s_mov_b64`/`s_mov_b32` track masks, and the unclaimed-mask release runs. `s_and_b64 vcc, exec, x` is now taken by the new block (`gfx1013_direct_graphics.inl:2942`) ahead of the existing WQM reduction. The census would show that no stage that translates today changes its refusal. - Checked, no finding: - `exec_bit` (`:2165`): the predicate when one is set; `1` under whole-quad EXEC, where helpers are in the guest EXEC too; otherwise `!IsHelperLane`. Per-lane AND, OR, XOR and ANDN2 against it give each lane its own guest bit, active or not. It is disabled with kills, discards, packed WQM and loops. - SCC: every setter of `compare_scc_unknown` also clears 128, so the relaxed `s_cselect` and branch checks (`:2756`, `:3271`) accept only an SCC written later. - Spills (`:2682`): a dedicated VGPR is refused if it is also used as a vector, in either order, because the read and write hooks cover inputs and interpolation. A constant lane, a dependency-free scalar, the same block, no predicate, no exact mode and no full-wave island make `v_readlane` of the written slot equal to the scalar. - `check_graphics_read` has no other user in graphics, and the `graphics_input` override keeps `graphics.input`. Tests: `_controls` is in the `pr` filter. `_warp`/`_hardware` (11 draws, wrong-EXEC and swapped-slot controls) ran only locally.
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-12-02 10:34 UTC · original

Census follow-up for the SHOULD in my review: f365f125 + this PR alone, same capture and method as #3816 (6,436 distinct pixel stages). Counts only. None lost, no validation failures.

Build Pixel translated Moved
f365f125 272 —
f365f125 + #3836 272 86

49 undefined graphics register 126 stages now stop at graphics wave or control-flow instruction. Of 37 graphics wave or control-flow instruction stages, 17 move to pixel lane spill requires unpartitioned execution and 12 to graphics scalar condition depends on a varying input. None reaches OK yet.

**@⁠lukaslw-lab** on GitHub · 2026-12-02 10:34 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3834#issuecomment-7342672126) Census follow-up for the SHOULD in my review: `f365f125` + this PR alone, same capture and method as #3816 (6,436 distinct pixel stages). Counts only. **None lost**, no validation failures. | Build | Pixel translated | Moved | |---|---:|---:| | `f365f125` | 272 | — | | `f365f125` + #3836 | 272 | 86 | 49 `undefined graphics register 126` stages now stop at `graphics wave or control-flow instruction`. Of 37 `graphics wave or control-flow instruction` stages, 17 move to `pixel lane spill requires unpartitioned execution` and 12 to `graphics scalar condition depends on a varying input`. None reaches OK yet.
github-bot force-pushed github-bot/gh-3834 from afc8039522 to 3724526d92 2026-12-02 12:38:01 +00:00 Compare
Author
Owner

@⁠timbot103 on GitHub · 2026-12-02 23:20 UTC · original

Merged main (67862ee4) into this branch. The reviewed commit is unchanged, and no follow-up fix was needed. It keeps the EXEC-mask and spill helpers alongside main's exact-mode transition.

Tests, Windows 11 26200 with RTX 5080 and WARP. The filter was native_pixel_|native_graphics_|native_direct_container plus this PR's own tests. There were 0 failures and 0 skips, with 15 WARP and 12 RTX 5080 tests per configuration. A full Debug build of every target, including the C++17 native_compute_pack_refusal_check, succeeded.

  • Debug passed 39/39 and Release 39/39. The PR preset passed 1/1.
**@⁠timbot103** on GitHub · 2026-12-02 23:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3834#issuecomment-7361879749) Merged `main` (`67862ee4`) into this branch. The reviewed commit is unchanged, and no follow-up fix was needed. It keeps the EXEC-mask and spill helpers alongside main's exact-mode transition. Tests, Windows 11 26200 with RTX 5080 and WARP. The filter was `native_pixel_|native_graphics_|native_direct_container` plus this PR's own tests. There were 0 failures and 0 skips, with 15 WARP and 12 RTX 5080 tests per configuration. A full Debug build of every target, including the C++17 `native_compute_pack_refusal_check`, succeeded. - Debug passed 39/39 and Release 39/39. The PR preset passed 1/1.
Author
Owner

@⁠timbot103 on GitHub · 2026-12-03 01:37 UTC · original

Merged main (f3ab02fe, which includes #3849's live-mask lowering) into this branch. The reviewed commit is unchanged. native_pixel_|native_graphics_|native_direct_container passed 47/47 in Debug and 47/47 in Release, with 0 failures and 0 skips (18 WARP and 15 RTX 5080 tests per configuration). The PR preset passed 1/1. A full Debug build of every target, including the C++17 native_compute_pack_refusal_check, succeeded.

**@⁠timbot103** on GitHub · 2026-12-03 01:37 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3834#issuecomment-7364559872) Merged `main` (`f3ab02fe`, which includes #3849's live-mask lowering) into this branch. The reviewed commit is unchanged. `native_pixel_|native_graphics_|native_direct_container` passed 47/47 in Debug and 47/47 in Release, with 0 failures and 0 skips (18 WARP and 15 RTX 5080 tests per configuration). The PR preset passed 1/1. A full Debug build of every target, including the C++17 `native_compute_pack_refusal_check`, succeeded.
Author
Owner

@⁠timbot103 on GitHub · 2026-12-03 04:14 UTC · original

Merged main (41a83a9a) into this branch. The conflict with main's varying-VCCZ save/restore handling keeps both sides. native_pixel_|native_graphics_|native_direct_container passed 53/53 in Debug and 53/53 in Release, with 0 skips (20 WARP and 17 RTX 5080 tests per configuration). The PR preset passed 1/1. A full Debug build of every target, including the C++17 native_compute_pack_refusal_check, succeeded. Marked Ready for review, keeping within 5 non-draft PRs per #3516.

**@⁠timbot103** on GitHub · 2026-12-03 04:14 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3834#issuecomment-7367412368) Merged `main` (`41a83a9a`) into this branch. The conflict with main's varying-VCCZ save/restore handling keeps both sides. `native_pixel_|native_graphics_|native_direct_container` passed 53/53 in Debug and 53/53 in Release, with 0 skips (20 WARP and 17 RTX 5080 tests per configuration). The PR preset passed 1/1. A full Debug build of every target, including the C++17 `native_compute_pack_refusal_check`, succeeded. Marked Ready for review, keeping within 5 non-draft PRs per #3516.
github-bot changed target branch from main to gh-pr/3834/base 2026-12-03 04:42:14 +00:00
github manually merged commit 0959ff5118 into gh-pr/3834/base 2026-12-03 04:43:02 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-03 04:34 UTC · original · approved these changes

Independently reviewed 0959ff51 and checked the clean combined tree with main d1d727f1, which includes #3842. Saved-EXEC mask values remain unavailable as numeric SGPR pairs. The scalar spill accepts only constant lanes on a dedicated VGPR in an unpartitioned block and refuses aliases, undefined slots, and nonuniform scalar sources. MSVC Debug ctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^native_pixel_(exec_writelane_vcc|masked_region_alu)_(controls|warp|hardware)$' passed 6/6 with no skips. Windows build 26300, WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, D3D12 debug layer enabled. Both adapters matched all 16 pixels in each of the 11 new cases and caught the two fixture controls. With the wide-execution spill read locally changed to return zero, both adapters reported 9/16 pixel mismatches on the wave64 spill, and I restored the code.

**@⁠R0Y00** on GitHub · 2026-12-03 04:34 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3834#pullrequestreview-6163736316) · **approved these changes** Independently reviewed `0959ff51` and checked the clean combined tree with `main` `d1d727f1`, which includes #3842. Saved-EXEC mask values remain unavailable as numeric SGPR pairs. The scalar spill accepts only constant lanes on a dedicated VGPR in an unpartitioned block and refuses aliases, undefined slots, and nonuniform scalar sources. MSVC Debug `ctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^native_pixel_(exec_writelane_vcc|masked_region_alu)_(controls|warp|hardware)$'` passed 6/6 with no skips. Windows build 26300, WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, D3D12 debug layer enabled. Both adapters matched all 16 pixels in each of the 11 new cases and caught the two fixture controls. With the wide-execution spill read locally changed to return zero, both adapters reported 9/16 pixel mismatches on the wave64 spill, and I restored the code.
This discussion has been locked. Commenting is limited to contributors.
No description provided.