rdna2spirv: redirect absent subgroup lanes before OpGroupNonUniformShuffle in ds_permute #97

Closed
Andretuta wants to merge 1 commit from upstream-pr/97 into main
Andretuta commented 2026-11-24 02:17:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:17:24Z.


Carried over from old PR 9829 by Lewandox in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9829, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
Lewandox: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

In Gen.ds_permute() (tools/rdna2spirv.py), the non-emulated subgroup path checked whether each source lane exists via OpGroupNonUniformBallotBitExtract, but still passed the raw src lane ID straight into both OpGroupNonUniformShuffle calls. In a partial wave, shuffling from an absent invocation ID is undefined behavior in Vulkan/SPIR-V even if the result is masked afterward.

Redirect absent source lanes to the current lane before both shuffles (safe_src = OpSelect %uint {ex} {src} {self_lane}), matching ds_lane_read() right above it.

Added a test in tests/semantic/test_ds_permute.py checking all 64 shuffles across wave32 compute, wave64 compute, and fragment shaders use a ballot-guarded lane ID, plus a partial-wave (7 lanes in a 32-wide subgroup) execution check.

Claimed in #9235. AI-assisted; tested on Windows 11 / Python 3.12.10 with python -I -m unittest discover -s tests/semantic -p "test_ds_permute.py" -v (7 OK), spirv_asm.assemble(), python -m compileall -q tools/rdna2spirv.py tests/semantic/test_ds_permute.py, and python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_ds_permute.py (no game files).

Reopened after mass PR cleanup (previously #9257).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5464819855 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/97). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:17:24Z. --- > Carried over from **old PR 9829** by `Lewandox` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9829`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `Lewandox`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): In `Gen.ds_permute()` (`tools/rdna2spirv.py`), the non-emulated subgroup path checked whether each source lane exists via `OpGroupNonUniformBallotBitExtract`, but still passed the raw `src` lane ID straight into both `OpGroupNonUniformShuffle` calls. In a partial wave, shuffling from an absent invocation ID is undefined behavior in Vulkan/SPIR-V even if the result is masked afterward. Redirect absent source lanes to the current lane before both shuffles (`safe_src = OpSelect %uint {ex} {src} {self_lane}`), matching `ds_lane_read()` right above it. Added a test in `tests/semantic/test_ds_permute.py` checking all 64 shuffles across wave32 compute, wave64 compute, and fragment shaders use a ballot-guarded lane ID, plus a partial-wave (`7` lanes in a 32-wide subgroup) execution check. Claimed in `#9235`. AI-assisted; tested on Windows 11 / Python 3.12.10 with `python -I -m unittest discover -s tests/semantic -p "test_ds_permute.py" -v` (7 OK), `spirv_asm.assemble()`, `python -m compileall -q tools/rdna2spirv.py tests/semantic/test_ds_permute.py`, and `python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_ds_permute.py` (no game files). Reopened after mass PR cleanup (previously `#9257`).
aslan2142 commented 2026-11-25 19:09:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T19:09:46Z.


Closing: everything this pull request changes is already in main. Merging it into main (490f5b9ec) leaves every file as it is. The same change landed with #1118.

Thanks for the work! If something here is still missing from main, open a new pull request with what's left.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7171902458 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/97#issuecomment-7171902458). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-25T19:09:46Z. --- Closing: everything this pull request changes is already in `main`. Merging it into `main` (`490f5b9ec`) leaves every file as it is. The same change landed with #1118. Thanks for the work! If something here is still missing from `main`, open a new pull request with what's left. AI-assisted (Claude Code, Claude Opus 5.5).

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!97
No description provided.