Skip to content

Runtime: mesh PSOs and DispatchMesh without VK_EXT_mesh_shader, through --mesh-compute - #4408

Draft
DaniSBR1 wants to merge 24 commits into
ItsNotRexed:mainfrom
DaniSBR1:pr-mesh-compute-runtime
Draft

DaniSBR1 wants to merge 24 commits into
ItsNotRexed:mainfrom
DaniSBR1:pr-mesh-compute-runtime

Conversation

@DaniSBR1

@DaniSBR1 DaniSBR1 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in #4257 (#4257 (comment)), new D3D item: the runtime side of --mesh-compute.

Depends on: #1712 (D3D-29, mesh PSOs and DispatchMesh)
Depends on: #3777 (ExecuteIndirect DISPATCH_MESH and the M5 mesh gate, which merges #1712 and #1865 onto main)

This branch is zneel's m5-mesh (#3777's head, 536cb939) plus this PR's commits, the second one the review fixes. Only those are for review: git diff 536cb939..HEAD.

What and why

9,282 of the game's 26,503 shaders are mesh shaders. #1712 and #3777 draw them on VK_EXT_mesh_shader. Without the extension (RDNA1 on AMD's Windows driver and on RADV, NVIDIA Pascal, Intel UHD) a mesh PSO is E_NOTIMPL, so none of them draws there. The translator already has the fallback: --mesh-compute (#1053) makes each mesh shader a compute shader that writes its vertices and primitives into one output slot per workgroup. docs/design.md lists the runtime side as the follow-up, and this PR adds it:

  • PSO: when the device has no VK_EXT_mesh_shader, the MS entry must have a mesh_compute layout.
    • Its module becomes a compute pipeline. It gets the 152-byte push-constant block (the output address in dwords 36..37), the device's set 0 where it declares bindings, and its translated subgroup size.
    • In place of the mesh stage, the graphics pipeline gets the vertex shader that draws the slots. runtime/src/mesh_compute_vs.h builds it from the layout at PSO creation: the module tools/mesh_compute_vs.py writes.
    • For four layouts the two modules have the same instructions in the same order; only the id numbering differs. The layouts are a small one, the corpus's shape (128/128 outputs, 18 params, 3 clip distances), clip+cull, and f16 halves.
  • DispatchMesh: groups × slot_bytes of the queue's scratch, then vkCmdDispatch with the counts, a compute-write → vertex-read barrier, and vkCmdDraw(groups × max_primitives × 3) with triangle lists in the draw's rendering scope.
    • The scratch is vulkan_scratch.h's, the one depth ↔ colour copies use. It is now created with a device address where the device has buffer device addresses. It lives until the submission completes and is then reused.
    • Each draw already opens its own rendering scope, so the dispatch goes right before it.
  • MeshShaderTier: without the extension it is 1 where the index has --mesh-compute mesh shaders and the device can run every one of them as the PSO path does (the checks below), and NOT_SUPPORTED otherwise, as before.
  • Refused with E_NOTIMPL and a log, with the tier hidden wherever any --mesh-compute mesh shader would be:
    • a mesh shader without a mesh_compute layout (translated without the flag);
    • a device under 152 bytes of push constants;
    • a Direct queue family without VK_QUEUE_COMPUTE_BIT, since the dispatch is recorded on that queue (VUID-vkCmdDispatch-commandBuffer-02707);
    • a mesh shader whose subgroup size the compute stage can't be guaranteed. It must be emulated (--wave64-emulate), required by the stage, or the device's only size. A size that is only the default could change its subgroup operations' results;
    • a PS that reads a param's --f16-interp-fallback halves where the layout doesn't export them. Reading the halves of some of the exported params is fine. Per-pipeline pairing, mesh_compute_vs.pair_f16_halves, is not built yet.
  • Not built: ExecuteIndirect with DISPATCH_MESH. The group counts are GPU data, so the draw's vertex count is too. Its signatures stay E_NOTIMPL without the extension.
  • ShaderEntry reads the mesh_compute layout, and ShaderLibrary::mesh_compute_count() counts such mesh shaders.

Tests

RX 5700 XT (RDNA1, no VK_EXT_mesh_shader), AMD Adrenalin 26.11.2, Vulkan 1.4.315, Windows 11, MSVC 19.44:

  • d3d12_mesh_compute_test (new, GPU): runs on every GPU, because the layer's device is made without the extension whatever the GPU has.
    • The mesh shader is test/glsl/ms_draw_compute.comp: Runtime: mesh-shader PSOs from pipeline state streams and DispatchMesh (D3D-29) #1712's ms_draw.mesh written to the --mesh-compute contract, so the pixels are d3d12_mesh_test's.
    • Tier 1, and an MS + PS PSO from a stream.
    • An empty grid, then DispatchMesh(2, 2, 1) and DispatchMesh(1, 1, 2), so the X, Y and Z counts each reach the slot index. 4096/4096 pixels match.
    • A mesh shader without a layout is refused, and a vertex draw with the mesh PSO is invalid_draw.
    • f16 halves: a PS reading one exported param's halves where the layout puts them links; one reading them elsewhere is refused.
    • Two devices where the path can't run as built: one with 144 bytes of push constants (enough for every other pipeline) and one whose subgroup sizes can't be required. Both report NOT_SUPPORTED and refuse the PSO, and on the second a mesh shader marked as emulated is still created.
    • It passes with LEONIDA_VK_VALIDATION=1 too, with no messages.
  • mesh_compute_vs_test (new, CPU): the four layouts' interfaces and the refusals. CMake runs spirv-val (Vulkan 1.2) on the four modules where the Vulkan SDK has it: all valid.
  • shader_library_test: the layout fields.
  • Full ctest: 164/164 passed. 14 more skipped here because they need game files or something this machine lacks, including d3d12_mesh and the three d3d12_m5_mesh*, which need VK_EXT_mesh_shader. d3d12_mesh's check without the extension (tier NOT_SUPPORTED, PSO refused, with an index that has no --mesh-compute entries) still passes before it skips.
  • tests/test_ctest_registration.py: passes.
  • A translated mesh shader through the layer: @ligmaSec ran Runtime: ExecuteIndirect with DISPATCH_MESH signatures and the M5 mesh gate (translated mesh shader) #3777's ms_m5.asm translated with --mesh-compute --wave64-emulate through this path, with native mesh off. All four grids of the M5 test matched all 4,096 pixels under Khronos and synchronization validation (review). build.py itself still translates it for the mesh stage only.
  • Other runs: @nschlaepfer ran the fallback on an Apple M3 Max through CrossOver/MoltenVK, and the native path on an RTX 5090, with matching images on each device.
  • Not tested: this path on a GPU that has the extension, other than through the forced device above.

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

AlxcBTW and others added 23 commits November 22, 2026 15:41
…ad recording, 5120-SRV table, pipeline cache)

