[PR #802] [MERGED] rdna2spirv: list %ms_cull before %ms_out_vtx in OpEntryPoint MeshEXT (AMD LLPC crash, SHADER-MS-CLIP-IFACE) #841

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

📋 Pull Request Information

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

Base: main ← Head: shader-ms-clip-iface


📝 Commits (2)

  • 355fe0c rdna2spirv: list %ms_cull before %ms_out_vtx in OpEntryPoint MeshEXT (AMD Windows LLPC crash)
  • 052883f docs: the mesh interface order crash is one driver report, not every AMD driver

📊 Changes

3 files changed (+17 additions, -2 deletions)

View changed files

📝 docs/design.md (+1 -1)
📝 tests/test_translate.py (+11 -0)
📝 tools/rdna2spirv.py (+5 -1)

📄 Description

Claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7133575269 (SHADER-MS-CLIP-IFACE)

Problem

On AMD's proprietary Windows Vulkan driver (24.10.24, LLPC, AMD Ryzen 5 7600 RDNA2 iGPU), ms_clip segfaults (0xC0000005) during vkCreateGraphicsPipelines inside amdvlk64.dll.

Bisecting the SPIR-V (including compiling an equivalent GLSL mesh shader with glslangValidator) narrowed the trigger to a single condition: AMD Windows LLPC crashes whenever a MeshEXT shader lists a Block-decorated vertex output struct containing BuiltIn ClipDistance / CullDistance (%ms_out_vtx) before the Block-decorated PerPrimitiveEXT BuiltIn CullPrimitiveEXT output (%ms_cull) in OpEntryPoint's interface list. Even glslangValidator's own output (gl_MeshVerticesEXT before gl_MeshPrimitivesEXT) triggers the exact same 0xC0000005 crash.

Fix

  • tools/rdna2spirv.py (assemble): list %ms_cull before %ms_out_vtx / %ms_out_pos in OpEntryPoint MeshEXT's interface list. Keeps %ms_cull_blk as Block+bool so SPIRV-Tools ≤2025.1 (SHADER-30), test_mesh_cull_primitive_is_block_bool, test_mesh_cull_store, and SPIRV-Cross/Metal remain completely unchanged.
  • tests/test_translate.py: adds test_mesh_cull_precedes_clip_vertex_block_in_entrypoint.
  • docs/design.md: documents the rule in the Mesh shaders contract row.

Verification (before/after on main 47c651174, LEONIDA_VK_VALIDATION=1)

  • AMD Radeon(TM) Graphics (Ryzen 5 7600 RDNA2 iGPU, Windows 11, driver 24.10.24, 128B push constants, LEONIDA_PC_TAIL_UBO=1):
    • Before (main): ms_clip FAIL (vk_harness crash 0xC0000005)
    • After: ms_clip PASS (2048/4096 pixels covered, 0 validation errors), ms_tri PASS (4096/4096 pixels exact); also verified ClipDistance + CullDistance combined (2048/2048 clipped, 2048/2048 drawn) and CullPrimitiveEXT = true (4096/4096 culled).
  • NVIDIA GeForce RTX 4070 SUPER (Windows 11, driver 610.88):
    • --filter ms_ with LEONIDA_VK_VALIDATION=1: 5/6 passed, 1 skipped (ms_clip 2048/4096, ms_f16_pack, ms_tri, ms_v5_workgroup, ms_wave_info_s3; ms_w64x_ballot skipped on 32-wide), 0 validation errors; CullPrimitiveEXT = true verified 4096/4096 culled.
  • CPU / unit tests:
    • pytest tests/test_translate.py -k "mesh or clip" — 21 passed
    • unittest discover -s tests/semantic -p "test_ms_*.py" — 6 passed
    • unittest discover -s tests/semantic -p "test_mesh_*.py" — 2 passed
    • python -I tests/test_text_write_line_endings.py — 3 passed

AI-assisted (Gemini 4 Neon).


🔄 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/802 **Author:** [@whoalin1](https://github.com/whoalin1) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `shader-ms-clip-iface` --- ### 📝 Commits (2) - [`355fe0c`](https://github.com/ubiquitarianism/leonida/commit/355fe0c62e81ec245d8b927c7b27f904facba892) rdna2spirv: list %ms_cull before %ms_out_vtx in OpEntryPoint MeshEXT (AMD Windows LLPC crash) - [`052883f`](https://github.com/ubiquitarianism/leonida/commit/052883fba8d2a5cb8ed3924a528bd785cbbd6292) docs: the mesh interface order crash is one driver report, not every AMD driver ### 📊 Changes **3 files changed** (+17 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -1) 📝 `tests/test_translate.py` (+11 -0) 📝 `tools/rdna2spirv.py` (+5 -1) </details> ### 📄 Description Claim: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7133575269 (`SHADER-MS-CLIP-IFACE`) ### Problem On AMD's proprietary Windows Vulkan driver (`24.10.24`, LLPC, AMD Ryzen 5 7600 RDNA2 iGPU), `ms_clip` segfaults (`0xC0000005`) during `vkCreateGraphicsPipelines` inside `amdvlk64.dll`. Bisecting the SPIR-V (including compiling an equivalent GLSL mesh shader with `glslangValidator`) narrowed the trigger to a single condition: AMD Windows LLPC crashes whenever a `MeshEXT` shader lists a `Block`-decorated vertex output struct containing `BuiltIn ClipDistance` / `CullDistance` (`%ms_out_vtx`) **before** the `Block`-decorated `PerPrimitiveEXT` `BuiltIn CullPrimitiveEXT` output (`%ms_cull`) in `OpEntryPoint`'s interface list. Even `glslangValidator`'s own output (`gl_MeshVerticesEXT` before `gl_MeshPrimitivesEXT`) triggers the exact same `0xC0000005` crash. ### Fix - `tools/rdna2spirv.py` (`assemble`): list `%ms_cull` before `%ms_out_vtx` / `%ms_out_pos` in `OpEntryPoint MeshEXT`'s interface list. Keeps `%ms_cull_blk` as `Block+bool` so SPIRV-Tools ≤2025.1 (`SHADER-30`), `test_mesh_cull_primitive_is_block_bool`, `test_mesh_cull_store`, and SPIRV-Cross/Metal remain completely unchanged. - `tests/test_translate.py`: adds `test_mesh_cull_precedes_clip_vertex_block_in_entrypoint`. - `docs/design.md`: documents the rule in the Mesh shaders contract row. ### Verification (before/after on `main` `47c651174`, `LEONIDA_VK_VALIDATION=1`) - **AMD Radeon(TM) Graphics (Ryzen 5 7600 RDNA2 iGPU, Windows 11, driver 24.10.24, 128B push constants, `LEONIDA_PC_TAIL_UBO=1`)**: - Before (`main`): `ms_clip` **FAIL** (`vk_harness` crash `0xC0000005`) - After: `ms_clip` **PASS** (`2048/4096 pixels covered`, 0 validation errors), `ms_tri` **PASS** (`4096/4096 pixels exact`); also verified `ClipDistance + CullDistance` combined (`2048/2048` clipped, `2048/2048` drawn) and `CullPrimitiveEXT = true` (`4096/4096` culled). - **NVIDIA GeForce RTX 4070 SUPER (Windows 11, driver 610.88)**: - `--filter ms_` with `LEONIDA_VK_VALIDATION=1`: **5/6 passed, 1 skipped** (`ms_clip` `2048/4096`, `ms_f16_pack`, `ms_tri`, `ms_v5_workgroup`, `ms_wave_info_s3`; `ms_w64x_ballot` skipped on 32-wide), 0 validation errors; `CullPrimitiveEXT = true` verified `4096/4096` culled. - **CPU / unit tests**: - `pytest tests/test_translate.py -k "mesh or clip"` — **21 passed** - `unittest discover -s tests/semantic -p "test_ms_*.py"` — **6 passed** - `unittest discover -s tests/semantic -p "test_mesh_*.py"` — **2 passed** - `python -I tests/test_text_write_line_endings.py` — **3 passed** AI-assisted (Gemini 4 Neon). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:13 +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#841
No description provided.