Skip to content

Runtime: ExecuteIndirect with DISPATCH_MESH signatures and the M5 mesh gate (translated mesh shader) - #3777

Open
zneel wants to merge 22 commits into
ItsNotRexed:mainfrom
zneel:m5-mesh
Open

zneel wants to merge 22 commits into
ItsNotRexed:mainfrom
zneel:m5-mesh

Conversation

@zneel

@zneel zneel commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: the mesh half of milestone M5 (claim). Item ID: TBD.

Depends on: #1712 (D3D-29, mesh PSOs and DispatchMesh)
Depends on: #1865 (D3D-248, M5 without mesh: ExecuteIndirect draws carry the list's graphics state)

This branch is main aa2988cc, with #1712 and then #1865 merged in, plus my commits after them. The merges were resolved here because both PRs conflict with main now. #1865's indirect draws needed a small port to main's new PreparedDraw table: an indirect draw gets its own entry, as a Draw does. Only the commits after the second merge are for review: git diff fab9084c..HEAD.

Scope note: the test's mesh shader reads its root constants from s0..s2, where the layer packs them today, not from s16, the mesh user-data base the corpus reads. That base is listed under findings below.

What and why

9,282 of the game's 26,503 shaders are mesh shaders. #1712 adds mesh PSOs and DispatchMesh, and #1865 the synthetic M5 gate without mesh. Two pieces were still missing, and this PR adds both.

  • ExecuteIndirect with DISPATCH_MESH command signatures. CreateCommandSignature answered E_NOTIMPL for them.
    • It now takes them where VK_EXT_mesh_shader is enabled; without it they stay E_NOTIMPL, like mesh PSOs.
    • DISPATCH_MESH must be the only argument. Root constants or views before it stay E_NOTIMPL, because multi-argument signatures are not expanded (D3D-283).
    • D3D12_DISPATCH_MESH_ARGUMENTS and VkDrawMeshTasksIndirectCommandEXT are the same three dwords, so records are read as they are.
    • The call records the state DispatchMesh takes, and replays as a whole draw: vkCmdDrawMeshTasksIndirectEXT, or vkCmdDrawMeshTasksIndirectCountEXT with a count buffer.
    • The calls are split by multiDrawIndirect and maxDrawIndirectCount, as Runtime: milestone M5 synthetic gate (without mesh) — ExecuteIndirect draws render now, multi-threaded lists, 5,120-SRV bindless table, pipeline cache #1865 splits the draw kinds.
    • A DISPATCH_MESH call with a VS PSO, or a draw signature with a mesh PSO, is ReplayResult::invalid_draw.
  • A translated mesh shader through the layer. Runtime: mesh-shader PSOs from pipeline state streams and DispatchMesh (D3D-29) #1712's test uses a GLSL stand-in and lists translated mesh shaders as untested.
    • runtime/test/shaders/build.py skipped every ms_ shader, since it made no PSV0. It now builds one for a mesh shader whose header has ; psv0: THREADS MAX_VERTICES MAX_PRIMITIVES.
    • The new ms_m5.asm is an NGG wave64 mesh shader of 128 threads (two waves). It uses the corpus's idioms: the group index from v5 (v_readfirstlane_b32, >> 7), the thread id from s3[27:24] and mbcnt, thread-0 GS_ALLOC_REQ, and one vertex and one primitive export per thread.
    • It goes through rdna2spirv.py, and the mesh stage requires subgroup size 64. The test exits 77 where the device can't run it 64-wide (NVIDIA, Intel), or has fewer than 144 push-constant bytes.

New test: d3d12_m5_mesh_test

Through the proxy, D3D12 API only, with PSOs from pipeline state streams. Every pixel is compared with a CPU reference, error 0.

  • (a) DispatchMesh: 4×2×2 (16 cells, so every group got its own index), 3×1×1 and 1×1×1 at other cells and colours, plus an empty grid.
  • (b) ExecuteIndirect DISPATCH_MESH, with additive blending. A cell's colour counts the records whose group count reached it, so each record's counts show in the pixels.
    • 5 CPU-written records at offset 36, stride 12, one of them empty.
    • 4 records, stride 24, copied by the GPU into a default buffer (COPY_DEST → INDIRECT_ARGUMENT), with a count buffer of 3.
    • A count of 0.
    • A count of 7 under MaxCommandCount 2.
    • 20 records of 1 to 4 groups at stride 24 with zeroed padding, in one call. Read at the wrong stride, half of them would be empty.
    • Only a record's group total shows in the pixels. How it splits into X, Y and Z, and the order groups are numbered in, are not visible to the shader.
    • Without drawIndirectCount, the count-buffer calls are left out.
  • d3d12_m5_mesh_fallbacks: the same test with --single-calls --no-count-buffers, which turns multiDrawIndirect and drawIndirectCount off on the layer's device. So the one-call-per-record path runs on any GPU that runs the test at all (it needs 64-wide mesh subgroups, so not NVIDIA or Intel; thanks @CowBoYdu76), and a count-buffer call must come back ReplayResult::unsupported.
  • d3d12_m5_mesh_chunks: the same test with --max-draw-indirect-count 3, which lowers the layer's limit so the 20 records are split into calls of 3.
  • (c) Refusals: a stride below 12 is E_INVALIDARG, a root constant before DISPATCH_MESH is E_NOTIMPL, and a device without the extension gives E_NOTIMPL. A wrong-kind draw fails at execution, in both directions.
  • tests/test_shader_build_mesh.py checks that build.py's container matches run_gpu_tests.py's byte for byte.

