shader: lower nested mesh SAVEEXEC regions (Part of #3703) #3724

Manually merged
github merged 1 commit from github-bot/gh-3722 into main 2026-12-01 11:23:13 +00:00 AGit
Owner

@⁠timbot103 on GitHub · 2026-12-01 10:53 UTC · original
timbot103:shader/mesh-nested-saveexec → main · +415 −131 · 3 files · 1 commits · merged 2026-12-01 11:21 UTC

Refs #3705.

Summary

Lowers nested SAVEEXEC regions inside the then arm of an enclosing SAVEEXEC within a mesh lane skip (src/gfx1013_direct_mesh.inl, with a brief note in docs/experiments.md):

  • Nested if-only and if/else SAVEEXEC: Matches inner s_and_saveexec_b64 blocks inside an enclosing SAVEEXEC then arm, accepting s_andn2_b64 or s_xor_b64 inverses and s_mov_b64 or s_or_b64 restores (including vector-only inner else arms that omit their EXECZ when paired with a local restore).
  • Exact nested EXEC tracking: Intersects each inner arm's predicate with the reaching parent EXEC mask, propagates wave nonemptiness and mask words when proven (allowing uniform inner wave-SCC reads while leaving lane-varying SCC undefined), restores the parent mask at the inner join, and preserves incoming VGPR values for skipped lanes across both inner and outer joins.
  • Fail-closed controls: Keeps wrong restores, overwritten or overlapping saved EXEC pairs, escaping then/else branches, instruction-interior targets, unproven masks, extra restores, enclosing else reads of then-written scalars, and standalone nested CMPX strictly refused.

Verification

Windows 11 (26200), MSVC 19.44, Ninja, Windows SDK 10.0.26100. Source-built tests only; added nested if-only, nested paired, no-else-EXECZ, outer-if-only, mask-copy, uniform wave-SCC positive cases and 10 refusal controls in tests/native_direct_mesh_check.py.

  • Debug (dev preset):
    • ctest --preset dev --no-tests=error -R '^native_direct_|^startup_mesh57_real_shape$' -V -> 3/3 passed (native_direct_container, native_direct_mesh, startup_mesh57_real_shape)
  • Release (release preset):
    • ctest --preset release --no-tests=error -R '^native_direct_|^startup_mesh57_real_shape$' -V -> 3/3 passed
  • git diff --check HEAD^ HEAD clean.

AI-assisted.

**@⁠timbot103** on GitHub · 2026-12-01 10:53 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3722) `timbot103:shader/mesh-nested-saveexec` → `main` · +415 −131 · 3 files · 1 commits · merged 2026-12-01 11:21 UTC Refs #3705. ## Summary Lowers nested `SAVEEXEC` regions inside the `then` arm of an enclosing `SAVEEXEC` within a mesh lane skip (`src/gfx1013_direct_mesh.inl`, with a brief note in `docs/experiments.md`): - **Nested if-only and if/else `SAVEEXEC`:** Matches inner `s_and_saveexec_b64` blocks inside an enclosing `SAVEEXEC` `then` arm, accepting `s_andn2_b64` or `s_xor_b64` inverses and `s_mov_b64` or `s_or_b64` restores (including vector-only inner `else` arms that omit their `EXECZ` when paired with a local restore). - **Exact nested EXEC tracking:** Intersects each inner arm's predicate with the reaching parent EXEC mask, propagates wave nonemptiness and mask words when proven (allowing uniform inner wave-SCC reads while leaving lane-varying SCC undefined), restores the parent mask at the inner join, and preserves incoming VGPR values for skipped lanes across both inner and outer joins. - **Fail-closed controls:** Keeps wrong restores, overwritten or overlapping saved EXEC pairs, escaping `then`/`else` branches, instruction-interior targets, unproven masks, extra restores, enclosing `else` reads of `then`-written scalars, and standalone nested `CMPX` strictly refused. ## Verification Windows 11 (26200), MSVC 19.44, Ninja, Windows SDK 10.0.26100. Source-built tests only; added nested if-only, nested paired, no-else-EXECZ, outer-if-only, mask-copy, uniform wave-SCC positive cases and 10 refusal controls in `tests/native_direct_mesh_check.py`. - **Debug (`dev` preset):** - `ctest --preset dev --no-tests=error -R '^native_direct_|^startup_mesh57_real_shape$' -V` -> **3/3 passed** (`native_direct_container`, `native_direct_mesh`, `startup_mesh57_real_shape`) - **Release (`release` preset):** - `ctest --preset release --no-tests=error -R '^native_direct_|^startup_mesh57_real_shape$' -V` -> **3/3 passed** - `git diff --check HEAD^ HEAD` clean. AI-assisted.
Lower nested if-only and if/else SAVEEXEC regions inside the then arm
of an enclosing SAVEEXEC within a lane skip. Intersect each inner arm's
predicate with the reaching EXEC mask, accept ANDN2/XOR inverses and
MOV/OR restores, preserve inactive VGPR values on skipped lanes, and
keep escaping branches, overwritten saved pairs, and unproven masks
refused.

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 10:53:45 +00:00
github manually merged commit 69b16cab34 into main 2026-12-01 11:23:13 +00:00
Author
Owner

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

Reviewed mask restore, branch boundaries and scalar clobber tracking. Integrated native_direct_mesh passed locally with nested SAVEEXEC and refusal controls.

**@⁠R0Y00** on GitHub · 2026-12-01 11:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3722#pullrequestreview-6130203794) · **approved these changes** Reviewed mask restore, branch boundaries and scalar clobber tracking. Integrated native_direct_mesh passed locally with nested SAVEEXEC and refusal controls.
This discussion has been locked. Commenting is limited to contributors.
No description provided.