mesh: join descriptor tables selected by a constant-buffer predicate #2151

Manually merged
github merged 2 commits from gh-pr/2151/head into gh-pr/2151/base 2026-11-27 00:00:42 +00:00
Owner

@⁠tedin7 on GitHub · 2026-11-25 01:46 UTC · original
tedin7:x2w-1998d-mesh-join-desc → main · +307 −7 · 6 files · 2 commits · merged 2026-11-25 09:03 UTC

Part of #1998

What this unblocks: mesh programs (Item D) whose scalar descriptor differs between the two arms of a uniform join, such as a per-material view or a null descriptor in one arm, now lower instead of stopping at "Dynamic scalar predicate".

Scope: Item D only. Items A, C and G are separate PRs.

What changes

  • s_cmp_{eq,lt,gt}_u32 on a constant-buffer word now produces a predicate expression instead of a refusal.
  • s_cbranch_scc0 on that predicate runs both arms (an optional trailing s_branch gives the else arm) and merges every scalar register as a select on the predicate.
  • Arms may hold only scalar ALU and loads, and must leave EXEC, VCC and M0 unchanged.
  • After the join, s_buffer_load_* reads through the selected descriptor: the two constant tables, or a zero (null) descriptor that reads as 0.0f.
  • mesh_dynamic_aot.py inherits the change through the shared wave model; its check still passes.

Refused: nested joins, geometry tables in an arm, vector, export, barrier or branch instructions in an arm, a register defined in only one arm, scalar ALU on a joined register, and EXEC/VCC/M0 changes in an arm.

Verification

Linux, executed locally:

  • python3 -B tests/mesh_join_descriptor_check.py: lowering, emitted ternary and 5 refusal controls passed.
  • python3 -B tests/mesh_dynamic_aot_check.py: passed.
  • python3 -B tests/mesh_dynamic_geometry_check.py: passed.
  • python3 -B tests/mesh_entry_check.py source() function: passed.
  • python3 -B tests/docs_links_check.py and tests/run_checks_parallel_check.py: passed.

Not run yet (Draft until done): the D3D12 draw part of the new test, ctest --preset dev --no-tests=error -R "^mesh_join_descriptor_" -V, on Win2025 WARP. It draws both arms of a per-material join and a null arm, compares the mesh export trace and all 1,024 pixels, and uses the existing trace-mismatch control. Also not run locally: the LLVM 15 based mesh_entry_check.py binary mode, since LLVM 15 is not installed here.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-25 01:46 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2151) `tedin7:x2w-1998d-mesh-join-desc` → `main` · +307 −7 · 6 files · 2 commits · merged 2026-11-25 09:03 UTC Part of #1998 What this unblocks: mesh programs (Item D) whose scalar descriptor differs between the two arms of a uniform join, such as a per-material view or a null descriptor in one arm, now lower instead of stopping at "Dynamic scalar predicate". Scope: Item D only. Items A, C and G are separate PRs. ## What changes - `s_cmp_{eq,lt,gt}_u32` on a constant-buffer word now produces a predicate expression instead of a refusal. - `s_cbranch_scc0` on that predicate runs both arms (an optional trailing `s_branch` gives the else arm) and merges every scalar register as a select on the predicate. - Arms may hold only scalar ALU and loads, and must leave EXEC, VCC and M0 unchanged. - After the join, `s_buffer_load_*` reads through the selected descriptor: the two constant tables, or a zero (null) descriptor that reads as `0.0f`. - `mesh_dynamic_aot.py` inherits the change through the shared wave model; its check still passes. Refused: nested joins, geometry tables in an arm, vector, export, barrier or branch instructions in an arm, a register defined in only one arm, scalar ALU on a joined register, and EXEC/VCC/M0 changes in an arm. ## Verification Linux, executed locally: - `python3 -B tests/mesh_join_descriptor_check.py`: lowering, emitted ternary and 5 refusal controls passed. - `python3 -B tests/mesh_dynamic_aot_check.py`: passed. - `python3 -B tests/mesh_dynamic_geometry_check.py`: passed. - `python3 -B tests/mesh_entry_check.py` `source()` function: passed. - `python3 -B tests/docs_links_check.py` and `tests/run_checks_parallel_check.py`: passed. Not run yet (Draft until done): the D3D12 draw part of the new test, `ctest --preset dev --no-tests=error -R "^mesh_join_descriptor_" -V`, on Win2025 WARP. It draws both arms of a per-material join and a null arm, compares the mesh export trace and all 1,024 pixels, and uses the existing trace-mismatch control. Also not run locally: the LLVM 15 based `mesh_entry_check.py` binary mode, since LLVM 15 is not installed here. AI-assisted; commands listed were executed locally.
Check EXEC, VCC and M0 after each arm so opposite changes cannot cancel, and union the pending vector loads of both arms after the join.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:00:41 +00:00
github manually merged commit 13f267b490 into gh-pr/2151/base 2026-11-27 00:00:42 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 01:49 UTC · original · edited 2026-11-25 01:58 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-25T01:58:07.326370Z 8d8d5e3 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 01:49 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2151#issuecomment-7149994793) · edited 2026-11-25 01:58 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"8d8d5e359473322330fde6624cd0c0b52780bfdc","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-25T01:58:07.326370Z">2026-11-25T01:58:07.326370Z</relative-time> | `8d8d5e3` | 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 01:58 UTC · original

