You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
d3d12: split pipeline-statistics queries around XDXR compute passes - #8342
Split active D3D12_QUERY_TYPE_PIPELINE_STATISTICS queries around internal XDXR compute passes (BuildAccelerationStructure on the XDXR path, CopyRaytracingAccelerationStructure, and EmitRaytracingAccelerationStructurePostbuildInfo / inline BuildRaytracingAccelerationStructure postbuild writes), matching D3D-162 for every other helper dispatch in runtime/src/vulkan_replay.h:
plan_statistics_segments / plan_overlapping_statistics_segments: treat p.has_xdxr as a helper split point alongside predicate.scratch, predicated_copy, has_depth24, and counted_dispatch.indirect.
prepare():
For XDXR BuildAccelerationStructure: require both vk.xdxr_check and vk.xdxr_record, reject statistics_active && !statistics_helpers with ReplayResult::unsupported, and set p.has_xdxr = true (leaving the KHR path untouched).
For CopyAccelerationStructure and XDXR AccelerationStructurePostbuild: reject statistics_active && !statistics_helpers with ReplayResult::unsupported, and set p.has_xdxr = true.
emit(): bracket vk.xdxr_record, vk.xdxr_copy, and the vk.xdxr_postbuild loop with end_statistics() / begin_statistics().
Root cause
XdxrBuilder implements XDXR BLAS/TLAS builds, refits, copies/compactions, and postbuild size queries via internal compute dispatches (xdxr_build.comp). Unlike PredicateReducer::capture, PredicatedCopy, Depth24Converter, IndirectDispatchCount, and query-resolve helpers, those three XDXR paths did not split active pipeline-statistics queries, causing internal xdxr_build.comp shader invocations to leak into D3D12_QUERY_DATA_PIPELINE_STATISTICS::CSInvocations.
Red -> Green Verification
Tested on Windows 11 Pro (build 26300), MSVC 19.44.35230.0 (RelWithDebInfo), Vulkan SDK 1.4.363.0, AMD Radeon RX 6700 XT (driver 32.0.21045.29003), synthetic geometry only, no game files:
Independent Windows GPU check of 2308eadb on an RTX 3080 Ti (driver 621.35, MSVC 19.44, Vulkan SDK 1.4.363.0).
The stock d3d12_xdxr_statistics CTest passed all four GPU checks without skips. All five query results reported zero CSInvocations, covering acceleration-structure build and update, postbuild info, clone and compact, and overlapping queries. The postbuild and compacted-size checks also passed. Vulkan core and synchronization validation reported zero diagnostics.
Tested 2308eadb1 on Windows 11 (10.0.26300), NVIDIA GeForce RTX 5070 (driver 32.0.16.2101, subgroup 32), MSVC with SDK 10.0.26100, Release, merged onto maindfe4e4ad3 together with #8379, #8372, #8376 and #8342 (no conflicts between them): pass.
d3d12_xdxr_statistics and replay_xdxr_statistics pass.
Tested 2308ead on NVIDIA GeForce RTX 4080 SUPER, driver 621.24 (Vulkan 1.4.357), Windows 11 Pro 26300, MSVC 14.44, Ninja RelWithDebInfo, applied on main6dda063, no game data: pass.
d3d12_xdxr_statistics and replay_xdxr_statistics: both pass.
Negative control: only the test-side files applied (no source change): both fail.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claim: #8186 (comment)
Depends on: none
Summary
Split active
D3D12_QUERY_TYPE_PIPELINE_STATISTICSqueries around internal XDXR compute passes (BuildAccelerationStructureon the XDXR path,CopyRaytracingAccelerationStructure, andEmitRaytracingAccelerationStructurePostbuildInfo/ inlineBuildRaytracingAccelerationStructurepostbuild writes), matching D3D-162 for every other helper dispatch inruntime/src/vulkan_replay.h:detail::Prepared: addbool has_xdxr = false;(automatically cleared onout.commands.assign(..., {})).plan_statistics_segments/plan_overlapping_statistics_segments: treatp.has_xdxras a helper split point alongsidepredicate.scratch,predicated_copy,has_depth24, andcounted_dispatch.indirect.prepare():BuildAccelerationStructure: require bothvk.xdxr_checkandvk.xdxr_record, rejectstatistics_active && !statistics_helperswithReplayResult::unsupported, and setp.has_xdxr = true(leaving the KHR path untouched).CopyAccelerationStructureand XDXRAccelerationStructurePostbuild: rejectstatistics_active && !statistics_helperswithReplayResult::unsupported, and setp.has_xdxr = true.emit(): bracketvk.xdxr_record,vk.xdxr_copy, and thevk.xdxr_postbuildloop withend_statistics()/begin_statistics().Root cause
XdxrBuilderimplements XDXR BLAS/TLAS builds, refits, copies/compactions, and postbuild size queries via internal compute dispatches (xdxr_build.comp). UnlikePredicateReducer::capture,PredicatedCopy,Depth24Converter,IndirectDispatchCount, and query-resolve helpers, those three XDXR paths did not split active pipeline-statistics queries, causing internalxdxr_build.compshader invocations to leak intoD3D12_QUERY_DATA_PIPELINE_STATISTICS::CSInvocations.Red -> Green Verification
Tested on Windows 11 Pro (build 26300), MSVC 19.44.35230.0 (RelWithDebInfo), Vulkan SDK 1.4.363.0, AMD Radeon RX 6700 XT (driver
32.0.21045.29003), synthetic geometry only, no game files:origin/main):replay_xdxr_statistics_test.exefailed 12/12 assertions (exit 1).LEONIDA_VK_VALIDATION=1 d3d12_xdxr_statistics_test.exefailed withCSInvocations = 1408(expected0) insideD3D12_QUERY_TYPE_PIPELINE_STATISTICS.2308eadb1rebased onorigin/main67d877390):replay_xdxr_statistics_test.exe:replay_xdxr_statistics_test: all cases passed(covers single/overlapping statistics splitting,statistics_helpers=falserefusal, XDXR outside queries, KHR non-regression, and half-wired callback refusal).LEONIDA_VK_VALIDATION=1 d3d12_xdxr_statistics_test.exe:d3d12_xdxr_statistics_test: 4 GPU checks passed (CSInvocations == 0 across all XDXR passes)with 0 Vulkan validation or sync-validation errors (covers BLAS + inlineCOMPACTED_SIZEpostbuild + TLAS +PERFORM_UPDATE, multi-sourceEmitRaytracingAccelerationStructurePostbuildInfo,CopyRaytracingAccelerationStructureCLONE+COMPACT, and overlapping queries).LEONIDA_RT_AS=khr d3d12_xdxr_statistics_test.exe: cleanly skipped (exit 77).LEONIDA_VK_VALIDATION=1 ctest --test-dir runtime/build -R "^replay_query|^replay_xdxr|^d3d12_xdxr|^d3d12_predicated_copy|^d3d12_indirect_rt|^vk_xdxr" --output-on-failure -j 12: 8/8 passed (replay_query_edges,replay_xdxr_statistics,replay_query_predication,d3d12_xdxr_statistics,d3d12_xdxr_rt,d3d12_indirect_rt,d3d12_predicated_copy,d3d12_xdxr_rt_check).python -I scripts/check_no_game_data.py runtime/src/vulkan_replay.h runtime/CMakeLists.txt runtime/test/replay_xdxr_statistics_test.cpp runtime/test/d3d12_xdxr_statistics_test.cpp: clean (exit 0).Files
runtime/src/vulkan_replay.hruntime/CMakeLists.txtruntime/test/replay_xdxr_statistics_test.cppruntime/test/d3d12_xdxr_statistics_test.cppAI-assisted (Antigravity / Gemini 4).