[PR #1118] [MERGED] rdna2spirv: redirect absent subgroup lanes before OpGroupNonUniformShuffle in ds_permute (OLD-9829) #1153

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1118
Author: @ambroseautomation
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @QemmHD

Base: main ← Head: carry/old-9829-ds-permute-guard


📝 Commits (1)

  • 2d4dce4 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

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 author Lewandox preserved; indexed in #17), rebased cleanly onto current main.

Fixes undefined behavior in ds_permute (tools/rdna2spirv.py): previously, OpGroupNonUniformShuffle received 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 via OpSelect gated by OpGroupNonUniformBallotBitExtract before OpGroupNonUniformShuffle, matching ds_lane_read.

Adds test_shuffles_redirect_absent_lanes_via_ballot_select in tests/semantic/test_ds_permute.py covering 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

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a — UB guard on existing ds_permute rule)

🔄 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/1118 **Author:** [@ambroseautomation](https://github.com/ambroseautomation) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@QemmHD](https://github.com/QemmHD) **Base:** `main` ← **Head:** `carry/old-9829-ds-permute-guard` --- ### 📝 Commits (1) - [`2d4dce4`](https://github.com/ubiquitarianism/leonida/commit/2d4dce41e751d55dfc88b20b60ae511e98d473c5) 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 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 author `Lewandox` preserved; indexed in #17), rebased cleanly onto current `main`. Fixes undefined behavior in `ds_permute` (`tools/rdna2spirv.py`): previously, `OpGroupNonUniformShuffle` received 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 via `OpSelect` gated by `OpGroupNonUniformBallotBitExtract` before `OpGroupNonUniformShuffle`, matching `ds_lane_read`. Adds `test_shuffles_redirect_absent_lanes_via_ballot_select` in `tests/semantic/test_ds_permute.py` covering 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 - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a — UB guard on existing `ds_permute` rule) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:20:16 +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#1153
No description provided.