upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/statistics_sum.comp
blob: e4e2ce13c173b6669de0d4597f78a4c29aaf7a70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#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.
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; };

void main() {
    const uint counter = gl_LocalInvocationID.x;
    uvec2 sum = total[counter];
    for (uint i = 0; i < count; ++i) {
        uvec2 segment = segments[i * 11 + counter];
        uint low = sum.x + segment.x;
        sum.y += segment.y + uint(low < sum.x);
        sum.x = low;
    }
    total[counter] = sum;
}