shader: decode VOPC DPP16 and lower v_cmp quad swaps in the pixel path #3383

Open
tedin7 wants to merge 4 commits from upstream-pr/3383 into main
tedin7 commented 2026-11-28 17:24:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-28T17:24:10Z.


Part of #870

What this unblocks: pixel shaders that compare a value read through a quad swap (v_cmp_*_dpp with quad_perm) against the lane's own value, which the disassembler left undecoded and gfx2hlsl refused.

What changed:

  • tools/disasm_rdna2.py: decode VOPC DPP16 (32-bit float/integer compares) with its controls, masks, bound_ctrl, fi and neg/abs modifiers; invalid controls and 64-bit/class forms stay <unsupported DPP16>. tests/rdna2_tools_check.py covers the new decode.
  • tools/startup/gfx2hlsl.py: dpp_compare lowers v_cmp_*_dpp (VCC result, VGPR src0) with the existing whole-quad-EXEC proof: the swapped src0 goes to the hidden DPP temp register, the plain compare reads it, src1 stays the lane's own register.
  • tests/startup_gfx2hlsl_dpp_quad_swap_check.py: new cmp fixture (three swaps, v_cmp_lt_u32_dpp + v_cndmask_b32) drawn on WARP/hardware against a CPU reference, with mutants (wrong neighbour, no exchange, reversed compare) and dropped-swap rejections. The existing startup_gfx2hlsl_dpp_quad_swap_* tests carry it.

Verification:

  • Linux: python3 -B tests/rdna2_tools_check.py, python3 -B tests/startup_gfx2hlsl_dpp_quad_swap_check.py, and the other startup_gfx2hlsl_dpp_*_check.py scripts: pass.
  • Win2025 (aws-1) at 75473295a: x2w_pipe.py win2025 3383 --host aws-1 --keep-release --force --targets offscreen_check --regex '^(startup_gfx2hlsl_dpp_quad_swap|rdna2_tools_check)': dev 4/4 and release 4/4 passed (controls, warp, hardware, rdna2_tools_check).
  • Mutant (source change: dpp_compare reads src0 without the quad exchange), x2w_pipe.py win2025 3383 --host aws-1 --patch <mutant> --skip-release --regex '^startup_gfx2hlsl_dpp_quad_swap': _controls, _warp and _hardware all fail (0/3).

Draft until an independent peer review and the Win2025 WARP gate pass.

Thanks to @Makto94 for the testing that found this.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5542767508 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3383). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-28T17:24:10Z. --- Part of #870 What this unblocks: pixel shaders that compare a value read through a quad swap (`v_cmp_*_dpp` with quad_perm) against the lane's own value, which the disassembler left undecoded and gfx2hlsl refused. What changed: - `tools/disasm_rdna2.py`: decode VOPC DPP16 (32-bit float/integer compares) with its controls, masks, bound_ctrl, fi and neg/abs modifiers; invalid controls and 64-bit/class forms stay `<unsupported DPP16>`. `tests/rdna2_tools_check.py` covers the new decode. - `tools/startup/gfx2hlsl.py`: `dpp_compare` lowers `v_cmp_*_dpp` (VCC result, VGPR src0) with the existing whole-quad-EXEC proof: the swapped src0 goes to the hidden DPP temp register, the plain compare reads it, src1 stays the lane's own register. - `tests/startup_gfx2hlsl_dpp_quad_swap_check.py`: new `cmp` fixture (three swaps, `v_cmp_lt_u32_dpp` + `v_cndmask_b32`) drawn on WARP/hardware against a CPU reference, with mutants (wrong neighbour, no exchange, reversed compare) and dropped-swap rejections. The existing `startup_gfx2hlsl_dpp_quad_swap_*` tests carry it. Verification: - Linux: `python3 -B tests/rdna2_tools_check.py`, `python3 -B tests/startup_gfx2hlsl_dpp_quad_swap_check.py`, and the other `startup_gfx2hlsl_dpp_*_check.py` scripts: pass. - Win2025 (aws-1) at 75473295a: `x2w_pipe.py win2025 3383 --host aws-1 --keep-release --force --targets offscreen_check --regex '^(startup_gfx2hlsl_dpp_quad_swap|rdna2_tools_check)'`: dev 4/4 and release 4/4 passed (controls, warp, hardware, `rdna2_tools_check`). - Mutant (source change: `dpp_compare` reads src0 without the quad exchange), `x2w_pipe.py win2025 3383 --host aws-1 --patch <mutant> --skip-release --regex '^startup_gfx2hlsl_dpp_quad_swap'`: `_controls`, `_warp` and `_hardware` all fail (0/3). Draft until an independent peer review and the Win2025 WARP gate pass. Thanks to @Makto94 for the testing that found this. AI-assisted; commands listed were executed locally.
KelboLive commented 2026-11-28 20:34:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T20:34:52Z.

Review: APPROVED


LGTM — clean RDNA 2 decode and GFX10 lowering.

