• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#version 460
2
3vec4 undeclared_errors(vec4 f4)
4{
5  vec4 result;
6  gl_SubgroupSize;               // ERROR, extension not enabled (basic)
7  gl_SubgroupInvocationID;       // ERROR, extension not enabled (basic)
8  subgroupBarrier();             // ERROR, extension not enabled (basic)
9  subgroupMemoryBarrier();       // ERROR, extension not enabled (basic)
10  subgroupMemoryBarrierBuffer(); // ERROR, extension not enabled (basic)
11  subgroupMemoryBarrierImage();  // ERROR, extension not enabled (basic)
12  subgroupElect();               // ERROR, extension not enabled (basic)
13  gl_NumSubgroups;               // ERROR, extension not enabled (basic)
14  gl_SubgroupID;                 // ERROR, extension not enabled (basic)
15  subgroupMemoryBarrierShared(); // ERROR, extension not enabled (basic)
16
17  subgroupAll(true);        // ERROR extension not enabled (vote)
18  subgroupAny(false);       // ERROR extension not enabled (vote)
19  subgroupAllEqual(f4);     // ERROR extension not enabled (vote)
20
21  gl_SubgroupEqMask;                        // ERROR extension not enabled (ballot)
22  gl_SubgroupGeMask;                        // ERROR extension not enabled (ballot)
23  gl_SubgroupGtMask;                        // ERROR extension not enabled (ballot)
24  gl_SubgroupLeMask;                        // ERROR extension not enabled (ballot)
25  gl_SubgroupLtMask;                        // ERROR extension not enabled (ballot)
26  subgroupBroadcast(f4, 0);                 // ERROR extension not enabled (ballot)
27  subgroupBroadcastFirst(f4);               // ERROR extension not enabled (ballot)
28  uvec4 ballot = subgroupBallot(false);     // ERROR extension not enabled (ballot)
29  subgroupInverseBallot(uvec4(0x1));        // ERROR extension not enabled (ballot)
30  subgroupBallotBitExtract(ballot, 0);      // ERROR extension not enabled (ballot)
31  subgroupBallotBitCount(ballot);           // ERROR extension not enabled (ballot)
32  subgroupBallotInclusiveBitCount(ballot);  // ERROR extension not enabled (ballot)
33  subgroupBallotExclusiveBitCount(ballot);  // ERROR extension not enabled (ballot)
34  subgroupBallotFindLSB(ballot);            // ERROR extension not enabled (ballot)
35  subgroupBallotFindMSB(ballot);            // ERROR extension not enabled (ballot)
36
37  subgroupShuffle(f4, 0);           // ERROR extension not enabled (shuffle)
38  subgroupShuffleXor(f4, 0x1);      // ERROR extension not enabled (shuffle)
39  subgroupShuffleUp(f4, 1);         // ERROR extension not enabled (shuffle_relative)
40  subgroupShuffleDown(f4, 1);       // ERROR extension not enabled (shuffle_relative)
41
42  result = subgroupAdd(f4);         // ERROR, extension not enabled (arith)
43  subgroupMul(f4);                  // ERROR, extension not enabled (arith)
44  subgroupMin(f4);                  // ERROR, extension not enabled (arith)
45  subgroupMax(f4);                  // ERROR, extension not enabled (arith)
46  subgroupAnd(ballot);              // ERROR, extension not enabled (arith)
47  subgroupOr(ballot);               // ERROR, extension not enabled (arith)
48  subgroupXor(ballot);              // ERROR, extension not enabled (arith)
49  subgroupInclusiveAdd(f4);         // ERROR, extension not enabled (arith)
50  subgroupInclusiveMul(f4);         // ERROR, extension not enabled (arith)
51  subgroupInclusiveMin(f4);         // ERROR, extension not enabled (arith)
52  subgroupInclusiveMax(f4);         // ERROR, extension not enabled (arith)
53  subgroupInclusiveAnd(ballot);     // ERROR, extension not enabled (arith)
54  subgroupInclusiveOr(ballot);      // ERROR, extension not enabled (arith)
55  subgroupInclusiveXor(ballot);     // ERROR, extension not enabled (arith)
56  subgroupExclusiveAdd(f4);         // ERROR, extension not enabled (arith)
57  subgroupExclusiveMul(f4);         // ERROR, extension not enabled (arith)
58  subgroupExclusiveMin(f4);         // ERROR, extension not enabled (arith)
59  subgroupExclusiveMax(f4);         // ERROR, extension not enabled (arith)
60  subgroupExclusiveAnd(ballot);     // ERROR, extension not enabled (arith)
61  subgroupExclusiveOr(ballot);      // ERROR, extension not enabled (arith)
62  subgroupExclusiveXor(ballot);     // ERROR, extension not enabled (arith)
63
64  subgroupClusteredAdd(f4, 2);      // ERROR, extension not enabled (clustered)
65  subgroupClusteredMul(f4, 2);      // ERROR, extension not enabled (clustered)
66  subgroupClusteredMin(f4, 2);      // ERROR, extension not enabled (clustered)
67  subgroupClusteredMax(f4, 2);      // ERROR, extension not enabled (clustered)
68  subgroupClusteredAnd(ballot, 2);  // ERROR, extension not enabled (clustered)
69  subgroupClusteredOr(ballot, 2);   // ERROR, extension not enabled (clustered)
70  subgroupClusteredXor(ballot, 2);  // ERROR, extension not enabled (clustered)
71
72  subgroupQuadBroadcast(f4, 0);     // ERROR, extension not enabled (quad)
73  subgroupQuadSwapHorizontal(f4);   // ERROR, extension not enabled (quad)
74  subgroupQuadSwapVertical(f4);     // ERROR, extension not enabled (quad)
75  subgroupQuadSwapDiagonal(f4);     // ERROR, extension not enabled (quad)
76
77  uvec4 parti = subgroupPartitionNV(f4);                // ERROR, extension not enabled (partitioned)
78  subgroupPartitionedAddNV(f4, parti);                  // ERROR, extension not enabled (partitioned)
79  subgroupPartitionedMulNV(f4, parti);                  // ERROR, extension not enabled (partitioned)
80  subgroupPartitionedMinNV(f4, parti);                  // ERROR, extension not enabled (partitioned)
81  subgroupPartitionedMaxNV(f4, parti);                  // ERROR, extension not enabled (partitioned)
82  subgroupPartitionedAndNV(ballot, parti);              // ERROR, extension not enabled (partitioned)
83  subgroupPartitionedOrNV(ballot, parti);               // ERROR, extension not enabled (partitioned)
84  subgroupPartitionedXorNV(ballot, parti);              // ERROR, extension not enabled (partitioned)
85  subgroupPartitionedInclusiveAddNV(f4, parti);         // ERROR, extension not enabled (partitioned)
86  subgroupPartitionedInclusiveMulNV(f4, parti);         // ERROR, extension not enabled (partitioned)
87  subgroupPartitionedInclusiveMinNV(f4, parti);         // ERROR, extension not enabled (partitioned)
88  subgroupPartitionedInclusiveMaxNV(f4, parti);         // ERROR, extension not enabled (partitioned)
89  subgroupPartitionedInclusiveAndNV(ballot, parti);     // ERROR, extension not enabled (partitioned)
90  subgroupPartitionedInclusiveOrNV(ballot, parti);      // ERROR, extension not enabled (partitioned)
91  subgroupPartitionedInclusiveXorNV(ballot, parti);     // ERROR, extension not enabled (partitioned)
92  subgroupPartitionedExclusiveAddNV(f4, parti);         // ERROR, extension not enabled (partitioned)
93  subgroupPartitionedExclusiveMulNV(f4, parti);         // ERROR, extension not enabled (partitioned)
94  subgroupPartitionedExclusiveMinNV(f4, parti);         // ERROR, extension not enabled (partitioned)
95  subgroupPartitionedExclusiveMaxNV(f4, parti);         // ERROR, extension not enabled (partitioned)
96  subgroupPartitionedExclusiveAndNV(ballot, parti);     // ERROR, extension not enabled (partitioned)
97  subgroupPartitionedExclusiveOrNV(ballot, parti);      // ERROR, extension not enabled (partitioned)
98  subgroupPartitionedExclusiveXorNV(ballot, parti);     // ERROR, extension not enabled (partitioned)
99
100  return result;
101}
102
103#define MAX_VIEWS gl_MaxMeshViewCountNV
104
105#define BARRIER() \
106    memoryBarrierShared(); \
107    barrier();
108
109#extension GL_NV_mesh_shader : enable
110
111layout(local_size_x = 32) in;
112
113// test use of shared memory in task shaders:
114layout(binding=0) writeonly uniform image2D uni_image;
115uniform block0 {
116    uint uni_value;
117};
118shared vec4 mem[10];
119
120// test use of task memory in task shaders:
121taskNV out Task {
122    vec2 dummy;
123    vec2 submesh[3];
124    uint viewID;
125} mytask;
126
127void main()
128{
129    uint iid = gl_LocalInvocationID.x;
130    uint gid = gl_WorkGroupID.x;
131    uint viewID = gl_MeshViewIndicesNV[gl_MeshViewCountNV%MAX_VIEWS];
132
133    // 1. shared memory load and stores
134    for (uint i = 0; i < 10; ++i) {
135        mem[i] = vec4(i + uni_value);
136    }
137    imageStore(uni_image, ivec2(iid), mem[gid]);
138    imageStore(uni_image, ivec2(iid), mem[gid+1]);
139
140    BARRIER();
141
142    // 2. task memory stores
143
144    mytask.dummy      = vec2(30.0, 31.0);
145    mytask.submesh[0] = vec2(32.0, 33.0);
146    mytask.submesh[1] = vec2(34.0, 35.0);
147    mytask.submesh[2] = mytask.submesh[gid%2];
148    mytask.viewID     = viewID;
149
150    BARRIER();
151
152    // 3. set task count
153    gl_TaskCountNV = 3;
154}
155
156#extension GL_KHR_shader_subgroup_basic: enable
157void basic_works (void)
158{
159  gl_SubgroupSize;
160  gl_SubgroupInvocationID;
161  subgroupBarrier();
162  subgroupMemoryBarrier();
163  subgroupMemoryBarrierBuffer();
164  subgroupMemoryBarrierImage();
165  subgroupElect();
166  gl_NumSubgroups;                  // allowed in task
167  gl_SubgroupID;                    // allowed in task
168  subgroupMemoryBarrierShared();    // allowed in task
169}
170
171#extension GL_KHR_shader_subgroup_ballot: enable
172void ballot_works(vec4 f4) {
173  gl_SubgroupEqMask;
174  gl_SubgroupGeMask;
175  gl_SubgroupGtMask;
176  gl_SubgroupLeMask;
177  gl_SubgroupLtMask;
178  subgroupBroadcast(f4, 0);
179  subgroupBroadcastFirst(f4);
180  uvec4 ballot = subgroupBallot(false);
181  subgroupInverseBallot(uvec4(0x1));
182  subgroupBallotBitExtract(ballot, 0);
183  subgroupBallotBitCount(ballot);
184  subgroupBallotInclusiveBitCount(ballot);
185  subgroupBallotExclusiveBitCount(ballot);
186  subgroupBallotFindLSB(ballot);
187  subgroupBallotFindMSB(ballot);
188}
189
190#extension GL_KHR_shader_subgroup_vote: enable
191void vote_works(vec4 f4)
192{
193  subgroupAll(true);
194  subgroupAny(false);
195  subgroupAllEqual(f4);
196}
197
198#extension GL_KHR_shader_subgroup_shuffle: enable
199#extension GL_KHR_shader_subgroup_shuffle_relative: enable
200void shuffle_works(vec4 f4)
201{
202  subgroupShuffle(f4, 0);
203  subgroupShuffleXor(f4, 0x1);
204  subgroupShuffleUp(f4, 1);
205  subgroupShuffleDown(f4, 1);
206}
207
208#extension GL_KHR_shader_subgroup_arithmetic: enable
209void arith_works(vec4 f4)
210{
211  uvec4 ballot;
212  subgroupAdd(f4);
213  subgroupMul(f4);
214  subgroupMin(f4);
215  subgroupMax(f4);
216  subgroupAnd(ballot);
217  subgroupOr(ballot);
218  subgroupXor(ballot);
219  subgroupInclusiveAdd(f4);
220  subgroupInclusiveMul(f4);
221  subgroupInclusiveMin(f4);
222  subgroupInclusiveMax(f4);
223  subgroupInclusiveAnd(ballot);
224  subgroupInclusiveOr(ballot);
225  subgroupInclusiveXor(ballot);
226  subgroupExclusiveAdd(f4);
227  subgroupExclusiveMul(f4);
228  subgroupExclusiveMin(f4);
229  subgroupExclusiveMax(f4);
230  subgroupExclusiveAnd(ballot);
231  subgroupExclusiveOr(ballot);
232  subgroupExclusiveXor(ballot);
233}
234
235#extension GL_KHR_shader_subgroup_clustered: enable
236void clustered_works(vec4 f4)
237{
238  uvec4 ballot = uvec4(0x55,0,0,0);
239  subgroupClusteredAdd(f4, 2);
240  subgroupClusteredMul(f4, 2);
241  subgroupClusteredMin(f4, 2);
242  subgroupClusteredMax(f4, 2);
243  subgroupClusteredAnd(ballot, 2);
244  subgroupClusteredOr(ballot, 2);
245  subgroupClusteredXor(ballot, 2);
246}
247
248#extension GL_KHR_shader_subgroup_quad: enable
249void quad_works(vec4 f4)
250{
251  subgroupQuadBroadcast(f4, 0);
252  subgroupQuadSwapHorizontal(f4);
253  subgroupQuadSwapVertical(f4);
254  subgroupQuadSwapDiagonal(f4);
255}
256
257#extension GL_NV_shader_subgroup_partitioned: enable
258void partitioned_works(vec4 f4)
259{
260  uvec4 parti = subgroupPartitionNV(f4);
261  uvec4 ballot = uvec4(0x55,0,0,0);
262  subgroupPartitionedAddNV(f4, parti);
263  subgroupPartitionedMulNV(f4, parti);
264  subgroupPartitionedMinNV(f4, parti);
265  subgroupPartitionedMaxNV(f4, parti);
266  subgroupPartitionedAndNV(ballot, parti);
267  subgroupPartitionedOrNV(ballot, parti);
268  subgroupPartitionedXorNV(ballot, parti);
269  subgroupPartitionedInclusiveAddNV(f4, parti);
270  subgroupPartitionedInclusiveMulNV(f4, parti);
271  subgroupPartitionedInclusiveMinNV(f4, parti);
272  subgroupPartitionedInclusiveMaxNV(f4, parti);
273  subgroupPartitionedInclusiveAndNV(ballot, parti);
274  subgroupPartitionedInclusiveOrNV(ballot, parti);
275  subgroupPartitionedInclusiveXorNV(ballot, parti);
276  subgroupPartitionedExclusiveAddNV(f4, parti);
277  subgroupPartitionedExclusiveMulNV(f4, parti);
278  subgroupPartitionedExclusiveMinNV(f4, parti);
279  subgroupPartitionedExclusiveMaxNV(f4, parti);
280  subgroupPartitionedExclusiveAndNV(ballot, parti);
281  subgroupPartitionedExclusiveOrNV(ballot, parti);
282  subgroupPartitionedExclusiveXorNV(ballot, parti);
283}
284
285// tests for NV_shader_sm_builtins
286void sm_builtins_err()
287{
288    gl_WarpsPerSMNV;    // ERROR, no extension
289    gl_SMCountNV;       // ERROR, no extension
290    gl_WarpIDNV;        // ERROR, no extension
291    gl_SMIDNV;          // ERROR, no extension
292}
293
294#ifdef GL_NV_shader_sm_builtins
295#extension GL_NV_shader_sm_builtins : enable
296#endif
297
298void sm_builtins()
299{
300    gl_WarpsPerSMNV;
301    gl_SMCountNV;
302    gl_WarpIDNV;
303    gl_SMIDNV;
304}
305