computeShaderExecuteSize
Determines optimal size of ComputeShader execution for 3-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 = 8, local_size_y = 8, local_size_z = 2) in;
uniform ivec3 p_dataSize;
void main() {
ivec3 coord = int(gl_GlobalInvocationID.xyz);
if (coord.x >= p_dataSize.x || coord.y >= p_dataSize.y || coord.z >= p_dataSize.z) {
return;
}
// shader code
}
Content copied to clipboard
Parameters
workGroupSize
the work group size, where the x
, y
and z
components should be the same as local_size_x
, local_size_y
and local_size_y
respectively, as specified in the shader.
dataSize
the size of the data to process.