Repository navigation
Runtime: pipeline-statistics queries around mesh draws (D3D-291) - #2359
LloydNicholson wants to merge 3 commits into
Conversation
07f7530 to
ec3e628
Compare
|
Tested on an NVIDIA GeForce RTX 5090 (Windows 11, driver 621.24, Vulkan SDK 1.4.363.0), built at ec3e628 (current head, same result as at 07f7530 before the rebase),
VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076 forbids |
|
Windows + GPU check: AMD Radeon RX 9070 (RDNA4), Windows 11, MSVC Release, Vulkan SDK 1.4.363. Tested head ec3e628 merged onto AI-assisted (Claude Code); runs on my machine. |
|
Independent verification on RTX 5060 Ti, NVIDIA 621.14, Windows 11 Pro, MSVC 19.44 + Ninja, Vulkan SDK/validation layer 1.4.363.0. Tested PR head Confirmed TricksterG's finding:
Additional findings: The current test expects nonzero clipping statistics from mesh draws. Those values depend on counters Vulkan prohibits for this operation. The documentation in §4.6 and the comment in Locally tested minimal fix (not pushed):
Results after this change:
The full unmodified GPU suite had identical verdicts across the three tested revisions (139 passed, 46 skipped out of 185), and 2,567 semantic tests passed. One design question: should mesh clipping counters explicitly return zero for now, with that limitation documented, or should mapping mesh-specific statistics be tracked separately? The segment-splitting approach otherwise looks promising. I recommend correcting the query mask and expectations before merging. Synthetic fixtures only; no game data. AI-assisted verification (Claude Code). |
|
Confirmed the RTX 5090 report on an RTX 3060 12 GB at ec3e628, Windows 11, driver 621.14, Vulkan 1.4.357, Khronos validation 1.4.363. With LEONIDA_VK_VALIDATION=1, d3d12_mesh_test exited 1 in two consecutive runs. Each run reported exactly three VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076 errors (query 1 twice and query 3 once), with both CLIPPING_INVOCATIONS and CLIPPING_PRIMITIVES set. The same binary exited 0 with validation off. replay_query_predication_test passed. AI-assisted testing and write-up. |
|
Same on AMD: tested ec3e628 on AMD Radeon RX 7600 (RDNA3), AMD 26.11.2 (LLPC), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363.0. d3d12_mesh_test passes without validation; with LEONIDA_VK_VALIDATION=1 it reports the same 3 errors @TricksterG saw: VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076 for queries 1 (twice) and 3, pool created with CLIPPING_INVOCATIONS|CLIPPING_PRIMITIVES. So it is not NVIDIA-specific. AI-assisted (Claude Code, reviewed with Codex). No game files. |
ec3e628 to
46f7314
Compare
|
Tested ec3e628 (merged onto main 4947579) on NVIDIA GeForce RTX 4060 Ti, driver 610.88 (32.0.16.1088), Windows 11 26200, MSVC 14.51.36231 (VS 2026), Vulkan SDK 1.4.363.0: fails under validation
AI-assisted (Claude). |
46f7314 to
940ab5d
Compare
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).
|
Tested 940ab5d as-is (stacked on #1712) on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:
AI-assisted (Claude Code). |
…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>
940ab5d to
c3569af
Compare
Claimed in the coordination issue as D3D-291: #2078 (comment)
Depends on: #1712 (D3D-29, mesh-shader PSOs and
DispatchMesh). This branch is stacked on it, so until #1712 merges the diff also shows its two commits. The change here is the last commit, 940ab5d, onmainf847748.What and why
The problem. D3D12 allows
DispatchMeshinside aPIPELINE_STATISTICSquery and reads its IA/VS/GS/HS/DS fields as 0. Vulkan forbidsvkCmdDrawMeshTasksEXTwhile a query with those counters is active (VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076). The heap's pool is always created with all eleven counters (0x7ff). Gen800 found this in review of #1712.The fix reuses the D3D-162 split of a statistics query into physical segments:
plan_statistics_segments): a statistics query that holds a mesh draw is split, like one that holds a resolve or one of the other helpers. Mesh draws share the segment numbering of the helper splits.CLIPPING_INVOCATIONS,CLIPPING_PRIMITIVES,FRAGMENT_SHADER_INVOCATIONSandCOMPUTE_SHADER_INVOCATIONS.ExecuteIndirectdraws count as vertex draws.Prepared::statistics_end/begin), so the draw itself still runs. Each draw has its own rendering scope, so the split stays outside rendering. The per-command split helpers, andemit_query's, now pick the pool by the segment's kind, since a helper or resolve can end a mesh segment.statistics_sum.compgains ameshpush constant and adds them asCInvocations,CPrimitives,PSInvocationsandCSInvocations, so the other fields get nothing from that segment.statistics_sum_spirv.his regenerated as its header says:glslangValidator -V --target-env vulkan1.0 -Os -g0, thenspirv-val.unsupportedrather than run unsplit around a mesh draw.docs/d3d12_vulkan.md§4.6 has the rule.Queries without mesh draws are planned exactly as before.
Mixed queries: a query over vertex and mesh draws counts both. The vertex draws' IA/VS counts are kept, and the mesh draws add their clipping, pixel and compute counts.
Rebased onto
mainf847748:mainadded D3D-252's overlapping statistics queries, with a second planner,plan_overlapping_statistics_segments. That planner now records each segment's kind and splits at a mesh/vertex switch the same way, so overlapping queries around mesh draws stay out of the forbidden state too.replay_query_edges_test(new onmain) now callssum_statisticswith the mesh pool and kinds, and expects the 8-byte push constant.Tested
AI-assisted (Claude Code). RX 9060 XT (RDNA4, GFX1200), RADV Mesa 27.0.0-devel, Nobara Linux. Windows binaries cross-built with clang-cl 22 and the 10.0.26100 SDK, run under Wine 11.22. Native tests built with GCC.
replay_query_predication_testcases 14 and 15 (CPU, new): case 14 is a single query; case 15 is the same split inside overlapping queries (D3D-252's planner, see below).d3d12_mesh_test(GPU, extended): three queries in one list, on a mixed, a mesh-only and a vertex-only range.PSInvocationsisn't the pixel count, so the test compares against the vertex-only query rather than an absolute number.VK_LAYER_KHRONOS_validation1.4.341 (Fedora) reports nothing beyond the two VUIDs that come from this host's environment.vk_overlapping_occlusion,vk_binary_occlusion,vk_predicated_copy,depth24_convertandreplay_query_predicationpass natively under validation, with no messages.ctest: 41/41 passed (2 skipped). The query and helper tests (vk_overlapping_occlusion,vk_binary_occlusion,vk_predicated_copy,depth24_convert,replay_query_predication,replay_query_edges) pass under validation.d3d12_*under Wine (53 tests): 6 fail, and all 6 fail the same way onmainf847748 on this machine (d3d12_clear,d3d12_compute,d3d12_fence_timing,d3d12_private_data,d3d12_subresource_copy,d3d12_xdxr_rt).tests/test_docs_links.pyandtests/test_text_write_line_endings.pypass.Not tested: Windows/MSVC with Microsoft's loader and a current validation layer; NVIDIA or Intel;
ExecuteIndirectmesh draws, which the layer doesn't have yet.Checklist
🤖 Generated with Claude Code