Repository navigation
D3D12 layer: stream-output statistics query heaps (D3D-302) - #2562
Conversation
|
Independent physical-GPU run at I additionally extended the overlapping-occlusion test locally to exercise the no-split rule: start all four pool-less SO streams, then end and resolve each while a pipeline-statistics query is still active. With both a nonzero buffer binding offset and a nonzero resolve offset, the 64 result bytes were zero and all guard bytes stayed at |
|
Tested
Synthetic inputs only. Tested with assistance from OpenAI Codex. |
|
Tested
|
|
Independent Windows GPU check: PASS on RTX 3060 12 GB (driver 621.14, Vulkan 1.4.357, Windows 11 26H2, Ryzen 5 3600). Head: 70c9517 The D3D-302 checks passed for streams 0 and 3. All three query slots, including the unused slot, read back as zero. The destination sentinel was preserved, and the mismatched heap/query type and unterminated query were rejected as expected. AI-assisted test execution and write-up. |
|
Tested on Windows 11 with two GPUs on one machine (MSVC 14.51, llvm-mc 23.1.6): pass. |
|
Tested 70c9517 on Windows 11 (26200), MSVC 19.4x (VS 2022 Build Tools), Ninja RelWithDebInfo: pass on both GPUs of a two-GPU PC.
No game files. AI-assisted check (Claude Code), Vonsek3. |
|
Tested 70c9517 under Wine 11.21 (Fedora 45) on AMD Radeon 610M (RDNA2 iGPU, RADV Mesa 26.2.6) and NVIDIA RTX 4070 Ti (615.78.08): pass This adds an AMD GPU and Linux to the Windows NVIDIA checks above. The Windows runtime was cross-built with clang-cl 23.1.5 and xwin (MSVC 14.44, SDK 10.0.26100), and its ctest suite was run under Wine and Xvfb, one GPU at a time with
The two failures are the same on
AI-assisted (Claude Code); numbers copied from the run logs. |
CreateQueryHeap(D3D12_QUERY_HEAP_TYPE_SO_STATISTICS) returned E_NOTIMPL, so a title that makes one got nothing. The layer has no stream output (a PSO with StreamOutput entries is refused, SOSetTargets is not implemented), so every SO_STATISTICS_STREAM0..3 query counts 0 written and 0 needed. Such a heap is now made without a VkQueryPool: Begin/EndQuery record nothing in Vulkan (the D3D12 call rules and the ended tracking still apply), the queries overlap no occlusion or statistics query, and ResolveQueryData fills 16 zero bytes per query (D3D12_QUERY_DATA_SO_STATISTICS) with no statistics split. When stream output lands this becomes a VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT pool. Mesh-shader statistics (PIPELINE_STATISTICS1) are left to D3D-132.
70c9517 to
cd472ec
Compare
|
Rebased on main (f847748) as cd472ec: the only conflicts were docs §4.6 and the overlap counting in AI-assisted. |
|
Tested cd472ec on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). Ran AI-assisted. |
Claimed in the coordination issue as: D3D-302 (#2300)
What and why
CreateQueryHeap(D3D12_QUERY_HEAP_TYPE_SO_STATISTICS)returnedE_NOTIMPL(docs/d3d12_vulkan.md §4.6), so a title that makes one got nothing back. The layer has no stream output: a graphics PSO withStreamOutputentries is refused (d3d12_vulkan_device.cpp, the HS/DS/GS/SO check; #2109 keeps SO refused too) andSOSetTargetsis not implemented. So no primitive ever reaches a stream, and everySO_STATISTICS_STREAM0..3query is exactly{NumPrimitivesWritten 0, PrimitivesStorageNeeded 0}.This PR makes such a heap without a
VkQueryPool:QueryHeap::create:SO_STATISTICSregisters aQueryPoolwhosepoolis null; the destructor removes any registered heap, and destroys the pool only when there is one.query_result_size: 16 bytes for the four stream types (D3D12_QUERY_DATA_SO_STATISTICS, static_assert in the test); newis_so_statistics().prepare: stream queries get their own branch, so they are not counted as a pipeline-statistics query (several streams can run at once, inside a statistics query and across an occlusion one).plan_statistics_segments: an SO resolve does not split a running statistics query (it only fills zeros, nothing is dispatched).emit_query: Begin/EndQuery on a pool-less heap record nothing; the resolve already took the zero-fill path (run.poolnull ->vkCmdFillBuffer).When stream output lands, the heap becomes a
VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXTpool withvkCmdBeginQueryIndexedEXT; Vulkan's two results are in the same order as D3D12's. Written in §4.6.Not in this PR: the mesh/amplification counts of
PIPELINE_STATISTICS1, which D3D-302 also lists. That is D3D-132 (@itsRevela, blocked by #1712), so I left it alone to avoid a duplicate.Tested
runtime/cmake/clang-cl-xwin.cmake), run under Wine 9.0 on Linux with Mesa lavapipe (llvmpipe, LLVM 20.1.2). Not on real hardware: a GPU check (any vendor) would be welcome.d3d12_vulkan_device_test: the SO heap is created; streams 0 and 3 run at once inside the statistics query and across the occlusion query; three queries resolved (one never begun) read 48 zero bytes over the 0xcd fill and nothing past them; an SO query in an occlusion heap isinvalid_query; one begun and never ended is refused atClose. Pass. Negative control: expecting 1 instead of 0 fails at the new line.command_list_test(query_result_sizeof stream 0 is now 16),predicated_copy_test,replay_copy_offset_test,replay_query_predication_test,replay_uav_clear_offset_test,vk_command_replay_test,clear_color_test,d3d12_state_map_test,replay_clear_gate_test,replay_readback_stages_test,replay_write_immediate_predication_test,typeless_rtv_test: all pass, same setup.vk_binary_occlusion/vk_overlapping_occlusion(not configured in this build).AI-assisted.
Checklist
docs/design.md, with how it was confirmed. (No translator change.)