mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 18:48:38 +00:00
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
30 lines
1.4 KiB
Plaintext
30 lines
1.4 KiB
Plaintext
#version 450
|
|
|
|
// Adds the D3D12_QUERY_DATA_PIPELINE_STATISTICS segments of one split pipeline-statistics query (D3D-162): one
|
|
// invocation per counter, in the order of VkQueryPipelineStatisticFlagBits, which is the D3D12 field order.
|
|
// `mesh` segments come from the pool a mesh draw can run in (D3D-291), which counts only the fragment and compute
|
|
// invocations: they are copied to counters 7 and 8 of their record, so PSInvocations takes the fragment one and
|
|
// CSInvocations the compute one, and every other counter adds nothing.
|
|
// The clipping invocations of a mesh segment come from the mesh-primitives count of that segment, copied to
|
|
// counter 5 (D3D-MESH-CLIPPING-COUNTER); without that count the field stays 0.
|
|
layout(local_size_x = 11) in;
|
|
layout(set = 0, binding = 0, std430) buffer QueryResults {
|
|
uvec2 total[11];
|
|
uvec2 segments[]; // `count` results of 11 counters each
|
|
};
|
|
layout(push_constant) uniform ResolveRange { uint count; uint mesh; };
|
|
|
|
void main() {
|
|
const uint counter = gl_LocalInvocationID.x;
|
|
uvec2 sum = total[counter];
|
|
const bool counted = mesh == 0u || counter == 5u || counter == 7u || counter == 10u;
|
|
const uint source = mesh != 0u && counter == 10u ? 8u : counter;
|
|
for (uint i = 0; counted && i < count; ++i) {
|
|
uvec2 segment = segments[i * 11 + source];
|
|
uint low = sum.x + segment.x;
|
|
sum.y += segment.y + uint(low < sum.x);
|
|
sum.x = low;
|
|
}
|
|
total[counter] = sum;
|
|
}
|