SPIRV-Cross/shaders/amd/shader_ballot.comp

34 lines
948 B
Plaintext
Raw Normal View History

2017-11-21 13:04:57 +00:00
#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;
}
}