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

Merged
timbot103 merged 4 commits from upstream-pr/3834 into main 2026-12-03 04:34:09 +00:00
timbot103 commented 2026-12-02 08:09:58 +00:00 (Migrated from github.com)

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


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 #3814. Refs #3640, #3641, #3703.
(Opened as Draft per #3514 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.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5602454033 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3834). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T08:09:58Z. --- 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 #3814. Refs #3640, #3641, #3703. *(Opened as Draft per #3514 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.
lukaslw-lab commented 2026-12-02 08:12:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T08:12:00Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6146922076 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3834#pullrequestreview-6146922076). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T08:12:00Z. **Review:** APPROVED --- 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 commented 2026-12-02 10:34:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T10:34:36Z.


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

Build Pixel translated Moved
f365f125 272 —
f365f125 + #3834 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7342672126 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3834#issuecomment-7342672126). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T10:34:36Z. --- Census follow-up for the SHOULD in my review: `f365f125` + this PR alone, same capture and method as #3814 (6,436 distinct pixel stages). Counts only. **None lost**, no validation failures. | Build | Pixel translated | Moved | |---|---:|---:| | `f365f125` | 272 | — | | `f365f125` + #3834 | 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.
timbot103 commented 2026-12-02 23:20:55 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T23:20:55Z.


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.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7361879749 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3834#issuecomment-7361879749). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T23:20:55Z. --- 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 commented 2026-12-03 01:37:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T01:37:52Z.


Merged main (f3ab02fe, which includes #3847'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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7364559872 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3834#issuecomment-7364559872). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-03T01:37:52Z. --- Merged `main` (`f3ab02fe`, which includes #3847'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 commented 2026-12-03 04:14:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T04:14:07Z.


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 #3514.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7367412368 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3834#issuecomment-7367412368). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-03T04:14:07Z. --- 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 #3514.
R0Y00 commented 2026-12-03 04:34:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T04:34:03Z.

Review: APPROVED


Independently reviewed 0959ff51 and checked the clean combined tree with main d1d727f1, which includes #3840. 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6163736316 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3834#pullrequestreview-6163736316). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T04:34:03Z. **Review:** APPROVED --- Independently reviewed `0959ff51` and checked the clean combined tree with `main` `d1d727f1`, which includes #3840. 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.
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!3834
No description provided.