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

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

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


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.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5464826515 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/101). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:18:01Z. --- > 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.
MoonEyes commented 2026-11-30 18:39:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T18:39:59Z.


Closing as superseded: current main already uses ballot-based handling for non-fragment stages in Gen.quad_any, and tests/semantic/test_absent_lane_ub.py covers partial VS/CS quads. This draft's implementation and regression test are redundant; all checks on this head were cancelled.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7288186339 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/101#issuecomment-7288186339). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-30T18:39:59Z. --- Closing as superseded: current main already uses ballot-based handling for non-fragment stages in Gen.quad_any, and tests/semantic/test_absent_lane_ub.py covers partial VS/CS quads. This draft's implementation and regression test are redundant; all checks on this head were cancelled.

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!101
No description provided.