shader: lower additional mesh SAVEEXEC patterns (Part of #3703) #3845

Manually merged
github merged 23 commits from github-bot/gh-3843 into gh-pr/3843/base 2026-12-03 04:39:04 +00:00 AGit
Owner

@⁠timbot103 on GitHub · 2026-12-02 08:42 UTC · original
timbot103:shader/mesh-saveexec-exec-vcc → main · +374 −112 · 5 files · 23 commits · merged 2026-12-03 04:28 UTC

Part of #3705.

Summary

Targets the two #3705 mesh SAVEEXEC refusal buckets (mesh SAVEEXEC then arm depends on EXEC, 84 programs, and mesh SAVEEXEC VCC test requires an immediate VCC branch, 77 programs):

  • Evaluates s_and_b64/s_and_b32 mask tests at their original PC (setting SCC immediately and capturing the wave-uniform nonempty predicate for scheduled VCC/SCC branches across independent vector/32-bit scalar work, including dead SGPR-pair destinations), plus wave-uniform 32-bit Sopc forward SCC branches inside SAVEEXEC THEN arms.
  • Accepts common 32-bit scalar/SMEM tails before either restore form (find_restore), tracked EXEC mask copies (s_and_b64) and selects (s_cselect_b64 ... exec, 0) via needs_exact_exec, and Encoding::Mix ops in the vector-only inverse arm. Clobbers, escaping branches, backward loops, and leaked scalar values remain refused.

Verification

  • ctest --preset pr --no-tests=error --output-on-failure -R '^native_mesh_saveexec_exec_vcc_ir$': passed (16 positive DXIL cases + 22 refusal controls).
  • Debug (dev) and Release (release): 3/3 passed (native_mesh_saveexec_exec_vcc_ir|native_direct_mesh|native_direct_container), zero skips, zero new C++20 /W4 warnings on edited lines.
  • 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/3843) `timbot103:shader/mesh-saveexec-exec-vcc` → `main` · +374 −112 · 5 files · 23 commits · merged 2026-12-03 04:28 UTC Part of #3705. ### Summary Targets the two #3705 mesh `SAVEEXEC` refusal buckets (`mesh SAVEEXEC then arm depends on EXEC`, 84 programs, and `mesh SAVEEXEC VCC test requires an immediate VCC branch`, 77 programs): - Evaluates `s_and_b64`/`s_and_b32` mask tests at their original PC (setting SCC immediately and capturing the wave-uniform nonempty predicate for scheduled VCC/SCC branches across independent vector/32-bit scalar work, including dead SGPR-pair destinations), plus wave-uniform 32-bit `Sopc` forward SCC branches inside `SAVEEXEC` THEN arms. - Accepts common 32-bit scalar/SMEM tails before either restore form (`find_restore`), tracked EXEC mask copies (`s_and_b64`) and selects (`s_cselect_b64 ... exec, 0`) via `needs_exact_exec`, and `Encoding::Mix` ops in the vector-only inverse arm. Clobbers, escaping branches, backward loops, and leaked scalar values remain refused. ### Verification - `ctest --preset pr --no-tests=error --output-on-failure -R '^native_mesh_saveexec_exec_vcc_ir$'`: passed (16 positive DXIL cases + 22 refusal controls). - Debug (`dev`) and Release (`release`): 3/3 passed (`native_mesh_saveexec_exec_vcc_ir|native_direct_mesh|native_direct_container`), zero skips, zero new C++20 `/W4` warnings on edited lines. - `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:22 +00:00
Author
Owner

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

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

