• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#version 450
2
3#extension GL_KHR_shader_subgroup_ballot: enable
4#extension GL_EXT_shader_explicit_arithmetic_types_int8: enable
5#extension GL_EXT_shader_explicit_arithmetic_types_int16: enable
6#extension GL_EXT_shader_explicit_arithmetic_types_int64: enable
7#extension GL_EXT_shader_explicit_arithmetic_types_float16: enable
8
9layout (local_size_x = 8) in;
10
11layout(binding = 0) buffer Buffers
12{
13    i8vec4 i8;
14    u8vec4 u8;
15    i16vec4 i16;
16    u16vec4 u16;
17    i64vec4 i64;
18    u64vec4 u64;
19    f16vec4 f16;
20} data[4];
21
22void main()
23{
24    uint invocation = (gl_SubgroupInvocationID + gl_SubgroupSize) % 4;
25
26    data[invocation].i8.x   = subgroupBroadcast(data[0].i8.x,    3);
27    data[invocation].i8.xy  = subgroupBroadcast(data[1].i8.xy,   3);
28    data[invocation].i8.xyz = subgroupBroadcast(data[2].i8.xyz,  3);
29    data[invocation].i8     = subgroupBroadcast(data[3].i8,      3);
30    data[invocation].i8.x   = subgroupBroadcastFirst(data[0].i8.x);
31    data[invocation].i8.xy  = subgroupBroadcastFirst(data[1].i8.xy);
32    data[invocation].i8.xyz = subgroupBroadcastFirst(data[2].i8.xyz);
33    data[invocation].i8     = subgroupBroadcastFirst(data[3].i8);
34
35    data[invocation].u8.x   = subgroupBroadcast(data[0].u8.x,    3);
36    data[invocation].u8.xy  = subgroupBroadcast(data[1].u8.xy,   3);
37    data[invocation].u8.xyz = subgroupBroadcast(data[2].u8.xyz,  3);
38    data[invocation].u8     = subgroupBroadcast(data[3].u8,      3);
39    data[invocation].u8.x   = subgroupBroadcastFirst(data[0].u8.x);
40    data[invocation].u8.xy  = subgroupBroadcastFirst(data[1].u8.xy);
41    data[invocation].u8.xyz = subgroupBroadcastFirst(data[2].u8.xyz);
42    data[invocation].u8     = subgroupBroadcastFirst(data[3].u8);
43
44    data[invocation].i16.x   = subgroupBroadcast(data[0].i16.x,    3);
45    data[invocation].i16.xy  = subgroupBroadcast(data[1].i16.xy,   3);
46    data[invocation].i16.xyz = subgroupBroadcast(data[2].i16.xyz,  3);
47    data[invocation].i16     = subgroupBroadcast(data[3].i16,      3);
48    data[invocation].i16.x   = subgroupBroadcastFirst(data[0].i16.x);
49    data[invocation].i16.xy  = subgroupBroadcastFirst(data[1].i16.xy);
50    data[invocation].i16.xyz = subgroupBroadcastFirst(data[2].i16.xyz);
51    data[invocation].i16     = subgroupBroadcastFirst(data[3].i16);
52
53    data[invocation].u16.x   = subgroupBroadcast(data[0].u16.x,    3);
54    data[invocation].u16.xy  = subgroupBroadcast(data[1].u16.xy,   3);
55    data[invocation].u16.xyz = subgroupBroadcast(data[2].u16.xyz,  3);
56    data[invocation].u16     = subgroupBroadcast(data[3].u16,      3);
57    data[invocation].u16.x   = subgroupBroadcastFirst(data[0].u16.x);
58    data[invocation].u16.xy  = subgroupBroadcastFirst(data[1].u16.xy);
59    data[invocation].u16.xyz = subgroupBroadcastFirst(data[2].u16.xyz);
60    data[invocation].u16     = subgroupBroadcastFirst(data[3].u16);
61
62    data[invocation].i64.x   = subgroupBroadcast(data[0].i64.x,    3);
63    data[invocation].i64.xy  = subgroupBroadcast(data[1].i64.xy,   3);
64    data[invocation].i64.xyz = subgroupBroadcast(data[2].i64.xyz,  3);
65    data[invocation].i64     = subgroupBroadcast(data[3].i64,      3);
66    data[invocation].i64.x   = subgroupBroadcastFirst(data[0].i64.x);
67    data[invocation].i64.xy  = subgroupBroadcastFirst(data[1].i64.xy);
68    data[invocation].i64.xyz = subgroupBroadcastFirst(data[2].i64.xyz);
69    data[invocation].i64     = subgroupBroadcastFirst(data[3].i64);
70
71    data[invocation].u64.x   = subgroupBroadcast(data[0].u64.x,    3);
72    data[invocation].u64.xy  = subgroupBroadcast(data[1].u64.xy,   3);
73    data[invocation].u64.xyz = subgroupBroadcast(data[2].u64.xyz,  3);
74    data[invocation].u64     = subgroupBroadcast(data[3].u64,      3);
75    data[invocation].u64.x   = subgroupBroadcastFirst(data[0].u64.x);
76    data[invocation].u64.xy  = subgroupBroadcastFirst(data[1].u64.xy);
77    data[invocation].u64.xyz = subgroupBroadcastFirst(data[2].u64.xyz);
78    data[invocation].u64     = subgroupBroadcastFirst(data[3].u64);
79
80    data[invocation].f16.x   = subgroupBroadcast(data[0].f16.x,    3);
81    data[invocation].f16.xy  = subgroupBroadcast(data[1].f16.xy,   3);
82    data[invocation].f16.xyz = subgroupBroadcast(data[2].f16.xyz,  3);
83    data[invocation].f16     = subgroupBroadcast(data[3].f16,      3);
84    data[invocation].f16.x   = subgroupBroadcastFirst(data[0].f16.x);
85    data[invocation].f16.xy  = subgroupBroadcastFirst(data[1].f16.xy);
86    data[invocation].f16.xyz = subgroupBroadcastFirst(data[2].f16.xyz);
87    data[invocation].f16     = subgroupBroadcastFirst(data[3].f16);
88}
89