mesh: restore EXEC after a per-lane range through halves, moves and saveexec forms #2141

Merged
tedin7 merged 4 commits from upstream-pr/2149 into main 2026-11-25 10:06:30 +00:00
tedin7 commented 2026-11-25 01:44:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:44:41Z.


Part of #1998

What this unblocks: mesh programs that restore EXEC after a per-lane range through a moved copy, the 32-bit halves, a saveexec form, or a join of two arms now translate instead of stopping at the first unmodeled scalar instruction (item C).

What changed

  • tools/mesh_entry_aot.py (shared by tools/mesh_dynamic_aot.py): exec_lo / exec_hi as 32-bit read and write targets (a 64-bit write to one half is refused); s_orn2_b64, s_not_b64; s_andn2, s_or, s_orn2, s_xor _saveexec_b64 next to the existing s_and_saveexec_b64, all keeping the old mask in the destination pair.
  • Refusals now name the cause: a scalar register read before it is written, and an unmodeled branch opcode (both were bare KeyError).
  • tests/mesh_entry_check.py: exec-restore (Linux) and draw-exec-restore (WARP) modes, plus a binary assembler check. The program uses a moved copy, halves, a flipped and re-joined saved mask, and a restore joined from two arms of a wave-uniform branch. It must lower to the same HLSL as the plain restore program.
  • tests/mesh_dynamic_aot_check.py: the same restore forms and refusals on the dynamic lowerer.
  • CMake mesh_entry_exec_restore_cpu, mesh_entry_exec_restore_draw_{warp,hardware}; docs in docs/experiments.md.
  • Negative controls (all refused): restore from the mask saved after the flip, from a never-written pair, missing low half, 64-bit write to a half, s_nand_saveexec_b64, s_cbranch_scc1, backward branch. The draw also checks a depth one ulp off reports Mesh export trace mismatch.
  • The new Linux check fails on the previous lowerer (Unsupported scalar destination).
  • Twin tables checked: existing SCC/ALU tables unchanged; only the listed forms are added.

Verification

Run locally (Linux, no D3D12, no DXC, no llvm-mc):

  • python3 -B tests/mesh_entry_check.py exec-restore: pass.
  • python3 -B tests/mesh_dynamic_aot_check.py, mesh_dynamic_geometry_check.py, mesh_multi_check.py, mesh_amplification_refusal_check.py, startup_ngg_slice_check.py, docs_links_check.py: pass.

NOT yet run (Draft until done on Win2025):

  • python3 -B tests/mesh_entry_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1
  • ctest --preset dev --no-tests=error -R "^mesh_entry_exec_restore_" (WARP draw plus mismatch control) and -R "^mesh_entry_draw_" for regressions.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6595214534 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2149). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:44:41Z. --- Part of #1998 What this unblocks: mesh programs that restore EXEC after a per-lane range through a moved copy, the 32-bit halves, a saveexec form, or a join of two arms now translate instead of stopping at the first unmodeled scalar instruction (item C). ## What changed - `tools/mesh_entry_aot.py` (shared by `tools/mesh_dynamic_aot.py`): `exec_lo` / `exec_hi` as 32-bit read and write targets (a 64-bit write to one half is refused); `s_orn2_b64`, `s_not_b64`; `s_andn2`, `s_or`, `s_orn2`, `s_xor` `_saveexec_b64` next to the existing `s_and_saveexec_b64`, all keeping the old mask in the destination pair. - Refusals now name the cause: a scalar register read before it is written, and an unmodeled branch opcode (both were bare `KeyError`). - `tests/mesh_entry_check.py`: `exec-restore` (Linux) and `draw-exec-restore` (WARP) modes, plus a `binary` assembler check. The program uses a moved copy, halves, a flipped and re-joined saved mask, and a restore joined from two arms of a wave-uniform branch. It must lower to the same HLSL as the plain restore program. - `tests/mesh_dynamic_aot_check.py`: the same restore forms and refusals on the dynamic lowerer. - CMake `mesh_entry_exec_restore_cpu`, `mesh_entry_exec_restore_draw_{warp,hardware}`; docs in `docs/experiments.md`. - Negative controls (all refused): restore from the mask saved after the flip, from a never-written pair, missing low half, 64-bit write to a half, `s_nand_saveexec_b64`, `s_cbranch_scc1`, backward branch. The draw also checks a depth one ulp off reports `Mesh export trace mismatch`. - The new Linux check fails on the previous lowerer (`Unsupported scalar destination`). - Twin tables checked: existing SCC/ALU tables unchanged; only the listed forms are added. ## Verification Run locally (Linux, no D3D12, no DXC, no llvm-mc): - `python3 -B tests/mesh_entry_check.py exec-restore`: pass. - `python3 -B tests/mesh_dynamic_aot_check.py`, `mesh_dynamic_geometry_check.py`, `mesh_multi_check.py`, `mesh_amplification_refusal_check.py`, `startup_ngg_slice_check.py`, `docs_links_check.py`: pass. NOT yet run (Draft until done on Win2025): - `python3 -B tests/mesh_entry_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1` - `ctest --preset dev --no-tests=error -R "^mesh_entry_exec_restore_"` (WARP draw plus mismatch control) and `-R "^mesh_entry_draw_"` for regressions. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 03:01:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:31:56Z.

