mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:30:53 +01:00
[PR #575] [CLOSED] d3d12/vulkan: a mesh segment's clipping invocations come from a mesh-primitives query (D3D-MESH-CLIPPING-COUNTER) #619
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#619
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/575
Author: @Mby159
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:d3d-mesh-clipping-counter📝 Commits (2)
c9f4a56d3d12/vulkan: the mesh statistics pool enables no forbidden counter (D3D-291)4875e01d3d12/vulkan: a mesh segment's clipping invocations come from a mesh-primitives query (D3D-MESH-CLIPPING-COUNTER)📊 Changes
8 files changed (+272 additions, -98 deletions)
View changed files
📝
docs/d3d12_vulkan.md(+27 -16)📝
runtime/src/statistics_sum.comp(+6 -4)📝
runtime/src/statistics_sum_spirv.h(+31 -34)📝
runtime/src/vulkan_backend.h(+41 -14)📝
runtime/src/vulkan_replay.h(+48 -9)📝
runtime/test/d3d12_mesh_test.cpp(+21 -4)📝
runtime/test/replay_query_edges_test.cpp(+76 -14)📝
runtime/test/replay_query_predication_test.cpp(+22 -3)📄 Description
Claimed in the coordination issue as: D3D-MESH-CLIPPING-COUNTER (#14)
Depends on: #540
What and why
D3D-291 leaves the clipping fields of a mesh segment at 0, because
VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076forbids the clipping counters in aPIPELINE_STATISTICSpool that is active during a mesh draw. Where the device exposesVK_EXT_mesh_shaderwith themeshShaderQueriesfeature, the number of primitives the meshshader emitted can come from a
VK_QUERY_TYPE_MESH_PRIMITIVES_GENERATED_EXTquery run aroundthe mesh segment instead — the addition @milk4sale describes in
#14.
That query needs a pool of its own type, so a third pool of the submission is created next to
the two the statistics split needs, begun and ended with each mesh segment. Its count is copied
to field 5 of the segment's record and
statistics_sum.compadds it asCInvocations.CPrimitivesstays 0. Vulkan has no clipped-primitive counter, and D3D12'sCPrimitivesisthe clipper's output — 0 when a triangle is dropped, 2 when it is split — so there is nothing to
read it from. Where the device has no
meshShaderQueries, the fields stay 0, as in #540.The one divergence, documented rather than hidden. The count is not D3D12's number: Vulkan
counts a primitive the mesh shader culled with
gl_CullPrimitiveEXT, which D3D12 does notcount, so a mesh segment's
CInvocationscan be higher than D3D12's. Both measurements showit — @milk4sale's table on an RTX 4070 Ti and @sodove's cross-API comparison against native
D3D12 on the RTX 5070 Ti, where the generated count stayed at 1 for a triangle D3D12's
clipping counters reported as 0/0.
The files:
runtime/src/vulkan_backend.h: the pool ofVK_QUERY_TYPE_MESH_PRIMITIVES_GENERATED_EXT,created only when the device has the feature, and the copy of its count into field 5 of the
segment's record. The
mesh_queriesflag on the context says whether the feature is there.runtime/src/vulkan_replay.h: the pool travels with the list, the segment and the resolve.runtime/src/statistics_sum.comp: a mesh segment now also contributes counter 5.runtime/src/statistics_sum_spirv.h: regenerated fromstatistics_sum.compwith glslang16.6.0 (the version the CI pins) and the command its header names; the module's ID numbering
differs slightly from the build it replaces, the code is the same apart from that one
condition.
Tested
ctest --test-dir runtime/build -C Release: 72 of 72 tests passed (2 skipped:shader_library_corpusneeds the game's shaders,vk_sync_validationneeds a device withthe feature). Built with clang 23.1.6 (llvm-mingw 20261117) against the pinned Vulkan headers
(6802bb47, vulkan-sdk-1.4.363.0).
replay_query_predication_test: the mesh-primitives pool is the list's, and the mesh-onlyquery's resolve sums its one mesh segment with it.
replay_query_edges_test(new case): a mesh segment's record carries the mesh-primitivescount as
CInvocations, the fragment and compute invocations asPSInvocationsandCSInvocations, and nothing else.python -I scripts/check_no_game_data.py <the eight changed files>: passes.spirv-valand matchesstatistics_sum.compbyte for bytewhen recompiled with the same glslang.
The GPU test that covers this path is
d3d12_mesh_test, which needs a GPU withVK_EXT_mesh_shaderand the Khronos validation layer; this machine has neither (the Radeon780M is RDNA3, which has no mesh shader support, and there is no validation layer installed).
The test checks the counts against each other rather than against fixed numbers, because the
generated count is the driver's and depends on the mesh shader's output.
GPUs tested: n/a on this host. @sodove has offered to run this on the RTX 5070 Ti under the
validation layer, including a test device with
meshShaderQueriesdisabled; @milk4sale measuredthe query on an RTX 4070 Ti. Their numbers are quoted above, not mine.
No game files, no keys. AI-assisted: yes.
Checklist
mainand merges cleanly.docs/design.md(not applicable: thisis the D3D12 to Vulkan runtime layer, whose contract is
docs/d3d12_vulkan.md).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.