shader: lower s_clause and s_bitcmp{0,1}_b{32,64} in mesh_entry_aot #2430

Merged
triggered02 merged 2 commits from upstream-pr/2438 into main 2026-11-25 20:33:09 +00:00
triggered02 commented 2026-11-25 16:48:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-25T16:48:02Z.


Lowers the SOPP hard-clause hint s_clause and the four SOPC scalar bit-test instructions (s_bitcmp0_b32, s_bitcmp1_b32, s_bitcmp0_b64, s_bitcmp1_b64) in tools/mesh_entry_aot.py (inherited by tools/mesh_dynamic_aot.py via Wave).

Refs #2413 (where the T2 profile identified 129 s_bitcmp0_b32 and 120 s_clause stops in the bounded mesh lowerers).

What changed

  • tools/mesh_entry_aot.py:
    • Wave.exec_range accepts s_clause with integer operands 0..63 (0x0..0x3f) as a scheduling no-op (both top-level and inside join_arms), refusing out-of-range or non-integer operands.
    • Wave.scalar_op handles s_bitcmp0_b32, s_bitcmp1_b32, s_bitcmp0_b64, s_bitcmp1_b64: ((a & width) >> (b & mask)) & 1 == (1 or 0) (32-bit width = U32, mask = 31; 64-bit width = WAVE, mask = 63). Clears self.scc = None on UNDEF and raises ValueError('Dynamic scalar predicate') on non-concrete operands (RuntimeWord raises Unproven runtime geometry word).
  • tests/mesh_bitcmp_clause_check.py, CMakeLists.txt (mesh_bitcmp_clause_cpu), and docs/experiments.md.

Measured checks (25db1aff on origin/main b442b57f)

  • tests/mesh_bitcmp_clause_check.py: PASS — synthetic gfx1013 bytes decoded via disasm_rdna2.decode_instruction and lowered with both mesh_entry_aot.lower and mesh_dynamic_aot.enumerate_variants/lower (s_clause 0x0/0x3f vs 0x40/0xffff; 32-bit/64-bit bits 0, 31, 34, 35, 63 and index wraps 33 & 31, 65 & 63 across SGPR pairs, exec, vcc, -1; UNDEF/RuntimeWord/dynamic refusals).
  • 13 existing pure-Python mesh_* checks + docs_links_check.py (469 links) + bidi_controls_check.py (1,726 files) + git diff --check: all PASS.
  • 3 fail-first mutations on tools/mesh_entry_aot.py (flipping s_bitcmp1_/0_, & 31 on _b64, dropping s_clause): all 3 caught (exit 1).

Not established

  • No GPU draw or DXIL compilation was run in this pure-Python mesh lowerer check.

