Skip to content

Instantly share code, notes, and snippets.

@dboyan
Created November 27, 2016 03:43
Show Gist options
  • Save dboyan/915047bedc30cf9b498557aa320b3987 to your computer and use it in GitHub Desktop.
Save dboyan/915047bedc30cf9b498557aa320b3987 to your computer and use it in GitHub Desktop.
#version 450
layout(local_size_x = 64) in;
layout(binding = 0, std430) writeonly buffer resBlock {
vec3 res1;
vec3 res2;
};
shared uvec3 a;
shared uint bx, by, bz;
void main()
{
if (gl_LocalInvocationID.x == 0u) {
a = uvec3(0u);
bx = 0u;
by = 0u;
bz = 0u;
}
barrier();
uvec3 t = uvec3(1u);
atomicAdd(a.x, t.x);
atomicAdd(a.y, t.y);
atomicAdd(a.z, t.z);
atomicAdd(bx, t.x);
atomicAdd(by, t.y);
atomicAdd(bz, t.z);
barrier();
if (gl_LocalInvocationID.x == 0u) {
res1 = a;
res2 = uvec3(bx, by, bz);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment