[PR #101] rdna2spirv: use subgroup ballot in quad_any for non-PS stages to avoid partial-quad UB #154

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/101
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: old-pr/9833


📝 Commits (1)

  • 833af33 rdna2spirv: use subgroup ballot in quad_any for non-PS stages to avoid partial-quad UB

📊 Changes

2 files changed (+183 additions, -17 deletions)

View changed files

➕ tests/semantic/test_quad_any_partial_quad.py (+154 -0)
📝 tools/rdna2spirv.py (+29 -17)

📄 Description

Carried over from old PR 9833 by Lewandox in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9833, 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):

### Summary
In non-pixel shader stages (CS/VS/etc.), a 4-lane quad can be partially populated (absent/inactive subgroup lanes), where OpGroupNonUniformQuadSwap* has undefined behavior under Vulkan/SPIR-V rules.

This change updates quad_any in ools/rdna2spirv.py to use OpGroupNonUniformBallot masked to the lane's 4-lane quad for non-PS stages, while preserving OpGroupNonUniformQuadSwap* for pixel shaders where full 2x2 quads are guaranteed.

Tests

  • Added ests/semantic/test_quad_any_partial_quad.py (3 tests: CS partial quads, VS partial quads, and PS quad-swap preservation).
  • Verified with:
    • python -m unittest tests.semantic.test_quad_any_partial_quad -v (3/3 OK)
    • python scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_quad_any_partial_quad.py (OK)
  • Synthetic test inputs only; no game data.

🔄 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/101 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/9833` --- ### 📝 Commits (1) - [`833af33`](https://github.com/ubiquitarianism/leonida/commit/833af334973242a2650f7afc28118f07bf0d6341) rdna2spirv: use subgroup ballot in quad_any for non-PS stages to avoid partial-quad UB ### 📊 Changes **2 files changed** (+183 additions, -17 deletions) <details> <summary>View changed files</summary> ➕ `tests/semantic/test_quad_any_partial_quad.py` (+154 -0) 📝 `tools/rdna2spirv.py` (+29 -17) </details> ### 📄 Description > Carried over from **old PR 9833** by `Lewandox` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9833`, 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): ### Summary In non-pixel shader stages (CS/VS/etc.), a 4-lane quad can be partially populated (absent/inactive subgroup lanes), where OpGroupNonUniformQuadSwap* has undefined behavior under Vulkan/SPIR-V rules. This change updates quad_any in ools/rdna2spirv.py to use OpGroupNonUniformBallot masked to the lane's 4-lane quad for non-PS stages, while preserving OpGroupNonUniformQuadSwap* for pixel shaders where full 2x2 quads are guaranteed. ### Tests - Added ests/semantic/test_quad_any_partial_quad.py (3 tests: CS partial quads, VS partial quads, and PS quad-swap preservation). - Verified with: - python -m unittest tests.semantic.test_quad_any_partial_quad -v (3/3 OK) - python scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_quad_any_partial_quad.py (OK) - Synthetic test inputs only; no game data. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#154
No description provided.