Idea: Steal Lichii's Fix for Mesh Shaders for RDNA3/RDNA4 GPUs on Linux #1285

Open
opened 2026-11-17 00:32:56 +00:00 by grump · 3 comments

The idea

Someone finally got to the root of why the mesh shaders crash on RDNA3/RDNA4 GPUs on Linux, even though those GPUs support mesh shaders: A buggy driver expects that mesh shaders will always read the mesh grid size, but OOTs translated shaders never do. Hence the crash. It can be trivially fixed by always declaring and reading the grid size. See: https://github.com/zortos293/Lichii/pull/1203

With this fix, the compute fallback is no longer necessary for RDNA3/RDNA4 GPUs on Linux.

Anything else

Litchii does this: https://github.com/zortos293/Lichii/pull/1203

### The idea Someone finally got to the root of why the mesh shaders crash on RDNA3/RDNA4 GPUs on Linux, even though those GPUs support mesh shaders: A buggy driver expects that mesh shaders will always read the mesh grid size, but OOTs translated shaders never do. Hence the crash. It can be trivially fixed by always declaring and reading the grid size. See: https://github.com/zortos293/Lichii/pull/1203 With this fix, the compute fallback is no longer necessary for RDNA3/RDNA4 GPUs on Linux. ### Anything else Litchii does this: https://github.com/zortos293/Lichii/pull/1203
Member

Possibly related, for context:

  • issue #583 RX 6600 (Navi 23, Windows): device lost in Dodongo's Cavern with native mesh shaders, compute fixes it — Related mesh-shader GPU loss workaround on an AMD GPU; this report proposes a Linux driver-specific fix.
  • PR #865 fix(vk): the device line says whether the driver offers mesh shaders, not only whether this run uses them — Touches the existing Linux AMD compute-fallback policy for mesh shaders.
Possibly related, for context: - issue #583 RX 6600 (Navi 23, Windows): device lost in Dodongo's Cavern with native mesh shaders, compute fixes it — Related mesh-shader GPU loss workaround on an AMD GPU; this report proposes a Linux driver-specific fix. - PR #865 fix(vk): the device line says whether the driver offers mesh shaders, not only whether this run uses them — Touches the existing Linux AMD compute-fallback policy for mesh shaders.
Contributor

Claiming this on Linux (Fedora 45, Mesa RADV 26.3.1, AMD Radeon RX 9070 XT / RDNA 4, Ryzen 5 5600X). Initial probe of RX_VK_MESH_SHADERS=native ran cleanly across Hyrule Field, Kokiri Forest, Market, and Lake Hylia with -40% cold shader prep (254.8 -> 153.2 s), ~1 GB less private RAM, and -4 to -10% GPU time, though CPU-bound Market FPS was ~3% lower. Investigating that CPU overhead and testing GPU-bound scaling next before implementing the BuiltIn::NumWorkgroups workaround and RADV policy change.

Claiming this on Linux (Fedora 45, Mesa RADV 26.3.1, AMD Radeon RX 9070 XT / RDNA 4, Ryzen 5 5600X). Initial probe of `RX_VK_MESH_SHADERS=native` ran cleanly across Hyrule Field, Kokiri Forest, Market, and Lake Hylia with -40% cold shader prep (254.8 -> 153.2 s), ~1 GB less private RAM, and -4 to -10% GPU time, though CPU-bound Market FPS was ~3% lower. Investigating that CPU overhead and testing GPU-bound scaling next before implementing the `BuiltIn::NumWorkgroups` workaround and RADV policy change.
Contributor

We tested native VK_EXT_mesh_shader (RX_VK_MESH_FALLBACK=0) vs compute mesh fallback (RX_VK_MESH_FALLBACK=1) on Linux RADV RDNA 4 and tracked down both the NumWorkgroups fix and the CPU/GPU performance behavior.

Setup

  • Hardware / OS: AMD Radeon RX 9070 XT (RADV GFX1201, Mesa 26.3.1), Ryzen 5 5600X, Fedora 45 Linux, 1440p (DP-1)
  • Base: main @ a2dc5385

1. Lichii #1203 (NumWorkgroups) Fix

Opened a focused PR (#2338) with Lichii #1203's spv::BuiltIn::NumWorkgroups workaround for native Stage::Mesh shaders + a game-free SPIR-V regression test (tests/global_load_16_ir.cpp, validated with spirv-val --target-env vulkan1.3 --uniform-buffer-standard-layout). RADV's default mesh mode is kept unchanged there so maintainers can decide on flipping defaults once #2291 lands.

2. Paired A/B Measurements on RX 9070 XT (RADV Mesa 26.3.1)

On main alone, native mesh shaders trailed compute fallback on both scenes (kokiri-forest -13.6%, castle-gate -9.3%). Testing alongside #2291 (descriptor / SPIR-V improvements) + Task/Mesh c2 bank caching flipped kokiri-forest to a win and cut GPU frame time substantially on both scenes:

Scene / Settings Compute Fallback (RX_VK_MESH_FALLBACK=1) Native Mesh (RX_VK_MESH_FALLBACK=0) Delta
kokiri-forest (67% res, main) 105.1 fps (GPU 5.7–6.4 ms) 90.8 fps (GPU 5.9–6.0 ms) -13.6% FPS
kokiri-forest (67% res, w/ #2291 + bank cache) 93.8 fps (GPU 5.9–6.7 ms) 98.7 fps (GPU 4.9–5.1 ms) +5.2% FPS, -20% GPU
castle-gate (1440p, main) 78.7 fps (GPU 7.8–8.1 ms) 71.4 fps (GPU 7.1–7.7 ms) -9.3% FPS (+1.28 ms)
castle-gate (1440p, w/ #2291 + bank cache, stock tuning) 75.4 fps (GPU 7.9–8.4 ms) 70.8 fps (GPU 7.0–7.3 ms) -6.1% FPS (+0.85 ms)
castle-gate (1440p, w/ #2291 + bank cache, PART_MIN=360 PART_MAX=1024 GPU_CLOCK=peak) 75.5 fps (13.09 ms, GPU 8.1 ms) 71.6 fps (13.76 ms, GPU 5.8 ms) -5.1% FPS (+0.67 ms), -28% GPU

Memory & precompile wins with Native Mesh:

  • RAM / Working set: ~1.0 GB lower (6.5 GB WS / 0.96 GB private vs 7.5 GB WS / 1.95 GB private).
  • Cold prep + precompile: -40% faster (153.2 s vs 254.8 s).

3. Root Cause of the Remaining CPU-Bound Gap in castle-gate (-5.1% / +0.67 ms)

CPU profiling (HOS_PROFILE=1 / speedscope) showed that mkw_vk_replay draw/desc work is now equal or slightly faster on Native (7.49 / 3.01 ms vs 7.82 / 3.13 ms). The entire remaining +0.67 ms gap is inside mkw_vk_recorder part_submit -> submit_or_retry (vkQueueSubmit2):

  • Native: 162 µs/part (2.17 s / 10 s, 21.5% CPU; libdrm_amdgpu.so.1 3.1%, libdrm.so.2 3.1%)
  • Compute: 90 µs/part (1.21 s / 10 s, 11.7% CPU; libdrm_amdgpu < 0.1%, libdrm 0.6%)

Because RADV splits command buffers containing Task shaders across two hardware rings (GFX + ACE compute), every vkQueueSubmit2 pays two DRM_IOCTL_AMDGPU_CS ioctls plus ACE↔GFX syncobj synchronization. Reducing parts per frame from 18.7 -> 11.9 (RX_VK_PART_MIN=360 RX_VK_PART_MAX=1024) brought parts' ends and submits down to 2.25 ms/frame vs Compute's 1.59 ms/frame (+0.66 ms/frame), accounting for 100% of the +0.67 ms median delta on this 5600X.

Takeaway

  • On GPU-bound scenes / resolutions (or faster CPUs), native mesh shaders on RADV RDNA 4 are already a clear win (-20% to -28% GPU time, ~1 GB less RAM, -40% precompile time, and +5.2% FPS in kokiri-forest once #2291 lands).
  • On heavily CPU-bound scenes (castle-gate on a 5600X), RADV's dual-ring Task+Mesh submission overhead still costs ~0.67 ms/frame (~5%) unless part count per frame is reduced further.
  • We also opened a separate WIP PR (#2339) for the safe Task/Mesh c2 / per-stage pointer_table() bank caching cleanup.
We tested native `VK_EXT_mesh_shader` (`RX_VK_MESH_FALLBACK=0`) vs compute mesh fallback (`RX_VK_MESH_FALLBACK=1`) on Linux RADV RDNA 4 and tracked down both the `NumWorkgroups` fix and the CPU/GPU performance behavior. ### Setup - **Hardware / OS:** AMD Radeon RX 9070 XT (RADV GFX1201, Mesa 26.3.1), Ryzen 5 5600X, Fedora 45 Linux, 1440p (`DP-1`) - **Base:** `main` @ `a2dc5385` ### 1. Lichii `#1203` (`NumWorkgroups`) Fix Opened a focused PR (#2338) with Lichii `#1203`'s `spv::BuiltIn::NumWorkgroups` workaround for native `Stage::Mesh` shaders + a game-free SPIR-V regression test (`tests/global_load_16_ir.cpp`, validated with `spirv-val --target-env vulkan1.3 --uniform-buffer-standard-layout`). RADV's default mesh mode is kept unchanged there so maintainers can decide on flipping defaults once `#2291` lands. ### 2. Paired A/B Measurements on RX 9070 XT (RADV Mesa 26.3.1) On `main` alone, native mesh shaders trailed compute fallback on both scenes (`kokiri-forest` `-13.6%`, `castle-gate` `-9.3%`). Testing alongside `#2291` (descriptor / SPIR-V improvements) + Task/Mesh `c2` bank caching flipped `kokiri-forest` to a win and cut GPU frame time substantially on both scenes: | Scene / Settings | Compute Fallback (`RX_VK_MESH_FALLBACK=1`) | Native Mesh (`RX_VK_MESH_FALLBACK=0`) | Delta | |---|---:|---:|---:| | `kokiri-forest` (67% res, `main`) | 105.1 fps (GPU 5.7–6.4 ms) | 90.8 fps (GPU 5.9–6.0 ms) | **-13.6% FPS** | | `kokiri-forest` (67% res, w/ `#2291` + bank cache) | 93.8 fps (GPU 5.9–6.7 ms) | **98.7 fps** (GPU **4.9–5.1 ms**) | **+5.2% FPS, -20% GPU** | | `castle-gate` (1440p, `main`) | 78.7 fps (GPU 7.8–8.1 ms) | 71.4 fps (GPU 7.1–7.7 ms) | **-9.3% FPS** (+1.28 ms) | | `castle-gate` (1440p, w/ `#2291` + bank cache, stock tuning) | 75.4 fps (GPU 7.9–8.4 ms) | 70.8 fps (GPU **7.0–7.3 ms**) | **-6.1% FPS** (+0.85 ms) | | `castle-gate` (1440p, w/ `#2291` + bank cache, `PART_MIN=360 PART_MAX=1024 GPU_CLOCK=peak`) | 75.5 fps (13.09 ms, GPU 8.1 ms) | 71.6 fps (13.76 ms, GPU **5.8 ms**) | **-5.1% FPS** (+0.67 ms), **-28% GPU** | **Memory & precompile wins with Native Mesh:** - **RAM / Working set:** `~1.0 GB` lower (`6.5 GB` WS / `0.96 GB` private vs `7.5 GB` WS / `1.95 GB` private). - **Cold prep + precompile:** **-40% faster** (`153.2 s` vs `254.8 s`). ### 3. Root Cause of the Remaining CPU-Bound Gap in `castle-gate` (`-5.1%` / `+0.67 ms`) CPU profiling (`HOS_PROFILE=1` / speedscope) showed that `mkw_vk_replay` `draw`/`desc` work is now equal or slightly faster on Native (`7.49 / 3.01 ms` vs `7.82 / 3.13 ms`). The entire remaining `+0.67 ms` gap is inside `mkw_vk_recorder` `part_submit -> submit_or_retry` (`vkQueueSubmit2`): - **Native:** `162 µs/part` (`2.17 s / 10 s`, `21.5%` CPU; `libdrm_amdgpu.so.1` `3.1%`, `libdrm.so.2` `3.1%`) - **Compute:** `90 µs/part` (`1.21 s / 10 s`, `11.7%` CPU; `libdrm_amdgpu` `< 0.1%`, `libdrm` `0.6%`) Because RADV splits command buffers containing Task shaders across **two hardware rings (GFX + ACE compute)**, every `vkQueueSubmit2` pays two `DRM_IOCTL_AMDGPU_CS` ioctls plus ACE↔GFX syncobj synchronization. Reducing parts per frame from `18.7 -> 11.9` (`RX_VK_PART_MIN=360 RX_VK_PART_MAX=1024`) brought `parts' ends and submits` down to `2.25 ms/frame` vs Compute's `1.59 ms/frame` (`+0.66 ms/frame`), accounting for 100% of the `+0.67 ms` median delta on this 5600X. ### Takeaway - On GPU-bound scenes / resolutions (or faster CPUs), native mesh shaders on RADV RDNA 4 are already a clear win (**-20% to -28% GPU time**, **~1 GB less RAM**, **-40% precompile time**, and **+5.2% FPS** in `kokiri-forest` once `#2291` lands). - On heavily CPU-bound scenes (`castle-gate` on a 5600X), RADV's dual-ring Task+Mesh submission overhead still costs `~0.67 ms/frame` (`~5%`) unless part count per frame is reduced further. - We also opened a separate WIP PR (#2339) for the safe Task/Mesh `c2` / per-stage `pointer_table()` bank caching cleanup.
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
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
MagicBeanDev/Longshot#1285
No description provided.