summaryrefslogtreecommitdiff
path: root/graphics/asymptote/base/shaders/postsum.glsl
blob: 999fe5fdf37d864b4151f7eedac9f8bcd925ab44 (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[];
};

void main(void)
{
  uint id=gl_GlobalInvocationID.x;

  uint m=elements/gl_NumWorkGroups.x;
  uint r=elements-m*gl_NumWorkGroups.x;
  uint row,stop;
  if(id < r) {
    row=m*id+id;
    stop=row+m+1;
  } else {
    row=m*id+r;
    stop=row+m;
  }

  uint Sum=offset[row];
  for(uint i=row+1u; i < stop; ++i) {
    Sum += offset[i];
    offset[i]=Sum;
  }
}