Findings left open (not changed here)

  • The mesh user-data base. The layer packs root arguments from s0 for every stage. The corpus reads mesh user data from s16 (§3.5 census).
  • s3 is not user data in a mesh shader. In the translator's mesh ABI, s3 is the merged wave info. Under the s0 packing, a mesh shader therefore can't reach a fourth root dword. ms_m5.asm reads s0..s2 only.
  • These two belong with the root-parameter visibility and user-data work (D3D-318, D3D-329), so I left them alone.
  • Neighbour: D3D-291 (Runtime: pipeline-statistics queries around mesh draws (D3D-291) #2359). An indirect mesh draw inside a PIPELINE_STATISTICS query meets the same restriction as DispatchMesh there.
  • GPU-side group counts. A record's group counts are GPU data, so D3D12's limits (65535 per count, 2^22 groups) are not checked on replay. Counts above the device's maxMeshWorkGroupCount are undefined on both APIs.

Tested

AMD Radeon RX 9070 XT (RDNA4, wave64 native), AMD Software 26.11.2, Windows 11 Pro 26300, Ryzen 7 9800X3D / 64 GB. MSVC 19.51 (VS 18), Ninja, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8.

  • d3d12_m5_mesh_test: passes, with required subgroup size 64 for the mesh stage. 0 mismatched pixels in (a) and (b), 30 records drawn (count buffers included).
    • Also with --single-calls --no-count-buffers (25 records, one call each; the count-buffer call is unsupported) and with --single-calls alone.
    • All three runs with LEONIDA_VK_VALIDATION=1, which also turns on synchronization validation: 0 messages.
  • Mutation checks: each fault injected into the mesh indirect replay makes the test fail.
    • Skipping a record, and ignoring the count buffer: 1,024 wrong pixels.
    • Chunks that don't advance: 320 wrong pixels in d3d12_m5_mesh_chunks.
    • A stride hard-coded to 12: 256 wrong pixels in both runs.
  • Validation: the test now fails on validation errors, as its sibling tests do.
  • Review: two review passes (Fable 5.2, one adversarial) found no defect in the path on valid input. Their fixes are in 7cbaab6. The regression they found was a multi-argument mesh signature being accepted and misread; it is refused again.
  • Full ctest (Release with debug info, -j 4): at 7cbaab6, 143 of 143 pass without d3d12_present (it opens a window), the three d3d12_m5_mesh* tests included; those three also pass with validation on. Before the review fixes: 144 of 144. After the fallback test was added, a rerun without d3d12_present (it opens a window) passed 142 of 142, d3d12_m5_mesh_fallbacks included. 7 of them skip on this machine: they need game files, or a tool that isn't installed here (shader_library_corpus, bink_decode, fsr_dispatch, bvh_builder, bink_audio, vk_sync_validation, d3d12_first_light). d3d12_mesh, d3d12_m5_world, d3d12_indirect_rt, d3d12_indirect_zero, d3d12_draw and d3d12_vulkan_device pass.
  • GPU suite: scripts/run_gpu_tests.py 185 of 205 pass and 20 skip, the same native and with LEONIDA_W64_EMULATE=1, with no failures; ms_m5 and ps_m5_mesh show as run by d3d12_m5_mesh_test.
  • Python: tests/test_ctest_registration.py, tests/test_shader_checks.py 78 passed; tests/test_shader_build_fallbacks.py, tests/test_first_light.py 12 passed / 3 skipped; tests/test_shader_build_mesh.py 4 passed; tests/test_run_gpu_tests*.py and test_run_gpu_pixel_checks.py/test_run_gpu_wavemask.py pass.

Checklist

  • No game data, keys or decryption (hand-written shaders, synthetic FSSM words)
  • Registered with ctest (d3d12_m5_mesh, d3d12_m5_mesh_fallbacks, d3d12_m5_mesh_chunks, SKIP_RETURN_CODE 77). Its shaders are in run_gpu_tests.py's D3D12-harness list, and run_gpu_tests.py gives a mesh shader with a psv0: header its PSV0, as build.py does
  • docs/d3d12_vulkan.md: §3.6, §4.7 and the M5 row

AI-assisted (Claude Code).

🤖 Generated with Claude Code

AlxcBTW and others added 13 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>

@whattheflop whattheflop 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.

AI-assisted verification at 9e6fe557. Native Radeon iGPU result: both 4,096-pixel readbacks exactly matched, with zero core or synchronization validation warnings/errors. This adds default-wave64 coverage on a device that can require a subgroup size only for compute. All four generated modules passed validation, and the CPU callbacks passed fixed, chunked, single-record and counted emission. Windows uv Python checks: 167 passed, three skipped and 296 subtests passed.

Two test-gate details remain in the exact head:

  • The wave64 skip occurs after both mesh PSOs are created. Checking the compatible subgroup outcome before PSO creation would let an unsupported device skip even if its PSO creation fails.
  • The stock return value only includes pixel mismatches; include d.validation_errors() so a validation error also fails CTest. The run above reported zero through teardown.

The GPU run used the valid-only wrapper and did not execute the refusal cases.

@kacper-serewis kacper-serewis 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.

9e6fe55, RTX 5070 driver 616.56. Stock runs skipped on 32-wide subgroups. Regenerating synthetic shaders for wave64 emulation gave exact indirect pixels in both modes (30 ordinary records including count-buffer cases; 25 fallback records, count buffers correctly unsupported). Wrong-pipeline controls failed as expected. Separate direct DispatchMesh comparison differed at 2,816 pixels in each run; first six reported RGB 127 vs 128, alpha 255. Both dependency heads #1712 and #1865 are ancestors. No attribution yet for direct mismatch. AI-assisted.

@kacper-serewis kacper-serewis 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.

The direct discrepancy is now localized: all 1,280 painted pixels matched; all 2,816 untouched pixels were grey 127 versus the expected 128, alpha 255. Stock #1712 d8102a2 blue clear passed 4,096/4,096; applying the same grey midpoint on that dependency reproduced the discrepancy on all 1,536 untouched pixels only. An exactly representable clear would preserve strict assertions. Integrated indirect controls still matched all 30 ordinary and 25 fallback records. RTX 5070 driver 616.56, wave64 emulated. AI-assisted.

@CowBoYdu76

Copy link
Copy Markdown
Contributor

Tested 9e6fe55 (based on main f847748) on Windows 11 build 26300, MSVC 19.44, Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, with two GPUs picked by LEONIDA_VK_DEVICE: RTX 4070 SUPER (NVIDIA 616.64) and Intel UHD 770 (101.7092): no regression. As the description says, the new test can't run on these two GPUs, so this only covers the rest of the suite.

4070 SUPER UHD 770
d3d12_m5_mesh_test 77: ms_m5 (ms) is a 64-wide shader but this device cannot require that subgroup size (sizes 32..32) 77: no VK_EXT_mesh_shader (d3d12_mesh skips here too)
d3d12_m5_mesh_test --single-calls --no-count-buffers 77, the same reason 77
d3d12_mesh_test, d3d12_m5_world_test, d3d12_indirect_rt_test, d3d12_state_map_test exit 0 exit 0 (d3d12_mesh 77; ray queries are reported as skipped in d3d12_indirect_rt)
all of these under VK_LAYER_KHRONOS_validation 0 messages 0 messages
full ctest 144/144 (d3d12_m5_mesh and d3d12_m5_mesh_fallbacks skipped) 142/144: d3d12_descriptor and d3d12_subgroup, as on main (#2948, #2934)

One point on wording: d3d12_m5_mesh_fallbacks uses the same wave64 ms_m5, so it skips wherever the main test does. The one-call-per-record path therefore runs only on wave64-capable GPUs, not "on any GPU". build.py applies --wave64-emulate to compute shaders only, so I couldn't cover it on NVIDIA. A wave32 mesh shader for the fallback case, such as #1712's GLSL stand-in, would let NVIDIA run it.

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

@crastinator

Copy link
Copy Markdown
Contributor

Tested 9e6fe55 merged into main f847748c (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: 185/205 native, 185/205 with LEONIDA_W64_EMULATE=1 (skips: 20: the D3D12-only fixtures and ps_w64x_readlane as on main, plus the new M5 mesh fixtures, which a D3D12 test owns). ctest 41/41.
  • tests/test_shader_build_mesh.py: 4 passed.

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

zneel and others added 7 commits November 22, 2026 23:50
# 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>
mrp1no added a commit to mrp1no/Leonida that referenced this pull request Nov 22, 2026
…the host does

The command-signature comparison now also covers INCREMENTING_CONSTANT and
DISPATCH_MESH: 26 more values, 14 of which differed (RTX 3060, driver 610.88).

- An incrementing constant follows the root-constant rules: a root-constants
  parameter, an offset inside it, and no overlap with that parameter's other
  constants. The layer accepted any.
- The host refuses an index buffer view with a mesh dispatch, so an index
  buffer view now comes only with an indexed draw. A vertex buffer view with
  a mesh dispatch is taken.
- The host takes mesh-dispatch signatures, which the layer still answers
  with E_NOTIMPL until indirect mesh dispatch lands (ItsNotRexed#3777). The test leaves
  those four out of the comparison and says why.

177 values compared, 0 mismatches.

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

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

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown

@zneel heads-up: on an RTX 5080 the three M5 mesh tests skip (no 64-wide mesh), and with LEONIDA_W64_EMULATE=1 DispatchMesh gives 2816 pixels at 127 instead of 128 (ExecuteIndirect DISPATCH_MESH is exact). I claimed the follow-up to make the gate run on 32-wide GPUs, based on this branch (#4084 (comment)). If you would rather do it yourself, tell me and I drop it.

@tupacfan04

Copy link
Copy Markdown
Contributor

PASS as a draft. The gate is correct: the mesh signature/PSO is taken only with VK_EXT_mesh_shader and a translated ms entry (d3d12_vulkan_device.cpp:5052-5057,2830-2831,2960), and the test additionally requires library.find("ms", sha) before using it (d3d12_m5_mesh_test.cpp:158-163). The arguments read correctly too: D3D12_DISPATCH_MESH_ARGUMENTS is the same 12 bytes/order as VkDrawMeshTasksIndirectCommandEXT, stride >= 12 and %4 are enforced (:5044), the record size is vulkan_replay.h:1434, splitting honours multiDrawIndirect/maxDrawIndirectCount (:2106-2113), the count path is :2082, and a wrong-kind PSO gives invalid_draw (:1935).

Minor: runtime/test/shaders/build.py:185-186 takes the ms_ branch unconditionally, so ms_container(*asm_psv0(...)) raises TypeError for an ms_ shader without a psv0: header when translate_tests is called directly (main() filters at :220, run_gpu_tests.py:730 guards).

The branch is stacked on unmerged #1712/#1865, so fab9084c..536cb939 is the reviewable delta; merge is clean.

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

@Exopus-0x65f7ad0

Copy link
Copy Markdown

Tested 536cb939 on NVIDIA GeForce RTX 5060 Ti (Blackwell), driver 621.14, Windows 11 (26300), MSVC 14.51 (VS 2026) RelWithDebInfo, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8 (scripts/build_llvm_mc.ps1) so the translated-shader tests are built.

  • LEONIDA_VK_VALIDATION=1 ctest -C RelWithDebInfo -j4: 149/149 passed, 0 VUID messages in the log, including d3d12_m5_world, d3d12_mesh, the M1.5–M4 gates and d3d12_translated_draw.
  • d3d12_m5_mesh, d3d12_m5_mesh_fallbacks, d3d12_m5_mesh_chunks: skipped (exit 77), as expected on NVIDIA: SKIP: the wave64 mesh shader cannot run 64-wide here (subgroup sizes 32..32, default 32, requirable stages 0x3fff). Running the test with LEONIDA_W64_EMULATE=1 on this build skips too, since the test shaders were translated without --wave64-emulate (the runtime says so: "translate wave64 ms shaders with --wave64-emulate for this GPU"); so I couldn't reproduce @tedin7's 127-vs-128 result on this build. That 32-wide follow-up is theirs.
  • Other skips, unrelated: shader_library_corpus, bink_*, gameinput, d3d12_rgb9e5_rtv, d3d12_first_light.

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

@ddm-j

ddm-j commented Nov 23, 2026

Copy link
Copy Markdown

Tested 536cb93 under Wine 11.21 (Fedora 45) on AMD Radeon 610M iGPU (RDNA2 gfx1036, RADV Mesa 26.2.6, subgroup 32..64) and NVIDIA RTX 4070 Ti (615.78.08, subgroup 32..32): pass. This is the first run of this head on RDNA2, and so the first time the M5 mesh gate has run 64-wide natively on it; the RX 6700 XT result above was on 9e6fe55.

M5 gates (Windows runtime cross-built with clang-cl + xwin):

Test RADV (native wave64 mesh) RTX 4070 Ti
d3d12_m5_mesh Passed: translated wave64 mesh shader (128 threads, required subgroup size 64), DispatchMesh 4x2x2 / 3x1x1 / 1x1x1 / empty grid, 0 mismatched pixels; ExecuteIndirect DISPATCH_MESH, 30 records drawn (count buffers included), 0 mismatched pixels; wrong-kind indirect draws fail at execution Skipped: "the wave64 mesh shader cannot run 64-wide here (subgroup sizes 32..32)"
d3d12_m5_mesh_fallbacks Passed (one call per record, no count buffers) Skipped, same reason
d3d12_m5_mesh_chunks Passed (same 0-mismatch line) Skipped, same reason
d3d12_m5_world Passed: every pixel matched the CPU reference (error 0) Passed, same
d3d12_mesh Passed Passed

Full suites, base aa2988c → this PR:

base this PR
Wine ctest, RADV 129 passed, 21 skipped, 1 failed (of 151) 134 passed, 21 skipped, 1 failed (of 156)
Wine ctest, RTX 4070 Ti 130 passed, 21 skipped, 0 failed (of 151) 131 passed, 24 skipped, 1 failed (of 156)
run_gpu_tests.py, RADV / 4070 / 4070 with LEONIDA_W64_EMULATE=1 196/210, 164/210, 195/210 196/216, 164/216, 195/216

Not covered here: the emulated 32-wide case @tedin7 reported (2816 pixels at 127 instead of 128). Setting LEONIDA_W64_EMULATE=1 when running ctest doesn't re-translate ctest's prebuilt mesh shader, so on the 4070 the gates still skip. That needs the test shaders built with --wave64-emulate, which is their follow-up.

Nit: d3d12_m5_mesh_test.cpp:176-179 copies multi_draw_indirect, draw_indirect_count and max_draw_indirect_count from the test device into the layer's VulkanDeviceInfo, but not draw_indirect_first_instance (as d3d12_m5_world_test.cpp:204 does). So the layer logs drawIndirectFirstInstance is not enabled twice per run on devices that have it. It's harmless for DISPATCH_MESH, which has no instance field.

AI-assisted (Claude Code); numbers copied from the run logs.

mrp1no added a commit to mrp1no/Leonida that referenced this pull request Nov 23, 2026
…the host does

The command-signature comparison now also covers INCREMENTING_CONSTANT and
DISPATCH_MESH: 26 more values, 14 of which differed (RTX 3060, driver 610.88).

- An incrementing constant follows the root-constant rules: a root-constants
  parameter, an offset inside it, and no overlap with that parameter's other
  constants. The layer accepted any.
- The host refuses an index buffer view with a mesh dispatch, so an index
  buffer view now comes only with an indexed draw. A vertex buffer view with
  a mesh dispatch is taken.
- The host takes mesh-dispatch signatures, which the layer still answers
  with E_NOTIMPL until indirect mesh dispatch lands (ItsNotRexed#3777). The test leaves
  those four out of the comparison and says why.

177 values compared, 0 mismatches.

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

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown

Tested 536cb939 on an NVIDIA GeForce RTX 5080 (Linux, driver 580.65.06, VK_EXT_mesh_shader, 32-wide subgroups only), runtime cross-built with clang-cl/xwin, run under Wine 11, on top of #1712 (its own 7 commits fab9084c..536cb939 cherry-picked, because the branch carries older merges of #1712/#1865 that conflict in 9 files):

  • As shipped the test skips (77) here: "the wave64 mesh shader cannot run 64-wide here (subgroup sizes 32..32)", so on NVIDIA it never runs.
  • Rebuilt with LEONIDA_W64_EMULATE=1: every ExecuteIndirect DISPATCH_MESH part passes (30 records, 0 mismatches; the same in the fallbacks and chunks runs).
  • The direct DispatchMesh part reports 2,816 mismatches, and they are exactly the background: a 0.5 clear stored as 127 where the test expects 128. 0.5 × 255 = 127.5 may round either way within D3D12's float-to-UNORM tolerance, so this looks like the test's exact expectation, not the layer; the mesh cells themselves are exact. Accepting 127 or 128 for the clear (or clearing to an exactly representable value) would fix it.
  • User data base. ms_m5.asm reads its root constants from s0..s2 "as the layer packs root constants today", but title mesh shaders read user data from s16 (docs/d3d12_vulkan.md 3.5: s16 in 7,977 of 9,282), and rdna2spirv says user data follows in s16.. from push constants. With today's packing (root parameter 0 at dword 0 for every stage), a title mesh shader would read its first pointer from dword 16, not from parameter 0. A separate synthetic test of ours with a translated wave64 mesh shader reading s16 (dwords 0-15 filled with a pattern it never reads) passes through DispatchMesh under --wave64-emulate, so the path works; the question is only which dword the layer should put parameter 0 at for mesh shaders.
  • Conflict with Runtime: ExecuteIndirect with multi-argument command signatures (root constants/descriptors, VB/IB views per record) on VK_EXT_device_generated_commands #2077. Runtime: ExecuteIndirect with DISPATCH_MESH signatures and the M5 mesh gate (translated mesh shader) #3777 adds DISPATCH_MESH to the single-kind CreateCommandSignature; Runtime: ExecuteIndirect with multi-argument command signatures (root constants/descriptors, VB/IB views per record) on VK_EXT_device_generated_commands #2077 replaces that with build_indirect_signature/IndirectSignature. Porting it there worked: DISPATCH_MESH only as the sole argument (otherwise E_NOTIMPL, the same rule as here), a new IndirectArgumentType::dispatch_mesh, E_NOTIMPL without VK_EXT_mesh_shader, and prepare() checking the count variant. Whichever of the two lands second needs that port.

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

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.