shader: lower binary32 integer conversions, min and max in the mesh-entry translator #1152

Manually merged
github merged 2 commits from gh-pr/1152/head into gh-pr/1152/base 2026-11-26 22:44:37 +00:00
Owner

@⁠tedin7 on GitHub · 2026-11-24 01:48 UTC · original
tedin7:x2w-mesh-entry-cvt-minmax → main · +174 −0 · 4 files · 2 commits · merged 2026-11-24 02:53 UTC

Change

Lowers the binary32 integer-to-float conversions v_cvt_f32_u32 and v_cvt_f32_i32 and the binary32 v_min_f32 and v_max_f32 (_e32 and _e64) in the mesh-entry translator (tools/mesh_entry_aot.py). A conversion needs a concrete integer word; a float expression as its source is refused. Source modifiers, clamp and output modifiers are refused. No related issue.

Overlap: #1117 edits the same file and test for add, sub, subrev and mul. This change is separate (different opcodes, separate test mode draw-cvt-minmax and ctest mesh_entry_cvt_minmax_draw_*). Whichever lands second needs a mechanical rebase of the adjacent test and CMake lines.

Verification

Local, Linux, LLVM 19 (CI uses LLVM 15, not available locally):

  • python3 -B tests/mesh_entry_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so: exit 0 with this change; exit 1 on origin/main c205cffd with the same test file (the translator rejects the new opcodes).
  • tests/mesh_indexed_check.py binary and tests/mesh_descriptor_swap_check.py binary: exit 0.
  • The draw draw-cvt-minmax is written for Windows and was not run here (no D3D12 adapter, no dxc). Missing prerequisite: Windows runner.

Evidence and follow-up

Test program: four exact words (0xc0000000 and 0x80000000, each read as unsigned and signed) are converted, then clamped by min or max; depth 0.8125. The reference is independent hand arithmetic on exact values, not the lowering. Negative controls: each of the eight opcodes swapped for its sibling gives a different evaluated depth (binary mode) and must report Mesh export trace mismatch (draw mode); the draw also expects one unit in the last place off in the depth word of the last vertex to be reported. Refusals of modifiers, clamp, omod and a float source are asserted.

Not exercised: NaN operands, signed zeros, conversions that need rounding. Fixtures are synthetic, MIT, written from the ISA description.

This work is AI-assisted.

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.
  • I did not include game files, dumps, distribution links or secrets.
**@⁠tedin7** on GitHub · 2026-11-24 01:48 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1152) `tedin7:x2w-mesh-entry-cvt-minmax` → `main` · +174 −0 · 4 files · 2 commits · merged 2026-11-24 02:53 UTC ## Change Lowers the binary32 integer-to-float conversions `v_cvt_f32_u32` and `v_cvt_f32_i32` and the binary32 `v_min_f32` and `v_max_f32` (`_e32` and `_e64`) in the mesh-entry translator (`tools/mesh_entry_aot.py`). A conversion needs a concrete integer word; a float expression as its source is refused. Source modifiers, `clamp` and output modifiers are refused. No related issue. Overlap: #1117 edits the same file and test for add, sub, subrev and mul. This change is separate (different opcodes, separate test mode `draw-cvt-minmax` and ctest `mesh_entry_cvt_minmax_draw_*`). Whichever lands second needs a mechanical rebase of the adjacent test and CMake lines. ## Verification Local, Linux, LLVM 19 (CI uses LLVM 15, not available locally): - `python3 -B tests/mesh_entry_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so`: exit 0 with this change; exit 1 on `origin/main` c205cffd with the same test file (the translator rejects the new opcodes). - `tests/mesh_indexed_check.py binary` and `tests/mesh_descriptor_swap_check.py binary`: exit 0. - The draw `draw-cvt-minmax` is written for Windows and was not run here (no D3D12 adapter, no dxc). Missing prerequisite: Windows runner. ## Evidence and follow-up Test program: four exact words (0xc0000000 and 0x80000000, each read as unsigned and signed) are converted, then clamped by min or max; depth 0.8125. The reference is independent hand arithmetic on exact values, not the lowering. Negative controls: each of the eight opcodes swapped for its sibling gives a different evaluated depth (binary mode) and must report `Mesh export trace mismatch` (draw mode); the draw also expects one unit in the last place off in the depth word of the last vertex to be reported. Refusals of modifiers, clamp, omod and a float source are asserted. Not exercised: NaN operands, signed zeros, conversions that need rounding. Fixtures are synthetic, MIT, written from the ISA description. This work is AI-assisted. ## 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. - [x] I did not include game files, dumps, distribution links or secrets.
Adds v_cvt_f32_u32, v_cvt_f32_i32, v_min_f32 and v_max_f32 (e32 and e64) with an independent binary32 reference, a dedicated draw readback and sibling-opcode negative controls.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:44:35 +00:00
github manually merged commit a430e970b5 into gh-pr/1152/base 2026-11-26 22:44:37 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 02:31 UTC · original · edited 2026-11-24 02:36 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-24T02:36:08.657473Z a430e97 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-24 02:31 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1152#issuecomment-7120229342) · edited 2026-11-24 02:36 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"a430e970b589bdf6cec1e9ae53ba8a833a73f55e","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-24T02:36:08.657473Z">2026-11-24T02:36:08.657473Z</relative-time> | `a430e97` | 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>
This discussion has been locked. Commenting is limited to contributors.
No description provided.