Repository navigation
Conversation
…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>
D3D12 allows DispatchMesh inside a PIPELINE_STATISTICS query and reads its input-assembly, vertex, geometry and tessellation fields as 0; Vulkan forbids vkCmdDrawMeshTasksEXT while a query with those counters is active (VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076), and the heap's pool has all eleven. A statistics query that holds a mesh draw is now split like one that holds a resolve (D3D-162). Each segment's first draw picks the submission's full pool or a second one with only the clipping, fragment and compute counters, and a draw of the other kind starts a new segment. The statistics sum copies a mesh segment's four counters into fields 5..8 of its record and statistics_sum.comp adds them to their D3D12 fields. A list that would need the split without the compute helper is refused instead of running the query unsplit. replay_query_predication_test checks the split points, segment kinds and resolve plan on the CPU; d3d12_mesh_test resolves queries around mixed, mesh-only and vertex-only draws on the GPU. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested
AI-assisted |
|
Heads-up on an overlap with #2359 (D3D-291, mine), which is also stacked on #1712. Both PRs change
The merged shader needs both. Whichever lands second rebases. If this one lands first, I'll rebase #2359 onto it. That split is also most of what your D3D-339 finding asks for; more in the coordination issue: #2891 (comment) AI-assisted (Claude Code). |
|
Tested
D3D-339 reproduces on this card and driver too, with the same numbers as on the 3070 Ti: DispatchMesh(2,2,1) gives IAVertices/IAPrimitives/VSInvocations 4/4/128 on the layer and 0/0/0 on the host, DispatchMesh(1,1,2) 2/2/64, and the VS draw's MSPrimitives is 1 against the host's 0. @itsRevela, D3D-339 stays yours. In case it helps, I tried the one-kind case on top of this PR: CLHelper#3 (a draft in my fork, not a PR here). AI-assisted. |
Kam471
left a comment
There was a problem hiding this comment.
The implementation is sound but the branch is not mergeable as-is:
- Rebase required. The head sits on
47e8b421, a dropped #1712 head, and conflicts with current main inruntime/CMakeLists.txt(main'sd3d12_bundle_testvs #1712's mesh-test block) andruntime/shims/d3d12_vulkan_device.cpp(main's Device9 shader-cache methods vs #1712's Device2CreatePipelineState). Current #1712 is56e57fbe, which merges cleanly with main; rebase this PR onto that head (or onto main once #1712 lands) and drop the stale stack. - Build/test evidence. No configured build was available and the PR adds 3 test targets, so none were built or run here. Please provide a configured build plus the
d3d12_mesh_statistics_test,replay_query_predication_testandd3d12_query_rules_testresults, with validation enabled. - Contract delta. Unsupported mesh statistics currently return
E_NOTIMPL, while the D3D12 spec says the three newPIPELINE_STATISTICS1fields read 0. Either return the zeroed structure or state the deviation explicitly in the body/docs.
The SDK constants check out (D3D12_QUERY_DATA_PIPELINE_STATISTICS1 = 14 x UINT64, AS/MS/MSPrimitives at 11/12/13, heap type 7, query type 10), the 13 Vulkan counters match, and the embedded SPIR-V equals a fresh glslang compile (361 words, 0 diff) with spirv-val clean. Rebase and CI should be enough after that.
|
Thanks for the review. This is now a draft:
I'll rebuild D3D-132 on top of #2359's per-segment pools ( AI-assisted (Claude Code). |
ID3D12Device::CreateQueryHeap refused D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS1. It now creates one on a device with VK_EXT_mesh_shader's meshShaderQueries (enabled with meshShader where the GPU has it, and reported through OPTIONS9.MeshShaderPipelineStatsSupported); without it the heap is still refused with E_NOTIMPL. Built on D3D-291 (ItsNotRexed#2359), which splits a statistics query around mesh draws into full and mesh-pool segments. - The heap's pool counts the 11 classic statistics plus TASK_SHADER_INVOCATIONS (0x800) and MESH_SHADER_INVOCATIONS (0x1000); Vulkan writes them in bit order after CSInvocations, the order of ASInvocations and MSInvocations. Neither bit is forbidden around vertex draws (only around vkCmdDrawClusterHUAWEI, VUID-07819). - A query that holds a mesh draw is always split (VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076, D3D-291), so an unsplit query ran no mesh draw: the resolve copies its 13 statistics 112 bytes apart and writes MSPrimitives as 0. - With a split PIPELINE_STATISTICS1 query in the submission, the mesh pool also counts task and mesh invocations (6 counters), and each mesh segment runs a VK_QUERY_TYPE_MESH_PRIMITIVES_GENERATED_EXT query of its index beside it; full segments run none. No VUID ties those queries to the draw kind (07068, 07070, 07071), but NVIDIA's Vulkan driver counts a VS draw's triangles in them and D3D12 does not, so MSPrimitives is counted only around mesh draws. - A split PIPELINE_STATISTICS1 query always resolves through the sum. statistics_sum.comp takes the result width (11 or 14) as a push constant and maps a mesh segment's task and mesh invocations and primitives to fields 11-13. statistics_sum_spirv.h is regenerated with glslang 16.6.0 (-V --target-env vulkan1.0 -Os -g0; spirv-val clean). Tested on Windows 11, NVIDIA GeForce RTX 3070 Ti, driver 610.88, without Vulkan validation layers (not installed): ctest 125/125 passed, 8 skipped (game data, the validation layer, an RGB9E5 RTV); ItsNotRexed#2359's head alone: 124/124 passed, the same 8 skipped. New: d3d12_mesh_statistics runs one list on the layer and on host D3D12 (DXIL from HLSL equivalents compiled at run time by the Windows SDK's dxcompiler.dll): a VS draw in PIPELINE_STATISTICS1 and PIPELINE_STATISTICS queries, DispatchMesh(2,2,1) and (1,1,2), a query never ended, and a query split by a resolve inside it, resolved at an offset. Every one of the 14 fields matches the host. replay_query_predication cases 10-12 cover the unsplit resolve, the primitives queries beside mesh segments only, the refusals and the 14-counter sum; d3d12_query_rules compares PIPELINE_STATISTICS1 heap creation by count and node mask with WARP and the GPU. The host's refusal HRESULT is unmeasured: every host adapter here (WARP, RTX 3070 Ti) supports these heaps. Depends on: ItsNotRexed#1712, ItsNotRexed#2359 AI-assisted (Claude Code).
617455a to
25373c4
Compare
|
Rebuilt on #2359 ( |
Item: D3D-132 (claim).
Depends on: #2359 (D3D-291), which depends on #1712 (D3D-29); this is the coordinator's order. This branch is one commit,
25373c44, on #2359's head46f73149, which sits on #1712's56e57fbe.Draft until there is an AMD run, as below.
What
CreateQueryHeap(D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS1)works when the device hasVK_EXT_mesh_shader'smeshShaderQueries. The feature is enabled withmeshShaderwhere the GPU has it andpipelineStatisticsQuery, and OPTIONS9MeshShaderPipelineStatsSupportedreports it. Without the feature the heap is refused withE_NOTIMPL.It's built on #2359's split of a statistics query around mesh draws, which
VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076requires:VUID-07819forbids those bits only aroundvkCmdDrawClusterHUAWEI, so they're allowed around ordinary vertex draws.PIPELINE_STATISTICSare unchanged.PIPELINE_STATISTICS1query is present, the mesh-segment pool grows from 4 to 6 counters (adding task and mesh invocations).VK_QUERY_TYPE_MESH_PRIMITIVES_GENERATED_EXTquery in a per-submission pool. It runs only beside mesh segments, because NVIDIA's Vulkan driver counts a VS draw's triangle in that query and D3D12 doesn't.statistics_sum.comptakes the result width (11 or 14) as a push constant and maps a mesh segment's AS, MS and primitives into fields 11–13.statistics_sum_spirv.his regenerated with glslang 16.6.0 and passesspirv-val.VUIDs checked in the
validusage.jsonshipped with the pinned Vulkan-Headers (1.4.363): 07076, 07819, 07068/07069 (both needmeshShaderQueries), 07070 and 07071.Results
NVIDIA GeForce RTX 3070 Ti, driver 610.88, Windows 11, RelWithDebInfo.
d3d12_mesh_statisticscompares all 14 fields with host D3D12 and fails on any difference. They're identical:PIPELINE_STATISTICSgives the same first 11DispatchMesh(2,2,1)DispatchMesh(1,1,2)AS is 0 because #1712 refuses amplification shaders.
No regressions against the base:
cteston #2359's head alone gives 124/124 (8 skipped), and with this commit 125/125 (the same 8 skipped). The extra test isd3d12_mesh_statistics.Not verified:
ctest -R "mesh|statistics|query|predication"against Runtime: pipeline-statistics queries around mesh draws (D3D-291) #2359's head is needed before this leaves draft.meshShaderQueriesis unmeasured, because every host adapter tried supports the heap.No game files. AI-assisted (Claude Code).