[PR #162] rdna2spirv: a mesh shader exp pos1 writes Layer and ViewportIndex per primitive #214

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

📋 Pull Request Information

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

Base: main ← Head: old-pr/9893


📝 Commits (1)

  • d3a4d17 fix: mesh shader pos1 misc export writes Layer and ViewportIndex per primitive (rdna2spirv)

📊 Changes

2 files changed (+97 additions, -25 deletions)

View changed files

📝 tests/test_translate.py (+48 -0)
📝 tools/rdna2spirv.py (+49 -25)

📄 Description

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

What

A mesh shader that exports the misc vector at exp pos1 (z[10:0] = Layer, z[19:16] = ViewportIndex) now writes Layer and ViewportIndex as per-primitive mesh outputs (PerPrimitiveEXT members of the primitive block). Before, the pos1 export was staged as if it were an ordinary position and the Layer/ViewportIndex values were lost. The VS/NGG path shares the new export_misc_pos1 helper, so its output is unchanged. ShaderLayer/ShaderViewportIndex capabilities are skipped for mesh shaders (the builtins are part of MeshShadingEXT).

Why

Shaders that render into layered targets or multiple viewports through the mesh path would draw everything into layer 0 / viewport 0, breaking 3D rendering for those draws.

Tested

  • python3 -m pytest tests/test_translate.py: 666 passed (113 s), including 3 new tests: layer+viewport per primitive, layer only (no viewport member), and no misc outputs keeps the plain primitive block.
  • Negative control: with tools/rdna2spirv.py taken from origin/main, 2 of the 3 new tests fail (the third guards that nothing changes without misc outputs, and passes on both).
  • Not run: GPU/lavapipe validation of the emitted module (pods are off); the tests assert on the generated SPIR-V.

Rebased cleanly on current main (the cherry-pick applied without conflicts). Our earlier PR for this was not opened before the org migration, so there is nothing to supersede.


🔄 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/162 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/9893` --- ### 📝 Commits (1) - [`d3a4d17`](https://github.com/ubiquitarianism/leonida/commit/d3a4d1733bf1bd03db387b0a2bded31e70945264) fix: mesh shader pos1 misc export writes Layer and ViewportIndex per primitive (rdna2spirv) ### 📊 Changes **2 files changed** (+97 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_translate.py` (+48 -0) 📝 `tools/rdna2spirv.py` (+49 -25) </details> ### 📄 Description > Carried over from **old PR 9893** by `tedin7` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9893`, 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. > `tedin7`: 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): ## What A mesh shader that exports the misc vector at `exp pos1` (z[10:0] = Layer, z[19:16] = ViewportIndex) now writes Layer and ViewportIndex as per-primitive mesh outputs (`PerPrimitiveEXT` members of the primitive block). Before, the pos1 export was staged as if it were an ordinary position and the Layer/ViewportIndex values were lost. The VS/NGG path shares the new `export_misc_pos1` helper, so its output is unchanged. `ShaderLayer`/`ShaderViewportIndex` capabilities are skipped for mesh shaders (the builtins are part of MeshShadingEXT). ## Why Shaders that render into layered targets or multiple viewports through the mesh path would draw everything into layer 0 / viewport 0, breaking 3D rendering for those draws. ## Tested - `python3 -m pytest tests/test_translate.py`: 666 passed (113 s), including 3 new tests: layer+viewport per primitive, layer only (no viewport member), and no misc outputs keeps the plain primitive block. - Negative control: with `tools/rdna2spirv.py` taken from origin/main, 2 of the 3 new tests fail (the third guards that nothing changes without misc outputs, and passes on both). - Not run: GPU/lavapipe validation of the emitted module (pods are off); the tests assert on the generated SPIR-V. Rebased cleanly on current main (the cherry-pick applied without conflicts). Our earlier PR for this was not opened before the org migration, so there is nothing to supersede. --- <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#214
No description provided.