AI-assisted (Gemini).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6609285447 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2438). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-25T16:48:02Z. --- Lowers the SOPP hard-clause hint `s_clause` and the four SOPC scalar bit-test instructions (`s_bitcmp0_b32`, `s_bitcmp1_b32`, `s_bitcmp0_b64`, `s_bitcmp1_b64`) in `tools/mesh_entry_aot.py` (inherited by `tools/mesh_dynamic_aot.py` via `Wave`). Refs #2413 (where the T2 profile identified 129 `s_bitcmp0_b32` and 120 `s_clause` stops in the bounded mesh lowerers). ### What changed - **`tools/mesh_entry_aot.py`**: - `Wave.exec_range` accepts `s_clause` with integer operands `0..63` (`0x0..0x3f`) as a scheduling no-op (both top-level and inside `join_arms`), refusing out-of-range or non-integer operands. - `Wave.scalar_op` handles `s_bitcmp0_b32`, `s_bitcmp1_b32`, `s_bitcmp0_b64`, `s_bitcmp1_b64`: `((a & width) >> (b & mask)) & 1 == (1 or 0)` (`32`-bit `width = U32, mask = 31`; `64`-bit `width = WAVE, mask = 63`). Clears `self.scc = None` on `UNDEF` and raises `ValueError('Dynamic scalar predicate')` on non-concrete operands (`RuntimeWord` raises `Unproven runtime geometry word`). - **`tests/mesh_bitcmp_clause_check.py`**, **`CMakeLists.txt`** (`mesh_bitcmp_clause_cpu`), and **`docs/experiments.md`**. ### Measured checks (`25db1aff` on `origin/main` `b442b57f`) - `tests/mesh_bitcmp_clause_check.py`: PASS — synthetic gfx1013 bytes decoded via `disasm_rdna2.decode_instruction` and lowered with both `mesh_entry_aot.lower` and `mesh_dynamic_aot.enumerate_variants`/`lower` (`s_clause` `0x0`/`0x3f` vs `0x40`/`0xffff`; 32-bit/64-bit bits 0, 31, 34, 35, 63 and index wraps `33 & 31`, `65 & 63` across SGPR pairs, `exec`, `vcc`, `-1`; `UNDEF`/`RuntimeWord`/dynamic refusals). - 13 existing pure-Python `mesh_*` checks + `docs_links_check.py` (469 links) + `bidi_controls_check.py` (1,726 files) + `git diff --check`: all PASS. - 3 fail-first mutations on `tools/mesh_entry_aot.py` (flipping `s_bitcmp1_`/`0_`, `& 31` on `_b64`, dropping `s_clause`): all 3 caught (exit 1). ### Not established - No GPU draw or DXIL compilation was run in this pure-Python mesh lowerer check. AI-assisted (Gemini).
chatgpt-codex-connector[bot commented 2026-11-25 17:01:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T16:48:17Z.


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-25T16:50:19.189850Z 25db1af PR opened
ℹ️ 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:7168557340 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2438#issuecomment-7168557340). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T16:48:17Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"25db1aff2d8fafe8e1f62792fa77c002a2aa131d","has_any_findings":false,"has_unresolved_findings":false,"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-25T16:50:19.189850Z">2026-11-25T16:50:19.189850Z</relative-time> | `25db1af` | PR opened | <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>
tedin7 commented 2026-11-25 19:03:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T18:24:58Z.

Review: COMMENTED


Review of head 25db1aff (Linux-only checks; I did not run any Windows tests, and the PR body shows no Windows run for this head SHA).

Findings

  • P2, overlap with #2444: #2444 (opened later, 16:59 vs 16:48 UTC) also lowers s_bitcmp0/1_b32 and s_bitcmp0/1_b64 in tools/mesh_entry_aot.py, in the same Wave.scalar_op area, and it also touches tools/mesh_dynamic_aot.py. Whichever merges second will conflict. Only one of the two should land. #2438 is older and narrower, and it also adds s_clause. #2444 touches .github/workflows/windows.yml and AGENTS.md, which is out of scope for a small additive PR. The maintainers should pick one before either merges.
  • Nit, tools/mesh_entry_aot.py (s_bitcmp branch): the bit index is b & mask and the value is a & width. That matches the SOPC definition, and UNDEF clears scc. The test pins both. Nothing to change.

What I checked

  • Scope: 4 files (tools/mesh_entry_aot.py +18, new tests/mesh_bitcmp_clause_check.py, a CMakeLists.txt test entry, docs/experiments.md). It is additive and has no CI, launcher or hook changes.
  • s_clause accepts only 0..63 and refuses anything else, in both lower_static and join_arms. Dynamic or non-integer operands are refused with the existing error.
  • python3 -B tests/mesh_bitcmp_clause_check.py passes. It is a CPU-side machine-code decode and lowering check, not a D3D12 readback. That fits here because the change adds no HLSL math, but there is no GPU-side proof.
  • Mutation 1: replacing the 64-bit index mask (b & mask) with b & 31 makes the test fail on the s_bitcmp1_b64 case.
  • Mutation 2: raising the s_clause limit from 0x3F to 0x7F makes the test fail ("lower_static accepted invalid case"). Both mutations were reverted with git checkout -- ..
  • git diff --check origin/main...HEAD, tests/docs_links_check.py and tests/bidi_controls_check.py are clean.
  • Searched open and merged PRs for s_bitcmp and s_clause: #2024 (gfx2hlsl, a different file, merged) and #2444 (overlap, above). No other overlap.

Commands run: python3 -B tests/mesh_bitcmp_clause_check.py, python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py, git diff --check origin/main...HEAD, two sed mutations, git checkout -- ., gh pr list --search, gh pr diff 2444 --name-only.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6062841975 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2438#pullrequestreview-6062841975). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T18:24:58Z. **Review:** COMMENTED --- Review of head 25db1aff (Linux-only checks; I did not run any Windows tests, and the PR body shows no Windows run for this head SHA). Findings - P2, overlap with #2444: #2444 (opened later, 16:59 vs 16:48 UTC) also lowers `s_bitcmp0/1_b32` and `s_bitcmp0/1_b64` in `tools/mesh_entry_aot.py`, in the same `Wave.scalar_op` area, and it also touches `tools/mesh_dynamic_aot.py`. Whichever merges second will conflict. Only one of the two should land. #2438 is older and narrower, and it also adds `s_clause`. #2444 touches `.github/workflows/windows.yml` and `AGENTS.md`, which is out of scope for a small additive PR. The maintainers should pick one before either merges. - Nit, `tools/mesh_entry_aot.py` (`s_bitcmp` branch): the bit index is `b & mask` and the value is `a & width`. That matches the SOPC definition, and `UNDEF` clears `scc`. The test pins both. Nothing to change. What I checked - Scope: 4 files (`tools/mesh_entry_aot.py` +18, new `tests/mesh_bitcmp_clause_check.py`, a `CMakeLists.txt` test entry, `docs/experiments.md`). It is additive and has no CI, launcher or hook changes. - `s_clause` accepts only 0..63 and refuses anything else, in both `lower_static` and `join_arms`. Dynamic or non-integer operands are refused with the existing error. - `python3 -B tests/mesh_bitcmp_clause_check.py` passes. It is a CPU-side machine-code decode and lowering check, not a D3D12 readback. That fits here because the change adds no HLSL math, but there is no GPU-side proof. - Mutation 1: replacing the 64-bit index mask (`b & mask`) with `b & 31` makes the test fail on the `s_bitcmp1_b64` case. - Mutation 2: raising the `s_clause` limit from `0x3F` to `0x7F` makes the test fail ("lower_static accepted invalid case"). Both mutations were reverted with `git checkout -- .`. - `git diff --check origin/main...HEAD`, `tests/docs_links_check.py` and `tests/bidi_controls_check.py` are clean. - Searched open and merged PRs for `s_bitcmp` and `s_clause`: #2024 (gfx2hlsl, a different file, merged) and #2444 (overlap, above). No other overlap. Commands run: `python3 -B tests/mesh_bitcmp_clause_check.py`, `python3 tests/docs_links_check.py`, `python3 tests/bidi_controls_check.py`, `git diff --check origin/main...HEAD`, two `sed` mutations, `git checkout -- .`, `gh pr list --search`, `gh pr diff 2444 --name-only`. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 21:00:57 +00:00
tedin7 commented 2026-11-25 21:00:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:06:50Z.

Review: COMMENTED


Review of head 777a4277 (comment only, no merge from this side).

Checked:

  • tools/mesh_entry_aot.py: the s_bitcmp{0,1}_b{32,64} semantics (32-bit index & 31, 64-bit index & 63, UNDEF clears scc, non-concrete operands refuse) and the s_clause 0..63 operand range look correct.
  • tests/mesh_bitcmp_clause_check.py passes locally.
  • Two mutations of the code under test (flip s_bitcmp1_/s_bitcmp0_; disable the s_clause branch) both make the test fail (exit 1).
  • python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py, git diff --check origin/main...HEAD: clean.

Finding (overlap, design question): #2444 (shader/mesh-bitcmp) lowers the same four s_bitcmp{0,1}_b{32,64} opcodes in the same function (Wave.scalar_op in tools/mesh_entry_aot.py) and also touches tools/mesh_dynamic_aot.py. Two PRs for the same slice will conflict on whichever lands second. #2438 adds s_clause, which #2444 does not; #2444 adds Dyn constant-buffer bit tests, s_cbranch_scc1 joins and a WARP draw test, which #2438 does not. Leaving the choice (merge one, rebase the other onto it, or split s_clause out) to @R0Y00.

Not covered: CI on this head was still pending at review time; no GPU draw or DXIL compile exists for this slice (the PR says so itself). I did not run Win2025.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6064219003 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2438#pullrequestreview-6064219003). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T20:06:50Z. **Review:** COMMENTED --- Review of head 777a4277 (comment only, no merge from this side). Checked: - `tools/mesh_entry_aot.py`: the `s_bitcmp{0,1}_b{32,64}` semantics (32-bit index `& 31`, 64-bit index `& 63`, UNDEF clears `scc`, non-concrete operands refuse) and the `s_clause` 0..63 operand range look correct. - `tests/mesh_bitcmp_clause_check.py` passes locally. - Two mutations of the code under test (flip `s_bitcmp1_`/`s_bitcmp0_`; disable the `s_clause` branch) both make the test fail (exit 1). - `python3 tests/docs_links_check.py`, `python3 tests/bidi_controls_check.py`, `git diff --check origin/main...HEAD`: clean. Finding (overlap, design question): #2444 (`shader/mesh-bitcmp`) lowers the same four `s_bitcmp{0,1}_b{32,64}` opcodes in the same function (`Wave.scalar_op` in `tools/mesh_entry_aot.py`) and also touches `tools/mesh_dynamic_aot.py`. Two PRs for the same slice will conflict on whichever lands second. #2438 adds `s_clause`, which #2444 does not; #2444 adds `Dyn` constant-buffer bit tests, `s_cbranch_scc1` joins and a WARP draw test, which #2438 does not. Leaving the choice (merge one, rebase the other onto it, or split `s_clause` out) to @R0Y00. Not covered: CI on this head was still pending at review time; no GPU draw or DXIL compile exists for this slice (the PR says so itself). I did not run Win2025. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 21:00:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:29:34Z.

Review: COMMENTED


Review of head 5353163e (code + fixture tests only; no game, no GPU draw claimed).

Checked

  • tools/mesh_entry_aot.py: s_bitcmp{0,1}_b{32,64} semantics are right (bit index masked to 31/63, operand masked to width, SCC set from bit == 1 or 0). UNDEF clears SCC, non-concrete operands refuse. s_clause accepts 0..63 only, rejects other operands. Sibling s_cmp_ / s_inst_prefetch / s_nop paths are untouched.
  • tests/mesh_bitcmp_clause_check.py is registered as mesh_bitcmp_clause_cpu in CMakeLists.txt and decodes real gfx1013 bytes through both mesh_entry_aot and mesh_dynamic_aot.
  • No other open or merged PR covers the same slice (search on s_bitcmp s_clause).
  • This is a CPU lowering check, so no D3D12 readback is needed; the PR says so under "Not established".

Commands run locally

  • python3 -B tests/mesh_bitcmp_clause_check.py -> PASS
  • python3 tests/docs_links_check.py -> 483 links OK
  • python3 tests/bidi_controls_check.py -> OK
  • git diff --check origin/main...HEAD -> clean
  • Mutation 1: s_bitcmp1_ -> s_bitcmp0_ in the lowerer: new test fails (exit 1).
  • Mutation 2: s_clause upper bound 0x3F -> 0x7F: new test fails (exit 1).

No blocking findings. Win2025 run follows separately.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6064518606 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2438#pullrequestreview-6064518606). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T20:29:34Z. **Review:** COMMENTED --- Review of head 5353163e (code + fixture tests only; no game, no GPU draw claimed). Checked - `tools/mesh_entry_aot.py`: `s_bitcmp{0,1}_b{32,64}` semantics are right (bit index masked to 31/63, operand masked to width, SCC set from bit == 1 or 0). UNDEF clears SCC, non-concrete operands refuse. `s_clause` accepts 0..63 only, rejects other operands. Sibling `s_cmp_` / `s_inst_prefetch` / `s_nop` paths are untouched. - `tests/mesh_bitcmp_clause_check.py` is registered as `mesh_bitcmp_clause_cpu` in CMakeLists.txt and decodes real gfx1013 bytes through both `mesh_entry_aot` and `mesh_dynamic_aot`. - No other open or merged PR covers the same slice (search on `s_bitcmp s_clause`). - This is a CPU lowering check, so no D3D12 readback is needed; the PR says so under "Not established". Commands run locally - `python3 -B tests/mesh_bitcmp_clause_check.py` -> PASS - `python3 tests/docs_links_check.py` -> 483 links OK - `python3 tests/bidi_controls_check.py` -> OK - `git diff --check origin/main...HEAD` -> clean - Mutation 1: `s_bitcmp1_` -> `s_bitcmp0_` in the lowerer: new test fails (exit 1). - Mutation 2: `s_clause` upper bound 0x3F -> 0x7F: new test fails (exit 1). No blocking findings. Win2025 run follows separately. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 21:01:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:32:00Z.


Win2025 WARP receipt for head e12e1229 after updating with main.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit e12e122979d6dba3603a7d0b261e1f8c7173dc8a:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev -- -j 2): 34.17s (configure 1.81s)
    • Test (ctest --preset dev -R 'mesh_bitcmp_clause_cpu' --parallel 6 --no-tests=error --output-on-failure): 1/1 passed (3.15s: mesh_bitcmp_clause_cpu 2.73s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release -- -j 2): 45.14s (configure 2.05s)
    • Test (ctest --preset release -R 'mesh_bitcmp_clause_cpu' --parallel 6 --no-tests=error --output-on-failure): 1/1 passed (2.27s: mesh_bitcmp_clause_cpu 2.16s)
  • Windows Python checks: tests/mesh_clip_cull_check.py ok (3.4s), tests/mesh_dynamic_aot_check.py ok (0.8s), tests/mesh_dynamic_geometry_check.py ok (0.2s), tests/mesh_join_descriptor_check.py ok (0.2s), tests/mesh_lane_spill_check.py ok (0.2s), tests/startup_ngg_slice_check.py ok (0.2s)
  • sccache: 392/421 hits; wall 96.8s

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7173812819 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2438#issuecomment-7173812819). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T20:32:00Z. --- Win2025 WARP receipt for head e12e1229 after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `e12e122979d6dba3603a7d0b261e1f8c7173dc8a`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev -- -j 2`): `34.17s` (configure `1.81s`) - Test (`ctest --preset dev -R 'mesh_bitcmp_clause_cpu' --parallel 6 --no-tests=error --output-on-failure`): **1/1 passed** (`3.15s`: `mesh_bitcmp_clause_cpu` `2.73s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release -- -j 2`): `45.14s` (configure `2.05s`) - Test (`ctest --preset release -R 'mesh_bitcmp_clause_cpu' --parallel 6 --no-tests=error --output-on-failure`): **1/1 passed** (`2.27s`: `mesh_bitcmp_clause_cpu` `2.16s`) - **Windows Python checks**: `tests/mesh_clip_cull_check.py` ok (`3.4s`), `tests/mesh_dynamic_aot_check.py` ok (`0.8s`), `tests/mesh_dynamic_geometry_check.py` ok (`0.2s`), `tests/mesh_join_descriptor_check.py` ok (`0.2s`), `tests/mesh_lane_spill_check.py` ok (`0.2s`), `tests/startup_ngg_slice_check.py` ok (`0.2s`) - `sccache`: 392/421 hits; wall `96.8s` AI-assisted; commands listed were executed locally.
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!2430
No description provided.