[PR #1647] [MERGED] rdna2spirv: translate v_cmpx in DPP form (SHADER-VOPCX-DPP) #1660

Closed
opened 2026-11-26 20:22:01 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1647
Author: @OreoFR
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/26/2026
Merged by: @aslan2142

Base: main ← Head: shader-vopcx-dpp


📝 Commits (4)

  • c5f1807 rdna2spirv: translate v_cmpx in DPP form (SHADER-VOPCX-DPP)
  • d7f26f5 wave64_halves, rdna2spirv: a DPP v_cmpx is an EXEC write, and the restore pass recovers it (SHADER-VOPCX-DPP review)
  • c2771d4 rdna2spirv, docs: the DPP compare refusal cites the RDNA3 measurement of unwritten lanes (SHADER-VOPCX-DPP review)
  • 0df3712 tests: the v_cmpx DPP recovery test calls restore_vcc_tuples, main's name for the pass (SHADER-VOPCX-DPP)

📊 Changes

10 files changed (+218 additions, -51 deletions)

View changed files

📝 docs/design.md (+1 -1)
📝 runtime/test/shaders/check.py (+3 -1)
➕ runtime/test/shaders/cs_dpp_cmpx.asm (+24 -0)
📝 scripts/run_gpu_tests.py (+3 -2)
➕ tests/semantic/fixtures/disasm/cs_dpp_cmpx.s (+15 -0)
📝 tests/semantic/test_dpp_compare.py (+120 -32)
📝 tests/semantic/test_library_compute_forms.py (+10 -0)
📝 tests/semantic/test_wave64_halves.py (+20 -0)
📝 tools/rdna2spirv.py (+14 -13)
📝 tools/wave64_halves.py (+8 -2)

📄 Description

Claimed in the coordination issue as: SHADER-VOPCX-DPP (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155122672)

Depends on: #1375

#1375 makes tests/test_translate.py take the new cs_dpp_cmpx.asm as text, as it does cs_dpp_cmp.asm from #957: without it, both stop at llvm-mc's "dpp variant of this instruction is not supported".

What and why

Gen.dpp_insn refused every v_cmpx in DPP form (DPP on v_cmpx, tools/rdna2spirv.py). In the #1592 census of the pipeline library's graphics programs, that refusal accounts for 78 of the 344 programs that don't translate, all pixel shaders. Rain156 listed it as one of the remaining causes in #1608.

This extends #957's DPP VOPC compare to v_cmpx. The lane selection is the same, and the result goes to EXEC as for a plain v_cmpx: a lane that was off stays off. v_cmpx prints no destination, so its src0 is the first operand. The same forms as for v_cmp are taken, those where every lane writes its bit: row_mask and bank_mask 0xF, plus bound_ctrl:1 or DPP8. Any other form is still refused with DPP compare with lanes that keep their mask bit. The disassemblers already print the form (tools/shader_disasm.py with_vopc_dpp, tools/rdna2_decode.py), so the change is in the translator only.

All 113 instructions in those 78 programs have the same form: v_cmpx_gt_f32_dpp vN, -vM quad_perm:[2,3,0,1] row_mask:0xf bank_mask:0xf bound_ctrl:1 fi:1. That compares against the lane two above or below in the quad, with src1 negated.

  • tools/rdna2spirv.py: the src0 index follows the compare kind. Nothing else in dpp_insn changes.
  • docs/design.md: the "DPP on a VOPC compare" row covers v_cmpx, with the count and the GPU check.
  • tests/semantic/test_dpp_compare.py:
    • EXEC values from the SPIR-V interpreter for v_cmpx_gt_f32, v_cmpx_lt_u32 and v_cmpx_eq_u32 over the written forms and the game's form, with a lane off and with src1 negated;
    • the refused forms still refused;
    • both printers on the game's encoding (fa 02 28 7c 01 4e 4c ff).
    • The old "v_cmpx is refused" test is replaced.
  • runtime/test/shaders/cs_dpp_cmpx.asm, with its translator fixture: a GPU test of the game's form, with and without the negated src1.

Tested

  • Refused programs: the 344 programs the #1592 census refused (1.0.2.1, --wave64-emulate, listings from llvm-mc 23.1.6; with llvm-mc 21 far more programs stop earlier at undecodable words, and quartz-heron-58 measured 14 new programs there), translated again with this branch. Before: 0 translated. After: 78 translated, 78 pass spirv-val. The other 266 are refused as before: v_interp_p2_f16 242, s_getpc_b64 18 (#1632), no shader container 6. The 18,493 programs that already translated contain no v_cmpx in DPP form, since it was refused, so their output is unchanged.
  • python -I scripts/run_gpu_tests.py --filter cs_dpp: 10/11 pass with cs_dpp_cmpx = 1 1 0 0 3 3 2 2 (cs_dpp_w64 skipped: no 64-wide subgroup). With LEONIDA_W64_EMULATE=1, 11/11 pass.
  • tests/semantic/test_dpp_compare.py: 13 tests pass, including the llvm-mc listing test (LLVM 23).
  • Fixtures and full suite: regen_fixtures.py --check is clean. scripts/run_semantic_tests.py tests/semantic: 487 files, 6,283 tests, 0 failed.
  • Hardware: no RDNA2 hardware here. As for #957, the rule follows from the encoding and from the VOP2 DPP rules already measured, and is checked against the interpreter and on NVIDIA.

GPUs tested: NVIDIA GeForce RTX 4070 Laptop GPU, driver 591.59 (32.0.15.9159), Windows 11

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1647 **Author:** [@OreoFR](https://github.com/OreoFR) **Created:** 11/25/2026 **Status:** ✅ Merged **Merged:** 11/26/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `shader-vopcx-dpp` --- ### 📝 Commits (4) - [`c5f1807`](https://github.com/ubiquitarianism/leonida/commit/c5f1807515ec669ce428e150b40937be4a0a0fb7) rdna2spirv: translate v_cmpx in DPP form (SHADER-VOPCX-DPP) - [`d7f26f5`](https://github.com/ubiquitarianism/leonida/commit/d7f26f568c59519eb1bb45b1b0ee55d76c30e26b) wave64_halves, rdna2spirv: a DPP v_cmpx is an EXEC write, and the restore pass recovers it (SHADER-VOPCX-DPP review) - [`c2771d4`](https://github.com/ubiquitarianism/leonida/commit/c2771d43ba7ad074f6a3adc175f949cd90b5e18f) rdna2spirv, docs: the DPP compare refusal cites the RDNA3 measurement of unwritten lanes (SHADER-VOPCX-DPP review) - [`0df3712`](https://github.com/ubiquitarianism/leonida/commit/0df371254b9c7a5315ae39f6a8b935be7518d783) tests: the v_cmpx DPP recovery test calls restore_vcc_tuples, main's name for the pass (SHADER-VOPCX-DPP) ### 📊 Changes **10 files changed** (+218 additions, -51 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) 📝 `runtime/test/shaders/check.py` (+3 -1) ➕ `runtime/test/shaders/cs_dpp_cmpx.asm` (+24 -0) 📝 `scripts/run_gpu_tests.py` (+3 -2) ➕ `tests/semantic/fixtures/disasm/cs_dpp_cmpx.s` (+15 -0) 📝 `tests/semantic/test_dpp_compare.py` (+120 -32) 📝 `tests/semantic/test_library_compute_forms.py` (+10 -0) 📝 `tests/semantic/test_wave64_halves.py` (+20 -0) 📝 `tools/rdna2spirv.py` (+14 -13) 📝 `tools/wave64_halves.py` (+8 -2) </details> ### 📄 Description Claimed in the coordination issue as: SHADER-VOPCX-DPP (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7155122672) Depends on: #1375 #1375 makes `tests/test_translate.py` take the new `cs_dpp_cmpx.asm` as text, as it does `cs_dpp_cmp.asm` from #957: without it, both stop at llvm-mc's "dpp variant of this instruction is not supported". ### What and why `Gen.dpp_insn` refused every `v_cmpx` in DPP form (`DPP on v_cmpx`, `tools/rdna2spirv.py`). In the #1592 census of the pipeline library's graphics programs, that refusal accounts for 78 of the 344 programs that don't translate, all pixel shaders. Rain156 listed it as one of the remaining causes in #1608. This extends #957's DPP VOPC compare to `v_cmpx`. The lane selection is the same, and the result goes to EXEC as for a plain `v_cmpx`: a lane that was off stays off. `v_cmpx` prints no destination, so its src0 is the first operand. The same forms as for `v_cmp` are taken, those where every lane writes its bit: `row_mask` and `bank_mask` 0xF, plus `bound_ctrl:1` or DPP8. Any other form is still refused with `DPP compare with lanes that keep their mask bit`. The disassemblers already print the form (`tools/shader_disasm.py` `with_vopc_dpp`, `tools/rdna2_decode.py`), so the change is in the translator only. All 113 instructions in those 78 programs have the same form: `v_cmpx_gt_f32_dpp vN, -vM quad_perm:[2,3,0,1] row_mask:0xf bank_mask:0xf bound_ctrl:1 fi:1`. That compares against the lane two above or below in the quad, with src1 negated. - `tools/rdna2spirv.py`: the src0 index follows the compare kind. Nothing else in `dpp_insn` changes. - `docs/design.md`: the "DPP on a VOPC compare" row covers `v_cmpx`, with the count and the GPU check. - `tests/semantic/test_dpp_compare.py`: - EXEC values from the SPIR-V interpreter for `v_cmpx_gt_f32`, `v_cmpx_lt_u32` and `v_cmpx_eq_u32` over the written forms and the game's form, with a lane off and with src1 negated; - the refused forms still refused; - both printers on the game's encoding (`fa 02 28 7c 01 4e 4c ff`). - The old "v_cmpx is refused" test is replaced. - `runtime/test/shaders/cs_dpp_cmpx.asm`, with its translator fixture: a GPU test of the game's form, with and without the negated src1. ### Tested - **Refused programs:** the 344 programs the #1592 census refused (1.0.2.1, `--wave64-emulate`, listings from llvm-mc 23.1.6; with llvm-mc 21 far more programs stop earlier at undecodable words, and quartz-heron-58 measured 14 new programs there), translated again with this branch. Before: 0 translated. After: 78 translated, 78 pass spirv-val. The other 266 are refused as before: `v_interp_p2_f16` 242, `s_getpc_b64` 18 (#1632), no shader container 6. The 18,493 programs that already translated contain no `v_cmpx` in DPP form, since it was refused, so their output is unchanged. - **`python -I scripts/run_gpu_tests.py --filter cs_dpp`:** 10/11 pass with `cs_dpp_cmpx` = `1 1 0 0 3 3 2 2` (`cs_dpp_w64` skipped: no 64-wide subgroup). With `LEONIDA_W64_EMULATE=1`, 11/11 pass. - **`tests/semantic/test_dpp_compare.py`:** 13 tests pass, including the `llvm-mc` listing test (LLVM 23). - **Fixtures and full suite:** `regen_fixtures.py --check` is clean. `scripts/run_semantic_tests.py tests/semantic`: 487 files, 6,283 tests, 0 failed. - **Hardware:** no RDNA2 hardware here. As for #957, the rule follows from the encoding and from the VOP2 DPP rules already measured, and is checked against the interpreter and on NVIDIA. GPUs tested: NVIDIA GeForce RTX 4070 Laptop GPU, driver 591.59 (32.0.15.9159), Windows 11 AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:22:01 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#1660
No description provided.