shader: lower v_add_f32_dpp, v_or_b32_dpp, v_add_nc_u32_dpp and v_sub_f32_dpp in gfx2hlsl (Part of #1723) #2031

Closed
tedin7 wants to merge 5 commits from upstream-pr/2038 into main
tedin7 commented 2026-11-24 23:32:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T23:32:11Z.


Part of #1723

What this unblocks: Run 20 census #15, the _dpp spellings of v_add_f32, v_sub_f32, v_or_b32 and v_add_nc_u32, but only for the lane-local controls (see the open question).

The translator models one lane, so a DPP control that reads a neighbouring lane cannot be lowered correctly. The new dpp_form accepts quad_perm:[0,1,2,3] and the identity dpp8 with row_mask:0xf bank_mask:0xf, and translates them exactly like the plain operation (any source or output modifier travels along). quad_perm with another order, row_*, wave_*, a partial mask, bound_ctrl and fi are refused by name. Only ops in VEC_F/VEC_U are accepted.

Open question: if the census pairs mostly use cross-lane controls (for example quad_perm:[1,0,3,2] or row_shr), they stay refused. Lowering them needs lane or quad access, which fxc SM5 does not offer except through ddx_fine/ddy_fine in pixel shaders. I did not guess that.

Verification:

  • python3 -B tests/startup_gfx2hlsl_dpp_check.py -> PASS (on origin/main the same test fails with Unsupported: v_add_f32_dpp)
  • python3 -B tests/startup_gfx2hlsl_swap_check.py, ..._op_refusals_check.py, ..._refusals_check.py, ..._operand_count_check.py, ..._cndmask_neg_check.py -> exit 0
  • Not run: a Win2025 build; the change is Python only and registered as startup_gfx2hlsl_dpp in CMakeLists.txt.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6593563117 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2038). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T23:32:11Z. --- Part of #1723 What this unblocks: Run 20 census #15, the `_dpp` spellings of `v_add_f32`, `v_sub_f32`, `v_or_b32` and `v_add_nc_u32`, but only for the lane-local controls (see the open question). The translator models one lane, so a DPP control that reads a neighbouring lane cannot be lowered correctly. The new `dpp_form` accepts `quad_perm:[0,1,2,3]` and the identity `dpp8` with `row_mask:0xf bank_mask:0xf`, and translates them exactly like the plain operation (any source or output modifier travels along). `quad_perm` with another order, `row_*`, `wave_*`, a partial mask, `bound_ctrl` and `fi` are refused by name. Only ops in `VEC_F`/`VEC_U` are accepted. Open question: if the census pairs mostly use cross-lane controls (for example `quad_perm:[1,0,3,2]` or `row_shr`), they stay refused. Lowering them needs lane or quad access, which fxc SM5 does not offer except through `ddx_fine`/`ddy_fine` in pixel shaders. I did not guess that. Verification: - `python3 -B tests/startup_gfx2hlsl_dpp_check.py` -> PASS (on origin/main the same test fails with `Unsupported: v_add_f32_dpp`) - `python3 -B tests/startup_gfx2hlsl_swap_check.py`, `..._op_refusals_check.py`, `..._refusals_check.py`, `..._operand_count_check.py`, `..._cndmask_neg_check.py` -> exit 0 - Not run: a Win2025 build; the change is Python only and registered as `startup_gfx2hlsl_dpp` in CMakeLists.txt. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-25 00:05:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:36:17Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9bea878244

