blob: 9a2afaf845ee27df3c2c269e2ebeb85f3b9154cf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
layout(local_size_x=1) in;
uniform uint elements;
layout(binding=1, std430) buffer offsetBuffer
{
uint offset[];
};
uint ceilquotient(uint a, uint b)
{
return (a+b-1u)/b;
}
void main(void)
{
uint id=gl_GlobalInvocationID.x;
uint m=ceilquotient(elements,gl_NumWorkGroups.x);
uint row=m*id;
uint col=min(m,elements-row);
uint stop=row+col-1u;
uint curr=offset[row];
for(uint i=row; i < stop; ++i) {
uint next=offset[i+1u];
curr += next;
offset[i+1u]=curr;
}
}
|