blob: 20059b1c3ce1ca3e1be158c860524abcc97f38ed [file] [log] [blame]
Rex Xu574ab042016-04-14 16:53:07 +08001#version 450
2
3#extension GL_ARB_gpu_shader_int64: enable
4#extension GL_ARB_shader_ballot: enable
5
6layout (local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
7
8layout(binding = 0) buffer Buffers
9{
10 vec4 f4;
11 ivec4 i4;
12 uvec4 u4;
13} data[4];
14
15void main()
16{
17 uint invocation = (gl_SubGroupInvocationARB + gl_SubGroupSizeARB) % 4;
18
19 uint64_t relMask = gl_SubGroupEqMaskARB +
20 gl_SubGroupGeMaskARB +
21 gl_SubGroupGtMaskARB +
22 gl_SubGroupLeMaskARB +
23 gl_SubGroupLtMaskARB;
24
25 if (relMask == ballotARB(true))
26 {
27 data[invocation].f4.x = readInvocationARB(data[0].f4.x, invocation);
28 data[invocation].f4.xy = readInvocationARB(data[1].f4.xy, invocation);
29 data[invocation].f4.xyz = readInvocationARB(data[2].f4.xyz, invocation);
30 data[invocation].f4 = readInvocationARB(data[3].f4, invocation);
31
32 data[invocation].i4.x = readInvocationARB(data[0].i4.x, invocation);
33 data[invocation].i4.xy = readInvocationARB(data[1].i4.xy, invocation);
34 data[invocation].i4.xyz = readInvocationARB(data[2].i4.xyz, invocation);
35 data[invocation].i4 = readInvocationARB(data[3].i4, invocation);
36
37 data[invocation].u4.x = readInvocationARB(data[0].u4.x, invocation);
38 data[invocation].u4.xy = readInvocationARB(data[1].u4.xy, invocation);
39 data[invocation].u4.xyz = readInvocationARB(data[2].u4.xyz, invocation);
40 data[invocation].u4 = readInvocationARB(data[3].u4, invocation);
41 }
42 else
43 {
44 data[invocation].f4.x = readFirstInvocationARB(data[0].f4.x);
45 data[invocation].f4.xy = readFirstInvocationARB(data[1].f4.xy);
46 data[invocation].f4.xyz = readFirstInvocationARB(data[2].f4.xyz);
47 data[invocation].f4 = readFirstInvocationARB(data[3].f4);
48
49 data[invocation].i4.x = readFirstInvocationARB(data[0].i4.x);
50 data[invocation].i4.xy = readFirstInvocationARB(data[1].i4.xy);
51 data[invocation].i4.xyz = readFirstInvocationARB(data[2].i4.xyz);
52 data[invocation].i4 = readFirstInvocationARB(data[3].i4);
53
54 data[invocation].u4.x = readFirstInvocationARB(data[0].u4.x);
55 data[invocation].u4.xy = readFirstInvocationARB(data[1].u4.xy);
56 data[invocation].u4.xyz = readFirstInvocationARB(data[2].u4.xyz);
57 data[invocation].u4 = readFirstInvocationARB(data[3].u4);
58 }
59}