rdna2spirv: ds_permute_b32 stores its shuffles, so every lane runs them (SHADER-PERMUTE-EAGER) #1683
Open
github-bot
wants to merge 1 commit from
github-bot/gh-1683 into main
AGit
pull from: github-bot/gh-1683
merge into: github:main
github:main
github:docs/animation-merge-remnants
github:docs/story-dedup-and-cli
github:docs/restofworld-merge-remnants
github:docs/gamedata-dedup-tables
github:docs/textures-bcpack-tables-and-cli
github:docs/exe-fail-fast-shims-sync
github:fix/address-guard-wraparound-parity
github:fix/cvt-f16-denorm-and-clamp
github:docs/pso-cache-scope-note
github:docs/viewer-readme
github:docs/textures-arrays-dds-preview
github:docs/conformance-readme-status
github:fix/docs-validators-fences-urls
github:claude/loop-total
github:claude/pops-collision-seed
github:claude/dstorage-hold-page-reads
github:claude/host-image-copy-switch
github:feat/gdk-lifecycle-window-hook
github:claude/d16s8-uav-nvidia-fallback
github:feat/mfplat-offline-shim
github:claude/gameinput-slow-reader
github:fix/rt-null-barrier-clear
github:claude/depth-resolve-sample-positions
github:integration/palmetto-parity
github:claude/valu-literal-sext
github:claude/slot74-pool-handle
github:claude/rgb9e5-uint-alias-view
github:claude/fssm-root-layout-tables
github:feat/gdk-speech-display-lifecycle
github:asset-audio-skip-current
github:qemmhd/old-9940-rectangle-quad-lists
github:feat/ws2-offline-shim
github:qemmhd/rt-d16-unorm-uav
github:feat/xs-device-stops-7-9
github:qemmhd/rt-depth-same-base-shapes
github:qemmhd/rt-lazy-attachment-variant
github:feat/acphal-xma2-decoder
github:asset-audio-skip
github:codex/coord-claim-check-20261124-7e48
github:feat/xs-frame-pacing-presentx
github:feat/xs-device-vm-options
github:old-pr/9844
github:old-pr/9978
github:old-pr/9815
github:old-pr/10057
github:old-pr/9874
github:old-pr/9965
github:old-pr/9863
github:old-pr/10068
github:old-pr/10066
github:old-pr/10067
github:old-pr/10007
github:old-pr/10061
github:old-pr/10065
github:old-pr/10059
github:old-pr/10063
github:old-pr/10055
github:old-pr/10062
github:old-pr/10042
github:old-pr/10041
github:old-pr/10049
github:old-pr/10047
github:old-pr/10046
github:old-pr/10045
github:old-pr/10056
github:old-pr/10043
github:old-pr/10036
github:old-pr/10034
github:old-pr/9984
github:old-pr/10052
github:old-pr/10038
github:old-pr/10033
github:old-pr/10028
github:old-pr/10050
github:old-pr/9891
github:old-pr/9889
github:old-pr/10051
github:old-pr/10019
github:old-pr/10027
github:old-pr/10029
github:old-pr/10031
github:old-pr/10026
github:old-pr/9941
github:old-pr/10030
github:old-pr/10040
github:old-pr/9990
github:old-pr/10021
github:old-pr/9962
github:old-pr/10022
github:old-pr/10020
github:old-pr/10015
github:old-pr/10025
github:old-pr/9886
github:old-pr/10048
github:old-pr/10014
github:old-pr/10011
github:old-pr/9861
github:old-pr/10010
github:old-pr/10008
github:old-pr/9860
github:old-pr/10006
github:old-pr/9920
github:old-pr/9995
github:old-pr/10000
github:old-pr/10016
github:old-pr/10004
github:old-pr/10023
github:old-pr/9982
github:old-pr/9981
github:old-pr/9983
github:old-pr/9970
github:old-pr/9969
github:old-pr/9968
github:old-pr/9971
github:old-pr/9972
github:old-pr/9942
github:old-pr/9963
github:old-pr/9960
github:old-pr/9964
github:old-pr/9985
github:old-pr/9973
github:old-pr/9862
github:old-pr/9953
github:old-pr/10017
github:old-pr/9952
github:old-pr/9955
github:old-pr/9946
github:old-pr/9954
github:old-pr/9938
github:old-pr/9956
github:old-pr/9856
github:old-pr/9947
github:old-pr/9924
github:old-pr/9961
github:old-pr/9927
github:old-pr/9979
github:old-pr/10032
github:old-pr/9926
github:old-pr/5237
github:old-pr/9951
github:old-pr/9931
github:old-pr/9902
github:old-pr/9921
github:old-pr/9994
github:old-pr/9775
github:old-pr/9768
github:old-pr/9905
github:old-pr/9936
github:old-pr/9901
github:old-pr/9904
github:old-pr/9906
github:old-pr/9988
github:old-pr/9908
github:old-pr/9909
github:old-pr/9911
github:old-pr/9912
github:old-pr/9913
github:old-pr/9887
github:old-pr/9916
github:old-pr/9919
github:old-pr/9925
github:old-pr/9933
github:old-pr/9935
github:old-pr/9918
github:old-pr/9879
github:old-pr/9880
github:old-pr/9881
github:old-pr/9996
github:old-pr/9876
github:old-pr/9892
github:old-pr/9899
github:old-pr/9915
github:old-pr/9914
github:old-pr/9872
github:old-pr/9869
github:old-pr/9866
github:old-pr/9819
github:old-pr/10012
github:old-pr/9857
github:old-pr/9893
github:old-pr/9897
github:old-pr/9928
github:old-pr/9868
github:old-pr/9917
github:old-pr/9940
github:old-pr/9873
github:old-pr/9816
github:old-pr/10009
github:old-pr/9900
github:old-pr/9966
github:old-pr/9859
github:old-pr/9843
github:old-pr/9991
github:old-pr/10058
github:old-pr/9883
github:old-pr/9838
github:old-pr/9835
github:old-pr/9959
github:old-pr/9895
github:old-pr/9837
github:old-pr/9858
github:old-pr/9865
github:old-pr/9864
github:old-pr/9840
github:old-pr/9820
github:old-pr/4669
github:old-pr/9848
github:old-pr/9850
github:old-pr/9810
github:old-pr/9799
github:old-pr/9853
github:old-pr/9875
github:old-pr/9831
github:old-pr/9796
github:old-pr/9801
github:old-pr/9813
github:old-pr/9794
github:old-pr/7417
github:old-pr/9781
github:old-pr/9806
github:old-pr/9958
github:old-pr/9809
github:old-pr/9791
github:old-pr/9792
github:old-pr/10053
github:old-pr/9784
github:old-pr/9789
github:old-pr/9849
github:old-pr/9846
github:old-pr/9773
github:old-pr/9785
github:old-pr/9803
github:old-pr/9826
github:old-pr/9839
github:old-pr/9922
github:old-pr/9948
github:old-pr/7189
github:old-pr/9957
github:old-pr/9823
github:old-pr/9807
github:old-pr/9851
github:old-pr/9774
github:old-pr/9830
github:old-pr/9836
github:old-pr/9822
github:old-pr/9783
github:old-pr/9833
github:old-pr/9890
github:old-pr/9770
github:old-pr/9769
github:old-pr/9772
github:old-pr/9787
github:old-pr/9852
github:old-pr/9834
github:old-pr/9845
github:old-pr/9871
github:old-pr/9771
github:old-pr/9776
github:old-pr/10005
github:old-pr/9949
github:old-pr/9923
github:old-pr/9805
github:old-pr/9829
github:old-pr/9790
github:old-pr/9827
github:old-pr/9929
github:old-pr/9855
github:old-pr/9934
github:old-pr/9907
github:old-pr/9910
github:old-pr/9779
github:old-pr/9780
github:old-pr/9885
github:old-pr/9882
github:old-pr/9877
github:old-pr/9998
github:old-pr/4251
github:old-pr/9987
github:old-pr/9989
github:old-pr/9950
github:old-pr/9777
github:old-pr/10044
github:old-pr/9884
github:old-pr/2906
github:old-pr/5076
github:old-pr/9937
github:old-pr/9986
github:old-pr/3014
github:old-pr/9943
github:old-pr/9939
github:old-pr/4682
github:old-pr/4765
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
bug
Something isn't working
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
question
Further information is requested
wontfix
This will not be worked on
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
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
github/ubiquitarianism--leonida!1683
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1683"
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?
@hugo0024 on GitHub · 2026-11-25 08:01 UTC · original
hugo0024:shader-permute-eager→main· +138 −1 · 4 files · 1 commits · openClaimed 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, #1375's subject).test_mod_pack_output_alias.py: #1412;test_runner_calls_all_tests.pyandtest_tool_stdout_encoding.py: #1561;test_runtime_paths.py: #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
@ecox982745 on GitHub · 2026-11-25 08:16 UTC · original
The pixel-shader coverage listed as open in the PR passed on my RTX 4090. I compared
28cb94705with its parent3f81d46acon Windows, NVIDIA 616.64. 40,960 pixel results per revision matched the reference, and all ten corresponding frame pairs were byte-identical. All ten SPIR-V modules changed between revisions and passedspirv-valon both.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.
@whoalin1 on GitHub · 2026-11-25 08:41 UTC · original
Independent verification (native Windows; RTX 4070 SUPER + AMD Radeon gfx1036 iGPU): the eager-store fix pins the SHADER-529 mechanism — both
OpGroupNonUniformShuffleresults per source lane stored unconditionally to fresh vars, so no shuffle sits in conditional position; contract table row added;--wave64-emulatepath untouched as claimed.test_ds_permute_eager.py5/5 on PR and fails 7 checks on baseline translator (negative control confirmed). Full semantic suite 488 files / 6,284 tests / 0 failed — matches claimed counts exactly. GPUrun_gpu_tests.py --filter permute: NVIDIA 3/5 (wave64 skips, no 64-wide subgroup), AMD iGPU 5/5 incl. both wave64 permute fixtures; baseline verdicts identical — no regression; PR-vs-base .spv hashes differ only on ds_permute fixtures (bpermute byte-identical, untouched path correct). MoltenVK itself not testable here, but the emitted SPIR-V shape is pinned by the test. AI-assisted verification.@GrahamboJangles on GitHub · 2026-11-25 09:22 UTC · original
Reviewed head
28cb94705a824f614ab49626f8fbff85616512b5against currentmain2b567edca(base here is3f81d46ac, four merges have landed since). CPU-only on Windows 11, python 3.14.9,python -I; every number below measured on a fresh clone, nothing merged, no GPU.Coordination: SHADER-PERMUTE-EAGER claim comment 7156204534 (hugo0024, 2026-11-25T07:44:45Z,
updated_at == created_at) predates the PR (created 08:01:45Z); the roster hasdone: SHADER-PERMUTE-EAGER -> #1683. No duplicate PRs fix this (--search permutesurfaces only other ops).Mergeability against the moved main:
git diff 3f81d46ac..mainover the PR's four files is empty (the three merges since touchtest_active_cache.py/test_reg_ptr_hoist.py/check.py/docs/related_projects.md, no overlap) — clean rebase,gitsees no conflict.Measured, both directions:
python -I tests/semantic/test_ds_permute_eager.pyat head: 5 tests OK. The same file run againstmain's translator:failures=7, the bungs naming e.g.('%t30', 'OpGroupNonUniformShuffle', 'arm of OpSelect %t31')— the checks genuinely bite, the count-moves gate passes.scripts/run_semantic_tests.py tests/semantic: atmain487 files, 6,279 tests, 0 failed (297 s, 24 jobs); at head 488 files, 6,284 tests, 0 failed (295 s). Delta is the +5 the PR claims, and none of the three main@3f81d46acreds from #1673's subject family is touched here (they were green at this main already — someone carried that fix while my previous overnight run was reviewing).scripts/check_no_game_data.py tests/semantic/test_ds_permute_eager.pyexits 0.eager()helper is pre-existing (line 1509, the SHADER-529 store/load forwarder the DPP rule uses); this change is exactly two calls of it inGen.ds_permute(native path,def ds_permuteat 5902) plus the comment — the--wave64-emulatebranch is untouched, as claimed.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
git clone+fetch pull/1683/head.@adrianmjim on GitHub · 2026-11-25 11:24 UTC · original
Tested
28cb94705applied ontomain42537e7b6on AMD: Radeon RX 7900 XT (RDNA3, gfx1100, subgroup sizes 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. It adds a discrete RDNA3 run, andlds_fuzzwith native wave64 on a 64-wide subgroup. No game files.main--filter permute, native:cs_w32_permute,cs_w32_partial_permute,cs_w64x_permute,cs_bpermute32,cs_w64x_bpermuteLEONIDA_W64_EMULATE=1tools/lds_fuzz.py --wave 32 --permute --programs 300, seeds 31002 and 1--wave 64 --permute --programs 300 --seed 31002(native wave64)--wave both --extended --programs 300 --seed 31002I read the fuzz match counts, not just the exit code. Every run reported 0 mismatched and 0 harness errors. The one suite failure is
cs_imgatomic_exton both trees, which #1518 fixes.test_ds_permute_eager.pypasses 5/5.So AMD's own compiler gives the same results with or without the stores, as expected. I did not measure performance.
@EvgHaze on GitHub · 2026-11-25 12:52 UTC · original
Apple check (no regression, plus the semantic suite).
scripts/run_gpu_tests.py --filter permute, both drivers, identical:cs_bpermute320 50 162 99 36 218 183 15cs_w32_partial_permute0 29 127 0 1 0 134 113cs_w32_permute218 29 8 211 0 15 99 15cs_w64x_bpermutecs_w64x_permuteSo 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.
python3 -I scripts/run_semantic_tests.py tests/semantic→ 490 files, 6293 tests, 0 failed (8 jobs, 153 s), one file and three tests more than main, which is this PR'stests/semantic/test_ds_permute_eager.py.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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.