computeShader1DExecuteSize

fun computeShader1DExecuteSize(workGroupSize: IntVector3, dataSize: Int): IntVector3(source)

Determines optimal size of ComputeShader execution for 1-dimensional data of variable size.

Note: if the data size is not dividable by the work group size, the excessive invocations will happen and must be discarded in the compute shader:

#version 430
layout (local_size_x = 64) in;

uniform int p_dataSize;

void main() {
int x = int(gl_GlobalInvocationID.x);
if (x >= p_dataSize) {
return;
}
// shader code
}

Parameters

workGroupSize

the work group size, where the x component should be the same as local_size_x specified in the shader.

dataSize

the size of the data to process.