Skip to content

D3D-339: zero the other pipeline kind's counters in one-kind statistics queries (draft, on #2870) - #3

Closed
CLHelper wants to merge 1 commit into
base/pr2870-617455adfrom
d3d-339-mesh-statistics-mask
Closed

CLHelper wants to merge 1 commit into
base/pr2870-617455adfrom
d3d-339-mesh-statistics-mask

Conversation

@CLHelper

Copy link
Copy Markdown
Owner

Draft for D3D-339, on top of ItsNotRexed#2870 (617455ad); the base branch here is that head, so this diff is the fix alone. Not a PR to upstream: D3D-339 is @itsRevela's finding and builds on their PR.

What

Vulkan drivers count mesh draws in IAVertices, IAPrimitives and VSInvocations, and vertex draws in MESH_PRIMITIVES_GENERATED; D3D12 reports 0 there. D3D12 requires a query's BeginQuery and EndQuery in one command list, so prepare() can record which kinds of draw each pipeline-statistics query saw (DispatchMesh, or Draw/DrawIndexed/ExecuteIndirect draws). At resolve, a query that saw one kind only gets those counters zeroed (vkCmdFillBuffer after a transfer/compute → transfer barrier):

  • mesh only: IAVertices, IAPrimitives, VSInvocations (both statistics heap types);
  • vertex only: MSPrimitives (PIPELINE_STATISTICS1).

The kinds travel with the query state (QueryReplay pending values and QueryPool::draw_kinds), so a resolve in a later list or submission sees them too, and resolve runs only merge queries with the same kinds.

Not covered: a query that mixes mesh and vertex draws keeps the driver's counts. That needs the split the finding describes (a segment per pipeline kind, with its own mask).

Tested

Windows 11, NVIDIA GeForce RTX 4060 Laptop GPU (Ada), driver 576.80, MSVC 14.44, Vulkan SDK 1.4.363. Synthetic tests only, no game files.

  • d3d12_mesh_statistics_test now requires every counter to match host D3D12. Before: mesh queries 4/4/128 (and 2/2/64) in IAVertices/IAPrimitives/VSInvocations against the host's 0, and VS draw MSPrimitives 1 against 0. After: all 14 counters of all four queries match, including the split one.
  • d3d12_mesh_test, replay_query_predication_test, d3d12_query_rules_test: pass.

AI-assisted.

…tistics queries

Vulkan drivers count mesh draws in IAVertices, IAPrimitives and VSInvocations and vertex draws in
MESH_PRIMITIVES_GENERATED; D3D12 reports 0 there (measured on NVIDIA). prepare() records which kinds of
draw each pipeline-statistics query saw between BeginQuery and EndQuery; a query that saw only one kind
has those counters zeroed at resolve, after a transfer barrier. Queries that mix both kinds keep the
driver's counts. d3d12_mesh_statistics_test now requires every counter to match the host.
@CLHelper

Copy link
Copy Markdown
Owner Author

Superseded: ItsNotRexed#2870, rebuilt on ItsNotRexed#2359 (head 25373c4), fixes the IA/VS counters at the source, so this one-kind workaround is no longer needed. Closing.

@CLHelper CLHelper closed this Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant