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

Manually merged
github merged 2 commits from gh-pr/802/head into gh-pr/802/base 2026-11-26 09:22:00 +00:00
Owner

@⁠whoalin1 on GitHub · 2026-11-24 14:00 UTC · original
whoalin1:shader-ms-clip-iface → main · +17 −2 · 3 files · 2 commits · merged 2026-11-25 02:46 UTC

Claim: #14 (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).

**@⁠whoalin1** on GitHub · 2026-11-24 14:00 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/802) `whoalin1:shader-ms-clip-iface` → `main` · +17 −2 · 3 files · 2 commits · merged 2026-11-25 02:46 UTC Claim: https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14 (`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).
AMD's proprietary Windows Vulkan driver (24.10.24, LLPC) segfaults (0xC0000005) during vkCreateGraphicsPipelines whenever a MeshEXT shader lists a Block-decorated per-vertex output struct with ClipDistance/CullDistance (%ms_out_vtx) before the Block-decorated PerPrimitiveEXT CullPrimitiveEXT output (%ms_cull) in OpEntryPoint's interface list (even glslangValidator's own GLSL output with gl_ClipDistance + gl_CullPrimitiveEXT hits the same crash).

Listing %ms_cull before %ms_out_vtx/%ms_out_pos in OpEntryPoint fixes ms_clip on AMD Windows RDNA2 (0xC0000005 -> 2048/4096 covered pixels exact, 0 validation errors) while keeping %ms_cull_blk in its Block+bool form required by SPIRV-Tools <=2025.1 (SHADER-30).

SHADER-MS-CLIP-IFACE

Co-Authored-By: Gemini 4 Neon <[email protected]>
The contract row stated the LLPC crash as a general fact. It was seen on
driver 24.10.24 on one Ryzen 5 7600 iGPU; driver 32.0.32029.2010 on an RX
9070 XT and an RX 7900 XT accepts either order. Say so, and that the order
costs nothing elsewhere because it has no meaning in SPIR-V.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:21:57 +00:00
github manually merged commit 052883fba8 into gh-pr/802/base 2026-11-26 09:22:00 +00:00
Author
Owner

@⁠towade on GitHub · 2026-11-24 18:22 UTC · original

checked: 07837d80c (the same patch as the current head a5c8f43d0, per git range-diff; only the base moved) on RDNA4, as a regression check: AMD Radeon RX 9070 XT (gfx1201, AMD Windows driver 32.0.32029.2010, LLPC), Windows 11 26300, main 3aa975421 with this PR merged, scripts/run_gpu_tests.py with llvm-mc 21.1.8.

  • ms_clip: passes on main and with this PR, native and with LEONIDA_W64_EMULATE=1 (2048/2048 pixels covered). This driver does not crash on main's interface order, so I can't confirm the fix itself here, only that the new order is fine on RDNA4 too.
  • Full GPU suite, native: 207 pass, 16 skipped, identical test by test on main and with this PR; no test fails for another reason. 29 pixel-shader tests did not run because I had not built vk_texture_test, vk_bindless_test and vk_sampler_test. They don't involve mesh shaders.

AI-assisted (Claude Code).

**@⁠towade** on GitHub · 2026-11-24 18:22 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/802#issuecomment-7140544135) checked: `07837d80c` (the same patch as the current head `a5c8f43d0`, per `git range-diff`; only the base moved) on RDNA4, as a regression check: **AMD Radeon RX 9070 XT** (gfx1201, AMD Windows driver 32.0.32029.2010, LLPC), Windows 11 26300, `main` `3aa975421` with this PR merged, `scripts/run_gpu_tests.py` with `llvm-mc` 21.1.8. - `ms_clip`: passes on `main` and with this PR, native and with `LEONIDA_W64_EMULATE=1` (2048/2048 pixels covered). This driver does not crash on `main`'s interface order, so I can't confirm the fix itself here, only that the new order is fine on RDNA4 too. - Full GPU suite, native: 207 pass, 16 skipped, **identical test by test** on `main` and with this PR; no test fails for another reason. 29 pixel-shader tests did not run because I had not built `vk_texture_test`, `vk_bindless_test` and `vk_sampler_test`. They don't involve mesh shaders. AI-assisted (Claude Code).
Author
Owner

@⁠towade on GitHub · 2026-11-24 18:42 UTC · original

Follow-up to my check above: I built vk_texture_test, vk_bindless_test and vk_sampler_test and ran the full GPU suite again, natively on the same RX 9070 XT (AMD 32.0.32029.2010), on main 3aa975421 and with this PR merged. Result: 236 of 252 pass, 16 skipped, 0 fail on both, identical test by test, so the 29 pixel-shader tests that had not run pass too.

AI-assisted (Claude Code).

**@⁠towade** on GitHub · 2026-11-24 18:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/802#issuecomment-7141033832) Follow-up to my check above: I built `vk_texture_test`, `vk_bindless_test` and `vk_sampler_test` and ran the full GPU suite again, natively on the same RX 9070 XT (AMD 32.0.32029.2010), on `main` `3aa975421` and with this PR merged. Result: **236 of 252 pass, 16 skipped, 0 fail** on both, identical test by test, so the 29 pixel-shader tests that had not run pass too. AI-assisted (Claude Code).
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-24 21:42 UTC · original

Tested a5c8f43d0 applied onto main 66d4f5aa3 on an AMD Radeon RX 7900 XT (RDNA3, gfx1100), AMD proprietary driver 32.0.32029.2010 (26.11.2), Windows 11 build 26300, Vulkan SDK 1.4.363.0, llvm-mc 23.1.5. I used the test programs from a main 66d4f5aa3 build. No game files.

python -I scripts/run_gpu_tests.py --filter ms_, native mesh path:

fixture main this PR
ms_clip PASS, 2048/4096 pixels covered (expected 2048) PASS, the same
ms_f16_pack PASS PASS
ms_tri PASS PASS
ms_v5_workgroup PASS PASS
ms_w64x_ballot PASS PASS
ms_wave_info_s3 PASS PASS

The LLPC crash in ms_clip does not reproduce on this card and driver: main already creates the pipeline and draws the expected coverage. The reorder changes nothing visible here and breaks none of the six mesh fixtures. That adds an RDNA3 data point next to the gfx1036 crash and the RX 9070 XT regression check.

**@⁠adrianmjim** on GitHub · 2026-11-24 21:42 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/802#issuecomment-7145291135) Tested a5c8f43d0 applied onto main 66d4f5aa3 on an AMD Radeon RX 7900 XT (RDNA3, gfx1100), AMD proprietary driver 32.0.32029.2010 (26.11.2), Windows 11 build 26300, Vulkan SDK 1.4.363.0, llvm-mc 23.1.5. I used the test programs from a `main` `66d4f5aa3` build. No game files. `python -I scripts/run_gpu_tests.py --filter ms_`, native mesh path: | fixture | main | this PR | |---|---|---| | `ms_clip` | PASS, 2048/4096 pixels covered (expected 2048) | PASS, the same | | `ms_f16_pack` | PASS | PASS | | `ms_tri` | PASS | PASS | | `ms_v5_workgroup` | PASS | PASS | | `ms_w64x_ballot` | PASS | PASS | | `ms_wave_info_s3` | PASS | PASS | The LLPC crash in `ms_clip` does not reproduce on this card and driver: `main` already creates the pipeline and draws the expected coverage. The reorder changes nothing visible here and breaks none of the six mesh fixtures. That adds an RDNA3 data point next to the gfx1036 crash and the RX 9070 XT regression check.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 02:47 UTC · original

Merged. Thanks: the reorder is free on every driver and fixes the one where it crashed.

  • Claim: SHADER-MS-CLIP-IFACE, valid, four minutes before this PR.
  • One docs commit added before merging: the contract row now says the vkCreateGraphicsPipelines crash was reported on driver 24.10.24 on one Ryzen 5 7600 iGPU, while driver 32.0.32029.2010 on an RX 9070 XT and an RX 7900 XT accepts either order, instead of stating it for every AMD driver. The interface order has no meaning in SPIR-V, so listing %ms_cull first costs nothing elsewhere.
  • Tests: the new test fails on main and passes with the change.
  • On the user's own shader corpus (counts only): 1,906 of the 9,282 mesh shaders use clip exports; a slice of 120 translates and validates in full both before and after, and all 120 modules change.
  • Checked on main 2213d5cb8 + 052883fba: the semantic suite passes (486 files, 6,275 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 02:47 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/802#issuecomment-7151182035) Merged. Thanks: the reorder is free on every driver and fixes the one where it crashed. - **Claim:** `SHADER-MS-CLIP-IFACE`, valid, four minutes before this PR. - **One docs commit added before merging:** the contract row now says the `vkCreateGraphicsPipelines` crash was reported on driver `24.10.24` on one Ryzen 5 7600 iGPU, while driver `32.0.32029.2010` on an RX 9070 XT and an RX 7900 XT accepts either order, instead of stating it for every AMD driver. The interface order has no meaning in SPIR-V, so listing `%ms_cull` first costs nothing elsewhere. - **Tests:** the new test fails on `main` and passes with the change. - **On the user's own shader corpus (counts only):** 1,906 of the 9,282 mesh shaders use clip exports; a slice of 120 translates and validates in full both before and after, and all 120 modules change. - **Checked on `main` `2213d5cb8` + `052883fba`:** the semantic suite passes (486 files, 6,275 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.