shader: lower u32 add, max, or and xor in the compute store profile #1083

Manually merged
github merged 3 commits from gh-pr/1083/head into gh-pr/1083/base 2026-11-26 22:40:17 +00:00
Owner

@⁠tedin7 on GitHub · 2026-11-24 00:29 UTC · original
tedin7:x2w-compute-store-u32-add-max-or-xor → main · +99 −6 · 3 files · 3 commits · merged 2026-11-24 01:24 UTC

Change

Adds four unsigned 32-bit VOP2 operations to the compute store profile's integer ALU subset: v_add_nc_u32_e32, v_max_u32_e32, v_or_b32_e32 and v_xor_b32_e32. They follow the existing v_min_u32_e32 and v_and_b32_e32 path: known-word sources, inline HLSL expression, no write to vcc. The docs table is updated, and the rejection controls that used v_max_u32 and v_or_b32 as examples now use v_max_i32 and v_xnor_b32.

Refs #721 (step 4, arithmetic subset).

Verification

  • python3 -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so: passes with the change.
  • Same command with the new test and the unchanged tools/compute_store_aot.py from main: fails with Unsupported compute instruction: v_add_nc_u32_e32 v2, 7, v1.
  • python3 -B tests/rdna2_tools_check.py: 97 tests, OK (skipped=8).
  • Local runs used LLVM 19, not the LLVM 15 that CI uses. The four mnemonics and operand forms are ordinary VOP2 spellings.
  • tests/pixel_aot_check.py binary fails locally under LLVM 19 on v_cvt_f16_i16_e32; that file is untouched here.

Evidence and follow-up

New fixture read_vop2 chains add, or, xor and max and checks the exact lowered HLSL expression. This checks the translation text only. It is not a hardware or console result.

AI-assisted change.

Checklist

  • One behavior per PR
  • Docs updated
  • No game files, dumps or credentials
**@⁠tedin7** on GitHub · 2026-11-24 00:29 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1083) `tedin7:x2w-compute-store-u32-add-max-or-xor` → `main` · +99 −6 · 3 files · 3 commits · merged 2026-11-24 01:24 UTC ## Change Adds four unsigned 32-bit VOP2 operations to the compute store profile's integer ALU subset: `v_add_nc_u32_e32`, `v_max_u32_e32`, `v_or_b32_e32` and `v_xor_b32_e32`. They follow the existing `v_min_u32_e32` and `v_and_b32_e32` path: known-word sources, inline HLSL expression, no write to vcc. The docs table is updated, and the rejection controls that used `v_max_u32` and `v_or_b32` as examples now use `v_max_i32` and `v_xnor_b32`. Refs #721 (step 4, arithmetic subset). ## Verification - `python3 -B tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so`: passes with the change. - Same command with the new test and the unchanged `tools/compute_store_aot.py` from main: fails with `Unsupported compute instruction: v_add_nc_u32_e32 v2, 7, v1`. - `python3 -B tests/rdna2_tools_check.py`: 97 tests, OK (skipped=8). - Local runs used LLVM 19, not the LLVM 15 that CI uses. The four mnemonics and operand forms are ordinary VOP2 spellings. - `tests/pixel_aot_check.py binary` fails locally under LLVM 19 on `v_cvt_f16_i16_e32`; that file is untouched here. ## Evidence and follow-up New fixture `read_vop2` chains add, or, xor and max and checks the exact lowered HLSL expression. This checks the translation text only. It is not a hardware or console result. AI-assisted change. ## Checklist - [x] One behavior per PR - [x] Docs updated - [x] No game files, dumps or credentials
The draw modes route every read_ case through the indexed-copy reference, which does not describe the chained arithmetic of the VOP2 fixture, so the first non-empty dispatch would fail on Windows even with correct lowering. Assemble and translate the fixture in the binary mode only, in its own list, and say why in a comment.
Run the add, or, xor and unsigned max chain on the GPU against an independent CPU reference (320-word case format). The cap is large enough that the add wraps for most lanes, the high-bit OR and XOR clear and set bits 31 and 0, and the max takes the product for some lanes and the chain for others, so a signed max differs too. References for a signed max, a min, and a dropped add, or or xor must each fail at their first differing word, and the same four edits applied to the translated source must fail the readback.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:40:15 +00:00
github manually merged commit 4c3c11b1af into gh-pr/1083/base 2026-11-26 22:40:17 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 00:29 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:15.621324Z 5c7e4dd 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:29 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1083#issuecomment-7118128614) · edited 2026-11-24 00:33 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"5c7e4dd65fb59a26f5458404ae169f1d8dd01257","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:15.621324Z">2026-11-24T00:33:15.621324Z</relative-time> | `5c7e4dd` | 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>
@ -772,3 +780,4 @@
("read_compute", READ_COMPUTE, 32, READ_BINDING),
("read_mad24", READ_MAD24, 32, READ_BINDING),
("read_mul_lo", READ_MUL_LO, 32, READ_BINDING),
("read_vop2", READ_VOP2, 32, READ_BINDING),
Author
Owner

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

