feat: lower DPP quad broadcasts in the pixel translator #2135

Merged
tedin7 merged 5 commits from upstream-pr/2143 into main 2026-11-25 02:59:22 +00:00
tedin7 commented 2026-11-25 01:31:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:31:07Z.


Part of #2125

What this unblocks: pixel stages that broadcast one lane of a quad with DPP quad_perm:[k,k,k,k] (the coarse-derivative idiom) now translate instead of stopping at the first _dpp instruction.

What changed

  • tools/startup/gfx2hlsl.py: v_mov_b32_dpp and the VOP1/VOP2 float, integer and integer-to-float _dpp forms lower to one QuadReadLaneAt(src, k) read followed by the existing handler. Only a pixel stage with straight-line code and a known entry mask is accepted (every lane of the quad is live), with full row_mask/bank_mask and bound_ctrl:1 or none.
  • Such a stage needs shader model 6.0: Pipeline.ps_profile() returns ps_6_0 and translate_to compiles it with DXC (X2W_DXC, Windows Kits bin, or PATH). Every other pixel stage stays ps_5_1 with FXC.
  • Still refused: swaps, pair broadcasts, row shifts, mirrors, DPP8, partial masks, fi, bound_ctrl:0, non-VGPR sources, vertex stages, branches, EXEC-narrowed code.
  • tests/startup_gfx2hlsl_dpp_quad_broadcast_check.py plus CMake entries startup_gfx2hlsl_dpp_quad_broadcast and startup_gfx2hlsl_dpp_quad_broadcast_{warp,hardware}; docs in docs/startup-runtime.md.
  • Twin tables checked: VEC_F, VEC_U, VEC_U_TO_F are reused unchanged; v_swap_b32_dpp stays refused (swap check still passes).

Verification

Run locally (Linux, no D3D12, no DXC, no llvm-mc):

  • python3 tests/startup_gfx2hlsl_dpp_quad_broadcast_check.py: all controls ok (fixture decode, QuadReadLaneAt per lane, ps_6_0 choice, mutation images differ, accepted forms, 20 refusals).
  • python3 tests/startup_gfx2hlsl_swap_check.py, ..._vopc_sdwa_check.py, ..._op_refusals_check.py, ..._bit_alu_check.py, ..._cvt_alu_check.py: all pass.

NOT yet run (Draft until done on Win2025):

  • python3 tests/startup_gfx2hlsl_dpp_quad_broadcast_check.py binary <llvm-mc>
  • ctest --preset dev --no-tests=error -R "^startup_gfx2hlsl_dpp_quad_broadcast" (WARP draw of 16 x 16 pixels against a CPU reference; wrong-lane and own-lane mutations must fail the draw; includes the mixed DXBC vertex plus DXIL pixel pair when FXC is set, and the FXC refusal control).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6595045677 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2143). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:31:07Z. --- Part of #2125 What this unblocks: pixel stages that broadcast one lane of a quad with DPP `quad_perm:[k,k,k,k]` (the coarse-derivative idiom) now translate instead of stopping at the first `_dpp` instruction. ## What changed - `tools/startup/gfx2hlsl.py`: `v_mov_b32_dpp` and the VOP1/VOP2 float, integer and integer-to-float `_dpp` forms lower to one `QuadReadLaneAt(src, k)` read followed by the existing handler. Only a pixel stage with straight-line code and a known entry mask is accepted (every lane of the quad is live), with full `row_mask`/`bank_mask` and `bound_ctrl:1` or none. - Such a stage needs shader model 6.0: `Pipeline.ps_profile()` returns `ps_6_0` and `translate_to` compiles it with DXC (`X2W_DXC`, Windows Kits `bin`, or `PATH`). Every other pixel stage stays `ps_5_1` with FXC. - Still refused: swaps, pair broadcasts, row shifts, mirrors, DPP8, partial masks, `fi`, `bound_ctrl:0`, non-VGPR sources, vertex stages, branches, EXEC-narrowed code. - `tests/startup_gfx2hlsl_dpp_quad_broadcast_check.py` plus CMake entries `startup_gfx2hlsl_dpp_quad_broadcast` and `startup_gfx2hlsl_dpp_quad_broadcast_{warp,hardware}`; docs in `docs/startup-runtime.md`. - Twin tables checked: `VEC_F`, `VEC_U`, `VEC_U_TO_F` are reused unchanged; `v_swap_b32_dpp` stays refused (swap check still passes). ## Verification Run locally (Linux, no D3D12, no DXC, no llvm-mc): - `python3 tests/startup_gfx2hlsl_dpp_quad_broadcast_check.py`: all controls ok (fixture decode, QuadReadLaneAt per lane, ps_6_0 choice, mutation images differ, accepted forms, 20 refusals). - `python3 tests/startup_gfx2hlsl_swap_check.py`, `..._vopc_sdwa_check.py`, `..._op_refusals_check.py`, `..._bit_alu_check.py`, `..._cvt_alu_check.py`: all pass. NOT yet run (Draft until done on Win2025): - `python3 tests/startup_gfx2hlsl_dpp_quad_broadcast_check.py binary <llvm-mc>` - `ctest --preset dev --no-tests=error -R "^startup_gfx2hlsl_dpp_quad_broadcast"` (WARP draw of 16 x 16 pixels against a CPU reference; wrong-lane and own-lane mutations must fail the draw; includes the mixed DXBC vertex plus DXIL pixel pair when FXC is set, and the FXC refusal control). AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-25 02:01:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T01:47:30Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 68c282f65f