Verdict: approve. The scheduled VCC and SCC tests are matched only when nothing in between can change what the branch reads, and the new then-arm forms take the exact-EXEC path. No MUST.

  • SHOULD Run a before/after m86 census on f365f125 for the real gain on the 84 + 77. The tests now match across independent work, and a mask copy no longer needs a nested child. Both widen accepted shapes, so the census would also show that no program changes to a different refusal.
  • NIT This conflicts with #3709 (ours) and #3808 in lower_mesh. #3709 adds the same 32-bit SALU list and lane_free for loops that saveexec_scalar_tail (gfx1013_direct_mesh.inl:610) now holds. Whichever merges second can reuse the other's list. I will do that on #3709 if this lands first.
  • Checked, no finding:
    • Scheduled test (:812): an instruction in between may not read the AND's destination, EXEC, VCCZ or EXECZ, nor write the destination or the mask pair. A VOPC writing VCC, SMEM, or a compare ends the scan, and vcc_test then refuses. Scalar ALU in between disables only the SCC form. At the AND (:1674), SCC is the proven uniform bit, which equals "AND nonempty" inside a nonempty arm, and the AND's destination is cleared.
    • Arm SCC compares (:803): forward within the arm. Where a proof is needed (after allocation or before an else arm), both inputs must be wave-uniform, and a forward edge into the span is refused. group_flow is cleared for every matched test.
    • s_and_b64 sN, exec, x and s_cselect_b64 sN, exec, 0 set needs_exact_exec (:866), so the diamond computes exact masks instead of refusing. The s_cselect_b64 fix keeps an unknown EXEC word empty instead of selecting it.
    • find_restore (:660) accepts only saveexec_scalar_tail ops before the restore, and records their writes in gap_writes. diamond_joined uses the same list as before.

Tests: native_mesh_saveexec_exec_vcc_ir (16 cases, 22 refusals) is in the pr filter.

**@⁠lukaslw-lab** on GitHub · 2026-12-02 08:48 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3843#pullrequestreview-6147405317) · **approved these changes** Reviewed `fa774fcb` (draft) by reading the diff; not built or run. **Verdict: approve.** The scheduled VCC and SCC tests are matched only when nothing in between can change what the branch reads, and the new then-arm forms take the exact-EXEC path. No MUST. - **SHOULD** Run a before/after `m86` census on `f365f125` for the real gain on the 84 + 77. The tests now match across independent work, and a mask copy no longer needs a nested child. Both widen accepted shapes, so the census would also show that no program changes to a different refusal. - **NIT** This conflicts with #3709 (ours) and #3808 in `lower_mesh`. #3709 adds the same 32-bit SALU list and `lane_free` for loops that `saveexec_scalar_tail` (`gfx1013_direct_mesh.inl:610`) now holds. Whichever merges second can reuse the other's list. I will do that on #3709 if this lands first. - Checked, no finding: - Scheduled test (`:812`): an instruction in between may not read the AND's destination, EXEC, VCCZ or EXECZ, nor write the destination or the mask pair. A VOPC writing VCC, SMEM, or a compare ends the scan, and `vcc_test` then refuses. Scalar ALU in between disables only the SCC form. At the AND (`:1674`), SCC is the proven uniform bit, which equals "AND nonempty" inside a nonempty arm, and the AND's destination is cleared. - Arm SCC compares (`:803`): forward within the arm. Where a proof is needed (after allocation or before an else arm), both inputs must be wave-uniform, and a forward edge into the span is refused. `group_flow` is cleared for every matched test. - `s_and_b64 sN, exec, x` and `s_cselect_b64 sN, exec, 0` set `needs_exact_exec` (`:866`), so the diamond computes exact masks instead of refusing. The `s_cselect_b64` fix keeps an unknown EXEC word empty instead of selecting it. - `find_restore` (`:660`) accepts only `saveexec_scalar_tail` ops before the restore, and records their writes in `gap_writes`. `diamond_joined` uses the same list as before. Tests: `native_mesh_saveexec_exec_vcc_ir` (16 cases, 22 refusals) is in the `pr` filter.
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 #3705 / #3816 (6,685 distinct mesh programs, 6,436 pixel stages). Counts only.

Build Mesh translated Lost vs main
f365f125 1,036 —
f365f125 + #3845 1,036 0

81 programs move off their first refusal: mesh SAVEEXEC VCC test requires an immediate VCC branch 77, unbound numeric SGPR s4 4. None of them reaches OK yet: each stops at a later wall. The 84 mesh SAVEEXEC then arm depends on EXEC programs do not move on this capture. No validation failures.

