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

Manually merged
github merged 4 commits from gh-pr/2149/head into gh-pr/2149/base 2026-11-27 00:00:32 +00:00
Owner

@⁠tedin7 on GitHub · 2026-11-25 01:44 UTC · original
tedin7:x2w-1998c-mesh-exec-restore → main · +215 −9 · 6 files · 4 commits · merged 2026-11-25 10:06 UTC

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** on GitHub · 2026-11-25 01:44 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2149) `tedin7:x2w-1998c-mesh-exec-restore` → `main` · +215 −9 · 6 files · 4 commits · merged 2026-11-25 10:06 UTC 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:00:30 +00:00
github manually merged commit 20c2eb8482 into gh-pr/2149/base 2026-11-27 00:00:32 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 02:32 UTC · original · edited 2026-11-25 02:38 UTC

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.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 02:32 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2149#issuecomment-7150850203) · edited 2026-11-25 02:38 UTC <!-- 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>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 02:38 UTC · original

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 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 02:38 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2149#discussion_r4689630940) **<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 -->
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 02:56 UTC · original

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.

**@⁠tedin7** on GitHub · 2026-11-25 02:56 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2149#discussion_r4689804089) 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.
Author
Owner

@⁠legacy-code-archaeologist on GitHub · 2026-11-25 05:58 UTC · original

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.

**@⁠legacy-code-archaeologist** on GitHub · 2026-11-25 05:58 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2149#issuecomment-7154311192) 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._
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 02:31 UTC · original · reviewed

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.

**@⁠tedin7** on GitHub · 2026-11-25 02:31 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2149#pullrequestreview-6050884487) · **reviewed** 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.
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 02:38 UTC · original · reviewed

💡 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".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 02:38 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2149#pullrequestreview-6050968252) · **reviewed** <!-- 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>
This discussion has been locked. Commenting is limited to contributors.
No description provided.