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

Open
github-bot wants to merge 4 commits from github-bot/gh-3383 into main AGit
Owner

@⁠tedin7 on GitHub · 2026-11-28 17:24 UTC · original
tedin7:upprs-interp → main · +101 −4 · 4 files · 4 commits · draft

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.

**@⁠tedin7** on GitHub · 2026-11-28 17:24 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3383) `tedin7:upprs-interp` → `main` · +101 −4 · 4 files · 4 commits · draft 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 17:26:22 +00:00
Author
Owner

@⁠KelboLive on GitHub · 2026-11-28 20:34 UTC · original · approved these changes

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** on GitHub · 2026-11-28 20:34 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3383#pullrequestreview-6099979771) · **approved these changes** 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.
Author
Owner

@⁠KelboLive on GitHub · 2026-11-28 21:57 UTC · original · approved these changes

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** on GitHub · 2026-11-28 21:57 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3383#pullrequestreview-6100253153) · **approved these changes** 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.
Author
Owner

@⁠tedin7 on GitHub · 2026-11-28 21:58 UTC · original

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.

**@⁠tedin7** on GitHub · 2026-11-28 21:58 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3383#issuecomment-7246404186) 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 can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3385/head:github-bot/gh-3383'
git switch 'github-bot/gh-3383'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3383'
git switch 'github-bot/gh-3383'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3383'
git switch 'github-bot/gh-3383'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3383'
git switch 'main'
git merge --squash 'github-bot/gh-3383'
git switch 'main'
git merge --ff-only 'github-bot/gh-3383'
git switch 'main'
git merge 'github-bot/gh-3383'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.