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 |
…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>
Kam471
left a comment
There was a problem hiding this comment.
#1712 is now green at its rebased head c2376390a (contains main 561b65a83):
d3d12_mesh_test: 4096/4096 pixels, tier "mesh tier 1";MeshShaderTier=10(TIER_1) through the game's standalone device path.ctest -R '^(d3d12_mesh|d3d12_draw|d3d12_compute|d3d12_vulkan_device)$': 4/4 passed.- Validation-on rerun: exit 0, no messages.
git diff --checkclean. - The rebase is pure: same 13 files/+929/-34; the second commit is identical, the first differs only in context.
So the base for this branch is settled: rebase #3777 onto c2376390a and drop the duplicate mesh-PSO copy. The unique delta left is the ExecuteIndirect DISPATCH_MESH path and the M5 gate, which #1712 does not have. Once this is rebased, #4408's assist-4408-rebased branch will need the same treatment (it was based on this PR's older head).
|
Independent round-44 Linux check while the rebase onto #1712 is in progress. I tested a local merge of this PR at Test machine: Ryzen 7 9800X3D integrated Radeon, RADV
All listed processes exited 0. I also checked the published dependency separately on the same hardware under both runners. Result at the exact #1712 head Synthetic fixtures only. AI-assisted. |
# Conflicts: # docs/d3d12_vulkan.md # runtime/shims/d3d12_com.cpp # runtime/shims/d3d12_vulkan_device.cpp # runtime/src/vulkan_backend.h # runtime/src/vulkan_replay.h
main's bundles record their commands through defer() and replay them at ExecuteBundle. Without it, a DispatchMesh in a bundle went into the bundle's own command list and was never replayed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sh gate with a translated mesh shader CreateCommandSignature takes DISPATCH_MESH where VK_EXT_mesh_shader is enabled (E_NOTIMPL without it). ExecuteIndirect records it with the state DispatchMesh takes, and replay issues vkCmdDrawMeshTasksIndirectEXT, or vkCmdDrawMeshTasksIndirectCountEXT with a count buffer, split by multiDrawIndirect and maxDrawIndirectCount as the draw kinds are. build.py makes the PSV0 container of a mesh shader whose header has a psv0: line, so translated mesh shaders can be layer-test fixtures. d3d12_m5_mesh_test draws ms_m5.asm (NGG wave64, 128 threads, the corpus's v5/s3 idioms) by DispatchMesh and by ExecuteIndirect, error 0. AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mesh container test AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… fallback-path ctest; run_gpu_tests reads the psv0 header - Pass the device's subgroup caps to the layer, so the wave64 mesh stage asks for 64; exit 77 where the device cannot run it 64-wide, or has fewer than 144 push-constant bytes. - --single-calls / --no-count-buffers turn multiDrawIndirect / drawIndirectCount off on the layer's device; registered as d3d12_m5_mesh_fallbacks. Without drawIndirectCount a count-buffer call must be ReplayResult::unsupported. - scripts/run_gpu_tests.py translates every .asm itself: give a mesh shader with a psv0: header its PSV0 there too (ms_m5 failed translation in the GPU suite without it). AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…p size Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
From two review passes (one adversarial): - CreateCommandSignature refuses DISPATCH_MESH after root arguments (E_NOTIMPL, as before this branch) instead of accepting it and reading the group counts from the record's first bytes. - CommandList::execute_indirect refuses a mesh dispatch without DispatchMesh's state, and a draw kind with it. - The test fails on validation errors, as its siblings do; asserts the mesh stage's subgroup request was found (and fails on an undecided one). - I5 runs at stride 24 without a count buffer, zero-padded, 1 to 4 groups per record; new d3d12_m5_mesh_chunks lowers the layer's maxDrawIndirectCount to 3 so the calls are split. Mutations caught: chunks that don't advance (chunks run), a stride hard-coded to 12 (both). - Docs and comments: one-argument signatures only; maxDrawIndirectCount applies without a count buffer; invalid_draw for a draw signature with a mesh PSO needs a topology; only a record's group total is visible; ms_m5 sends GS_ALLOC_REQ from every thread; whitespace restored. AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ot every GPU Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ce caps; build.py psv0 error From review on ItsNotRexed#3777: - The wave64 skip is decided from the library entry and the device's subgroup caps (decide_subgroup_size, as the layer decides it) before any mesh PSO is created, so a device that cannot run ms_m5 skips even if its PSO creation would fail. The PSO's own mesh-stage request must match that prediction. (whattheflop) - The DispatchMesh part clears to 128/255 instead of 0.5: 0.5 is 127.5 in UNORM8 and some GPUs store 127. The emulated RTX 5070 / 5080 runs differed only there. (kacper-serewis, tedin7) - The layer's device info gets drawIndirectFirstInstance, as d3d12_m5_world_test does, which silences its "not enabled" log. (ddm-j) - build.py: an ms_ shader without a psv0 header raises a clear ValueError instead of a TypeError when translate_tests is called directly. (tupacfan04) AI-assisted (Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased again (head
Tested at
AI-assisted (Claude Code). |
|
Independent Windows check of f8b19786 on 561b65a8. Windows 11 x64, RTX 3080 Ti / 621.35, MSVC 19.44.35230, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0, LLVM MC 23.1.6, RelWithDebInfo.
The runtime was built from the exact PR head. The focused harness omitted the invalid-signature and wrong-pipeline probes and kept the draw cases and pixel checks. Synthetic inputs only. AI-assisted. |
|
Independent CPU check of
GPU rendering and pixel comparison remain unverified by this run. No game files used. AI-assisted (Codex). |
|
Rebased #3777's unique work onto #1712 (
Kept 13 commits: the M5 synthetic-gate chain ( Conflict resolutions:
Build: VS2022 BuildTools + Ninja, RelWithDebInfo, Vulkan 1.4.363, BUILD_TESTING=ON. All targets build. Tests on
Still open from #3777: native wave64 mesh path unverified on this 32-wide GPU; mesh user-data base (corpus reads s16, layer packs from s0); multi-argument command signatures; |
AI-assisted (Claude Code). |
|
Linux check on the rebased head I also ran this head's translated wave64 M5 mesh workload under Wine. The default mode drew 30 indirect records, the CachyOS, Ryzen 7 9800X3D integrated Radeon, Mesa RADV 26.3.1 (RAPHAEL_MENDOCINO). Synthetic inputs only. AI-assisted. |
|
Offscreen M5 pixel check on Linux x86-64, using llvmpipe (Debian Mesa 25.0.7 and 26.1.6, LLVM 19.1.7, 8-wide subgroups). I adapted the native Vulkan test harness to replay the PR’s M5 draw records using the With those compatible modules and the Khronos validation layer enabled, both driver versions produced the same results on 64×64 RGBA8 readbacks:
The default mismatch was confined to cells 48–51, the 20-record fixed-count draw at stride 24. The raw replay and direct Vulkan paths produced byte-identical images in each mode. No validation errors were reported with the compatible modules. This isolates an offscreen software-driver result; attribution is still open. The full Windows D3D12 test, its PSO rejection checks and physical NVIDIA hardware were outside this run. Synthetic inputs only. AI-assisted (Codex). |
|
Tested I rebuilt the shader fixtures with
AI-assisted test run. |
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