[PR #2155] rdna2spirv: --max-mesh-shared-memory checks a mesh shader's Workgroup memory (SHADER-MESH-SHARED-LIMIT) #2160

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2155
Author: @vinceychu
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: shader-mesh-shared-limit


📝 Commits (1)

  • d94d97f rdna2spirv: --max-mesh-shared-memory checks a mesh shader's Workgroup memory (SHADER-MESH-SHARED-LIMIT)

📊 Changes

5 files changed (+230 additions, -4 deletions)

View changed files

📝 docs/d3d12_vulkan.md (+3 -1)
📝 docs/design.md (+1 -1)
➕ tests/semantic/fixtures/ms_shared_limit.asm (+6 -0)
➕ tests/semantic/test_ms_shared_memory_limit.py (+189 -0)
📝 tools/rdna2spirv.py (+31 -2)

📄 Description

Claimed in the coordination issue as: SHADER-MESH-SHARED-LIMIT (#1608)

What and why

docs/design.md listed "mesh shaders against maxMeshSharedMemorySize" as not covered. The translator already caps a
compute shader's Workgroup memory (--max-shared-memory); a MeshEXT module had no equivalent.

  • New --max-mesh-shared-memory BYTES (MAX_MESH_SHARED_BYTES): a MeshEXT module whose Workgroup memory (the LDS
    array, the 4-byte %ms_counts and, under --wave64-emulate, %x_buf, the same total lds_bytes records) is over
    it is refused (Unsupported) with the needed and allowed byte counts, e.g.
    MS workgroup memory 32772 B (LDS 32768 B + %ms_counts 4 B) over maxMeshSharedMemorySize 28672 B.
  • The default is 0: no check. A full 64 KiB LDS array plus %ms_counts is already 65,540 B, so any non-zero
    default would refuse mesh shaders that translate today. Pass a device's limit (28,672 is the
    VK_EXT_mesh_shader minimum) to refuse at translation what that device can't run; the runtime keeps checking
    lds_bytes against the device it runs on either way.
  • A --mesh-compute module is GLCompute, so it keeps the compute cap.
  • design.md's row and the d3d12_vulkan.md note say the same.

Tested

  • tests/semantic/test_ms_shared_memory_limit.py (new, 7 tests, hand-written fixture ms_shared_limit.asm, PSV0
    written in the test): under the cap; over it with the byte counts; the exact boundary (32,772 passes, 32,771
    refuses); %x_buf counted under --wave64-emulate; --mesh-compute uses the compute cap; the default refuses
    nothing (65,540 B translates and lds_bytes carries it); the CLI flag end to end.
  • python -I scripts/run_semantic_tests.py tests/semantic: 494 files, 6,325 tests, 0 failed.
  • pytest tests/test_translate.py: 712 passed; the 2 failures are cs_dpp_cmp.asm with LLVM 21, which fail on main
    too (#1375 fixes the helper).
  • python -m compileall -q tools tests: clean.

GPUs tested: n/a (translator-side check; no GPU path changes)

AI-assisted: yes (Claude Code, with a Devin draft reviewed and changed: the default went from 28,672 to 0 after
the existing test_ms_lds_need.py showed real mesh LDS sizes over the spec minimum)

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.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RAL8MMXUuNpQAVa1iiyAMP


🔄 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/2155 **Author:** [@vinceychu](https://github.com/vinceychu) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `shader-mesh-shared-limit` --- ### 📝 Commits (1) - [`d94d97f`](https://github.com/ubiquitarianism/leonida/commit/d94d97f0a638d2807756458718b4474a41d0b09a) rdna2spirv: --max-mesh-shared-memory checks a mesh shader's Workgroup memory (SHADER-MESH-SHARED-LIMIT) ### 📊 Changes **5 files changed** (+230 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `docs/d3d12_vulkan.md` (+3 -1) 📝 `docs/design.md` (+1 -1) ➕ `tests/semantic/fixtures/ms_shared_limit.asm` (+6 -0) ➕ `tests/semantic/test_ms_shared_memory_limit.py` (+189 -0) 📝 `tools/rdna2spirv.py` (+31 -2) </details> ### 📄 Description Claimed in the coordination issue as: SHADER-MESH-SHARED-LIMIT (#1608) ### What and why `docs/design.md` listed "mesh shaders against `maxMeshSharedMemorySize`" as not covered. The translator already caps a compute shader's Workgroup memory (`--max-shared-memory`); a MeshEXT module had no equivalent. - New `--max-mesh-shared-memory BYTES` (`MAX_MESH_SHARED_BYTES`): a MeshEXT module whose Workgroup memory (the LDS array, the 4-byte `%ms_counts` and, under `--wave64-emulate`, `%x_buf`, the same total `lds_bytes` records) is over it is refused (`Unsupported`) with the needed and allowed byte counts, e.g. `MS workgroup memory 32772 B (LDS 32768 B + %ms_counts 4 B) over maxMeshSharedMemorySize 28672 B`. - **The default is 0: no check.** A full 64 KiB LDS array plus `%ms_counts` is already 65,540 B, so any non-zero default would refuse mesh shaders that translate today. Pass a device's limit (28,672 is the `VK_EXT_mesh_shader` minimum) to refuse at translation what that device can't run; the runtime keeps checking `lds_bytes` against the device it runs on either way. - A `--mesh-compute` module is GLCompute, so it keeps the compute cap. - design.md's row and the d3d12_vulkan.md note say the same. ### Tested - `tests/semantic/test_ms_shared_memory_limit.py` (new, 7 tests, hand-written fixture `ms_shared_limit.asm`, PSV0 written in the test): under the cap; over it with the byte counts; the exact boundary (32,772 passes, 32,771 refuses); `%x_buf` counted under `--wave64-emulate`; `--mesh-compute` uses the compute cap; the default refuses nothing (65,540 B translates and `lds_bytes` carries it); the CLI flag end to end. - `python -I scripts/run_semantic_tests.py tests/semantic`: 494 files, 6,325 tests, 0 failed. - `pytest tests/test_translate.py`: 712 passed; the 2 failures are `cs_dpp_cmp.asm` with LLVM 21, which fail on main too (#1375 fixes the helper). - `python -m compileall -q tools tests`: clean. GPUs tested: n/a (translator-side check; no GPU path changes) AI-assisted: yes (Claude Code, with a Devin draft reviewed and changed: the default went from 28,672 to 0 after the existing `test_ms_lds_need.py` showed real mesh LDS sizes over the spec minimum) ### 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. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01RAL8MMXUuNpQAVa1iiyAMP --- <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#2160
No description provided.