P1 Badge Add a matching runtime reference for the VOP2 fixture

When the Windows draw-guard-read mode consumes ALU_CASES, draw() routes read_vop2 to draw_read(). That handler uses read_words(), which expects an indexed copy (source_word(2 * gid + 1)), not the new arithmetic result. With the harness constants, lane 0 expects 0x8b06bba2 while the emitted expression yields 0xdffd2ae8, so the first nonempty dispatch fails the existing compute_store_aot_guard_read_* tests even when lowering is correct. Add a matching runtime reference and handler, or keep this text-only fixture separate from the runtime case list.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 00:33 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1083#discussion_r4673929265) **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Add a matching runtime reference for the VOP2 fixture** When the Windows `draw-guard-read` mode consumes `ALU_CASES`, `draw()` routes `read_vop2` to `draw_read()`. That handler uses `read_words()`, which expects an indexed copy (`source_word(2 * gid + 1)`), not the new arithmetic result. With the harness constants, lane 0 expects `0x8b06bba2` while the emitted expression yields `0xdffd2ae8`, so the first nonempty dispatch fails the existing `compute_store_aot_guard_read_*` tests even when lowering is correct. Add a matching runtime reference and handler, or keep this text-only fixture separate from the runtime case list. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠tedin7 on GitHub · 2026-11-24 00:56 UTC · original

Added the dedicated readback (read_vop2 is back in the runtime list and has its own handler, not the indexed-copy oracle).

  • Chain per lane: p = lo16 * hi16 + gid; chain = 0x80000001 ^ (0x80000010 | (cap + p)); stored word = unsigned max(p, chain). The reference is plain Python integer arithmetic in tests/compute_store_check.py, independent of the lowering.
  • Inputs: cap 0xe0000000, so the add wraps (115 of 150 lanes), the max picks the product on 115 lanes and the chain on 35, and a signed max gives different words (the test asserts all of this before running).
  • Controls: references with a signed max, min for max, a dropped add, a dropped or, and a dropped xor each must fail at their first differing word; the same four edits on the translated HLSL must fail the readback.
  • Local: binary mode passes with LLVM 19. The draw itself needs the Windows jobs, which are running now.

AI-assisted.

**@⁠tedin7** on GitHub · 2026-11-24 00:56 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1083#issuecomment-7118598982) Added the dedicated readback (read_vop2 is back in the runtime list and has its own handler, not the indexed-copy oracle). - Chain per lane: p = lo16 * hi16 + gid; chain = 0x80000001 ^ (0x80000010 | (cap + p)); stored word = unsigned max(p, chain). The reference is plain Python integer arithmetic in tests/compute_store_check.py, independent of the lowering. - Inputs: cap 0xe0000000, so the add wraps (115 of 150 lanes), the max picks the product on 115 lanes and the chain on 35, and a signed max gives different words (the test asserts all of this before running). - Controls: references with a signed max, min for max, a dropped add, a dropped or, and a dropped xor each must fail at their first differing word; the same four edits on the translated HLSL must fail the readback. - Local: binary mode passes with LLVM 19. The draw itself needs the Windows jobs, which are running now. AI-assisted.
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: 5c7e4dd65f

ℹ️ 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/1083#pullrequestreview-6031785246) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `5c7e4dd65f` <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>
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-24 00:50 UTC · original · requested changes

The LLVM 15 binary suite and the surrounding Windows compute fixture ran locally. I see why the indexed-copy oracle cannot check the new arithmetic. Please give this candidate a dedicated chained arithmetic readback with an independent CPU reference. Use inputs that show add wrap, high-bit XOR/OR and unsigned max choosing both operands, and a wrong max/signed or dropped-op control that changes a specific output word. This can reuse the existing 320-word case format.

**@⁠R0Y00** on GitHub · 2026-11-24 00:50 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1083#pullrequestreview-6031935003) · **requested changes** The LLVM 15 binary suite and the surrounding Windows compute fixture ran locally. I see why the indexed-copy oracle cannot check the new arithmetic. Please give this candidate a dedicated chained arithmetic readback with an independent CPU reference. Use inputs that show add wrap, high-bit XOR/OR and unsigned max choosing both operands, and a wrong max/signed or dropped-op control that changes a specific output word. This can reuse the existing 320-word case format.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-24 01:05 UTC · original · approved these changes

The dedicated readback now runs in the guard-read entries. I reran both Windows Release entries on RTX 4060 Laptop and WARP at 4c3c11b1. All normal buffers matched and the independent alternative references caught the arithmetic and range errors while preserving the sentinel words. This clears my previous readback request.

**@⁠R0Y00** on GitHub · 2026-11-24 01:05 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1083#pullrequestreview-6032054350) · **approved these changes** The dedicated readback now runs in the guard-read entries. I reran both Windows Release entries on RTX 4060 Laptop and WARP at 4c3c11b1. All normal buffers matched and the independent alternative references caught the arithmetic and range errors while preserving the sentinel words. This clears my previous readback request.
This discussion has been locked. Commenting is limited to contributors.
No description provided.