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

Merged
tedin7 merged 2 commits from upstream-pr/1152 into main 2026-11-24 02:53:42 +00:00
tedin7 commented 2026-11-24 01:48:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T01:48:46Z.


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.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6572751780 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1152). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T01:48:46Z. --- ## 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.
upstream-sync closed this pull request 2026-11-24 06:46:33 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:50:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T02:31:33Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7120229342 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1152#issuecomment-7120229342). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T02:31:33Z. --- <!-- 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>
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!1145
No description provided.