generate OpLine before OpFunction
[platform/upstream/glslang.git] / Test / glsl.460.subgroup.rmiss
1 #version 460
2 #extension GL_NV_ray_tracing : enable
3
4
5 vec4 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 layout(binding = 0, set = 0) uniform accelerationStructureNV accNV;
107 layout(location = 0) rayPayloadNV vec4 localPayload;
108 layout(location = 1) rayPayloadInNV vec4 incomingPayload;
109 void main()
110 {
111         uvec3 v0 = gl_LaunchIDNV;
112         uvec3 v1 = gl_LaunchSizeNV;
113         vec3 v2 = gl_WorldRayOriginNV;
114         vec3 v3 = gl_WorldRayDirectionNV;
115         vec3 v4 = gl_ObjectRayOriginNV;
116         vec3 v5 = gl_ObjectRayDirectionNV;
117         float v6 = gl_RayTminNV;
118         float v7 = gl_RayTmaxNV;
119         traceNV(accNV, 0u, 1u, 2u, 3u, 0u, vec3(0.5f), 0.5f, vec3(1.0f), 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 }