40 lines
1.2 KiB
GLSL
40 lines
1.2 KiB
GLSL
#[compute]
|
|
#version 450
|
|
// Invocations in the (x, y, z) dimension
|
|
layout(local_size_x = 25, local_size_y = 1, local_size_z = 1) in;
|
|
|
|
// A binding to the buffer we create in our script
|
|
layout(set = 0, binding = 0, std430) restrict buffer PointBuffer {
|
|
int points[];
|
|
}
|
|
pointbuffer;
|
|
layout(set = 0, binding = 1, std430) restrict buffer NeighborBuffer {
|
|
int neighbors[];
|
|
}
|
|
neighborbuffer;
|
|
layout(set = 0, binding = 2, std430) restrict buffer PlateBuffer {
|
|
int plateid[];
|
|
}
|
|
platebuffer;
|
|
|
|
// The code we want to execute in each invocation
|
|
void main() {
|
|
// Iteration is gl_GlobalInvocationID.x
|
|
// Neighbors for Point gl_GlobalInvocationID.y
|
|
for (int point = 0; point < int(gl_WorkGroupSize.x); point++)
|
|
{
|
|
int localpoint = int(gl_WorkGroupID.x)*int(gl_WorkGroupSize.x) + point;
|
|
for (int neighbor = 0; neighbor < 6; neighbor++) {
|
|
if (neighborbuffer.neighbors[localpoint*6+neighbor] == -1)
|
|
{
|
|
continue;
|
|
}
|
|
if (platebuffer.plateid[localpoint] != -1 && platebuffer.plateid[neighborbuffer.neighbors[localpoint*6+neighbor]] == -1)
|
|
{
|
|
// Neighbor unclaimed, and we can claim it.
|
|
platebuffer.plateid[neighborbuffer.neighbors[localpoint*6+neighbor]] = platebuffer.plateid[localpoint];
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|