#version 450 #define INDEX(_x, _y) ((_y) * WIDTH + (_x)) #define IS_CONNECTED(_i0, _i1) (values[_i0] >= 0 && values[_i1] >= 0) #define LABEL(_idx) (values[_idx]) layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; layout(constant_id = 0) const uint WIDTH = 8; layout(constant_id = 1) const uint HEIGHT = 8; layout(binding = 0) buffer Binding { int values[]; }; void scanColumn(uint x) { for (uint y = 1; y < HEIGHT; ++y) { uint i0 = INDEX(x, y-1); uint i1 = INDEX(x, y); if (IS_CONNECTED(i0, i1)) { LABEL(i1) = LABEL(i0); } } } void main() { uint id = gl_GlobalInvocationID.x; scanColumn(id); }