Skip to content

[BUILD-748] Reject over-limit mesh workgroup memory in vk_pipeline_check - #2689

Merged
ItsNotRexed merged 1 commit into
ProjectLeonida:mainfrom
Capi360:codex/pipeline-mesh-workgroup-limit
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ProjectLeonida:mainfrom
Capi360:codex/pipeline-mesh-workgroup-limit

Conversation

@Capi360

@Capi360 Capi360 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

BUILD-748, claimed in #2516. Extends the merged #1958 pipeline checker guard to the mesh stage.

The checker now queries VkPhysicalDeviceMeshShaderPropertiesEXT on devices with mesh shader support. It compares mesh index entries with maxMeshSharedMemorySize and compute entries with maxComputeSharedMemorySize. Entries above the stage limit are reported before module creation, and the rest of the batch continues. Missing mesh support still follows the existing feature skip. Vulkan mesh shader properties

Verification

Windows 11 build 26200, MSVC 19.44 x64, Windows SDK 10.0.28000.0, RTX 3060 Ti (driver 616.56, Vulkan 1.4.351). Khronos validation enabled, no validation errors. Synthetic mesh, fragment and compute inputs only.

  • This device reports 28,672 bytes for mesh and 49,152 for compute. The parent accepted all three valid synthetic mesh modules. The patched checker refused only the mesh entry declaring 28,676 bytes. It compiled the exact-limit entry and the legacy mesh entry with no lds_bytes.
  • A compute entry declaring the same 28,676 bytes still compiled, and one declaring 49,156 bytes received the existing compute-limit error. The mixed batch continued and wrote a nonempty cache. Tested with one and two workers and with the compute-only filter.
  • vk_pipeline_check_cli, docs links, CTest registration, and git diff --check passed.

AI-assisted with Codex.

@carlcdx

carlcdx commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 0cb7b7bf on Windows 11 (26300, MSVC 19.44, Windows SDK 10.0.26100.0, Vulkan SDK 1.4.363.0, RelWithDebInfo, VK_LOADER_LAYERS_DISABLE=~implicit~, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation): pass on two physical AMD GPUs, 0 validation errors.

Build & checks:

  • cmake --build runtime/build --config RelWithDebInfo --target vk_pipeline_check: built cleanly with 0 warnings.
  • ctest --test-dir runtime/build -C RelWithDebInfo -R "pipeline_check": 1/1 passed (vk_pipeline_check_cli, 0.12s).
  • python -m unittest tests/test_docs_links.py -v: 5/5 OK.
  • git diff --check HEAD~1..HEAD: clean.

Synthetic batch (ms_exact 32768, ms_over 32772, ms_legacy no lds_bytes, ps_basic, cs_exact 32768, cs_over 32772 — all Vulkan 1.3 SPIR-V validated with spirv-val):
Both adapters report maxMeshSharedMemorySize = 32768 and maxComputeSharedMemorySize = 32768 in vulkaninfo.

  • AMD Radeon RX 9070 XT (RDNA 4, Vulkan 1.4.349):
    • Mixed batch (--jobs 1 and --jobs 2): MODULE FAIL cs_over (workgroup memory 32772 bytes exceeds maxComputeSharedMemorySize 32768) and MODULE FAIL ms_over (workgroup memory 32772 bytes exceeds maxMeshSharedMemorySize 32768); cs: 1 modules ok, 1 failed (1 pipeline ok), ms: 2 modules ok, 1 failed, ps: 1 modules ok, 0 failed, pipeline cache written (2420 bytes), exit 1, 0 validation errors.
    • --compute-only --jobs 2: checking 2 shaders [0, 2) (stage=cs), cs: 1 modules ok, 1 failed, 1 pipeline ok, exit 1.
  • AMD Radeon(TM) Graphics (Ryzen 7 9800X3D RDNA 2 iGPU, Vulkan 1.3.302):
    • Identical module and --compute-only results across --jobs 1 and --jobs 2, pipeline cache written (2252 bytes), exit 1, 0 validation errors.

