1#version 460
2#extension GL_NV_ray_tracing : enable
3
4
5vec4 undeclared_errors(vec4 f4)
6{
7  vec4 result;
8  gl_SubgroupSize;               // ERROR, extension not enabled (basic)
9  gl_SubgroupInvocationID;       // ERROR, extension not enabled (basic)
10  subgroupBarrier();             // ERROR, extension not enabled (basic)
11  subgroupMemoryBarrier();       // ERROR, extension not enabled (basic)
12  subgroupMemoryBarrierBuffer(); // ERROR, extension not enabled (basic)
13  subgroupMemoryBarrierImage();  // ERROR, extension not enabled (basic)
14  subgroupElect();               // ERROR, extension not enabled (basic)
15  gl_NumSubgroups;               // ERROR, only defined in compute
16  gl_SubgroupID;                 // ERROR, only defined in compute
17  subgroupMemoryBarrierShared(); // ERROR, only defined in compute
18
19  subgroupAll(true);        // ERROR extension not enabled (vote)
20  subgroupAny(false);       // ERROR extension not enabled (vote)
21  subgroupAllEqual(f4);     // ERROR extension not enabled (vote)
22
23  gl_SubgroupEqMask;                        // ERROR extension not enabled (ballot)
24  gl_SubgroupGeMask;                        // ERROR extension not enabled (ballot)
25  gl_SubgroupGtMask;                        // ERROR extension not enabled (ballot)
26  gl_SubgroupLeMask;                        // ERROR extension not enabled (ballot)
27  gl_SubgroupLtMask;                        // ERROR extension not enabled (ballot)
28  subgroupBroadcast(f4, 0);                 // ERROR extension not enabled (ballot)
29  subgroupBroadcastFirst(f4);               // ERROR extension not enabled (ballot)
30  uvec4 ballot = subgroupBallot(false);     // ERROR extension not enabled (ballot)
31  subgroupInverseBallot(uvec4(0x1));        // ERROR extension not enabled (ballot)
32  subgroupBallotBitExtract(ballot, 0);      // ERROR extension not enabled (ballot)
33  subgroupBallotBitCount(ballot);           // ERROR extension not enabled (ballot)
34  subgroupBallotInclusiveBitCount(ballot);  // ERROR extension not enabled (ballot)
35  subgroupBallotExclusiveBitCount(ballot);  // ERROR extension not enabled (ballot)
36  subgroupBallotFindLSB(ballot);            // ERROR extension not enabled (ballot)
37  subgroupBallotFindMSB(ballot);            // ERROR extension not enabled (ballot)
38
39  subgroupShuffle(f4, 0);           // ERROR extension not enabled (shuffle)
40  subgroupShuffleXor(f4, 0x1);      // ERROR extension not enabled (shuffle)
41  subgroupShuffleUp(f4, 1);         // ERROR extension not enabled (shuffle_relative)
42  subgroupShuffleDown(f4, 1);       // ERROR extension not enabled (shuffle_relative)
43
44  result = subgroupAdd(f4);         // ERROR, extension not enabled (arith)
45  subgroupMul(f4);                  // ERROR, extension not enabled (arith)
46  subgroupMin(f4);                  // ERROR, extension not enabled (arith)
47  subgroupMax(f4);                  // ERROR, extension not enabled (arith)
48  subgroupAnd(ballot);              // ERROR, extension not enabled (arith)
49  subgroupOr(ballot);               // ERROR, extension not enabled (arith)
50  subgroupXor(ballot);              // ERROR, extension not enabled (arith)
51  subgroupInclusiveAdd(f4);         // ERROR, extension not enabled (arith)
52  subgroupInclusiveMul(f4);         // ERROR, extension not enabled (arith)
53  subgroupInclusiveMin(f4);         // ERROR, extension not enabled (arith)
54  subgroupInclusiveMax(f4);         // ERROR, extension not enabled (arith)
55  subgroupInclusiveAnd(ballot);     // ERROR, extension not enabled (arith)
56  subgroupInclusiveOr(ballot);      // ERROR, extension not enabled (arith)
57  subgroupInclusiveXor(ballot);     // ERROR, extension not enabled (arith)
58  subgroupExclusiveAdd(f4);         // ERROR, extension not enabled (arith)
59  subgroupExclusiveMul(f4);         // ERROR, extension not enabled (arith)
60  subgroupExclusiveMin(f4);         // ERROR, extension not enabled (arith)
61  subgroupExclusiveMax(f4);         // ERROR, extension not enabled (arith)
62  subgroupExclusiveAnd(ballot);     // ERROR, extension not enabled (arith)
63  subgroupExclusiveOr(ballot);      // ERROR, extension not enabled (arith)
64  subgroupExclusiveXor(ballot);     // ERROR, extension not enabled (arith)
65
66  subgroupClusteredAdd(f4, 2);      // ERROR, extension not enabled (clustered)
67  subgroupClusteredMul(f4, 2);      // ERROR, extension not enabled (clustered)
68  subgroupClusteredMin(f4, 2);      // ERROR, extension not enabled (clustered)
69  subgroupClusteredMax(f4, 2);      // ERROR, extension not enabled (clustered)
70  subgroupClusteredAnd(ballot, 2);  // ERROR, extension not enabled (clustered)
71  subgroupClusteredOr(ballot, 2);   // ERROR, extension not enabled (clustered)
72  subgroupClusteredXor(ballot, 2);  // ERROR, extension not enabled (clustered)
73
74  subgroupQuadBroadcast(f4, 0);     // ERROR, extension not enabled (quad)
75  subgroupQuadSwapHorizontal(f4);   // ERROR, extension not enabled (quad)
76  subgroupQuadSwapVertical(f4);     // ERROR, extension not enabled (quad)
77  subgroupQuadSwapDiagonal(f4);     // ERROR, extension not enabled (quad)
78
79  uvec4 parti = subgroupPartitionNV(f4);                // ERROR, extension not enabled (partitioned)
80  subgroupPartitionedAddNV(f4, parti);                  // ERROR, extension not enabled (partitioned)
81  subgroupPartitionedMulNV(f4, parti);                  // ERROR, extension not enabled (partitioned)
82  subgroupPartitionedMinNV(f4, parti);                  // ERROR, extension not enabled (partitioned)
83  subgroupPartitionedMaxNV(f4, parti);                  // ERROR, extension not enabled (partitioned)
84  subgroupPartitionedAndNV(ballot, parti);              // ERROR, extension not enabled (partitioned)
85  subgroupPartitionedOrNV(ballot, parti);               // ERROR, extension not enabled (partitioned)
86  subgroupPartitionedXorNV(ballot, parti);              // ERROR, extension not enabled (partitioned)
87  subgroupPartitionedInclusiveAddNV(f4, parti);         // ERROR, extension not enabled (partitioned)
88  subgroupPartitionedInclusiveMulNV(f4, parti);         // ERROR, extension not enabled (partitioned)
89  subgroupPartitionedInclusiveMinNV(f4, parti);         // ERROR, extension not enabled (partitioned)
90  subgroupPartitionedInclusiveMaxNV(f4, parti);         // ERROR, extension not enabled (partitioned)
91  subgroupPartitionedInclusiveAndNV(ballot, parti);     // ERROR, extension not enabled (partitioned)
92  subgroupPartitionedInclusiveOrNV(ballot, parti);      // ERROR, extension not enabled (partitioned)
93  subgroupPartitionedInclusiveXorNV(ballot, parti);     // ERROR, extension not enabled (partitioned)
94  subgroupPartitionedExclusiveAddNV(f4, parti);         // ERROR, extension not enabled (partitioned)
95  subgroupPartitionedExclusiveMulNV(f4, parti);         // ERROR, extension not enabled (partitioned)
96  subgroupPartitionedExclusiveMinNV(f4, parti);         // ERROR, extension not enabled (partitioned)
97  subgroupPartitionedExclusiveMaxNV(f4, parti);         // ERROR, extension not enabled (partitioned)
98  subgroupPartitionedExclusiveAndNV(ballot, parti);     // ERROR, extension not enabled (partitioned)
99  subgroupPartitionedExclusiveOrNV(ballot, parti);      // ERROR, extension not enabled (partitioned)
100  subgroupPartitionedExclusiveXorNV(ballot, parti);     // ERROR, extension not enabled (partitioned)
101
102  return result;
103}
104
105
106
107hitAttributeNV vec4 iAttr;
108void main()
109{
110	uvec3 v0 = gl_LaunchIDNV;
111	uvec3 v1 = gl_LaunchSizeNV;
112	int v2 = gl_PrimitiveID;
113	int v3 = gl_InstanceID;
114	int v4 = gl_InstanceCustomIndexNV;
115	vec3 v5 = gl_WorldRayOriginNV;
116	vec3 v6 = gl_WorldRayDirectionNV;
117	vec3 v7 = gl_ObjectRayOriginNV;
118	vec3 v8 = gl_ObjectRayDirectionNV;
119	float v9 = gl_RayTminNV;
120	float v10 = gl_RayTmaxNV;
121	mat4x3 v11 = gl_ObjectToWorldNV;
122	mat4x3 v12 = gl_WorldToObjectNV;
123	iAttr = vec4(0.5f,0.5f,0.0f,1.0f);
124	reportIntersectionNV(0.5, 1U);
125}
126
127
128#extension GL_KHR_shader_subgroup_basic: enable
129void basic_works (void)
130{
131  gl_SubgroupSize;
132  gl_SubgroupInvocationID;
133  subgroupBarrier();
134  subgroupMemoryBarrier();
135  subgroupMemoryBarrierBuffer();
136  subgroupMemoryBarrierImage();
137  subgroupElect();
138}
139
140#extension GL_KHR_shader_subgroup_ballot: enable
141void ballot_works(vec4 f4) {
142  gl_SubgroupEqMask;
143  gl_SubgroupGeMask;
144  gl_SubgroupGtMask;
145  gl_SubgroupLeMask;
146  gl_SubgroupLtMask;
147  subgroupBroadcast(f4, 0);
148  subgroupBroadcastFirst(f4);
149  uvec4 ballot = subgroupBallot(false);
150  subgroupInverseBallot(uvec4(0x1));
151  subgroupBallotBitExtract(ballot, 0);
152  subgroupBallotBitCount(ballot);
153  subgroupBallotInclusiveBitCount(ballot);
154  subgroupBallotExclusiveBitCount(ballot);
155  subgroupBallotFindLSB(ballot);
156  subgroupBallotFindMSB(ballot);
157}
158
159#extension GL_KHR_shader_subgroup_vote: enable
160void vote_works(vec4 f4)
161{
162  subgroupAll(true);
163  subgroupAny(false);
164  subgroupAllEqual(f4);
165}
166
167#extension GL_KHR_shader_subgroup_shuffle: enable
168#extension GL_KHR_shader_subgroup_shuffle_relative: enable
169void shuffle_works(vec4 f4)
170{
171  subgroupShuffle(f4, 0);
172  subgroupShuffleXor(f4, 0x1);
173  subgroupShuffleUp(f4, 1);
174  subgroupShuffleDown(f4, 1);
175}
176
177#extension GL_KHR_shader_subgroup_arithmetic: enable
178void arith_works(vec4 f4)
179{
180  uvec4 ballot;
181  subgroupAdd(f4);
182  subgroupMul(f4);
183  subgroupMin(f4);
184  subgroupMax(f4);
185  subgroupAnd(ballot);
186  subgroupOr(ballot);
187  subgroupXor(ballot);
188  subgroupInclusiveAdd(f4);
189  subgroupInclusiveMul(f4);
190  subgroupInclusiveMin(f4);
191  subgroupInclusiveMax(f4);
192  subgroupInclusiveAnd(ballot);
193  subgroupInclusiveOr(ballot);
194  subgroupInclusiveXor(ballot);
195  subgroupExclusiveAdd(f4);
196  subgroupExclusiveMul(f4);
197  subgroupExclusiveMin(f4);
198  subgroupExclusiveMax(f4);
199  subgroupExclusiveAnd(ballot);
200  subgroupExclusiveOr(ballot);
201  subgroupExclusiveXor(ballot);
202}
203
204#extension GL_KHR_shader_subgroup_clustered: enable
205void clustered_works(vec4 f4)
206{
207  uvec4 ballot = uvec4(0x55,0,0,0);
208  subgroupClusteredAdd(f4, 2);
209  subgroupClusteredMul(f4, 2);
210  subgroupClusteredMin(f4, 2);
211  subgroupClusteredMax(f4, 2);
212  subgroupClusteredAnd(ballot, 2);
213  subgroupClusteredOr(ballot, 2);
214  subgroupClusteredXor(ballot, 2);
215}
216
217#extension GL_KHR_shader_subgroup_quad: enable
218void quad_works(vec4 f4)
219{
220  subgroupQuadBroadcast(f4, 0);
221  subgroupQuadSwapHorizontal(f4);
222  subgroupQuadSwapVertical(f4);
223  subgroupQuadSwapDiagonal(f4);
224}
225
226#extension GL_NV_shader_subgroup_partitioned: enable
227void partitioned_works(vec4 f4)
228{
229  uvec4 parti = subgroupPartitionNV(f4);
230  uvec4 ballot = uvec4(0x55,0,0,0);
231  subgroupPartitionedAddNV(f4, parti);
232  subgroupPartitionedMulNV(f4, parti);
233  subgroupPartitionedMinNV(f4, parti);
234  subgroupPartitionedMaxNV(f4, parti);
235  subgroupPartitionedAndNV(ballot, parti);
236  subgroupPartitionedOrNV(ballot, parti);
237  subgroupPartitionedXorNV(ballot, parti);
238  subgroupPartitionedInclusiveAddNV(f4, parti);
239  subgroupPartitionedInclusiveMulNV(f4, parti);
240  subgroupPartitionedInclusiveMinNV(f4, parti);
241  subgroupPartitionedInclusiveMaxNV(f4, parti);
242  subgroupPartitionedInclusiveAndNV(ballot, parti);
243  subgroupPartitionedInclusiveOrNV(ballot, parti);
244  subgroupPartitionedInclusiveXorNV(ballot, parti);
245  subgroupPartitionedExclusiveAddNV(f4, parti);
246  subgroupPartitionedExclusiveMulNV(f4, parti);
247  subgroupPartitionedExclusiveMinNV(f4, parti);
248  subgroupPartitionedExclusiveMaxNV(f4, parti);
249  subgroupPartitionedExclusiveAndNV(ballot, parti);
250  subgroupPartitionedExclusiveOrNV(ballot, parti);
251  subgroupPartitionedExclusiveXorNV(ballot, parti);
252}
253
254// tests for NV_shader_sm_builtins
255void sm_builtins_err()
256{
257    gl_WarpsPerSMNV;    // ERROR, no extension
258    gl_SMCountNV;       // ERROR, no extension
259    gl_WarpIDNV;        // ERROR, no extension
260    gl_SMIDNV;          // ERROR, no extension
261}
262
263#ifdef GL_NV_shader_sm_builtins
264#extension GL_NV_shader_sm_builtins : enable
265#endif
266
267void sm_builtins()
268{
269    gl_WarpsPerSMNV;
270    gl_SMCountNV;
271    gl_WarpIDNV;
272    gl_SMIDNV;
273}
274