Test d3d12_m5_world_test (D3D12 API only, translator-output shaders, every pixel against a CPU reference):
(a) five ExecuteIndirect calls (DRAW and DRAW_INDEXED signatures, CPU- and GPU-written records at offsets in
placed buffers, count buffer, count 0, count above MaxCommandCount), (b) four threads recording four lists run in
one ExecuteCommandLists, eight rounds, (c) a descriptor table of 5120 SRVs of distinct textures read at a byte
offset from a root constant, (d) a PSO created twice through the device's VkPipelineCache.

Layer gaps fixed on the way:
- ExecuteIndirect draws carry the list's graphics state and replay as whole draws; they used to replay as a bare
  vkCmdDraw*Indirect outside any render pass with no pipeline bound.
- multiDrawIndirect, drawIndirectCount and drawIndirectFirstInstance are enabled on the layer's device where
  present (VulkanDeviceInfo::multi_draw_indirect / draw_indirect_count); without multiDrawIndirect each record
  is its own call.
- One VkPipelineCache per device for every graphics and compute pipeline (was VK_NULL_HANDLE), with
  VkPipelineCreationFeedback hit counting (rt::d3d12::pipeline_cache_stats).

Section 6 M5 row: synthetic part met except mesh shaders (D3D-29).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ature flags, test leniency

- A draw-kind ExecuteIndirect with no graphics state is unsupported at prepare unless it is marked raw
  (ExecuteIndirect::raw, set by the unit tests that wrap the call in rendering themselves).
