#version 460
layout(local_size_x = 512, local_size_y = 1) in;
layout(std430) buffer;

struct MyStruct {
  uint a;
  uint b;
  uint c;
};

layout(binding = 0) buffer MyStructs {
  uint count;
  MyStruct data[];
}
my_structs;

layout(binding = 1) buffer Output {
  uint a;
  uint b;
  uint c;
}
o;

shared MyStruct s[512];

void main() {
  s[0] = MyStruct(1, 2, 3);

  uint id = gl_GlobalInvocationID.x;
  MyStruct ms =
      id > my_structs.count ? s[id - my_structs.count] : my_structs.data[id];

  atomicAdd(o.a, ms.a);
  atomicAdd(o.b, ms.b);
  atomicAdd(o.c, ms.c);
}

