Repository navigation
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>
# 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>
…ot every GPU Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gh --mesh-compute On a device without VK_EXT_mesh_shader (RDNA1, NVIDIA Pascal, Intel UHD) a mesh PSO was E_NOTIMPL. With mesh shaders translated by --mesh-compute (ItsNotRexed#1053) the layer now runs them, the runtime side docs/design.md listed as the follow-up: - PSO: the MS module becomes a compute pipeline (152-byte push constants, set 0 where it has bindings, its translated subgroup size). The graphics pipeline gets, in place of the mesh stage, the vertex shader that draws the slots, built from the index's mesh_compute layout by runtime/src/mesh_compute_vs.h: the module tools/mesh_compute_vs.py writes, instruction for instruction. - DispatchMesh: groups x slot_bytes of the queue's scratch (now with a device address), vkCmdDispatch, a compute-write -> vertex-read barrier, and vkCmdDraw(groups x max_primitives x 3) in the draw's rendering scope. - MeshShaderTier is 1 without the extension where the index has --mesh-compute mesh shaders and the device can run them. A mesh shader without a layout, a PS reading f16 halves elsewhere than the layout exports them, or a device under 152 bytes of push constants is E_NOTIMPL with a log. ExecuteIndirect DISPATCH_MESH is not built. Tests: mesh_compute_vs_test (four layouts, refusals; spirv-val on the modules), d3d12_mesh_compute_test (a stand-in for ms_draw.mesh written to the --mesh-compute contract, drawn through a stream PSO on a device made without the extension: every pixel checked), shader_library_test (the layout). RX 5700 XT, AMD 26.11.2, Windows 11: ctest 164/164 (the four VK_EXT_mesh_shader tests skip); the new D3D12 test also passes under the Khronos validation layer. Depends on: ItsNotRexed#1712, ItsNotRexed#3777 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kam471
left a comment
There was a problem hiding this comment.
Built and ran this at b990f5e0 on Windows 11, RTX 5070 Ti:
mesh_compute_vs_test.exe-> exit 0: "interfaces of four layouts (small, corpus-like, clip+cull, f16 halves) and the refusals as expected".d3d12_mesh_compute_test.exe-> exit 0: "withoutVK_EXT_mesh_shader, mesh tier 1 through--mesh-compute; a stream MS + PS PSO drewDispatchMeshover X, Y and Z (each slot a workgroup's quad) and matched all 4096 pixels; a mesh shader without amesh_computelayout refused; a vertex draw with the mesh PSO fails at execution".ctest -R 'mesh_compute|m5_mesh'-> 9/9 (3 skipped); the skipped entries are the m5 mesh cases not built/registered for this target.
The fallback path (mesh PSO + DispatchMesh → compute + draw) works end to end, with the refuse case and wrong-kind draw check. No blocking issue.
Flyander
left a comment
There was a problem hiding this comment.
P1: create_mesh_compute calls subgroup_size_for, which only logs when the translated subgroup size is unavailable, then still creates the pipeline. On a device that cannot require the shader entry wave size, the fallback runs subgroup operations at the default width and can produce incorrect results. OPTIONS7 also advertises tier 1 from mesh_compute_count without this capability check. Please reject the PSO and hide the fallback tier unless the required size is guaranteed.
P2: The fallback records vkCmdDispatch on the Direct queue, but physical-device selection requires only VK_QUEUE_GRAPHICS_BIT. On a device whose graphics family lacks VK_QUEUE_COMPUTE_BIT (with compute exposed by a separate family), this command buffer pool cannot issue vkCmdDispatch (VUID-vkCmdDispatch-commandBuffer-02707). Require the selected Direct family to support compute before enabling this path, or provide a queueing design that supports both dispatch and draw.
|
Tested
No game files. AI-assisted (Claude Code). |
|
HOLD: this is not independently landable. It has no textual conflict with The gate itself is right: the fallback applies only when Issues:
AI-assisted review, no game files, no GPU. |
ligmaSec
left a comment
There was a problem hiding this comment.
I tested b990f5e0 on Debian 13, Wine 10.0 and Mesa llvmpipe 25.0.7 (LLVM 19.1.7, subgroup 8). All six native CTests passed, including spirv-val for each of the four generated vertex shader layouts.
The clang-cl/xwin cross-build needed one explicit std::uint32_t conversion in the graphics VkPushConstantRange initializer. Its mesh_compute ? sizeof(...) : sizeof(...) expression has type size_t, which clang-cl rejects as a narrowing list initialization. With that one local cast, the existing d3d12_mesh_compute_test passed all 4,096 pixels and its two refusal checks. shader_library_test passed under Wine too.
I also tested the translator-to-runtime path called out as pending in the description. I built the hand-written ms_m5.asm fixtures with --mesh-compute --wave64-emulate --no-float-controls. All four modules passed spirv-val; the mesh module had no native subgroup operations. I used a local copy of the M5 test harness with native mesh disabled and stopped it after its existing direct-dispatch pixel comparison. The 4×2×2, 3×1×1, 1×1×1 and empty-grid calls matched all 4,096 pixels against the same CPU reference. Khronos validation and synchronization validation were active and reported zero errors for both tests.
This exercises the emulated mesh shader with eight-wide hardware subgroups. The already-reported native subgroup-width check is a separate concern. Only synthetic fixtures were used. AI-assisted with Codex.
|
Independent hardware verification of @DaniSBR1’s mesh-to-compute runtime at A mapped x86-64 guest created a mesh pipeline state and called DispatchMesh for 98 workgroups. The fixture contained 12,326 triangles. For each of four camera states the guest copied five render targets back after a fence. Compared with an independent reference on the same device, all 40 target images matched byte for byte across the two sets of runs (2,621,440 bytes checked). The four poses covered 55, 30, 1,086 and 637 pixels on each GPU. The test used paired producer/consumer metadata for the half-precision interpolants on Mac. The fixture supplies camera and draw globals. I also repeated the comparison with the dedicated 2D depth-comparison binding from #4616 integrated into the test runtime. That combination preserved all forty reference images. Disabling the required binding rejected pipeline creation before drawing. On the unmodified main revision used as a baseline, the mesh pipeline-state stream was rejected before dispatch. This verifies four direct guest draws through the native and fallback paths. It does not measure cross-device byte identity, retail frame selection, or a full scene's frame rate. AI-assisted verification. Only aggregate counts are shared. Longer follow-up on the same composed runtime. The mapped guest completed 7,200 direct DispatchMesh calls per host over a two-minute offscreen controller route, streaming five successive workgroup counts (76, 90, 98, 90 and 76). Each host dispatched 601,800 workgroups in total. The matching repeat reproduced all five material targets and depth at every frame on each respective device. A separate 60-frame neutral controller interval delayed the 76-to-90 group transition by 60 frames. Cross-device edge coverage and some color values still differ. This used controlled draw state and lighting. |
|
clang-cl build break at The Fix: const VkPushConstantRange push{graphics_.push_stages, 0,
- mesh_compute ? sizeof(leonida::MeshComputeUserData)
- : sizeof(leonida::ShaderUserData)};
+ static_cast<uint32_t>(mesh_compute ? sizeof(leonida::MeshComputeUserData)
+ : sizeof(leonida::ShaderUserData))};With it (main d0835dd + #3777 + this PR + #4236), the Windows ctest suite under Wine 11.21 on Fedora 45: 163/163, 0 failed (22 skipped) on both an RDNA2 iGPU (RADV Mesa 26.2.6) and an RTX 4070 Ti (615.78.08), including AI-assisted (Claude Code). |
…bset, clang-cl) - A --mesh-compute PSO is refused unless the compute stage is guaranteed the mesh shader's subgroup size (emulated, required by the stage, or the device's only size); OPTIONS7 reports tier 1 only where every --mesh-compute mesh shader in the index passes (Flyander, P1). - The path needs VK_QUEUE_COMPUTE_BIT on the Direct queue's family, for the PSO and the tier (Flyander, P2). - A PS reading the f16 halves of some of the exported params links; only halves read where the layout doesn't export them are refused (tupacfan04). - The graphics push-constant range size is an explicit uint32_t (clang-cl narrowing; ligmaSec, ddm-j). - d3d12_mesh_compute_test covers the refusals: 144 push-constant bytes and subgroup sizes that can't be required hide the tier and refuse the PSO (an emulated mesh shader is still created), plus the f16 subset and mismatch. RX 5700 XT, AMD 26.11.2, Windows 11: ctest 164/164; d3d12_mesh_compute clean under the validation layer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the reviews and the runs. The fixes are in fdd4667, on the same base:
Re-tested on the RX 5700 XT (AMD 26.11.2, Windows 11): AI-assisted (Claude Code). |
Claimed in #4257 (#4257 (comment)), new D3D item: the runtime side of
--mesh-compute.Depends on: #1712 (D3D-29, mesh PSOs and
DispatchMesh)Depends on: #3777 (
ExecuteIndirectDISPATCH_MESHand the M5 mesh gate, which merges #1712 and #1865 ontomain)This branch is zneel's
m5-mesh(#3777's head,536cb939) plus this PR's commits, the second one the review fixes. Only those are for review:git diff 536cb939..HEAD.What and why
9,282 of the game's 26,503 shaders are mesh shaders. #1712 and #3777 draw them on
VK_EXT_mesh_shader. Without the extension (RDNA1 on AMD's Windows driver and on RADV, NVIDIA Pascal, Intel UHD) a mesh PSO isE_NOTIMPL, so none of them draws there. The translator already has the fallback:--mesh-compute(#1053) makes each mesh shader a compute shader that writes its vertices and primitives into one output slot per workgroup.docs/design.mdlists the runtime side as the follow-up, and this PR adds it:VK_EXT_mesh_shader, the MS entry must have amesh_computelayout.runtime/src/mesh_compute_vs.hbuilds it from the layout at PSO creation: the moduletools/mesh_compute_vs.pywrites.DispatchMesh: groups ×slot_bytesof the queue's scratch, thenvkCmdDispatchwith the counts, a compute-write → vertex-read barrier, andvkCmdDraw(groups × max_primitives × 3)with triangle lists in the draw's rendering scope.vulkan_scratch.h's, the one depth ↔ colour copies use. It is now created with a device address where the device has buffer device addresses. It lives until the submission completes and is then reused.MeshShaderTier: without the extension it is 1 where the index has--mesh-computemesh shaders and the device can run every one of them as the PSO path does (the checks below), andNOT_SUPPORTEDotherwise, as before.E_NOTIMPLand a log, with the tier hidden wherever any--mesh-computemesh shader would be:mesh_computelayout (translated without the flag);VK_QUEUE_COMPUTE_BIT, since the dispatch is recorded on that queue (VUID-vkCmdDispatch-commandBuffer-02707);--wave64-emulate), required by the stage, or the device's only size. A size that is only the default could change its subgroup operations' results;--f16-interp-fallbackhalves where the layout doesn't export them. Reading the halves of some of the exported params is fine. Per-pipeline pairing,mesh_compute_vs.pair_f16_halves, is not built yet.ExecuteIndirectwithDISPATCH_MESH. The group counts are GPU data, so the draw's vertex count is too. Its signatures stayE_NOTIMPLwithout the extension.ShaderEntryreads themesh_computelayout, andShaderLibrary::mesh_compute_count()counts such mesh shaders.Tests
RX 5700 XT (RDNA1, no
VK_EXT_mesh_shader), AMD Adrenalin 26.11.2, Vulkan 1.4.315, Windows 11, MSVC 19.44:d3d12_mesh_compute_test(new, GPU): runs on every GPU, because the layer's device is made without the extension whatever the GPU has.test/glsl/ms_draw_compute.comp: Runtime: mesh-shader PSOs from pipeline state streams and DispatchMesh (D3D-29) #1712'sms_draw.meshwritten to the--mesh-computecontract, so the pixels ared3d12_mesh_test's.DispatchMesh(2, 2, 1)andDispatchMesh(1, 1, 2), so the X, Y and Z counts each reach the slot index. 4096/4096 pixels match.invalid_draw.NOT_SUPPORTEDand refuse the PSO, and on the second a mesh shader marked as emulated is still created.LEONIDA_VK_VALIDATION=1too, with no messages.mesh_compute_vs_test(new, CPU): the four layouts' interfaces and the refusals. CMake runsspirv-val(Vulkan 1.2) on the four modules where the Vulkan SDK has it: all valid.shader_library_test: the layout fields.ctest: 164/164 passed. 14 more skipped here because they need game files or something this machine lacks, includingd3d12_meshand the threed3d12_m5_mesh*, which needVK_EXT_mesh_shader.d3d12_mesh's check without the extension (tierNOT_SUPPORTED, PSO refused, with an index that has no--mesh-computeentries) still passes before it skips.tests/test_ctest_registration.py: passes.ms_m5.asmtranslated with--mesh-compute --wave64-emulatethrough this path, with native mesh off. All four grids of the M5 test matched all 4,096 pixels under Khronos and synchronization validation (review).build.pyitself still translates it for the mesh stage only.No game files were used. AI-assisted (Claude Code).