Commit Graph

10 Commits

Author SHA1 Message Date
6af9c80a99 d3d12: refuse an active SO stream across heaps too (D3D-302)
VUID-vkCmdBeginQueryIndexedEXT-queryPool-04753 forbids two active
transform-feedback queries with the same index anywhere in the command
buffer, whatever their pools. prepare() tracked the active ones by heap
and stream, so two heaps beginning stream 0 together still issued two
active indexed queries. It now keeps one bit per stream for the list.

replay_query_predication case 18 adds a second heap: overlapping queries
on one stream in two heaps are refused, and queries that take turns on
that stream are fine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 17:04:39 -05:00
369bb1c753 d3d12: gate SO_STATISTICS pools and refuse per-stream overlap (D3D-302)
The three review points on #1630:

- prepare() refuses two overlapping SO_STATISTICS queries on one stream: two
  active indexed queries in one pool break
  VUID-vkCmdBeginQueryIndexedEXT-queryPool-04753. Queries on different streams
  are fine.
- The transform-feedback pool now also needs the transformFeedbackQueries
  property, and a stream at or above maxTransformFeedbackStreams runs nothing
  and resolves zero instead of issuing an invalid indexed begin.
- replay_query_predication case 18 fails without both: the overlapping-stream
  list is invalid_query and a stream past the pool's stream count fills zeros.

Tested: d3d12_vulkan_device, d3d12_state_map and replay_query_predication pass
plain and with LEONIDA_VK_VALIDATION=1 (RTX 3080 Ti, driver 616.64). AI-assisted.
2026-11-25 14:24:41 -05:00
1bb23a2803 d3d12/vulkan: a mesh segment's clipping invocations come from a mesh-primitives query (D3D-MESH-CLIPPING-COUNTER)
Where the device has the meshShaderQueries feature of VK_EXT_mesh_shader, the number of
primitives the mesh shader emitted comes from a VK_QUERY_TYPE_MESH_PRIMITIVES_GENERATED_EXT
query run around each mesh segment, and it is added as the clipping invocations of that
segment. CPrimitives stays 0: Vulkan has no clipped-primitive counter, and D3D12's
CPrimitives is the clipper's output.

Claim: D3D-MESH-CLIPPING-COUNTER
Depends on: #540
2026-11-24 12:35:29 +00:00
916dbc619d d3d12/vulkan: the mesh statistics pool enables no forbidden counter (D3D-291) 2026-11-24 12:35:29 +00:00
56e607ac85 Runtime: pipeline-statistics queries around mesh draws (D3D-291) (#2359)
Squash-merged after diff review of PR #2359
2026-11-23 09:34:02 -06:00
a8773a46b1 Runtime: the single-list replay() gives overlapping queries segment pools (D3D-399)
With a `keep` vector and ReplayFunctions::create_segment_pool (plus the sum
helpers), replay() makes one occlusion and one pipeline-statistics segment pool
sized to the list, plans them as the batched path does and hands them to the
caller, instead of refusing a list whose queries overlap. Without them the list
is still refused. replay_query_predication_test case 14 checks both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 00:34:08 +03:00
9b17404e15 Runtime: replay overlapping statistics and binary occlusion queries (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
2026-11-22 18:10:42 +01:00
0bde4c82d7 Runtime: split pipeline statistics around predication and footprint helpers (D3D-162)
Replay refused SetPredication, predicated buffer copies and D24/RGB96 footprint conversions while a
pipeline-statistics query was active (#1624 added the last), because their compute dispatches would count in the
application's CSInvocations. They now get the segment split #1519 gave resolves: the statistics query ends its
current physical segment right before the helper dispatch and begins the next right after it, and its result is
the per-counter sum of the segments. Query resolves and these helpers share one segment numbering. The markers for
non-query commands live on detail::Prepared, and emit() places them around capture_predicate,
emit_predicated_copy and the depth24 conversion parts, outside any rendering scope.

Without a statistics segment pool (the single-list replay(), or a queue without the summation helper), the three
commands are still refused while statistics are active, before any helper scratch is allocated (prepare() takes
statistics_helpers, false by default) and again in QueryReplay::plan.

Tests (Khronos validation on): vk_predicated_copy and depth24_convert run their helpers inside an otherwise empty
statistics query. Their results stay byte-exact and all 11 counters are 0. d3d12_predicated_copy compares with
WARP the same way. replay_query_predication checks the emitted order for a capture, a predicated copy, a footprint
copy and a resolve in one query, and the refusal without a pool. predicated_copy and typeless_rtv check both
preparation modes.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 11:52:23 -03:00
170dc22518 Runtime: resolves inside a pipeline-statistics query (D3D-162)
Replay refused binary occlusion resolves, and ordinary resolves that need a sum, while a pipeline-statistics
query was active: their compute helper would count in the application's CSInvocations.

A statistics query that contains a resolve (other than a timestamp copy) is now split. Its counters go to
physical PIPELINE_STATISTICS segments in a pool of the submission's own (flags 0x7ff, as the device creates
the heap). A segment ends before each such resolve and the next begins after it, so no helper dispatch runs
inside the application's query. The query's result is the sum of its segments: a new 11-counter compute shader
(statistics_sum.comp, encoded in statistics_sum_spirv.h like the occlusion helpers) adds them on the
occlusion-resolve scratch buffer. That sum is a helper dispatch too, and is kept out of any statistics query
still running by the same split. Whether a resolve dispatches is only known when the list is planned against
the heaps, so every such resolve splits the query.

The single-list replay() has no segment pool. It keeps refusing a resolve that dispatches inside statistics,
and now allows a binary resolve that only writes zeros. SetPredication and predicated copies are still refused
while statistics are active.

Tests, all with the Khronos validation layer on:
- vk_binary_occlusion: a binary resolve inside one statistics query, then the statistics sum of that query
  inside a second one. Every counter of both is 0. With the split disabled, CSInvocations reads 64.
- vk_overlapping_occlusion: a 261-segment occlusion sum inside a statistics query, with a native draw in each
  segment. The split query, and a second one split around the statistics sum, equal two unsplit queries with the
  same draws on every counter, and CSInvocations is 0.
- replay_query_predication (CPU): the exact begin/end/dispatch order of a split query, and the refusal without a
  segment pool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 08:51:45 -03:00
2fdfd8c433 Runtime: suspend conditional rendering across all ResolveQueryData runs (D3D-148) 2026-11-22 13:06:54 +03:00