[PR #97] [CLOSED] rdna2spirv: redirect absent subgroup lanes before OpGroupNonUniformShuffle in ds_permute #149

Closed
opened 2026-11-26 20:16:57 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/97
Author: @Andretuta
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: old-pr/9829


📝 Commits (1)

  • 1d9f451 rdna2spirv: redirect absent subgroup lanes before OpGroupNonUniformShuffle in ds_permute

📊 Changes

2 files changed (+38 additions, -4 deletions)

View changed files

📝 tests/semantic/test_ds_permute.py (+30 -0)
📝 tools/rdna2spirv.py (+8 -4)

📄 Description

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).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/97 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `old-pr/9829` --- ### 📝 Commits (1) - [`1d9f451`](https://github.com/ubiquitarianism/leonida/commit/1d9f45188fd2d2745628a725d978e12c946cc6f7) rdna2spirv: redirect absent subgroup lanes before OpGroupNonUniformShuffle in ds_permute ### 📊 Changes **2 files changed** (+38 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `tests/semantic/test_ds_permute.py` (+30 -0) 📝 `tools/rdna2spirv.py` (+8 -4) </details> ### 📄 Description > 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`). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:16:57 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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
starred/leonida#149
No description provided.