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 22 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
…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
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). |
# 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>
…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>
|
@zneel heads-up: on an RTX 5080 the three M5 mesh tests skip (no 64-wide mesh), and with |
|
PASS as a draft. The gate is correct: the mesh signature/PSO is taken only with Minor: The branch is stacked on unmerged #1712/#1865, so AI-assisted review, no game files, no GPU. |
|
Tested
No game files. AI-assisted (Claude Code). |
|
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):
Full suites, base aa2988c → this PR:
Not covered here: the emulated 32-wide case @tedin7 reported (2816 pixels at 127 instead of 128). Setting Nit: AI-assisted (Claude Code); numbers copied from the run logs. |
…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>
|
Tested
AI-assisted (Claude Code). No game files. |
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)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 newPreparedDrawtable: an indirect draw gets its own entry, as aDrawdoes. 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.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 4): at 7cbaab6, 143 of 143 pass withoutd3d12_present(it opens a window), the threed3d12_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 withoutd3d12_present(it opens a window) passed 142 of 142,d3d12_m5_mesh_fallbacksincluded. 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_drawandd3d12_vulkan_devicepass.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