**@⁠lukaslw-lab** on GitHub · 2026-12-02 09:23 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3843#issuecomment-7340809261) Census follow-up for the SHOULD in my review: `f365f125` + this PR alone, same capture and method as #3705 / #3816 (6,685 distinct mesh programs, 6,436 pixel stages). Counts only. | Build | Mesh translated | Lost vs main | |---|---:|---:| | `f365f125` | 1,036 | — | | `f365f125` + #3845 | 1,036 | 0 | 81 programs move off their first refusal: `mesh SAVEEXEC VCC test requires an immediate VCC branch` 77, `unbound numeric SGPR s4` 4. None of them reaches OK yet: each stops at a later wall. The 84 `mesh SAVEEXEC then arm depends on EXEC` programs do not move on this capture. No validation failures.
github-bot force-pushed github-bot/gh-3843 from f53fce5c5f to b6c4f79b02 2026-12-02 12:37:40 +00:00 Compare
Author
Owner

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

Re-review on b6c4f79b (rebased on 5770f14e: the 32-bit SALU list and lane_free hoisted for the two users, full_exec added to the exact-EXEC condition from main).

Verdict: approve.

Census, same capture and method as before (6,685 distinct mesh programs), main 5770f14e vs this head:

Programs
Translate, main / with this PR 1,047 / 1,047
Lost / gained 0 / 0
First refusal moved 81: SAVEEXEC VCC test requires an immediate VCC branch → SAVEEXEC then arm depends on EXEC 77; unbound numeric SGPR s4 → s2 4

Same 81 as the earlier head. The hoisted scalar_alu32 set is unchanged in content, and both users now share it.

