shader: lower off and vcc_hi operands in gfx2hlsl (Part of #1723) #2034

Closed
github-bot wants to merge 3 commits from gh-pr/2034/head into gh-pr/2034/base
Owner

@⁠tedin7 on GitHub · 2026-11-24 23:30 UTC · original
tedin7:x2w-r20-off-vcchi → main · +108 −0 · 4 files · 3 commits · closed without merging

Part of #1723

What this unblocks: Run 20 census #20 (34/32 pairs).

gfx2hlsl refused two operands outright. A compressed export with an off register (exp mrt0 v0, v1, off, off compr) now exports zero for that pair, as an uncompressed off already does. vcc_hi as a source now reads zero, because in wave32 the high half of the lane mask holds no lane.

Known limit: the vcc_hi rule assumes wave32, which is what the translator targets. Writes to vcc_hi and to exec_hi are unchanged.

Changes:

  • tools/startup/gfx2hlsl.py: u() returns 0u for vcc_hi; the compressed export maps off to 0u before splitting it into halves.
  • tests/startup_gfx2hlsl_off_vcchi_check.py (new, registered in CMakeLists.txt as startup_gfx2hlsl_off_vcchi): translates both forms and checks the emitted lines.

Verification: run locally on Linux (not on Win2025), from the repo root of the branch.

  • python3 -B tests/startup_gfx2hlsl_off_vcchi_check.py: PASS with the change. With tools/startup/gfx2hlsl.py from origin/main: FAIL (operand 'off', operand 'vcc_hi').
  • python3 -B tests/startup_gfx2hlsl_sop2_complement_check.py: PASS.
  • python3 -B tests/startup_gfx2hlsl_refusals_check.py: no failing check.
  • python3 -B tests/startup_translator_check.py: 0 failed.
  • Not run: the CMake/CTest registration.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-24 23:30 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2034) `tedin7:x2w-r20-off-vcchi` → `main` · +108 −0 · 4 files · 3 commits · closed without merging Part of #1723 What this unblocks: Run 20 census #20 (34/32 pairs). `gfx2hlsl` refused two operands outright. A compressed export with an `off` register (`exp mrt0 v0, v1, off, off compr`) now exports zero for that pair, as an uncompressed `off` already does. `vcc_hi` as a source now reads zero, because in wave32 the high half of the lane mask holds no lane. Known limit: the `vcc_hi` rule assumes wave32, which is what the translator targets. Writes to `vcc_hi` and to `exec_hi` are unchanged. Changes: - `tools/startup/gfx2hlsl.py`: `u()` returns `0u` for `vcc_hi`; the compressed export maps `off` to `0u` before splitting it into halves. - `tests/startup_gfx2hlsl_off_vcchi_check.py` (new, registered in `CMakeLists.txt` as `startup_gfx2hlsl_off_vcchi`): translates both forms and checks the emitted lines. Verification: run locally on Linux (not on Win2025), from the repo root of the branch. - `python3 -B tests/startup_gfx2hlsl_off_vcchi_check.py`: PASS with the change. With `tools/startup/gfx2hlsl.py` from `origin/main`: FAIL (`operand 'off'`, `operand 'vcc_hi'`). - `python3 -B tests/startup_gfx2hlsl_sop2_complement_check.py`: PASS. - `python3 -B tests/startup_gfx2hlsl_refusals_check.py`: no failing check. - `python3 -B tests/startup_translator_check.py`: 0 failed. - Not run: the CMake/CTest registration. AI-assisted; commands listed were executed locally.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:51:09 +00:00
github-bot closed this pull request 2026-11-26 23:51:09 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:31 UTC · original · edited 2026-11-24 23:39 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-24T23:39:53.219480Z 6766106 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 23:31 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2034#issuecomment-7147490898) · edited 2026-11-24 23:39 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"6766106b8b2edab8bd3d8458100fc5be1abe5d69","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-24T23:39:53.219480Z">2026-11-24T23:39:53.219480Z</relative-time> | `6766106` | 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>
Author
Owner

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

P1 Badge Preserve disabled channels in partial compressed exports

For an RG-only compressed export with a full render-target write mask, off disables B/A writes; it does not write zero to those channels. This now emits a full float4, but the manifest carries no channel mask and pipeline_for() in src/startup_stubs/d3d12_draw.inl:473-476 defaults to D3D12_COLOR_WRITE_ENABLE_ALL. Consequently, the newly accepted exp mrt0 v0, v0, off, off done compr vm overwrites existing B/A values with zero. Carry the EXP enable mask through to the desktop PSO, as the existing pixel_aot.lower(..., return_write_mask=True) path does, or retain refusal until that mask can be applied.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 23:39 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2034#discussion_r4688081629) **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Preserve disabled channels in partial compressed exports** For an RG-only compressed export with a full render-target write mask, `off` disables B/A writes; it does not write zero to those channels. This now emits a full `float4`, but the manifest carries no channel mask and `pipeline_for()` in `src/startup_stubs/d3d12_draw.inl:473-476` defaults to `D3D12_COLOR_WRITE_ENABLE_ALL`. Consequently, the newly accepted `exp mrt0 v0, v0, off, off done compr vm` overwrites existing B/A values with zero. Carry the EXP enable mask through to the desktop PSO, as the existing `pixel_aot.lower(..., return_write_mask=True)` path does, or retain refusal until that mask can be applied. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

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