- Calls take at most VkPhysicalDeviceLimits::maxDrawIndirectCount records (ReplayFunctions, VulkanDeviceInfo).
- VulkanDeviceInfo::draw_indirect_first_instance is recorded; the layer logs once when it is absent.
- VulkanDeviceInfo::draw_indirect_count defaults to false.
- d3d12_m5_world_test: without drawIndirectCount the count-buffer calls are left out; pipeline-cache checks only
  run when the driver returns valid creation feedback, and size equality only when both sizes are known.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	runtime/src/vulkan_replay.h
The fixed-count loops added a full chunk to a 32-bit cursor, so a short final chunk could wrap it and restart at
argument offset 0 (MaxCommandCount UINT32_MAX with maxDrawIndirectCount 0x80000000). Found by @Vonsek in review of
ItsNotRexed#1865. d3d12_state_map now checks the calls (counts and offsets, not records) for both draw kinds with a huge count
and for a limit that does not divide the count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…wing without bound

A cursor that wraps again now ends the loop with a failed check rather than
appending until memory runs out. Checked by lowering the cap to 1: the
check fails at the call. Suggested by @Vonsek in ItsNotRexed#1865.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	docs/d3d12_vulkan.md
#	runtime/CMakeLists.txt
#	runtime/src/command_list.h
#	runtime/src/vulkan_replay.h
#	scripts/run_gpu_tests.py
# Conflicts:
#	runtime/CMakeLists.txt
#	runtime/src/vulkan_backend.h
#	scripts/run_gpu_tests.py
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	docs/d3d12_vulkan.md
#	runtime/shims/d3d12_com.h
#	runtime/shims/d3d12_vulkan_device.cpp
# Conflicts:
#	runtime/shims/d3d12_com.cpp
#	runtime/src/vulkan_backend.h
…h (D3D-29)

The device enables VK_EXT_mesh_shader (meshShader) where the GPU has it
and reports MeshShaderTier 1 only then.

ID3D12Device2::CreatePipelineState parses pipeline state streams in the
d3dx12.h layout into the descriptions the existing PSO creators take, with
the runtime's defaults for missing subobjects. Streams the PC runtime
refuses are E_INVALIDARG; AS, depth bounds, split stencil masks and view
instancing are E_NOTIMPL with a log.

A mesh PSO is MS + PS with no vertex input or input assembly, and no
dynamic topology or strides. Its output sizes and workgroup are checked
against VkPhysicalDeviceMeshShaderPropertiesEXT.

DispatchMesh records a Draw with mesh set and replays as
vkCmdDrawMeshTasksEXT; a draw of the wrong kind for its pipeline fails
with ReplayResult::invalid_draw.

d3d12_mesh_test covers the refusals and checks a 2x2x1 and a 1x1x2 mesh
grid plus a VS PSO from a stream, pixel by pixel.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ates; mesh test skips without Vulkan

The stream parser keyed its duplicate check on the raw subobject type, so DEPTH_STENCIL with DEPTH_STENCIL1
(either order) or RASTERIZER with RASTERIZER2 was accepted; D3D12_PIPELINE_STATE_STREAM_DESC counts versions of
one subobject as the same one. The check now uses the base type, while the payload still follows the original
type. d3d12_mesh_test covers both mixed orders, RASTERIZER + RASTERIZER2, and each description alone.
Reported by Vonsek in review.

d3d12_mesh_test failed on a machine without a Vulkan device (the Windows CI runner) instead of exiting 77; it
now skips there like d3d12_draw_test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…main's translator subtracts BaseVertex/BaseInstance)

After the round-41 merge the non-indexed records (P1) all drew cell 0: they chose their cell by StartVertexLocation,
which the hardware-style zero-based v0 no longer carries. P1 now picks cells through the instance id (InstanceCount),
indexed records still through the index values. The layer and the merge were fine; the test relied on an id semantic
main changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	runtime/CMakeLists.txt
#	runtime/src/vulkan_replay.h
#	runtime/test/vk_test_device.h
# Conflicts:
#	docs/d3d12_vulkan.md
#	runtime/src/vulkan_backend.h
#	runtime/src/vulkan_replay.h
…sh gate with a translated mesh shader

