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

Merged
whoalin1 merged 2 commits from upstream-pr/802 into main 2026-11-25 02:46:59 +00:00
whoalin1 commented 2026-11-24 14:00:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-24T14:00:28Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5473593596 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/802). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-24T14:00:28Z. --- 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).
towade commented 2026-11-24 18:22:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by towade on 2026-11-24T18:22:03Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7140544135 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/802#issuecomment-7140544135). Originally posted by [towade](https://github.com/towade) on 2026-11-24T18:22:03Z. --- 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 commented 2026-11-24 18:42:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by towade on 2026-11-24T18:42:21Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7141033832 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/802#issuecomment-7141033832). Originally posted by [towade](https://github.com/towade) on 2026-11-24T18:42:21Z. --- 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).
adrianmjim commented 2026-11-24 21:42:50 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by adrianmjim on 2026-11-24T21:42:50Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7145291135 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/802#issuecomment-7145291135). Originally posted by [adrianmjim](https://github.com/adrianmjim) on 2026-11-24T21:42:50Z. --- 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.
aslan2142 commented 2026-11-25 02:47:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T02:47:02Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7151182035 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/802#issuecomment-7151182035). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-25T02:47:02Z. --- 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).
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!802
No description provided.