P1 Badge Validate special registers separately for each join arm

When the true arm changes EXEC/VCC/M0 and the false arm restores its original value, checking only after both arms lets forbidden changes cancel. For example, table arms ending in s_mov_b64 exec, 1 and s_mov_b64 exec, -1 are accepted, and vector ALU immediately after the join is evaluated for all lanes even when the runtime true path has only lane 0 active. Restoring EXEC later still leaves incorrectly computed vertex values. Execute each arm from the saved special-register state and validate its result before executing the other arm.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 01:58 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2151#discussion_r4689208074) **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Validate special registers separately for each join arm** When the true arm changes EXEC/VCC/M0 and the false arm restores its original value, checking only after both arms lets forbidden changes cancel. For example, table arms ending in `s_mov_b64 exec, 1` and `s_mov_b64 exec, -1` are accepted, and vector ALU immediately after the join is evaluated for all lanes even when the runtime true path has only lane 0 active. Restoring EXEC later still leaves incorrectly computed vertex values. Execute each arm from the saved special-register state and validate its result before executing the other arm. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
@ -212,0 +307,4 @@
raise ValueError("Nested descriptor joins are not supported")
else:
merged[reg] = Select(cond, value, other)
self.s, self.pending, self.scc = merged, true_p | false_p, None
Author
Owner

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

P2 Badge Merge vector-load pending state across the join

When a vector load is pending before the branch and only one arm executes s_waitcnt vmcnt(0), that arm clears the shared self.pending_v through exec_range(). Because this state is neither restored for the other arm nor merged here, post-join code can consume an unwaited VGPR on the other path. A buffer_load_dword before the join followed by v_readfirstlane_b32 after it is accepted with a dynamic selector, while forcing the non-waiting branch raises Vector load used before wait. Snapshot each arm's vector pending state and union the results alongside scalar pending state.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 01:58 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2151#discussion_r4689208084) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Merge vector-load pending state across the join** When a vector load is pending before the branch and only one arm executes `s_waitcnt vmcnt(0)`, that arm clears the shared `self.pending_v` through `exec_range()`. Because this state is neither restored for the other arm nor merged here, post-join code can consume an unwaited VGPR on the other path. A `buffer_load_dword` before the join followed by `v_readfirstlane_b32` after it is accepted with a dynamic selector, while forcing the non-waiting branch raises `Vector load used before wait`. Snapshot each arm's vector pending state and union the results alongside scalar pending state. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

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

Fixed in 08b98aaa.

  • EXEC/VCC/M0 are now checked after each join arm separately, so opposite changes in the two arms can no longer cancel. Regression: arms ending in s_mov_b64 exec, 1 / s_mov_b64 exec, -1 are now refused (it was accepted before the fix).
  • Pending vector-load state is snapshotted per arm and unioned after the join. Regression: a buffer_load_dword before the join, waited in one arm only, then v_readfirstlane_b32 after the join, is refused with "Vector load used before wait".

Commands executed locally:

  • python3 -B tests/mesh_join_descriptor_check.py, mesh_dynamic_aot_check.py, mesh_dynamic_geometry_check.py, mesh_multi_check.py, mesh_shadow_check.py, mesh_amplification_refusal_check.py, docs_links_check.py, bidi_controls_check.py, run_checks_parallel_check.py: PASS
  • x2w_pipe.py win2025 2151 (WARP, 12 mesh tests incl. mesh_join_descriptor_warp): dev 12/12 PASS, release 12/12 PASS

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-25 02:55 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2151#discussion_r4689792440) Fixed in 08b98aaa. - EXEC/VCC/M0 are now checked after each join arm separately, so opposite changes in the two arms can no longer cancel. Regression: arms ending in `s_mov_b64 exec, 1` / `s_mov_b64 exec, -1` are now refused (it was accepted before the fix). - Pending vector-load state is snapshotted per arm and unioned after the join. Regression: a `buffer_load_dword` before the join, waited in one arm only, then `v_readfirstlane_b32` after the join, is refused with "Vector load used before wait". Commands executed locally: - `python3 -B tests/mesh_join_descriptor_check.py`, `mesh_dynamic_aot_check.py`, `mesh_dynamic_geometry_check.py`, `mesh_multi_check.py`, `mesh_shadow_check.py`, `mesh_amplification_refusal_check.py`, `docs_links_check.py`, `bidi_controls_check.py`, `run_checks_parallel_check.py`: PASS - `x2w_pipe.py win2025 2151` (WARP, 12 mesh tests incl. `mesh_join_descriptor_warp`): dev 12/12 PASS, release 12/12 PASS AI-assisted; commands listed were executed locally.
@ -212,0 +307,4 @@
raise ValueError("Nested descriptor joins are not supported")
else:
merged[reg] = Select(cond, value, other)
self.s, self.pending, self.scc = merged, true_p | false_p, None
Author
Owner

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