ℹ️ 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:6050366700 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2143#pullrequestreview-6050366700). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T01:47:30Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `68c282f65f` <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>
chatgpt-codex-connector[bot commented 2026-11-25 02:02:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T01:37:00Z.


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-25T01:47:33.199216Z 68c282f 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:7149754666 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2143#issuecomment-7149754666). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T01:37:00Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"68c282f65f3cebdd3a127349f7b4031795407329","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-25T01:47:33.199216Z">2026-11-25T01:47:33.199216Z</relative-time> | `68c282f` | 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>
chatgpt-codex-connector[bot commented 2026-11-25 02:02:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T01:47:30Z.

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

@@ -2379,10 +2464,22 @@ def translate_to(out_dir, key, vs_code, ps_code, root_blob, check=True, rtv_form
         import subprocess
         # An existing manifest can already point at these paths. Publish only bytecode from a successful pair.
         with tempfile.TemporaryDirectory(prefix='.fxc-', dir=out_dir) as staging:
-            for stage, profile in (('vs', 'vs_5_1'), ('ps', 'ps_5_1')):
+            ps_profile = pipe.ps_profile()

P1 Badge Update the translator stub for the new profile method

The existing fxc_environment() in tests/startup_translator_check.py substitutes StubPipeline, which does not define ps_profile(). This call therefore raises AttributeError before the stub compiler runs, and python3 -B tests/startup_translator_check.py now exits 1 with two failures in the pending/retry checks; the same test passes against the parent commit. Update that test double alongside the new interface, otherwise the registered startup_translator CTest and the Linux Python-checks job fail.

AGENTS.md reference: AGENTS.md:L159-L159

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4689118477 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2143#discussion_r4689118477). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T01:47:30Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 2467 ~~~~diff @@ -2379,10 +2464,22 @@ def translate_to(out_dir, key, vs_code, ps_code, root_blob, check=True, rtv_form import subprocess # An existing manifest can already point at these paths. Publish only bytecode from a successful pair. with tempfile.TemporaryDirectory(prefix='.fxc-', dir=out_dir) as staging: - for stage, profile in (('vs', 'vs_5_1'), ('ps', 'ps_5_1')): + ps_profile = pipe.ps_profile() ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Update the translator stub for the new profile method** The existing `fxc_environment()` in `tests/startup_translator_check.py` substitutes `StubPipeline`, which does not define `ps_profile()`. This call therefore raises `AttributeError` before the stub compiler runs, and `python3 -B tests/startup_translator_check.py` now exits 1 with two failures in the pending/retry checks; the same test passes against the parent commit. Update that test double alongside the new interface, otherwise the registered `startup_translator` CTest and the Linux Python-checks job fail. AGENTS.md reference: [AGENTS.md:L159-L159](https://github.com/R0Y00/Xbox2Windows/blob/68c282f65f3cebdd3a127349f7b4031795407329/AGENTS.md#L159-L159) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-25 02:02:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T01:47:30Z.

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

@@ -744,6 +747,63 @@ def lower(self, base, asm, ops, mods):
             raise Unsupported('%s requires descriptor FORMAT and DST_SEL' % base)
         raise Unsupported(base)
 
+    # VOP1/VOP2 with DPP16 quad broadcast (#2125 item A): quad_perm:[k,k,k,k] makes every lane read SRC0 from
+    # lane k of its own quad (RDNA 2 ISA, "DPP": a lane reads lane (lane & ~3) | perm[lane & 3] of the row; LLVM 15
+    # AMDGPU DPP quad_perm). A pixel stage's four consecutive lanes are a 2x2 pixel quad (lane = x & 1 | (y & 1) << 1),
+    # which is what SM 6.0 QuadReadLaneAt(value, k) reads, so the stage is compiled as ps_6_0 (Stage.quad_ops).
+    # Accepted only where the whole quad is active: a straight-line pixel stage whose EXEC is still the entry mask,
+    # which covers helper lanes. bound_ctrl then has nothing to decide (the source lane is never disabled), so it is
+    # accepted and ignored. Everything else a DPP word can say stays refused: other controls (swaps, pair
+    # broadcasts, row shifts, mirrors, DPP8), a masked row or bank, fi, and a vertex stage.
+    DPP_TEMP = 256   # hidden VGPR that holds the quad read; the hardware has v0..v255 only
+    DPP_OUTPUT_MODS = ('clamp', 'mul:2', 'mul:4', 'div:2')
+
+    def dpp(self, base, ops, mods):
+        fields, rest = {}, []
+        for m in mods:
+            key, _, value = m.partition(':')
+            if key in ('quad_perm', 'row_mask', 'bank_mask', 'bound_ctrl') and value and key not in fields:
+                fields[key] = value
+            elif m in self.DPP_OUTPUT_MODS:
+                rest.append(m)
+            else:
+                raise Unsupported('%s_dpp with modifier %s' % (base, m))
+        lanes = re.fullmatch(r'\[([0-3]),([0-3]),([0-3]),([0-3])\]', fields.get('quad_perm', ''))
+        if not lanes or len(set(lanes.groups())) != 1:
+            raise Unsupported('%s_dpp %s: only quad_perm:[k,k,k,k] broadcasts are lowered'
+                              % (base, fields.get('quad_perm', 'without quad_perm')))
+        if fields.get('row_mask') != '0xf' or fields.get('bank_mask') != '0xf':
+            raise Unsupported('%s_dpp with a partial row_mask or bank_mask' % base)
+        if fields.get('bound_ctrl', '1') != '1':
+            raise Unsupported('%s_dpp bound_ctrl:%s' % (base, fields['bound_ctrl']))
+        if (self.kind != 'ps' or getattr(self, 'has_branches', True) or getattr(self, 'blocks', [])
+                or not getattr(self, 'exec_known', False)):
+            raise Unsupported('%s_dpp outside a straight-line pixel stage with the entry EXEC mask' % base)

P2 Badge Verify quad-wide activity instead of only unchanged EXEC

For a triangle covering only part of a 2×2 quad, the guest's entry EXEC can exclude the selected source lane even in straight-line code: exec_known means unchanged since entry, not whole-quad execution. This guard nevertheless accepts shaders that reach DPP without s_wqm_*, and the emitted QuadReadLaneAt reads a D3D helper's computed value instead of preserving the guest DPP inactive-source behavior with fi unset. Covered edge pixels can consequently differ, while the fullscreen fixtures explicitly cover whole quads and cannot detect this case. Track proven whole-quad activity and source definition, or explicitly model inactive-source behavior.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4689118481 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2143#discussion_r4689118481). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T01:47:30Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 781 ~~~~diff @@ -744,6 +747,63 @@ def lower(self, base, asm, ops, mods): raise Unsupported('%s requires descriptor FORMAT and DST_SEL' % base) raise Unsupported(base) + # VOP1/VOP2 with DPP16 quad broadcast (#2125 item A): quad_perm:[k,k,k,k] makes every lane read SRC0 from + # lane k of its own quad (RDNA 2 ISA, "DPP": a lane reads lane (lane & ~3) | perm[lane & 3] of the row; LLVM 15 + # AMDGPU DPP quad_perm). A pixel stage's four consecutive lanes are a 2x2 pixel quad (lane = x & 1 | (y & 1) << 1), + # which is what SM 6.0 QuadReadLaneAt(value, k) reads, so the stage is compiled as ps_6_0 (Stage.quad_ops). + # Accepted only where the whole quad is active: a straight-line pixel stage whose EXEC is still the entry mask, + # which covers helper lanes. bound_ctrl then has nothing to decide (the source lane is never disabled), so it is + # accepted and ignored. Everything else a DPP word can say stays refused: other controls (swaps, pair + # broadcasts, row shifts, mirrors, DPP8), a masked row or bank, fi, and a vertex stage. + DPP_TEMP = 256 # hidden VGPR that holds the quad read; the hardware has v0..v255 only + DPP_OUTPUT_MODS = ('clamp', 'mul:2', 'mul:4', 'div:2') + + def dpp(self, base, ops, mods): + fields, rest = {}, [] + for m in mods: + key, _, value = m.partition(':') + if key in ('quad_perm', 'row_mask', 'bank_mask', 'bound_ctrl') and value and key not in fields: + fields[key] = value + elif m in self.DPP_OUTPUT_MODS: + rest.append(m) + else: + raise Unsupported('%s_dpp with modifier %s' % (base, m)) + lanes = re.fullmatch(r'\[([0-3]),([0-3]),([0-3]),([0-3])\]', fields.get('quad_perm', '')) + if not lanes or len(set(lanes.groups())) != 1: + raise Unsupported('%s_dpp %s: only quad_perm:[k,k,k,k] broadcasts are lowered' + % (base, fields.get('quad_perm', 'without quad_perm'))) + if fields.get('row_mask') != '0xf' or fields.get('bank_mask') != '0xf': + raise Unsupported('%s_dpp with a partial row_mask or bank_mask' % base) + if fields.get('bound_ctrl', '1') != '1': + raise Unsupported('%s_dpp bound_ctrl:%s' % (base, fields['bound_ctrl'])) + if (self.kind != 'ps' or getattr(self, 'has_branches', True) or getattr(self, 'blocks', []) + or not getattr(self, 'exec_known', False)): + raise Unsupported('%s_dpp outside a straight-line pixel stage with the entry EXEC mask' % base) ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Verify quad-wide activity instead of only unchanged EXEC** For a triangle covering only part of a 2×2 quad, the guest's entry EXEC can exclude the selected source lane even in straight-line code: `exec_known` means unchanged since entry, not whole-quad execution. This guard nevertheless accepts shaders that reach DPP without `s_wqm_*`, and the emitted `QuadReadLaneAt` reads a D3D helper's computed value instead of preserving the guest DPP inactive-source behavior with `fi` unset. Covered edge pixels can consequently differ, while the fullscreen fixtures explicitly cover whole quads and cannot detect this case. Track proven whole-quad activity and source definition, or explicitly model inactive-source behavior. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-25 02:02:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T01:47:30Z.

Code review location: docs/startup-runtime.md; line 1085

@@ -1082,6 +1082,19 @@ These are measured on one executable; treat them as hypotheses for others.
   integer form against an integer reference, and the draws on WARP and hardware check 16 x 16 pixels
   that a `v_cmpx_le_i32_sdwa` on a sign-extended byte keeps or discards, with translations that drop
   the select or `sext()` as failing controls. [#1906](https://github.com/R0Y00/Xbox2Windows/issues/1906)
+- **DPP quad broadcasts.** `quad_perm:[k,k,k,k]` for k = 0, 1, 2 or 3, with full `row_mask` and

P1 Badge Add the capability to the required experiment documentation

This introduces supported DPP operations, a new compiler-selection path and a reproduction command, but updates only the runtime notes. The capability/reproduction update required by AGENTS.md is still absent from both README.md and docs/experiments.md. Add the bounded support to the relevant README entry and put the reproduction details in docs/experiments.md so the central experiment documentation reflects the new capability.

AGENTS.md reference: AGENTS.md:L230-L231

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4689118488 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2143#discussion_r4689118488). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-25T01:47:30Z. **Code review location:** `docs/startup-runtime.md`; line 1085 ~~~~diff @@ -1082,6 +1082,19 @@ These are measured on one executable; treat them as hypotheses for others. integer form against an integer reference, and the draws on WARP and hardware check 16 x 16 pixels that a `v_cmpx_le_i32_sdwa` on a sign-extended byte keeps or discards, with translations that drop the select or `sext()` as failing controls. [#1906](https://github.com/R0Y00/Xbox2Windows/issues/1906) +- **DPP quad broadcasts.** `quad_perm:[k,k,k,k]` for k = 0, 1, 2 or 3, with full `row_mask` and ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Add the capability to the required experiment documentation** This introduces supported DPP operations, a new compiler-selection path and a reproduction command, but updates only the runtime notes. The capability/reproduction update required by `AGENTS.md` is still absent from both `README.md` and `docs/experiments.md`. Add the bounded support to the relevant README entry and put the reproduction details in `docs/experiments.md` so the central experiment documentation reflects the new capability. AGENTS.md reference: [AGENTS.md:L230-L231](https://github.com/R0Y00/Xbox2Windows/blob/68c282f65f3cebdd3a127349f7b4031795407329/AGENTS.md#L230-L231) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
upstream-sync closed this pull request 2026-11-25 03:01:04 +00:00
tedin7 commented 2026-11-25 03:01:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:13:42Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6050653368 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2143#pullrequestreview-6050653368). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:13:42Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-25 03:01:04 +00:00 (Migrated from github.com)

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

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6050653860 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2143#pullrequestreview-6050653860). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:13:44Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-25 03:01:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:13:47Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6050654444 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2143#pullrequestreview-6050654444). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:13:47Z. **Review:** COMMENTED --- _No description provided._
R0Y00 commented 2026-11-25 03:01:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T02:44:23Z.


I resolved the overlap with #2141. Broadcast and swap retain their respective operand handlers, use the same whole-quad EXEC proof and DXC compilation path, and each now checks that the other form is still accepted. Both draw suites passed on WARP and RTX 4060 Laptop with their wrong-lane controls. LLVM 15 assembled all four fixtures to their recorded words. Pair permutations remain a separate slice under #2140.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7151122132 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2143#issuecomment-7151122132). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T02:44:23Z. --- I resolved the overlap with #2141. Broadcast and swap retain their respective operand handlers, use the same whole-quad EXEC proof and DXC compilation path, and each now checks that the other form is still accepted. Both draw suites passed on WARP and RTX 4060 Laptop with their wrong-lane controls. LLVM 15 assembled all four fixtures to their recorded words. Pair permutations remain a separate slice under #2140.
tedin7 commented 2026-11-25 03:01:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:13:42Z.

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

@@ -2379,10 +2464,22 @@ def translate_to(out_dir, key, vs_code, ps_code, root_blob, check=True, rtv_form
         import subprocess
         # An existing manifest can already point at these paths. Publish only bytecode from a successful pair.
         with tempfile.TemporaryDirectory(prefix='.fxc-', dir=out_dir) as staging:
-            for stage, profile in (('vs', 'vs_5_1'), ('ps', 'ps_5_1')):
+            ps_profile = pipe.ps_profile()

Fixed in aafa4a63: the translator test stub pipeline now defines ps_profile(). Verification on Windows Server 2025 (Build 26100, MSVC 14.44, D3D12 WARP) at 08e0143a: debug and release ctest -R ^startup_gfx2hlsl_dpp_quad_broadcast 3/3 passed each; tests/startup_translator_check.py and tests/docs_links_check.py ok. Linux: python3 -B tests/startup_gfx2hlsl_dpp_quad_broadcast_check.py, startup_translator_check.py, startup_buffer_address_check.py, docs_links_check.py pass.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4689367496 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2143#discussion_r4689367496). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:13:42Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 2467 ~~~~diff @@ -2379,10 +2464,22 @@ def translate_to(out_dir, key, vs_code, ps_code, root_blob, check=True, rtv_form import subprocess # An existing manifest can already point at these paths. Publish only bytecode from a successful pair. with tempfile.TemporaryDirectory(prefix='.fxc-', dir=out_dir) as staging: - for stage, profile in (('vs', 'vs_5_1'), ('ps', 'ps_5_1')): + ps_profile = pipe.ps_profile() ~~~~ --- Fixed in aafa4a63: the translator test stub pipeline now defines `ps_profile()`. Verification on Windows Server 2025 (Build 26100, MSVC 14.44, D3D12 WARP) at 08e0143a: debug and release `ctest -R ^startup_gfx2hlsl_dpp_quad_broadcast` 3/3 passed each; `tests/startup_translator_check.py` and `tests/docs_links_check.py` ok. Linux: `python3 -B tests/startup_gfx2hlsl_dpp_quad_broadcast_check.py`, `startup_translator_check.py`, `startup_buffer_address_check.py`, `docs_links_check.py` pass. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 03:01:26 +00:00 (Migrated from github.com)

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

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

@@ -744,6 +747,63 @@ def lower(self, base, asm, ops, mods):
             raise Unsupported('%s requires descriptor FORMAT and DST_SEL' % base)
         raise Unsupported(base)
 
+    # VOP1/VOP2 with DPP16 quad broadcast (#2125 item A): quad_perm:[k,k,k,k] makes every lane read SRC0 from
+    # lane k of its own quad (RDNA 2 ISA, "DPP": a lane reads lane (lane & ~3) | perm[lane & 3] of the row; LLVM 15
+    # AMDGPU DPP quad_perm). A pixel stage's four consecutive lanes are a 2x2 pixel quad (lane = x & 1 | (y & 1) << 1),
+    # which is what SM 6.0 QuadReadLaneAt(value, k) reads, so the stage is compiled as ps_6_0 (Stage.quad_ops).
+    # Accepted only where the whole quad is active: a straight-line pixel stage whose EXEC is still the entry mask,
+    # which covers helper lanes. bound_ctrl then has nothing to decide (the source lane is never disabled), so it is
+    # accepted and ignored. Everything else a DPP word can say stays refused: other controls (swaps, pair
+    # broadcasts, row shifts, mirrors, DPP8), a masked row or bank, fi, and a vertex stage.
+    DPP_TEMP = 256   # hidden VGPR that holds the quad read; the hardware has v0..v255 only
+    DPP_OUTPUT_MODS = ('clamp', 'mul:2', 'mul:4', 'div:2')
+
+    def dpp(self, base, ops, mods):
+        fields, rest = {}, []
+        for m in mods:
+            key, _, value = m.partition(':')
+            if key in ('quad_perm', 'row_mask', 'bank_mask', 'bound_ctrl') and value and key not in fields:
+                fields[key] = value
+            elif m in self.DPP_OUTPUT_MODS:
+                rest.append(m)
+            else:
+                raise Unsupported('%s_dpp with modifier %s' % (base, m))
+        lanes = re.fullmatch(r'\[([0-3]),([0-3]),([0-3]),([0-3])\]', fields.get('quad_perm', ''))
+        if not lanes or len(set(lanes.groups())) != 1:
+            raise Unsupported('%s_dpp %s: only quad_perm:[k,k,k,k] broadcasts are lowered'
+                              % (base, fields.get('quad_perm', 'without quad_perm')))
+        if fields.get('row_mask') != '0xf' or fields.get('bank_mask') != '0xf':
+            raise Unsupported('%s_dpp with a partial row_mask or bank_mask' % base)
+        if fields.get('bound_ctrl', '1') != '1':
+            raise Unsupported('%s_dpp bound_ctrl:%s' % (base, fields['bound_ctrl']))
+        if (self.kind != 'ps' or getattr(self, 'has_branches', True) or getattr(self, 'blocks', [])
+                or not getattr(self, 'exec_known', False)):
+            raise Unsupported('%s_dpp outside a straight-line pixel stage with the entry EXEC mask' % base)

Fixed in 08e0143a: a DPP quad broadcast is now lowered only after s_wqm exec, exec with EXEC unchanged since (whole-quad activity proven); otherwise it is refused. Fixtures carry the s_wqm; new controls cover a missing s_wqm and an s_wqm into another register. Verification on Windows Server 2025 (Build 26100, MSVC 14.44, D3D12 WARP) at 08e0143a: debug and release ctest -R ^startup_gfx2hlsl_dpp_quad_broadcast 3/3 passed each; tests/startup_translator_check.py and tests/docs_links_check.py ok. Linux: python3 -B tests/startup_gfx2hlsl_dpp_quad_broadcast_check.py, startup_translator_check.py, startup_buffer_address_check.py, docs_links_check.py pass.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4689367951 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2143#discussion_r4689367951). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:13:44Z. **Code review location:** `tools/startup/gfx2hlsl.py`; line 781 ~~~~diff @@ -744,6 +747,63 @@ def lower(self, base, asm, ops, mods): raise Unsupported('%s requires descriptor FORMAT and DST_SEL' % base) raise Unsupported(base) + # VOP1/VOP2 with DPP16 quad broadcast (#2125 item A): quad_perm:[k,k,k,k] makes every lane read SRC0 from + # lane k of its own quad (RDNA 2 ISA, "DPP": a lane reads lane (lane & ~3) | perm[lane & 3] of the row; LLVM 15 + # AMDGPU DPP quad_perm). A pixel stage's four consecutive lanes are a 2x2 pixel quad (lane = x & 1 | (y & 1) << 1), + # which is what SM 6.0 QuadReadLaneAt(value, k) reads, so the stage is compiled as ps_6_0 (Stage.quad_ops). + # Accepted only where the whole quad is active: a straight-line pixel stage whose EXEC is still the entry mask, + # which covers helper lanes. bound_ctrl then has nothing to decide (the source lane is never disabled), so it is + # accepted and ignored. Everything else a DPP word can say stays refused: other controls (swaps, pair + # broadcasts, row shifts, mirrors, DPP8), a masked row or bank, fi, and a vertex stage. + DPP_TEMP = 256 # hidden VGPR that holds the quad read; the hardware has v0..v255 only + DPP_OUTPUT_MODS = ('clamp', 'mul:2', 'mul:4', 'div:2') + + def dpp(self, base, ops, mods): + fields, rest = {}, [] + for m in mods: + key, _, value = m.partition(':') + if key in ('quad_perm', 'row_mask', 'bank_mask', 'bound_ctrl') and value and key not in fields: + fields[key] = value + elif m in self.DPP_OUTPUT_MODS: + rest.append(m) + else: + raise Unsupported('%s_dpp with modifier %s' % (base, m)) + lanes = re.fullmatch(r'\[([0-3]),([0-3]),([0-3]),([0-3])\]', fields.get('quad_perm', '')) + if not lanes or len(set(lanes.groups())) != 1: + raise Unsupported('%s_dpp %s: only quad_perm:[k,k,k,k] broadcasts are lowered' + % (base, fields.get('quad_perm', 'without quad_perm'))) + if fields.get('row_mask') != '0xf' or fields.get('bank_mask') != '0xf': + raise Unsupported('%s_dpp with a partial row_mask or bank_mask' % base) + if fields.get('bound_ctrl', '1') != '1': + raise Unsupported('%s_dpp bound_ctrl:%s' % (base, fields['bound_ctrl'])) + if (self.kind != 'ps' or getattr(self, 'has_branches', True) or getattr(self, 'blocks', []) + or not getattr(self, 'exec_known', False)): + raise Unsupported('%s_dpp outside a straight-line pixel stage with the entry EXEC mask' % base) ~~~~ --- Fixed in 08e0143a: a DPP quad broadcast is now lowered only after `s_wqm exec, exec` with EXEC unchanged since (whole-quad activity proven); otherwise it is refused. Fixtures carry the `s_wqm`; new controls cover a missing `s_wqm` and an `s_wqm` into another register. Verification on Windows Server 2025 (Build 26100, MSVC 14.44, D3D12 WARP) at 08e0143a: debug and release `ctest -R ^startup_gfx2hlsl_dpp_quad_broadcast` 3/3 passed each; `tests/startup_translator_check.py` and `tests/docs_links_check.py` ok. Linux: `python3 -B tests/startup_gfx2hlsl_dpp_quad_broadcast_check.py`, `startup_translator_check.py`, `startup_buffer_address_check.py`, `docs_links_check.py` pass. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 03:01:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:13:47Z.

Code review location: docs/startup-runtime.md; line 1085

@@ -1082,6 +1082,19 @@ These are measured on one executable; treat them as hypotheses for others.
   integer form against an integer reference, and the draws on WARP and hardware check 16 x 16 pixels
   that a `v_cmpx_le_i32_sdwa` on a sign-extended byte keeps or discards, with translations that drop
   the select or `sext()` as failing controls. [#1906](https://github.com/R0Y00/Xbox2Windows/issues/1906)
+- **DPP quad broadcasts.** `quad_perm:[k,k,k,k]` for k = 0, 1, 2 or 3, with full `row_mask` and

Fixed in 08e0143a: README row for the capability and a reproduction section in docs/experiments.md; docs/startup-runtime.md updated. Verification on Windows Server 2025 (Build 26100, MSVC 14.44, D3D12 WARP) at 08e0143a: debug and release ctest -R ^startup_gfx2hlsl_dpp_quad_broadcast 3/3 passed each; tests/startup_translator_check.py and tests/docs_links_check.py ok. Linux: python3 -B tests/startup_gfx2hlsl_dpp_quad_broadcast_check.py, startup_translator_check.py, startup_buffer_address_check.py, docs_links_check.py pass.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4689368493 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2143#discussion_r4689368493). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T02:13:47Z. **Code review location:** `docs/startup-runtime.md`; line 1085 ~~~~diff @@ -1082,6 +1082,19 @@ These are measured on one executable; treat them as hypotheses for others. integer form against an integer reference, and the draws on WARP and hardware check 16 x 16 pixels that a `v_cmpx_le_i32_sdwa` on a sign-extended byte keeps or discards, with translations that drop the select or `sext()` as failing controls. [#1906](https://github.com/R0Y00/Xbox2Windows/issues/1906) +- **DPP quad broadcasts.** `quad_perm:[k,k,k,k]` for k = 0, 1, 2 or 3, with full `row_mask` and ~~~~ --- Fixed in 08e0143a: README row for the capability and a reproduction section in `docs/experiments.md`; `docs/startup-runtime.md` updated. Verification on Windows Server 2025 (Build 26100, MSVC 14.44, D3D12 WARP) at 08e0143a: debug and release `ctest -R ^startup_gfx2hlsl_dpp_quad_broadcast` 3/3 passed each; `tests/startup_translator_check.py` and `tests/docs_links_check.py` ok. Linux: `python3 -B tests/startup_gfx2hlsl_dpp_quad_broadcast_check.py`, `startup_translator_check.py`, `startup_buffer_address_check.py`, `docs_links_check.py` pass. AI-assisted; commands listed were executed locally.
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!2135
No description provided.