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

Manually merged
github merged 3 commits from gh-pr/1197/head into gh-pr/1197/base 2026-11-26 09:42:33 +00:00
Owner

@⁠ambroseautomation on GitHub · 2026-11-24 20:01 UTC · original
ambroseautomation:carry/old-9893-ms-pos1-layer-viewport → main · +98 −26 · 3 files · 3 commits · merged 2026-11-25 03:12 UTC

Claimed in the coordination issue as: OLD-9893 (#14)

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)
**@⁠ambroseautomation** on GitHub · 2026-11-24 20:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1197) `ambroseautomation:carry/old-9893-ms-pos1-layer-viewport` → `main` · +98 −26 · 3 files · 3 commits · merged 2026-11-25 03:12 UTC Claimed in the coordination issue as: OLD-9893 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### 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)
Add the rule this pull request introduces to the "Mesh shaders" row of
docs/design.md: Layer and ViewportIndex from the pos1 misc vector become
per-primitive members of %ms_cull, each lane writing the primitive with
its own index. That is exact when the value is the same for all vertices
of a primitive; whether the hardware takes the provoking vertex's value
instead is not measured. None of the 1,906 mesh shaders of the
maintainer's corpus that export pos1 writes either output.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:42:29 +00:00
github manually merged commit e950f8582f into gh-pr/1197/base 2026-11-26 09:42:33 +00:00
Author
Owner

@⁠Deedlyy on GitHub · 2026-11-24 20:07 UTC · original

Recommendation: [MERGE]

Reasoning: Carries #162: mesh shaders decode Layer and ViewportIndex from the exp pos1 misc export and write them as per-primitive outputs when OSG1 declares them. Focused translator change with a translate test. No independent GPU run yet, but the change only takes effect when the outputs are declared. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 4/10

**@⁠Deedlyy** on GitHub · 2026-11-24 20:07 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1197#issuecomment-7143083502) **Recommendation:** [MERGE] **Reasoning:** Carries #162: mesh shaders decode `Layer` and `ViewportIndex` from the `exp pos1` misc export and write them as per-primitive outputs when `OSG1` declares them. Focused translator change with a translate test. No independent GPU run yet, but the change only takes effect when the outputs are declared. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. Merge once the queued checks are green. **Impact level:** 4/10
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 03:12 UTC · original

Merged, after merging main into it. Thanks.

  • Claim: OLD-9893, valid, before this PR; the only claim for the item.
  • One docs commit added before merging: the contract row for the rule, in the "Mesh shaders" row of docs/design.md. It states one open point as a hypothesis: each lane writes the primitive with its own index, which is exact when the value is the same for all vertices of a primitive; whether the hardware takes the provoking vertex's value instead is not measured.
  • On the maintainer's own shader corpus (counts only): none of the 1,906 mesh shaders that export pos1 writes Layer or ViewportIndex under this translation, so the game's mesh shaders only gain three unused declarations each.
  • Next: #1203 (OLD-9921) depends on this; its one conflict with it, in mesh_export, is resolved next by keeping both: the misc-vector return first, then the compressed components.
  • Checked on main b07b9ecb0 + e950f8582: the semantic suite passes (487 files, 6,279 tests, 0 files failed); test_translate (pytest; 2 failing as on main) pass; the 14 docs and writer tests pass; check_no_game_data.py is clean on the 3 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 03:12 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1197#issuecomment-7151699379) Merged, after merging `main` into it. Thanks. - **Claim:** `OLD-9893`, valid, before this PR; the only claim for the item. - **One docs commit added before merging:** the contract row for the rule, in the "Mesh shaders" row of `docs/design.md`. It states one open point as a hypothesis: each lane writes the primitive with its own index, which is exact when the value is the same for all vertices of a primitive; whether the hardware takes the provoking vertex's value instead is not measured. - **On the maintainer's own shader corpus (counts only):** none of the 1,906 mesh shaders that export `pos1` writes `Layer` or `ViewportIndex` under this translation, so the game's mesh shaders only gain three unused declarations each. - **Next:** #1203 (`OLD-9921`) depends on this; its one conflict with it, in `mesh_export`, is resolved next by keeping both: the misc-vector return first, then the compressed components. - **Checked on `main` `b07b9ecb0` + `e950f8582`:** the semantic suite passes (487 files, 6,279 tests, 0 files failed); `test_translate (pytest; 2 failing as on main)` pass; the 14 docs and writer tests pass; `check_no_game_data.py` is clean on the 3 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.