P2 Badge Validate the guest wave mode before folding vcc_hi to zero

For a wave64 gfx1013 shader, the legal sequence s_mov_b64 vcc, -1 followed by v_mov_b32 v3, vcc_hi must copy 0xffffffff, but this change emits v3 = 0u. Neither Pipeline nor Stage validates a guest wave32 profile, so the comment's wave32 assumption does not constrain when this folding occurs. The sequence was previously refused and now silently produces incorrect shader data. Require validated mode/value information before folding the high word, and retain refusal for unverified reads.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 23:39 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2034#discussion_r4688081641) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Validate the guest wave mode before folding vcc_hi to zero** For a wave64 gfx1013 shader, the legal sequence `s_mov_b64 vcc, -1` followed by `v_mov_b32 v3, vcc_hi` must copy `0xffffffff`, but this change emits `v3 = 0u`. Neither `Pipeline` nor `Stage` validates a guest wave32 profile, so the comment's wave32 assumption does not constrain when this folding occurs. The sequence was previously refused and now silently produces incorrect shader data. Require validated mode/value information before folding the high word, and retain refusal for unverified reads. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

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

P1 Badge Document the expanded translator support and reproduction command

Accepting previously refused compressed-export and vcc_hi forms expands the public startup translator capability, but this commit updates neither the README nor docs/experiments.md. The root AGENTS.md requires a documentation update when a public capability changes. Add the new fixture's reproduction command and scope there, distinguishing the passing translation-only checks from unverified GPU behavior and recording the wave-mode limitation.

AGENTS.md reference: AGENTS.md:L210-L211

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-24 23:39 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2034#discussion_r4688081648) **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Document the expanded translator support and reproduction command** Accepting previously refused compressed-export and `vcc_hi` forms expands the public startup translator capability, but this commit updates neither the README nor `docs/experiments.md`. The root `AGENTS.md` requires a documentation update when a public capability changes. Add the new fixture's reproduction command and scope there, distinguishing the passing translation-only checks from unverified GPU behavior and recording the wave-mode limitation. AGENTS.md reference: [AGENTS.md:L210-L211](https://github.com/R0Y00/Xbox2Windows/blob/6766106b8b2edab8bd3d8458100fc5be1abe5d69/AGENTS.md#L210-L211) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 00:55 UTC · original

Already covered on the rebased branch: the export derives its channel mask from the non-off operands (0x3 for v0, v0, off, off compr) and the manifest wmask line carries it to the pipeline write mask, so B/A are not overwritten. The check now asserts the mask. Commit 01e9853f (rebased on current main, pending host push).

Commands: python3 -B tests/startup_gfx2hlsl_off_vcchi_check.py PASS.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-25 00:55 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2034#discussion_r4688720426) Already covered on the rebased branch: the export derives its channel mask from the non-`off` operands (0x3 for `v0, v0, off, off compr`) and the manifest `wmask` line carries it to the pipeline write mask, so B/A are not overwritten. The check now asserts the mask. Commit 01e9853f (rebased on current main, pending host push). Commands: `python3 -B tests/startup_gfx2hlsl_off_vcchi_check.py` PASS. AI-assisted; commands listed were executed locally.
Author
Owner

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

Fixed: vcc_hi now raises Unsupported unless the stage is explicitly marked wave32, which nothing sets yet, so real shaders keep the refusal. The check covers both the refusal and the wave32 case. Commit 01e9853f (pending host push).

Commands: python3 -B tests/startup_gfx2hlsl_off_vcchi_check.py PASS; tests/startup_smem_address_check.py and tests/startup_gfx2hlsl_sop2_complement_check.py PASS.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-25 00:56 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2034#discussion_r4688720624) Fixed: `vcc_hi` now raises Unsupported unless the stage is explicitly marked wave32, which nothing sets yet, so real shaders keep the refusal. The check covers both the refusal and the wave32 case. Commit 01e9853f (pending host push). Commands: `python3 -B tests/startup_gfx2hlsl_off_vcchi_check.py` PASS; `tests/startup_smem_address_check.py` and `tests/startup_gfx2hlsl_sop2_complement_check.py` PASS. AI-assisted; commands listed were executed locally.
Author
Owner

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

Fixed: new section in docs/experiments.md with the reproduction commands, the translation-only scope (GPU behaviour unverified) and the wave-mode limitation. Commit 01e9853f (pending host push).

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-25 00:56 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2034#discussion_r4688720805) Fixed: new section in docs/experiments.md with the reproduction commands, the translation-only scope (GPU behaviour unverified) and the wave-mode limitation. Commit 01e9853f (pending host push). AI-assisted; commands listed were executed locally.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 11:03 UTC · original

Closing: compressed-export off handling is already on main (tools/startup/gfx2hlsl.py), and vcc_hi currently has no live wave32 caller in the startup translator, so keeping this PR open adds no real startup coverage.

**@⁠tedin7** on GitHub · 2026-11-25 11:03 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2034#issuecomment-7160534412) Closing: compressed-export `off` handling is already on `main` (`tools/startup/gfx2hlsl.py`), and `vcc_hi` currently has no live wave32 caller in the startup translator, so keeping this PR open adds no real startup coverage.
Author
Owner

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6766106b8b

ℹ️ 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 23:39 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2034#pullrequestreview-6049188411) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `6766106b8b` <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>

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.