Repository navigation
Conversation
…em (SHADER-PERMUTE-EAGER) Gen.ds_permute lets each destination lane scan the 32 source lanes of its half: per source lane a shuffle of the published target, a shuffle of the data and an OpSelect that keeps the data when the target is this lane. Each shuffle was used once and so was every link of that chain, so SPIRV-Cross (MoltenVK) wrote the 32 steps as one nested ternary under the EXEC ternary of the register write. A lane that takes an outer arm, or is off in EXEC, then runs none of the shuffles inside it (the SHADER-529 mechanism). On an Apple M5 (MoltenVK 1.4.2) tools/lds_fuzz.py --wave 32 --permute had 17 of the 100 programs of seed 31002 differ from the model, every one in a ds_permute_b32 result, mostly 0 where a source lane's data belongs. Both shuffles are now stored to Function variables (Gen.eager), as the DPP rule stores its ballot bit and its shuffle. tests/semantic/test_ds_permute_eager.py checks the three native forms with test_dpp_eager_subgroup.py's model of SPIRV-Cross's single-use forwarding, and the values against test_ds_permute.py's ISA model. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
The pixel-shader coverage listed as open in the PR passed on my RTX 4090. I compared I ran five synthetic full-screen draws for each of the wave32 and wave64 source declarations: a 17-lane rotation, a masked reversal with an unaligned byte address and instruction offset, a scatter leaving holes, multiple active sources targeting the same lane, and a scatter with the destination register aliased to the data register. Each pixel exported its actual lane, source address and result. The CPU reference checked the expected writer, zero for an active destination with no writer, and the old register value for an inactive destination. For collisions it accepted any active writer that targeted that lane. The RTX 4090 ran physical 32-wide subgroups throughout. Both revisions passed on this driver. The author's MoltenVK results supply the before/after evidence for the fix. AI-assisted verification. |
|
Independent verification (native Windows; RTX 4070 SUPER + AMD Radeon gfx1036 iGPU): the eager-store fix pins the SHADER-529 mechanism — both |
|
Reviewed head Coordination: SHADER-PERMUTE-EAGER claim comment 7156204534 (hugo0024, 2026-11-25T07:44:45Z, Mergeability against the moved main: Measured, both directions:
CI at head: five checks (change-scope, linux-gpu-tools, macos, no-game-data, windows) pending as of this run — started, none failing yet. Verdict: LGTM. The store-to-Function-variable mechanism is the repo's established SHADER-529 answer, applied consistently with the DPP and ballot precedents; the test's inverse sabotage (stores removed -> all 64 shuffles back in ternary arms) makes it unvacuous. Caveats the PR already states honestly: only the M5 path is GPU-measured, and the op is absent from the game corpus, so this is correctness insurance rather than a boot unblock. Reviewed by an overnight shift of my own account; measurements reproducible with |
|
Tested
I read the fuzz match counts, not just the exit code. Every run reported 0 mismatched and 0 harness errors. The one suite failure is So AMD's own compiler gives the same results with or without the stores, as expected. I did not measure performance. |
|
Apple check (no regression, plus the semantic suite).
So on a 32-wide host, where these programs run natively rather than split, the eager-store change gives the same words on two drivers that take different paths to Metal.
What I did not run: the 64-wide cases, which this device cannot execute. AI-assisted. No game data: hand-written fixtures, and the numbers above are test output. |
Claimed in the coordination issue as: SHADER-PERMUTE-EAGER (claim)
What and why
On an Apple M5 (MoltenVK 1.4.2)
ds_permute_b32delivers wrong words:tools/lds_fuzz.py --wave 32 --permutehas about a quarter of its programs differ from the model. Over seeds 1, 2, 3 and 31002, 1,374 of the 1,440 wrong words were last written by ads_permute_b32(the others by an op a wrong word fed), and 1,238 of the 1,440 read 0 where a source lane's data belongs.docs/shader_validation.mdrecords 0 mismatches for the op on RADV. The fuzzer files the op under "hypothesis" and exits 0, so the runs looked clean.Gen.ds_permutelets each destination lane scan the 32 source lanes of its half: per source lane a shuffle of the published target, a shuffle of the data, and anOpSelectthat keeps the data when the target is this lane. Each shuffle is used once, and so is every link of that chain. SPIRV-Cross inlines a result that is used once into the expression that uses it, so the 32 steps become one nested ternary inside the EXEC ternary of the register write:A lane that takes an outer arm, or is off in EXEC, runs none of the shuffles inside it. This is the SHADER-529 mechanism;
test_dpp_eager_subgroup.py's model of that inlining flags all 64 shuffles of oneds_permute_b32onmain.tools/rdna2spirv.py:Gen.ds_permutestores both shuffles to Function variables (Gen.eager), as the DPP rule stores its ballot bit and its shuffle. A store is a statement every lane runs. Native path only;--wave64-emulatehas no subgroup operation in this rule.tests/semantic/test_ds_permute_eager.py: no shuffle of the rule is left in a conditional position, in a wave32 and a wave64 compute shader and a pixel shader; each of the 64 is read by oneOpStoreto a variable of its own; the module with the stores taken out again has all 64 in a ternary's arm; and the stored form gives the ISA model's words with EXEC narrowed, sources that are off and a collision.docs/design.md(the LDS row) andtests/semantic/README.md: the rule and how it was confirmed.ds_permute_b32occurs in no shader of the corpus (docs/testing.md), so no game shader changes; the cost is 64 Function variables perds_permute_b32.Tested
Apple M5, MoltenVK 1.4.2, llvm-mc 23.1.6, SPIRV-Tools v2026.4. Before is
main3f81d46ac, after is this branch on the same commit, both with the test programs built frommain.python3 -I tools/lds_fuzz.py --wave 32 <options>, programs that match the model:--permute --programs 100 --seed 31002--permute --programs 300 --seed 1--permute --programs 300 --seed 2--permute --programs 300 --seed 3--extended --programs 300 --seed 31002--programs 300 --seed 31001(default mix, nods_permute_b32)scripts/run_gpu_tests.py: 193/263 passed, 68 skipped, before and after, every test with the same verdict (cs_w32_permuteandcs_w32_partial_permutepass in both; the two failures arecs_fma_fused, the MoltenVK 1.4.2 row ofdocs/testing.md, andcs_imgatomic_ext, which is red onmainand claimed by someone else as GPU-IMG-ATOMIC-EXT-VOLUME-TAG). Its translation step reports273 shaders: 272 translated, 272 pass spirv-valin both. 3 of the 275 modules in its work folder change:cs_w32_permute,cs_w32_partial_permuteandcs_w64x_permute.lds_fuzz.py --wave 64 --emulate --extended --programs 200 --seed 31003(the path this does not touch): 148 of 148 that ran match, before and after.tests/semantic/test_ds_permute_eager.py: 5 tests pass; withmain's translator 7 checks fail (each shuffle "is read byOpSelect, not stored").python3 -I scripts/run_semantic_tests.py tests/semantic: 487 files, 6,279 tests, 0 failed before; 488 files, 6,284 tests, 0 failed after.spirv-asandspirv-valreports nothing.tests/test_translate.pyoncs_dpp_cmp.asm, tests: the pytest helper takes a text-only sample's lines as its listing, as run_gpu_tests.py does (TEST-TRANSLATE-TEXT-ONLY) #1375's subject).test_mod_pack_output_alias.py: tests: the mod-pack alias test compares resolved names, as same_report_path does (TEST-MOD-PACK-ALIAS-MACOS) #1412;test_runner_calls_all_tests.pyandtest_tool_stdout_encoding.py: Fix two repository checks that fail on main #1561;test_runtime_paths.py: ci: the Runtime workflow starts on tools/conformance/** (CI-RUNTIME-PATHS-CONFORMANCE) #1657).tests/test_docs_*.pypass;python3 -I scripts/check_no_game_data.py tests/semantic/test_ds_permute_eager.pyis clean.Not tested: a GPU other than the M5 (on a driver that does not inline this way the change is a store and a load of the same value), wave64 on a 64-wide subgroup and the pixel-shader form on a GPU (both only in the interpreter), and the game corpus (the op is not in it).
GPUs tested: Apple M5 (8-core GPU), MoltenVK 1.4.2, macOS 27.2.1 (26B131)
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