Repository navigation
Runtime: ExecuteIndirect with DISPATCH_MESH signatures and the M5 mesh gate (translated mesh shader) - #3777
Runtime: ExecuteIndirect with DISPATCH_MESH signatures and the M5 mesh gate (translated mesh shader)#3777zneel wants to merge 25 commits into
Conversation
…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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
|
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
One point on wording: AI-assisted (Claude Code). No game files. |
|
Tested
No game files. AI-assisted (Claude Code). |
…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 heads-up: on an RTX 5080 the three M5 mesh tests skip (no 64-wide mesh), and with |
|
Re-tested the current head What your DXBC/ — while at your head the same command builds 267 shaders: 267 translated, 267 pass spirv-val, those six included. GPU battery at your head: 214/238 passed, 23 skipped with the emulator variable, 183/238, 54 skipped
Worth knowing since your head is the one that finally builds that program here: the RTX 5080 not used in this pass (186 MiB free, another job holds the card). AI-assisted testing, counts read through by |
|
Found a regression in the new count-buffer branch of if (ind.count_buffer) {
if (draw) ...
else if (draw_indexed) ...
else if (dispatch_mesh) ...
return; // <-- DISPATCH with a count buffer returns here
}
...
} else if (kind == dispatch) {
for (...) {
if (ind.count_buffer) vk.dispatch_indirect(counted...); // dead code
else ...
}
}So an Fix: handle the counted dispatch inside the first block: } else if (ind.kind == IndirectKind::dispatch) {
// Vulkan has no vkCmdDispatchIndirectCount: the prepass wrote the counted records.
for (std::uint64_t k = 0; k < ind.max_count; ++k)
vk.dispatch_indirect(command_buffer, p.counted_dispatch.indirect,
p.counted_dispatch.offset + VkDeviceSize(k) * 12);
}
return;and drop the now-unreachable |
|
@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 RX 6900 XT (RDNA2), Windows 11, MSVC,
AI-assisted (Claude Code). |
|
@Kam471 thanks for digging, but that snippet isn't this PR's head. At f8b1978, if (ind.count_buffer && ind.kind != IndirectKind::dispatch) {So a counted The 0/0 for "count 0 update 1" is a separate problem, and it comes from AI-assisted (Claude Code). |
…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>
…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: this PR conflicts with |
|
Review finding at current head |
|
@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 @tedin7's
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, AI-assisted (Claude Code). Git analysis only, no build or GPU run. |
|
Native AMD wave64 check of the review-only rebase at
|
…ignatures and the M5 mesh gate (translated mesh shader) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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, 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 AI-assisted test run. |
|
Tested
Not run: other GPUs/vendors, Linux, anything that needs game files. No game files. AI-assisted (Claude Code). |
|
✅ Automated security review: CLEAN (commit
Scope: static analysis of added diff lines only; no code was executed. Please review findings manually. |
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:
ExecuteIndirectdraws carry the list's graphics state)Merge order: #1712, then #1865, then this PR. This branch is main
561b65a8, with #1712's current headc2376390merged in unchanged (a clean merge, so its two commits are ancestors here and no second copy of the mesh PSO code is carried), then #18659a74588b, 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:VkPipelineCache. Runtime: milestone M5 synthetic gate (without mesh) — ExecuteIndirect draws render now, multi-threaded lists, 5,120-SRV bindless table, pipeline cache #1865's creation-feedback counting (create_pipeline,pipeline_cache_stats) uses that cache instead of making a second one.emit_indirect: keeps main's counted-dispatch prepass forDISPATCHwith a count buffer, and main's choice of descriptor set 0 when it binds the recorded compute pipeline.Only the commits after the #1865 merge are for review:
git diff 7ca3311f..HEAD. The first of them (7c6d99a2) is a fix to #1712'sDispatchMesh: main's bundles record throughdefer()and replay atExecuteBundle. Without it,Close()fails on a bundle that contains aDispatchMesh(@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.ExecuteIndirectwithDISPATCH_MESHcommand signatures.CreateCommandSignatureansweredE_NOTIMPLfor them.VK_EXT_mesh_shaderis enabled; without it they stayE_NOTIMPL, like mesh PSOs.DISPATCH_MESHmust be the only argument. Root constants or views before it stayE_NOTIMPL, because multi-argument signatures are not expanded (D3D-283).D3D12_DISPATCH_MESH_ARGUMENTSandVkDrawMeshTasksIndirectCommandEXTare the same three dwords, so records are read as they are.DispatchMeshtakes, and replays as a whole draw:vkCmdDrawMeshTasksIndirectEXT, orvkCmdDrawMeshTasksIndirectCountEXTwith a count buffer.multiDrawIndirectandmaxDrawIndirectCount, 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.DISPATCH_MESHcall with a VS PSO, or a draw signature with a mesh PSO, isReplayResult::invalid_draw.runtime/test/shaders/build.pyskipped everyms_shader, since it made no PSV0. It now builds one for a mesh shader whose header has; psv0: THREADS MAX_VERTICES MAX_PRIMITIVES.ms_m5.asmis an NGG wave64 mesh shader of 128 threads (two waves). It uses the corpus's idioms: the group index fromv5(v_readfirstlane_b32,>> 7), the thread id froms3[27:24]andmbcnt, thread-0GS_ALLOC_REQ, and one vertex and one primitive export per thread.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_testThrough the proxy, D3D12 API only, with PSOs from pipeline state streams. Every pixel is compared with a CPU reference, error 0.
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.ExecuteIndirectDISPATCH_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.MaxCommandCount2.drawIndirectCount, the count-buffer calls are left out.d3d12_m5_mesh_fallbacks: the same test with--single-calls --no-count-buffers, which turnsmultiDrawIndirectanddrawIndirectCountoff 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 backReplayResult::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.E_INVALIDARG, a root constant beforeDISPATCH_MESHisE_NOTIMPL, and a device without the extension givesE_NOTIMPL. A wrong-kind draw fails at execution, in both directions.tests/test_shader_build_mesh.pychecks thatbuild.py's container matchesrun_gpu_tests.py's byte for byte.Findings left open (not changed here)
s3is not user data in a mesh shader. In the translator's mesh ABI,s3is the merged wave info. Under the s0 packing, a mesh shader therefore can't reach a fourth root dword.ms_m5.asmreads s0..s2 only.PIPELINE_STATISTICSquery meets the same restriction asDispatchMeshthere.maxMeshWorkGroupCountare 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).--single-calls --no-count-buffers(25 records, one call each; the count-buffer call isunsupported) and with--single-callsalone.LEONIDA_VK_VALIDATION=1, which also turns on synchronization validation: 0 messages.d3d12_m5_mesh_chunks.-j 8), on main561b65a8: 237 pass and 11 skip (game data or optional tools), withoutd3d12_present(it opens a window). 4 fail, and each fails the same way on main561b65a8alone 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_tilesandd3d12_pipeline_library_host.d3d12_m5_mesh*,d3d12_mesh(Runtime: mesh-shader PSOs from pipeline state streams and DispatchMesh (D3D-29) #1712),d3d12_m5_world(Runtime: milestone M5 synthetic gate (without mesh) — ExecuteIndirect draws render now, multi-threaded lists, 5,120-SRV bindless table, pipeline cache #1865),d3d12_bundle,d3d12_indirect_zeroandd3d12_indirect_rtpass, with no validation messages.3faac557, 156 of 156 on mainaa2988cc, 143 of 143 at 7cbaab6.scripts/run_gpu_tests.py185 of 205 pass and 20 skip, the same native and withLEONIDA_W64_EMULATE=1, with no failures;ms_m5andps_m5_meshshow as run byd3d12_m5_mesh_test.tests/test_ctest_registration.py,tests/test_shader_checks.py78 passed;tests/test_shader_build_fallbacks.py,tests/test_first_light.py12 passed / 3 skipped;tests/test_shader_build_mesh.py4 passed;tests/test_run_gpu_tests*.pyandtest_run_gpu_pixel_checks.py/test_run_gpu_wavemask.pypass.Checklist
d3d12_m5_mesh,d3d12_m5_mesh_fallbacks,d3d12_m5_mesh_chunks,SKIP_RETURN_CODE 77). Its shaders are inrun_gpu_tests.py's D3D12-harness list, andrun_gpu_tests.pygives a mesh shader with apsv0:header its PSV0, asbuild.pydoesdocs/d3d12_vulkan.md: §3.6, §4.7 and the M5 rowAI-assisted (Claude Code).
🤖 Generated with Claude Code