Repository navigation
rdna2spirv: translate v_cmpx in DPP form (SHADER-VOPCX-DPP) - #1647
Conversation
|
Tested
AI-assisted; synthetic fixtures only, no game data. |
|
I tested the compare in a pixel shader on an RTX 4090, since all 78 programs in the reported bucket are pixel shaders. On I used two distinct lane-dependent float operands with 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. |
|
Independent verification (native Windows): diff reviewed — |
|
Tested GPU:
One problem this PR makes reachable: the wave64 halves analysis does not see the EXEC write of a DPP So after The same wave64 pixel shader body, with an e32 and a DPP compare.
On With the DPP form, the analysis treats
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 Two smaller points:
|
…tore pass recovers it (SHADER-VOPCX-DPP review) - wave64_halves.transfer: the cross-lane branch caught v_cmpx in DPP form and returned before its EXEC write, so the analysis kept the old EXEC and could call a value uniform that is not (tier B readlane-uniform instead of C). It now goes through exec_write, never as a uniform vote. - restore_skipped_instructions recovers v_cmpx_*_f32_dpp as it does v_cmp_*. Found by adrianmjim's review of ProjectLeonida#1647. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@adrianmjim thanks, that's a real hole, and this PR is what made it reachable. Fixed in
None of the 78 programs this PR unblocks is wave64. All are wave32 ( AI-assisted. |
|
I confirmed the rendering consequence of the EXEC-tracking issue on an RTX 4090 (Windows, NVIDIA 616.64) and rechecked My synthetic wave64 pixel shader initializes
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 |
|
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 2b639a3 against its base on main 42537e7. 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.
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
Also run, all passing: 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) |
|
@quartz-heron-58 thanks, especially for the run on a real library with another toolchain.
AI-assisted. |
MoonEyes
left a comment
There was a problem hiding this comment.
Checked on Windows 11, Python 3.14, Vulkan SDK 1.4.363 spirv-val on PATH, LLVM_MC=wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc (LLVM 21.1.8). Head 2b639a3. Main moved during the checks, so each result names the main commit it was run on.
Translator tests (scripts/run_semantic_tests.py, main 604ddff):
| file | main | this PR |
|---|---|---|
test_dpp_compare.py |
9 tests OK | 13 tests OK |
test_library_compute_forms.py |
12 tests OK | 13 tests OK |
test_wave64_halves.py |
127 tests OK | 128 tests OK |
tests/test_translate.py (pytest 9.2.0, main 57ba40b), confirming the Depends on: #1375:
| tree | result |
|---|---|
| main | 2 failed, 705 passed: test_gpu_samples_translate_and_validate and test_wave64_emulate_uses_no_subgroup_ops on cs_dpp_cmp.asm (from #957) |
| this PR | 4 failed, 705 passed: the same two tests, each on cs_dpp_cmp.asm and cs_dpp_cmpx.asm |
| this PR + #1375 (local merge) | 711 passed |
GPU: NVIDIA GeForce RTX 4060 (Ada), driver 610.88, vk_compute_test built with MSVC 19.44 from main 3f81d46, fixtures and translator from this PR. python -I scripts/run_gpu_tests.py --build <build> --filter cs_dpp --disasm-dir tests/semantic/fixtures/disasm gives PASS cs_dpp_cmp and PASS 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/library has 2,680 programs, not the graphics library), and the main corpus with this branch. None of its 26,503 shaders/dxbc/disasm listings contains a v_cmpx_*_dpp in text (grep), but restore_skipped_instructions can 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).
|
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 (
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 |
|
@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. |
|
Rechecked at
So the DPP form is now treated like the e32 one. On the RX 7900 XT (driver 32.0.32029.2010, test programs from a
No game files. |
|
Apple check of the new DPP fixture, on both drivers.
The skip is the 64-wide case (
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. |
Extend ProjectLeonida#957's DPP VOPC compare to v_cmpx: the same lane selection, with the result written to EXEC. v_cmpx prints no destination, so src0 is its first operand. Only the forms where every lane writes its bit are taken, as for v_cmp. 78 pipeline-library pixel shaders of 1.0.2.1 were refused for it; all 78 now translate and pass spirv-val. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tore pass recovers it (SHADER-VOPCX-DPP review) - wave64_halves.transfer: the cross-lane branch caught v_cmpx in DPP form and returned before its EXEC write, so the analysis kept the old EXEC and could call a value uniform that is not (tier B readlane-uniform instead of C). It now goes through exec_write, never as a uniform vote. - restore_skipped_instructions recovers v_cmpx_*_f32_dpp as it does v_cmp_*. Found by adrianmjim's review of ProjectLeonida#1647. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… of unwritten lanes (SHADER-VOPCX-DPP review) On RDNA3 a lane DPP leaves unwritten does not keep its mask bit: v_cmp writes 0 to its VCC bit and v_cmpx turns it off in EXEC (mcpeacebir-lang, RX 7800 XT, ubiquitarianism#1608). The refusal text and the docs/design.md row said the bit was kept, as fact. The forms stay refused, since RDNA2 is not measured; the wording now says that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…name for the pass (SHADER-VOPCX-DPP) main replaced restore_skipped_instructions with restore_vcc_tuples and its skipped_form predicate while this branch was open; the rebase carries the v_cmpx case into skipped_form, and the test now takes the listing entry the way main's own v_cmp DPP case does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dec0765 to
0df3712
Compare
|
Merging.
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) |
Claimed in the coordination issue as: SHADER-VOPCX-DPP (#1608 (comment))
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 (rdna2spirv: support vcc and null destinations on s_getpc_b64 and reject odd pairs #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