Adds _decode_vopc_dpp16 to disasm_rdna2.py for 8-byte VOPC DPP16 instructions (VCC/EXEC results). gfx2hlsl.py gains dpp_compare method for VOPC compare DPP16 with quad swaps: src0 goes through the hidden temp register, src1 stays the lane's own register, result lands in VCC. DPP_COMPARE regex filters matching opcodes. Test fixture covers X/Y/diagonal swaps with mutation coverage. Disassembler test adds DPP16 decode cases.

Ready to land.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6099979771 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3383#pullrequestreview-6099979771). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-28T20:34:52Z. **Review:** APPROVED --- LGTM — clean RDNA 2 decode and GFX10 lowering. Adds `_decode_vopc_dpp16` to disasm_rdna2.py for 8-byte VOPC DPP16 instructions (VCC/EXEC results). gfx2hlsl.py gains `dpp_compare` method for VOPC compare DPP16 with quad swaps: src0 goes through the hidden temp register, src1 stays the lane's own register, result lands in VCC. DPP_COMPARE regex filters matching opcodes. Test fixture covers X/Y/diagonal swaps with mutation coverage. Disassembler test adds DPP16 decode cases. Ready to land.
KelboLive commented 2026-11-28 21:57:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-28T21:57:09Z.

Review: APPROVED


LGTM — clean RDNA 2 decode and GFX10 lowering.

Adds _decode_vopc_dpp16 to disasm_rdna2.py for 8-byte VOPC DPP16 instructions (VCC/EXEC results). gfx2hlsl.py gains dpp_compare method for VOPC compare DPP16 with quad swaps: src0 goes through the hidden temp register, src1 stays the lane's own register, result lands in VCC. DPP_COMPARE regex filters matching opcodes. Test fixture covers X/Y/diagonal swaps with mutation coverage. Disassembler test adds DPP16 decode cases.

Ready to land.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6100253153 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3383#pullrequestreview-6100253153). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-28T21:57:09Z. **Review:** APPROVED --- LGTM — clean RDNA 2 decode and GFX10 lowering. Adds `_decode_vopc_dpp16` to disasm_rdna2.py for 8-byte VOPC DPP16 instructions (VCC/EXEC results). gfx2hlsl.py gains `dpp_compare` method for VOPC compare DPP16 with quad swaps: src0 goes through the hidden temp register, src1 stays the lane's own register, result lands in VCC. DPP_COMPARE regex filters matching opcodes. Test fixture covers X/Y/diagonal swaps with mutation coverage. Disassembler test adds DPP16 decode cases. Ready to land.
tedin7 commented 2026-11-28 21:58:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-28T21:58:18Z.


CI fix on the draft: Assemble and translate gfx1013 fixtures failed because LLVM's assembler has no DPP variant of VOPC ("dpp variant of this instruction is not supported"), so the cmp fixture could not be reassembled. Pushed 4cd15cc38 (origin/main merged, no force push): the cmp fixture now reassembles everything except its three v_cmp_lt_u32_dpp lines, and those words are checked through disasm_rdna2 (must decode to exactly the expected v_cmp_lt_u32_dpp ... quad_perm text). A mutant that shifts the control field in vopc_dpp fails the decoder cases.

Verification:

  • Linux: python3 tests/startup_gfx2hlsl_dpp_quad_swap_check.py binary <llvm-mc> -> PASS.
  • Windows Server 2025 (D3D12 WARP), head 4cd15cc38: x2w_pipe.py win2025 3383 --regex '^(startup_gfx2hlsl_dpp_quad_swap|rdna2_tools_check)' -> 4/4 passed.

Staying Draft: @KelboLive the test file changed after your approval of 75473295; could you re-check the head? Then I will mark it Ready.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7246404186 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3383#issuecomment-7246404186). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-28T21:58:18Z. --- CI fix on the draft: `Assemble and translate gfx1013 fixtures` failed because LLVM's assembler has no DPP variant of VOPC ("dpp variant of this instruction is not supported"), so the `cmp` fixture could not be reassembled. Pushed `4cd15cc38` (origin/main merged, no force push): the `cmp` fixture now reassembles everything except its three `v_cmp_lt_u32_dpp` lines, and those words are checked through `disasm_rdna2` (must decode to exactly the expected `v_cmp_lt_u32_dpp ... quad_perm` text). A mutant that shifts the control field in `vopc_dpp` fails the decoder cases. Verification: - Linux: `python3 tests/startup_gfx2hlsl_dpp_quad_swap_check.py binary <llvm-mc>` -> PASS. - Windows Server 2025 (D3D12 WARP), head `4cd15cc38`: `x2w_pipe.py win2025 3383 --regex '^(startup_gfx2hlsl_dpp_quad_swap|rdna2_tools_check)'` -> 4/4 passed. Staying Draft: @KelboLive the test file changed after your approval of `75473295`; could you re-check the head? Then I will mark it Ready. AI-assisted; commands listed were executed locally.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3383:upstream-pr/3383'
git switch 'upstream-pr/3383'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3383'
git switch 'upstream-pr/3383'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3383'
git switch 'upstream-pr/3383'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3383'
git switch 'main'
git merge --squash 'upstream-pr/3383'
git switch 'main'
git merge --ff-only 'upstream-pr/3383'
git switch 'main'
git merge 'upstream-pr/3383'
git push origin 'main'
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!3383
No description provided.