• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#version 450
2
3#extension GL_KHR_shader_subgroup_ballot: enable
4
5layout (local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
6
7layout(binding = 0) buffer Buffers
8{
9    vec4  f4;
10    ivec4 i4;
11    uvec4 u4;
12    dvec4 d4;
13} data[4];
14
15void main()
16{
17    uint invocation = (gl_SubgroupInvocationID + gl_SubgroupSize) % 4;
18
19    uvec4 relMask = gl_SubgroupEqMask +
20                       gl_SubgroupGeMask +
21                       gl_SubgroupGtMask +
22                       gl_SubgroupLeMask +
23                       gl_SubgroupLtMask;
24
25    uvec4 result = subgroupBallot(true);
26
27    data[invocation].u4.x = subgroupBallotBitCount(result);
28    data[invocation].u4.y = subgroupBallotBitExtract(result, 0) ? 1 : 0;
29    data[invocation].u4.z = subgroupBallotInclusiveBitCount(result) + subgroupBallotExclusiveBitCount(result);
30    data[invocation].u4.w = subgroupBallotFindLSB(result) + subgroupBallotFindMSB(result);
31
32    data[invocation].f4.x   = subgroupBroadcast(data[0].f4.x,    invocation);  // ERROR: not constant
33}
34