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

Manually merged
github merged 5 commits from gh-pr/2143/head into gh-pr/2143/base 2026-11-26 23:59:58 +00:00
Owner

@⁠tedin7 on GitHub · 2026-11-25 01:31 UTC · original
tedin7:x2w-2125a-dpp-quad-bcast → main · +444 −14 · 8 files · 5 commits · merged 2026-11-25 02:59 UTC

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.

**@⁠tedin7** on GitHub · 2026-11-25 01:31 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2143) `tedin7:x2w-2125a-dpp-quad-bcast` → `main` · +444 −14 · 8 files · 5 commits · merged 2026-11-25 02:59 UTC 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.
Lower quad_perm:[k,k,k,k] on v_mov_b32 and the VOP1/VOP2 float, integer and
integer-to-float tables to QuadReadLaneAt, compile such pixel stages as ps_6_0
with DXC, refuse every other DPP form, and add controls plus WARP and hardware
draws against a CPU reference.
D3D12 rejects a pipeline state pairing a DXBC vertex stage with a DXIL pixel stage; the draw test now uses the DXIL pair only.
The entry EXEC can leave out lanes of a partly covered quad, so a guest DPP
read could hit an inactive source lane while QuadReadLaneAt returns a helper
lane value. The broadcast now needs s_wqm exec, exec with EXEC unchanged.
Fixtures gain the s_wqm; new refusal controls cover its absence.
Document the capability in README.md and docs/experiments.md.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 23:59:56 +00:00
github manually merged commit fd3fbed9ad into gh-pr/2143/base 2026-11-26 23:59:58 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 01:37 UTC · original · edited 2026-11-25 01:47 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-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.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 01:37 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2143#issuecomment-7149754666) · edited 2026-11-25 01:47 UTC <!-- 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>
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 01:47 UTC · original

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 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 01:47 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2143#discussion_r4689118477) **<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 -->
@ -847,0 +877,4 @@
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)
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 01:47 UTC · original

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 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 01:47 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2143#discussion_r4689118481) **<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 -->
@ -1194,6 +1194,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
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 01:47 UTC · original

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 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 01:47 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2143#discussion_r4689118488) **<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 -->
Author
Owner

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

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** on GitHub · 2026-11-25 02:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2143#discussion_r4689367496) 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.
@ -847,0 +877,4 @@
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)
Author
Owner

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

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** on GitHub · 2026-11-25 02:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2143#discussion_r4689367951) 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.
@ -1194,6 +1194,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
Author
Owner

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

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.

**@⁠tedin7** on GitHub · 2026-11-25 02:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2143#discussion_r4689368493) 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.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-25 02:44 UTC · original

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.

**@⁠R0Y00** on GitHub · 2026-11-25 02:44 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2143#issuecomment-7151122132) 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.
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-25 01:47 UTC · original · reviewed

💡 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".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-25 01:47 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2143#pullrequestreview-6050366700) · **reviewed** <!-- 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>
This discussion has been locked. Commenting is limited to contributors.
No description provided.