Fixed in 08b98aaa.

  • EXEC/VCC/M0 are now checked after each join arm separately, so opposite changes in the two arms can no longer cancel. Regression: arms ending in s_mov_b64 exec, 1 / s_mov_b64 exec, -1 are now refused (it was accepted before the fix).
  • Pending vector-load state is snapshotted per arm and unioned after the join. Regression: a buffer_load_dword before the join, waited in one arm only, then v_readfirstlane_b32 after the join, is refused with "Vector load used before wait".

Commands executed locally:

  • python3 -B tests/mesh_join_descriptor_check.py, mesh_dynamic_aot_check.py, mesh_dynamic_geometry_check.py, mesh_multi_check.py, mesh_shadow_check.py, mesh_amplification_refusal_check.py, docs_links_check.py, bidi_controls_check.py, run_checks_parallel_check.py: PASS
  • x2w_pipe.py win2025 2151 (WARP, 12 mesh tests incl. mesh_join_descriptor_warp): dev 12/12 PASS, release 12/12 PASS

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-25 02:55 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2151#discussion_r4689792634) Fixed in 08b98aaa. - EXEC/VCC/M0 are now checked after each join arm separately, so opposite changes in the two arms can no longer cancel. Regression: arms ending in `s_mov_b64 exec, 1` / `s_mov_b64 exec, -1` are now refused (it was accepted before the fix). - Pending vector-load state is snapshotted per arm and unioned after the join. Regression: a `buffer_load_dword` before the join, waited in one arm only, then `v_readfirstlane_b32` after the join, is refused with "Vector load used before wait". Commands executed locally: - `python3 -B tests/mesh_join_descriptor_check.py`, `mesh_dynamic_aot_check.py`, `mesh_dynamic_geometry_check.py`, `mesh_multi_check.py`, `mesh_shadow_check.py`, `mesh_amplification_refusal_check.py`, `docs_links_check.py`, `bidi_controls_check.py`, `run_checks_parallel_check.py`: PASS - `x2w_pipe.py win2025 2151` (WARP, 12 mesh tests incl. `mesh_join_descriptor_warp`): dev 12/12 PASS, release 12/12 PASS AI-assisted; commands listed were executed locally.
Author
Owner

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

