Merge pull request #2865 from alan-baker/update-license
[platform/upstream/glslang.git] / Test / glsl.460.subgroup.rchit
1 #version 460
2 #extension GL_NV_ray_tracing : enable
3
4 vec4 undeclared_errors(vec4 f4)
5 {
6   vec4 result;
7   gl_SubgroupSize;               // ERROR, extension not enabled (basic)
8   gl_SubgroupInvocationID;       // ERROR, extension not enabled (basic)
9   subgroupBarrier();             // ERROR, extension not enabled (basic)
10   subgroupMemoryBarrier();       // ERROR, extension not enabled (basic)
11   subgroupMemoryBarrierBuffer(); // ERROR, extension not enabled (basic)
12   subgroupMemoryBarrierImage();  // ERROR, extension not enabled (basic)
13   subgroupElect();               // ERROR, extension not enabled (basic)
14   gl_NumSubgroups;               // ERROR, only defined in compute
15   gl_SubgroupID;                 // ERROR, only defined in compute
16   subgroupMemoryBarrierShared(); // ERROR, only defined in compute
17
18   subgroupAll(true);        // ERROR extension not enabled (vote)
19   subgroupAny(false);       // ERROR extension not enabled (vote)
20   subgroupAllEqual(f4);     // ERROR extension not enabled (vote)
21
22   gl_SubgroupEqMask;                        // ERROR extension not enabled (ballot)
23   gl_SubgroupGeMask;                        // ERROR extension not enabled (ballot)
24   gl_SubgroupGtMask;                        // ERROR extension not enabled (ballot)
25   gl_SubgroupLeMask;                        // ERROR extension not enabled (ballot)
26   gl_SubgroupLtMask;                        // ERROR extension not enabled (ballot)
27   subgroupBroadcast(f4, 0);                 // ERROR extension not enabled (ballot)
28   subgroupBroadcastFirst(f4);               // ERROR extension not enabled (ballot)
29   uvec4 ballot = subgroupBallot(false);     // ERROR extension not enabled (ballot)
30   subgroupInverseBallot(uvec4(0x1));        // ERROR extension not enabled (ballot)
31   subgroupBallotBitExtract(ballot, 0);      // ERROR extension not enabled (ballot)
32   subgroupBallotBitCount(ballot);           // ERROR extension not enabled (ballot)
33   subgroupBallotInclusiveBitCount(ballot);  // ERROR extension not enabled (ballot)
34   subgroupBallotExclusiveBitCount(ballot);  // ERROR extension not enabled (ballot)
35   subgroupBallotFindLSB(ballot);            // ERROR extension not enabled (ballot)
36   subgroupBallotFindMSB(ballot);            // ERROR extension not enabled (ballot)
37
38   subgroupShuffle(f4, 0);           // ERROR extension not enabled (shuffle)
39   subgroupShuffleXor(f4, 0x1);      // ERROR extension not enabled (shuffle)
40   subgroupShuffleUp(f4, 1);         // ERROR extension not enabled (shuffle_relative)
41   subgroupShuffleDown(f4, 1);       // ERROR extension not enabled (shuffle_relative)
42
43   result = subgroupAdd(f4);         // ERROR, extension not enabled (arith)
44   subgroupMul(f4);                  // ERROR, extension not enabled (arith)
45   subgroupMin(f4);                  // ERROR, extension not enabled (arith)
46   subgroupMax(f4);                  // ERROR, extension not enabled (arith)
47   subgroupAnd(ballot);              // ERROR, extension not enabled (arith)
48   subgroupOr(ballot);               // ERROR, extension not enabled (arith)
49   subgroupXor(ballot);              // ERROR, extension not enabled (arith)
50   subgroupInclusiveAdd(f4);         // ERROR, extension not enabled (arith)
51   subgroupInclusiveMul(f4);         // ERROR, extension not enabled (arith)
52   subgroupInclusiveMin(f4);         // ERROR, extension not enabled (arith)
53   subgroupInclusiveMax(f4);         // ERROR, extension not enabled (arith)
54   subgroupInclusiveAnd(ballot);     // ERROR, extension not enabled (arith)
55   subgroupInclusiveOr(ballot);      // ERROR, extension not enabled (arith)
56   subgroupInclusiveXor(ballot);     // ERROR, extension not enabled (arith)
57   subgroupExclusiveAdd(f4);         // ERROR, extension not enabled (arith)
58   subgroupExclusiveMul(f4);         // ERROR, extension not enabled (arith)
59   subgroupExclusiveMin(f4);         // ERROR, extension not enabled (arith)
60   subgroupExclusiveMax(f4);         // ERROR, extension not enabled (arith)
61   subgroupExclusiveAnd(ballot);     // ERROR, extension not enabled (arith)
62   subgroupExclusiveOr(ballot);      // ERROR, extension not enabled (arith)
63   subgroupExclusiveXor(ballot);     // ERROR, extension not enabled (arith)
64
65   subgroupClusteredAdd(f4, 2);      // ERROR, extension not enabled (clustered)
66   subgroupClusteredMul(f4, 2);      // ERROR, extension not enabled (clustered)
67   subgroupClusteredMin(f4, 2);      // ERROR, extension not enabled (clustered)
68   subgroupClusteredMax(f4, 2);      // ERROR, extension not enabled (clustered)
69   subgroupClusteredAnd(ballot, 2);  // ERROR, extension not enabled (clustered)
70   subgroupClusteredOr(ballot, 2);   // ERROR, extension not enabled (clustered)
71   subgroupClusteredXor(ballot, 2);  // ERROR, extension not enabled (clustered)
72
73   subgroupQuadBroadcast(f4, 0);     // ERROR, extension not enabled (quad)
74   subgroupQuadSwapHorizontal(f4);   // ERROR, extension not enabled (quad)
75   subgroupQuadSwapVertical(f4);     // ERROR, extension not enabled (quad)
76   subgroupQuadSwapDiagonal(f4);     // ERROR, extension not enabled (quad)
77
78   uvec4 parti = subgroupPartitionNV(f4);                // ERROR, extension not enabled (partitioned)
79   subgroupPartitionedAddNV(f4, parti);                  // ERROR, extension not enabled (partitioned)
80   subgroupPartitionedMulNV(f4, parti);                  // ERROR, extension not enabled (partitioned)
81   subgroupPartitionedMinNV(f4, parti);                  // ERROR, extension not enabled (partitioned)
82   subgroupPartitionedMaxNV(f4, parti);                  // ERROR, extension not enabled (partitioned)
83   subgroupPartitionedAndNV(ballot, parti);              // ERROR, extension not enabled (partitioned)
84   subgroupPartitionedOrNV(ballot, parti);               // ERROR, extension not enabled (partitioned)
85   subgroupPartitionedXorNV(ballot, parti);              // ERROR, extension not enabled (partitioned)
86   subgroupPartitionedInclusiveAddNV(f4, parti);         // ERROR, extension not enabled (partitioned)
87   subgroupPartitionedInclusiveMulNV(f4, parti);         // ERROR, extension not enabled (partitioned)
88   subgroupPartitionedInclusiveMinNV(f4, parti);         // ERROR, extension not enabled (partitioned)
89   subgroupPartitionedInclusiveMaxNV(f4, parti);         // ERROR, extension not enabled (partitioned)
90   subgroupPartitionedInclusiveAndNV(ballot, parti);     // ERROR, extension not enabled (partitioned)
91   subgroupPartitionedInclusiveOrNV(ballot, parti);      // ERROR, extension not enabled (partitioned)
92   subgroupPartitionedInclusiveXorNV(ballot, parti);     // ERROR, extension not enabled (partitioned)
93   subgroupPartitionedExclusiveAddNV(f4, parti);         // ERROR, extension not enabled (partitioned)
94   subgroupPartitionedExclusiveMulNV(f4, parti);         // ERROR, extension not enabled (partitioned)
95   subgroupPartitionedExclusiveMinNV(f4, parti);         // ERROR, extension not enabled (partitioned)
96   subgroupPartitionedExclusiveMaxNV(f4, parti);         // ERROR, extension not enabled (partitioned)
97   subgroupPartitionedExclusiveAndNV(ballot, parti);     // ERROR, extension not enabled (partitioned)
98   subgroupPartitionedExclusiveOrNV(ballot, parti);      // ERROR, extension not enabled (partitioned)
99   subgroupPartitionedExclusiveXorNV(ballot, parti);     // ERROR, extension not enabled (partitioned)
100
101   return result;
102 }
103
104
105 layout(binding = 0, set = 0) uniform accelerationStructureNV accNV;
106 layout(location = 0) rayPayloadNV vec4 localPayload;
107 layout(location = 1) rayPayloadInNV vec4 incomingPayload;
108 void 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         float v11 = gl_HitTNV;
122         uint v12 = gl_HitKindNV;
123         mat4x3 v13 = gl_ObjectToWorldNV;
124         mat4x3 v14 = gl_WorldToObjectNV;
125         traceNV(accNV, 0u, 1u, 2u, 3u, 0u, vec3(0.5f), 0.5f, vec3(1.0f), 0.75f, 1);
126 }
127
128 #extension GL_KHR_shader_subgroup_basic: enable
129 void 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
141 void 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
160 void 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
169 void 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
178 void 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
205 void 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
218 void 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
227 void 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
255 void 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
267 void sm_builtins()
268 {
269     gl_WarpsPerSMNV;
270     gl_SMCountNV;
271     gl_WarpIDNV;
272     gl_SMIDNV;
273 }