summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/asymptote/shaders/sum3.glsl
blob: 85f55ff2a6c0152ae4a92ed8cb68559ff1d566b7 (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
layout(local_size_x=LOCAL_SIZE_X) in;

uniform uint offset2;

layout(binding=2, std430) buffer localSumBuffer
{
  uint localSum[];
};

layout(binding=3, std430) buffer globalSumBuffer {
  uint globalSum[];
};

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

  uint row=offset2+LOCAL_SIZE_X*id;
  uint stop=row+LOCAL_SIZE_X;

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

  globalSum[id+1u]=Sum;
}