Update: the first run was on a main that refused 257 programs early (my #3709, #3894; fixed by #3895). I reran main 5770f14e and this head, both with that fix: 81 moved, 0 lost, 0 gained. The numbers above are unchanged.

AI-assisted.

**@⁠lukaslw-lab** on GitHub · 2026-12-02 20:27 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3843#pullrequestreview-6158377798) · **approved these changes** Re-review on `b6c4f79b` (rebased on `5770f14e`: the 32-bit SALU list and `lane_free` hoisted for the two users, `full_exec` added to the exact-EXEC condition from main). **Verdict: approve.** Census, same capture and method as before (6,685 distinct mesh programs), main `5770f14e` vs this head: | | Programs | |---|---:| | Translate, main / with this PR | 1,047 / 1,047 | | Lost / gained | 0 / 0 | | First refusal moved | 81: `SAVEEXEC VCC test requires an immediate VCC branch` → `SAVEEXEC then arm depends on EXEC` 77; `unbound numeric SGPR s4` → `s2` 4 | Same 81 as the earlier head. The hoisted `scalar_alu32` set is unchanged in content, and both users now share it. Update: the first run was on a main that refused 257 programs early (my #3709, #3894; fixed by #3895). I reran main `5770f14e` and this head, both with that fix: 81 moved, 0 lost, 0 gained. The numbers above are unchanged. AI-assisted.
Part of #3703
Use per-guest-wave shared storage to select the minimum active lane, with lane zero as the empty-EXEC fallback. Require group convergence for each barrier and cover CMPX, SAVEEXEC, and whole-wave skips with draw readbacks.

Part of #3703
The compute pack refusal target compiles a fault-injected copy of the frontend as C++17. Use the same prefix check accepted by both frontend builds.
# Conflicts:
#	src/gfx1013_direct_mesh.inl
Keep the full-EXEC root value identity from the heap proof and apply first-active-lane completeness checks to the remaining uniform and broadcast paths.
The full Texture1D descriptor path on main rebuilt only the mask from the root constant. Share selector lowering with typed buffer loads so the DXIL slot and the reported selector agree for shifted fields and immediate displacements.
The straight first-active-lane shortcut bypassed the exact region required by the new EXEC mask-copy and mask-select forms. Keep that region for these mixed arms and let the existing group barrier check refuse a varying broadcast there.
Author
Owner

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

Stacked on #3844, and through it on #3837. This branch includes their commits; please land them first.

  • 845d46f8 replaces the C++20 starts_with calls. native_compute_pack_refusal_check builds the frontend as C++17, which main CI compiles but PR CI does not, so this PR would otherwise have broken main's full build after merging.
  • b350ac6d fixes an interaction with #3844. An arm that both copies an EXEC mask and contains a broadcast could drop the exact SAVEEXEC region. The region is now kept, and a varying broadcast that would need a group barrier is refused. The mask-copy and mask-select controls pass in both configurations. Straight SAVEEXEC broadcasts still pass the WARP and RTX 5080 readbacks.

Tests, Windows 11 26200 with RTX 5080 and WARP. The mesh filter was native_direct_mesh|native_direct_container|native_mesh_ plus this PR's own tests. Every branch passed a full Debug build of every target, including the C++17 native_compute_pack_refusal_check.

  • Debug passed 20/20. Release passed 19/20, and the PR preset passed 1/1.
  • The Release failures are the existing asynchronous WARP allocation fixtures (accepted=1 refused=0). They also fail on a clean 67862ee4, and every one of them passed with X2W_SYNC_MESH_REQUESTS=1.

All six mesh PRs (#3834, #3837, #3840, #3844, #3845 and #3848) were also merged together onto 67862ee4. That combined tree passed 47/47 in Debug and 47/47 in Release, plus 8/8 under the PR preset. All 15 pairs merge cleanly.

**@⁠timbot103** on GitHub · 2026-12-02 23:05 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3843#issuecomment-7361541258) **Stacked on #3844**, and through it on #3837. This branch includes their commits; please land them first. - `845d46f8` replaces the C++20 `starts_with` calls. `native_compute_pack_refusal_check` builds the frontend as C++17, which main CI compiles but PR CI does not, so this PR would otherwise have broken main's full build after merging. - `b350ac6d` fixes an interaction with #3844. An arm that both copies an EXEC mask and contains a broadcast could drop the exact SAVEEXEC region. The region is now kept, and a varying broadcast that would need a group barrier is refused. The mask-copy and mask-select controls pass in both configurations. Straight SAVEEXEC broadcasts still pass the WARP and RTX 5080 readbacks. Tests, Windows 11 26200 with RTX 5080 and WARP. The mesh filter was `native_direct_mesh|native_direct_container|native_mesh_` plus this PR's own tests. Every branch passed a full Debug build of every target, including the C++17 `native_compute_pack_refusal_check`. - Debug passed 20/20. Release passed 19/20, and the PR preset passed 1/1. - The Release failures are the existing asynchronous WARP allocation fixtures (`accepted=1 refused=0`). They also fail on a clean `67862ee4`, and every one of them passed with `X2W_SYNC_MESH_REQUESTS=1`. All six mesh PRs (#3834, #3837, #3840, #3844, #3845 and #3848) were also merged together onto `67862ee4`. That combined tree passed 47/47 in Debug and 47/47 in Release, plus 8/8 under the PR preset. All 15 pairs merge cleanly.
The shared graphics decoder can admit DLC and GLC for read-only scalar loads. Exercise a reserved bit in the address word so the refusal control checks unsupported addressing under either decoder policy.
Author
Owner

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

Merged the updated #3837 (705d91ab, its fixture now uses a reserved-bit control that does not depend on #3835) into this stacked branch. The merge was clean. On main c42b7ce3 the mesh filter passes in Debug, and in Release apart from the existing asynchronous WARP allocation fixtures, which also fail on clean main and pass with X2W_SYNC_MESH_REQUESTS=1.

**@⁠timbot103** on GitHub · 2026-12-02 23:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3843#issuecomment-7362672309) Merged the updated #3837 (`705d91ab`, its fixture now uses a reserved-bit control that does not depend on #3835) into this stacked branch. The merge was clean. On main `c42b7ce3` the mesh filter passes in Debug, and in Release apart from the existing asynchronous WARP allocation fixtures, which also fail on clean main and pass with `X2W_SYNC_MESH_REQUESTS=1`.
# Conflicts:
#	src/gfx1013_direct_mesh.inl
The full-EXEC join fixture now reads the wave ID before allocation. Locate the shared instructions before arranging the active-lane entry so the count and wave32 lane proof still modify the intended words.
Author
Owner

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

Merged the updated #3844 (main f3ab02fe). The merge was clean, and the SAVEEXEC controls and inherited active-lane readbacks pass. This PR is still stacked on #3844 and #3837. The remaining failures also fail on clean main: native_mesh_entry_registers_ir (fix PR coming) and the asynchronous WARP allocation fixtures.

**@⁠timbot103** on GitHub · 2026-12-03 01:30 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3843#issuecomment-7364429217) Merged the updated #3844 (main `f3ab02fe`). The merge was clean, and the SAVEEXEC controls and inherited active-lane readbacks pass. This PR is still stacked on #3844 and #3837. The remaining failures also fail on clean main: `native_mesh_entry_registers_ir` (fix PR coming) and the asynchronous WARP allocation fixtures.
Author
Owner

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

Merged the updated #3844 (main 41a83a9a); the merge was clean. This PR is still stacked on #3844 only, since #3837 has merged. The mesh filter passed 22/22 in Debug. Release passed 19/22; the 3 failures are the existing asynchronous WARP fixtures. The PR preset passed 1/1.

**@⁠timbot103** on GitHub · 2026-12-03 04:01 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3843#issuecomment-7367177231) Merged the updated #3844 (main `41a83a9a`); the merge was clean. This PR is still stacked on #3844 only, since #3837 has merged. The mesh filter passed 22/22 in Debug. Release passed 19/22; the 3 failures are the existing asynchronous WARP fixtures. The PR preset passed 1/1.
Author
Owner

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

No longer stacked: #3844 has merged. Merged main (43055293) into this branch. The two conflicts keep this PR's exact-EXEC guard and its mask-copy and mask-select refusal controls. The diff against main now contains only this PR's SAVEEXEC changes, the C++17-compatible prefix check, and their fixtures. The mesh filter passed 22/22 in Debug. Release passed 19/22; the 3 failures are the existing asynchronous WARP allocation fixtures, which pass with X2W_SYNC_MESH_REQUESTS=1. The PR preset passed 1/1, and the RTX 5080 checks passed 5/5 in each configuration. Marked Ready for review, keeping within 5 non-draft PRs per #3516.

**@⁠timbot103** on GitHub · 2026-12-03 04:17 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3843#issuecomment-7367473554) No longer stacked: #3844 has merged. Merged `main` (`43055293`) into this branch. The two conflicts keep this PR's exact-EXEC guard and its mask-copy and mask-select refusal controls. The diff against `main` now contains only this PR's SAVEEXEC changes, the C++17-compatible prefix check, and their fixtures. The mesh filter passed 22/22 in Debug. Release passed 19/22; the 3 failures are the existing asynchronous WARP allocation fixtures, which pass with `X2W_SYNC_MESH_REQUESTS=1`. The PR preset passed 1/1, and the RTX 5080 checks passed 5/5 in each configuration. Marked Ready for review, keeping within 5 non-draft PRs per #3516.
# Conflicts:
#	src/gfx1013_direct_mesh.inl
#	tests/native_mesh_readfirstlane_active_check.py
Author
Owner

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

Independently reviewed 8974c077 after the #3844 merge. The clean trial merge onto main 0bb85d8f gives tree 098ff4149a5bb6e5d62526468728220c06a8b791, byte-for-byte the tree tested from this PR's three changes replayed onto that main. MSVC Debug ctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^(native_mesh_saveexec_exec_vcc_ir|native_mesh_buffer_load_format_ir|native_mesh_readfirstlane_active_(controls|warp|hardware))$' passed 5/5. The inherited readbacks passed on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, Windows build 26300, debug layer enabled, no skips. The new SAVEEXEC cases validate DXIL and the expected refusals. On the preceding source-equivalent SAVEEXEC revision c1076cc7, forcing the captured branch predicate to zero failed the scheduled-VCC DXIL assertion. The edit was local and restored.

**@⁠R0Y00** on GitHub · 2026-12-03 04:21 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3843#pullrequestreview-6163640967) · **approved these changes** Independently reviewed `8974c077` after the #3844 merge. The clean trial merge onto main `0bb85d8f` gives tree `098ff4149a5bb6e5d62526468728220c06a8b791`, byte-for-byte the tree tested from this PR's three changes replayed onto that main. MSVC Debug `ctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^(native_mesh_saveexec_exec_vcc_ir|native_mesh_buffer_load_format_ir|native_mesh_readfirstlane_active_(controls|warp|hardware))$'` passed 5/5. The inherited readbacks passed on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, Windows build 26300, debug layer enabled, no skips. The new SAVEEXEC cases validate DXIL and the expected refusals. On the preceding source-equivalent SAVEEXEC revision `c1076cc7`, forcing the captured branch predicate to zero failed the scheduled-VCC DXIL assertion. The edit was local and restored.
github-bot changed target branch from main to gh-pr/3843/base 2026-12-03 04:38:48 +00:00
github manually merged commit 8974c077a7 into gh-pr/3843/base 2026-12-03 04:39:04 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.