Skip to content

rdna2spirv: mesh clip and cull distances as standalone arrayed outputs, not a per-vertex Block (AMD 24.10.24 crash in ms_clip) - #8097

Open
SpaghettiMaster545 wants to merge 1 commit into
ItsNotRexed:mainfrom
SpaghettiMaster545:ms-clip-standalone
Open

SpaghettiMaster545 wants to merge 1 commit into
ItsNotRexed:mainfrom
SpaghettiMaster545:ms-clip-standalone

Conversation

@SpaghettiMaster545

Copy link
Copy Markdown

Finding and claim: #7913.

What and why

On AMD's Windows driver 24.10.24 (Vulkan driver 2.0.302), ms_clip crashes the driver's shader compiler. vk_harness dies with an access violation (0xC0000005), and VK_LAYER_LUNARG_api_dump shows vkCreateGraphicsPipelines never returning. With clip or cull distances, the translator writes Position, ClipDistance and CullDistance as members of one arrayed per-vertex output Block (%ms_vtx_blk, added in 79b3542). Without them, Position is already a standalone arrayed built-in (%ms_out_pos).

To narrow it down, I hand-edited the translated ms_clip module. Every variant is spirv-val clean, run on the same iGPU:

variant result
as translated (Block: Position + ClipDistance[1]) crash
ClipDistance[2] instead of [1] crash
a constant stored into the ClipDistance member crash
the same Block without the ClipDistance store no crash
Position and ClipDistance as standalone arrayed built-ins, no Block no crash, 2048/4096 pixels (expected)

So the trigger is a store to a ClipDistance member of an arrayed output Block in a mesh shader. docs/design.md counts clip distances in 1,906 of the 9,282 corpus mesh shaders, so on that driver every one of them would crash at pipeline creation. kormocicsaba saw the same ms_clip failure on 24.10.34 (#5581). #5744 and #5767 add the exit code to the report, and their comments show newer AMD drivers passing.

The translator now emits %ms_out_clip (BuiltIn ClipDistance) and %ms_out_culld (BuiltIn CullDistance) as standalone arrayed outputs next to %ms_out_pos, and drops %ms_vtx_blk. The distances are still copied one float at a time, so the SHADER-155 workaround for SPIRV-Cross/Metal is kept. --mesh-compute doesn't change. The mesh row in docs/design.md says why the outputs are standalone, and tests/test_translate.py checks the new form (%ms_vtx_blk absent, standalone decorations, per-float access chains into %ms_out_clip / %ms_out_culld).

Tested

Windows 11 IoT Enterprise LTSC 2024 (26100), MSVC 14.50 (VS 2026), Vulkan SDK 1.4.363.0, llvm-mc 23.1.6 (conda-forge), Python 3.14. Both GPUs are in one machine. Synthetic fixtures only, no game files.

Not tested: MoltenVK/Metal, which is what the per-float copy (SHADER-155) is for. The SPIR-V there is the same per-float store, now into a standalone arrayed output instead of a Block member.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

…s, not a per-vertex Block

AMD's Windows driver 24.10.24 (Vulkan driver 2.0.302, a gfx1036 iGPU) crashes with an access violation
inside vkCreateGraphicsPipelines on ms_clip. In hand-edited modules the trigger is a store to a
ClipDistance member of an arrayed per-vertex output Block. Removing that store, or writing Position and
ClipDistance as standalone arrayed built-ins, compiles and draws the expected 2048/4096 pixels.
docs/design.md counts clip distances in 1,906 of the 9,282 corpus mesh shaders.

The translator now emits %ms_out_clip and %ms_out_culld next to %ms_out_pos and drops %ms_vtx_blk.
The distances are still copied one float at a time (SHADER-155), and --mesh-compute is unchanged.

Tested on Windows 11 (VS 2026, Vulkan SDK 1.4.363.0, llvm-mc 23.1.6):
- run_gpu_tests --filter ms_clip: the AMD iGPU fails on main and passes 2048/4096 with this change;
  the RTX 5070 Ti (621.24) passes; Khronos validation clean on both.
- The other mesh tests are unchanged.
- pytest test_translate, test_mesh_compute(_vs), test_ps_interp_modes: 713 passed.
- Semantic suite: only the two files that are red on main fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@morodirule

Copy link
Copy Markdown

Tested 9ea52cd on Arch Linux + RTX 4070 (NVIDIA 620.70, llvm-mc 23.1.5), CPU + native GPU: pass — pytest tests/test_translate.py 648/648 OK (incl. 20 clip/cull/mesh). Negative control: merge-base translator → the 3 ms_clip/ms_cull tests fail. GPU: ms_clip fixture runs natively (mesh shaders present) — 2048/4096 pixels covered as expected, spirv-val clean. No game files. AI-assisted.

@RAINighty

Copy link
Copy Markdown

Tested 9ea52cdb7 merged with main dde82f27e (clean merge) on Windows 11 (10.0.26300), Python 3.13.15 (venv with the pinned tests/requirements.txt), with llvm-mc 21.1.8 (AMDGPU) and SPIRV-Tools v2026.4 on PATH: pass.

  • tests/test_translate.py with this PR: passes (648 passed in 57.95s). On main: passes (648 passed in 56.89s).
  • Negative control: this PR's test with main's version of docs/design.md, tools/rdna2spirv.py fails (1 failed, 355 passed in 35.85s), so the new test does catch the problem.
  • Code not reviewed beyond running it. No GPU or game files.

AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants