Skip to content

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

Open
zneel wants to merge 25 commits into
ProjectLeonida:mainfrom
zneel:m5-mesh
Open

zneel wants to merge 25 commits into
ProjectLeonida: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)

Merge order: #1712, then #1865, then this PR. This branch is main 561b65a8, with #1712's current head c2376390 merged in unchanged (a clean merge, so its two commits are ancestors here and no second copy of the mesh PSO code is carried), then #1865 9a74588b, then my commits. If #1712 or #1865 lands first, this PR's diff shrinks to its own part. If they move again, I rebuild the branch the same way.

#1865 conflicts with main, so its merge (7ca3311f) was resolved here. Two resolutions go beyond picking sides:

Only the commits after the #1865 merge are for review: git diff 7ca3311f..HEAD. The first of them (7c6d99a2) is a fix to #1712's DispatchMesh: main's bundles record through defer() and replay at ExecuteBundle. Without it, Close() fails on a bundle that contains a DispatchMesh (@Stalkerino reproduced this on #1712 and wrote a test for it). It belongs in #1712; if #1712 takes it, I drop it here.

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 8), on main 561b65a8: 237 pass and 11 skip (game data or optional tools), without d3d12_present (it opens a window). 4 fail, and each fails the same way on main 561b65a8 alone on this GPU: d3d12_indirect_dispatch_count (the layer gives 0/0 for "count 0 update 1", where 6/10 is expected), vk_queue_query_sync, d3d12_texture_tiles and d3d12_pipeline_library_host.
  • 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 11 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
…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).

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>
@zneel
zneel marked this pull request as ready for review November 22, 2026 23:07
@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

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

@controldebils

Copy link
Copy Markdown
Contributor

@zneel a retail data point for this PR: the 1.0.2.1 title creates a DISPATCH_MESH command signature at boot, so the Vulkan backend's E_NOTIMPL for it is an RT-5 boot stop.

