shader: lower proven varying pixel VCCZ shortcuts (Part of #3814) #3847

Manually merged
github merged 2 commits from github-bot/gh-3845 into gh-pr/3845/base 2026-12-03 01:53:47 +00:00 AGit
Owner

@⁠timbot103 on GitHub · 2026-12-02 08:42 UTC · original
timbot103:shader/pixel-varying-scalar-cond → main · +377 −16 · 5 files · 2 commits · merged 2026-12-03 01:51 UTC

Part of #3816.

Summary

Targets graphics scalar condition depends on a varying input (73 pixel stages in #3816):

  • Lowers acyclic pixel varying s_cbranch_vccz shortcuts over lane-preserving v_cndmask_b32 writes or a matching s_and_saveexec + restore (pixel_vcc_skip), expiring scratch registers and saved mask state at the join and propagating input dependencies onto merged PHIs. Varying s_cbranch_vccnz with inverted v_cndmask_b32 remains refused.
  • Recognizes uniform VGPR comparisons for WQM mask tests (uniform_operand) and folds pure pixel integer self-comparisons (s_cmp_eq/lg, v_cmp_eq/ne) and v_and_b32 with zero while preserving flat-attribute input dependencies.

Verification

  • ctest --preset pr --no-tests=error --output-on-failure -R '^native_pixel_varying_vcc_branch_controls$': passed.
  • Debug (dev) and Release (release): 15/15 passed in each build, zero skips, zero new C++20 /W4 warnings on edited lines.
  • All 21 new 8×2 GPU readback draws matched on both WARP (10.0.26100.9818) and NVIDIA GeForce RTX 5080 (32.0.16.2140) on Windows 11 (26200.9974), with every wrong reference mismatching.
  • tests/bidi_controls_check.py, tests/docs_links_check.py, and git diff --check origin/main..HEAD passed.
  • Opened as Draft under #3514's 5-PR ready cap.
**@⁠timbot103** on GitHub · 2026-12-02 08:42 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3845) `timbot103:shader/pixel-varying-scalar-cond` → `main` · +377 −16 · 5 files · 2 commits · merged 2026-12-03 01:51 UTC Part of #3816. ### Summary Targets `graphics scalar condition depends on a varying input` (73 pixel stages in #3816): - Lowers acyclic pixel varying `s_cbranch_vccz` shortcuts over lane-preserving `v_cndmask_b32` writes or a matching `s_and_saveexec` + restore (`pixel_vcc_skip`), expiring scratch registers and saved mask state at the join and propagating input dependencies onto merged PHIs. Varying `s_cbranch_vccnz` with inverted `v_cndmask_b32` remains refused. - Recognizes uniform VGPR comparisons for WQM mask tests (`uniform_operand`) and folds pure pixel integer self-comparisons (`s_cmp_eq/lg`, `v_cmp_eq/ne`) and `v_and_b32` with zero while preserving flat-attribute input dependencies. ### Verification - `ctest --preset pr --no-tests=error --output-on-failure -R '^native_pixel_varying_vcc_branch_controls$'`: passed. - Debug (`dev`) and Release (`release`): 15/15 passed in each build, zero skips, zero new C++20 `/W4` warnings on edited lines. - All **21** new 8×2 GPU readback draws matched on both WARP (`10.0.26100.9818`) and NVIDIA GeForce RTX 5080 (`32.0.16.2140`) on Windows 11 (`26200.9974`), with every wrong reference mismatching. - `tests/bidi_controls_check.py`, `tests/docs_links_check.py`, and `git diff --check origin/main..HEAD` passed. - Opened as Draft under `#3514`'s 5-PR ready cap.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 08:45:29 +00:00
Author
Owner

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

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

Verdict: approve. A varying s_cbranch_vccz over a VCC-guarded body is equivalent per invocation to a DXIL branch on the lane's own VCC bit, and only that shape is accepted. No MUST.

  • SHOULD Run a before/after ps86 census on f365f125. On our local stack this wall grew from 73 to 85 stages as other PRs cleared earlier walls, so the census on main and the stacked count would both show the real gain.
  • NIT This conflicts with #3831 and #3836 in gfx1013_direct_graphics.inl.
  • Checked, no finding:
    • pixel_vcc_skip (gfx1013_direct_graphics.inl:1482): VCCZ only, forward, with the target reached by this branch alone and nothing entering the body. The producer must be a v_cmp into VCC, or a wave64 s_and_b64 vcc, exec, x. Without SAVEEXEC, every lasting write must be v_cndmask dst, dst, x, vcc (:1536), which keeps the value of a lane whose VCC is clear. That makes "skip when the wave's VCC is zero" equal to "skip per lane". Every other write is scratch and is cleared at the join. With SAVEEXEC on VCC and a matching restore, the incoming edge already selects those lanes, so the save and restore are lowered as no-ops.
    • local_alu and the carry exclusion keep the body free of cross-lane reads and VCC writes. The join adds VCC's dependencies to the merged values (:1594), so later branches on them stay varying.
    • Folding: integer v_cmp_eq/ne and s_cmp_eq/lg of a register with itself are exact (:2870), as is v_and_b32 with 0 (:3167). Loops and predicates are excluded.

Tests: _controls is in the pr filter. The 21 WARP and hardware draws with wrong references ran only locally.

**@⁠lukaslw-lab** on GitHub · 2026-12-02 08:50 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3845#pullrequestreview-6147432803) · **approved these changes** Reviewed `9421e92a` (draft) by reading the diff; not built or run. **Verdict: approve.** A varying `s_cbranch_vccz` over a VCC-guarded body is equivalent per invocation to a DXIL branch on the lane's own VCC bit, and only that shape is accepted. No MUST. - **SHOULD** Run a before/after `ps86` census on `f365f125`. On our local stack this wall grew from 73 to 85 stages as other PRs cleared earlier walls, so the census on main and the stacked count would both show the real gain. - **NIT** This conflicts with #3831 and #3836 in `gfx1013_direct_graphics.inl`. - Checked, no finding: - `pixel_vcc_skip` (`gfx1013_direct_graphics.inl:1482`): VCCZ only, forward, with the target reached by this branch alone and nothing entering the body. The producer must be a `v_cmp` into VCC, or a wave64 `s_and_b64 vcc, exec, x`. Without SAVEEXEC, every lasting write must be `v_cndmask dst, dst, x, vcc` (`:1536`), which keeps the value of a lane whose VCC is clear. That makes "skip when the wave's VCC is zero" equal to "skip per lane". Every other write is scratch and is cleared at the join. With SAVEEXEC on VCC and a matching restore, the incoming edge already selects those lanes, so the save and restore are lowered as no-ops. - `local_alu` and the carry exclusion keep the body free of cross-lane reads and VCC writes. The join adds VCC's dependencies to the merged values (`:1594`), so later branches on them stay varying. - Folding: integer `v_cmp_eq/ne` and `s_cmp_eq/lg` of a register with itself are exact (`:2870`), as is `v_and_b32` with 0 (`:3167`). Loops and predicates are excluded. Tests: `_controls` is in the `pr` filter. The 21 WARP and hardware draws with wrong references ran only locally.
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-12-02 09:23 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.

Build Pixel translated Lost vs main Moved off graphics scalar condition depends on a varying input
f365f125 272 — —
f365f125 + #3847 272 0 0 of 73

All 73 stages on this wall branch with s_cbranch_vccnz, which this PR leaves refused on purpose. The dominant shape (46 of 73):

v_mul_legacy_f32 vA, vB, vC
v_fract_f32 vA, vA
s_cbranch_vccnz L          ; VCC from an earlier compare
...
L: v_cmp_lt_f32 vcc_lo, c, vA

So the VCCZ lowering is sound but does not apply to this capture. The real wall is the VCCNZ form.

**@⁠lukaslw-lab** on GitHub · 2026-12-02 09:23 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3845#issuecomment-7340810538) 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. | Build | Pixel translated | Lost vs main | Moved off `graphics scalar condition depends on a varying input` | |---|---:|---:|---:| | `f365f125` | 272 | — | — | | `f365f125` + #3847 | 272 | 0 | **0** of 73 | All 73 stages on this wall branch with **`s_cbranch_vccnz`**, which this PR leaves refused on purpose. The dominant shape (46 of 73): ``` v_mul_legacy_f32 vA, vB, vC v_fract_f32 vA, vA s_cbranch_vccnz L ; VCC from an earlier compare ... L: v_cmp_lt_f32 vcc_lo, c, vA ``` So the VCCZ lowering is sound but does not apply to this capture. The real wall is the VCCNZ form.
github-bot force-pushed github-bot/gh-3845 from 9421e92a10 to c749d98489 2026-12-02 12:37:38 +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 VCCZ branch-target accounting, main's lane-kill analysis, and both experiment entries.

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/3845#issuecomment-7361880273) Merged `main` (`67862ee4`) into this branch. The reviewed commit is unchanged, and no follow-up fix was needed. It keeps the VCCZ branch-target accounting, main's lane-kill analysis, and both experiment entries. 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:14 UTC · original

Marked Ready for review now that the previous batch (#3834, #3840, #3841, #3846, #3849) has merged. This keeps us within 5 non-draft PRs per #3516. The branch merges cleanly into current main, and CI is green at this head.

**@⁠timbot103** on GitHub · 2026-12-03 01:14 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3845#issuecomment-7364125536) Marked Ready for review now that the previous batch (#3834, #3840, #3841, #3846, #3849) has merged. This keeps us within 5 non-draft PRs per #3516. The branch merges cleanly into current main, and CI is green at this head.
github-bot changed target branch from main to gh-pr/3845/base 2026-12-03 01:53:43 +00:00
github manually merged commit 43f97a9a10 into gh-pr/3845/base 2026-12-03 01:53:47 +00:00
Author
Owner

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

Independent MSVC Debug on 43f97a9a, Windows 11 build 26300. ctest --preset dev --no-tests=error -j 1 -R '^native_pixel_varying_vcc_branch_(controls|warp|hardware)$' passed 3/3 with zero skips. WARP and RTX 4060 Laptop (616.56), debug layer enabled, each matched all 21 draws and each opposite reference differed. The branch projection is limited to VCCZ and checks explicit save/restore or dead scratch and the CNDMASK source that preserves VCC-clear lanes. Removing that source equality made the wrong-polarity CNDMASK compile, and the restored binary passed.

**@⁠R0Y00** on GitHub · 2026-12-03 01:51 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3845#pullrequestreview-6162327195) · **approved these changes** Independent MSVC Debug on 43f97a9a, Windows 11 build 26300. `ctest --preset dev --no-tests=error -j 1 -R '^native_pixel_varying_vcc_branch_(controls|warp|hardware)$'` passed 3/3 with zero skips. WARP and RTX 4060 Laptop (616.56), debug layer enabled, each matched all 21 draws and each opposite reference differed. The branch projection is limited to VCCZ and checks explicit save/restore or dead scratch and the CNDMASK source that preserves VCC-clear lanes. Removing that source equality made the wrong-polarity CNDMASK compile, and the restored binary passed.
This discussion has been locked. Commenting is limited to contributors.
No description provided.