Review: COMMENTED


Peer review of head 43edcd72: no blocking findings.

  • Exec restore semantics: exec_lo/exec_hi halves, copy/move, the saveexec family, s_orn2_b64 and s_not_b64 and the two-arm join all give the same HLSL as the plain restore. Lost lanes, a missing half, an unwritten source, a 64-bit write to a half, unmodeled saveexec and branches are refused, each with a control.
  • Dynamic lowerer repeats the forms and refusals.
  • Tests, docs and CMake are in step with sibling mesh_entry_* tests. No duplicate open PR. Clean-room, no model names.

Verification (Win2025):

  • python3 -B tests/mesh_entry_check.py exec-restore and python3 -B tests/mesh_dynamic_aot_check.py: pass (Linux)
  • x2w_pipe.py win2025 2149 --force --regex '^mesh_(entry|dynamic)_': dev 15/15 and release 15/15 passed, including mesh_entry_exec_restore_cpu, _draw_warp, _draw_hardware.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6050884487 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2149#pullrequestreview-6050884487). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:31:56Z. **Review:** COMMENTED --- Peer review of head 43edcd72: no blocking findings. - Exec restore semantics: exec_lo/exec_hi halves, copy/move, the saveexec family, s_orn2_b64 and s_not_b64 and the two-arm join all give the same HLSL as the plain restore. Lost lanes, a missing half, an unwritten source, a 64-bit write to a half, unmodeled saveexec and branches are refused, each with a control. - Dynamic lowerer repeats the forms and refusals. - Tests, docs and CMake are in step with sibling mesh_entry_* tests. No duplicate open PR. Clean-room, no model names. Verification (Win2025): - `python3 -B tests/mesh_entry_check.py exec-restore` and `python3 -B tests/mesh_dynamic_aot_check.py`: pass (Linux) - `x2w_pipe.py win2025 2149 --force --regex '^mesh_(entry|dynamic)_'`: dev 15/15 and release 15/15 passed, including `mesh_entry_exec_restore_cpu`, `_draw_warp`, `_draw_hardware`. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-25 03:01:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T02:38:35Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 43edcd7235

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6050968252 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2149#pullrequestreview-6050968252). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T02:38:35Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `43edcd7235` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
tedin7 commented 2026-11-25 03:01:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:56:23Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6051178263 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2149#pullrequestreview-6051178263). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:56:23Z. **Review:** COMMENTED --- _No description provided._
chatgpt-codex-connector[bot commented 2026-11-25 03:01:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T02:32:13Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T02:38:38.170511Z 43edcd7 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7150850203 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2149#issuecomment-7150850203). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T02:32:13Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"43edcd72350b9c67d1232e478b9c92a52365be42","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-25T02:38:38.170511Z">2026-11-25T02:38:38.170511Z</relative-time> | `43edcd7` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
chatgpt-codex-connector[bot commented 2026-11-25 03:01:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T02:38:36Z.

Code review location: tools/mesh_entry_aot.py; line 56

@@ -48,6 +48,16 @@ def span(token):
 VERTEX_BYTES = 512
 
 
+# Lane-mask updates that keep the previous exec in the destination pair. The source is the second operand.
+SAVEEXEC = {
+    "s_and_saveexec_b64": lambda old, a: old & a,
+    "s_andn2_saveexec_b64": lambda old, a: old & ~a,
+    "s_or_saveexec_b64": lambda old, a: old | a,
+    "s_orn2_saveexec_b64": lambda old, a: old | ~a,

P1 Badge Reverse the operands for complemented saveexec operations

When a shader uses either complemented saveexec form, these callbacks reverse the ISA operand order: the operations are SRC0 & ~old_exec and SRC0 | ~old_exec, respectively. For example, with EXEC equal to 7 and source equal to 2, ANDN2 must produce 0, but this implementation produces 5. An assembled gfx1013 mesh fixture that writes a VGPR under that mask and then restores EXEC successfully lowers with incorrect vertex depths for lanes 0 and 2. Both mesh lowerers therefore silently miscompile valid programs. Use a & ~old and a | ~old, and test both forms against equivalent ordinary scalar instruction sequences.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4689630940 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2149#discussion_r4689630940). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T02:38:36Z. **Code review location:** `tools/mesh_entry_aot.py`; line 56 ~~~~diff @@ -48,6 +48,16 @@ def span(token): VERTEX_BYTES = 512 +# Lane-mask updates that keep the previous exec in the destination pair. The source is the second operand. +SAVEEXEC = { + "s_and_saveexec_b64": lambda old, a: old & a, + "s_andn2_saveexec_b64": lambda old, a: old & ~a, + "s_or_saveexec_b64": lambda old, a: old | a, + "s_orn2_saveexec_b64": lambda old, a: old | ~a, ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Reverse the operands for complemented saveexec operations** When a shader uses either complemented saveexec form, these callbacks reverse the ISA operand order: the operations are `SRC0 & ~old_exec` and `SRC0 | ~old_exec`, respectively. For example, with EXEC equal to 7 and source equal to 2, ANDN2 must produce 0, but this implementation produces 5. An assembled gfx1013 mesh fixture that writes a VGPR under that mask and then restores EXEC successfully lowers with incorrect vertex depths for lanes 0 and 2. Both mesh lowerers therefore silently miscompile valid programs. Use `a & ~old` and `a | ~old`, and test both forms against equivalent ordinary scalar instruction sequences. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-25 03:01:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:56:23Z.

Code review location: tools/mesh_entry_aot.py; line 56

@@ -48,6 +48,16 @@ def span(token):
 VERTEX_BYTES = 512
 
 
+# Lane-mask updates that keep the previous exec in the destination pair. The source is the second operand.
+SAVEEXEC = {
+    "s_and_saveexec_b64": lambda old, a: old & a,
+    "s_andn2_saveexec_b64": lambda old, a: old & ~a,
+    "s_or_saveexec_b64": lambda old, a: old | a,
+    "s_orn2_saveexec_b64": lambda old, a: old | ~a,

Fixed in 9f9267e8. The complemented saveexec forms now compute SRC0 & ~EXEC and SRC0 | ~EXEC. The new check in tests/mesh_entry_check.py exec-restore compares each form against the same mask built from ordinary scalar instructions. It failed with the swapped operands and passes now.

Verification:

  • python3 tests/mesh_entry_check.py exec-restore: PASS (it failed before the fix)
  • tests/pso_readiness_check.py, tests/docs_links_check.py and all tests/mesh_*_check.py: PASS. The pso check also failed in Linux CI; its expected detail now names the unwritten register.
  • x2w_pipe.py win2025 2149: PASS on dev and release (WARP) at 9f9267e8

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4689804089 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2149#discussion_r4689804089). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:56:23Z. **Code review location:** `tools/mesh_entry_aot.py`; line 56 ~~~~diff @@ -48,6 +48,16 @@ def span(token): VERTEX_BYTES = 512 +# Lane-mask updates that keep the previous exec in the destination pair. The source is the second operand. +SAVEEXEC = { + "s_and_saveexec_b64": lambda old, a: old & a, + "s_andn2_saveexec_b64": lambda old, a: old & ~a, + "s_or_saveexec_b64": lambda old, a: old | a, + "s_orn2_saveexec_b64": lambda old, a: old | ~a, ~~~~ --- Fixed in 9f9267e8. The complemented saveexec forms now compute SRC0 & ~EXEC and SRC0 | ~EXEC. The new check in `tests/mesh_entry_check.py exec-restore` compares each form against the same mask built from ordinary scalar instructions. It failed with the swapped operands and passes now. Verification: - `python3 tests/mesh_entry_check.py exec-restore`: PASS (it failed before the fix) - `tests/pso_readiness_check.py`, `tests/docs_links_check.py` and all `tests/mesh_*_check.py`: PASS. The pso check also failed in Linux CI; its expected detail now names the unwritten register. - `x2w_pipe.py win2025 2149`: PASS on dev and release (WARP) at 9f9267e8 AI-assisted; commands listed were executed locally.
legacy-code-archaeologist commented 2026-11-25 06:01:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-25T05:58:13Z.


Ran head a547e87d. Windows 11 build 26100, debug layer unavailable. Adapters: WARP 10.0.26100.8972, NVIDIA Quadro M1000M 32.0.15.7371, Intel HD Graphics 530 31.0.101.2111, the hardware ones selected with XBOX2WINDOWS_ADAPTER.

Test WARP Quadro M1000M Intel HD 530
mesh_entry_exec_restore_cpu pass n/a n/a
mesh_entry_exec_restore_draw_{warp,hardware} pass skip (77), mesh_shader_tier=unsupported skip (77), mesh_shader_tier=unsupported

Neither older GPU has mesh shaders, so the hardware rows are capability skips, not results. Only WARP drew.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7154311192 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2149#issuecomment-7154311192). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-25T05:58:13Z. --- Ran head `a547e87d`. Windows 11 build 26100, debug layer unavailable. Adapters: WARP 10.0.26100.8972, NVIDIA Quadro M1000M 32.0.15.7371, Intel HD Graphics 530 31.0.101.2111, the hardware ones selected with `XBOX2WINDOWS_ADAPTER`. | Test | WARP | Quadro M1000M | Intel HD 530 | |---|---|---|---| | `mesh_entry_exec_restore_cpu` | pass | n/a | n/a | | `mesh_entry_exec_restore_draw_{warp,hardware}` | pass | skip (77), `mesh_shader_tier=unsupported` | skip (77), `mesh_shader_tier=unsupported` | Neither older GPU has mesh shaders, so the hardware rows are capability skips, not results. Only WARP drew. _AI-assisted._
upstream-sync closed this pull request 2026-11-25 11:02:11 +00:00
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!2141
No description provided.