ℹ️ 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".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6049145606 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2038#pullrequestreview-6049145606). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:36:17Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `9bea878244` <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>
tedin7 commented 2026-11-25 01:01:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:55:49Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6049898775 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2038#pullrequestreview-6049898775). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T00:55:49Z. **Review:** COMMENTED --- _No description provided._
chatgpt-codex-connector[bot commented 2026-11-25 01:01:56 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:32:23Z.


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:36:19.532140Z 9bea878 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7147514455 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2038#issuecomment-7147514455). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:32:23Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"9bea8782445487f1b5744953b338476b4523a090","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:36:19.532140Z">2026-11-24T23:36:19.532140Z</relative-time> | `9bea878` | 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>
denn0x commented 2026-11-25 01:02:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-25T00:55:02Z.


I checked this against the DPP use in a private executable's pixel and vertex programs (decode only, aggregate counts):

  • 695 programs use DPP, with 19,902 DPP instructions in total.
  • None of them uses quad_perm:[0,1,2,3] or the identity dpp8.
  • Every control reads another lane:
control instructions
quad swaps [1,0,3,2], [2,3,0,1], [3,2,1,0] 8,971
quad broadcasts [0,0,0,0], [1,1,1,1], [2,2,2,2] 6,342
pair broadcasts [1,1,3,3], [0,0,2,2], [2,3,2,3], [0,1,0,1] 2,419
row_mirror / row_half_mirror 2,170
  • About 78% of them also carry bound_ctrl.
  • The ops are mostly v_add_f32, v_mov_b32, v_subrev_f32, v_mul_f32, v_or_b32 and v_min_u32 / v_max_u32.

The patch looks correct to me. Every non-identity control is refused by name, so nothing is lowered silently with the wrong lane. The test passes locally (pure Python).

One small note: with the identity control and full masks, the source lane is always in range, so bound_ctrl cannot change the result there. Refusing it is stricter than needed, but harmless.

On these programs, though, the identity form never occurs, so this PR removes no refusal there. The forms that matter are the quad broadcasts and quad swaps. They need a model of the 2x2 quad, for example derivative intrinsics or quad-read intrinsics, rather than one lane. They could be a follow-up item.

I agree with the review note that a short docs/experiments.md entry would help: the identity-only scope, the full-mask requirement, and the refusals.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7149021128 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2038#issuecomment-7149021128). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-25T00:55:02Z. --- I checked this against the DPP use in a private executable's pixel and vertex programs (decode only, aggregate counts): - 695 programs use DPP, with 19,902 DPP instructions in total. - **None** of them uses `quad_perm:[0,1,2,3]` or the identity `dpp8`. - Every control reads another lane: | control | instructions | |---|---| | quad swaps `[1,0,3,2]`, `[2,3,0,1]`, `[3,2,1,0]` | 8,971 | | quad broadcasts `[0,0,0,0]`, `[1,1,1,1]`, `[2,2,2,2]` | 6,342 | | pair broadcasts `[1,1,3,3]`, `[0,0,2,2]`, `[2,3,2,3]`, `[0,1,0,1]` | 2,419 | | `row_mirror` / `row_half_mirror` | 2,170 | - About 78% of them also carry `bound_ctrl`. - The ops are mostly `v_add_f32`, `v_mov_b32`, `v_subrev_f32`, `v_mul_f32`, `v_or_b32` and `v_min_u32` / `v_max_u32`. The patch looks correct to me. Every non-identity control is refused by name, so nothing is lowered silently with the wrong lane. The test passes locally (pure Python). One small note: with the identity control and full masks, the source lane is always in range, so `bound_ctrl` cannot change the result there. Refusing it is stricter than needed, but harmless. On these programs, though, the identity form never occurs, so this PR removes no refusal there. The forms that matter are the quad broadcasts and quad swaps. They need a model of the 2x2 quad, for example derivative intrinsics or quad-read intrinsics, rather than one lane. They could be a follow-up item. I agree with the review note that a short `docs/experiments.md` entry would help: the identity-only scope, the full-mask requirement, and the refusals.
chatgpt-codex-connector[bot commented 2026-11-25 01:02:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:36:17Z.

Code review location: tools/startup/gfx2hlsl.py; line 567

@@ -563,6 +563,8 @@ def one(self, name, asm):
                     ops[0] == 'exec_hi' or not (base in SCA or base.startswith('v_cmp') or
                                                 (base in ('s_cselect_b32', 's_cselect_b64') and ops[0] == 'exec'))):
                 raise Unsupported('%s into %s after a fetch call' % (base, ops[0]))
+        if base.endswith('_dpp'):
+            base, mods = self.dpp_form(base[:-len('_dpp')], mods)

P1 Badge Document the new startup-translator DPP capability

This adds publicly usable DPP lowering to the startup translator, but neither README.md nor docs/experiments.md is updated. The root AGENTS.md explicitly requires updating one of those documents when a public capability changes. Add an experiment entry recording the identity-only DPP16/DPP8 scope, full-mask requirement, remaining refusals, and reproduction command/result so contributors can discover and reproduce this narrowly supported behavior without relying on the commit message.

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

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688045839 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2038#discussion_r4688045839). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:36:17Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 567 ~~~~diff @@ -563,6 +563,8 @@ def one(self, name, asm): ops[0] == 'exec_hi' or not (base in SCA or base.startswith('v_cmp') or (base in ('s_cselect_b32', 's_cselect_b64') and ops[0] == 'exec'))): raise Unsupported('%s into %s after a fetch call' % (base, ops[0])) + if base.endswith('_dpp'): + base, mods = self.dpp_form(base[:-len('_dpp')], mods) ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Document the new startup-translator DPP capability** This adds publicly usable DPP lowering to the startup translator, but neither `README.md` nor `docs/experiments.md` is updated. The root `AGENTS.md` explicitly requires updating one of those documents when a public capability changes. Add an experiment entry recording the identity-only DPP16/DPP8 scope, full-mask requirement, remaining refusals, and reproduction command/result so contributors can discover and reproduce this narrowly supported behavior without relying on the commit message. AGENTS.md reference: [AGENTS.md:L210-L211](https://github.com/R0Y00/Xbox2Windows/blob/9bea8782445487f1b5744953b338476b4523a090/AGENTS.md#L210-L211) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-25 01:02:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:55:49Z.

Code review location: tools/startup/gfx2hlsl.py; line 567

@@ -563,6 +563,8 @@ def one(self, name, asm):
                     ops[0] == 'exec_hi' or not (base in SCA or base.startswith('v_cmp') or
                                                 (base in ('s_cselect_b32', 's_cselect_b64') and ops[0] == 'exec'))):
                 raise Unsupported('%s into %s after a fetch call' % (base, ops[0]))