Ran head b4c8735e. 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_join_descriptor_{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/2151#issuecomment-7154311602) Ran head `b4c8735e`. 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_join_descriptor_{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

@⁠alvaroolt on GitHub · 2026-11-25 09:16 UTC · original

The mesh checks on main fail since this merge (54830b1d). They pass on its parent c4309205 and still fail on 07c1c20f. Every case fails the same way:

File "tools/mesh_entry_aot.py", line 882, in run_group
    next(steps)
TypeError: 'NoneType' object is not an iterator

Cause. The refactor moved the body of Wave.steps into exec_range, and the yield at s_barrier moved with it (now line 713). steps no longer contains a yield, so it is a plain function that returns None, and run_group calls next(None). exec_range is now a generator. That has two consequences:

  • In steps, if self.exec_range(...) is always true (a generator object), so the wave returns without executing anything.
  • In join_arms (line 304), self.exec_range(..., arm=True) creates the generator and drops it, so the arm is never executed.

Failing checks on the PR runs merged into 54830b1d (for example run 45581905589):

  • Linux Python job: mesh_heap_sampler, mesh_dynamic_geometry, mesh_dynamic_aot, mesh_lane_spill, mesh_join_descriptor, pso_readiness (blocked with mesh_lowering_rejected: lowering failed unexpectedly: TypeError).
  • gfx1013 job: mesh_entry, mesh_dynamic_geometry, mesh_two_exits, mesh_heap_sampler, mesh_indexed, mesh_multi, mesh_descriptor_swap, mesh_lit, mesh_shadow.

A minimal change that restores them (tested locally on 07c1c20f, not submitted):

@@ -301,7 +301,8 @@ class Wave:
             self.s, self.pending = dict(base[0]), set(base[1])
             self.pending_v = set(base[2])
             self.scc = None
-            self.exec_range(decoded, expressions, jumps, start, stop, arm=True)
+            for _ in self.exec_range(decoded, expressions, jumps, start, stop, arm=True):
+                raise ValueError("Unsupported instruction inside a descriptor join arm")
             # Each arm is checked on its own so two changes cannot cancel.
@@ -676,7 +677,7 @@ class Wave:
-        if self.exec_range(decoded, expressions, jumps, 0, len(decoded)):
+        if (yield from self.exec_range(decoded, expressions, jumps, 0, len(decoded))):
             return
         raise ValueError("No program exit")

arm=True already refuses s_barrier, so an arm never yields. The loop only drains the generator and keeps the refusal in place if that changes.

Results on Windows 11 26300 with Python 3.12, LLVM 15.0.7 LLVM-C.dll, llvm-mc 15.0.7 and llvm-objcopy 15.0.7:

  • The nine gfx1013-job checks, each run with binary <llvm-mc> <llvm-objcopy> <LLVM-C.dll>: all exit 1 with the TypeError on 07c1c20f, and all exit 0 with the change.
  • The six Linux-job checks, run without arguments as that job does: all exit 0 with the change. mesh_heap_sampler_check.py exits 1 on 54830b1d and 0 on c4309205.

I did not run the D3D12 mesh draws or the full ctest suite with this change.

AI-assisted (Claude Code); I reviewed the diagnosis and the test results.

**@⁠alvaroolt** on GitHub · 2026-11-25 09:16 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2151#issuecomment-7158101515) The mesh checks on `main` fail since this merge (54830b1d). They pass on its parent c4309205 and still fail on 07c1c20f. Every case fails the same way: ``` File "tools/mesh_entry_aot.py", line 882, in run_group next(steps) TypeError: 'NoneType' object is not an iterator ``` **Cause.** The refactor moved the body of `Wave.steps` into `exec_range`, and the `yield` at `s_barrier` moved with it (now line 713). `steps` no longer contains a `yield`, so it is a plain function that returns `None`, and `run_group` calls `next(None)`. `exec_range` is now a generator. That has two consequences: - In `steps`, `if self.exec_range(...)` is always true (a generator object), so the wave returns without executing anything. - In `join_arms` (line 304), `self.exec_range(..., arm=True)` creates the generator and drops it, so the arm is never executed. **Failing checks** on the PR runs merged into 54830b1d (for example run 45581905589): - Linux Python job: `mesh_heap_sampler`, `mesh_dynamic_geometry`, `mesh_dynamic_aot`, `mesh_lane_spill`, `mesh_join_descriptor`, `pso_readiness` (blocked with `mesh_lowering_rejected: lowering failed unexpectedly: TypeError`). - gfx1013 job: `mesh_entry`, `mesh_dynamic_geometry`, `mesh_two_exits`, `mesh_heap_sampler`, `mesh_indexed`, `mesh_multi`, `mesh_descriptor_swap`, `mesh_lit`, `mesh_shadow`. **A minimal change that restores them** (tested locally on 07c1c20f, not submitted): ```diff @@ -301,7 +301,8 @@ class Wave: self.s, self.pending = dict(base[0]), set(base[1]) self.pending_v = set(base[2]) self.scc = None - self.exec_range(decoded, expressions, jumps, start, stop, arm=True) + for _ in self.exec_range(decoded, expressions, jumps, start, stop, arm=True): + raise ValueError("Unsupported instruction inside a descriptor join arm") # Each arm is checked on its own so two changes cannot cancel. @@ -676,7 +677,7 @@ class Wave: - if self.exec_range(decoded, expressions, jumps, 0, len(decoded)): + if (yield from self.exec_range(decoded, expressions, jumps, 0, len(decoded))): return raise ValueError("No program exit") ``` `arm=True` already refuses `s_barrier`, so an arm never yields. The loop only drains the generator and keeps the refusal in place if that changes. Results on Windows 11 26300 with Python 3.12, LLVM 15.0.7 `LLVM-C.dll`, `llvm-mc` 15.0.7 and `llvm-objcopy` 15.0.7: - The nine gfx1013-job checks, each run with `binary <llvm-mc> <llvm-objcopy> <LLVM-C.dll>`: all exit 1 with the `TypeError` on 07c1c20f, and all exit 0 with the change. - The six Linux-job checks, run without arguments as that job does: all exit 0 with the change. `mesh_heap_sampler_check.py` exits 1 on 54830b1d and 0 on c4309205. I did not run the D3D12 mesh draws or the full ctest suite with this change. AI-assisted (Claude Code); I reviewed the diagnosis and the test results.
Author
Owner

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d8d5e3594

ℹ️ 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 01:58 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2151#pullrequestreview-6050474396) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `8d8d5e3594` <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.