1#version 450
2
3#extension GL_KHR_shader_subgroup_quad: enable
4
5layout (local_size_x = 8) 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    data[invocation].f4.x   = subgroupQuadBroadcast(data[0].f4.x, 1);
20    data[invocation].f4.xy  = subgroupQuadBroadcast(data[1].f4.xy, 1);
21    data[invocation].f4.xyz = subgroupQuadBroadcast(data[2].f4.xyz, 1);
22    data[invocation].f4     = subgroupQuadBroadcast(data[3].f4, 1);
23
24    data[invocation].i4.x   = subgroupQuadBroadcast(data[0].i4.x, 1);
25    data[invocation].i4.xy  = subgroupQuadBroadcast(data[1].i4.xy, 1);
26    data[invocation].i4.xyz = subgroupQuadBroadcast(data[2].i4.xyz, 1);
27    data[invocation].i4     = subgroupQuadBroadcast(data[3].i4, 1);
28
29    data[invocation].u4.x   = subgroupQuadBroadcast(data[0].u4.x, 1);
30    data[invocation].u4.xy  = subgroupQuadBroadcast(data[1].u4.xy, 1);
31    data[invocation].u4.xyz = subgroupQuadBroadcast(data[2].u4.xyz, 1);
32    data[invocation].u4     = subgroupQuadBroadcast(data[3].u4, 1);
33
34    data[invocation].d4.x   = subgroupQuadBroadcast(data[0].d4.x, 1);
35    data[invocation].d4.xy  = subgroupQuadBroadcast(data[1].d4.xy, 1);
36    data[invocation].d4.xyz = subgroupQuadBroadcast(data[2].d4.xyz, 1);
37    data[invocation].d4     = subgroupQuadBroadcast(data[3].d4, 1);
38
39    data[invocation].i4.x   =   int(subgroupQuadBroadcast(data[0].i4.x < 0, 1));
40    data[invocation].i4.xy  = ivec2(subgroupQuadBroadcast(lessThan(data[1].i4.xy, ivec2(0)), 1));
41    data[invocation].i4.xyz = ivec3(subgroupQuadBroadcast(lessThan(data[1].i4.xyz, ivec3(0)), 1));
42    data[invocation].i4     = ivec4(subgroupQuadBroadcast(lessThan(data[1].i4, ivec4(0)), 1));
43
44    data[invocation].f4.x   = subgroupQuadSwapHorizontal(data[0].f4.x);
45    data[invocation].f4.xy  = subgroupQuadSwapHorizontal(data[1].f4.xy);
46    data[invocation].f4.xyz = subgroupQuadSwapHorizontal(data[2].f4.xyz);
47    data[invocation].f4     = subgroupQuadSwapHorizontal(data[3].f4);
48
49    data[invocation].i4.x   = subgroupQuadSwapHorizontal(data[0].i4.x);
50    data[invocation].i4.xy  = subgroupQuadSwapHorizontal(data[1].i4.xy);
51    data[invocation].i4.xyz = subgroupQuadSwapHorizontal(data[2].i4.xyz);
52    data[invocation].i4     = subgroupQuadSwapHorizontal(data[3].i4);
53
54    data[invocation].u4.x   = subgroupQuadSwapHorizontal(data[0].u4.x);
55    data[invocation].u4.xy  = subgroupQuadSwapHorizontal(data[1].u4.xy);
56    data[invocation].u4.xyz = subgroupQuadSwapHorizontal(data[2].u4.xyz);
57    data[invocation].u4     = subgroupQuadSwapHorizontal(data[3].u4);
58
59    data[invocation].d4.x   = subgroupQuadSwapHorizontal(data[0].d4.x);
60    data[invocation].d4.xy  = subgroupQuadSwapHorizontal(data[1].d4.xy);
61    data[invocation].d4.xyz = subgroupQuadSwapHorizontal(data[2].d4.xyz);
62    data[invocation].d4     = subgroupQuadSwapHorizontal(data[3].d4);
63
64    data[invocation].i4.x   =   int(subgroupQuadSwapHorizontal(data[0].i4.x < 0));
65    data[invocation].i4.xy  = ivec2(subgroupQuadSwapHorizontal(lessThan(data[1].i4.xy, ivec2(0))));
66    data[invocation].i4.xyz = ivec3(subgroupQuadSwapHorizontal(lessThan(data[1].i4.xyz, ivec3(0))));
67    data[invocation].i4     = ivec4(subgroupQuadSwapHorizontal(lessThan(data[1].i4, ivec4(0))));
68
69    data[invocation].f4.x   = subgroupQuadSwapVertical(data[0].f4.x);
70    data[invocation].f4.xy  = subgroupQuadSwapVertical(data[1].f4.xy);
71    data[invocation].f4.xyz = subgroupQuadSwapVertical(data[2].f4.xyz);
72    data[invocation].f4     = subgroupQuadSwapVertical(data[3].f4);
73
74    data[invocation].i4.x   = subgroupQuadSwapVertical(data[0].i4.x);
75    data[invocation].i4.xy  = subgroupQuadSwapVertical(data[1].i4.xy);
76    data[invocation].i4.xyz = subgroupQuadSwapVertical(data[2].i4.xyz);
77    data[invocation].i4     = subgroupQuadSwapVertical(data[3].i4);
78
79    data[invocation].u4.x   = subgroupQuadSwapVertical(data[0].u4.x);
80    data[invocation].u4.xy  = subgroupQuadSwapVertical(data[1].u4.xy);
81    data[invocation].u4.xyz = subgroupQuadSwapVertical(data[2].u4.xyz);
82    data[invocation].u4     = subgroupQuadSwapVertical(data[3].u4);
83
84    data[invocation].d4.x   = subgroupQuadSwapVertical(data[0].d4.x);
85    data[invocation].d4.xy  = subgroupQuadSwapVertical(data[1].d4.xy);
86    data[invocation].d4.xyz = subgroupQuadSwapVertical(data[2].d4.xyz);
87    data[invocation].d4     = subgroupQuadSwapVertical(data[3].d4);
88
89    data[invocation].i4.x   =   int(subgroupQuadSwapVertical(data[0].i4.x < 0));
90    data[invocation].i4.xy  = ivec2(subgroupQuadSwapVertical(lessThan(data[1].i4.xy, ivec2(0))));
91    data[invocation].i4.xyz = ivec3(subgroupQuadSwapVertical(lessThan(data[1].i4.xyz, ivec3(0))));
92    data[invocation].i4     = ivec4(subgroupQuadSwapVertical(lessThan(data[1].i4, ivec4(0))));
93
94    data[invocation].f4.x   = subgroupQuadSwapDiagonal(data[0].f4.x);
95    data[invocation].f4.xy  = subgroupQuadSwapDiagonal(data[1].f4.xy);
96    data[invocation].f4.xyz = subgroupQuadSwapDiagonal(data[2].f4.xyz);
97    data[invocation].f4     = subgroupQuadSwapDiagonal(data[3].f4);
98
99    data[invocation].i4.x   = subgroupQuadSwapDiagonal(data[0].i4.x);
100    data[invocation].i4.xy  = subgroupQuadSwapDiagonal(data[1].i4.xy);
101    data[invocation].i4.xyz = subgroupQuadSwapDiagonal(data[2].i4.xyz);
102    data[invocation].i4     = subgroupQuadSwapDiagonal(data[3].i4);
103
104    data[invocation].u4.x   = subgroupQuadSwapDiagonal(data[0].u4.x);
105    data[invocation].u4.xy  = subgroupQuadSwapDiagonal(data[1].u4.xy);
106    data[invocation].u4.xyz = subgroupQuadSwapDiagonal(data[2].u4.xyz);
107    data[invocation].u4     = subgroupQuadSwapDiagonal(data[3].u4);
108
109    data[invocation].d4.x   = subgroupQuadSwapDiagonal(data[0].d4.x);
110    data[invocation].d4.xy  = subgroupQuadSwapDiagonal(data[1].d4.xy);
111    data[invocation].d4.xyz = subgroupQuadSwapDiagonal(data[2].d4.xyz);
112    data[invocation].d4     = subgroupQuadSwapDiagonal(data[3].d4);
113
114    data[invocation].i4.x   =   int(subgroupQuadSwapDiagonal(data[0].i4.x < 0));
115    data[invocation].i4.xy  = ivec2(subgroupQuadSwapDiagonal(lessThan(data[1].i4.xy, ivec2(0))));
116    data[invocation].i4.xyz = ivec3(subgroupQuadSwapDiagonal(lessThan(data[1].i4.xyz, ivec3(0))));
117    data[invocation].i4     = ivec4(subgroupQuadSwapDiagonal(lessThan(data[1].i4, ivec4(0))));
118}
119