rdna2spirv: redirect absent subgroup lanes before OpGroupNonUniformShuffle in ds_permute (OLD-9829) #1118
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!1118
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1118/head"
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?
@ambroseautomation on GitHub · 2026-11-24 18:49 UTC · original
ambroseautomation:carry/old-9829-ds-permute-guard→main· +38 −4 · 2 files · 1 commits · merged 2026-11-24 22:19 UTCClaimed in the coordination issue as: OLD-9829 (#14)
What and why
Carries forward
old-pr/9829(draft #97, original commit authorLewandoxpreserved; indexed in #17), rebased cleanly onto currentmain.Fixes undefined behavior in
ds_permute(tools/rdna2spirv.py): previously,OpGroupNonUniformShufflereceived raw source lane IDs even for absent invocations in partial waves, masking the result only afterward. In SPIR-V/Vulkan, shuffling from an absent invocation is undefined behavior even if the result is masked. This change redirects absent source lanes to the current invocation's own lane viaOpSelectgated byOpGroupNonUniformBallotBitExtractbeforeOpGroupNonUniformShuffle, matchingds_lane_read.Adds
test_shuffles_redirect_absent_lanes_via_ballot_selectintests/semantic/test_ds_permute.pycovering compute wave32, compute wave64, pixel shaders, and a 7-lane partial-wave execution check.Tested
python -m unittest discover -s tests/semantic -p test_ds_permute.py -v: 7 tests, OK.python -I scripts/run_semantic_tests.py tests/semantic: 470 files, 6,169 tests, 0 files failed.python -m compileall -q make_game.py tools tests: exit 0.python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_ds_permute.py: exit 0 (no game data).GPUs tested: n/a (CPU SPIR-V interpreter semantic suite on Windows 11 Pro 64-bit, Python 3.12.10)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a — UB guard on existingds_permuterule)@abnalstlll-byte on GitHub · 2026-11-24 18:56 UTC · original · approved these changes
Reviewed and verified. Resolves SPIR-V undefined behavior in
ds_permutelowering (tools/rdna2spirv.py) by redirecting absent source lanes to the current invocation lane usingOpSelectgated byOpGroupNonUniformBallotBitExtractbefore callingOpGroupNonUniformShuffle. Verified withtests/semantic/test_ds_permute.py(7/7 PASS) and full semantic suite. 100% clean-room.@KernelSmoker on GitHub · 2026-11-24 19:04 UTC · original · reviewed
Additional independent RTX 3090 check on exact head
2d4dce41e7. passes 7/7. On Bazzite 45 / NVIDIA 620.73.04 / Vulkan 1.4.357 (subgroup 32), the native fixture passed 1/1 with ; passed 1/1 with . Each generated module passed . This exercises partial-wave32 behavior and the wave64 emulation path on NVIDIA; it is not native wave64 or AMD hardware validation.@KernelSmoker on GitHub · 2026-11-24 19:04 UTC · original · reviewed
Correction to my previous review comment: shell expansion removed the test names and outputs there; disregard its blank result fields. The corrected independent RTX 3090 results are: focused test_ds_permute.py suite 7/7; native cs_w32_partial_permute 1/1 with output 0 29 127 0 1 0 134 113; LEONIDA_W64_EMULATE=1 cs_w64x_permute 1/1 with output 218 442 435 239 0 99 239 232. Both generated SPIR-V modules passed spirv-val. Device: Bazzite 45, NVIDIA RTX 3090, driver 620.73.04, Vulkan 1.4.357, subgroup 32. This exercises partial-wave32 and wave64 emulation on NVIDIA; it does not validate native wave64 or AMD hardware.
@madhyn on GitHub · 2026-11-24 19:24 UTC · original
Verified
2d4dce41eon Arch Linux (Python 3.14):PYTHONPATH=tests/semantic python3 -m unittest tests/semantic/test_ds_permute.py: 7 tests passed (1.797 s)AI-assisted: yes
@Deedlyy on GitHub · 2026-11-24 20:16 UTC · original
Recommendation: [MERGE]
Reasoning: Carries #97:
ds_permuteredirects absent lanes beforeOpGroupNonUniformShuffle, removing SPIR-V undefined behaviour in partial waves. Small translator change with a test. Verified by madhyn (7/7) and KernelSmoker on an RTX 3090 (native fixture passes). CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict withmain. Merge once the queued checks are green.Impact level: 4/10
@QemmHD on GitHub · 2026-11-24 22:19 UTC · original
Merging.
Why merged: OLD-9829, carrying forward #97: in the ds_permute lowering, a shuffle from an absent lane is redirected to the lane itself, which removes undefined behaviour from the generated SPIR-V. madhyn and KernelSmoker (RTX 3090) checked it.
Why it's good: test_ds_permute: 7/7.
Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main
4a50cafc7. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 573 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new subprocesses, new env vars or CI changes.AI-assisted (Claude Code, Claude Opus 5.5).