shader: lower scalar and vector 32-bit ALU ops in the mesh-entry translator #1080

Manually merged
github merged 2 commits from gh-pr/1080/head into gh-pr/1080/base 2026-11-26 22:40:07 +00:00
Owner

@⁠tedin7 on GitHub · 2026-11-24 00:28 UTC · original
tedin7:x2w-mesh-entry-scalar-vector-u32 → main · +76 −2 · 2 files · 2 commits · merged 2026-11-24 01:13 UTC

Change

Adds scalar s_add_u32, s_sub_u32, s_mul_i32 and vector v_sub_nc_u32_e32, v_or_b32_e32, v_xor_b32_e32, v_min_u32_e32, v_max_u32_e32 to the concrete mesh-entry evaluator in tools/mesh_entry_aot.py, following the pattern of the existing integer ops.

  • s_add_u32 sets SCC to the carry out, s_sub_u32 sets SCC to the borrow, s_mul_i32 leaves SCC unchanged.
  • v_sub_nc_u32_e32 is src0 - vsrc1; v_min_u32_e32 / v_max_u32_e32 compare unsigned.

The fixture in tests/mesh_entry_check.py uses operands chosen so that wrong flag handling, wrong operand order or a signed comparison changes an emitted constant. It also adds a draw case with the same program for the GPU runner.

Verification

Base 110e1860 plus this commit, Linux, LLVM 19 (llvm-mc-19, libLLVM 19.1; llvm-mc-15 is not installed here):

python3 -B tests/mesh_entry_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM.so.19.1 exits 0.

Negative control: the same test with tools/mesh_entry_aot.py taken from origin/main exits 1 (the tool rejects the new instructions).

Not run: the --mesh-entry draw path (needs DXC and a D3D12 adapter on Windows); LLVM 15 locally. The CI job uses llvm-mc-15; these are long-standing gfx10 spellings, but CI is the check for that.

Evidence and follow-up

Synthetic fixture only; no external inputs. The draw case expects exact depth 0.6953125, a sum of binary32-exact terms.

This is AI-assisted work.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed (none needed).
  • I did not include game files, dumps, distribution links or secrets.
**@⁠tedin7** on GitHub · 2026-11-24 00:28 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1080) `tedin7:x2w-mesh-entry-scalar-vector-u32` → `main` · +76 −2 · 2 files · 2 commits · merged 2026-11-24 01:13 UTC ## Change Adds scalar `s_add_u32`, `s_sub_u32`, `s_mul_i32` and vector `v_sub_nc_u32_e32`, `v_or_b32_e32`, `v_xor_b32_e32`, `v_min_u32_e32`, `v_max_u32_e32` to the concrete mesh-entry evaluator in `tools/mesh_entry_aot.py`, following the pattern of the existing integer ops. - `s_add_u32` sets SCC to the carry out, `s_sub_u32` sets SCC to the borrow, `s_mul_i32` leaves SCC unchanged. - `v_sub_nc_u32_e32` is `src0 - vsrc1`; `v_min_u32_e32` / `v_max_u32_e32` compare unsigned. The fixture in `tests/mesh_entry_check.py` uses operands chosen so that wrong flag handling, wrong operand order or a signed comparison changes an emitted constant. It also adds a draw case with the same program for the GPU runner. ## Verification Base 110e1860 plus this commit, Linux, LLVM 19 (llvm-mc-19, libLLVM 19.1; llvm-mc-15 is not installed here): `python3 -B tests/mesh_entry_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM.so.19.1` exits 0. Negative control: the same test with `tools/mesh_entry_aot.py` taken from origin/main exits 1 (the tool rejects the new instructions). Not run: the `--mesh-entry` draw path (needs DXC and a D3D12 adapter on Windows); LLVM 15 locally. The CI job uses llvm-mc-15; these are long-standing gfx10 spellings, but CI is the check for that. ## Evidence and follow-up Synthetic fixture only; no external inputs. The draw case expects exact depth 0.6953125, a sum of binary32-exact terms. This is AI-assisted work. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed (none needed). - [x] I did not include game files, dumps, distribution links or secrets.
Adds s_add_u32, s_sub_u32, s_mul_i32, v_sub_nc_u32, v_or_b32, v_xor_b32, v_min_u32 and v_max_u32 with a fixture that checks flag and operand-order behavior.
The two sign-bit results were each used once, so a signed comparison only swapped two addends and left both the translated text and the drawn depth unchanged. Use the unsigned min three times and the unsigned max twice, update the expected depth (0.4453125, exact in binary32; the swapped results would give -3.2578125), and assert both use counts in the translated text.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:40:05 +00:00
github manually merged commit d162e9d713 into gh-pr/1080/base 2026-11-26 22:40:07 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 00:28 UTC · original · edited 2026-11-24 00:33 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-24T00:33:41.168033Z 2c49c0c 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.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 00:28 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1080#issuecomment-7118111147) · edited 2026-11-24 00:33 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"2c49c0c5af7e07702c99d64f6e114d148aeb5136","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-24T00:33:41.168033Z">2026-11-24T00:33:41.168033Z</relative-time> | `2c49c0c` | 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>
@ -261,0 +308,4 @@
Path(directory), *sys.argv[2:], program=ALU_PROGRAM, words=[4099]
)
for operand in ALU_OPERANDS:
assert f"asfloat(0x{operand:08x}u)" in text, hex(operand)
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 00:33 UTC · original

P2 Badge Make the unsigned min/max fixture distinguish swapped results

When both min/max handlers use signed comparisons, these assertions still pass: the sign-bit cases merely swap 0x3f200000 and 0xbfc00000, leaving both strings present. alu_draw() also adds both results using exact binary32 arithmetic, so its expected depth remains 0.6953125. I verified this signed-comparison negative control against the added assertions and depth calculation. Assert each result at its specific use, or consume the results asymmetrically, so the fixture actually detects incorrect signedness.

AGENTS.md reference: AGENTS.md:L159-L159

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 00:33 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1080#discussion_r4673932174) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Make the unsigned min/max fixture distinguish swapped results** When both min/max handlers use signed comparisons, these assertions still pass: the sign-bit cases merely swap `0x3f200000` and `0xbfc00000`, leaving both strings present. `alu_draw()` also adds both results using exact binary32 arithmetic, so its expected depth remains `0.6953125`. I verified this signed-comparison negative control against the added assertions and depth calculation. Assert each result at its specific use, or consume the results asymmetrically, so the fixture actually detects incorrect signedness. AGENTS.md reference: [AGENTS.md:L159-L159](https://github.com/R0Y00/Xbox2Windows/blob/2c49c0c5af7e07702c99d64f6e114d148aeb5136/AGENTS.md#L159-L159) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-24 01:13 UTC · original

On d162e9d7 the asymmetric min/max fixture drew all 1,024 pixels correctly on WARP, including the trace-enabled run. In a separate source-built control I swapped the two sign-bit min/max results, which is what signed comparison would do for these operands. The readback rejected all 1,024 pixels. This verifies the review thread's missing control.

**@⁠R0Y00** on GitHub · 2026-11-24 01:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1080#issuecomment-7118878649) On `d162e9d7` the asymmetric min/max fixture drew all 1,024 pixels correctly on WARP, including the trace-enabled run. In a separate source-built control I swapped the two sign-bit min/max results, which is what signed comparison would do for these operands. The readback rejected all 1,024 pixels. This verifies the review thread's missing control.
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 00:33 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2c49c0c5af

ℹ️ 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-24 00:33 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1080#pullrequestreview-6031788702) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `2c49c0c5af` <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.