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