+        if base.endswith('_dpp'):
+            base, mods = self.dpp_form(base[:-len('_dpp')], mods)

Added a Startup translator: lane-local DPP forms entry to docs/experiments.md in e5abc5f0 (on the rebased branch, pending push). It records the identity-only quad_perm/dpp8 scope, the 0xf row_mask/bank_mask requirement, the refused controls and the reproduction command python3 -B tests/startup_gfx2hlsl_dpp_check.py (PASS).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688719297 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2038#discussion_r4688719297). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T00:55:49Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 567 ~~~~diff @@ -563,6 +563,8 @@ def one(self, name, asm): ops[0] == 'exec_hi' or not (base in SCA or base.startswith('v_cmp') or (base in ('s_cselect_b32', 's_cselect_b64') and ops[0] == 'exec'))): raise Unsupported('%s into %s after a fetch call' % (base, ops[0])) + if base.endswith('_dpp'): + base, mods = self.dpp_form(base[:-len('_dpp')], mods) ~~~~ --- Added a `Startup translator: lane-local DPP forms` entry to `docs/experiments.md` in e5abc5f0 (on the rebased branch, pending push). It records the identity-only quad_perm/dpp8 scope, the 0xf row_mask/bank_mask requirement, the refused controls and the reproduction command `python3 -B tests/startup_gfx2hlsl_dpp_check.py` (PASS). AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 12:01:26 +00:00
tedin7 commented 2026-11-25 12:01:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T11:03:44Z.


Closing: main already lowers quad swaps and broadcasts for these DPP ops, leaving only the identity control (measured at 0 of 19,902 DPP instructions in real programs), so this PR removes no real refusal.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7160535409 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2038#issuecomment-7160535409). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T11:03:44Z. --- Closing: `main` already lowers quad swaps and broadcasts for these DPP ops, leaving only the identity control (measured at 0 of 19,902 DPP instructions in real programs), so this PR removes no real refusal.

Pull request closed

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!2031
No description provided.