rdna2spirv: translate v_cmpx in DPP form (SHADER-VOPCX-DPP) #1647
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!1647
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1647"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@OreoFR on GitHub · 2026-11-25 06:59 UTC · original
OreoFR:shader-vopcx-dpp→main· +218 −51 · 10 files · 4 commits · merged 2026-11-26 18:54 UTCClaimed in the coordination issue as: SHADER-VOPCX-DPP (#1608)
Depends on: #1375
#1375 makes
tests/test_translate.pytake the newcs_dpp_cmpx.asmas text, as it doescs_dpp_cmp.asmfrom #957: without it, both stop at llvm-mc's "dpp variant of this instruction is not supported".What and why
Gen.dpp_insnrefused everyv_cmpxin 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 plainv_cmpx: a lane that was off stays off.v_cmpxprints no destination, so its src0 is the first operand. The same forms as forv_cmpare taken, those where every lane writes its bit:row_maskandbank_mask0xF, plusbound_ctrl:1or DPP8. Any other form is still refused withDPP compare with lanes that keep their mask bit. The disassemblers already print the form (tools/shader_disasm.pywith_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 indpp_insnchanges.docs/design.md: the "DPP on a VOPC compare" row coversv_cmpx, with the count and the GPU check.tests/semantic/test_dpp_compare.py:v_cmpx_gt_f32,v_cmpx_lt_u32andv_cmpx_eq_u32over the written forms and the game's form, with a lane off and with src1 negated;fa 02 28 7c 01 4e 4c ff).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
--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_f16242,s_getpc_b6418 (#1632), no shader container 6. The 18,493 programs that already translated contain nov_cmpxin DPP form, since it was refused, so their output is unchanged.python -I scripts/run_gpu_tests.py --filter cs_dpp: 10/11 pass withcs_dpp_cmpx=1 1 0 0 3 3 2 2(cs_dpp_w64skipped: no 64-wide subgroup). WithLEONIDA_W64_EMULATE=1, 11/11 pass.tests/semantic/test_dpp_compare.py: 13 tests pass, including thellvm-mclisting test (LLVM 23).regen_fixtures.py --checkis clean.scripts/run_semantic_tests.py tests/semantic: 487 files, 6,283 tests, 0 failed.GPUs tested: NVIDIA GeForce RTX 4070 Laptop GPU, driver 591.59 (32.0.15.9159), Windows 11
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.🤖 Generated with Claude Code
@GeorgiyDemo on GitHub · 2026-11-25 07:21 UTC · original
Tested
844dd42b6on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), againstmain3f81d46ac(translator + new GPU fixture; binaries from the build at66d4f5aa3):tests/semantic/test_dpp_compare.py: OK (2 skipped) at this head; copied ontomainit fails 5 + 85 errors.--filter cs_dpp_cmpx: 1/1 PASS on MoltenVK 1.4.2 and 1/1 PASS on KosmicKrisp (Mesa 26.3.1), words1 1 0 0 3 3 2 2.main'stools/rdna2spirv.pyfails exactly as before the PR —1 DPP on v_cmpx, thenmissing .spv (translation failed).AI-assisted; synthetic fixtures only, no game data.
@ecox982745 on GitHub · 2026-11-25 07:46 UTC · original
I tested the compare in a pixel shader on an RTX 4090, since all 78 programs in the reported bucket are pixel shaders. On
844dd42b6, eight synthetic 64×64 draws matched the independent per-pixel reference in all 32,768 pixel results. Parent42537e7b6refused all eight translations withDPP on v_cmpx.I used two distinct lane-dependent float operands with
quad_perm:[2,3,0,1], negated src1, full row/bank masks,bound_ctrl:1andfi:1. One draw starts with full EXEC. A second disables lane 2 of each quad after initializing both operands and before the DPP compare. The shader saves the result, restores EXEC, and exports the result, lane ID and both inputs. This lets the CPU reference check each actual fragment lane independently of its screen position.The partially masked draw produced 512 true results out of 4,096. Treating an inactive source as zero would change 384 pixels. Omitting the quad permutation would change 1,024 pixels, and omitting src1 negation would change 1,536. Both disassemblers (LLVM 23.1.6 and Python) and both source wave declarations gave exact results, and all eight modules passed SPIR-V validation. The wave64-source draw ran on physical 32-wide NVIDIA subgroups (observed lanes 0–31).
Windows, NVIDIA 616.64. Synthetic shaders only. AI-assisted verification.
@whoalin1 on GitHub · 2026-11-25 08:31 UTC · original
Independent verification (native Windows): diff reviewed —
v_cmpxhandled as a DPP compare (src0 = first operand, result -> EXEC), conservative gating (full row/bank + bound_ctrl/DPP8 only), contract row in docs/design.md extended, new semantic test + GPU fixture wired.test_dpp_compare.py13 OK (2 llvm-mc skips, environmental); FULL semantic suite 487 files / 6,283 tests / 0 failed;run_gpu_tests.py --filter cs_dpp_cmpxPASS on both RTX 4070 SUPER and AMD gfx1036 iGPU, output matches check.py. The "78 pipeline-library shaders" claim needs game files — unverifiable here, but the mechanism is sound. AI-assisted verification.@adrianmjim on GitHub · 2026-11-25 09:04 UTC · original
Tested
844dd42b6applied ontomain42537e7b6, on AMD: Radeon RX 7900 XT (RDNA3, gfx1100, subgroup 32..64), AMD driver 32.0.32029.2010 (26.11.2), Windows 11 build 26300, Vulkan SDK 1.4.363.0, llvm-mc 23.1.5, test programs from amain42537e7b6build. That adds an RDNA3 and wave64-capable run to the gfx1036 one above. No game files.GPU:
--filter cs_dpp:cs_dpp_cmpxpasses with1 1 0 0 3 3 2 2, natively and withLEONIDA_W64_EMULATE=1. The other tencs_dpp*fixtures,cs_dpp_w64included, give the same words as onmain.maingives 244/263 here, and the only difference is the new pass. The failure iscs_imgatomic_exton both, the fixture problem #1518 fixes.One problem this PR makes reachable: the wave64 halves analysis does not see the EXEC write of a DPP
v_cmpx. Intools/wave64_halves.pytransfer(), the cross-lane branch (around line 912) catches every op with_dppor a DPP modifier. It taintsdests, which is empty forv_cmpx, and returns before the"exec" in defs→exec_write()step (around line 927).So after
v_cmpx_*_dpp, SHADER-10 still believes EXEC is what it was before the compare (in the repro below, the launch mask). Until this PR every DPPv_cmpxwas refused, so the gap could not be reached.The same wave64 pixel shader body, with an e32 and a DPP compare.
test_wave64_halves.ps()wraps the body and exportsv6throughexp mrt0 v6, v7, v5, v5 done vm:<cmpx>w64gwith this PRv_cmpx_gt_f32_e32 v1, v2['cross-lane'], no idiomsv_cmpx_gt_f32_dpp v1, -v1 quad_perm:[2,3,0,1] row_mask:0xf bank_mask:0xf bound_ctrl:1 fi:1readlane-uniform, one entry inuniform_readlaneOn
mainthe DPP form stops withUnsupported: DPP on v_cmpx.With the DPP form, the analysis treats
v5 = s4as uniform in every lane. Sov_readlane_b32 s5, v5, 0becomes a read of each lane's own copy:A vcc vote after such a compare could be given tier A/B in the same way.
A fix: in that cross-lane branch, fall through to
exec_write()when"exec" in defs, or check the EXEC write before the branch. This needs no game data to reproduce. The repro callstests/semantic/test_wave64_halves.py'slisting/ps/translate_listing, then readsrdna2spirv.translate.last_gen.w64g.Two smaller points:
restore_skipped_instructions(tools/rdna2spirv.py, around 17572) only recovers DPP compares namedv_cmp_*_f32_dpp, and"v_cmpx_gt_f32_dpp".startswith("v_cmp_")is False. So a listing made withoutwith_vopc_dpp(or where that pass returned None) should stop withfall-through into undecodable words. I worked that out fromreachable_codeand did not run it. It fails safe, and listings from the currentshader_disasm.pyare not affected.v_cmpx_class_f32_dppwith a negated src0, on a lane whose DPP source reads 0 (out of its row withbound_ctrl:1, or inactive withoutfi:1),negis applied before the zero substitution. The lane classifies +0 (class bit 6). Hardware, if it appliesnegafter the DPP fetch as the ISA describes, classifies -0 (bit 5). The game's form (src1 negated,quad_perm) can't hit it, andv_cmp_classonmainbehaves the same.@OreoFR on GitHub · 2026-11-25 09:15 UTC · original
@adrianmjim thanks, that's a real hole, and this PR is what made it reachable. Fixed in
2b639a367:tools/wave64_halves.py: intransfer(), the cross-lane branch still taints the DPP sources, then goes throughexec_write()when"exec" in defs, with a newvote=False. A DPPv_cmpxis never taken as a uniform vote, because a lane whose DPP source is invalid compares 0. Your repro is nowtests/semantic/test_wave64_halves.pyVcmpxDppExec. The DPP form classifies exactly as the e32 one does: tier C,['cross-lane'], no idioms. Before the fix it was tier B withreadlane-uniform.restore_skipped_instructions: it now also recoversv_cmpx_*_f32_dpp.test_library_compute_forms.pycovers it with the game's encoding (fa 02 28 7c 01 4e 4c ff), decoded to two operands and restored at pc 0.v_cmpx_classneg/zero order: left out here. As you say,v_cmp_classonmainbehaves the same and the game's form can't reach it. It's better fixed for both compares together, in a separate PR.None of the 78 programs this PR unblocks is wave64. All are wave32 (
wave64: falsein the index), so the halves analysis never ran on them. Re-translated with the fix: still 78 translated and 78 passing spirv-val. The full suite passes: 487 files, 6,285 tests, 0 failed.AI-assisted.
@ecox982745 on GitHub · 2026-11-25 09:19 UTC · original
I confirmed the rendering consequence of the EXEC-tracking issue on an RTX 4090 (Windows, NVIDIA 616.64) and rechecked
2b639a367against its parent844dd42b6.My synthetic wave64 pixel shader initializes
v5to zero, uses an alternating screen-space input for the DPP compare, writes1.0tov5only in the surviving lanes, restores EXEC, then broadcastsv_readlane_b32 s5, v5, 0to the red channel. Whichever value lane 0 held, every lane in its wave should read the same red value.844dd42b6,--wave64-graphics erroraccepted the shader as tier B (readlane-uniform). The frame contained 2,048 red zeros and 2,048 red ones. To check whether variation occurred within a subgroup, I addedOpGroupNonUniformAllEqualon red at the final export and recorded the vote in alpha. All 4,096 pixels reported a mixed subgroup. The RGB bytes matched the uninstrumented draw. A control with EXEC kept full reported uniform red at all 4,096 pixels.2b639a367, strict mode correctly refuses both the DPP case and the ordinary compare control as tier C (cross-lane). The full-EXEC control still draws correctly. All eight previously tested DPP draws without the unsafe readlane still match their references, 32,768/32,768 pixels across both decoders.The hardware subgroups were 32-wide. The new result for the unsafe shader is a translator refusal before GPU execution. Separately, all 154 CPU tests in
test_wave64_halves,test_library_compute_forms, andtest_dpp_comparepassed with LLVM 23.1.6. AI-assisted verification.@quartz-heron-58 on GitHub · 2026-11-25 09:50 UTC · original
Author of #957 here. A check on a real copy of the pipeline library, which the reports above could not do, plus one test file that is red on this head.
Setup: head 2b639a367 against its base on main
42537e7b6. Windows 11 build 26300, own 1.0.2.1 copy, llvm-mc 21.1.8 (so an older assembler than the PR's LLVM 23 runs), SPIRV-Tools v2026.4, Python 3.12.Pipeline library, graphics programs.
tools/shader_library.py shaders.rpf --stages ps,vs,ms --disasm --carve ...from this branch writes 18,837 programs, the same total as your census (18,493 + 344). Both translators then ran over the same listings with--wave64-emulate:42537e7b6v_interp_p2_f16, 43 normalized encoding, 6 no shader container, 1s_getpc_b64. Only the first count moves.So the direction is confirmed on a second copy and toolchain, but not the number 78. With llvm-mc 21 far more programs stop at undecodable words for reasons that have nothing to do with this PR (1,708 here against a total of 344 refusals in your census), and the rest of your 78 are presumably behind those. On these listings the base never reports
DPP on v_cmpxat all: the 14 come through the restore pass added in 2b639a367. I did not rerun with LLVM 23 or the Python backend, so I cannot say whether 78 reproduces there.pytest tests/test_translate.py: 4 failed, 705 passed on this head; 2 failed, 705 passed on the base. The two on the base arecs_dpp_cmp.asm, which is my doing from #957. The two new ones are the same two tests oncs_dpp_cmpx.asm:test_gpu_samples_translate_and_validateandtest_wave64_emulate_uses_no_subgroup_ops, both stopping at the llvm-mc assertion intests/conftest.py("dpp variant of this instruction is not supported"). The new fixture carries the; run_gpu_tests: text onlyline, so #1375 (open) fixes all four once it lands; until then this PR adds two failures to the translator-tests job. Nothing to change in the fixture, as far as I can see. It only needs #1375 first, or aDepends on.Also run, all passing:
test_dpp_compare.py13,test_wave64_halves.py128,test_library_compute_forms.py13. GPU,run_gpu_tests.py --filter cs_dppwith test programs from a main2376e7d56build:cs_dpp_cmpxgives1 1 0 0 3 3 2 2on an AMD Radeon iGPU (Ryzen 9 9950X3D, driver 32.0.21042.62, subgroup 32..64), natively and withLEONIDA_W64_EMULATE=1(11/11 both), and on an RTX 4080 (621.24): 10/11 with one 64-wide skip natively, 11/11 emulated.Not run: the full semantic suite, LLVM 23, the Python disassembler backend. One run of each. Counts only, no game data. AI-assisted: yes (Claude Code)
@OreoFR on GitHub · 2026-11-25 10:09 UTC · original
@quartz-heron-58 thanks, especially for the run on a real library with another toolchain.
make_game.py's shaders stage on #1592's tree (344 refusals in all). Your 1,708 "fall-through into undecodable words" with llvm-mc 21.1.8 hide most of the DPPv_cmpxprograms before the translator reaches them. That fits the 14 coming through the restore pass. I'll say in the description that the 78 is with LLVM 23.tests/test_translate.py: right,cs_dpp_cmpx.asmhits the same llvm-mc assertion ascs_dpp_cmp.asm, and #1375 fixes both. I added#1375to this PR'sDepends on.AI-assisted.
@MoonEyes on GitHub · 2026-11-25 10:37 UTC · original · reviewed
Checked on Windows 11, Python 3.14, Vulkan SDK 1.4.363
spirv-valon PATH,LLVM_MC=wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc(LLVM 21.1.8). Head 2b639a367. Main moved during the checks, so each result names the main commit it was run on.Translator tests (
scripts/run_semantic_tests.py, main604ddff0b):test_dpp_compare.pytest_library_compute_forms.pytest_wave64_halves.pytests/test_translate.py(pytest 9.2.0, main57ba40bd6), confirming theDepends on: #1375:test_gpu_samples_translate_and_validateandtest_wave64_emulate_uses_no_subgroup_opsoncs_dpp_cmp.asm(from #957)cs_dpp_cmp.asmandcs_dpp_cmpx.asmGPU: NVIDIA GeForce RTX 4060 (Ada), driver 610.88,
vk_compute_testbuilt with MSVC 19.44 from main3f81d46ac, fixtures and translator from this PR.python -I scripts/run_gpu_tests.py --build <build> --filter cs_dpp --disasm-dir tests/semantic/fixtures/disasmgivesPASS cs_dpp_cmpandPASS cs_dpp_cmpx(2/2; both translate and pass spirv-val).Not checked: the 78 graphics programs from the #1592 census (my work folder's
shaders/libraryhas 2,680 programs, not the graphics library), and the main corpus with this branch. None of its 26,503shaders/dxbc/disasmlistings contains av_cmpx_*_dppin text (grep), butrestore_skipped_instructionscan now recover that form from the raw bytes, so a text grep does not show the corpus output is unchanged; I did not re-translate it.AI-assisted: yes (Claude Code ran the checks; a separate agent checked this text against the logs; I read both).
@quartz-heron-58 on GitHub · 2026-11-25 11:04 UTC · original
The check @MoonEyes lists as not done, the main corpus re-translated with this branch: the output does not change.
All 26,503 listings of a 1.0.2.1 copy (
shaders/dxbc/disasm, llvm-mc 21.1.8 backend), translated withrdna2spirv.py --no-asm --wave64-emulateonce from the base42537e7b6and once from this head 2b639a367, each into its own folder:.spvfiles are byte-identical between the two (SHA-256 of each pair), and so is the mergedindex.json.So on this corpus neither the new compare path nor the extended restore pass changes a module. Together with the library result above (14 new pixel programs, none lost), that is every program I can translate here.
Not covered: listings from LLVM 23 or the Python backend, a run without
--wave64-emulate, and the fallback flags. One run of each side. Hashes and counts only, no game data. AI-assisted: yes (Claude Code)@OreoFR on GitHub · 2026-11-25 11:10 UTC · original
@quartz-heron-58 thanks, that closes the check left open: all 26,503 modules byte-identical, plus the 14 new pixel programs from the library run. And thanks @MoonEyes for the review on the 4060.
AI-assisted.
@adrianmjim on GitHub · 2026-11-25 12:48 UTC · original
Rechecked at
dec076574. The wave64 halves gap is closed. My repro, the same wave64 pixel shader with an e32 and a DPP compare followed byv_readlane_b32after the EXEC restore, now gives:<cmpx>w64gat844dd42b6dec076574v_cmpx_gt_f32_e32 v1, v2cross-lanecross-lanev_cmpx_gt_f32_dpp v1, -v1 quad_perm:[2,3,0,1] ... bound_ctrl:1 fi:1readlane-uniformcross-laneSo the DPP form is now treated like the e32 one.
On the RX 7900 XT (driver 32.0.32029.2010, test programs from a
main42537e7b6build):cs_dpp*fixtures pass, withcs_dpp_cmpx=1 1 0 0 3 3 2 2.LEONIDA_W64_EMULATE=1,cs_dpp_cmpxpasses too.test_dpp_compare.pyand the fivetest_wave64_halves*.pyfiles pass.No game files.
@EvgHaze on GitHub · 2026-11-25 13:08 UTC · original
Apple check of the new DPP fixture, on both drivers.
scripts/run_gpu_tests.py --filter cs_dpp— identical on both drivers, 10/11 passed, 1 skipped:cs_dpp1 0 3 2 5 4 7 6cs_dpp87 6 5 4 3 2 1 0cs_dpp_bank4294967295 4294967294 4294967293 4294967292 7 7 7 7cs_dpp_bound10 10 11 12 13 14 15 16cs_dpp_cmp3 2 3 2 1 0 1 0cs_dpp_cmpx(new)1 1 0 0 3 3 2 2cs_dpp_fi1 2 3 30583 5 6 7 30583cs_dpp_mask1 0 3 2 4008636142 4008636142 4008636142 4008636142cs_dpp_ops100 10 11 12 13 14 15 16cs_dpp_row0 0 1 2 3 4 5 6The skip is the 64-wide case (
no 64-wide compute subgroup on this device).python3 -I scripts/run_semantic_tests.py tests/semantic→ 489 files, 6294 tests, 0 failed (main is 6288, so this diff adds six), 148 s.Worth noting for the record: these run at subgroup size 32 natively on both Apple drivers, so the DPP forms are not being emulated here.
AI-assisted. No game data: hand-written fixtures, and the numbers above are test output.
@aslan2142 on GitHub · 2026-11-26 18:54 UTC · original
Merging.
v_cmpxin DPP form is now translated instead of refused, for the forms where every lane writes its bit. The result goes into EXEC as for a plainv_cmpx, and the contract-table row records how it was confirmed.maine57bc63bc+ #1375 + this PR (0df371254):pytest tests/test_translate.py: 720 passed, including the four DPP compare cases.test_dpp_compare13,test_library_compute_forms13,test_wave64_halves128. Withmain's translator they fail.test_ci_registration.py,compileallandcheck_no_game_data.pypass.make_game.pydoes not carve yet.Thanks @OreoFR, and @GeorgiyDemo, @ecox982745, @whoalin1, @adrianmjim, @quartz-heron-58, @MoonEyes and @EvgHaze for the reviews and runs.
AI-assisted (Claude Code, Claude Opus 5.5 and Claude Fable 5.2)