Notes / not tested here:

  • Graphics pipeline creation for ms_exact, ms_legacy, and ps_basic was skipped in this ad-hoc directory due to missing ps_empty.spv / vs_empty.spv stubs (module creation and the maxMeshSharedMemorySize guard itself ran and passed/rejected as expected).
  • Neither adapter lacks VK_EXT_mesh_shader, and both report equal maxMeshSharedMemorySize and maxComputeSharedMemorySize (32768).

Synthetic tests only; no game files. AI-assisted.

@tupacfan04

Copy link
Copy Markdown
Contributor

Code read of 0cb7b7bf (I didn't run it). Looks right. mesh_props is only filled when ext_mesh && mesh.meshShader. Otherwise maxMeshSharedMemorySize stays 0, the guard is skipped, and the existing "no VK_EXT_mesh_shader" skip applies. Mesh entries always have lds_bytes ≥ 4, since the translator counts the 4-byte %ms_counts, so every ms entry is checked on mesh-capable devices.

AI-assisted review (Claude Code).

@TurboSosiska304

Copy link
Copy Markdown

Verified 0cb7b7b on CachyOS Linux, gcc 16.2.1, CMake 4.5.1.

  • Compiled vk_pipeline_check against fetched Vulkan-Headers 1.4.363: builds cleanly.
  • Could not execute it: it creates a Vulkan instance and device, and the single GPU here belongs to another worker.

Static review: mesh_props is queried only when ext_mesh && mesh.meshShader; otherwise the limit stays 0 and entries fall through to the existing "no VK_EXT_mesh_shader" skip at line 875. limit_name is only printed when the limit is non-zero, so the non-cs branch always means ms. The docs wording matches the code. Task-stage shared memory is not covered, but the checker has no task stage.

Not run: the reported 28,676-byte overshoot against a 28,672-byte mesh limit, and validation-layer runs.

No issues found in static review.

@Marukooh

Copy link
Copy Markdown
Contributor

Tested 0cb7b7bf against its base 49475796 on an NVIDIA GeForce RTX 5070 Ti (Blackwell, GB203), driver 620.73.04, Vulkan 1.4.357, CachyOS / Linux 7.3.5, GCC 16.2.1, CMake 4.5.1 + Ninja, RelWithDebInfo: pass, and the before/after difference is observable on this device.

This card is the interesting case here because its two limits differ — vulkaninfo reports maxMeshSharedMemorySize = 28672 and maxComputeSharedMemorySize = 49152. The earlier verification ran on adapters where both were 32768, so a mesh entry compared against the compute limit could not be told apart from one compared against the mesh limit. Here it can.

Build: vk_pipeline_check built at head and at the base, 0 warnings each.

Synthetic corpus — 6 index entries, every module spirv-val clean, plus stubs/ps_empty.spv so the mesh graphics pipelines are actually created (the gap left open above):

entry stage lds_bytes base 49475796 head 0cb7b7bf
ms_exact ms 28672 (= mesh limit) module + pipeline ok module + pipeline ok
ms_over ms 28676 (mesh limit + 4) module + pipeline ok, no error MODULE FAIL ms_over (workgroup memory 28676 bytes exceeds maxMeshSharedMemorySize 28672)
ms_mid ms 32768 (over mesh, under compute) module + pipeline ok, no error MODULE FAIL ms_mid (workgroup memory 32768 bytes exceeds maxMeshSharedMemorySize 28672)
ms_legacy ms absent module + pipeline ok module + pipeline ok
cs_exact cs 49152 (= compute limit) module + pipeline ok module + pipeline ok
cs_over cs 49156 MODULE FAIL cs_over (… exceeds maxComputeSharedMemorySize 49152) identical

Totals: base ms: 4 modules ok, 0 failed and ms pipelines: 4 ok, 0 failed, 0 skipped; head ms: 2 modules ok, 2 failed and ms pipelines: 2 ok, 0 failed, 0 skipped. The cs counts are the same on both (1 modules ok, 1 failed). Same output with --jobs 1 and --jobs 2, and --isolate --jobs 1 reports the same three MODULE FAIL lines.

Worth recording: this driver does not reject over-limit mesh workgroup memory on its own. At the base, both ms_over and ms_mid got through vkCreateShaderModule and vkCreateGraphicsPipelines and were counted as ok, so without this patch they pass the corpus check undetected on Blackwell. That is exactly the case the guard catches.

--compute-only output is byte-identical before and after (diff empty), so the merged compute guard is untouched. --graphics-only exit status goes 0 → 1; the full run exits 1 on both, because of cs_over.

Repo tests at head: ctest -R pipeline_check 1/1 passed (vk_pipeline_check_cli, 0.02 s); tests/test_vk_pipeline_check_index.py 5 OK and tests/test_vk_pipeline_check_isolate.py 6 OK with LEONIDA_VK_PIPELINE_CHECK pointed at the built binary (both skip silently without it); tests/test_docs_links.py 5 OK; git diff --check 49475796..0cb7b7bf clean.

Not covered here: no Khronos validation layer is installed on this machine, so I can only say the driver accepted ms_over/ms_mid at the base — not whether validation would have flagged them. This device supports VK_EXT_mesh_shader, so the missing-mesh-support skip path is still unverified by me.

Synthetic shaders only, no game files. AI-assisted (Claude).

@crastinator

Copy link
Copy Markdown
Contributor

Tested 0cb7b7b merged into main ec8ec4c9 (clean merge) on AMD Radeon RX 6700 XT (Navi 22, gfx1031, subgroup 32..64), RADV Mesa 26.3.1, CachyOS, Linux 7.3.5, GCC 16.2.1, llvm-mc 23.1.5: pass.

  • Whole run_gpu_tests.py: 175/189 native, 175/189 with LEONIDA_W64_EMULATE=1 (the skips are the D3D12-only fixtures and ps_w64x_readlane, as on main). ctest 37/37.
  • RADV reports maxMeshSharedMemorySize = 28672. With ms_tri.spv and its index entry, lds_bytes 28672 gives ms: 1 modules ok, and 28673 gives MODULE FAIL ms_tri (workgroup memory 28673 bytes exceeds maxMeshSharedMemorySize 28672), exit 1.

No game files. AI-assisted (Claude Code).

@MiguelMatMar

Copy link
Copy Markdown

Tested 0cb7b7b on RTX 4080 SUPER (Ada, subgroup 32), NVIDIA 621.24 (Vulkan 1.4.357), Windows 11 Pro build 26300; MSVC 14.44, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8 built with scripts/build_llvm_mc.ps1, Python 3.14: pass

This device reports maxMeshSharedMemorySize 28,672 and maxComputeSharedMemorySize 49,152. The corpus was synthetic: GLSL mesh/compute shaders with a shared uint array (glslang, all pass spirv-val) plus tools/spirv_stubs.py. Run under Khronos validation, with --jobs 1 and --jobs 2, against the base 49475796 checker:

entry lds_bytes base this PR
ms_exact 28,672 ok ok
ms_over 28,676 "ok", plus VUID-RuntimeSpirv-maxMeshSharedMemorySize-08754 from the layer MODULE FAIL ms_over (workgroup memory 28676 bytes exceeds maxMeshSharedMemorySize 28672), no VUID
ms_legacy (absent) ok ok
cs_28676 28,676 ok ok
cs_over 49,156 MODULE FAIL (compute limit) MODULE FAIL (compute limit)
  • The batch continues after the failures and a non-empty cache is written. --compute-only reports only cs_over. The exit code is 1 when a module fails, in both builds.
  • Code read: looks right. When mesh is unsupported, mesh_props stays zeroed, so the limit is 0 and the check is skipped. Those entries are already skipped by the no VK_EXT_mesh_shader feature check.

@ItsNotRexed
ItsNotRexed merged commit 8511fba into ProjectLeonida:main Nov 22, 2026
3 of 4 checks passed
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.

8 participants