#version 450 #extension GL_AMD_shader_ballot : require #extension GL_ARB_shader_ballot : require layout (local_size_x = 64) in; layout (std430, binding = 0) buffer inputData { float inputDataArray[]; }; layout (std430, binding = 1) buffer outputData { float outputDataArray[]; }; void main () { float thisLaneData = inputDataArray [gl_LocalInvocationID.x]; bool laneActive = (thisLaneData > 0); uint thisLaneOutputSlot = mbcntAMD (ballotARB (laneActive)); int firstInvocation = readFirstInvocationARB(1); int invocation = readInvocationARB(1, 0); vec3 swizzleInvocations = swizzleInvocationsAMD(vec3(0.0, 2.0, 1.0), uvec4(3)); vec3 swizzelInvocationsMasked = swizzleInvocationsMaskedAMD(vec3(0.0, 2.0, 1.0), uvec3(2)); vec3 writeInvocation = writeInvocationAMD(swizzleInvocations, swizzelInvocationsMasked, 0); if (laneActive) { outputDataArray[thisLaneOutputSlot] = thisLaneData; } }