Repository navigation
Runtime: replay overlapping statistics and binary occlusion queries (D3D-252) - #2100
Conversation
6f0e181 to
ee37962
Compare
0xTehuti
left a comment
There was a problem hiding this comment.
GPU Verification & Code Audit: PR #2100 (D3D-252)
Tested and verified on Windows 11 with MSVC 2022, Ninja, CMake, and Vulkan SDK 1.4:
- GPU: NVIDIA GeForce RTX 2070 SUPER (8192 MB VRAM, Turing TU104, Compute Capability 7.5)
- Driver: NVIDIA Game Ready / Studio 595.79 (Vulkan 1.4.304 / 1.4.363)
- Validation Layers: Khronos Validation Layer active (
LEONIDA_VK_VALIDATION=1) - Environment: Clean-room with synthetic test harnesses (zero game assets)
Test Execution & Results
All 6 query and occlusion test targets compiled and passed 100%:
| Test Target | Duration | Status | Vulkan Validation Errors |
|---|---|---|---|
vk_queue_query_sync |
0.47s | PASSED | 0 errors |
vk_overlapping_occlusion |
0.29s | PASSED | 0 errors |
vk_binary_occlusion |
0.32s | PASSED | 0 errors |
d3d12_vulkan_device |
13.99s | PASSED | 0 errors |
d3d12_query_rules |
0.55s | PASSED | 0 errors |
replay_query_predication |
0.01s | PASSED | 0 errors |
Total test time: 15.71s (100% pass rate).
Engineering Review Notes
- Virtual Segment Pooling: Correctly circumvents the Vulkan limitation allowing only one active occlusion query at a time by transparently sharing and chaining physical pool segments when D3D12 begins multiple overlapping queries.
- Normalization Compute Shaders: The composite sum-and-normalize shaders run outside conditional rendering scopes as required by
D3D-148, avoiding suppression under active predicates. - Lifetime & Resource Management: Query pool allocations, staging buffers, and fence synchronizations in
vulkan_replay.h/vulkan_backend.hshow clean ownership semantics with zero leaks detected.
LGTM. Ready to merge from a Windows + NVIDIA hardware perspective.
AI-assisted verification (Orca / Antigravity). No game data used.
|
Tested
AI-assisted (Claude Code). |
|
Tested ee37962 on an NVIDIA GeForce RTX 3050 Laptop GPU, driver 32.0.16.2101, Windows 11, native MSVC (VS 2022 Build Tools, Ninja, RelWithDebInfo), with
AI-assisted (Claude Code). |
…D3D-252) D3D12 only forbids beginning the same query element twice while it runs, so a command list may overlap two pipeline-statistics queries, or an ordinary occlusion query and a binary one, on different slots of one heap. The replay refused all of those with ReplayResult::unsupported. The overlapping-ordinary occlusion machinery already virtualizes concurrent queries as non-overlapping physical segments whose results are summed; this extends it to the remaining cases: - Binary occlusion joins the ordinary kind in the same physical pool (both are VK_QUERY_TYPE_OCCLUSION, so one physical query is open at a time and the shared intersection interval is counted by both logical queries). A binary resolve of a multi-segment query sums its segments and normalizes the total to 0/1 (OcclusionResolve::sum_binary; run flag needs_sum_binary). - Overlapping pipeline-statistics queries split into the statistics pool with the same one-slot-per-event layout (plan_overlapping_statistics_segments); every non-timestamp resolve while a query runs closes and reopens the open segment for D3D-162's helper-dispatch exclusion. The single-list replay() helper still has no segment pool and refuses such lists outright instead of running two Vulkan queries of one type whole. The device test's old pin of the occlusion+binary refusal now expects a replay; vk_overlapping_occlusion adds crossing statistics queries checked word-by-word against three unsplit references and an ordinary query around a binary one; replay_query_predication pins the segment layouts, the composite binary resolve and the helper's refusal without a GPU. docs/d3d12_vulkan.md 4.6 moves the case out of "Not implemented yet". AI-assisted: yes
|
Tested AI-assisted run for D3D-252: NVIDIA GeForce RTX 5070, driver 617.42 (32.0.16.1742), Windows 11 Home 26300, MSVC 14.44 (VS 2022 Build Tools), Ninja RelWithDebInfo via
Full One note on |
ee37962 to
9b17404
Compare
|
Tested ee37962 on Intel UHD Graphics (Xe-LP, Tiger Lake-H iGPU, driver 101.7088) and NVIDIA RTX 3050 Laptop GPU (driver 617.42), Windows 11 Pro build 26300,
|
|
Tested 9b17404 on AMD Radeon RX 7600 (RDNA3), AMD 26.11.2 (LLPC), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8: pass.
AI-assisted (Claude Code, reviewed with Codex). No game files. |
|
Tested
No game files. AI-assisted (Claude Code). |
Claimed on #313: #313 (comment)
What and why
D3D12's query rules are per heap element ("It is illegal to begin a query twice without ending it, for a given element", the Queries page), so a command list may overlap two pipeline-statistics queries, or an ordinary occlusion query and a binary one, on different slots of one heap — the recording side already accepts them. The replay refused every such list with
ReplayResult::unsupported(vulkan_replay.hbegin-on-active checks), so a title that overlaps queries got no results at all instead of both results.The overlapping-ordinary-occlusion machinery already virtualizes concurrent queries as non-overlapping physical segments summed at resolve time. This extends it to the remaining cases:
VK_QUERY_TYPE_OCCLUSION, so the invariant "one physical query of the type is open at a time" holds unchanged, and the shared intersection interval is counted by both logical queries. A binary resolve of a multi-segment query sums its segments and normalizes the total to 0/1:OcclusionResolve::sum_binaryreuses the existing sum and normalize pipelines back to back, wired assum_binary_occlusionand gated byQueryReplay::needs_sum_binary.plan_overlapping_statistics_segments), and every non-timestamp resolve — and every helper dispatch — while a query runs closes and reopens the open segment for every query still running, so D3D-162's helper-dispatch exclusion keeps holding for all of them (the helpers share the segment numbering with the single-query planner's). A resolve sums the query's contiguous slot range through the existingstatistics_sum.comp.replay()helper has no segment pool. Running such lists whole would keep two Vulkan queries of one type active, which the driver rejects, so it refuses them explicitly instead (PreparedList::statistics_overlaps), the way it already refuses overlapping occlusion resolves without a pool.How checked
Windows 11 26200.9457, MSVC 14.44 (VS 2022 BuildTools), Vulkan headers fetched by the pinned
LEONIDA_VULKAN_HEADERS_FETCH, glslang 16.6.0; GPU NVIDIA GeForce RTX 3060 (driver 617.14, Windows).vk_overlapping_occlusion(GPU): new crossing statistics queries are checked word by word, all eleven counters, against three unsplit reference queries that carry the same draws; an ordinary query around a binary one is checked against its references (ordinary sum, binary 1); CS invocations stay 0. All pre-existing cases pass unchanged.replay_query_predication(CPU, no GPU): new cases 9–13 pin the segment layouts — five/four-slot crossing statistics plans, the shared-segment kind overlap, the composite sum-and-normalize binary resolve, a D24 footprint conversion inside overlapping statistics queries (its dispatches run outside every open segment; the helpers share the numbering,statistics_segment_countgrows by two), and the single-list helper's refusal.d3d12_vulkan_device(GPU, end to end through the proxy): the old pin of the occlusion+binary refusal now expects a successful replay with resolves.cteston the RTX 3060 on the fully rebuilt tree (main at 4947579): all 117 tests pass,d3d12_traceandd3d12_drawincluded (an earlier locald3d12_drawfailure came from stale test binaries and is gone after the rebuild); the seven skipped tests are the usual data-gated ones that skip on every run here.vk_binary_occlusion,vk_command_replay,vk_queue_query_sync,predicated_copy,depth24_convertand the rest of the suite pass unchanged.Notes
docs/d3d12_vulkan.md4.6 moves the case out of "Not implemented yet" and describes the design; the D3D-162 row's "non-query helpers and resolves share the segment numbering" now holds in the overlapping planner too.can_resolve_occlusionexactly as before.mainat 4947579).AI-assisted: yes