[PR #1197] [MERGED] rdna2spirv: mesh shader pos1 misc export writes Layer and ViewportIndex per primitive (OLD-9893) #1229

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

📋 Pull Request Information

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

Base: main ← Head: carry/old-9893-ms-pos1-layer-viewport


📝 Commits (3)

  • c48cc23 fix: mesh shader pos1 misc export writes Layer and ViewportIndex per primitive (rdna2spirv)
  • 2fc4224 Merge commit 'b07b9ecb0' into HEAD
  • e950f85 docs: contract row for mesh-shader Layer and ViewportIndex

📊 Changes

3 files changed (+98 additions, -26 deletions)

View changed files

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

📄 Description

Claimed in the coordination issue as: OLD-9893 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7142685828)

What and why

Carries forward old-pr/9893 (draft #162, original commit author tedin7 preserved; indexed in #17), rebased cleanly onto current main.

Implements per-primitive Layer and ViewportIndex mesh shader outputs from exp pos1 misc vector exports in tools/rdna2spirv.py:

  • When OSG1 declares SV_RenderTargetArrayIndex (Layer) and/or SV_ViewportArrayIndex (ViewportIndex), decodes z[10:0] (Layer) and (z >> 16) & 0xF (ViewportIndex) from exp pos1 into %ms_layer / %ms_viewport and writes them into per-primitive members of %ms_cull_blk (BuiltIn Layer, BuiltIn ViewportIndex, PerPrimitiveEXT), emitting OpCapability ShaderLayer / OpCapability ShaderViewportIndex and reporting shaderOutputLayer / shaderOutputViewportIndex in shader metadata.
  • Adds 3 unit tests in tests/test_translate.py: test_ms_misc_pos1_exports_layer_and_viewport_per_primitive, test_ms_misc_pos1_layer_only_has_no_viewport_member, and test_ms_without_misc_outputs_keeps_plain_primitive_block.

Tested

  • Executed all 3 new tests/test_translate.py functions directly via rdna2spirv.translate and verified SPIR-V binary assembly via spirv_asm.assemble (no llvm-mc/spirv-val installed on host): 3/3 PASS.
  • python -I scripts/run_semantic_tests.py tests/semantic: 470 files, 6,168 tests, 0 files failed.
  • python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/test_translate.py: exit 0 (no game data).

GPUs tested: n/a (CPU SPIR-V interpreter semantic suite + in-process spirv_asm assembly 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. (extends existing mesh shader pos1 export lowering)

🔄 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/1197 **Author:** [@ambroseautomation](https://github.com/ambroseautomation) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `carry/old-9893-ms-pos1-layer-viewport` --- ### 📝 Commits (3) - [`c48cc23`](https://github.com/ubiquitarianism/leonida/commit/c48cc2353abddb82a81e5cbac342ca81bac6fadf) fix: mesh shader pos1 misc export writes Layer and ViewportIndex per primitive (rdna2spirv) - [`2fc4224`](https://github.com/ubiquitarianism/leonida/commit/2fc4224cda37257071fdf05ecdb5d29b5af31862) Merge commit 'b07b9ecb0' into HEAD - [`e950f85`](https://github.com/ubiquitarianism/leonida/commit/e950f8582f883fb6ef8427ae5af1679b8897d203) docs: contract row for mesh-shader Layer and ViewportIndex ### 📊 Changes **3 files changed** (+98 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) 📝 `tests/test_translate.py` (+48 -0) 📝 `tools/rdna2spirv.py` (+49 -25) </details> ### 📄 Description Claimed in the coordination issue as: OLD-9893 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7142685828) ### What and why Carries forward `old-pr/9893` (draft #162, original commit author `tedin7` preserved; indexed in #17), rebased cleanly onto current `main`. Implements per-primitive `Layer` and `ViewportIndex` mesh shader outputs from `exp pos1` misc vector exports in `tools/rdna2spirv.py`: - When `OSG1` declares `SV_RenderTargetArrayIndex` (`Layer`) and/or `SV_ViewportArrayIndex` (`ViewportIndex`), decodes `z[10:0]` (`Layer`) and `(z >> 16) & 0xF` (`ViewportIndex`) from `exp pos1` into `%ms_layer` / `%ms_viewport` and writes them into per-primitive members of `%ms_cull_blk` (`BuiltIn Layer`, `BuiltIn ViewportIndex`, `PerPrimitiveEXT`), emitting `OpCapability ShaderLayer` / `OpCapability ShaderViewportIndex` and reporting `shaderOutputLayer` / `shaderOutputViewportIndex` in shader metadata. - Adds 3 unit tests in `tests/test_translate.py`: `test_ms_misc_pos1_exports_layer_and_viewport_per_primitive`, `test_ms_misc_pos1_layer_only_has_no_viewport_member`, and `test_ms_without_misc_outputs_keeps_plain_primitive_block`. ### Tested - Executed all 3 new `tests/test_translate.py` functions directly via `rdna2spirv.translate` and verified SPIR-V binary assembly via `spirv_asm.assemble` (no `llvm-mc`/`spirv-val` installed on host): 3/3 PASS. - `python -I scripts/run_semantic_tests.py tests/semantic`: 470 files, 6,168 tests, 0 files failed. - `python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/test_translate.py`: exit 0 (no game data). GPUs tested: n/a (CPU SPIR-V interpreter semantic suite + in-process `spirv_asm` assembly 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. (extends existing mesh shader `pos1` export lowering) --- <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:31 +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#1229
No description provided.