CreateCommandSignature takes DISPATCH_MESH where VK_EXT_mesh_shader is enabled (E_NOTIMPL without it).
ExecuteIndirect records it with the state DispatchMesh takes, and replay issues
vkCmdDrawMeshTasksIndirectEXT, or vkCmdDrawMeshTasksIndirectCountEXT with a count buffer, split by
multiDrawIndirect and maxDrawIndirectCount as the draw kinds are.

build.py makes the PSV0 container of a mesh shader whose header has a psv0: line, so translated mesh
shaders can be layer-test fixtures. d3d12_m5_mesh_test draws ms_m5.asm (NGG wave64, 128 threads, the
corpus's v5/s3 idioms) by DispatchMesh and by ExecuteIndirect, error 0.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mesh container test

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… fallback-path ctest; run_gpu_tests reads the psv0 header

- Pass the device's subgroup caps to the layer, so the wave64 mesh stage asks for 64; exit 77 where the
  device cannot run it 64-wide, or has fewer than 144 push-constant bytes.
- --single-calls / --no-count-buffers turn multiDrawIndirect / drawIndirectCount off on the layer's
  device; registered as d3d12_m5_mesh_fallbacks. Without drawIndirectCount a count-buffer call must be
  ReplayResult::unsupported.
- scripts/run_gpu_tests.py translates every .asm itself: give a mesh shader with a psv0: header its
  PSV0 there too (ms_m5 failed translation in the GPU suite without it).

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…p size

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From two review passes (one adversarial):
- CreateCommandSignature refuses DISPATCH_MESH after root arguments (E_NOTIMPL, as before this
  branch) instead of accepting it and reading the group counts from the record's first bytes.
- CommandList::execute_indirect refuses a mesh dispatch without DispatchMesh's state, and a draw
  kind with it.
- The test fails on validation errors, as its siblings do; asserts the mesh stage's subgroup request
  was found (and fails on an undecided one).
- I5 runs at stride 24 without a count buffer, zero-padded, 1 to 4 groups per record; new
  d3d12_m5_mesh_chunks lowers the layer's maxDrawIndirectCount to 3 so the calls are split.
  Mutations caught: chunks that don't advance (chunks run), a stride hard-coded to 12 (both).
- Docs and comments: one-argument signatures only; maxDrawIndirectCount applies without a count
  buffer; invalid_draw for a draw signature with a mesh PSO needs a topology; only a record's group
  total is visible; ms_m5 sends GS_ALLOC_REQ from every thread; whitespace restored.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ot every GPU

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gh --mesh-compute

On a device without VK_EXT_mesh_shader (RDNA1, NVIDIA Pascal, Intel UHD) a mesh PSO was E_NOTIMPL. With mesh
shaders translated by --mesh-compute (ItsNotRexed#1053) the layer now runs them, the runtime side docs/design.md listed as
the follow-up:

- PSO: the MS module becomes a compute pipeline (152-byte push constants, set 0 where it has bindings, its
  translated subgroup size). The graphics pipeline gets, in place of the mesh stage, the vertex shader that draws
  the slots, built from the index's mesh_compute layout by runtime/src/mesh_compute_vs.h: the module
  tools/mesh_compute_vs.py writes, instruction for instruction.
- DispatchMesh: groups x slot_bytes of the queue's scratch (now with a device address), vkCmdDispatch, a
  compute-write -> vertex-read barrier, and vkCmdDraw(groups x max_primitives x 3) in the draw's rendering scope.
- MeshShaderTier is 1 without the extension where the index has --mesh-compute mesh shaders and the device can
  run them. A mesh shader without a layout, a PS reading f16 halves elsewhere than the layout exports them, or a
  device under 152 bytes of push constants is E_NOTIMPL with a log. ExecuteIndirect DISPATCH_MESH is not built.

Tests: mesh_compute_vs_test (four layouts, refusals; spirv-val on the modules), d3d12_mesh_compute_test (a
stand-in for ms_draw.mesh written to the --mesh-compute contract, drawn through a stream PSO on a device made
without the extension: every pixel checked), shader_library_test (the layout). RX 5700 XT, AMD 26.11.2,
Windows 11: ctest 164/164 (the four VK_EXT_mesh_shader tests skip); the new D3D12 test also passes under the
Khronos validation layer.

Depends on: ItsNotRexed#1712, ItsNotRexed#3777

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

@Kam471 Kam471 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Built and ran this at b990f5e0 on Windows 11, RTX 5070 Ti:

  • mesh_compute_vs_test.exe -> exit 0: "interfaces of four layouts (small, corpus-like, clip+cull, f16 halves) and the refusals as expected".
  • d3d12_mesh_compute_test.exe -> exit 0: "without VK_EXT_mesh_shader, mesh tier 1 through --mesh-compute; a stream MS + PS PSO drew DispatchMesh over X, Y and Z (each slot a workgroup's quad) and matched all 4096 pixels; a mesh shader without a mesh_compute layout refused; a vertex draw with the mesh PSO fails at execution".
  • ctest -R 'mesh_compute|m5_mesh' -> 9/9 (3 skipped); the skipped entries are the m5 mesh cases not built/registered for this target.

The fallback path (mesh PSO + DispatchMesh → compute + draw) works end to end, with the refuse case and wrong-kind draw check. No blocking issue.

@Flyander Flyander left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: create_mesh_compute calls subgroup_size_for, which only logs when the translated subgroup size is unavailable, then still creates the pipeline. On a device that cannot require the shader entry wave size, the fallback runs subgroup operations at the default width and can produce incorrect results. OPTIONS7 also advertises tier 1 from mesh_compute_count without this capability check. Please reject the PSO and hide the fallback tier unless the required size is guaranteed.

P2: The fallback records vkCmdDispatch on the Direct queue, but physical-device selection requires only VK_QUEUE_GRAPHICS_BIT. On a device whose graphics family lacks VK_QUEUE_COMPUTE_BIT (with compute exposed by a separate family), this command buffer pool cannot issue vkCmdDispatch (VUID-vkCmdDispatch-commandBuffer-02707). Require the selected Direct family to support compute before enabling this path, or provide a queueing design that supports both dispatch and draw.

@tunczzz

tunczzz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested b990f5e0 on an NVIDIA GeForce RTX 5070 Ti (Blackwell, driver 616.56, subgroup 32..32), Windows 11 10.0.26300, MSVC 19.44 Build Tools, Ninja RelWithDebInfo, Vulkan headers fetched, glslangValidator 16.2 and llvm-mc 21 available: pass.

  • ctest: 164/164 passed. Skipped only the game-data tests (shader_library_corpus, bink_*, fsr_dispatch, bvh_builder, d3d12_first_light), plus vk_sync_validation (no validation layer), d3d12_rgb9e5_rtv and the three d3d12_m5_mesh* tests from Runtime: ExecuteIndirect with DISPATCH_MESH signatures and the M5 mesh gate (translated mesh shader) #3777 (they skipped; I didn't look into why). main aa2988cc with the same setup: 153/153.
  • d3d12_mesh_compute (new): passed. "without VK_EXT_mesh_shader, mesh tier 1 through --mesh-compute; a stream MS + PS PSO drew DispatchMesh over X, Y and Z (each slot a workgroup's quad) and matched all 4096 pixels", and the vertex draw with the mesh PSO is refused at execution as the test expects.
  • mesh_compute_vs and its four spirv-val checks (small, corpus, distances, f16): passed. d3d12_mesh (the native VK_EXT_mesh_shader path, which this GPU has): passed.

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

@tupacfan04

Copy link
Copy Markdown
Contributor

HOLD: this is not independently landable. It has no textual conflict with main, but it is based on open #3777 and #1712 is CONFLICTING, so merging this branch pulls #3777 in.

The gate itself is right: the fallback applies only when !info.mesh_shader || !vkCmdDrawMeshTasksEXT (d3d12_vulkan_device.cpp:2837), tier 1 requires BDA + 152 bytes (:6675), four generated-VS layouts pass spirv-val, and 97 Python tests pass (20 skipped) with regen/compileall clean.

Issues:

  1. f16_halves equality (:2995) refuses a PS reading an exact subset of the exported halves; a subset should link.
  2. The tests force mesh_shader=false only (runtime/test/d3d12_mesh_compute_test.cpp:134); the native path and the 152-byte/BDA refusals are untested.
  3. ExecuteIndirect(DISPATCH_MESH) is still E_NOTIMPL under reported tier 1 (documented).
  4. C++ tests were not built here.

AI-assisted review, no game files, no GPU.

@ligmaSec ligmaSec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested b990f5e0 on Debian 13, Wine 10.0 and Mesa llvmpipe 25.0.7 (LLVM 19.1.7, subgroup 8). All six native CTests passed, including spirv-val for each of the four generated vertex shader layouts.

The clang-cl/xwin cross-build needed one explicit std::uint32_t conversion in the graphics VkPushConstantRange initializer. Its mesh_compute ? sizeof(...) : sizeof(...) expression has type size_t, which clang-cl rejects as a narrowing list initialization. With that one local cast, the existing d3d12_mesh_compute_test passed all 4,096 pixels and its two refusal checks. shader_library_test passed under Wine too.

I also tested the translator-to-runtime path called out as pending in the description. I built the hand-written ms_m5.asm fixtures with --mesh-compute --wave64-emulate --no-float-controls. All four modules passed spirv-val; the mesh module had no native subgroup operations. I used a local copy of the M5 test harness with native mesh disabled and stopped it after its existing direct-dispatch pixel comparison. The 4×2×2, 3×1×1, 1×1×1 and empty-grid calls matched all 4,096 pixels against the same CPU reference. Khronos validation and synchronization validation were active and reported zero errors for both tests.

This exercises the emulated mesh shader with eight-wide hardware subgroups. The already-reported native subgroup-width check is a separate concern. Only synthetic fixtures were used. AI-assisted with Codex.

@nschlaepfer

nschlaepfer commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Independent hardware verification of @DaniSBR1’s mesh-to-compute runtime at b990f5e0. I included the underlying mesh pipeline and indirect-dispatch work from #1712, #1865 and #3777, and the test configuration from #4236. The native-mesh path ran on a Windows RTX 5090. The fallback ran on Apple M3 Max through CrossOver/MoltenVK.

A mapped x86-64 guest created a mesh pipeline state and called DispatchMesh for 98 workgroups. The fixture contained 12,326 triangles. For each of four camera states the guest copied five render targets back after a fence. Compared with an independent reference on the same device, all 40 target images matched byte for byte across the two sets of runs (2,621,440 bytes checked). The four poses covered 55, 30, 1,086 and 637 pixels on each GPU.

The test used paired producer/consumer metadata for the half-precision interpolants on Mac. The fixture supplies camera and draw globals. I also repeated the comparison with the dedicated 2D depth-comparison binding from #4616 integrated into the test runtime. That combination preserved all forty reference images. Disabling the required binding rejected pipeline creation before drawing. On the unmodified main revision used as a baseline, the mesh pipeline-state stream was rejected before dispatch.

This verifies four direct guest draws through the native and fallback paths. It does not measure cross-device byte identity, retail frame selection, or a full scene's frame rate. AI-assisted verification. Only aggregate counts are shared.

Longer follow-up on the same composed runtime. The mapped guest completed 7,200 direct DispatchMesh calls per host over a two-minute offscreen controller route, streaming five successive workgroup counts (76, 90, 98, 90 and 76). Each host dispatched 601,800 workgroups in total. The matching repeat reproduced all five material targets and depth at every frame on each respective device. A separate 60-frame neutral controller interval delayed the 76-to-90 group transition by 60 frames. Cross-device edge coverage and some color values still differ. This used controlled draw state and lighting.

@ddm-j

ddm-j commented Nov 23, 2026

Copy link
Copy Markdown

clang-cl build break at b990f5e0 (found while testing #3777 + this PR + #4236 merged onto main d0835dd; Windows runtime cross-built with clang-cl + xwin):

runtime/shims/d3d12_vulkan_device.cpp(3301,40): error: non-constant-expression cannot be narrowed from type
'__size_t' (aka 'unsigned long long') to 'uint32_t' (aka 'unsigned int') in initializer list [-Wc++11-narrowing]

The size of the VkPushConstantRange is a runtime ternary of two sizeofs inside a brace initializer, so it narrows size_t to uint32_t. Clang treats that as an error; MSVC accepts it, which is why the MSVC runs above passed. It's in this PR alone: main + #3777 + this PR fails to compile the same object; #4236 isn't needed.

Fix:

         const VkPushConstantRange push{graphics_.push_stages, 0,
-                                       mesh_compute ? sizeof(leonida::MeshComputeUserData)
-                                                    : sizeof(leonida::ShaderUserData)};
+                                       static_cast<uint32_t>(mesh_compute ? sizeof(leonida::MeshComputeUserData)
+                                                                          : sizeof(leonida::ShaderUserData))};

With it (main d0835dd + #3777 + this PR + #4236), the Windows ctest suite under Wine 11.21 on Fedora 45: 163/163, 0 failed (22 skipped) on both an RDNA2 iGPU (RADV Mesa 26.2.6) and an RTX 4070 Ti (615.78.08), including d3d12_m5_mesh, d3d12_m5_mesh_fallbacks, d3d12_m5_mesh_chunks, d3d12_m5_world and the mesh_compute_vs* tests. The Linux build was not affected; run_gpu_tests.py on the same combination has no failures on either GPU.

AI-assisted (Claude Code).

…bset, clang-cl)

- A --mesh-compute PSO is refused unless the compute stage is guaranteed the mesh shader's subgroup size
  (emulated, required by the stage, or the device's only size); OPTIONS7 reports tier 1 only where every
  --mesh-compute mesh shader in the index passes (Flyander, P1).
- The path needs VK_QUEUE_COMPUTE_BIT on the Direct queue's family, for the PSO and the tier (Flyander, P2).
- A PS reading the f16 halves of some of the exported params links; only halves read where the layout doesn't
  export them are refused (tupacfan04).
- The graphics push-constant range size is an explicit uint32_t (clang-cl narrowing; ligmaSec, ddm-j).
- d3d12_mesh_compute_test covers the refusals: 144 push-constant bytes and subgroup sizes that can't be required
  hide the tier and refuse the PSO (an emulated mesh shader is still created), plus the f16 subset and mismatch.

RX 5700 XT, AMD 26.11.2, Windows 11: ctest 164/164; d3d12_mesh_compute clean under the validation layer.

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

Copy link
Copy Markdown
Contributor Author

Thanks for the reviews and the runs. The fixes are in fdd4667, on the same base:

  • @Flyander P1 (subgroup size): a --mesh-compute PSO is now refused with a log unless the compute stage is guaranteed the mesh shader's subgroup size. That means the shader is emulated (--wave64-emulate), the stage requires the size, or the size is the device's only one. A size that is only the default counts as not guaranteed. OPTIONS7 reports tier 1 only if every --mesh-compute mesh shader in the index passes the same check.
  • @Flyander P2 (queue): the path now also needs VK_QUEUE_COMPUTE_BIT on the Direct queue's family, both for the PSO and for the tier.
  • @ligmaSec, @ddm-j (clang-cl): the push-constant range size is now an explicit std::uint32_t.
  • @tupacfan04:
    1. A PS that reads the halves of some of the exported params now links. Only halves read where the layout doesn't export them are refused.
    2. d3d12_mesh_compute_test now covers the refusals. A device with 144 push-constant bytes and one whose subgroup sizes can't be required both hide the tier and refuse the PSO, and an emulated mesh shader is still created on the second. It also covers the f16 subset and the mismatch. The native path stays d3d12_mesh_test's.
    3. The HOLD is right: it stays a draft until Runtime: mesh-shader PSOs from pipeline state streams and DispatchMesh (D3D-29) #1712 and Runtime: ExecuteIndirect with DISPATCH_MESH signatures and the M5 mesh gate (translated mesh shader) #3777 land.
  • @ligmaSec: thanks for running ms_m5.asm under --mesh-compute through the layer. That was the case the description listed as untested, so the description now points to your run.

Re-tested on the RX 5700 XT (AMD 26.11.2, Windows 11): ctest 164/164 (the four tests that need VK_EXT_mesh_shader skip). d3d12_mesh_compute passes under LEONIDA_VK_VALIDATION=1 with no messages.

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.