rdna2spirv: redirect absent subgroup lanes before OpGroupNonUniformShuffle in ds_permute (OLD-9829) #1118
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1118
Loading…
Reference in a new issue
No description provided.
Delete branch "carry/old-9829-ds-permute-guard"
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?
Pull request successfully merged and closed
Claimed in the coordination issue as: OLD-9829 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140912852)
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)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.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
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
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).