Merge pull request #2865 from alan-baker/update-license
[platform/upstream/glslang.git] / Test / glsl.460.subgroup.rcall
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(location = 0) callableDataNV vec4 data0;
106 layout(location = 1) callableDataInNV dataBlock {
107         uint data1;
108 };
109 void main()
110 {
111         uvec3 id = gl_LaunchIDNV;
112         uvec3 size = gl_LaunchSizeNV;
113         data1 = 256U;
114         executeCallableNV(2,1);
115 }
116
117
118 #extension GL_KHR_shader_subgroup_basic: enable
119 void basic_works (void)
120 {
121   gl_SubgroupSize;
122   gl_SubgroupInvocationID;
123   subgroupBarrier();
124   subgroupMemoryBarrier();
125   subgroupMemoryBarrierBuffer();
126   subgroupMemoryBarrierImage();
127   subgroupElect();
128 }
129
130 #extension GL_KHR_shader_subgroup_ballot: enable
131 void ballot_works(vec4 f4) {
132   gl_SubgroupEqMask;
133   gl_SubgroupGeMask;
134   gl_SubgroupGtMask;
135   gl_SubgroupLeMask;
136   gl_SubgroupLtMask;
137   subgroupBroadcast(f4, 0);
138   subgroupBroadcastFirst(f4);
139   uvec4 ballot = subgroupBallot(false);
140   subgroupInverseBallot(uvec4(0x1));
141   subgroupBallotBitExtract(ballot, 0);
142   subgroupBallotBitCount(ballot);
143   subgroupBallotInclusiveBitCount(ballot);
144   subgroupBallotExclusiveBitCount(ballot);
145   subgroupBallotFindLSB(ballot);
146   subgroupBallotFindMSB(ballot);
147 }
148
149 #extension GL_KHR_shader_subgroup_vote: enable
150 void vote_works(vec4 f4)
151 {
152   subgroupAll(true);
153   subgroupAny(false);
154   subgroupAllEqual(f4);
155 }
156
157 #extension GL_KHR_shader_subgroup_shuffle: enable
158 #extension GL_KHR_shader_subgroup_shuffle_relative: enable
159 void shuffle_works(vec4 f4)
160 {
161   subgroupShuffle(f4, 0);
162   subgroupShuffleXor(f4, 0x1);
163   subgroupShuffleUp(f4, 1);
164   subgroupShuffleDown(f4, 1);
165 }
166
167 #extension GL_KHR_shader_subgroup_arithmetic: enable
168 void arith_works(vec4 f4)
169 {
170   uvec4 ballot;
171   subgroupAdd(f4);
172   subgroupMul(f4);
173   subgroupMin(f4);
174   subgroupMax(f4);
175   subgroupAnd(ballot);
176   subgroupOr(ballot);
177   subgroupXor(ballot);
178   subgroupInclusiveAdd(f4);
179   subgroupInclusiveMul(f4);
180   subgroupInclusiveMin(f4);
181   subgroupInclusiveMax(f4);
182   subgroupInclusiveAnd(ballot);
183   subgroupInclusiveOr(ballot);
184   subgroupInclusiveXor(ballot);
185   subgroupExclusiveAdd(f4);
186   subgroupExclusiveMul(f4);
187   subgroupExclusiveMin(f4);
188   subgroupExclusiveMax(f4);
189   subgroupExclusiveAnd(ballot);
190   subgroupExclusiveOr(ballot);
191   subgroupExclusiveXor(ballot);
192 }
193
194 #extension GL_KHR_shader_subgroup_clustered: enable
195 void clustered_works(vec4 f4)
196 {
197   uvec4 ballot = uvec4(0x55,0,0,0);
198   subgroupClusteredAdd(f4, 2);
199   subgroupClusteredMul(f4, 2);
200   subgroupClusteredMin(f4, 2);
201   subgroupClusteredMax(f4, 2);
202   subgroupClusteredAnd(ballot, 2);
203   subgroupClusteredOr(ballot, 2);
204   subgroupClusteredXor(ballot, 2);
205 }
206
207 #extension GL_KHR_shader_subgroup_quad: enable
208 void quad_works(vec4 f4)
209 {
210   subgroupQuadBroadcast(f4, 0);
211   subgroupQuadSwapHorizontal(f4);
212   subgroupQuadSwapVertical(f4);
213   subgroupQuadSwapDiagonal(f4);
214 }
215
216 #extension GL_NV_shader_subgroup_partitioned: enable
217 void partitioned_works(vec4 f4)
218 {
219   uvec4 parti = subgroupPartitionNV(f4);
220   uvec4 ballot = uvec4(0x55,0,0,0);
221   subgroupPartitionedAddNV(f4, parti);
222   subgroupPartitionedMulNV(f4, parti);
223   subgroupPartitionedMinNV(f4, parti);
224   subgroupPartitionedMaxNV(f4, parti);
225   subgroupPartitionedAndNV(ballot, parti);
226   subgroupPartitionedOrNV(ballot, parti);
227   subgroupPartitionedXorNV(ballot, parti);
228   subgroupPartitionedInclusiveAddNV(f4, parti);
229   subgroupPartitionedInclusiveMulNV(f4, parti);
230   subgroupPartitionedInclusiveMinNV(f4, parti);
231   subgroupPartitionedInclusiveMaxNV(f4, parti);
232   subgroupPartitionedInclusiveAndNV(ballot, parti);
233   subgroupPartitionedInclusiveOrNV(ballot, parti);
234   subgroupPartitionedInclusiveXorNV(ballot, parti);
235   subgroupPartitionedExclusiveAddNV(f4, parti);
236   subgroupPartitionedExclusiveMulNV(f4, parti);
237   subgroupPartitionedExclusiveMinNV(f4, parti);
238   subgroupPartitionedExclusiveMaxNV(f4, parti);
239   subgroupPartitionedExclusiveAndNV(ballot, parti);
240   subgroupPartitionedExclusiveOrNV(ballot, parti);
241   subgroupPartitionedExclusiveXorNV(ballot, parti);
242 }
243
244 // tests for NV_shader_sm_builtins
245 void sm_builtins_err()
246 {
247     gl_WarpsPerSMNV;    // ERROR, no extension
248     gl_SMCountNV;       // ERROR, no extension
249     gl_WarpIDNV;        // ERROR, no extension
250     gl_SMIDNV;          // ERROR, no extension
251 }
252
253 #ifdef GL_NV_shader_sm_builtins
254 #extension GL_NV_shader_sm_builtins : enable
255 #endif
256
257 void sm_builtins()
258 {
259     gl_WarpsPerSMNV;
260     gl_SMCountNV;
261     gl_WarpIDNV;
262     gl_SMIDNV;
263 }