RX 6900 XT (RDNA2), Windows 11, MSVC, LEONIDA_D3D12=vulkan, own copy, main plus the open boot-chain PRs (#6982's stops 1-21):

  • At startup the title creates five one-argument command signatures, all without a root signature: DRAW (stride 16), DRAW_INDEXED (20), console type 105 (12, d3d12_xs: a console indirect argument of type 105 is created as DISPATCH (device slot 41, RT-5 stop 19) #7163), DISPATCH (12) and DISPATCH_MESH (12).
  • Without DISPATCH_MESH support, CreateCommandSignature returns E_NOTIMPL and the title's HRESULT check asserts. This happens on every Vulkan-backend run, whatever the GPU.
  • VK_EXT_mesh_shader is enabled on this AMD Windows driver for gfx1030. A local stand-in with this PR's surface (single-argument DISPATCH_MESH -> IndirectKind::dispatch_mesh, S_OK) gets the title past it. That is exactly this PR's single-argument, stride-12, no-root-signature case.
  • Between creating these signatures and our next stop, the title makes 0 ExecuteIndirect calls (--trace-d3d12), so whether it uses the mesh signature at run time isn't known yet.
  • The title also creates a plain DISPATCH signature, so @Kam471's count-buffer DISPATCH regression in emit_indirect matters for the retail path once it executes them.
  • A trial merge of f8b197868 into that local stack (not main alone) conflicts in 6 files: runtime/shims/d3d12_com.cpp, runtime/src/command_list.h, runtime/src/vulkan_backend.h, runtime/src/vulkan_replay.h, runtime/test/d3d12_mesh_test.cpp (add/add) and docs/d3d12_vulkan.md.

AI-assisted (Claude Code).

@zneel

zneel commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@Kam471 thanks for digging, but that snippet isn't this PR's head. At f8b1978, emit_indirect (runtime/src/vulkan_replay.h:2221) starts with

if (ind.count_buffer && ind.kind != IndirectKind::dispatch) {

So a counted DISPATCH skips the early return and reaches the bottom loop, which dispatches from p.counted_dispatch.indirect at offset + k * 12. That is the #1865 merge resolution listed in the PR body. The if (ind.count_buffer) { ... return; } you quote is in your assist-3777-rebased (a4e5561a), which doesn't carry that resolution. Your fix is the right one for that branch.

The 0/0 for "count 0 update 1" is a separate problem, and it comes from main. I built main 561b65a8 on its own, without #1712, #1865 or this PR, and d3d12_indirect_dispatch_count fails there the same way on an RX 9070 XT (layer 0/0, expected 6/10). @KiryaAfimin saw the same on an RTX 4070 with main alone, and #6162 traces it to #4312: cs_indirect_dispatch_count.comp still reads its root UAV from s0:s1. On your branch, that shader fix alone can't help, because the early return also drops the dispatch; on this head I'd expect it to be the only fix needed, though I haven't tested that.

AI-assisted (Claude Code).

zebraso pushed a commit to zebraso/Leonida that referenced this pull request Nov 23, 2026
…device with mesh shaders

The Vulkan layer created signatures for draw, draw-indexed and dispatch only and answered E_NOTIMPL
for DISPATCH_MESH, which the PC runtime creates on any mesh-shader tier 1 device. A title that
creates such a signature at startup and asserts on the result stopped there.

The signature is created when the device has VK_EXT_mesh_shader (MeshShaderTier 1), as a new
IndirectKind::dispatch_mesh (the name and value ItsNotRexed#3777 uses, so the two merge). ExecuteIndirect with
it records nothing yet and says so once; ItsNotRexed#3777 replays it as vkCmdDrawMeshTasksIndirectEXT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zneel pushed a commit to zneel/Leonida that referenced this pull request Nov 23, 2026
…device with mesh shaders

The Vulkan layer created signatures for draw, draw-indexed and dispatch only and answered E_NOTIMPL
for DISPATCH_MESH, which the PC runtime creates on any mesh-shader tier 1 device. A title that
creates such a signature at startup and asserts on the result stopped there.

The signature is created when the device has VK_EXT_mesh_shader (MeshShaderTier 1), as a new
IndirectKind::dispatch_mesh (the name and value ItsNotRexed#3777 uses, so the two merge). ExecuteIndirect with
it records nothing yet and says so once; ItsNotRexed#3777 replays it as vkCmdDrawMeshTasksIndirectEXT.

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

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

@zneel: this PR conflicts with main in 6 files (command_list.h, vulkan_backend.h, vulkan_replay.h, d3d12_com.cpp, d3d12_mesh_test.cpp, docs). To save you the work I merged current main into your head, keeping both sides: https://github.com/tedin7/Leonida/tree/zneel-m5-rebased (one merge commit 2ff59abfd, your commits and authorship untouched, nothing force-pushed anywhere). Pod check (Wine, RTX 4090): d3d12_mesh_test exit 0, d3d12_state_map_test exit 0, d3d12_m5_mesh_test skips (needs 64-wide mesh, 32-wide GPU here); d3d12_indirect_rt_test fails on RayQueryKHR ARRAY exactly as on current main (not from this PR, see #8186 marso006). You are welcome to git merge that branch into yours, or ignore it and rebase your own way. I will not open a PR from it unless you say so. AI-assisted.

@editrice

Copy link
Copy Markdown

Review finding at current head f8b19786: a valid direct mesh list's DispatchMesh(0, 1, 1) reaches record_mesh_draw and calls list_.draw(make_mesh_draw(...)). That prvalue selects CommandList::draw(Draw&&), whose zero-count guard returns false; check(false) makes the later Close() return E_INVALIDARG. DispatchMesh(1, 1, 0) instead records a draw, although an empty grid should record nothing. The PR's d3d12_m5_mesh_test itself has a direct DispatchMesh(0, 1, 1) // empty followed by end()/Close. Please handle any zero dimension after PSO/root validation and before draw construction, and isolate all three zero-axis Close checks in the synthetic test. The current head also needs rebasing onto main before a new test run. AI-assisted (Codex).

@berkay8987

Copy link
Copy Markdown
Contributor

@zneel a note on why five of the six conflicts exist, and a check of @tedin7's merge above.

Why: this branch carries #1712's two commits, and #1712 is already on main through #2359 (squash-merged at 15:34; details on #1712). So Depends on: #1712 is met by main. With #1712's head (c2376390) as the merge base, this PR's own changes conflict with main 67d87739 in one place only: the top of execute_indirect in runtime/src/command_list.h. A plain git rebase --onto origin/main c2376390 does not get you there, though: the branch has 8 merge commits and the rebase stops 6 times, so @tedin7's merge is the simpler route.

@tedin7's 2ff59abf: I compared it with that one-conflict result on the same main (dde82f27). It differs in three places, and all three are needed:

  1. command_list.h, execute_indirect: main's alignment checks from d3d12: match Windows recording-time ExecuteIndirect validation #6830 plus this PR's two mesh-state checks, with main's first line replacing this PR's if (!indirect.argument_buffer || !indirect.stride).
  2. d3d12_com.cpp, ExecuteIndirect: IndirectKind::dispatch_mesh ? sizeof(D3D12_DISPATCH_MESH_ARGUMENTS) in the record size of d3d12: match Windows recording-time ExecuteIndirect validation #6830's recording-time check. main has no dispatch_mesh kind, so without this line the size is 0 and every DISPATCH_MESH ExecuteIndirect fails at recording.
  3. vulkan_replay.h, plan_statistics_segments and plan_overlapping_statistics_segments: a DISPATCH_MESH call counts as a mesh draw in Runtime: pipeline-statistics queries around mesh draws (D3D-291) #2359's statistics split (VUID-07076), not as a vertex draw.

2 and 3 are not textual conflicts, so a merge or rebase that only clears the conflict markers would drop them without any error. The test that drives them, d3d12_m5_mesh_test, needs a 64-wide mesh stage and skips on 32-wide GPUs (as on @tedin7's 4090), so they are not exercised on NVIDIA; a run on an AMD card with native wave64 would cover them.

AI-assisted (Claude Code). Git analysis only, no build or GPU run.

@fuzeofficlal

Copy link
Copy Markdown

Native AMD wave64 check of the review-only rebase at 2ff59abfd21c34956e62d95819db61c7910854e5, following the request for AMD coverage.

  • Windows AMD Radeon gfx1036 (32.0.21042.62), with Khronos Vulkan validation 1.4.369. All three stock M5 CTests passed at native subgroup size 64. Direct and indirect draws had zero pixel mismatches. The default and chunked variants drew 30 indirect records each, and the no-count/single-call variant drew 25. The wrong-kind draws were rejected as expected. All four synthetic shader modules passed spirv-val, and the M5 tests produced no validation errors.
  • RTX 5090 (616.56) reported subgroup size 32 and skipped all three wave64 mesh variants as expected.
  • The main parent dde82f27 has no stock M5 target. I used the same fixture and shader modules in a scratch build, omitting the newer multi-draw/count capability fields to match its headers. The fixture reached the DISPATCH_MESH signature assertion and failed on creation of the valid 12/24-byte signature. The unmodified single-call variant passed on the rebase. The separate legacy d3d12_mesh test emitted the same three VUID-07076 messages on both revisions (TEST-1698).

@XIIYAZ

XIIYAZ commented Nov 23, 2026

Copy link
Copy Markdown

Retail boot test (RT-5): own 1.0.2.1 copy, Windows 11, i9-12900KF (Intel, no SSE4a/CLZERO/MONITORX), RTX 3070 (NVIDIA 617.42), MSVC 2022 RelWithDebInfo, LEONIDA_D3D12=vulkan, network shimmed (#6943), OBS/RTSS layers disabled. Local integration on main dde82f27e with about 35 open PRs (the boot chain through #7235, #7858, #7163, #3777, #7115, #7323, #8529, #7201, #7111, #7403, #7290, #7949, #7286, #7880). Counts and outcomes only.

Retail result on NVIDIA: clears the DISPATCH_MESH command-signature stop (after #7163's type 105, the title's next signature is DISPATCH_MESH). Merge notes against current main: d3d12_vulkan_device.cpp must keep #7858's host_stall::Scope around create_pipeline() for compute PSOs; command_list.h should keep main's stride/offset/count alignment checks and add this PR's two state checks; vulkan_replay.h and d3d12_com.cpp take this PR's emit_indirect / record_mesh_draw (which keeps main's zero-viewport check). 17/17 mesh, indirect and proxy tests pass on the RTX 3070.

AI-assisted test run.

@tunczzz

tunczzz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested f8b19786 (merge base 561b65a8) on Windows 11 10.0.26300 with an NVIDIA GeForce RTX 5070 Ti (Blackwell, subgroup 32..32), driver 616.56. Result: pass (no failure that main doesn't have).

Not run: other GPUs/vendors, Linux, anything that needs game files. No game files.

AI-assisted (Claude Code).

@rideinstead

Copy link
Copy Markdown

✅ Automated security review: CLEAN (commit f8b19786)

  • No findings.

Scope: static analysis of added diff lines only; no code was executed. Please review findings manually.

@SirKingg

Copy link
Copy Markdown
Contributor

Independent Windows/MSVC temporary integration against the descriptor/list boot stack: reconciled six mesh/command-list/replay conflicts and retained its current indirect-buffer bounds checks. One integration adjustment was needed in GraphicsCommandList::ExecuteIndirect: its record-size validation must recognize DISPATCH_MESH instead of rejecting that kind before replay.

On an RTX 4070 Ti (driver 610.88), the existing GLSL mesh test passed. The native translated M5 mesh test correctly skipped on the 32-wide-only device; in a separately built wave64-emulated synthetic fixture, all three M5 mesh variants passed with Vulkan validation, including 30 indirect records and zero pixel mismatches. Eighteen additional targeted boot, proxy and indirect-validation tests passed.

In Windows Sandbox with networking disabled and guest network checks, the retail startup's five slot-41 signatures, including DISPATCH_MESH, returned S_OK and the run reached the later slot-61 call. This is integration/progression evidence only: the run also logged a non-aliased host-memory fallback, and no retail rendering or memory coherence is established.

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.