• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 2002-2005  3Dlabs Inc. Ltd.
3 // Copyright (C) 2012-2016 LunarG, Inc.
4 // Copyright (C) 2015-2018 Google, Inc.
5 // Copyright (C) 2017 ARM Limited.
6 //
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions
11 // are met:
12 //
13 //    Redistributions of source code must retain the above copyright
14 //    notice, this list of conditions and the following disclaimer.
15 //
16 //    Redistributions in binary form must reproduce the above
17 //    copyright notice, this list of conditions and the following
18 //    disclaimer in the documentation and/or other materials provided
19 //    with the distribution.
20 //
21 //    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
22 //    contributors may be used to endorse or promote products derived
23 //    from this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 // POSSIBILITY OF SUCH DAMAGE.
37 //
38 
39 //
40 // Create strings that declare built-in definitions, add built-ins programmatically
41 // that cannot be expressed in the strings, and establish mappings between
42 // built-in functions and operators.
43 //
44 // Where to put a built-in:
45 //   TBuiltIns::initialize(version,profile)       context-independent textual built-ins; add them to the right string
46 //   TBuiltIns::initialize(resources,...)         context-dependent textual built-ins; add them to the right string
47 //   TBuiltIns::identifyBuiltIns(...,symbolTable) context-independent programmatic additions/mappings to the symbol table,
48 //                                                including identifying what extensions are needed if a version does not allow a symbol
49 //   TBuiltIns::identifyBuiltIns(...,symbolTable, resources) context-dependent programmatic additions/mappings to the symbol table,
50 //                                                including identifying what extensions are needed if a version does not allow a symbol
51 //
52 
53 #include "../Include/intermediate.h"
54 #include "Initialize.h"
55 
56 namespace glslang {
57 
58 // TODO: ARB_Compatability: do full extension support
59 const bool ARBCompatibility = true;
60 
61 const bool ForwardCompatibility = false;
62 
63 // change this back to false if depending on textual spellings of texturing calls when consuming the AST
64 // Using PureOperatorBuiltins=false is deprecated.
65 bool PureOperatorBuiltins = true;
66 
IncludeLegacy(int version,EProfile profile,const SpvVersion & spvVersion)67 inline bool IncludeLegacy(int version, EProfile profile, const SpvVersion& spvVersion)
68 {
69     return profile != EEsProfile && (version <= 130 || (spvVersion.spv == 0 && ARBCompatibility) || profile == ECompatibilityProfile);
70 }
71 
72 // Construct TBuiltInParseables base class.  This can be used for language-common constructs.
TBuiltInParseables()73 TBuiltInParseables::TBuiltInParseables()
74 {
75 }
76 
77 // Destroy TBuiltInParseables.
~TBuiltInParseables()78 TBuiltInParseables::~TBuiltInParseables()
79 {
80 }
81 
TBuiltIns()82 TBuiltIns::TBuiltIns()
83 {
84     // Set up textual representations for making all the permutations
85     // of texturing/imaging functions.
86     prefixes[EbtFloat] =  "";
87 #ifdef AMD_EXTENSIONS
88     prefixes[EbtFloat16] = "f16";
89 #endif
90     prefixes[EbtInt8]  = "i8";
91     prefixes[EbtUint8] = "u8";
92     prefixes[EbtInt16]  = "i16";
93     prefixes[EbtUint16] = "u16";
94     prefixes[EbtInt]   = "i";
95     prefixes[EbtUint]  = "u";
96     postfixes[2] = "2";
97     postfixes[3] = "3";
98     postfixes[4] = "4";
99 
100     // Map from symbolic class of texturing dimension to numeric dimensions.
101     dimMap[Esd1D] = 1;
102     dimMap[Esd2D] = 2;
103     dimMap[EsdRect] = 2;
104     dimMap[Esd3D] = 3;
105     dimMap[EsdCube] = 3;
106     dimMap[EsdBuffer] = 1;
107     dimMap[EsdSubpass] = 2;  // potientially unused for now
108 }
109 
~TBuiltIns()110 TBuiltIns::~TBuiltIns()
111 {
112 }
113 
114 
115 //
116 // Add all context-independent built-in functions and variables that are present
117 // for the given version and profile.  Share common ones across stages, otherwise
118 // make stage-specific entries.
119 //
120 // Most built-ins variables can be added as simple text strings.  Some need to
121 // be added programmatically, which is done later in IdentifyBuiltIns() below.
122 //
initialize(int version,EProfile profile,const SpvVersion & spvVersion)123 void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvVersion)
124 {
125     //============================================================================
126     //
127     // Prototypes for built-in functions used repeatly by different shaders
128     //
129     //============================================================================
130 
131     //
132     // Derivatives Functions.
133     //
134     TString derivatives (
135         "float dFdx(float p);"
136         "vec2  dFdx(vec2  p);"
137         "vec3  dFdx(vec3  p);"
138         "vec4  dFdx(vec4  p);"
139 
140         "float dFdy(float p);"
141         "vec2  dFdy(vec2  p);"
142         "vec3  dFdy(vec3  p);"
143         "vec4  dFdy(vec4  p);"
144 
145         "float fwidth(float p);"
146         "vec2  fwidth(vec2  p);"
147         "vec3  fwidth(vec3  p);"
148         "vec4  fwidth(vec4  p);"
149     );
150 
151     TString derivativeControls (
152         "float dFdxFine(float p);"
153         "vec2  dFdxFine(vec2  p);"
154         "vec3  dFdxFine(vec3  p);"
155         "vec4  dFdxFine(vec4  p);"
156 
157         "float dFdyFine(float p);"
158         "vec2  dFdyFine(vec2  p);"
159         "vec3  dFdyFine(vec3  p);"
160         "vec4  dFdyFine(vec4  p);"
161 
162         "float fwidthFine(float p);"
163         "vec2  fwidthFine(vec2  p);"
164         "vec3  fwidthFine(vec3  p);"
165         "vec4  fwidthFine(vec4  p);"
166 
167         "float dFdxCoarse(float p);"
168         "vec2  dFdxCoarse(vec2  p);"
169         "vec3  dFdxCoarse(vec3  p);"
170         "vec4  dFdxCoarse(vec4  p);"
171 
172         "float dFdyCoarse(float p);"
173         "vec2  dFdyCoarse(vec2  p);"
174         "vec3  dFdyCoarse(vec3  p);"
175         "vec4  dFdyCoarse(vec4  p);"
176 
177         "float fwidthCoarse(float p);"
178         "vec2  fwidthCoarse(vec2  p);"
179         "vec3  fwidthCoarse(vec3  p);"
180         "vec4  fwidthCoarse(vec4  p);"
181     );
182 
183     TString derivativesAndControl16bits (
184         "float16_t dFdx(float16_t);"
185         "f16vec2   dFdx(f16vec2);"
186         "f16vec3   dFdx(f16vec3);"
187         "f16vec4   dFdx(f16vec4);"
188 
189         "float16_t dFdy(float16_t);"
190         "f16vec2   dFdy(f16vec2);"
191         "f16vec3   dFdy(f16vec3);"
192         "f16vec4   dFdy(f16vec4);"
193 
194         "float16_t dFdxFine(float16_t);"
195         "f16vec2   dFdxFine(f16vec2);"
196         "f16vec3   dFdxFine(f16vec3);"
197         "f16vec4   dFdxFine(f16vec4);"
198 
199         "float16_t dFdyFine(float16_t);"
200         "f16vec2   dFdyFine(f16vec2);"
201         "f16vec3   dFdyFine(f16vec3);"
202         "f16vec4   dFdyFine(f16vec4);"
203 
204         "float16_t dFdxCoarse(float16_t);"
205         "f16vec2   dFdxCoarse(f16vec2);"
206         "f16vec3   dFdxCoarse(f16vec3);"
207         "f16vec4   dFdxCoarse(f16vec4);"
208 
209         "float16_t dFdyCoarse(float16_t);"
210         "f16vec2   dFdyCoarse(f16vec2);"
211         "f16vec3   dFdyCoarse(f16vec3);"
212         "f16vec4   dFdyCoarse(f16vec4);"
213 
214         "float16_t fwidth(float16_t);"
215         "f16vec2   fwidth(f16vec2);"
216         "f16vec3   fwidth(f16vec3);"
217         "f16vec4   fwidth(f16vec4);"
218 
219         "float16_t fwidthFine(float16_t);"
220         "f16vec2   fwidthFine(f16vec2);"
221         "f16vec3   fwidthFine(f16vec3);"
222         "f16vec4   fwidthFine(f16vec4);"
223 
224         "float16_t fwidthCoarse(float16_t);"
225         "f16vec2   fwidthCoarse(f16vec2);"
226         "f16vec3   fwidthCoarse(f16vec3);"
227         "f16vec4   fwidthCoarse(f16vec4);"
228     );
229 
230     TString derivativesAndControl64bits (
231         "float64_t dFdx(float64_t);"
232         "f64vec2   dFdx(f64vec2);"
233         "f64vec3   dFdx(f64vec3);"
234         "f64vec4   dFdx(f64vec4);"
235 
236         "float64_t dFdy(float64_t);"
237         "f64vec2   dFdy(f64vec2);"
238         "f64vec3   dFdy(f64vec3);"
239         "f64vec4   dFdy(f64vec4);"
240 
241         "float64_t dFdxFine(float64_t);"
242         "f64vec2   dFdxFine(f64vec2);"
243         "f64vec3   dFdxFine(f64vec3);"
244         "f64vec4   dFdxFine(f64vec4);"
245 
246         "float64_t dFdyFine(float64_t);"
247         "f64vec2   dFdyFine(f64vec2);"
248         "f64vec3   dFdyFine(f64vec3);"
249         "f64vec4   dFdyFine(f64vec4);"
250 
251         "float64_t dFdxCoarse(float64_t);"
252         "f64vec2   dFdxCoarse(f64vec2);"
253         "f64vec3   dFdxCoarse(f64vec3);"
254         "f64vec4   dFdxCoarse(f64vec4);"
255 
256         "float64_t dFdyCoarse(float64_t);"
257         "f64vec2   dFdyCoarse(f64vec2);"
258         "f64vec3   dFdyCoarse(f64vec3);"
259         "f64vec4   dFdyCoarse(f64vec4);"
260 
261         "float64_t fwidth(float64_t);"
262         "f64vec2   fwidth(f64vec2);"
263         "f64vec3   fwidth(f64vec3);"
264         "f64vec4   fwidth(f64vec4);"
265 
266         "float64_t fwidthFine(float64_t);"
267         "f64vec2   fwidthFine(f64vec2);"
268         "f64vec3   fwidthFine(f64vec3);"
269         "f64vec4   fwidthFine(f64vec4);"
270 
271         "float64_t fwidthCoarse(float64_t);"
272         "f64vec2   fwidthCoarse(f64vec2);"
273         "f64vec3   fwidthCoarse(f64vec3);"
274         "f64vec4   fwidthCoarse(f64vec4);"
275     );
276 
277     //============================================================================
278     //
279     // Prototypes for built-in functions seen by both vertex and fragment shaders.
280     //
281     //============================================================================
282 
283     //
284     // Angle and Trigonometric Functions.
285     //
286     commonBuiltins.append(
287         "float radians(float degrees);"
288         "vec2  radians(vec2  degrees);"
289         "vec3  radians(vec3  degrees);"
290         "vec4  radians(vec4  degrees);"
291 
292         "float degrees(float radians);"
293         "vec2  degrees(vec2  radians);"
294         "vec3  degrees(vec3  radians);"
295         "vec4  degrees(vec4  radians);"
296 
297         "float sin(float angle);"
298         "vec2  sin(vec2  angle);"
299         "vec3  sin(vec3  angle);"
300         "vec4  sin(vec4  angle);"
301 
302         "float cos(float angle);"
303         "vec2  cos(vec2  angle);"
304         "vec3  cos(vec3  angle);"
305         "vec4  cos(vec4  angle);"
306 
307         "float tan(float angle);"
308         "vec2  tan(vec2  angle);"
309         "vec3  tan(vec3  angle);"
310         "vec4  tan(vec4  angle);"
311 
312         "float asin(float x);"
313         "vec2  asin(vec2  x);"
314         "vec3  asin(vec3  x);"
315         "vec4  asin(vec4  x);"
316 
317         "float acos(float x);"
318         "vec2  acos(vec2  x);"
319         "vec3  acos(vec3  x);"
320         "vec4  acos(vec4  x);"
321 
322         "float atan(float y, float x);"
323         "vec2  atan(vec2  y, vec2  x);"
324         "vec3  atan(vec3  y, vec3  x);"
325         "vec4  atan(vec4  y, vec4  x);"
326 
327         "float atan(float y_over_x);"
328         "vec2  atan(vec2  y_over_x);"
329         "vec3  atan(vec3  y_over_x);"
330         "vec4  atan(vec4  y_over_x);"
331 
332         "\n");
333 
334     if (version >= 130) {
335         commonBuiltins.append(
336             "float sinh(float angle);"
337             "vec2  sinh(vec2  angle);"
338             "vec3  sinh(vec3  angle);"
339             "vec4  sinh(vec4  angle);"
340 
341             "float cosh(float angle);"
342             "vec2  cosh(vec2  angle);"
343             "vec3  cosh(vec3  angle);"
344             "vec4  cosh(vec4  angle);"
345 
346             "float tanh(float angle);"
347             "vec2  tanh(vec2  angle);"
348             "vec3  tanh(vec3  angle);"
349             "vec4  tanh(vec4  angle);"
350 
351             "float asinh(float x);"
352             "vec2  asinh(vec2  x);"
353             "vec3  asinh(vec3  x);"
354             "vec4  asinh(vec4  x);"
355 
356             "float acosh(float x);"
357             "vec2  acosh(vec2  x);"
358             "vec3  acosh(vec3  x);"
359             "vec4  acosh(vec4  x);"
360 
361             "float atanh(float y_over_x);"
362             "vec2  atanh(vec2  y_over_x);"
363             "vec3  atanh(vec3  y_over_x);"
364             "vec4  atanh(vec4  y_over_x);"
365 
366             "\n");
367     }
368 
369     //
370     // Exponential Functions.
371     //
372     commonBuiltins.append(
373         "float pow(float x, float y);"
374         "vec2  pow(vec2  x, vec2  y);"
375         "vec3  pow(vec3  x, vec3  y);"
376         "vec4  pow(vec4  x, vec4  y);"
377 
378         "float exp(float x);"
379         "vec2  exp(vec2  x);"
380         "vec3  exp(vec3  x);"
381         "vec4  exp(vec4  x);"
382 
383         "float log(float x);"
384         "vec2  log(vec2  x);"
385         "vec3  log(vec3  x);"
386         "vec4  log(vec4  x);"
387 
388         "float exp2(float x);"
389         "vec2  exp2(vec2  x);"
390         "vec3  exp2(vec3  x);"
391         "vec4  exp2(vec4  x);"
392 
393         "float log2(float x);"
394         "vec2  log2(vec2  x);"
395         "vec3  log2(vec3  x);"
396         "vec4  log2(vec4  x);"
397 
398         "float sqrt(float x);"
399         "vec2  sqrt(vec2  x);"
400         "vec3  sqrt(vec3  x);"
401         "vec4  sqrt(vec4  x);"
402 
403         "float inversesqrt(float x);"
404         "vec2  inversesqrt(vec2  x);"
405         "vec3  inversesqrt(vec3  x);"
406         "vec4  inversesqrt(vec4  x);"
407 
408         "\n");
409 
410     //
411     // Common Functions.
412     //
413     commonBuiltins.append(
414         "float abs(float x);"
415         "vec2  abs(vec2  x);"
416         "vec3  abs(vec3  x);"
417         "vec4  abs(vec4  x);"
418 
419         "float sign(float x);"
420         "vec2  sign(vec2  x);"
421         "vec3  sign(vec3  x);"
422         "vec4  sign(vec4  x);"
423 
424         "float floor(float x);"
425         "vec2  floor(vec2  x);"
426         "vec3  floor(vec3  x);"
427         "vec4  floor(vec4  x);"
428 
429         "float ceil(float x);"
430         "vec2  ceil(vec2  x);"
431         "vec3  ceil(vec3  x);"
432         "vec4  ceil(vec4  x);"
433 
434         "float fract(float x);"
435         "vec2  fract(vec2  x);"
436         "vec3  fract(vec3  x);"
437         "vec4  fract(vec4  x);"
438 
439         "float mod(float x, float y);"
440         "vec2  mod(vec2  x, float y);"
441         "vec3  mod(vec3  x, float y);"
442         "vec4  mod(vec4  x, float y);"
443         "vec2  mod(vec2  x, vec2  y);"
444         "vec3  mod(vec3  x, vec3  y);"
445         "vec4  mod(vec4  x, vec4  y);"
446 
447         "float min(float x, float y);"
448         "vec2  min(vec2  x, float y);"
449         "vec3  min(vec3  x, float y);"
450         "vec4  min(vec4  x, float y);"
451         "vec2  min(vec2  x, vec2  y);"
452         "vec3  min(vec3  x, vec3  y);"
453         "vec4  min(vec4  x, vec4  y);"
454 
455         "float max(float x, float y);"
456         "vec2  max(vec2  x, float y);"
457         "vec3  max(vec3  x, float y);"
458         "vec4  max(vec4  x, float y);"
459         "vec2  max(vec2  x, vec2  y);"
460         "vec3  max(vec3  x, vec3  y);"
461         "vec4  max(vec4  x, vec4  y);"
462 
463         "float clamp(float x, float minVal, float maxVal);"
464         "vec2  clamp(vec2  x, float minVal, float maxVal);"
465         "vec3  clamp(vec3  x, float minVal, float maxVal);"
466         "vec4  clamp(vec4  x, float minVal, float maxVal);"
467         "vec2  clamp(vec2  x, vec2  minVal, vec2  maxVal);"
468         "vec3  clamp(vec3  x, vec3  minVal, vec3  maxVal);"
469         "vec4  clamp(vec4  x, vec4  minVal, vec4  maxVal);"
470 
471         "float mix(float x, float y, float a);"
472         "vec2  mix(vec2  x, vec2  y, float a);"
473         "vec3  mix(vec3  x, vec3  y, float a);"
474         "vec4  mix(vec4  x, vec4  y, float a);"
475         "vec2  mix(vec2  x, vec2  y, vec2  a);"
476         "vec3  mix(vec3  x, vec3  y, vec3  a);"
477         "vec4  mix(vec4  x, vec4  y, vec4  a);"
478 
479         "float step(float edge, float x);"
480         "vec2  step(vec2  edge, vec2  x);"
481         "vec3  step(vec3  edge, vec3  x);"
482         "vec4  step(vec4  edge, vec4  x);"
483         "vec2  step(float edge, vec2  x);"
484         "vec3  step(float edge, vec3  x);"
485         "vec4  step(float edge, vec4  x);"
486 
487         "float smoothstep(float edge0, float edge1, float x);"
488         "vec2  smoothstep(vec2  edge0, vec2  edge1, vec2  x);"
489         "vec3  smoothstep(vec3  edge0, vec3  edge1, vec3  x);"
490         "vec4  smoothstep(vec4  edge0, vec4  edge1, vec4  x);"
491         "vec2  smoothstep(float edge0, float edge1, vec2  x);"
492         "vec3  smoothstep(float edge0, float edge1, vec3  x);"
493         "vec4  smoothstep(float edge0, float edge1, vec4  x);"
494 
495         "\n");
496 
497     if (version >= 130) {
498         commonBuiltins.append(
499             "  int abs(  int x);"
500             "ivec2 abs(ivec2 x);"
501             "ivec3 abs(ivec3 x);"
502             "ivec4 abs(ivec4 x);"
503 
504             "  int sign(  int x);"
505             "ivec2 sign(ivec2 x);"
506             "ivec3 sign(ivec3 x);"
507             "ivec4 sign(ivec4 x);"
508 
509             "float trunc(float x);"
510             "vec2  trunc(vec2  x);"
511             "vec3  trunc(vec3  x);"
512             "vec4  trunc(vec4  x);"
513 
514             "float round(float x);"
515             "vec2  round(vec2  x);"
516             "vec3  round(vec3  x);"
517             "vec4  round(vec4  x);"
518 
519             "float roundEven(float x);"
520             "vec2  roundEven(vec2  x);"
521             "vec3  roundEven(vec3  x);"
522             "vec4  roundEven(vec4  x);"
523 
524             "float modf(float, out float);"
525             "vec2  modf(vec2,  out vec2 );"
526             "vec3  modf(vec3,  out vec3 );"
527             "vec4  modf(vec4,  out vec4 );"
528 
529             "  int min(int    x, int y);"
530             "ivec2 min(ivec2  x, int y);"
531             "ivec3 min(ivec3  x, int y);"
532             "ivec4 min(ivec4  x, int y);"
533             "ivec2 min(ivec2  x, ivec2  y);"
534             "ivec3 min(ivec3  x, ivec3  y);"
535             "ivec4 min(ivec4  x, ivec4  y);"
536 
537             " uint min(uint   x, uint y);"
538             "uvec2 min(uvec2  x, uint y);"
539             "uvec3 min(uvec3  x, uint y);"
540             "uvec4 min(uvec4  x, uint y);"
541             "uvec2 min(uvec2  x, uvec2  y);"
542             "uvec3 min(uvec3  x, uvec3  y);"
543             "uvec4 min(uvec4  x, uvec4  y);"
544 
545             "  int max(int    x, int y);"
546             "ivec2 max(ivec2  x, int y);"
547             "ivec3 max(ivec3  x, int y);"
548             "ivec4 max(ivec4  x, int y);"
549             "ivec2 max(ivec2  x, ivec2  y);"
550             "ivec3 max(ivec3  x, ivec3  y);"
551             "ivec4 max(ivec4  x, ivec4  y);"
552 
553             " uint max(uint   x, uint y);"
554             "uvec2 max(uvec2  x, uint y);"
555             "uvec3 max(uvec3  x, uint y);"
556             "uvec4 max(uvec4  x, uint y);"
557             "uvec2 max(uvec2  x, uvec2  y);"
558             "uvec3 max(uvec3  x, uvec3  y);"
559             "uvec4 max(uvec4  x, uvec4  y);"
560 
561             "int    clamp(int x, int minVal, int maxVal);"
562             "ivec2  clamp(ivec2  x, int minVal, int maxVal);"
563             "ivec3  clamp(ivec3  x, int minVal, int maxVal);"
564             "ivec4  clamp(ivec4  x, int minVal, int maxVal);"
565             "ivec2  clamp(ivec2  x, ivec2  minVal, ivec2  maxVal);"
566             "ivec3  clamp(ivec3  x, ivec3  minVal, ivec3  maxVal);"
567             "ivec4  clamp(ivec4  x, ivec4  minVal, ivec4  maxVal);"
568 
569             "uint   clamp(uint x, uint minVal, uint maxVal);"
570             "uvec2  clamp(uvec2  x, uint minVal, uint maxVal);"
571             "uvec3  clamp(uvec3  x, uint minVal, uint maxVal);"
572             "uvec4  clamp(uvec4  x, uint minVal, uint maxVal);"
573             "uvec2  clamp(uvec2  x, uvec2  minVal, uvec2  maxVal);"
574             "uvec3  clamp(uvec3  x, uvec3  minVal, uvec3  maxVal);"
575             "uvec4  clamp(uvec4  x, uvec4  minVal, uvec4  maxVal);"
576 
577             "float mix(float x, float y, bool  a);"
578             "vec2  mix(vec2  x, vec2  y, bvec2 a);"
579             "vec3  mix(vec3  x, vec3  y, bvec3 a);"
580             "vec4  mix(vec4  x, vec4  y, bvec4 a);"
581 
582             "bool  isnan(float x);"
583             "bvec2 isnan(vec2  x);"
584             "bvec3 isnan(vec3  x);"
585             "bvec4 isnan(vec4  x);"
586 
587             "bool  isinf(float x);"
588             "bvec2 isinf(vec2  x);"
589             "bvec3 isinf(vec3  x);"
590             "bvec4 isinf(vec4  x);"
591 
592             "\n");
593     }
594 
595     //
596     // double functions added to desktop 4.00, but not fma, frexp, ldexp, or pack/unpack
597     //
598     if (profile != EEsProfile && version >= 400) {
599         commonBuiltins.append(
600 
601             "double sqrt(double);"
602             "dvec2  sqrt(dvec2);"
603             "dvec3  sqrt(dvec3);"
604             "dvec4  sqrt(dvec4);"
605 
606             "double inversesqrt(double);"
607             "dvec2  inversesqrt(dvec2);"
608             "dvec3  inversesqrt(dvec3);"
609             "dvec4  inversesqrt(dvec4);"
610 
611             "double abs(double);"
612             "dvec2  abs(dvec2);"
613             "dvec3  abs(dvec3);"
614             "dvec4  abs(dvec4);"
615 
616             "double sign(double);"
617             "dvec2  sign(dvec2);"
618             "dvec3  sign(dvec3);"
619             "dvec4  sign(dvec4);"
620 
621             "double floor(double);"
622             "dvec2  floor(dvec2);"
623             "dvec3  floor(dvec3);"
624             "dvec4  floor(dvec4);"
625 
626             "double trunc(double);"
627             "dvec2  trunc(dvec2);"
628             "dvec3  trunc(dvec3);"
629             "dvec4  trunc(dvec4);"
630 
631             "double round(double);"
632             "dvec2  round(dvec2);"
633             "dvec3  round(dvec3);"
634             "dvec4  round(dvec4);"
635 
636             "double roundEven(double);"
637             "dvec2  roundEven(dvec2);"
638             "dvec3  roundEven(dvec3);"
639             "dvec4  roundEven(dvec4);"
640 
641             "double ceil(double);"
642             "dvec2  ceil(dvec2);"
643             "dvec3  ceil(dvec3);"
644             "dvec4  ceil(dvec4);"
645 
646             "double fract(double);"
647             "dvec2  fract(dvec2);"
648             "dvec3  fract(dvec3);"
649             "dvec4  fract(dvec4);"
650 
651             "double mod(double, double);"
652             "dvec2  mod(dvec2 , double);"
653             "dvec3  mod(dvec3 , double);"
654             "dvec4  mod(dvec4 , double);"
655             "dvec2  mod(dvec2 , dvec2);"
656             "dvec3  mod(dvec3 , dvec3);"
657             "dvec4  mod(dvec4 , dvec4);"
658 
659             "double modf(double, out double);"
660             "dvec2  modf(dvec2,  out dvec2);"
661             "dvec3  modf(dvec3,  out dvec3);"
662             "dvec4  modf(dvec4,  out dvec4);"
663 
664             "double min(double, double);"
665             "dvec2  min(dvec2,  double);"
666             "dvec3  min(dvec3,  double);"
667             "dvec4  min(dvec4,  double);"
668             "dvec2  min(dvec2,  dvec2);"
669             "dvec3  min(dvec3,  dvec3);"
670             "dvec4  min(dvec4,  dvec4);"
671 
672             "double max(double, double);"
673             "dvec2  max(dvec2 , double);"
674             "dvec3  max(dvec3 , double);"
675             "dvec4  max(dvec4 , double);"
676             "dvec2  max(dvec2 , dvec2);"
677             "dvec3  max(dvec3 , dvec3);"
678             "dvec4  max(dvec4 , dvec4);"
679 
680             "double clamp(double, double, double);"
681             "dvec2  clamp(dvec2 , double, double);"
682             "dvec3  clamp(dvec3 , double, double);"
683             "dvec4  clamp(dvec4 , double, double);"
684             "dvec2  clamp(dvec2 , dvec2 , dvec2);"
685             "dvec3  clamp(dvec3 , dvec3 , dvec3);"
686             "dvec4  clamp(dvec4 , dvec4 , dvec4);"
687 
688             "double mix(double, double, double);"
689             "dvec2  mix(dvec2,  dvec2,  double);"
690             "dvec3  mix(dvec3,  dvec3,  double);"
691             "dvec4  mix(dvec4,  dvec4,  double);"
692             "dvec2  mix(dvec2,  dvec2,  dvec2);"
693             "dvec3  mix(dvec3,  dvec3,  dvec3);"
694             "dvec4  mix(dvec4,  dvec4,  dvec4);"
695             "double mix(double, double, bool);"
696             "dvec2  mix(dvec2,  dvec2,  bvec2);"
697             "dvec3  mix(dvec3,  dvec3,  bvec3);"
698             "dvec4  mix(dvec4,  dvec4,  bvec4);"
699 
700             "double step(double, double);"
701             "dvec2  step(dvec2 , dvec2);"
702             "dvec3  step(dvec3 , dvec3);"
703             "dvec4  step(dvec4 , dvec4);"
704             "dvec2  step(double, dvec2);"
705             "dvec3  step(double, dvec3);"
706             "dvec4  step(double, dvec4);"
707 
708             "double smoothstep(double, double, double);"
709             "dvec2  smoothstep(dvec2 , dvec2 , dvec2);"
710             "dvec3  smoothstep(dvec3 , dvec3 , dvec3);"
711             "dvec4  smoothstep(dvec4 , dvec4 , dvec4);"
712             "dvec2  smoothstep(double, double, dvec2);"
713             "dvec3  smoothstep(double, double, dvec3);"
714             "dvec4  smoothstep(double, double, dvec4);"
715 
716             "bool  isnan(double);"
717             "bvec2 isnan(dvec2);"
718             "bvec3 isnan(dvec3);"
719             "bvec4 isnan(dvec4);"
720 
721             "bool  isinf(double);"
722             "bvec2 isinf(dvec2);"
723             "bvec3 isinf(dvec3);"
724             "bvec4 isinf(dvec4);"
725 
726             "double length(double);"
727             "double length(dvec2);"
728             "double length(dvec3);"
729             "double length(dvec4);"
730 
731             "double distance(double, double);"
732             "double distance(dvec2 , dvec2);"
733             "double distance(dvec3 , dvec3);"
734             "double distance(dvec4 , dvec4);"
735 
736             "double dot(double, double);"
737             "double dot(dvec2 , dvec2);"
738             "double dot(dvec3 , dvec3);"
739             "double dot(dvec4 , dvec4);"
740 
741             "dvec3 cross(dvec3, dvec3);"
742 
743             "double normalize(double);"
744             "dvec2  normalize(dvec2);"
745             "dvec3  normalize(dvec3);"
746             "dvec4  normalize(dvec4);"
747 
748             "double faceforward(double, double, double);"
749             "dvec2  faceforward(dvec2,  dvec2,  dvec2);"
750             "dvec3  faceforward(dvec3,  dvec3,  dvec3);"
751             "dvec4  faceforward(dvec4,  dvec4,  dvec4);"
752 
753             "double reflect(double, double);"
754             "dvec2  reflect(dvec2 , dvec2 );"
755             "dvec3  reflect(dvec3 , dvec3 );"
756             "dvec4  reflect(dvec4 , dvec4 );"
757 
758             "double refract(double, double, double);"
759             "dvec2  refract(dvec2 , dvec2 , double);"
760             "dvec3  refract(dvec3 , dvec3 , double);"
761             "dvec4  refract(dvec4 , dvec4 , double);"
762 
763             "dmat2 matrixCompMult(dmat2, dmat2);"
764             "dmat3 matrixCompMult(dmat3, dmat3);"
765             "dmat4 matrixCompMult(dmat4, dmat4);"
766             "dmat2x3 matrixCompMult(dmat2x3, dmat2x3);"
767             "dmat2x4 matrixCompMult(dmat2x4, dmat2x4);"
768             "dmat3x2 matrixCompMult(dmat3x2, dmat3x2);"
769             "dmat3x4 matrixCompMult(dmat3x4, dmat3x4);"
770             "dmat4x2 matrixCompMult(dmat4x2, dmat4x2);"
771             "dmat4x3 matrixCompMult(dmat4x3, dmat4x3);"
772 
773             "dmat2   outerProduct(dvec2, dvec2);"
774             "dmat3   outerProduct(dvec3, dvec3);"
775             "dmat4   outerProduct(dvec4, dvec4);"
776             "dmat2x3 outerProduct(dvec3, dvec2);"
777             "dmat3x2 outerProduct(dvec2, dvec3);"
778             "dmat2x4 outerProduct(dvec4, dvec2);"
779             "dmat4x2 outerProduct(dvec2, dvec4);"
780             "dmat3x4 outerProduct(dvec4, dvec3);"
781             "dmat4x3 outerProduct(dvec3, dvec4);"
782 
783             "dmat2   transpose(dmat2);"
784             "dmat3   transpose(dmat3);"
785             "dmat4   transpose(dmat4);"
786             "dmat2x3 transpose(dmat3x2);"
787             "dmat3x2 transpose(dmat2x3);"
788             "dmat2x4 transpose(dmat4x2);"
789             "dmat4x2 transpose(dmat2x4);"
790             "dmat3x4 transpose(dmat4x3);"
791             "dmat4x3 transpose(dmat3x4);"
792 
793             "double determinant(dmat2);"
794             "double determinant(dmat3);"
795             "double determinant(dmat4);"
796 
797             "dmat2 inverse(dmat2);"
798             "dmat3 inverse(dmat3);"
799             "dmat4 inverse(dmat4);"
800 
801             "bvec2 lessThan(dvec2, dvec2);"
802             "bvec3 lessThan(dvec3, dvec3);"
803             "bvec4 lessThan(dvec4, dvec4);"
804 
805             "bvec2 lessThanEqual(dvec2, dvec2);"
806             "bvec3 lessThanEqual(dvec3, dvec3);"
807             "bvec4 lessThanEqual(dvec4, dvec4);"
808 
809             "bvec2 greaterThan(dvec2, dvec2);"
810             "bvec3 greaterThan(dvec3, dvec3);"
811             "bvec4 greaterThan(dvec4, dvec4);"
812 
813             "bvec2 greaterThanEqual(dvec2, dvec2);"
814             "bvec3 greaterThanEqual(dvec3, dvec3);"
815             "bvec4 greaterThanEqual(dvec4, dvec4);"
816 
817             "bvec2 equal(dvec2, dvec2);"
818             "bvec3 equal(dvec3, dvec3);"
819             "bvec4 equal(dvec4, dvec4);"
820 
821             "bvec2 notEqual(dvec2, dvec2);"
822             "bvec3 notEqual(dvec3, dvec3);"
823             "bvec4 notEqual(dvec4, dvec4);"
824 
825             "\n");
826     }
827 
828     if (profile != EEsProfile && version >= 450) {
829         commonBuiltins.append(
830 
831             "int64_t abs(int64_t);"
832             "i64vec2 abs(i64vec2);"
833             "i64vec3 abs(i64vec3);"
834             "i64vec4 abs(i64vec4);"
835 
836             "int64_t sign(int64_t);"
837             "i64vec2 sign(i64vec2);"
838             "i64vec3 sign(i64vec3);"
839             "i64vec4 sign(i64vec4);"
840 
841             "int64_t  min(int64_t,  int64_t);"
842             "i64vec2  min(i64vec2,  int64_t);"
843             "i64vec3  min(i64vec3,  int64_t);"
844             "i64vec4  min(i64vec4,  int64_t);"
845             "i64vec2  min(i64vec2,  i64vec2);"
846             "i64vec3  min(i64vec3,  i64vec3);"
847             "i64vec4  min(i64vec4,  i64vec4);"
848             "uint64_t min(uint64_t, uint64_t);"
849             "u64vec2  min(u64vec2,  uint64_t);"
850             "u64vec3  min(u64vec3,  uint64_t);"
851             "u64vec4  min(u64vec4,  uint64_t);"
852             "u64vec2  min(u64vec2,  u64vec2);"
853             "u64vec3  min(u64vec3,  u64vec3);"
854             "u64vec4  min(u64vec4,  u64vec4);"
855 
856             "int64_t  max(int64_t,  int64_t);"
857             "i64vec2  max(i64vec2,  int64_t);"
858             "i64vec3  max(i64vec3,  int64_t);"
859             "i64vec4  max(i64vec4,  int64_t);"
860             "i64vec2  max(i64vec2,  i64vec2);"
861             "i64vec3  max(i64vec3,  i64vec3);"
862             "i64vec4  max(i64vec4,  i64vec4);"
863             "uint64_t max(uint64_t, uint64_t);"
864             "u64vec2  max(u64vec2,  uint64_t);"
865             "u64vec3  max(u64vec3,  uint64_t);"
866             "u64vec4  max(u64vec4,  uint64_t);"
867             "u64vec2  max(u64vec2,  u64vec2);"
868             "u64vec3  max(u64vec3,  u64vec3);"
869             "u64vec4  max(u64vec4,  u64vec4);"
870 
871             "int64_t  clamp(int64_t,  int64_t,  int64_t);"
872             "i64vec2  clamp(i64vec2,  int64_t,  int64_t);"
873             "i64vec3  clamp(i64vec3,  int64_t,  int64_t);"
874             "i64vec4  clamp(i64vec4,  int64_t,  int64_t);"
875             "i64vec2  clamp(i64vec2,  i64vec2,  i64vec2);"
876             "i64vec3  clamp(i64vec3,  i64vec3,  i64vec3);"
877             "i64vec4  clamp(i64vec4,  i64vec4,  i64vec4);"
878             "uint64_t clamp(uint64_t, uint64_t, uint64_t);"
879             "u64vec2  clamp(u64vec2,  uint64_t, uint64_t);"
880             "u64vec3  clamp(u64vec3,  uint64_t, uint64_t);"
881             "u64vec4  clamp(u64vec4,  uint64_t, uint64_t);"
882             "u64vec2  clamp(u64vec2,  u64vec2,  u64vec2);"
883             "u64vec3  clamp(u64vec3,  u64vec3,  u64vec3);"
884             "u64vec4  clamp(u64vec4,  u64vec4,  u64vec4);"
885 
886             "int64_t  mix(int64_t,  int64_t,  bool);"
887             "i64vec2  mix(i64vec2,  i64vec2,  bvec2);"
888             "i64vec3  mix(i64vec3,  i64vec3,  bvec3);"
889             "i64vec4  mix(i64vec4,  i64vec4,  bvec4);"
890             "uint64_t mix(uint64_t, uint64_t, bool);"
891             "u64vec2  mix(u64vec2,  u64vec2,  bvec2);"
892             "u64vec3  mix(u64vec3,  u64vec3,  bvec3);"
893             "u64vec4  mix(u64vec4,  u64vec4,  bvec4);"
894 
895             "int64_t doubleBitsToInt64(double);"
896             "i64vec2 doubleBitsToInt64(dvec2);"
897             "i64vec3 doubleBitsToInt64(dvec3);"
898             "i64vec4 doubleBitsToInt64(dvec4);"
899 
900             "uint64_t doubleBitsToUint64(double);"
901             "u64vec2  doubleBitsToUint64(dvec2);"
902             "u64vec3  doubleBitsToUint64(dvec3);"
903             "u64vec4  doubleBitsToUint64(dvec4);"
904 
905             "double int64BitsToDouble(int64_t);"
906             "dvec2  int64BitsToDouble(i64vec2);"
907             "dvec3  int64BitsToDouble(i64vec3);"
908             "dvec4  int64BitsToDouble(i64vec4);"
909 
910             "double uint64BitsToDouble(uint64_t);"
911             "dvec2  uint64BitsToDouble(u64vec2);"
912             "dvec3  uint64BitsToDouble(u64vec3);"
913             "dvec4  uint64BitsToDouble(u64vec4);"
914 
915             "int64_t  packInt2x32(ivec2);"
916             "uint64_t packUint2x32(uvec2);"
917             "ivec2    unpackInt2x32(int64_t);"
918             "uvec2    unpackUint2x32(uint64_t);"
919 
920             "bvec2 lessThan(i64vec2, i64vec2);"
921             "bvec3 lessThan(i64vec3, i64vec3);"
922             "bvec4 lessThan(i64vec4, i64vec4);"
923             "bvec2 lessThan(u64vec2, u64vec2);"
924             "bvec3 lessThan(u64vec3, u64vec3);"
925             "bvec4 lessThan(u64vec4, u64vec4);"
926 
927             "bvec2 lessThanEqual(i64vec2, i64vec2);"
928             "bvec3 lessThanEqual(i64vec3, i64vec3);"
929             "bvec4 lessThanEqual(i64vec4, i64vec4);"
930             "bvec2 lessThanEqual(u64vec2, u64vec2);"
931             "bvec3 lessThanEqual(u64vec3, u64vec3);"
932             "bvec4 lessThanEqual(u64vec4, u64vec4);"
933 
934             "bvec2 greaterThan(i64vec2, i64vec2);"
935             "bvec3 greaterThan(i64vec3, i64vec3);"
936             "bvec4 greaterThan(i64vec4, i64vec4);"
937             "bvec2 greaterThan(u64vec2, u64vec2);"
938             "bvec3 greaterThan(u64vec3, u64vec3);"
939             "bvec4 greaterThan(u64vec4, u64vec4);"
940 
941             "bvec2 greaterThanEqual(i64vec2, i64vec2);"
942             "bvec3 greaterThanEqual(i64vec3, i64vec3);"
943             "bvec4 greaterThanEqual(i64vec4, i64vec4);"
944             "bvec2 greaterThanEqual(u64vec2, u64vec2);"
945             "bvec3 greaterThanEqual(u64vec3, u64vec3);"
946             "bvec4 greaterThanEqual(u64vec4, u64vec4);"
947 
948             "bvec2 equal(i64vec2, i64vec2);"
949             "bvec3 equal(i64vec3, i64vec3);"
950             "bvec4 equal(i64vec4, i64vec4);"
951             "bvec2 equal(u64vec2, u64vec2);"
952             "bvec3 equal(u64vec3, u64vec3);"
953             "bvec4 equal(u64vec4, u64vec4);"
954 
955             "bvec2 notEqual(i64vec2, i64vec2);"
956             "bvec3 notEqual(i64vec3, i64vec3);"
957             "bvec4 notEqual(i64vec4, i64vec4);"
958             "bvec2 notEqual(u64vec2, u64vec2);"
959             "bvec3 notEqual(u64vec3, u64vec3);"
960             "bvec4 notEqual(u64vec4, u64vec4);"
961 
962             "int   findLSB(int64_t);"
963             "ivec2 findLSB(i64vec2);"
964             "ivec3 findLSB(i64vec3);"
965             "ivec4 findLSB(i64vec4);"
966 
967             "int   findLSB(uint64_t);"
968             "ivec2 findLSB(u64vec2);"
969             "ivec3 findLSB(u64vec3);"
970             "ivec4 findLSB(u64vec4);"
971 
972             "int   findMSB(int64_t);"
973             "ivec2 findMSB(i64vec2);"
974             "ivec3 findMSB(i64vec3);"
975             "ivec4 findMSB(i64vec4);"
976 
977             "int   findMSB(uint64_t);"
978             "ivec2 findMSB(u64vec2);"
979             "ivec3 findMSB(u64vec3);"
980             "ivec4 findMSB(u64vec4);"
981 
982             "\n"
983         );
984     }
985 
986 #ifdef AMD_EXTENSIONS
987     // GL_AMD_shader_trinary_minmax
988     if (profile != EEsProfile && version >= 430) {
989         commonBuiltins.append(
990             "float min3(float, float, float);"
991             "vec2  min3(vec2,  vec2,  vec2);"
992             "vec3  min3(vec3,  vec3,  vec3);"
993             "vec4  min3(vec4,  vec4,  vec4);"
994 
995             "int   min3(int,   int,   int);"
996             "ivec2 min3(ivec2, ivec2, ivec2);"
997             "ivec3 min3(ivec3, ivec3, ivec3);"
998             "ivec4 min3(ivec4, ivec4, ivec4);"
999 
1000             "uint  min3(uint,  uint,  uint);"
1001             "uvec2 min3(uvec2, uvec2, uvec2);"
1002             "uvec3 min3(uvec3, uvec3, uvec3);"
1003             "uvec4 min3(uvec4, uvec4, uvec4);"
1004 
1005             "float max3(float, float, float);"
1006             "vec2  max3(vec2,  vec2,  vec2);"
1007             "vec3  max3(vec3,  vec3,  vec3);"
1008             "vec4  max3(vec4,  vec4,  vec4);"
1009 
1010             "int   max3(int,   int,   int);"
1011             "ivec2 max3(ivec2, ivec2, ivec2);"
1012             "ivec3 max3(ivec3, ivec3, ivec3);"
1013             "ivec4 max3(ivec4, ivec4, ivec4);"
1014 
1015             "uint  max3(uint,  uint,  uint);"
1016             "uvec2 max3(uvec2, uvec2, uvec2);"
1017             "uvec3 max3(uvec3, uvec3, uvec3);"
1018             "uvec4 max3(uvec4, uvec4, uvec4);"
1019 
1020             "float mid3(float, float, float);"
1021             "vec2  mid3(vec2,  vec2,  vec2);"
1022             "vec3  mid3(vec3,  vec3,  vec3);"
1023             "vec4  mid3(vec4,  vec4,  vec4);"
1024 
1025             "int   mid3(int,   int,   int);"
1026             "ivec2 mid3(ivec2, ivec2, ivec2);"
1027             "ivec3 mid3(ivec3, ivec3, ivec3);"
1028             "ivec4 mid3(ivec4, ivec4, ivec4);"
1029 
1030             "uint  mid3(uint,  uint,  uint);"
1031             "uvec2 mid3(uvec2, uvec2, uvec2);"
1032             "uvec3 mid3(uvec3, uvec3, uvec3);"
1033             "uvec4 mid3(uvec4, uvec4, uvec4);"
1034 
1035             "float16_t min3(float16_t, float16_t, float16_t);"
1036             "f16vec2   min3(f16vec2,   f16vec2,   f16vec2);"
1037             "f16vec3   min3(f16vec3,   f16vec3,   f16vec3);"
1038             "f16vec4   min3(f16vec4,   f16vec4,   f16vec4);"
1039 
1040             "float16_t max3(float16_t, float16_t, float16_t);"
1041             "f16vec2   max3(f16vec2,   f16vec2,   f16vec2);"
1042             "f16vec3   max3(f16vec3,   f16vec3,   f16vec3);"
1043             "f16vec4   max3(f16vec4,   f16vec4,   f16vec4);"
1044 
1045             "float16_t mid3(float16_t, float16_t, float16_t);"
1046             "f16vec2   mid3(f16vec2,   f16vec2,   f16vec2);"
1047             "f16vec3   mid3(f16vec3,   f16vec3,   f16vec3);"
1048             "f16vec4   mid3(f16vec4,   f16vec4,   f16vec4);"
1049 
1050             "int16_t   min3(int16_t,   int16_t,   int16_t);"
1051             "i16vec2   min3(i16vec2,   i16vec2,   i16vec2);"
1052             "i16vec3   min3(i16vec3,   i16vec3,   i16vec3);"
1053             "i16vec4   min3(i16vec4,   i16vec4,   i16vec4);"
1054 
1055             "int16_t   max3(int16_t,   int16_t,   int16_t);"
1056             "i16vec2   max3(i16vec2,   i16vec2,   i16vec2);"
1057             "i16vec3   max3(i16vec3,   i16vec3,   i16vec3);"
1058             "i16vec4   max3(i16vec4,   i16vec4,   i16vec4);"
1059 
1060             "int16_t   mid3(int16_t,   int16_t,   int16_t);"
1061             "i16vec2   mid3(i16vec2,   i16vec2,   i16vec2);"
1062             "i16vec3   mid3(i16vec3,   i16vec3,   i16vec3);"
1063             "i16vec4   mid3(i16vec4,   i16vec4,   i16vec4);"
1064 
1065             "uint16_t  min3(uint16_t,  uint16_t,  uint16_t);"
1066             "u16vec2   min3(u16vec2,   u16vec2,   u16vec2);"
1067             "u16vec3   min3(u16vec3,   u16vec3,   u16vec3);"
1068             "u16vec4   min3(u16vec4,   u16vec4,   u16vec4);"
1069 
1070             "uint16_t  max3(uint16_t,  uint16_t,  uint16_t);"
1071             "u16vec2   max3(u16vec2,   u16vec2,   u16vec2);"
1072             "u16vec3   max3(u16vec3,   u16vec3,   u16vec3);"
1073             "u16vec4   max3(u16vec4,   u16vec4,   u16vec4);"
1074 
1075             "uint16_t  mid3(uint16_t,  uint16_t,  uint16_t);"
1076             "u16vec2   mid3(u16vec2,   u16vec2,   u16vec2);"
1077             "u16vec3   mid3(u16vec3,   u16vec3,   u16vec3);"
1078             "u16vec4   mid3(u16vec4,   u16vec4,   u16vec4);"
1079 
1080             "\n"
1081         );
1082     }
1083 #endif
1084 
1085     if ((profile == EEsProfile && version >= 310) ||
1086         (profile != EEsProfile && version >= 430)) {
1087         commonBuiltins.append(
1088             "uint atomicAdd(coherent volatile inout uint, uint);"
1089             " int atomicAdd(coherent volatile inout  int,  int);"
1090             "uint atomicAdd(coherent volatile inout uint, uint, int, int, int);"
1091             " int atomicAdd(coherent volatile inout  int,  int, int, int, int);"
1092 
1093             "uint atomicMin(coherent volatile inout uint, uint);"
1094             " int atomicMin(coherent volatile inout  int,  int);"
1095             "uint atomicMin(coherent volatile inout uint, uint, int, int, int);"
1096             " int atomicMin(coherent volatile inout  int,  int, int, int, int);"
1097 
1098             "uint atomicMax(coherent volatile inout uint, uint);"
1099             " int atomicMax(coherent volatile inout  int,  int);"
1100             "uint atomicMax(coherent volatile inout uint, uint, int, int, int);"
1101             " int atomicMax(coherent volatile inout  int,  int, int, int, int);"
1102 
1103             "uint atomicAnd(coherent volatile inout uint, uint);"
1104             " int atomicAnd(coherent volatile inout  int,  int);"
1105             "uint atomicAnd(coherent volatile inout uint, uint, int, int, int);"
1106             " int atomicAnd(coherent volatile inout  int,  int, int, int, int);"
1107 
1108             "uint atomicOr (coherent volatile inout uint, uint);"
1109             " int atomicOr (coherent volatile inout  int,  int);"
1110             "uint atomicOr (coherent volatile inout uint, uint, int, int, int);"
1111             " int atomicOr (coherent volatile inout  int,  int, int, int, int);"
1112 
1113             "uint atomicXor(coherent volatile inout uint, uint);"
1114             " int atomicXor(coherent volatile inout  int,  int);"
1115             "uint atomicXor(coherent volatile inout uint, uint, int, int, int);"
1116             " int atomicXor(coherent volatile inout  int,  int, int, int, int);"
1117 
1118             "uint atomicExchange(coherent volatile inout uint, uint);"
1119             " int atomicExchange(coherent volatile inout  int,  int);"
1120             "uint atomicExchange(coherent volatile inout uint, uint, int, int, int);"
1121             " int atomicExchange(coherent volatile inout  int,  int, int, int, int);"
1122 
1123             "uint atomicCompSwap(coherent volatile inout uint, uint, uint);"
1124             " int atomicCompSwap(coherent volatile inout  int,  int,  int);"
1125             "uint atomicCompSwap(coherent volatile inout uint, uint, uint, int, int, int, int, int);"
1126             " int atomicCompSwap(coherent volatile inout  int,  int,  int, int, int, int, int, int);"
1127 
1128             "uint atomicLoad(coherent volatile in uint, int, int, int);"
1129             " int atomicLoad(coherent volatile in  int, int, int, int);"
1130 
1131             "void atomicStore(coherent volatile out uint, uint, int, int, int);"
1132             "void atomicStore(coherent volatile out  int,  int, int, int, int);"
1133 
1134             "\n");
1135     }
1136 
1137     if (profile != EEsProfile && version >= 440) {
1138         commonBuiltins.append(
1139             "uint64_t atomicMin(coherent volatile inout uint64_t, uint64_t);"
1140             " int64_t atomicMin(coherent volatile inout  int64_t,  int64_t);"
1141             "uint64_t atomicMin(coherent volatile inout uint64_t, uint64_t, int, int, int);"
1142             " int64_t atomicMin(coherent volatile inout  int64_t,  int64_t, int, int, int);"
1143 
1144             "uint64_t atomicMax(coherent volatile inout uint64_t, uint64_t);"
1145             " int64_t atomicMax(coherent volatile inout  int64_t,  int64_t);"
1146             "uint64_t atomicMax(coherent volatile inout uint64_t, uint64_t, int, int, int);"
1147             " int64_t atomicMax(coherent volatile inout  int64_t,  int64_t, int, int, int);"
1148 
1149             "uint64_t atomicAnd(coherent volatile inout uint64_t, uint64_t);"
1150             " int64_t atomicAnd(coherent volatile inout  int64_t,  int64_t);"
1151             "uint64_t atomicAnd(coherent volatile inout uint64_t, uint64_t, int, int, int);"
1152             " int64_t atomicAnd(coherent volatile inout  int64_t,  int64_t, int, int, int);"
1153 
1154             "uint64_t atomicOr (coherent volatile inout uint64_t, uint64_t);"
1155             " int64_t atomicOr (coherent volatile inout  int64_t,  int64_t);"
1156             "uint64_t atomicOr (coherent volatile inout uint64_t, uint64_t, int, int, int);"
1157             " int64_t atomicOr (coherent volatile inout  int64_t,  int64_t, int, int, int);"
1158 
1159             "uint64_t atomicXor(coherent volatile inout uint64_t, uint64_t);"
1160             " int64_t atomicXor(coherent volatile inout  int64_t,  int64_t);"
1161             "uint64_t atomicXor(coherent volatile inout uint64_t, uint64_t, int, int, int);"
1162             " int64_t atomicXor(coherent volatile inout  int64_t,  int64_t, int, int, int);"
1163 
1164             "uint64_t atomicAdd(coherent volatile inout uint64_t, uint64_t);"
1165             " int64_t atomicAdd(coherent volatile inout  int64_t,  int64_t);"
1166             "uint64_t atomicAdd(coherent volatile inout uint64_t, uint64_t, int, int, int);"
1167             " int64_t atomicAdd(coherent volatile inout  int64_t,  int64_t, int, int, int);"
1168 
1169             "uint64_t atomicExchange(coherent volatile inout uint64_t, uint64_t);"
1170             " int64_t atomicExchange(coherent volatile inout  int64_t,  int64_t);"
1171             "uint64_t atomicExchange(coherent volatile inout uint64_t, uint64_t, int, int, int);"
1172             " int64_t atomicExchange(coherent volatile inout  int64_t,  int64_t, int, int, int);"
1173 
1174             "uint64_t atomicCompSwap(coherent volatile inout uint64_t, uint64_t, uint64_t);"
1175             " int64_t atomicCompSwap(coherent volatile inout  int64_t,  int64_t,  int64_t);"
1176             "uint64_t atomicCompSwap(coherent volatile inout uint64_t, uint64_t, uint64_t, int, int, int, int, int);"
1177             " int64_t atomicCompSwap(coherent volatile inout  int64_t,  int64_t,  int64_t, int, int, int, int, int);"
1178 
1179             "uint64_t atomicLoad(coherent volatile in uint64_t, int, int, int);"
1180             " int64_t atomicLoad(coherent volatile in  int64_t, int, int, int);"
1181 
1182             "void atomicStore(coherent volatile out uint64_t, uint64_t, int, int, int);"
1183             "void atomicStore(coherent volatile out  int64_t,  int64_t, int, int, int);"
1184             "\n");
1185     }
1186 
1187     if ((profile == EEsProfile && version >= 310) ||
1188         (profile != EEsProfile && version >= 450)) {
1189         commonBuiltins.append(
1190             "int    mix(int    x, int    y, bool  a);"
1191             "ivec2  mix(ivec2  x, ivec2  y, bvec2 a);"
1192             "ivec3  mix(ivec3  x, ivec3  y, bvec3 a);"
1193             "ivec4  mix(ivec4  x, ivec4  y, bvec4 a);"
1194 
1195             "uint   mix(uint   x, uint   y, bool  a);"
1196             "uvec2  mix(uvec2  x, uvec2  y, bvec2 a);"
1197             "uvec3  mix(uvec3  x, uvec3  y, bvec3 a);"
1198             "uvec4  mix(uvec4  x, uvec4  y, bvec4 a);"
1199 
1200             "bool   mix(bool   x, bool   y, bool  a);"
1201             "bvec2  mix(bvec2  x, bvec2  y, bvec2 a);"
1202             "bvec3  mix(bvec3  x, bvec3  y, bvec3 a);"
1203             "bvec4  mix(bvec4  x, bvec4  y, bvec4 a);"
1204 
1205             "\n");
1206     }
1207 
1208     if ((profile == EEsProfile && version >= 300) ||
1209         (profile != EEsProfile && version >= 330)) {
1210         commonBuiltins.append(
1211             "int   floatBitsToInt(highp float value);"
1212             "ivec2 floatBitsToInt(highp vec2  value);"
1213             "ivec3 floatBitsToInt(highp vec3  value);"
1214             "ivec4 floatBitsToInt(highp vec4  value);"
1215 
1216             "uint  floatBitsToUint(highp float value);"
1217             "uvec2 floatBitsToUint(highp vec2  value);"
1218             "uvec3 floatBitsToUint(highp vec3  value);"
1219             "uvec4 floatBitsToUint(highp vec4  value);"
1220 
1221             "float intBitsToFloat(highp int   value);"
1222             "vec2  intBitsToFloat(highp ivec2 value);"
1223             "vec3  intBitsToFloat(highp ivec3 value);"
1224             "vec4  intBitsToFloat(highp ivec4 value);"
1225 
1226             "float uintBitsToFloat(highp uint  value);"
1227             "vec2  uintBitsToFloat(highp uvec2 value);"
1228             "vec3  uintBitsToFloat(highp uvec3 value);"
1229             "vec4  uintBitsToFloat(highp uvec4 value);"
1230 
1231             "\n");
1232     }
1233 
1234     if ((profile != EEsProfile && version >= 400) ||
1235         (profile == EEsProfile && version >= 310)) {    // GL_OES_gpu_shader5
1236 
1237         commonBuiltins.append(
1238             "float  fma(float,  float,  float );"
1239             "vec2   fma(vec2,   vec2,   vec2  );"
1240             "vec3   fma(vec3,   vec3,   vec3  );"
1241             "vec4   fma(vec4,   vec4,   vec4  );"
1242             "\n");
1243 
1244         if (profile != EEsProfile) {
1245             commonBuiltins.append(
1246                 "double fma(double, double, double);"
1247                 "dvec2  fma(dvec2,  dvec2,  dvec2 );"
1248                 "dvec3  fma(dvec3,  dvec3,  dvec3 );"
1249                 "dvec4  fma(dvec4,  dvec4,  dvec4 );"
1250                 "\n");
1251         }
1252     }
1253 
1254     if ((profile == EEsProfile && version >= 310) ||
1255         (profile != EEsProfile && version >= 400)) {
1256         commonBuiltins.append(
1257             "float frexp(highp float, out highp int);"
1258             "vec2  frexp(highp vec2,  out highp ivec2);"
1259             "vec3  frexp(highp vec3,  out highp ivec3);"
1260             "vec4  frexp(highp vec4,  out highp ivec4);"
1261 
1262             "float ldexp(highp float, highp int);"
1263             "vec2  ldexp(highp vec2,  highp ivec2);"
1264             "vec3  ldexp(highp vec3,  highp ivec3);"
1265             "vec4  ldexp(highp vec4,  highp ivec4);"
1266 
1267             "\n");
1268     }
1269 
1270     if (profile != EEsProfile && version >= 400) {
1271         commonBuiltins.append(
1272             "double frexp(double, out int);"
1273             "dvec2  frexp( dvec2, out ivec2);"
1274             "dvec3  frexp( dvec3, out ivec3);"
1275             "dvec4  frexp( dvec4, out ivec4);"
1276 
1277             "double ldexp(double, int);"
1278             "dvec2  ldexp( dvec2, ivec2);"
1279             "dvec3  ldexp( dvec3, ivec3);"
1280             "dvec4  ldexp( dvec4, ivec4);"
1281 
1282             "double packDouble2x32(uvec2);"
1283             "uvec2 unpackDouble2x32(double);"
1284 
1285             "\n");
1286     }
1287 
1288     if ((profile == EEsProfile && version >= 300) ||
1289         (profile != EEsProfile && version >= 400)) {
1290         commonBuiltins.append(
1291             "highp uint packUnorm2x16(vec2);"
1292                   "vec2 unpackUnorm2x16(highp uint);"
1293             "\n");
1294     }
1295 
1296     if ((profile == EEsProfile && version >= 300) ||
1297         (profile != EEsProfile && version >= 420)) {
1298         commonBuiltins.append(
1299             "highp uint packSnorm2x16(vec2);"
1300             "      vec2 unpackSnorm2x16(highp uint);"
1301             "highp uint packHalf2x16(vec2);"
1302             "\n");
1303     }
1304 
1305     if (profile == EEsProfile && version >= 300) {
1306         commonBuiltins.append(
1307             "mediump vec2 unpackHalf2x16(highp uint);"
1308             "\n");
1309     } else if (profile != EEsProfile && version >= 420) {
1310         commonBuiltins.append(
1311             "        vec2 unpackHalf2x16(highp uint);"
1312             "\n");
1313     }
1314 
1315     if ((profile == EEsProfile && version >= 310) ||
1316         (profile != EEsProfile && version >= 400)) {
1317         commonBuiltins.append(
1318             "highp uint packSnorm4x8(vec4);"
1319             "highp uint packUnorm4x8(vec4);"
1320             "\n");
1321     }
1322 
1323     if (profile == EEsProfile && version >= 310) {
1324         commonBuiltins.append(
1325             "mediump vec4 unpackSnorm4x8(highp uint);"
1326             "mediump vec4 unpackUnorm4x8(highp uint);"
1327             "\n");
1328     } else if (profile != EEsProfile && version >= 400) {
1329         commonBuiltins.append(
1330                     "vec4 unpackSnorm4x8(highp uint);"
1331                     "vec4 unpackUnorm4x8(highp uint);"
1332             "\n");
1333     }
1334 
1335     //
1336     // Geometric Functions.
1337     //
1338     commonBuiltins.append(
1339         "float length(float x);"
1340         "float length(vec2  x);"
1341         "float length(vec3  x);"
1342         "float length(vec4  x);"
1343 
1344         "float distance(float p0, float p1);"
1345         "float distance(vec2  p0, vec2  p1);"
1346         "float distance(vec3  p0, vec3  p1);"
1347         "float distance(vec4  p0, vec4  p1);"
1348 
1349         "float dot(float x, float y);"
1350         "float dot(vec2  x, vec2  y);"
1351         "float dot(vec3  x, vec3  y);"
1352         "float dot(vec4  x, vec4  y);"
1353 
1354         "vec3 cross(vec3 x, vec3 y);"
1355         "float normalize(float x);"
1356         "vec2  normalize(vec2  x);"
1357         "vec3  normalize(vec3  x);"
1358         "vec4  normalize(vec4  x);"
1359 
1360         "float faceforward(float N, float I, float Nref);"
1361         "vec2  faceforward(vec2  N, vec2  I, vec2  Nref);"
1362         "vec3  faceforward(vec3  N, vec3  I, vec3  Nref);"
1363         "vec4  faceforward(vec4  N, vec4  I, vec4  Nref);"
1364 
1365         "float reflect(float I, float N);"
1366         "vec2  reflect(vec2  I, vec2  N);"
1367         "vec3  reflect(vec3  I, vec3  N);"
1368         "vec4  reflect(vec4  I, vec4  N);"
1369 
1370         "float refract(float I, float N, float eta);"
1371         "vec2  refract(vec2  I, vec2  N, float eta);"
1372         "vec3  refract(vec3  I, vec3  N, float eta);"
1373         "vec4  refract(vec4  I, vec4  N, float eta);"
1374 
1375         "\n");
1376 
1377     //
1378     // Matrix Functions.
1379     //
1380     commonBuiltins.append(
1381         "mat2 matrixCompMult(mat2 x, mat2 y);"
1382         "mat3 matrixCompMult(mat3 x, mat3 y);"
1383         "mat4 matrixCompMult(mat4 x, mat4 y);"
1384 
1385         "\n");
1386 
1387     // 120 is correct for both ES and desktop
1388     if (version >= 120) {
1389         commonBuiltins.append(
1390             "mat2   outerProduct(vec2 c, vec2 r);"
1391             "mat3   outerProduct(vec3 c, vec3 r);"
1392             "mat4   outerProduct(vec4 c, vec4 r);"
1393             "mat2x3 outerProduct(vec3 c, vec2 r);"
1394             "mat3x2 outerProduct(vec2 c, vec3 r);"
1395             "mat2x4 outerProduct(vec4 c, vec2 r);"
1396             "mat4x2 outerProduct(vec2 c, vec4 r);"
1397             "mat3x4 outerProduct(vec4 c, vec3 r);"
1398             "mat4x3 outerProduct(vec3 c, vec4 r);"
1399 
1400             "mat2   transpose(mat2   m);"
1401             "mat3   transpose(mat3   m);"
1402             "mat4   transpose(mat4   m);"
1403             "mat2x3 transpose(mat3x2 m);"
1404             "mat3x2 transpose(mat2x3 m);"
1405             "mat2x4 transpose(mat4x2 m);"
1406             "mat4x2 transpose(mat2x4 m);"
1407             "mat3x4 transpose(mat4x3 m);"
1408             "mat4x3 transpose(mat3x4 m);"
1409 
1410             "mat2x3 matrixCompMult(mat2x3, mat2x3);"
1411             "mat2x4 matrixCompMult(mat2x4, mat2x4);"
1412             "mat3x2 matrixCompMult(mat3x2, mat3x2);"
1413             "mat3x4 matrixCompMult(mat3x4, mat3x4);"
1414             "mat4x2 matrixCompMult(mat4x2, mat4x2);"
1415             "mat4x3 matrixCompMult(mat4x3, mat4x3);"
1416 
1417             "\n");
1418 
1419         // 150 is correct for both ES and desktop
1420         if (version >= 150) {
1421             commonBuiltins.append(
1422                 "float determinant(mat2 m);"
1423                 "float determinant(mat3 m);"
1424                 "float determinant(mat4 m);"
1425 
1426                 "mat2 inverse(mat2 m);"
1427                 "mat3 inverse(mat3 m);"
1428                 "mat4 inverse(mat4 m);"
1429 
1430                 "\n");
1431         }
1432     }
1433 
1434     //
1435     // Vector relational functions.
1436     //
1437     commonBuiltins.append(
1438         "bvec2 lessThan(vec2 x, vec2 y);"
1439         "bvec3 lessThan(vec3 x, vec3 y);"
1440         "bvec4 lessThan(vec4 x, vec4 y);"
1441 
1442         "bvec2 lessThan(ivec2 x, ivec2 y);"
1443         "bvec3 lessThan(ivec3 x, ivec3 y);"
1444         "bvec4 lessThan(ivec4 x, ivec4 y);"
1445 
1446         "bvec2 lessThanEqual(vec2 x, vec2 y);"
1447         "bvec3 lessThanEqual(vec3 x, vec3 y);"
1448         "bvec4 lessThanEqual(vec4 x, vec4 y);"
1449 
1450         "bvec2 lessThanEqual(ivec2 x, ivec2 y);"
1451         "bvec3 lessThanEqual(ivec3 x, ivec3 y);"
1452         "bvec4 lessThanEqual(ivec4 x, ivec4 y);"
1453 
1454         "bvec2 greaterThan(vec2 x, vec2 y);"
1455         "bvec3 greaterThan(vec3 x, vec3 y);"
1456         "bvec4 greaterThan(vec4 x, vec4 y);"
1457 
1458         "bvec2 greaterThan(ivec2 x, ivec2 y);"
1459         "bvec3 greaterThan(ivec3 x, ivec3 y);"
1460         "bvec4 greaterThan(ivec4 x, ivec4 y);"
1461 
1462         "bvec2 greaterThanEqual(vec2 x, vec2 y);"
1463         "bvec3 greaterThanEqual(vec3 x, vec3 y);"
1464         "bvec4 greaterThanEqual(vec4 x, vec4 y);"
1465 
1466         "bvec2 greaterThanEqual(ivec2 x, ivec2 y);"
1467         "bvec3 greaterThanEqual(ivec3 x, ivec3 y);"
1468         "bvec4 greaterThanEqual(ivec4 x, ivec4 y);"
1469 
1470         "bvec2 equal(vec2 x, vec2 y);"
1471         "bvec3 equal(vec3 x, vec3 y);"
1472         "bvec4 equal(vec4 x, vec4 y);"
1473 
1474         "bvec2 equal(ivec2 x, ivec2 y);"
1475         "bvec3 equal(ivec3 x, ivec3 y);"
1476         "bvec4 equal(ivec4 x, ivec4 y);"
1477 
1478         "bvec2 equal(bvec2 x, bvec2 y);"
1479         "bvec3 equal(bvec3 x, bvec3 y);"
1480         "bvec4 equal(bvec4 x, bvec4 y);"
1481 
1482         "bvec2 notEqual(vec2 x, vec2 y);"
1483         "bvec3 notEqual(vec3 x, vec3 y);"
1484         "bvec4 notEqual(vec4 x, vec4 y);"
1485 
1486         "bvec2 notEqual(ivec2 x, ivec2 y);"
1487         "bvec3 notEqual(ivec3 x, ivec3 y);"
1488         "bvec4 notEqual(ivec4 x, ivec4 y);"
1489 
1490         "bvec2 notEqual(bvec2 x, bvec2 y);"
1491         "bvec3 notEqual(bvec3 x, bvec3 y);"
1492         "bvec4 notEqual(bvec4 x, bvec4 y);"
1493 
1494         "bool any(bvec2 x);"
1495         "bool any(bvec3 x);"
1496         "bool any(bvec4 x);"
1497 
1498         "bool all(bvec2 x);"
1499         "bool all(bvec3 x);"
1500         "bool all(bvec4 x);"
1501 
1502         "bvec2 not(bvec2 x);"
1503         "bvec3 not(bvec3 x);"
1504         "bvec4 not(bvec4 x);"
1505 
1506         "\n");
1507 
1508     if (version >= 130) {
1509         commonBuiltins.append(
1510             "bvec2 lessThan(uvec2 x, uvec2 y);"
1511             "bvec3 lessThan(uvec3 x, uvec3 y);"
1512             "bvec4 lessThan(uvec4 x, uvec4 y);"
1513 
1514             "bvec2 lessThanEqual(uvec2 x, uvec2 y);"
1515             "bvec3 lessThanEqual(uvec3 x, uvec3 y);"
1516             "bvec4 lessThanEqual(uvec4 x, uvec4 y);"
1517 
1518             "bvec2 greaterThan(uvec2 x, uvec2 y);"
1519             "bvec3 greaterThan(uvec3 x, uvec3 y);"
1520             "bvec4 greaterThan(uvec4 x, uvec4 y);"
1521 
1522             "bvec2 greaterThanEqual(uvec2 x, uvec2 y);"
1523             "bvec3 greaterThanEqual(uvec3 x, uvec3 y);"
1524             "bvec4 greaterThanEqual(uvec4 x, uvec4 y);"
1525 
1526             "bvec2 equal(uvec2 x, uvec2 y);"
1527             "bvec3 equal(uvec3 x, uvec3 y);"
1528             "bvec4 equal(uvec4 x, uvec4 y);"
1529 
1530             "bvec2 notEqual(uvec2 x, uvec2 y);"
1531             "bvec3 notEqual(uvec3 x, uvec3 y);"
1532             "bvec4 notEqual(uvec4 x, uvec4 y);"
1533 
1534             "\n");
1535     }
1536 
1537     //
1538     // Original-style texture functions existing in all stages.
1539     // (Per-stage functions below.)
1540     //
1541     if ((profile == EEsProfile && version == 100) ||
1542          profile == ECompatibilityProfile ||
1543         (profile == ECoreProfile && version < 420) ||
1544          profile == ENoProfile) {
1545         if (spvVersion.spv == 0) {
1546             commonBuiltins.append(
1547                 "vec4 texture2D(sampler2D, vec2);"
1548 
1549                 "vec4 texture2DProj(sampler2D, vec3);"
1550                 "vec4 texture2DProj(sampler2D, vec4);"
1551 
1552                 "vec4 texture3D(sampler3D, vec3);"     // OES_texture_3D, but caught by keyword check
1553                 "vec4 texture3DProj(sampler3D, vec4);" // OES_texture_3D, but caught by keyword check
1554 
1555                 "vec4 textureCube(samplerCube, vec3);"
1556 
1557                 "\n");
1558         }
1559     }
1560 
1561     if ( profile == ECompatibilityProfile ||
1562         (profile == ECoreProfile && version < 420) ||
1563          profile == ENoProfile) {
1564         if (spvVersion.spv == 0) {
1565             commonBuiltins.append(
1566                 "vec4 texture1D(sampler1D, float);"
1567 
1568                 "vec4 texture1DProj(sampler1D, vec2);"
1569                 "vec4 texture1DProj(sampler1D, vec4);"
1570 
1571                 "vec4 shadow1D(sampler1DShadow, vec3);"
1572                 "vec4 shadow2D(sampler2DShadow, vec3);"
1573                 "vec4 shadow1DProj(sampler1DShadow, vec4);"
1574                 "vec4 shadow2DProj(sampler2DShadow, vec4);"
1575 
1576                 "vec4 texture2DRect(sampler2DRect, vec2);"          // GL_ARB_texture_rectangle, caught by keyword check
1577                 "vec4 texture2DRectProj(sampler2DRect, vec3);"      // GL_ARB_texture_rectangle, caught by keyword check
1578                 "vec4 texture2DRectProj(sampler2DRect, vec4);"      // GL_ARB_texture_rectangle, caught by keyword check
1579                 "vec4 shadow2DRect(sampler2DRectShadow, vec3);"     // GL_ARB_texture_rectangle, caught by keyword check
1580                 "vec4 shadow2DRectProj(sampler2DRectShadow, vec4);" // GL_ARB_texture_rectangle, caught by keyword check
1581 
1582                 "\n");
1583         }
1584     }
1585 
1586     if (profile == EEsProfile) {
1587         if (spvVersion.spv == 0) {
1588             if (version < 300) {
1589                 commonBuiltins.append(
1590                     "vec4 texture2D(samplerExternalOES, vec2 coord);" // GL_OES_EGL_image_external
1591                     "vec4 texture2DProj(samplerExternalOES, vec3);"   // GL_OES_EGL_image_external
1592                     "vec4 texture2DProj(samplerExternalOES, vec4);"   // GL_OES_EGL_image_external
1593                 "\n");
1594             } else {
1595                 commonBuiltins.append(
1596                     "highp ivec2 textureSize(samplerExternalOES, int lod);"   // GL_OES_EGL_image_external_essl3
1597                     "vec4 texture(samplerExternalOES, vec2);"                 // GL_OES_EGL_image_external_essl3
1598                     "vec4 texture(samplerExternalOES, vec2, float bias);"     // GL_OES_EGL_image_external_essl3
1599                     "vec4 textureProj(samplerExternalOES, vec3);"             // GL_OES_EGL_image_external_essl3
1600                     "vec4 textureProj(samplerExternalOES, vec3, float bias);" // GL_OES_EGL_image_external_essl3
1601                     "vec4 textureProj(samplerExternalOES, vec4);"             // GL_OES_EGL_image_external_essl3
1602                     "vec4 textureProj(samplerExternalOES, vec4, float bias);" // GL_OES_EGL_image_external_essl3
1603                     "vec4 texelFetch(samplerExternalOES, ivec2, int lod);"    // GL_OES_EGL_image_external_essl3
1604                 "\n");
1605             }
1606             commonBuiltins.append(
1607                 "vec4 texture2DGradEXT(sampler2D, vec2, vec2, vec2);"      // GL_EXT_shader_texture_lod
1608                 "vec4 texture2DProjGradEXT(sampler2D, vec3, vec2, vec2);"  // GL_EXT_shader_texture_lod
1609                 "vec4 texture2DProjGradEXT(sampler2D, vec4, vec2, vec2);"  // GL_EXT_shader_texture_lod
1610                 "vec4 textureCubeGradEXT(samplerCube, vec3, vec3, vec3);"  // GL_EXT_shader_texture_lod
1611 
1612                 "float shadow2DEXT(sampler2DShadow, vec3);"     // GL_EXT_shadow_samplers
1613                 "float shadow2DProjEXT(sampler2DShadow, vec4);" // GL_EXT_shadow_samplers
1614 
1615                 "\n");
1616         }
1617     }
1618 
1619     //
1620     // Noise functions.
1621     //
1622     if (spvVersion.spv == 0 && profile != EEsProfile) {
1623         commonBuiltins.append(
1624             "float noise1(float x);"
1625             "float noise1(vec2  x);"
1626             "float noise1(vec3  x);"
1627             "float noise1(vec4  x);"
1628 
1629             "vec2 noise2(float x);"
1630             "vec2 noise2(vec2  x);"
1631             "vec2 noise2(vec3  x);"
1632             "vec2 noise2(vec4  x);"
1633 
1634             "vec3 noise3(float x);"
1635             "vec3 noise3(vec2  x);"
1636             "vec3 noise3(vec3  x);"
1637             "vec3 noise3(vec4  x);"
1638 
1639             "vec4 noise4(float x);"
1640             "vec4 noise4(vec2  x);"
1641             "vec4 noise4(vec3  x);"
1642             "vec4 noise4(vec4  x);"
1643 
1644             "\n");
1645     }
1646 
1647     if (spvVersion.vulkan == 0) {
1648         //
1649         // Atomic counter functions.
1650         //
1651         if ((profile != EEsProfile && version >= 300) ||
1652             (profile == EEsProfile && version >= 310)) {
1653             commonBuiltins.append(
1654                 "uint atomicCounterIncrement(atomic_uint);"
1655                 "uint atomicCounterDecrement(atomic_uint);"
1656                 "uint atomicCounter(atomic_uint);"
1657 
1658                 "\n");
1659         }
1660         if (profile != EEsProfile && version >= 460) {
1661             commonBuiltins.append(
1662                 "uint atomicCounterAdd(atomic_uint, uint);"
1663                 "uint atomicCounterSubtract(atomic_uint, uint);"
1664                 "uint atomicCounterMin(atomic_uint, uint);"
1665                 "uint atomicCounterMax(atomic_uint, uint);"
1666                 "uint atomicCounterAnd(atomic_uint, uint);"
1667                 "uint atomicCounterOr(atomic_uint, uint);"
1668                 "uint atomicCounterXor(atomic_uint, uint);"
1669                 "uint atomicCounterExchange(atomic_uint, uint);"
1670                 "uint atomicCounterCompSwap(atomic_uint, uint, uint);"
1671 
1672                 "\n");
1673         }
1674     }
1675 
1676     // Bitfield
1677     if ((profile == EEsProfile && version >= 310) ||
1678         (profile != EEsProfile && version >= 400)) {
1679         commonBuiltins.append(
1680             "  int bitfieldExtract(  int, int, int);"
1681             "ivec2 bitfieldExtract(ivec2, int, int);"
1682             "ivec3 bitfieldExtract(ivec3, int, int);"
1683             "ivec4 bitfieldExtract(ivec4, int, int);"
1684 
1685             " uint bitfieldExtract( uint, int, int);"
1686             "uvec2 bitfieldExtract(uvec2, int, int);"
1687             "uvec3 bitfieldExtract(uvec3, int, int);"
1688             "uvec4 bitfieldExtract(uvec4, int, int);"
1689 
1690             "  int bitfieldInsert(  int base,   int, int, int);"
1691             "ivec2 bitfieldInsert(ivec2 base, ivec2, int, int);"
1692             "ivec3 bitfieldInsert(ivec3 base, ivec3, int, int);"
1693             "ivec4 bitfieldInsert(ivec4 base, ivec4, int, int);"
1694 
1695             " uint bitfieldInsert( uint base,  uint, int, int);"
1696             "uvec2 bitfieldInsert(uvec2 base, uvec2, int, int);"
1697             "uvec3 bitfieldInsert(uvec3 base, uvec3, int, int);"
1698             "uvec4 bitfieldInsert(uvec4 base, uvec4, int, int);"
1699 
1700             "\n");
1701     }
1702 
1703     if (profile != EEsProfile && version >= 400) {
1704         commonBuiltins.append(
1705             "  int findLSB(  int);"
1706             "ivec2 findLSB(ivec2);"
1707             "ivec3 findLSB(ivec3);"
1708             "ivec4 findLSB(ivec4);"
1709 
1710             "  int findLSB( uint);"
1711             "ivec2 findLSB(uvec2);"
1712             "ivec3 findLSB(uvec3);"
1713             "ivec4 findLSB(uvec4);"
1714 
1715             "\n");
1716     } else if (profile == EEsProfile && version >= 310) {
1717         commonBuiltins.append(
1718             "lowp   int findLSB(  int);"
1719             "lowp ivec2 findLSB(ivec2);"
1720             "lowp ivec3 findLSB(ivec3);"
1721             "lowp ivec4 findLSB(ivec4);"
1722 
1723             "lowp   int findLSB( uint);"
1724             "lowp ivec2 findLSB(uvec2);"
1725             "lowp ivec3 findLSB(uvec3);"
1726             "lowp ivec4 findLSB(uvec4);"
1727 
1728             "\n");
1729     }
1730 
1731     if (profile != EEsProfile && version >= 400) {
1732         commonBuiltins.append(
1733             "  int bitCount(  int);"
1734             "ivec2 bitCount(ivec2);"
1735             "ivec3 bitCount(ivec3);"
1736             "ivec4 bitCount(ivec4);"
1737 
1738             "  int bitCount( uint);"
1739             "ivec2 bitCount(uvec2);"
1740             "ivec3 bitCount(uvec3);"
1741             "ivec4 bitCount(uvec4);"
1742 
1743             "  int findMSB(highp   int);"
1744             "ivec2 findMSB(highp ivec2);"
1745             "ivec3 findMSB(highp ivec3);"
1746             "ivec4 findMSB(highp ivec4);"
1747 
1748             "  int findMSB(highp  uint);"
1749             "ivec2 findMSB(highp uvec2);"
1750             "ivec3 findMSB(highp uvec3);"
1751             "ivec4 findMSB(highp uvec4);"
1752 
1753             "\n");
1754     }
1755 
1756     if ((profile == EEsProfile && version >= 310) ||
1757         (profile != EEsProfile && version >= 400)) {
1758         commonBuiltins.append(
1759             " uint uaddCarry(highp  uint, highp  uint, out lowp  uint carry);"
1760             "uvec2 uaddCarry(highp uvec2, highp uvec2, out lowp uvec2 carry);"
1761             "uvec3 uaddCarry(highp uvec3, highp uvec3, out lowp uvec3 carry);"
1762             "uvec4 uaddCarry(highp uvec4, highp uvec4, out lowp uvec4 carry);"
1763 
1764             " uint usubBorrow(highp  uint, highp  uint, out lowp  uint borrow);"
1765             "uvec2 usubBorrow(highp uvec2, highp uvec2, out lowp uvec2 borrow);"
1766             "uvec3 usubBorrow(highp uvec3, highp uvec3, out lowp uvec3 borrow);"
1767             "uvec4 usubBorrow(highp uvec4, highp uvec4, out lowp uvec4 borrow);"
1768 
1769             "void umulExtended(highp  uint, highp  uint, out highp  uint, out highp  uint lsb);"
1770             "void umulExtended(highp uvec2, highp uvec2, out highp uvec2, out highp uvec2 lsb);"
1771             "void umulExtended(highp uvec3, highp uvec3, out highp uvec3, out highp uvec3 lsb);"
1772             "void umulExtended(highp uvec4, highp uvec4, out highp uvec4, out highp uvec4 lsb);"
1773 
1774             "void imulExtended(highp   int, highp   int, out highp   int, out highp   int lsb);"
1775             "void imulExtended(highp ivec2, highp ivec2, out highp ivec2, out highp ivec2 lsb);"
1776             "void imulExtended(highp ivec3, highp ivec3, out highp ivec3, out highp ivec3 lsb);"
1777             "void imulExtended(highp ivec4, highp ivec4, out highp ivec4, out highp ivec4 lsb);"
1778 
1779             "  int bitfieldReverse(highp   int);"
1780             "ivec2 bitfieldReverse(highp ivec2);"
1781             "ivec3 bitfieldReverse(highp ivec3);"
1782             "ivec4 bitfieldReverse(highp ivec4);"
1783 
1784             " uint bitfieldReverse(highp  uint);"
1785             "uvec2 bitfieldReverse(highp uvec2);"
1786             "uvec3 bitfieldReverse(highp uvec3);"
1787             "uvec4 bitfieldReverse(highp uvec4);"
1788 
1789             "\n");
1790     }
1791 
1792     if (profile == EEsProfile && version >= 310) {
1793         commonBuiltins.append(
1794             "lowp   int bitCount(  int);"
1795             "lowp ivec2 bitCount(ivec2);"
1796             "lowp ivec3 bitCount(ivec3);"
1797             "lowp ivec4 bitCount(ivec4);"
1798 
1799             "lowp   int bitCount( uint);"
1800             "lowp ivec2 bitCount(uvec2);"
1801             "lowp ivec3 bitCount(uvec3);"
1802             "lowp ivec4 bitCount(uvec4);"
1803 
1804             "lowp   int findMSB(highp   int);"
1805             "lowp ivec2 findMSB(highp ivec2);"
1806             "lowp ivec3 findMSB(highp ivec3);"
1807             "lowp ivec4 findMSB(highp ivec4);"
1808 
1809             "lowp   int findMSB(highp  uint);"
1810             "lowp ivec2 findMSB(highp uvec2);"
1811             "lowp ivec3 findMSB(highp uvec3);"
1812             "lowp ivec4 findMSB(highp uvec4);"
1813 
1814             "\n");
1815     }
1816 
1817     // GL_ARB_shader_ballot
1818     if (profile != EEsProfile && version >= 450) {
1819         commonBuiltins.append(
1820             "uint64_t ballotARB(bool);"
1821 
1822             "float readInvocationARB(float, uint);"
1823             "vec2  readInvocationARB(vec2,  uint);"
1824             "vec3  readInvocationARB(vec3,  uint);"
1825             "vec4  readInvocationARB(vec4,  uint);"
1826 
1827             "int   readInvocationARB(int,   uint);"
1828             "ivec2 readInvocationARB(ivec2, uint);"
1829             "ivec3 readInvocationARB(ivec3, uint);"
1830             "ivec4 readInvocationARB(ivec4, uint);"
1831 
1832             "uint  readInvocationARB(uint,  uint);"
1833             "uvec2 readInvocationARB(uvec2, uint);"
1834             "uvec3 readInvocationARB(uvec3, uint);"
1835             "uvec4 readInvocationARB(uvec4, uint);"
1836 
1837             "float readFirstInvocationARB(float);"
1838             "vec2  readFirstInvocationARB(vec2);"
1839             "vec3  readFirstInvocationARB(vec3);"
1840             "vec4  readFirstInvocationARB(vec4);"
1841 
1842             "int   readFirstInvocationARB(int);"
1843             "ivec2 readFirstInvocationARB(ivec2);"
1844             "ivec3 readFirstInvocationARB(ivec3);"
1845             "ivec4 readFirstInvocationARB(ivec4);"
1846 
1847             "uint  readFirstInvocationARB(uint);"
1848             "uvec2 readFirstInvocationARB(uvec2);"
1849             "uvec3 readFirstInvocationARB(uvec3);"
1850             "uvec4 readFirstInvocationARB(uvec4);"
1851 
1852             "\n");
1853     }
1854 
1855     // GL_ARB_shader_group_vote
1856     if (profile != EEsProfile && version >= 430) {
1857         commonBuiltins.append(
1858             "bool anyInvocationARB(bool);"
1859             "bool allInvocationsARB(bool);"
1860             "bool allInvocationsEqualARB(bool);"
1861 
1862             "\n");
1863     }
1864 
1865     // GL_KHR_shader_subgroup
1866     if (spvVersion.vulkan > 0) {
1867         commonBuiltins.append(
1868             "void subgroupBarrier();"
1869             "void subgroupMemoryBarrier();"
1870             "void subgroupMemoryBarrierBuffer();"
1871             "void subgroupMemoryBarrierImage();"
1872             "bool subgroupElect();"
1873 
1874             "bool   subgroupAll(bool);\n"
1875             "bool   subgroupAny(bool);\n"
1876 
1877             "bool   subgroupAllEqual(float);\n"
1878             "bool   subgroupAllEqual(vec2);\n"
1879             "bool   subgroupAllEqual(vec3);\n"
1880             "bool   subgroupAllEqual(vec4);\n"
1881             "bool   subgroupAllEqual(int);\n"
1882             "bool   subgroupAllEqual(ivec2);\n"
1883             "bool   subgroupAllEqual(ivec3);\n"
1884             "bool   subgroupAllEqual(ivec4);\n"
1885             "bool   subgroupAllEqual(uint);\n"
1886             "bool   subgroupAllEqual(uvec2);\n"
1887             "bool   subgroupAllEqual(uvec3);\n"
1888             "bool   subgroupAllEqual(uvec4);\n"
1889             "bool   subgroupAllEqual(bool);\n"
1890             "bool   subgroupAllEqual(bvec2);\n"
1891             "bool   subgroupAllEqual(bvec3);\n"
1892             "bool   subgroupAllEqual(bvec4);\n"
1893 
1894             "float  subgroupBroadcast(float, uint);\n"
1895             "vec2   subgroupBroadcast(vec2, uint);\n"
1896             "vec3   subgroupBroadcast(vec3, uint);\n"
1897             "vec4   subgroupBroadcast(vec4, uint);\n"
1898             "int    subgroupBroadcast(int, uint);\n"
1899             "ivec2  subgroupBroadcast(ivec2, uint);\n"
1900             "ivec3  subgroupBroadcast(ivec3, uint);\n"
1901             "ivec4  subgroupBroadcast(ivec4, uint);\n"
1902             "uint   subgroupBroadcast(uint, uint);\n"
1903             "uvec2  subgroupBroadcast(uvec2, uint);\n"
1904             "uvec3  subgroupBroadcast(uvec3, uint);\n"
1905             "uvec4  subgroupBroadcast(uvec4, uint);\n"
1906             "bool   subgroupBroadcast(bool, uint);\n"
1907             "bvec2  subgroupBroadcast(bvec2, uint);\n"
1908             "bvec3  subgroupBroadcast(bvec3, uint);\n"
1909             "bvec4  subgroupBroadcast(bvec4, uint);\n"
1910 
1911             "float  subgroupBroadcastFirst(float);\n"
1912             "vec2   subgroupBroadcastFirst(vec2);\n"
1913             "vec3   subgroupBroadcastFirst(vec3);\n"
1914             "vec4   subgroupBroadcastFirst(vec4);\n"
1915             "int    subgroupBroadcastFirst(int);\n"
1916             "ivec2  subgroupBroadcastFirst(ivec2);\n"
1917             "ivec3  subgroupBroadcastFirst(ivec3);\n"
1918             "ivec4  subgroupBroadcastFirst(ivec4);\n"
1919             "uint   subgroupBroadcastFirst(uint);\n"
1920             "uvec2  subgroupBroadcastFirst(uvec2);\n"
1921             "uvec3  subgroupBroadcastFirst(uvec3);\n"
1922             "uvec4  subgroupBroadcastFirst(uvec4);\n"
1923             "bool   subgroupBroadcastFirst(bool);\n"
1924             "bvec2  subgroupBroadcastFirst(bvec2);\n"
1925             "bvec3  subgroupBroadcastFirst(bvec3);\n"
1926             "bvec4  subgroupBroadcastFirst(bvec4);\n"
1927 
1928             "uvec4  subgroupBallot(bool);\n"
1929             "bool   subgroupInverseBallot(uvec4);\n"
1930             "bool   subgroupBallotBitExtract(uvec4, uint);\n"
1931             "uint   subgroupBallotBitCount(uvec4);\n"
1932             "uint   subgroupBallotInclusiveBitCount(uvec4);\n"
1933             "uint   subgroupBallotExclusiveBitCount(uvec4);\n"
1934             "uint   subgroupBallotFindLSB(uvec4);\n"
1935             "uint   subgroupBallotFindMSB(uvec4);\n"
1936 
1937             "float  subgroupShuffle(float, uint);\n"
1938             "vec2   subgroupShuffle(vec2, uint);\n"
1939             "vec3   subgroupShuffle(vec3, uint);\n"
1940             "vec4   subgroupShuffle(vec4, uint);\n"
1941             "int    subgroupShuffle(int, uint);\n"
1942             "ivec2  subgroupShuffle(ivec2, uint);\n"
1943             "ivec3  subgroupShuffle(ivec3, uint);\n"
1944             "ivec4  subgroupShuffle(ivec4, uint);\n"
1945             "uint   subgroupShuffle(uint, uint);\n"
1946             "uvec2  subgroupShuffle(uvec2, uint);\n"
1947             "uvec3  subgroupShuffle(uvec3, uint);\n"
1948             "uvec4  subgroupShuffle(uvec4, uint);\n"
1949             "bool   subgroupShuffle(bool, uint);\n"
1950             "bvec2  subgroupShuffle(bvec2, uint);\n"
1951             "bvec3  subgroupShuffle(bvec3, uint);\n"
1952             "bvec4  subgroupShuffle(bvec4, uint);\n"
1953 
1954             "float  subgroupShuffleXor(float, uint);\n"
1955             "vec2   subgroupShuffleXor(vec2, uint);\n"
1956             "vec3   subgroupShuffleXor(vec3, uint);\n"
1957             "vec4   subgroupShuffleXor(vec4, uint);\n"
1958             "int    subgroupShuffleXor(int, uint);\n"
1959             "ivec2  subgroupShuffleXor(ivec2, uint);\n"
1960             "ivec3  subgroupShuffleXor(ivec3, uint);\n"
1961             "ivec4  subgroupShuffleXor(ivec4, uint);\n"
1962             "uint   subgroupShuffleXor(uint, uint);\n"
1963             "uvec2  subgroupShuffleXor(uvec2, uint);\n"
1964             "uvec3  subgroupShuffleXor(uvec3, uint);\n"
1965             "uvec4  subgroupShuffleXor(uvec4, uint);\n"
1966             "bool   subgroupShuffleXor(bool, uint);\n"
1967             "bvec2  subgroupShuffleXor(bvec2, uint);\n"
1968             "bvec3  subgroupShuffleXor(bvec3, uint);\n"
1969             "bvec4  subgroupShuffleXor(bvec4, uint);\n"
1970 
1971             "float  subgroupShuffleUp(float, uint delta);\n"
1972             "vec2   subgroupShuffleUp(vec2, uint delta);\n"
1973             "vec3   subgroupShuffleUp(vec3, uint delta);\n"
1974             "vec4   subgroupShuffleUp(vec4, uint delta);\n"
1975             "int    subgroupShuffleUp(int, uint delta);\n"
1976             "ivec2  subgroupShuffleUp(ivec2, uint delta);\n"
1977             "ivec3  subgroupShuffleUp(ivec3, uint delta);\n"
1978             "ivec4  subgroupShuffleUp(ivec4, uint delta);\n"
1979             "uint   subgroupShuffleUp(uint, uint delta);\n"
1980             "uvec2  subgroupShuffleUp(uvec2, uint delta);\n"
1981             "uvec3  subgroupShuffleUp(uvec3, uint delta);\n"
1982             "uvec4  subgroupShuffleUp(uvec4, uint delta);\n"
1983             "bool   subgroupShuffleUp(bool, uint delta);\n"
1984             "bvec2  subgroupShuffleUp(bvec2, uint delta);\n"
1985             "bvec3  subgroupShuffleUp(bvec3, uint delta);\n"
1986             "bvec4  subgroupShuffleUp(bvec4, uint delta);\n"
1987 
1988             "float  subgroupShuffleDown(float, uint delta);\n"
1989             "vec2   subgroupShuffleDown(vec2, uint delta);\n"
1990             "vec3   subgroupShuffleDown(vec3, uint delta);\n"
1991             "vec4   subgroupShuffleDown(vec4, uint delta);\n"
1992             "int    subgroupShuffleDown(int, uint delta);\n"
1993             "ivec2  subgroupShuffleDown(ivec2, uint delta);\n"
1994             "ivec3  subgroupShuffleDown(ivec3, uint delta);\n"
1995             "ivec4  subgroupShuffleDown(ivec4, uint delta);\n"
1996             "uint   subgroupShuffleDown(uint, uint delta);\n"
1997             "uvec2  subgroupShuffleDown(uvec2, uint delta);\n"
1998             "uvec3  subgroupShuffleDown(uvec3, uint delta);\n"
1999             "uvec4  subgroupShuffleDown(uvec4, uint delta);\n"
2000             "bool   subgroupShuffleDown(bool, uint delta);\n"
2001             "bvec2  subgroupShuffleDown(bvec2, uint delta);\n"
2002             "bvec3  subgroupShuffleDown(bvec3, uint delta);\n"
2003             "bvec4  subgroupShuffleDown(bvec4, uint delta);\n"
2004 
2005             "float  subgroupAdd(float);\n"
2006             "vec2   subgroupAdd(vec2);\n"
2007             "vec3   subgroupAdd(vec3);\n"
2008             "vec4   subgroupAdd(vec4);\n"
2009             "int    subgroupAdd(int);\n"
2010             "ivec2  subgroupAdd(ivec2);\n"
2011             "ivec3  subgroupAdd(ivec3);\n"
2012             "ivec4  subgroupAdd(ivec4);\n"
2013             "uint   subgroupAdd(uint);\n"
2014             "uvec2  subgroupAdd(uvec2);\n"
2015             "uvec3  subgroupAdd(uvec3);\n"
2016             "uvec4  subgroupAdd(uvec4);\n"
2017 
2018             "float  subgroupMul(float);\n"
2019             "vec2   subgroupMul(vec2);\n"
2020             "vec3   subgroupMul(vec3);\n"
2021             "vec4   subgroupMul(vec4);\n"
2022             "int    subgroupMul(int);\n"
2023             "ivec2  subgroupMul(ivec2);\n"
2024             "ivec3  subgroupMul(ivec3);\n"
2025             "ivec4  subgroupMul(ivec4);\n"
2026             "uint   subgroupMul(uint);\n"
2027             "uvec2  subgroupMul(uvec2);\n"
2028             "uvec3  subgroupMul(uvec3);\n"
2029             "uvec4  subgroupMul(uvec4);\n"
2030 
2031             "float  subgroupMin(float);\n"
2032             "vec2   subgroupMin(vec2);\n"
2033             "vec3   subgroupMin(vec3);\n"
2034             "vec4   subgroupMin(vec4);\n"
2035             "int    subgroupMin(int);\n"
2036             "ivec2  subgroupMin(ivec2);\n"
2037             "ivec3  subgroupMin(ivec3);\n"
2038             "ivec4  subgroupMin(ivec4);\n"
2039             "uint   subgroupMin(uint);\n"
2040             "uvec2  subgroupMin(uvec2);\n"
2041             "uvec3  subgroupMin(uvec3);\n"
2042             "uvec4  subgroupMin(uvec4);\n"
2043 
2044             "float  subgroupMax(float);\n"
2045             "vec2   subgroupMax(vec2);\n"
2046             "vec3   subgroupMax(vec3);\n"
2047             "vec4   subgroupMax(vec4);\n"
2048             "int    subgroupMax(int);\n"
2049             "ivec2  subgroupMax(ivec2);\n"
2050             "ivec3  subgroupMax(ivec3);\n"
2051             "ivec4  subgroupMax(ivec4);\n"
2052             "uint   subgroupMax(uint);\n"
2053             "uvec2  subgroupMax(uvec2);\n"
2054             "uvec3  subgroupMax(uvec3);\n"
2055             "uvec4  subgroupMax(uvec4);\n"
2056 
2057             "int    subgroupAnd(int);\n"
2058             "ivec2  subgroupAnd(ivec2);\n"
2059             "ivec3  subgroupAnd(ivec3);\n"
2060             "ivec4  subgroupAnd(ivec4);\n"
2061             "uint   subgroupAnd(uint);\n"
2062             "uvec2  subgroupAnd(uvec2);\n"
2063             "uvec3  subgroupAnd(uvec3);\n"
2064             "uvec4  subgroupAnd(uvec4);\n"
2065             "bool   subgroupAnd(bool);\n"
2066             "bvec2  subgroupAnd(bvec2);\n"
2067             "bvec3  subgroupAnd(bvec3);\n"
2068             "bvec4  subgroupAnd(bvec4);\n"
2069 
2070             "int    subgroupOr(int);\n"
2071             "ivec2  subgroupOr(ivec2);\n"
2072             "ivec3  subgroupOr(ivec3);\n"
2073             "ivec4  subgroupOr(ivec4);\n"
2074             "uint   subgroupOr(uint);\n"
2075             "uvec2  subgroupOr(uvec2);\n"
2076             "uvec3  subgroupOr(uvec3);\n"
2077             "uvec4  subgroupOr(uvec4);\n"
2078             "bool   subgroupOr(bool);\n"
2079             "bvec2  subgroupOr(bvec2);\n"
2080             "bvec3  subgroupOr(bvec3);\n"
2081             "bvec4  subgroupOr(bvec4);\n"
2082 
2083             "int    subgroupXor(int);\n"
2084             "ivec2  subgroupXor(ivec2);\n"
2085             "ivec3  subgroupXor(ivec3);\n"
2086             "ivec4  subgroupXor(ivec4);\n"
2087             "uint   subgroupXor(uint);\n"
2088             "uvec2  subgroupXor(uvec2);\n"
2089             "uvec3  subgroupXor(uvec3);\n"
2090             "uvec4  subgroupXor(uvec4);\n"
2091             "bool   subgroupXor(bool);\n"
2092             "bvec2  subgroupXor(bvec2);\n"
2093             "bvec3  subgroupXor(bvec3);\n"
2094             "bvec4  subgroupXor(bvec4);\n"
2095 
2096             "float  subgroupInclusiveAdd(float);\n"
2097             "vec2   subgroupInclusiveAdd(vec2);\n"
2098             "vec3   subgroupInclusiveAdd(vec3);\n"
2099             "vec4   subgroupInclusiveAdd(vec4);\n"
2100             "int    subgroupInclusiveAdd(int);\n"
2101             "ivec2  subgroupInclusiveAdd(ivec2);\n"
2102             "ivec3  subgroupInclusiveAdd(ivec3);\n"
2103             "ivec4  subgroupInclusiveAdd(ivec4);\n"
2104             "uint   subgroupInclusiveAdd(uint);\n"
2105             "uvec2  subgroupInclusiveAdd(uvec2);\n"
2106             "uvec3  subgroupInclusiveAdd(uvec3);\n"
2107             "uvec4  subgroupInclusiveAdd(uvec4);\n"
2108 
2109             "float  subgroupInclusiveMul(float);\n"
2110             "vec2   subgroupInclusiveMul(vec2);\n"
2111             "vec3   subgroupInclusiveMul(vec3);\n"
2112             "vec4   subgroupInclusiveMul(vec4);\n"
2113             "int    subgroupInclusiveMul(int);\n"
2114             "ivec2  subgroupInclusiveMul(ivec2);\n"
2115             "ivec3  subgroupInclusiveMul(ivec3);\n"
2116             "ivec4  subgroupInclusiveMul(ivec4);\n"
2117             "uint   subgroupInclusiveMul(uint);\n"
2118             "uvec2  subgroupInclusiveMul(uvec2);\n"
2119             "uvec3  subgroupInclusiveMul(uvec3);\n"
2120             "uvec4  subgroupInclusiveMul(uvec4);\n"
2121 
2122             "float  subgroupInclusiveMin(float);\n"
2123             "vec2   subgroupInclusiveMin(vec2);\n"
2124             "vec3   subgroupInclusiveMin(vec3);\n"
2125             "vec4   subgroupInclusiveMin(vec4);\n"
2126             "int    subgroupInclusiveMin(int);\n"
2127             "ivec2  subgroupInclusiveMin(ivec2);\n"
2128             "ivec3  subgroupInclusiveMin(ivec3);\n"
2129             "ivec4  subgroupInclusiveMin(ivec4);\n"
2130             "uint   subgroupInclusiveMin(uint);\n"
2131             "uvec2  subgroupInclusiveMin(uvec2);\n"
2132             "uvec3  subgroupInclusiveMin(uvec3);\n"
2133             "uvec4  subgroupInclusiveMin(uvec4);\n"
2134 
2135             "float  subgroupInclusiveMax(float);\n"
2136             "vec2   subgroupInclusiveMax(vec2);\n"
2137             "vec3   subgroupInclusiveMax(vec3);\n"
2138             "vec4   subgroupInclusiveMax(vec4);\n"
2139             "int    subgroupInclusiveMax(int);\n"
2140             "ivec2  subgroupInclusiveMax(ivec2);\n"
2141             "ivec3  subgroupInclusiveMax(ivec3);\n"
2142             "ivec4  subgroupInclusiveMax(ivec4);\n"
2143             "uint   subgroupInclusiveMax(uint);\n"
2144             "uvec2  subgroupInclusiveMax(uvec2);\n"
2145             "uvec3  subgroupInclusiveMax(uvec3);\n"
2146             "uvec4  subgroupInclusiveMax(uvec4);\n"
2147 
2148             "int    subgroupInclusiveAnd(int);\n"
2149             "ivec2  subgroupInclusiveAnd(ivec2);\n"
2150             "ivec3  subgroupInclusiveAnd(ivec3);\n"
2151             "ivec4  subgroupInclusiveAnd(ivec4);\n"
2152             "uint   subgroupInclusiveAnd(uint);\n"
2153             "uvec2  subgroupInclusiveAnd(uvec2);\n"
2154             "uvec3  subgroupInclusiveAnd(uvec3);\n"
2155             "uvec4  subgroupInclusiveAnd(uvec4);\n"
2156             "bool   subgroupInclusiveAnd(bool);\n"
2157             "bvec2  subgroupInclusiveAnd(bvec2);\n"
2158             "bvec3  subgroupInclusiveAnd(bvec3);\n"
2159             "bvec4  subgroupInclusiveAnd(bvec4);\n"
2160 
2161             "int    subgroupInclusiveOr(int);\n"
2162             "ivec2  subgroupInclusiveOr(ivec2);\n"
2163             "ivec3  subgroupInclusiveOr(ivec3);\n"
2164             "ivec4  subgroupInclusiveOr(ivec4);\n"
2165             "uint   subgroupInclusiveOr(uint);\n"
2166             "uvec2  subgroupInclusiveOr(uvec2);\n"
2167             "uvec3  subgroupInclusiveOr(uvec3);\n"
2168             "uvec4  subgroupInclusiveOr(uvec4);\n"
2169             "bool   subgroupInclusiveOr(bool);\n"
2170             "bvec2  subgroupInclusiveOr(bvec2);\n"
2171             "bvec3  subgroupInclusiveOr(bvec3);\n"
2172             "bvec4  subgroupInclusiveOr(bvec4);\n"
2173 
2174             "int    subgroupInclusiveXor(int);\n"
2175             "ivec2  subgroupInclusiveXor(ivec2);\n"
2176             "ivec3  subgroupInclusiveXor(ivec3);\n"
2177             "ivec4  subgroupInclusiveXor(ivec4);\n"
2178             "uint   subgroupInclusiveXor(uint);\n"
2179             "uvec2  subgroupInclusiveXor(uvec2);\n"
2180             "uvec3  subgroupInclusiveXor(uvec3);\n"
2181             "uvec4  subgroupInclusiveXor(uvec4);\n"
2182             "bool   subgroupInclusiveXor(bool);\n"
2183             "bvec2  subgroupInclusiveXor(bvec2);\n"
2184             "bvec3  subgroupInclusiveXor(bvec3);\n"
2185             "bvec4  subgroupInclusiveXor(bvec4);\n"
2186 
2187             "float  subgroupExclusiveAdd(float);\n"
2188             "vec2   subgroupExclusiveAdd(vec2);\n"
2189             "vec3   subgroupExclusiveAdd(vec3);\n"
2190             "vec4   subgroupExclusiveAdd(vec4);\n"
2191             "int    subgroupExclusiveAdd(int);\n"
2192             "ivec2  subgroupExclusiveAdd(ivec2);\n"
2193             "ivec3  subgroupExclusiveAdd(ivec3);\n"
2194             "ivec4  subgroupExclusiveAdd(ivec4);\n"
2195             "uint   subgroupExclusiveAdd(uint);\n"
2196             "uvec2  subgroupExclusiveAdd(uvec2);\n"
2197             "uvec3  subgroupExclusiveAdd(uvec3);\n"
2198             "uvec4  subgroupExclusiveAdd(uvec4);\n"
2199 
2200             "float  subgroupExclusiveMul(float);\n"
2201             "vec2   subgroupExclusiveMul(vec2);\n"
2202             "vec3   subgroupExclusiveMul(vec3);\n"
2203             "vec4   subgroupExclusiveMul(vec4);\n"
2204             "int    subgroupExclusiveMul(int);\n"
2205             "ivec2  subgroupExclusiveMul(ivec2);\n"
2206             "ivec3  subgroupExclusiveMul(ivec3);\n"
2207             "ivec4  subgroupExclusiveMul(ivec4);\n"
2208             "uint   subgroupExclusiveMul(uint);\n"
2209             "uvec2  subgroupExclusiveMul(uvec2);\n"
2210             "uvec3  subgroupExclusiveMul(uvec3);\n"
2211             "uvec4  subgroupExclusiveMul(uvec4);\n"
2212 
2213             "float  subgroupExclusiveMin(float);\n"
2214             "vec2   subgroupExclusiveMin(vec2);\n"
2215             "vec3   subgroupExclusiveMin(vec3);\n"
2216             "vec4   subgroupExclusiveMin(vec4);\n"
2217             "int    subgroupExclusiveMin(int);\n"
2218             "ivec2  subgroupExclusiveMin(ivec2);\n"
2219             "ivec3  subgroupExclusiveMin(ivec3);\n"
2220             "ivec4  subgroupExclusiveMin(ivec4);\n"
2221             "uint   subgroupExclusiveMin(uint);\n"
2222             "uvec2  subgroupExclusiveMin(uvec2);\n"
2223             "uvec3  subgroupExclusiveMin(uvec3);\n"
2224             "uvec4  subgroupExclusiveMin(uvec4);\n"
2225 
2226             "float  subgroupExclusiveMax(float);\n"
2227             "vec2   subgroupExclusiveMax(vec2);\n"
2228             "vec3   subgroupExclusiveMax(vec3);\n"
2229             "vec4   subgroupExclusiveMax(vec4);\n"
2230             "int    subgroupExclusiveMax(int);\n"
2231             "ivec2  subgroupExclusiveMax(ivec2);\n"
2232             "ivec3  subgroupExclusiveMax(ivec3);\n"
2233             "ivec4  subgroupExclusiveMax(ivec4);\n"
2234             "uint   subgroupExclusiveMax(uint);\n"
2235             "uvec2  subgroupExclusiveMax(uvec2);\n"
2236             "uvec3  subgroupExclusiveMax(uvec3);\n"
2237             "uvec4  subgroupExclusiveMax(uvec4);\n"
2238 
2239             "int    subgroupExclusiveAnd(int);\n"
2240             "ivec2  subgroupExclusiveAnd(ivec2);\n"
2241             "ivec3  subgroupExclusiveAnd(ivec3);\n"
2242             "ivec4  subgroupExclusiveAnd(ivec4);\n"
2243             "uint   subgroupExclusiveAnd(uint);\n"
2244             "uvec2  subgroupExclusiveAnd(uvec2);\n"
2245             "uvec3  subgroupExclusiveAnd(uvec3);\n"
2246             "uvec4  subgroupExclusiveAnd(uvec4);\n"
2247             "bool   subgroupExclusiveAnd(bool);\n"
2248             "bvec2  subgroupExclusiveAnd(bvec2);\n"
2249             "bvec3  subgroupExclusiveAnd(bvec3);\n"
2250             "bvec4  subgroupExclusiveAnd(bvec4);\n"
2251 
2252             "int    subgroupExclusiveOr(int);\n"
2253             "ivec2  subgroupExclusiveOr(ivec2);\n"
2254             "ivec3  subgroupExclusiveOr(ivec3);\n"
2255             "ivec4  subgroupExclusiveOr(ivec4);\n"
2256             "uint   subgroupExclusiveOr(uint);\n"
2257             "uvec2  subgroupExclusiveOr(uvec2);\n"
2258             "uvec3  subgroupExclusiveOr(uvec3);\n"
2259             "uvec4  subgroupExclusiveOr(uvec4);\n"
2260             "bool   subgroupExclusiveOr(bool);\n"
2261             "bvec2  subgroupExclusiveOr(bvec2);\n"
2262             "bvec3  subgroupExclusiveOr(bvec3);\n"
2263             "bvec4  subgroupExclusiveOr(bvec4);\n"
2264 
2265             "int    subgroupExclusiveXor(int);\n"
2266             "ivec2  subgroupExclusiveXor(ivec2);\n"
2267             "ivec3  subgroupExclusiveXor(ivec3);\n"
2268             "ivec4  subgroupExclusiveXor(ivec4);\n"
2269             "uint   subgroupExclusiveXor(uint);\n"
2270             "uvec2  subgroupExclusiveXor(uvec2);\n"
2271             "uvec3  subgroupExclusiveXor(uvec3);\n"
2272             "uvec4  subgroupExclusiveXor(uvec4);\n"
2273             "bool   subgroupExclusiveXor(bool);\n"
2274             "bvec2  subgroupExclusiveXor(bvec2);\n"
2275             "bvec3  subgroupExclusiveXor(bvec3);\n"
2276             "bvec4  subgroupExclusiveXor(bvec4);\n"
2277 
2278             "float  subgroupClusteredAdd(float, uint);\n"
2279             "vec2   subgroupClusteredAdd(vec2, uint);\n"
2280             "vec3   subgroupClusteredAdd(vec3, uint);\n"
2281             "vec4   subgroupClusteredAdd(vec4, uint);\n"
2282             "int    subgroupClusteredAdd(int, uint);\n"
2283             "ivec2  subgroupClusteredAdd(ivec2, uint);\n"
2284             "ivec3  subgroupClusteredAdd(ivec3, uint);\n"
2285             "ivec4  subgroupClusteredAdd(ivec4, uint);\n"
2286             "uint   subgroupClusteredAdd(uint, uint);\n"
2287             "uvec2  subgroupClusteredAdd(uvec2, uint);\n"
2288             "uvec3  subgroupClusteredAdd(uvec3, uint);\n"
2289             "uvec4  subgroupClusteredAdd(uvec4, uint);\n"
2290 
2291             "float  subgroupClusteredMul(float, uint);\n"
2292             "vec2   subgroupClusteredMul(vec2, uint);\n"
2293             "vec3   subgroupClusteredMul(vec3, uint);\n"
2294             "vec4   subgroupClusteredMul(vec4, uint);\n"
2295             "int    subgroupClusteredMul(int, uint);\n"
2296             "ivec2  subgroupClusteredMul(ivec2, uint);\n"
2297             "ivec3  subgroupClusteredMul(ivec3, uint);\n"
2298             "ivec4  subgroupClusteredMul(ivec4, uint);\n"
2299             "uint   subgroupClusteredMul(uint, uint);\n"
2300             "uvec2  subgroupClusteredMul(uvec2, uint);\n"
2301             "uvec3  subgroupClusteredMul(uvec3, uint);\n"
2302             "uvec4  subgroupClusteredMul(uvec4, uint);\n"
2303 
2304             "float  subgroupClusteredMin(float, uint);\n"
2305             "vec2   subgroupClusteredMin(vec2, uint);\n"
2306             "vec3   subgroupClusteredMin(vec3, uint);\n"
2307             "vec4   subgroupClusteredMin(vec4, uint);\n"
2308             "int    subgroupClusteredMin(int, uint);\n"
2309             "ivec2  subgroupClusteredMin(ivec2, uint);\n"
2310             "ivec3  subgroupClusteredMin(ivec3, uint);\n"
2311             "ivec4  subgroupClusteredMin(ivec4, uint);\n"
2312             "uint   subgroupClusteredMin(uint, uint);\n"
2313             "uvec2  subgroupClusteredMin(uvec2, uint);\n"
2314             "uvec3  subgroupClusteredMin(uvec3, uint);\n"
2315             "uvec4  subgroupClusteredMin(uvec4, uint);\n"
2316 
2317             "float  subgroupClusteredMax(float, uint);\n"
2318             "vec2   subgroupClusteredMax(vec2, uint);\n"
2319             "vec3   subgroupClusteredMax(vec3, uint);\n"
2320             "vec4   subgroupClusteredMax(vec4, uint);\n"
2321             "int    subgroupClusteredMax(int, uint);\n"
2322             "ivec2  subgroupClusteredMax(ivec2, uint);\n"
2323             "ivec3  subgroupClusteredMax(ivec3, uint);\n"
2324             "ivec4  subgroupClusteredMax(ivec4, uint);\n"
2325             "uint   subgroupClusteredMax(uint, uint);\n"
2326             "uvec2  subgroupClusteredMax(uvec2, uint);\n"
2327             "uvec3  subgroupClusteredMax(uvec3, uint);\n"
2328             "uvec4  subgroupClusteredMax(uvec4, uint);\n"
2329 
2330             "int    subgroupClusteredAnd(int, uint);\n"
2331             "ivec2  subgroupClusteredAnd(ivec2, uint);\n"
2332             "ivec3  subgroupClusteredAnd(ivec3, uint);\n"
2333             "ivec4  subgroupClusteredAnd(ivec4, uint);\n"
2334             "uint   subgroupClusteredAnd(uint, uint);\n"
2335             "uvec2  subgroupClusteredAnd(uvec2, uint);\n"
2336             "uvec3  subgroupClusteredAnd(uvec3, uint);\n"
2337             "uvec4  subgroupClusteredAnd(uvec4, uint);\n"
2338             "bool   subgroupClusteredAnd(bool, uint);\n"
2339             "bvec2  subgroupClusteredAnd(bvec2, uint);\n"
2340             "bvec3  subgroupClusteredAnd(bvec3, uint);\n"
2341             "bvec4  subgroupClusteredAnd(bvec4, uint);\n"
2342 
2343             "int    subgroupClusteredOr(int, uint);\n"
2344             "ivec2  subgroupClusteredOr(ivec2, uint);\n"
2345             "ivec3  subgroupClusteredOr(ivec3, uint);\n"
2346             "ivec4  subgroupClusteredOr(ivec4, uint);\n"
2347             "uint   subgroupClusteredOr(uint, uint);\n"
2348             "uvec2  subgroupClusteredOr(uvec2, uint);\n"
2349             "uvec3  subgroupClusteredOr(uvec3, uint);\n"
2350             "uvec4  subgroupClusteredOr(uvec4, uint);\n"
2351             "bool   subgroupClusteredOr(bool, uint);\n"
2352             "bvec2  subgroupClusteredOr(bvec2, uint);\n"
2353             "bvec3  subgroupClusteredOr(bvec3, uint);\n"
2354             "bvec4  subgroupClusteredOr(bvec4, uint);\n"
2355 
2356             "int    subgroupClusteredXor(int, uint);\n"
2357             "ivec2  subgroupClusteredXor(ivec2, uint);\n"
2358             "ivec3  subgroupClusteredXor(ivec3, uint);\n"
2359             "ivec4  subgroupClusteredXor(ivec4, uint);\n"
2360             "uint   subgroupClusteredXor(uint, uint);\n"
2361             "uvec2  subgroupClusteredXor(uvec2, uint);\n"
2362             "uvec3  subgroupClusteredXor(uvec3, uint);\n"
2363             "uvec4  subgroupClusteredXor(uvec4, uint);\n"
2364             "bool   subgroupClusteredXor(bool, uint);\n"
2365             "bvec2  subgroupClusteredXor(bvec2, uint);\n"
2366             "bvec3  subgroupClusteredXor(bvec3, uint);\n"
2367             "bvec4  subgroupClusteredXor(bvec4, uint);\n"
2368 
2369             "float  subgroupQuadBroadcast(float, uint);\n"
2370             "vec2   subgroupQuadBroadcast(vec2, uint);\n"
2371             "vec3   subgroupQuadBroadcast(vec3, uint);\n"
2372             "vec4   subgroupQuadBroadcast(vec4, uint);\n"
2373             "int    subgroupQuadBroadcast(int, uint);\n"
2374             "ivec2  subgroupQuadBroadcast(ivec2, uint);\n"
2375             "ivec3  subgroupQuadBroadcast(ivec3, uint);\n"
2376             "ivec4  subgroupQuadBroadcast(ivec4, uint);\n"
2377             "uint   subgroupQuadBroadcast(uint, uint);\n"
2378             "uvec2  subgroupQuadBroadcast(uvec2, uint);\n"
2379             "uvec3  subgroupQuadBroadcast(uvec3, uint);\n"
2380             "uvec4  subgroupQuadBroadcast(uvec4, uint);\n"
2381             "bool   subgroupQuadBroadcast(bool, uint);\n"
2382             "bvec2  subgroupQuadBroadcast(bvec2, uint);\n"
2383             "bvec3  subgroupQuadBroadcast(bvec3, uint);\n"
2384             "bvec4  subgroupQuadBroadcast(bvec4, uint);\n"
2385 
2386             "float  subgroupQuadSwapHorizontal(float);\n"
2387             "vec2   subgroupQuadSwapHorizontal(vec2);\n"
2388             "vec3   subgroupQuadSwapHorizontal(vec3);\n"
2389             "vec4   subgroupQuadSwapHorizontal(vec4);\n"
2390             "int    subgroupQuadSwapHorizontal(int);\n"
2391             "ivec2  subgroupQuadSwapHorizontal(ivec2);\n"
2392             "ivec3  subgroupQuadSwapHorizontal(ivec3);\n"
2393             "ivec4  subgroupQuadSwapHorizontal(ivec4);\n"
2394             "uint   subgroupQuadSwapHorizontal(uint);\n"
2395             "uvec2  subgroupQuadSwapHorizontal(uvec2);\n"
2396             "uvec3  subgroupQuadSwapHorizontal(uvec3);\n"
2397             "uvec4  subgroupQuadSwapHorizontal(uvec4);\n"
2398             "bool   subgroupQuadSwapHorizontal(bool);\n"
2399             "bvec2  subgroupQuadSwapHorizontal(bvec2);\n"
2400             "bvec3  subgroupQuadSwapHorizontal(bvec3);\n"
2401             "bvec4  subgroupQuadSwapHorizontal(bvec4);\n"
2402 
2403             "float  subgroupQuadSwapVertical(float);\n"
2404             "vec2   subgroupQuadSwapVertical(vec2);\n"
2405             "vec3   subgroupQuadSwapVertical(vec3);\n"
2406             "vec4   subgroupQuadSwapVertical(vec4);\n"
2407             "int    subgroupQuadSwapVertical(int);\n"
2408             "ivec2  subgroupQuadSwapVertical(ivec2);\n"
2409             "ivec3  subgroupQuadSwapVertical(ivec3);\n"
2410             "ivec4  subgroupQuadSwapVertical(ivec4);\n"
2411             "uint   subgroupQuadSwapVertical(uint);\n"
2412             "uvec2  subgroupQuadSwapVertical(uvec2);\n"
2413             "uvec3  subgroupQuadSwapVertical(uvec3);\n"
2414             "uvec4  subgroupQuadSwapVertical(uvec4);\n"
2415             "bool   subgroupQuadSwapVertical(bool);\n"
2416             "bvec2  subgroupQuadSwapVertical(bvec2);\n"
2417             "bvec3  subgroupQuadSwapVertical(bvec3);\n"
2418             "bvec4  subgroupQuadSwapVertical(bvec4);\n"
2419 
2420             "float  subgroupQuadSwapDiagonal(float);\n"
2421             "vec2   subgroupQuadSwapDiagonal(vec2);\n"
2422             "vec3   subgroupQuadSwapDiagonal(vec3);\n"
2423             "vec4   subgroupQuadSwapDiagonal(vec4);\n"
2424             "int    subgroupQuadSwapDiagonal(int);\n"
2425             "ivec2  subgroupQuadSwapDiagonal(ivec2);\n"
2426             "ivec3  subgroupQuadSwapDiagonal(ivec3);\n"
2427             "ivec4  subgroupQuadSwapDiagonal(ivec4);\n"
2428             "uint   subgroupQuadSwapDiagonal(uint);\n"
2429             "uvec2  subgroupQuadSwapDiagonal(uvec2);\n"
2430             "uvec3  subgroupQuadSwapDiagonal(uvec3);\n"
2431             "uvec4  subgroupQuadSwapDiagonal(uvec4);\n"
2432             "bool   subgroupQuadSwapDiagonal(bool);\n"
2433             "bvec2  subgroupQuadSwapDiagonal(bvec2);\n"
2434             "bvec3  subgroupQuadSwapDiagonal(bvec3);\n"
2435             "bvec4  subgroupQuadSwapDiagonal(bvec4);\n"
2436 
2437 #ifdef NV_EXTENSIONS
2438             "uvec4  subgroupPartitionNV(float);\n"
2439             "uvec4  subgroupPartitionNV(vec2);\n"
2440             "uvec4  subgroupPartitionNV(vec3);\n"
2441             "uvec4  subgroupPartitionNV(vec4);\n"
2442             "uvec4  subgroupPartitionNV(int);\n"
2443             "uvec4  subgroupPartitionNV(ivec2);\n"
2444             "uvec4  subgroupPartitionNV(ivec3);\n"
2445             "uvec4  subgroupPartitionNV(ivec4);\n"
2446             "uvec4  subgroupPartitionNV(uint);\n"
2447             "uvec4  subgroupPartitionNV(uvec2);\n"
2448             "uvec4  subgroupPartitionNV(uvec3);\n"
2449             "uvec4  subgroupPartitionNV(uvec4);\n"
2450             "uvec4  subgroupPartitionNV(bool);\n"
2451             "uvec4  subgroupPartitionNV(bvec2);\n"
2452             "uvec4  subgroupPartitionNV(bvec3);\n"
2453             "uvec4  subgroupPartitionNV(bvec4);\n"
2454 
2455             "float  subgroupPartitionedAddNV(float, uvec4 ballot);\n"
2456             "vec2   subgroupPartitionedAddNV(vec2, uvec4 ballot);\n"
2457             "vec3   subgroupPartitionedAddNV(vec3, uvec4 ballot);\n"
2458             "vec4   subgroupPartitionedAddNV(vec4, uvec4 ballot);\n"
2459             "int    subgroupPartitionedAddNV(int, uvec4 ballot);\n"
2460             "ivec2  subgroupPartitionedAddNV(ivec2, uvec4 ballot);\n"
2461             "ivec3  subgroupPartitionedAddNV(ivec3, uvec4 ballot);\n"
2462             "ivec4  subgroupPartitionedAddNV(ivec4, uvec4 ballot);\n"
2463             "uint   subgroupPartitionedAddNV(uint, uvec4 ballot);\n"
2464             "uvec2  subgroupPartitionedAddNV(uvec2, uvec4 ballot);\n"
2465             "uvec3  subgroupPartitionedAddNV(uvec3, uvec4 ballot);\n"
2466             "uvec4  subgroupPartitionedAddNV(uvec4, uvec4 ballot);\n"
2467 
2468             "float  subgroupPartitionedMulNV(float, uvec4 ballot);\n"
2469             "vec2   subgroupPartitionedMulNV(vec2, uvec4 ballot);\n"
2470             "vec3   subgroupPartitionedMulNV(vec3, uvec4 ballot);\n"
2471             "vec4   subgroupPartitionedMulNV(vec4, uvec4 ballot);\n"
2472             "int    subgroupPartitionedMulNV(int, uvec4 ballot);\n"
2473             "ivec2  subgroupPartitionedMulNV(ivec2, uvec4 ballot);\n"
2474             "ivec3  subgroupPartitionedMulNV(ivec3, uvec4 ballot);\n"
2475             "ivec4  subgroupPartitionedMulNV(ivec4, uvec4 ballot);\n"
2476             "uint   subgroupPartitionedMulNV(uint, uvec4 ballot);\n"
2477             "uvec2  subgroupPartitionedMulNV(uvec2, uvec4 ballot);\n"
2478             "uvec3  subgroupPartitionedMulNV(uvec3, uvec4 ballot);\n"
2479             "uvec4  subgroupPartitionedMulNV(uvec4, uvec4 ballot);\n"
2480 
2481             "float  subgroupPartitionedMinNV(float, uvec4 ballot);\n"
2482             "vec2   subgroupPartitionedMinNV(vec2, uvec4 ballot);\n"
2483             "vec3   subgroupPartitionedMinNV(vec3, uvec4 ballot);\n"
2484             "vec4   subgroupPartitionedMinNV(vec4, uvec4 ballot);\n"
2485             "int    subgroupPartitionedMinNV(int, uvec4 ballot);\n"
2486             "ivec2  subgroupPartitionedMinNV(ivec2, uvec4 ballot);\n"
2487             "ivec3  subgroupPartitionedMinNV(ivec3, uvec4 ballot);\n"
2488             "ivec4  subgroupPartitionedMinNV(ivec4, uvec4 ballot);\n"
2489             "uint   subgroupPartitionedMinNV(uint, uvec4 ballot);\n"
2490             "uvec2  subgroupPartitionedMinNV(uvec2, uvec4 ballot);\n"
2491             "uvec3  subgroupPartitionedMinNV(uvec3, uvec4 ballot);\n"
2492             "uvec4  subgroupPartitionedMinNV(uvec4, uvec4 ballot);\n"
2493 
2494             "float  subgroupPartitionedMaxNV(float, uvec4 ballot);\n"
2495             "vec2   subgroupPartitionedMaxNV(vec2, uvec4 ballot);\n"
2496             "vec3   subgroupPartitionedMaxNV(vec3, uvec4 ballot);\n"
2497             "vec4   subgroupPartitionedMaxNV(vec4, uvec4 ballot);\n"
2498             "int    subgroupPartitionedMaxNV(int, uvec4 ballot);\n"
2499             "ivec2  subgroupPartitionedMaxNV(ivec2, uvec4 ballot);\n"
2500             "ivec3  subgroupPartitionedMaxNV(ivec3, uvec4 ballot);\n"
2501             "ivec4  subgroupPartitionedMaxNV(ivec4, uvec4 ballot);\n"
2502             "uint   subgroupPartitionedMaxNV(uint, uvec4 ballot);\n"
2503             "uvec2  subgroupPartitionedMaxNV(uvec2, uvec4 ballot);\n"
2504             "uvec3  subgroupPartitionedMaxNV(uvec3, uvec4 ballot);\n"
2505             "uvec4  subgroupPartitionedMaxNV(uvec4, uvec4 ballot);\n"
2506 
2507             "int    subgroupPartitionedAndNV(int, uvec4 ballot);\n"
2508             "ivec2  subgroupPartitionedAndNV(ivec2, uvec4 ballot);\n"
2509             "ivec3  subgroupPartitionedAndNV(ivec3, uvec4 ballot);\n"
2510             "ivec4  subgroupPartitionedAndNV(ivec4, uvec4 ballot);\n"
2511             "uint   subgroupPartitionedAndNV(uint, uvec4 ballot);\n"
2512             "uvec2  subgroupPartitionedAndNV(uvec2, uvec4 ballot);\n"
2513             "uvec3  subgroupPartitionedAndNV(uvec3, uvec4 ballot);\n"
2514             "uvec4  subgroupPartitionedAndNV(uvec4, uvec4 ballot);\n"
2515             "bool   subgroupPartitionedAndNV(bool, uvec4 ballot);\n"
2516             "bvec2  subgroupPartitionedAndNV(bvec2, uvec4 ballot);\n"
2517             "bvec3  subgroupPartitionedAndNV(bvec3, uvec4 ballot);\n"
2518             "bvec4  subgroupPartitionedAndNV(bvec4, uvec4 ballot);\n"
2519 
2520             "int    subgroupPartitionedOrNV(int, uvec4 ballot);\n"
2521             "ivec2  subgroupPartitionedOrNV(ivec2, uvec4 ballot);\n"
2522             "ivec3  subgroupPartitionedOrNV(ivec3, uvec4 ballot);\n"
2523             "ivec4  subgroupPartitionedOrNV(ivec4, uvec4 ballot);\n"
2524             "uint   subgroupPartitionedOrNV(uint, uvec4 ballot);\n"
2525             "uvec2  subgroupPartitionedOrNV(uvec2, uvec4 ballot);\n"
2526             "uvec3  subgroupPartitionedOrNV(uvec3, uvec4 ballot);\n"
2527             "uvec4  subgroupPartitionedOrNV(uvec4, uvec4 ballot);\n"
2528             "bool   subgroupPartitionedOrNV(bool, uvec4 ballot);\n"
2529             "bvec2  subgroupPartitionedOrNV(bvec2, uvec4 ballot);\n"
2530             "bvec3  subgroupPartitionedOrNV(bvec3, uvec4 ballot);\n"
2531             "bvec4  subgroupPartitionedOrNV(bvec4, uvec4 ballot);\n"
2532 
2533             "int    subgroupPartitionedXorNV(int, uvec4 ballot);\n"
2534             "ivec2  subgroupPartitionedXorNV(ivec2, uvec4 ballot);\n"
2535             "ivec3  subgroupPartitionedXorNV(ivec3, uvec4 ballot);\n"
2536             "ivec4  subgroupPartitionedXorNV(ivec4, uvec4 ballot);\n"
2537             "uint   subgroupPartitionedXorNV(uint, uvec4 ballot);\n"
2538             "uvec2  subgroupPartitionedXorNV(uvec2, uvec4 ballot);\n"
2539             "uvec3  subgroupPartitionedXorNV(uvec3, uvec4 ballot);\n"
2540             "uvec4  subgroupPartitionedXorNV(uvec4, uvec4 ballot);\n"
2541             "bool   subgroupPartitionedXorNV(bool, uvec4 ballot);\n"
2542             "bvec2  subgroupPartitionedXorNV(bvec2, uvec4 ballot);\n"
2543             "bvec3  subgroupPartitionedXorNV(bvec3, uvec4 ballot);\n"
2544             "bvec4  subgroupPartitionedXorNV(bvec4, uvec4 ballot);\n"
2545 
2546             "float  subgroupPartitionedInclusiveAddNV(float, uvec4 ballot);\n"
2547             "vec2   subgroupPartitionedInclusiveAddNV(vec2, uvec4 ballot);\n"
2548             "vec3   subgroupPartitionedInclusiveAddNV(vec3, uvec4 ballot);\n"
2549             "vec4   subgroupPartitionedInclusiveAddNV(vec4, uvec4 ballot);\n"
2550             "int    subgroupPartitionedInclusiveAddNV(int, uvec4 ballot);\n"
2551             "ivec2  subgroupPartitionedInclusiveAddNV(ivec2, uvec4 ballot);\n"
2552             "ivec3  subgroupPartitionedInclusiveAddNV(ivec3, uvec4 ballot);\n"
2553             "ivec4  subgroupPartitionedInclusiveAddNV(ivec4, uvec4 ballot);\n"
2554             "uint   subgroupPartitionedInclusiveAddNV(uint, uvec4 ballot);\n"
2555             "uvec2  subgroupPartitionedInclusiveAddNV(uvec2, uvec4 ballot);\n"
2556             "uvec3  subgroupPartitionedInclusiveAddNV(uvec3, uvec4 ballot);\n"
2557             "uvec4  subgroupPartitionedInclusiveAddNV(uvec4, uvec4 ballot);\n"
2558 
2559             "float  subgroupPartitionedInclusiveMulNV(float, uvec4 ballot);\n"
2560             "vec2   subgroupPartitionedInclusiveMulNV(vec2, uvec4 ballot);\n"
2561             "vec3   subgroupPartitionedInclusiveMulNV(vec3, uvec4 ballot);\n"
2562             "vec4   subgroupPartitionedInclusiveMulNV(vec4, uvec4 ballot);\n"
2563             "int    subgroupPartitionedInclusiveMulNV(int, uvec4 ballot);\n"
2564             "ivec2  subgroupPartitionedInclusiveMulNV(ivec2, uvec4 ballot);\n"
2565             "ivec3  subgroupPartitionedInclusiveMulNV(ivec3, uvec4 ballot);\n"
2566             "ivec4  subgroupPartitionedInclusiveMulNV(ivec4, uvec4 ballot);\n"
2567             "uint   subgroupPartitionedInclusiveMulNV(uint, uvec4 ballot);\n"
2568             "uvec2  subgroupPartitionedInclusiveMulNV(uvec2, uvec4 ballot);\n"
2569             "uvec3  subgroupPartitionedInclusiveMulNV(uvec3, uvec4 ballot);\n"
2570             "uvec4  subgroupPartitionedInclusiveMulNV(uvec4, uvec4 ballot);\n"
2571 
2572             "float  subgroupPartitionedInclusiveMinNV(float, uvec4 ballot);\n"
2573             "vec2   subgroupPartitionedInclusiveMinNV(vec2, uvec4 ballot);\n"
2574             "vec3   subgroupPartitionedInclusiveMinNV(vec3, uvec4 ballot);\n"
2575             "vec4   subgroupPartitionedInclusiveMinNV(vec4, uvec4 ballot);\n"
2576             "int    subgroupPartitionedInclusiveMinNV(int, uvec4 ballot);\n"
2577             "ivec2  subgroupPartitionedInclusiveMinNV(ivec2, uvec4 ballot);\n"
2578             "ivec3  subgroupPartitionedInclusiveMinNV(ivec3, uvec4 ballot);\n"
2579             "ivec4  subgroupPartitionedInclusiveMinNV(ivec4, uvec4 ballot);\n"
2580             "uint   subgroupPartitionedInclusiveMinNV(uint, uvec4 ballot);\n"
2581             "uvec2  subgroupPartitionedInclusiveMinNV(uvec2, uvec4 ballot);\n"
2582             "uvec3  subgroupPartitionedInclusiveMinNV(uvec3, uvec4 ballot);\n"
2583             "uvec4  subgroupPartitionedInclusiveMinNV(uvec4, uvec4 ballot);\n"
2584 
2585             "float  subgroupPartitionedInclusiveMaxNV(float, uvec4 ballot);\n"
2586             "vec2   subgroupPartitionedInclusiveMaxNV(vec2, uvec4 ballot);\n"
2587             "vec3   subgroupPartitionedInclusiveMaxNV(vec3, uvec4 ballot);\n"
2588             "vec4   subgroupPartitionedInclusiveMaxNV(vec4, uvec4 ballot);\n"
2589             "int    subgroupPartitionedInclusiveMaxNV(int, uvec4 ballot);\n"
2590             "ivec2  subgroupPartitionedInclusiveMaxNV(ivec2, uvec4 ballot);\n"
2591             "ivec3  subgroupPartitionedInclusiveMaxNV(ivec3, uvec4 ballot);\n"
2592             "ivec4  subgroupPartitionedInclusiveMaxNV(ivec4, uvec4 ballot);\n"
2593             "uint   subgroupPartitionedInclusiveMaxNV(uint, uvec4 ballot);\n"
2594             "uvec2  subgroupPartitionedInclusiveMaxNV(uvec2, uvec4 ballot);\n"
2595             "uvec3  subgroupPartitionedInclusiveMaxNV(uvec3, uvec4 ballot);\n"
2596             "uvec4  subgroupPartitionedInclusiveMaxNV(uvec4, uvec4 ballot);\n"
2597 
2598             "int    subgroupPartitionedInclusiveAndNV(int, uvec4 ballot);\n"
2599             "ivec2  subgroupPartitionedInclusiveAndNV(ivec2, uvec4 ballot);\n"
2600             "ivec3  subgroupPartitionedInclusiveAndNV(ivec3, uvec4 ballot);\n"
2601             "ivec4  subgroupPartitionedInclusiveAndNV(ivec4, uvec4 ballot);\n"
2602             "uint   subgroupPartitionedInclusiveAndNV(uint, uvec4 ballot);\n"
2603             "uvec2  subgroupPartitionedInclusiveAndNV(uvec2, uvec4 ballot);\n"
2604             "uvec3  subgroupPartitionedInclusiveAndNV(uvec3, uvec4 ballot);\n"
2605             "uvec4  subgroupPartitionedInclusiveAndNV(uvec4, uvec4 ballot);\n"
2606             "bool   subgroupPartitionedInclusiveAndNV(bool, uvec4 ballot);\n"
2607             "bvec2  subgroupPartitionedInclusiveAndNV(bvec2, uvec4 ballot);\n"
2608             "bvec3  subgroupPartitionedInclusiveAndNV(bvec3, uvec4 ballot);\n"
2609             "bvec4  subgroupPartitionedInclusiveAndNV(bvec4, uvec4 ballot);\n"
2610 
2611             "int    subgroupPartitionedInclusiveOrNV(int, uvec4 ballot);\n"
2612             "ivec2  subgroupPartitionedInclusiveOrNV(ivec2, uvec4 ballot);\n"
2613             "ivec3  subgroupPartitionedInclusiveOrNV(ivec3, uvec4 ballot);\n"
2614             "ivec4  subgroupPartitionedInclusiveOrNV(ivec4, uvec4 ballot);\n"
2615             "uint   subgroupPartitionedInclusiveOrNV(uint, uvec4 ballot);\n"
2616             "uvec2  subgroupPartitionedInclusiveOrNV(uvec2, uvec4 ballot);\n"
2617             "uvec3  subgroupPartitionedInclusiveOrNV(uvec3, uvec4 ballot);\n"
2618             "uvec4  subgroupPartitionedInclusiveOrNV(uvec4, uvec4 ballot);\n"
2619             "bool   subgroupPartitionedInclusiveOrNV(bool, uvec4 ballot);\n"
2620             "bvec2  subgroupPartitionedInclusiveOrNV(bvec2, uvec4 ballot);\n"
2621             "bvec3  subgroupPartitionedInclusiveOrNV(bvec3, uvec4 ballot);\n"
2622             "bvec4  subgroupPartitionedInclusiveOrNV(bvec4, uvec4 ballot);\n"
2623 
2624             "int    subgroupPartitionedInclusiveXorNV(int, uvec4 ballot);\n"
2625             "ivec2  subgroupPartitionedInclusiveXorNV(ivec2, uvec4 ballot);\n"
2626             "ivec3  subgroupPartitionedInclusiveXorNV(ivec3, uvec4 ballot);\n"
2627             "ivec4  subgroupPartitionedInclusiveXorNV(ivec4, uvec4 ballot);\n"
2628             "uint   subgroupPartitionedInclusiveXorNV(uint, uvec4 ballot);\n"
2629             "uvec2  subgroupPartitionedInclusiveXorNV(uvec2, uvec4 ballot);\n"
2630             "uvec3  subgroupPartitionedInclusiveXorNV(uvec3, uvec4 ballot);\n"
2631             "uvec4  subgroupPartitionedInclusiveXorNV(uvec4, uvec4 ballot);\n"
2632             "bool   subgroupPartitionedInclusiveXorNV(bool, uvec4 ballot);\n"
2633             "bvec2  subgroupPartitionedInclusiveXorNV(bvec2, uvec4 ballot);\n"
2634             "bvec3  subgroupPartitionedInclusiveXorNV(bvec3, uvec4 ballot);\n"
2635             "bvec4  subgroupPartitionedInclusiveXorNV(bvec4, uvec4 ballot);\n"
2636 
2637             "float  subgroupPartitionedExclusiveAddNV(float, uvec4 ballot);\n"
2638             "vec2   subgroupPartitionedExclusiveAddNV(vec2, uvec4 ballot);\n"
2639             "vec3   subgroupPartitionedExclusiveAddNV(vec3, uvec4 ballot);\n"
2640             "vec4   subgroupPartitionedExclusiveAddNV(vec4, uvec4 ballot);\n"
2641             "int    subgroupPartitionedExclusiveAddNV(int, uvec4 ballot);\n"
2642             "ivec2  subgroupPartitionedExclusiveAddNV(ivec2, uvec4 ballot);\n"
2643             "ivec3  subgroupPartitionedExclusiveAddNV(ivec3, uvec4 ballot);\n"
2644             "ivec4  subgroupPartitionedExclusiveAddNV(ivec4, uvec4 ballot);\n"
2645             "uint   subgroupPartitionedExclusiveAddNV(uint, uvec4 ballot);\n"
2646             "uvec2  subgroupPartitionedExclusiveAddNV(uvec2, uvec4 ballot);\n"
2647             "uvec3  subgroupPartitionedExclusiveAddNV(uvec3, uvec4 ballot);\n"
2648             "uvec4  subgroupPartitionedExclusiveAddNV(uvec4, uvec4 ballot);\n"
2649 
2650             "float  subgroupPartitionedExclusiveMulNV(float, uvec4 ballot);\n"
2651             "vec2   subgroupPartitionedExclusiveMulNV(vec2, uvec4 ballot);\n"
2652             "vec3   subgroupPartitionedExclusiveMulNV(vec3, uvec4 ballot);\n"
2653             "vec4   subgroupPartitionedExclusiveMulNV(vec4, uvec4 ballot);\n"
2654             "int    subgroupPartitionedExclusiveMulNV(int, uvec4 ballot);\n"
2655             "ivec2  subgroupPartitionedExclusiveMulNV(ivec2, uvec4 ballot);\n"
2656             "ivec3  subgroupPartitionedExclusiveMulNV(ivec3, uvec4 ballot);\n"
2657             "ivec4  subgroupPartitionedExclusiveMulNV(ivec4, uvec4 ballot);\n"
2658             "uint   subgroupPartitionedExclusiveMulNV(uint, uvec4 ballot);\n"
2659             "uvec2  subgroupPartitionedExclusiveMulNV(uvec2, uvec4 ballot);\n"
2660             "uvec3  subgroupPartitionedExclusiveMulNV(uvec3, uvec4 ballot);\n"
2661             "uvec4  subgroupPartitionedExclusiveMulNV(uvec4, uvec4 ballot);\n"
2662 
2663             "float  subgroupPartitionedExclusiveMinNV(float, uvec4 ballot);\n"
2664             "vec2   subgroupPartitionedExclusiveMinNV(vec2, uvec4 ballot);\n"
2665             "vec3   subgroupPartitionedExclusiveMinNV(vec3, uvec4 ballot);\n"
2666             "vec4   subgroupPartitionedExclusiveMinNV(vec4, uvec4 ballot);\n"
2667             "int    subgroupPartitionedExclusiveMinNV(int, uvec4 ballot);\n"
2668             "ivec2  subgroupPartitionedExclusiveMinNV(ivec2, uvec4 ballot);\n"
2669             "ivec3  subgroupPartitionedExclusiveMinNV(ivec3, uvec4 ballot);\n"
2670             "ivec4  subgroupPartitionedExclusiveMinNV(ivec4, uvec4 ballot);\n"
2671             "uint   subgroupPartitionedExclusiveMinNV(uint, uvec4 ballot);\n"
2672             "uvec2  subgroupPartitionedExclusiveMinNV(uvec2, uvec4 ballot);\n"
2673             "uvec3  subgroupPartitionedExclusiveMinNV(uvec3, uvec4 ballot);\n"
2674             "uvec4  subgroupPartitionedExclusiveMinNV(uvec4, uvec4 ballot);\n"
2675 
2676             "float  subgroupPartitionedExclusiveMaxNV(float, uvec4 ballot);\n"
2677             "vec2   subgroupPartitionedExclusiveMaxNV(vec2, uvec4 ballot);\n"
2678             "vec3   subgroupPartitionedExclusiveMaxNV(vec3, uvec4 ballot);\n"
2679             "vec4   subgroupPartitionedExclusiveMaxNV(vec4, uvec4 ballot);\n"
2680             "int    subgroupPartitionedExclusiveMaxNV(int, uvec4 ballot);\n"
2681             "ivec2  subgroupPartitionedExclusiveMaxNV(ivec2, uvec4 ballot);\n"
2682             "ivec3  subgroupPartitionedExclusiveMaxNV(ivec3, uvec4 ballot);\n"
2683             "ivec4  subgroupPartitionedExclusiveMaxNV(ivec4, uvec4 ballot);\n"
2684             "uint   subgroupPartitionedExclusiveMaxNV(uint, uvec4 ballot);\n"
2685             "uvec2  subgroupPartitionedExclusiveMaxNV(uvec2, uvec4 ballot);\n"
2686             "uvec3  subgroupPartitionedExclusiveMaxNV(uvec3, uvec4 ballot);\n"
2687             "uvec4  subgroupPartitionedExclusiveMaxNV(uvec4, uvec4 ballot);\n"
2688 
2689             "int    subgroupPartitionedExclusiveAndNV(int, uvec4 ballot);\n"
2690             "ivec2  subgroupPartitionedExclusiveAndNV(ivec2, uvec4 ballot);\n"
2691             "ivec3  subgroupPartitionedExclusiveAndNV(ivec3, uvec4 ballot);\n"
2692             "ivec4  subgroupPartitionedExclusiveAndNV(ivec4, uvec4 ballot);\n"
2693             "uint   subgroupPartitionedExclusiveAndNV(uint, uvec4 ballot);\n"
2694             "uvec2  subgroupPartitionedExclusiveAndNV(uvec2, uvec4 ballot);\n"
2695             "uvec3  subgroupPartitionedExclusiveAndNV(uvec3, uvec4 ballot);\n"
2696             "uvec4  subgroupPartitionedExclusiveAndNV(uvec4, uvec4 ballot);\n"
2697             "bool   subgroupPartitionedExclusiveAndNV(bool, uvec4 ballot);\n"
2698             "bvec2  subgroupPartitionedExclusiveAndNV(bvec2, uvec4 ballot);\n"
2699             "bvec3  subgroupPartitionedExclusiveAndNV(bvec3, uvec4 ballot);\n"
2700             "bvec4  subgroupPartitionedExclusiveAndNV(bvec4, uvec4 ballot);\n"
2701 
2702             "int    subgroupPartitionedExclusiveOrNV(int, uvec4 ballot);\n"
2703             "ivec2  subgroupPartitionedExclusiveOrNV(ivec2, uvec4 ballot);\n"
2704             "ivec3  subgroupPartitionedExclusiveOrNV(ivec3, uvec4 ballot);\n"
2705             "ivec4  subgroupPartitionedExclusiveOrNV(ivec4, uvec4 ballot);\n"
2706             "uint   subgroupPartitionedExclusiveOrNV(uint, uvec4 ballot);\n"
2707             "uvec2  subgroupPartitionedExclusiveOrNV(uvec2, uvec4 ballot);\n"
2708             "uvec3  subgroupPartitionedExclusiveOrNV(uvec3, uvec4 ballot);\n"
2709             "uvec4  subgroupPartitionedExclusiveOrNV(uvec4, uvec4 ballot);\n"
2710             "bool   subgroupPartitionedExclusiveOrNV(bool, uvec4 ballot);\n"
2711             "bvec2  subgroupPartitionedExclusiveOrNV(bvec2, uvec4 ballot);\n"
2712             "bvec3  subgroupPartitionedExclusiveOrNV(bvec3, uvec4 ballot);\n"
2713             "bvec4  subgroupPartitionedExclusiveOrNV(bvec4, uvec4 ballot);\n"
2714 
2715             "int    subgroupPartitionedExclusiveXorNV(int, uvec4 ballot);\n"
2716             "ivec2  subgroupPartitionedExclusiveXorNV(ivec2, uvec4 ballot);\n"
2717             "ivec3  subgroupPartitionedExclusiveXorNV(ivec3, uvec4 ballot);\n"
2718             "ivec4  subgroupPartitionedExclusiveXorNV(ivec4, uvec4 ballot);\n"
2719             "uint   subgroupPartitionedExclusiveXorNV(uint, uvec4 ballot);\n"
2720             "uvec2  subgroupPartitionedExclusiveXorNV(uvec2, uvec4 ballot);\n"
2721             "uvec3  subgroupPartitionedExclusiveXorNV(uvec3, uvec4 ballot);\n"
2722             "uvec4  subgroupPartitionedExclusiveXorNV(uvec4, uvec4 ballot);\n"
2723             "bool   subgroupPartitionedExclusiveXorNV(bool, uvec4 ballot);\n"
2724             "bvec2  subgroupPartitionedExclusiveXorNV(bvec2, uvec4 ballot);\n"
2725             "bvec3  subgroupPartitionedExclusiveXorNV(bvec3, uvec4 ballot);\n"
2726             "bvec4  subgroupPartitionedExclusiveXorNV(bvec4, uvec4 ballot);\n"
2727 #endif
2728 
2729             "\n");
2730 
2731         if (profile != EEsProfile && version >= 400) {
2732             commonBuiltins.append(
2733                 "bool   subgroupAllEqual(double);\n"
2734                 "bool   subgroupAllEqual(dvec2);\n"
2735                 "bool   subgroupAllEqual(dvec3);\n"
2736                 "bool   subgroupAllEqual(dvec4);\n"
2737 
2738                 "double subgroupBroadcast(double, uint);\n"
2739                 "dvec2  subgroupBroadcast(dvec2, uint);\n"
2740                 "dvec3  subgroupBroadcast(dvec3, uint);\n"
2741                 "dvec4  subgroupBroadcast(dvec4, uint);\n"
2742 
2743                 "double subgroupBroadcastFirst(double);\n"
2744                 "dvec2  subgroupBroadcastFirst(dvec2);\n"
2745                 "dvec3  subgroupBroadcastFirst(dvec3);\n"
2746                 "dvec4  subgroupBroadcastFirst(dvec4);\n"
2747 
2748                 "double subgroupShuffle(double, uint);\n"
2749                 "dvec2  subgroupShuffle(dvec2, uint);\n"
2750                 "dvec3  subgroupShuffle(dvec3, uint);\n"
2751                 "dvec4  subgroupShuffle(dvec4, uint);\n"
2752 
2753                 "double subgroupShuffleXor(double, uint);\n"
2754                 "dvec2  subgroupShuffleXor(dvec2, uint);\n"
2755                 "dvec3  subgroupShuffleXor(dvec3, uint);\n"
2756                 "dvec4  subgroupShuffleXor(dvec4, uint);\n"
2757 
2758                 "double subgroupShuffleUp(double, uint delta);\n"
2759                 "dvec2  subgroupShuffleUp(dvec2, uint delta);\n"
2760                 "dvec3  subgroupShuffleUp(dvec3, uint delta);\n"
2761                 "dvec4  subgroupShuffleUp(dvec4, uint delta);\n"
2762 
2763                 "double subgroupShuffleDown(double, uint delta);\n"
2764                 "dvec2  subgroupShuffleDown(dvec2, uint delta);\n"
2765                 "dvec3  subgroupShuffleDown(dvec3, uint delta);\n"
2766                 "dvec4  subgroupShuffleDown(dvec4, uint delta);\n"
2767 
2768                 "double subgroupAdd(double);\n"
2769                 "dvec2  subgroupAdd(dvec2);\n"
2770                 "dvec3  subgroupAdd(dvec3);\n"
2771                 "dvec4  subgroupAdd(dvec4);\n"
2772 
2773                 "double subgroupMul(double);\n"
2774                 "dvec2  subgroupMul(dvec2);\n"
2775                 "dvec3  subgroupMul(dvec3);\n"
2776                 "dvec4  subgroupMul(dvec4);\n"
2777 
2778                 "double subgroupMin(double);\n"
2779                 "dvec2  subgroupMin(dvec2);\n"
2780                 "dvec3  subgroupMin(dvec3);\n"
2781                 "dvec4  subgroupMin(dvec4);\n"
2782 
2783                 "double subgroupMax(double);\n"
2784                 "dvec2  subgroupMax(dvec2);\n"
2785                 "dvec3  subgroupMax(dvec3);\n"
2786                 "dvec4  subgroupMax(dvec4);\n"
2787 
2788                 "double subgroupInclusiveAdd(double);\n"
2789                 "dvec2  subgroupInclusiveAdd(dvec2);\n"
2790                 "dvec3  subgroupInclusiveAdd(dvec3);\n"
2791                 "dvec4  subgroupInclusiveAdd(dvec4);\n"
2792 
2793                 "double subgroupInclusiveMul(double);\n"
2794                 "dvec2  subgroupInclusiveMul(dvec2);\n"
2795                 "dvec3  subgroupInclusiveMul(dvec3);\n"
2796                 "dvec4  subgroupInclusiveMul(dvec4);\n"
2797 
2798                 "double subgroupInclusiveMin(double);\n"
2799                 "dvec2  subgroupInclusiveMin(dvec2);\n"
2800                 "dvec3  subgroupInclusiveMin(dvec3);\n"
2801                 "dvec4  subgroupInclusiveMin(dvec4);\n"
2802 
2803                 "double subgroupInclusiveMax(double);\n"
2804                 "dvec2  subgroupInclusiveMax(dvec2);\n"
2805                 "dvec3  subgroupInclusiveMax(dvec3);\n"
2806                 "dvec4  subgroupInclusiveMax(dvec4);\n"
2807 
2808                 "double subgroupExclusiveAdd(double);\n"
2809                 "dvec2  subgroupExclusiveAdd(dvec2);\n"
2810                 "dvec3  subgroupExclusiveAdd(dvec3);\n"
2811                 "dvec4  subgroupExclusiveAdd(dvec4);\n"
2812 
2813                 "double subgroupExclusiveMul(double);\n"
2814                 "dvec2  subgroupExclusiveMul(dvec2);\n"
2815                 "dvec3  subgroupExclusiveMul(dvec3);\n"
2816                 "dvec4  subgroupExclusiveMul(dvec4);\n"
2817 
2818                 "double subgroupExclusiveMin(double);\n"
2819                 "dvec2  subgroupExclusiveMin(dvec2);\n"
2820                 "dvec3  subgroupExclusiveMin(dvec3);\n"
2821                 "dvec4  subgroupExclusiveMin(dvec4);\n"
2822 
2823                 "double subgroupExclusiveMax(double);\n"
2824                 "dvec2  subgroupExclusiveMax(dvec2);\n"
2825                 "dvec3  subgroupExclusiveMax(dvec3);\n"
2826                 "dvec4  subgroupExclusiveMax(dvec4);\n"
2827 
2828                 "double subgroupClusteredAdd(double, uint);\n"
2829                 "dvec2  subgroupClusteredAdd(dvec2, uint);\n"
2830                 "dvec3  subgroupClusteredAdd(dvec3, uint);\n"
2831                 "dvec4  subgroupClusteredAdd(dvec4, uint);\n"
2832 
2833                 "double subgroupClusteredMul(double, uint);\n"
2834                 "dvec2  subgroupClusteredMul(dvec2, uint);\n"
2835                 "dvec3  subgroupClusteredMul(dvec3, uint);\n"
2836                 "dvec4  subgroupClusteredMul(dvec4, uint);\n"
2837 
2838                 "double subgroupClusteredMin(double, uint);\n"
2839                 "dvec2  subgroupClusteredMin(dvec2, uint);\n"
2840                 "dvec3  subgroupClusteredMin(dvec3, uint);\n"
2841                 "dvec4  subgroupClusteredMin(dvec4, uint);\n"
2842 
2843                 "double subgroupClusteredMax(double, uint);\n"
2844                 "dvec2  subgroupClusteredMax(dvec2, uint);\n"
2845                 "dvec3  subgroupClusteredMax(dvec3, uint);\n"
2846                 "dvec4  subgroupClusteredMax(dvec4, uint);\n"
2847 
2848                 "double subgroupQuadBroadcast(double, uint);\n"
2849                 "dvec2  subgroupQuadBroadcast(dvec2, uint);\n"
2850                 "dvec3  subgroupQuadBroadcast(dvec3, uint);\n"
2851                 "dvec4  subgroupQuadBroadcast(dvec4, uint);\n"
2852 
2853                 "double subgroupQuadSwapHorizontal(double);\n"
2854                 "dvec2  subgroupQuadSwapHorizontal(dvec2);\n"
2855                 "dvec3  subgroupQuadSwapHorizontal(dvec3);\n"
2856                 "dvec4  subgroupQuadSwapHorizontal(dvec4);\n"
2857 
2858                 "double subgroupQuadSwapVertical(double);\n"
2859                 "dvec2  subgroupQuadSwapVertical(dvec2);\n"
2860                 "dvec3  subgroupQuadSwapVertical(dvec3);\n"
2861                 "dvec4  subgroupQuadSwapVertical(dvec4);\n"
2862 
2863                 "double subgroupQuadSwapDiagonal(double);\n"
2864                 "dvec2  subgroupQuadSwapDiagonal(dvec2);\n"
2865                 "dvec3  subgroupQuadSwapDiagonal(dvec3);\n"
2866                 "dvec4  subgroupQuadSwapDiagonal(dvec4);\n"
2867 
2868 
2869 #ifdef NV_EXTENSIONS
2870                 "uvec4  subgroupPartitionNV(double);\n"
2871                 "uvec4  subgroupPartitionNV(dvec2);\n"
2872                 "uvec4  subgroupPartitionNV(dvec3);\n"
2873                 "uvec4  subgroupPartitionNV(dvec4);\n"
2874 
2875                 "double subgroupPartitionedAddNV(double, uvec4 ballot);\n"
2876                 "dvec2  subgroupPartitionedAddNV(dvec2, uvec4 ballot);\n"
2877                 "dvec3  subgroupPartitionedAddNV(dvec3, uvec4 ballot);\n"
2878                 "dvec4  subgroupPartitionedAddNV(dvec4, uvec4 ballot);\n"
2879 
2880                 "double subgroupPartitionedMulNV(double, uvec4 ballot);\n"
2881                 "dvec2  subgroupPartitionedMulNV(dvec2, uvec4 ballot);\n"
2882                 "dvec3  subgroupPartitionedMulNV(dvec3, uvec4 ballot);\n"
2883                 "dvec4  subgroupPartitionedMulNV(dvec4, uvec4 ballot);\n"
2884 
2885                 "double subgroupPartitionedMinNV(double, uvec4 ballot);\n"
2886                 "dvec2  subgroupPartitionedMinNV(dvec2, uvec4 ballot);\n"
2887                 "dvec3  subgroupPartitionedMinNV(dvec3, uvec4 ballot);\n"
2888                 "dvec4  subgroupPartitionedMinNV(dvec4, uvec4 ballot);\n"
2889 
2890                 "double subgroupPartitionedMaxNV(double, uvec4 ballot);\n"
2891                 "dvec2  subgroupPartitionedMaxNV(dvec2, uvec4 ballot);\n"
2892                 "dvec3  subgroupPartitionedMaxNV(dvec3, uvec4 ballot);\n"
2893                 "dvec4  subgroupPartitionedMaxNV(dvec4, uvec4 ballot);\n"
2894 
2895                 "double subgroupPartitionedInclusiveAddNV(double, uvec4 ballot);\n"
2896                 "dvec2  subgroupPartitionedInclusiveAddNV(dvec2, uvec4 ballot);\n"
2897                 "dvec3  subgroupPartitionedInclusiveAddNV(dvec3, uvec4 ballot);\n"
2898                 "dvec4  subgroupPartitionedInclusiveAddNV(dvec4, uvec4 ballot);\n"
2899 
2900                 "double subgroupPartitionedInclusiveMulNV(double, uvec4 ballot);\n"
2901                 "dvec2  subgroupPartitionedInclusiveMulNV(dvec2, uvec4 ballot);\n"
2902                 "dvec3  subgroupPartitionedInclusiveMulNV(dvec3, uvec4 ballot);\n"
2903                 "dvec4  subgroupPartitionedInclusiveMulNV(dvec4, uvec4 ballot);\n"
2904 
2905                 "double subgroupPartitionedInclusiveMinNV(double, uvec4 ballot);\n"
2906                 "dvec2  subgroupPartitionedInclusiveMinNV(dvec2, uvec4 ballot);\n"
2907                 "dvec3  subgroupPartitionedInclusiveMinNV(dvec3, uvec4 ballot);\n"
2908                 "dvec4  subgroupPartitionedInclusiveMinNV(dvec4, uvec4 ballot);\n"
2909 
2910                 "double subgroupPartitionedInclusiveMaxNV(double, uvec4 ballot);\n"
2911                 "dvec2  subgroupPartitionedInclusiveMaxNV(dvec2, uvec4 ballot);\n"
2912                 "dvec3  subgroupPartitionedInclusiveMaxNV(dvec3, uvec4 ballot);\n"
2913                 "dvec4  subgroupPartitionedInclusiveMaxNV(dvec4, uvec4 ballot);\n"
2914 
2915                 "double subgroupPartitionedExclusiveAddNV(double, uvec4 ballot);\n"
2916                 "dvec2  subgroupPartitionedExclusiveAddNV(dvec2, uvec4 ballot);\n"
2917                 "dvec3  subgroupPartitionedExclusiveAddNV(dvec3, uvec4 ballot);\n"
2918                 "dvec4  subgroupPartitionedExclusiveAddNV(dvec4, uvec4 ballot);\n"
2919 
2920                 "double subgroupPartitionedExclusiveMulNV(double, uvec4 ballot);\n"
2921                 "dvec2  subgroupPartitionedExclusiveMulNV(dvec2, uvec4 ballot);\n"
2922                 "dvec3  subgroupPartitionedExclusiveMulNV(dvec3, uvec4 ballot);\n"
2923                 "dvec4  subgroupPartitionedExclusiveMulNV(dvec4, uvec4 ballot);\n"
2924 
2925                 "double subgroupPartitionedExclusiveMinNV(double, uvec4 ballot);\n"
2926                 "dvec2  subgroupPartitionedExclusiveMinNV(dvec2, uvec4 ballot);\n"
2927                 "dvec3  subgroupPartitionedExclusiveMinNV(dvec3, uvec4 ballot);\n"
2928                 "dvec4  subgroupPartitionedExclusiveMinNV(dvec4, uvec4 ballot);\n"
2929 
2930                 "double subgroupPartitionedExclusiveMaxNV(double, uvec4 ballot);\n"
2931                 "dvec2  subgroupPartitionedExclusiveMaxNV(dvec2, uvec4 ballot);\n"
2932                 "dvec3  subgroupPartitionedExclusiveMaxNV(dvec3, uvec4 ballot);\n"
2933                 "dvec4  subgroupPartitionedExclusiveMaxNV(dvec4, uvec4 ballot);\n"
2934 #endif
2935 
2936                 "\n");
2937             }
2938 
2939         stageBuiltins[EShLangCompute].append(
2940             "void subgroupMemoryBarrierShared();"
2941 
2942             "\n"
2943             );
2944 #ifdef NV_EXTENSIONS
2945         stageBuiltins[EShLangMeshNV].append(
2946             "void subgroupMemoryBarrierShared();"
2947             "\n"
2948             );
2949         stageBuiltins[EShLangTaskNV].append(
2950             "void subgroupMemoryBarrierShared();"
2951             "\n"
2952             );
2953 #endif
2954     }
2955 
2956     if (profile != EEsProfile && version >= 460) {
2957         commonBuiltins.append(
2958             "bool anyInvocation(bool);"
2959             "bool allInvocations(bool);"
2960             "bool allInvocationsEqual(bool);"
2961 
2962             "\n");
2963     }
2964 
2965 #ifdef AMD_EXTENSIONS
2966     // GL_AMD_shader_ballot
2967     if (profile != EEsProfile && version >= 450) {
2968         commonBuiltins.append(
2969             "float minInvocationsAMD(float);"
2970             "vec2  minInvocationsAMD(vec2);"
2971             "vec3  minInvocationsAMD(vec3);"
2972             "vec4  minInvocationsAMD(vec4);"
2973 
2974             "int   minInvocationsAMD(int);"
2975             "ivec2 minInvocationsAMD(ivec2);"
2976             "ivec3 minInvocationsAMD(ivec3);"
2977             "ivec4 minInvocationsAMD(ivec4);"
2978 
2979             "uint  minInvocationsAMD(uint);"
2980             "uvec2 minInvocationsAMD(uvec2);"
2981             "uvec3 minInvocationsAMD(uvec3);"
2982             "uvec4 minInvocationsAMD(uvec4);"
2983 
2984             "double minInvocationsAMD(double);"
2985             "dvec2  minInvocationsAMD(dvec2);"
2986             "dvec3  minInvocationsAMD(dvec3);"
2987             "dvec4  minInvocationsAMD(dvec4);"
2988 
2989             "int64_t minInvocationsAMD(int64_t);"
2990             "i64vec2 minInvocationsAMD(i64vec2);"
2991             "i64vec3 minInvocationsAMD(i64vec3);"
2992             "i64vec4 minInvocationsAMD(i64vec4);"
2993 
2994             "uint64_t minInvocationsAMD(uint64_t);"
2995             "u64vec2  minInvocationsAMD(u64vec2);"
2996             "u64vec3  minInvocationsAMD(u64vec3);"
2997             "u64vec4  minInvocationsAMD(u64vec4);"
2998 
2999             "float16_t minInvocationsAMD(float16_t);"
3000             "f16vec2   minInvocationsAMD(f16vec2);"
3001             "f16vec3   minInvocationsAMD(f16vec3);"
3002             "f16vec4   minInvocationsAMD(f16vec4);"
3003 
3004             "int16_t minInvocationsAMD(int16_t);"
3005             "i16vec2 minInvocationsAMD(i16vec2);"
3006             "i16vec3 minInvocationsAMD(i16vec3);"
3007             "i16vec4 minInvocationsAMD(i16vec4);"
3008 
3009             "uint16_t minInvocationsAMD(uint16_t);"
3010             "u16vec2  minInvocationsAMD(u16vec2);"
3011             "u16vec3  minInvocationsAMD(u16vec3);"
3012             "u16vec4  minInvocationsAMD(u16vec4);"
3013 
3014             "float minInvocationsInclusiveScanAMD(float);"
3015             "vec2  minInvocationsInclusiveScanAMD(vec2);"
3016             "vec3  minInvocationsInclusiveScanAMD(vec3);"
3017             "vec4  minInvocationsInclusiveScanAMD(vec4);"
3018 
3019             "int   minInvocationsInclusiveScanAMD(int);"
3020             "ivec2 minInvocationsInclusiveScanAMD(ivec2);"
3021             "ivec3 minInvocationsInclusiveScanAMD(ivec3);"
3022             "ivec4 minInvocationsInclusiveScanAMD(ivec4);"
3023 
3024             "uint  minInvocationsInclusiveScanAMD(uint);"
3025             "uvec2 minInvocationsInclusiveScanAMD(uvec2);"
3026             "uvec3 minInvocationsInclusiveScanAMD(uvec3);"
3027             "uvec4 minInvocationsInclusiveScanAMD(uvec4);"
3028 
3029             "double minInvocationsInclusiveScanAMD(double);"
3030             "dvec2  minInvocationsInclusiveScanAMD(dvec2);"
3031             "dvec3  minInvocationsInclusiveScanAMD(dvec3);"
3032             "dvec4  minInvocationsInclusiveScanAMD(dvec4);"
3033 
3034             "int64_t minInvocationsInclusiveScanAMD(int64_t);"
3035             "i64vec2 minInvocationsInclusiveScanAMD(i64vec2);"
3036             "i64vec3 minInvocationsInclusiveScanAMD(i64vec3);"
3037             "i64vec4 minInvocationsInclusiveScanAMD(i64vec4);"
3038 
3039             "uint64_t minInvocationsInclusiveScanAMD(uint64_t);"
3040             "u64vec2  minInvocationsInclusiveScanAMD(u64vec2);"
3041             "u64vec3  minInvocationsInclusiveScanAMD(u64vec3);"
3042             "u64vec4  minInvocationsInclusiveScanAMD(u64vec4);"
3043 
3044             "float16_t minInvocationsInclusiveScanAMD(float16_t);"
3045             "f16vec2   minInvocationsInclusiveScanAMD(f16vec2);"
3046             "f16vec3   minInvocationsInclusiveScanAMD(f16vec3);"
3047             "f16vec4   minInvocationsInclusiveScanAMD(f16vec4);"
3048 
3049             "int16_t minInvocationsInclusiveScanAMD(int16_t);"
3050             "i16vec2 minInvocationsInclusiveScanAMD(i16vec2);"
3051             "i16vec3 minInvocationsInclusiveScanAMD(i16vec3);"
3052             "i16vec4 minInvocationsInclusiveScanAMD(i16vec4);"
3053 
3054             "uint16_t minInvocationsInclusiveScanAMD(uint16_t);"
3055             "u16vec2  minInvocationsInclusiveScanAMD(u16vec2);"
3056             "u16vec3  minInvocationsInclusiveScanAMD(u16vec3);"
3057             "u16vec4  minInvocationsInclusiveScanAMD(u16vec4);"
3058 
3059             "float minInvocationsExclusiveScanAMD(float);"
3060             "vec2  minInvocationsExclusiveScanAMD(vec2);"
3061             "vec3  minInvocationsExclusiveScanAMD(vec3);"
3062             "vec4  minInvocationsExclusiveScanAMD(vec4);"
3063 
3064             "int   minInvocationsExclusiveScanAMD(int);"
3065             "ivec2 minInvocationsExclusiveScanAMD(ivec2);"
3066             "ivec3 minInvocationsExclusiveScanAMD(ivec3);"
3067             "ivec4 minInvocationsExclusiveScanAMD(ivec4);"
3068 
3069             "uint  minInvocationsExclusiveScanAMD(uint);"
3070             "uvec2 minInvocationsExclusiveScanAMD(uvec2);"
3071             "uvec3 minInvocationsExclusiveScanAMD(uvec3);"
3072             "uvec4 minInvocationsExclusiveScanAMD(uvec4);"
3073 
3074             "double minInvocationsExclusiveScanAMD(double);"
3075             "dvec2  minInvocationsExclusiveScanAMD(dvec2);"
3076             "dvec3  minInvocationsExclusiveScanAMD(dvec3);"
3077             "dvec4  minInvocationsExclusiveScanAMD(dvec4);"
3078 
3079             "int64_t minInvocationsExclusiveScanAMD(int64_t);"
3080             "i64vec2 minInvocationsExclusiveScanAMD(i64vec2);"
3081             "i64vec3 minInvocationsExclusiveScanAMD(i64vec3);"
3082             "i64vec4 minInvocationsExclusiveScanAMD(i64vec4);"
3083 
3084             "uint64_t minInvocationsExclusiveScanAMD(uint64_t);"
3085             "u64vec2  minInvocationsExclusiveScanAMD(u64vec2);"
3086             "u64vec3  minInvocationsExclusiveScanAMD(u64vec3);"
3087             "u64vec4  minInvocationsExclusiveScanAMD(u64vec4);"
3088 
3089             "float16_t minInvocationsExclusiveScanAMD(float16_t);"
3090             "f16vec2   minInvocationsExclusiveScanAMD(f16vec2);"
3091             "f16vec3   minInvocationsExclusiveScanAMD(f16vec3);"
3092             "f16vec4   minInvocationsExclusiveScanAMD(f16vec4);"
3093 
3094             "int16_t minInvocationsExclusiveScanAMD(int16_t);"
3095             "i16vec2 minInvocationsExclusiveScanAMD(i16vec2);"
3096             "i16vec3 minInvocationsExclusiveScanAMD(i16vec3);"
3097             "i16vec4 minInvocationsExclusiveScanAMD(i16vec4);"
3098 
3099             "uint16_t minInvocationsExclusiveScanAMD(uint16_t);"
3100             "u16vec2  minInvocationsExclusiveScanAMD(u16vec2);"
3101             "u16vec3  minInvocationsExclusiveScanAMD(u16vec3);"
3102             "u16vec4  minInvocationsExclusiveScanAMD(u16vec4);"
3103 
3104             "float maxInvocationsAMD(float);"
3105             "vec2  maxInvocationsAMD(vec2);"
3106             "vec3  maxInvocationsAMD(vec3);"
3107             "vec4  maxInvocationsAMD(vec4);"
3108 
3109             "int   maxInvocationsAMD(int);"
3110             "ivec2 maxInvocationsAMD(ivec2);"
3111             "ivec3 maxInvocationsAMD(ivec3);"
3112             "ivec4 maxInvocationsAMD(ivec4);"
3113 
3114             "uint  maxInvocationsAMD(uint);"
3115             "uvec2 maxInvocationsAMD(uvec2);"
3116             "uvec3 maxInvocationsAMD(uvec3);"
3117             "uvec4 maxInvocationsAMD(uvec4);"
3118 
3119             "double maxInvocationsAMD(double);"
3120             "dvec2  maxInvocationsAMD(dvec2);"
3121             "dvec3  maxInvocationsAMD(dvec3);"
3122             "dvec4  maxInvocationsAMD(dvec4);"
3123 
3124             "int64_t maxInvocationsAMD(int64_t);"
3125             "i64vec2 maxInvocationsAMD(i64vec2);"
3126             "i64vec3 maxInvocationsAMD(i64vec3);"
3127             "i64vec4 maxInvocationsAMD(i64vec4);"
3128 
3129             "uint64_t maxInvocationsAMD(uint64_t);"
3130             "u64vec2  maxInvocationsAMD(u64vec2);"
3131             "u64vec3  maxInvocationsAMD(u64vec3);"
3132             "u64vec4  maxInvocationsAMD(u64vec4);"
3133 
3134             "float16_t maxInvocationsAMD(float16_t);"
3135             "f16vec2   maxInvocationsAMD(f16vec2);"
3136             "f16vec3   maxInvocationsAMD(f16vec3);"
3137             "f16vec4   maxInvocationsAMD(f16vec4);"
3138 
3139             "int16_t maxInvocationsAMD(int16_t);"
3140             "i16vec2 maxInvocationsAMD(i16vec2);"
3141             "i16vec3 maxInvocationsAMD(i16vec3);"
3142             "i16vec4 maxInvocationsAMD(i16vec4);"
3143 
3144             "uint16_t maxInvocationsAMD(uint16_t);"
3145             "u16vec2  maxInvocationsAMD(u16vec2);"
3146             "u16vec3  maxInvocationsAMD(u16vec3);"
3147             "u16vec4  maxInvocationsAMD(u16vec4);"
3148 
3149             "float maxInvocationsInclusiveScanAMD(float);"
3150             "vec2  maxInvocationsInclusiveScanAMD(vec2);"
3151             "vec3  maxInvocationsInclusiveScanAMD(vec3);"
3152             "vec4  maxInvocationsInclusiveScanAMD(vec4);"
3153 
3154             "int   maxInvocationsInclusiveScanAMD(int);"
3155             "ivec2 maxInvocationsInclusiveScanAMD(ivec2);"
3156             "ivec3 maxInvocationsInclusiveScanAMD(ivec3);"
3157             "ivec4 maxInvocationsInclusiveScanAMD(ivec4);"
3158 
3159             "uint  maxInvocationsInclusiveScanAMD(uint);"
3160             "uvec2 maxInvocationsInclusiveScanAMD(uvec2);"
3161             "uvec3 maxInvocationsInclusiveScanAMD(uvec3);"
3162             "uvec4 maxInvocationsInclusiveScanAMD(uvec4);"
3163 
3164             "double maxInvocationsInclusiveScanAMD(double);"
3165             "dvec2  maxInvocationsInclusiveScanAMD(dvec2);"
3166             "dvec3  maxInvocationsInclusiveScanAMD(dvec3);"
3167             "dvec4  maxInvocationsInclusiveScanAMD(dvec4);"
3168 
3169             "int64_t maxInvocationsInclusiveScanAMD(int64_t);"
3170             "i64vec2 maxInvocationsInclusiveScanAMD(i64vec2);"
3171             "i64vec3 maxInvocationsInclusiveScanAMD(i64vec3);"
3172             "i64vec4 maxInvocationsInclusiveScanAMD(i64vec4);"
3173 
3174             "uint64_t maxInvocationsInclusiveScanAMD(uint64_t);"
3175             "u64vec2  maxInvocationsInclusiveScanAMD(u64vec2);"
3176             "u64vec3  maxInvocationsInclusiveScanAMD(u64vec3);"
3177             "u64vec4  maxInvocationsInclusiveScanAMD(u64vec4);"
3178 
3179             "float16_t maxInvocationsInclusiveScanAMD(float16_t);"
3180             "f16vec2   maxInvocationsInclusiveScanAMD(f16vec2);"
3181             "f16vec3   maxInvocationsInclusiveScanAMD(f16vec3);"
3182             "f16vec4   maxInvocationsInclusiveScanAMD(f16vec4);"
3183 
3184             "int16_t maxInvocationsInclusiveScanAMD(int16_t);"
3185             "i16vec2 maxInvocationsInclusiveScanAMD(i16vec2);"
3186             "i16vec3 maxInvocationsInclusiveScanAMD(i16vec3);"
3187             "i16vec4 maxInvocationsInclusiveScanAMD(i16vec4);"
3188 
3189             "uint16_t maxInvocationsInclusiveScanAMD(uint16_t);"
3190             "u16vec2  maxInvocationsInclusiveScanAMD(u16vec2);"
3191             "u16vec3  maxInvocationsInclusiveScanAMD(u16vec3);"
3192             "u16vec4  maxInvocationsInclusiveScanAMD(u16vec4);"
3193 
3194             "float maxInvocationsExclusiveScanAMD(float);"
3195             "vec2  maxInvocationsExclusiveScanAMD(vec2);"
3196             "vec3  maxInvocationsExclusiveScanAMD(vec3);"
3197             "vec4  maxInvocationsExclusiveScanAMD(vec4);"
3198 
3199             "int   maxInvocationsExclusiveScanAMD(int);"
3200             "ivec2 maxInvocationsExclusiveScanAMD(ivec2);"
3201             "ivec3 maxInvocationsExclusiveScanAMD(ivec3);"
3202             "ivec4 maxInvocationsExclusiveScanAMD(ivec4);"
3203 
3204             "uint  maxInvocationsExclusiveScanAMD(uint);"
3205             "uvec2 maxInvocationsExclusiveScanAMD(uvec2);"
3206             "uvec3 maxInvocationsExclusiveScanAMD(uvec3);"
3207             "uvec4 maxInvocationsExclusiveScanAMD(uvec4);"
3208 
3209             "double maxInvocationsExclusiveScanAMD(double);"
3210             "dvec2  maxInvocationsExclusiveScanAMD(dvec2);"
3211             "dvec3  maxInvocationsExclusiveScanAMD(dvec3);"
3212             "dvec4  maxInvocationsExclusiveScanAMD(dvec4);"
3213 
3214             "int64_t maxInvocationsExclusiveScanAMD(int64_t);"
3215             "i64vec2 maxInvocationsExclusiveScanAMD(i64vec2);"
3216             "i64vec3 maxInvocationsExclusiveScanAMD(i64vec3);"
3217             "i64vec4 maxInvocationsExclusiveScanAMD(i64vec4);"
3218 
3219             "uint64_t maxInvocationsExclusiveScanAMD(uint64_t);"
3220             "u64vec2  maxInvocationsExclusiveScanAMD(u64vec2);"
3221             "u64vec3  maxInvocationsExclusiveScanAMD(u64vec3);"
3222             "u64vec4  maxInvocationsExclusiveScanAMD(u64vec4);"
3223 
3224             "float16_t maxInvocationsExclusiveScanAMD(float16_t);"
3225             "f16vec2   maxInvocationsExclusiveScanAMD(f16vec2);"
3226             "f16vec3   maxInvocationsExclusiveScanAMD(f16vec3);"
3227             "f16vec4   maxInvocationsExclusiveScanAMD(f16vec4);"
3228 
3229             "int16_t maxInvocationsExclusiveScanAMD(int16_t);"
3230             "i16vec2 maxInvocationsExclusiveScanAMD(i16vec2);"
3231             "i16vec3 maxInvocationsExclusiveScanAMD(i16vec3);"
3232             "i16vec4 maxInvocationsExclusiveScanAMD(i16vec4);"
3233 
3234             "uint16_t maxInvocationsExclusiveScanAMD(uint16_t);"
3235             "u16vec2  maxInvocationsExclusiveScanAMD(u16vec2);"
3236             "u16vec3  maxInvocationsExclusiveScanAMD(u16vec3);"
3237             "u16vec4  maxInvocationsExclusiveScanAMD(u16vec4);"
3238 
3239             "float addInvocationsAMD(float);"
3240             "vec2  addInvocationsAMD(vec2);"
3241             "vec3  addInvocationsAMD(vec3);"
3242             "vec4  addInvocationsAMD(vec4);"
3243 
3244             "int   addInvocationsAMD(int);"
3245             "ivec2 addInvocationsAMD(ivec2);"
3246             "ivec3 addInvocationsAMD(ivec3);"
3247             "ivec4 addInvocationsAMD(ivec4);"
3248 
3249             "uint  addInvocationsAMD(uint);"
3250             "uvec2 addInvocationsAMD(uvec2);"
3251             "uvec3 addInvocationsAMD(uvec3);"
3252             "uvec4 addInvocationsAMD(uvec4);"
3253 
3254             "double  addInvocationsAMD(double);"
3255             "dvec2   addInvocationsAMD(dvec2);"
3256             "dvec3   addInvocationsAMD(dvec3);"
3257             "dvec4   addInvocationsAMD(dvec4);"
3258 
3259             "int64_t addInvocationsAMD(int64_t);"
3260             "i64vec2 addInvocationsAMD(i64vec2);"
3261             "i64vec3 addInvocationsAMD(i64vec3);"
3262             "i64vec4 addInvocationsAMD(i64vec4);"
3263 
3264             "uint64_t addInvocationsAMD(uint64_t);"
3265             "u64vec2  addInvocationsAMD(u64vec2);"
3266             "u64vec3  addInvocationsAMD(u64vec3);"
3267             "u64vec4  addInvocationsAMD(u64vec4);"
3268 
3269             "float16_t addInvocationsAMD(float16_t);"
3270             "f16vec2   addInvocationsAMD(f16vec2);"
3271             "f16vec3   addInvocationsAMD(f16vec3);"
3272             "f16vec4   addInvocationsAMD(f16vec4);"
3273 
3274             "int16_t addInvocationsAMD(int16_t);"
3275             "i16vec2 addInvocationsAMD(i16vec2);"
3276             "i16vec3 addInvocationsAMD(i16vec3);"
3277             "i16vec4 addInvocationsAMD(i16vec4);"
3278 
3279             "uint16_t addInvocationsAMD(uint16_t);"
3280             "u16vec2  addInvocationsAMD(u16vec2);"
3281             "u16vec3  addInvocationsAMD(u16vec3);"
3282             "u16vec4  addInvocationsAMD(u16vec4);"
3283 
3284             "float addInvocationsInclusiveScanAMD(float);"
3285             "vec2  addInvocationsInclusiveScanAMD(vec2);"
3286             "vec3  addInvocationsInclusiveScanAMD(vec3);"
3287             "vec4  addInvocationsInclusiveScanAMD(vec4);"
3288 
3289             "int   addInvocationsInclusiveScanAMD(int);"
3290             "ivec2 addInvocationsInclusiveScanAMD(ivec2);"
3291             "ivec3 addInvocationsInclusiveScanAMD(ivec3);"
3292             "ivec4 addInvocationsInclusiveScanAMD(ivec4);"
3293 
3294             "uint  addInvocationsInclusiveScanAMD(uint);"
3295             "uvec2 addInvocationsInclusiveScanAMD(uvec2);"
3296             "uvec3 addInvocationsInclusiveScanAMD(uvec3);"
3297             "uvec4 addInvocationsInclusiveScanAMD(uvec4);"
3298 
3299             "double  addInvocationsInclusiveScanAMD(double);"
3300             "dvec2   addInvocationsInclusiveScanAMD(dvec2);"
3301             "dvec3   addInvocationsInclusiveScanAMD(dvec3);"
3302             "dvec4   addInvocationsInclusiveScanAMD(dvec4);"
3303 
3304             "int64_t addInvocationsInclusiveScanAMD(int64_t);"
3305             "i64vec2 addInvocationsInclusiveScanAMD(i64vec2);"
3306             "i64vec3 addInvocationsInclusiveScanAMD(i64vec3);"
3307             "i64vec4 addInvocationsInclusiveScanAMD(i64vec4);"
3308 
3309             "uint64_t addInvocationsInclusiveScanAMD(uint64_t);"
3310             "u64vec2  addInvocationsInclusiveScanAMD(u64vec2);"
3311             "u64vec3  addInvocationsInclusiveScanAMD(u64vec3);"
3312             "u64vec4  addInvocationsInclusiveScanAMD(u64vec4);"
3313 
3314             "float16_t addInvocationsInclusiveScanAMD(float16_t);"
3315             "f16vec2   addInvocationsInclusiveScanAMD(f16vec2);"
3316             "f16vec3   addInvocationsInclusiveScanAMD(f16vec3);"
3317             "f16vec4   addInvocationsInclusiveScanAMD(f16vec4);"
3318 
3319             "int16_t addInvocationsInclusiveScanAMD(int16_t);"
3320             "i16vec2 addInvocationsInclusiveScanAMD(i16vec2);"
3321             "i16vec3 addInvocationsInclusiveScanAMD(i16vec3);"
3322             "i16vec4 addInvocationsInclusiveScanAMD(i16vec4);"
3323 
3324             "uint16_t addInvocationsInclusiveScanAMD(uint16_t);"
3325             "u16vec2  addInvocationsInclusiveScanAMD(u16vec2);"
3326             "u16vec3  addInvocationsInclusiveScanAMD(u16vec3);"
3327             "u16vec4  addInvocationsInclusiveScanAMD(u16vec4);"
3328 
3329             "float addInvocationsExclusiveScanAMD(float);"
3330             "vec2  addInvocationsExclusiveScanAMD(vec2);"
3331             "vec3  addInvocationsExclusiveScanAMD(vec3);"
3332             "vec4  addInvocationsExclusiveScanAMD(vec4);"
3333 
3334             "int   addInvocationsExclusiveScanAMD(int);"
3335             "ivec2 addInvocationsExclusiveScanAMD(ivec2);"
3336             "ivec3 addInvocationsExclusiveScanAMD(ivec3);"
3337             "ivec4 addInvocationsExclusiveScanAMD(ivec4);"
3338 
3339             "uint  addInvocationsExclusiveScanAMD(uint);"
3340             "uvec2 addInvocationsExclusiveScanAMD(uvec2);"
3341             "uvec3 addInvocationsExclusiveScanAMD(uvec3);"
3342             "uvec4 addInvocationsExclusiveScanAMD(uvec4);"
3343 
3344             "double  addInvocationsExclusiveScanAMD(double);"
3345             "dvec2   addInvocationsExclusiveScanAMD(dvec2);"
3346             "dvec3   addInvocationsExclusiveScanAMD(dvec3);"
3347             "dvec4   addInvocationsExclusiveScanAMD(dvec4);"
3348 
3349             "int64_t addInvocationsExclusiveScanAMD(int64_t);"
3350             "i64vec2 addInvocationsExclusiveScanAMD(i64vec2);"
3351             "i64vec3 addInvocationsExclusiveScanAMD(i64vec3);"
3352             "i64vec4 addInvocationsExclusiveScanAMD(i64vec4);"
3353 
3354             "uint64_t addInvocationsExclusiveScanAMD(uint64_t);"
3355             "u64vec2  addInvocationsExclusiveScanAMD(u64vec2);"
3356             "u64vec3  addInvocationsExclusiveScanAMD(u64vec3);"
3357             "u64vec4  addInvocationsExclusiveScanAMD(u64vec4);"
3358 
3359             "float16_t addInvocationsExclusiveScanAMD(float16_t);"
3360             "f16vec2   addInvocationsExclusiveScanAMD(f16vec2);"
3361             "f16vec3   addInvocationsExclusiveScanAMD(f16vec3);"
3362             "f16vec4   addInvocationsExclusiveScanAMD(f16vec4);"
3363 
3364             "int16_t addInvocationsExclusiveScanAMD(int16_t);"
3365             "i16vec2 addInvocationsExclusiveScanAMD(i16vec2);"
3366             "i16vec3 addInvocationsExclusiveScanAMD(i16vec3);"
3367             "i16vec4 addInvocationsExclusiveScanAMD(i16vec4);"
3368 
3369             "uint16_t addInvocationsExclusiveScanAMD(uint16_t);"
3370             "u16vec2  addInvocationsExclusiveScanAMD(u16vec2);"
3371             "u16vec3  addInvocationsExclusiveScanAMD(u16vec3);"
3372             "u16vec4  addInvocationsExclusiveScanAMD(u16vec4);"
3373 
3374             "float minInvocationsNonUniformAMD(float);"
3375             "vec2  minInvocationsNonUniformAMD(vec2);"
3376             "vec3  minInvocationsNonUniformAMD(vec3);"
3377             "vec4  minInvocationsNonUniformAMD(vec4);"
3378 
3379             "int   minInvocationsNonUniformAMD(int);"
3380             "ivec2 minInvocationsNonUniformAMD(ivec2);"
3381             "ivec3 minInvocationsNonUniformAMD(ivec3);"
3382             "ivec4 minInvocationsNonUniformAMD(ivec4);"
3383 
3384             "uint  minInvocationsNonUniformAMD(uint);"
3385             "uvec2 minInvocationsNonUniformAMD(uvec2);"
3386             "uvec3 minInvocationsNonUniformAMD(uvec3);"
3387             "uvec4 minInvocationsNonUniformAMD(uvec4);"
3388 
3389             "double minInvocationsNonUniformAMD(double);"
3390             "dvec2  minInvocationsNonUniformAMD(dvec2);"
3391             "dvec3  minInvocationsNonUniformAMD(dvec3);"
3392             "dvec4  minInvocationsNonUniformAMD(dvec4);"
3393 
3394             "int64_t minInvocationsNonUniformAMD(int64_t);"
3395             "i64vec2 minInvocationsNonUniformAMD(i64vec2);"
3396             "i64vec3 minInvocationsNonUniformAMD(i64vec3);"
3397             "i64vec4 minInvocationsNonUniformAMD(i64vec4);"
3398 
3399             "uint64_t minInvocationsNonUniformAMD(uint64_t);"
3400             "u64vec2  minInvocationsNonUniformAMD(u64vec2);"
3401             "u64vec3  minInvocationsNonUniformAMD(u64vec3);"
3402             "u64vec4  minInvocationsNonUniformAMD(u64vec4);"
3403 
3404             "float16_t minInvocationsNonUniformAMD(float16_t);"
3405             "f16vec2   minInvocationsNonUniformAMD(f16vec2);"
3406             "f16vec3   minInvocationsNonUniformAMD(f16vec3);"
3407             "f16vec4   minInvocationsNonUniformAMD(f16vec4);"
3408 
3409             "int16_t minInvocationsNonUniformAMD(int16_t);"
3410             "i16vec2 minInvocationsNonUniformAMD(i16vec2);"
3411             "i16vec3 minInvocationsNonUniformAMD(i16vec3);"
3412             "i16vec4 minInvocationsNonUniformAMD(i16vec4);"
3413 
3414             "uint16_t minInvocationsNonUniformAMD(uint16_t);"
3415             "u16vec2  minInvocationsNonUniformAMD(u16vec2);"
3416             "u16vec3  minInvocationsNonUniformAMD(u16vec3);"
3417             "u16vec4  minInvocationsNonUniformAMD(u16vec4);"
3418 
3419             "float minInvocationsInclusiveScanNonUniformAMD(float);"
3420             "vec2  minInvocationsInclusiveScanNonUniformAMD(vec2);"
3421             "vec3  minInvocationsInclusiveScanNonUniformAMD(vec3);"
3422             "vec4  minInvocationsInclusiveScanNonUniformAMD(vec4);"
3423 
3424             "int   minInvocationsInclusiveScanNonUniformAMD(int);"
3425             "ivec2 minInvocationsInclusiveScanNonUniformAMD(ivec2);"
3426             "ivec3 minInvocationsInclusiveScanNonUniformAMD(ivec3);"
3427             "ivec4 minInvocationsInclusiveScanNonUniformAMD(ivec4);"
3428 
3429             "uint  minInvocationsInclusiveScanNonUniformAMD(uint);"
3430             "uvec2 minInvocationsInclusiveScanNonUniformAMD(uvec2);"
3431             "uvec3 minInvocationsInclusiveScanNonUniformAMD(uvec3);"
3432             "uvec4 minInvocationsInclusiveScanNonUniformAMD(uvec4);"
3433 
3434             "double minInvocationsInclusiveScanNonUniformAMD(double);"
3435             "dvec2  minInvocationsInclusiveScanNonUniformAMD(dvec2);"
3436             "dvec3  minInvocationsInclusiveScanNonUniformAMD(dvec3);"
3437             "dvec4  minInvocationsInclusiveScanNonUniformAMD(dvec4);"
3438 
3439             "int64_t minInvocationsInclusiveScanNonUniformAMD(int64_t);"
3440             "i64vec2 minInvocationsInclusiveScanNonUniformAMD(i64vec2);"
3441             "i64vec3 minInvocationsInclusiveScanNonUniformAMD(i64vec3);"
3442             "i64vec4 minInvocationsInclusiveScanNonUniformAMD(i64vec4);"
3443 
3444             "uint64_t minInvocationsInclusiveScanNonUniformAMD(uint64_t);"
3445             "u64vec2  minInvocationsInclusiveScanNonUniformAMD(u64vec2);"
3446             "u64vec3  minInvocationsInclusiveScanNonUniformAMD(u64vec3);"
3447             "u64vec4  minInvocationsInclusiveScanNonUniformAMD(u64vec4);"
3448 
3449             "float16_t minInvocationsInclusiveScanNonUniformAMD(float16_t);"
3450             "f16vec2   minInvocationsInclusiveScanNonUniformAMD(f16vec2);"
3451             "f16vec3   minInvocationsInclusiveScanNonUniformAMD(f16vec3);"
3452             "f16vec4   minInvocationsInclusiveScanNonUniformAMD(f16vec4);"
3453 
3454             "int16_t minInvocationsInclusiveScanNonUniformAMD(int16_t);"
3455             "i16vec2 minInvocationsInclusiveScanNonUniformAMD(i16vec2);"
3456             "i16vec3 minInvocationsInclusiveScanNonUniformAMD(i16vec3);"
3457             "i16vec4 minInvocationsInclusiveScanNonUniformAMD(i16vec4);"
3458 
3459             "uint16_t minInvocationsInclusiveScanNonUniformAMD(uint16_t);"
3460             "u16vec2  minInvocationsInclusiveScanNonUniformAMD(u16vec2);"
3461             "u16vec3  minInvocationsInclusiveScanNonUniformAMD(u16vec3);"
3462             "u16vec4  minInvocationsInclusiveScanNonUniformAMD(u16vec4);"
3463 
3464             "float minInvocationsExclusiveScanNonUniformAMD(float);"
3465             "vec2  minInvocationsExclusiveScanNonUniformAMD(vec2);"
3466             "vec3  minInvocationsExclusiveScanNonUniformAMD(vec3);"
3467             "vec4  minInvocationsExclusiveScanNonUniformAMD(vec4);"
3468 
3469             "int   minInvocationsExclusiveScanNonUniformAMD(int);"
3470             "ivec2 minInvocationsExclusiveScanNonUniformAMD(ivec2);"
3471             "ivec3 minInvocationsExclusiveScanNonUniformAMD(ivec3);"
3472             "ivec4 minInvocationsExclusiveScanNonUniformAMD(ivec4);"
3473 
3474             "uint  minInvocationsExclusiveScanNonUniformAMD(uint);"
3475             "uvec2 minInvocationsExclusiveScanNonUniformAMD(uvec2);"
3476             "uvec3 minInvocationsExclusiveScanNonUniformAMD(uvec3);"
3477             "uvec4 minInvocationsExclusiveScanNonUniformAMD(uvec4);"
3478 
3479             "double minInvocationsExclusiveScanNonUniformAMD(double);"
3480             "dvec2  minInvocationsExclusiveScanNonUniformAMD(dvec2);"
3481             "dvec3  minInvocationsExclusiveScanNonUniformAMD(dvec3);"
3482             "dvec4  minInvocationsExclusiveScanNonUniformAMD(dvec4);"
3483 
3484             "int64_t minInvocationsExclusiveScanNonUniformAMD(int64_t);"
3485             "i64vec2 minInvocationsExclusiveScanNonUniformAMD(i64vec2);"
3486             "i64vec3 minInvocationsExclusiveScanNonUniformAMD(i64vec3);"
3487             "i64vec4 minInvocationsExclusiveScanNonUniformAMD(i64vec4);"
3488 
3489             "uint64_t minInvocationsExclusiveScanNonUniformAMD(uint64_t);"
3490             "u64vec2  minInvocationsExclusiveScanNonUniformAMD(u64vec2);"
3491             "u64vec3  minInvocationsExclusiveScanNonUniformAMD(u64vec3);"
3492             "u64vec4  minInvocationsExclusiveScanNonUniformAMD(u64vec4);"
3493 
3494             "float16_t minInvocationsExclusiveScanNonUniformAMD(float16_t);"
3495             "f16vec2   minInvocationsExclusiveScanNonUniformAMD(f16vec2);"
3496             "f16vec3   minInvocationsExclusiveScanNonUniformAMD(f16vec3);"
3497             "f16vec4   minInvocationsExclusiveScanNonUniformAMD(f16vec4);"
3498 
3499             "int16_t minInvocationsExclusiveScanNonUniformAMD(int16_t);"
3500             "i16vec2 minInvocationsExclusiveScanNonUniformAMD(i16vec2);"
3501             "i16vec3 minInvocationsExclusiveScanNonUniformAMD(i16vec3);"
3502             "i16vec4 minInvocationsExclusiveScanNonUniformAMD(i16vec4);"
3503 
3504             "uint16_t minInvocationsExclusiveScanNonUniformAMD(uint16_t);"
3505             "u16vec2  minInvocationsExclusiveScanNonUniformAMD(u16vec2);"
3506             "u16vec3  minInvocationsExclusiveScanNonUniformAMD(u16vec3);"
3507             "u16vec4  minInvocationsExclusiveScanNonUniformAMD(u16vec4);"
3508 
3509             "float maxInvocationsNonUniformAMD(float);"
3510             "vec2  maxInvocationsNonUniformAMD(vec2);"
3511             "vec3  maxInvocationsNonUniformAMD(vec3);"
3512             "vec4  maxInvocationsNonUniformAMD(vec4);"
3513 
3514             "int   maxInvocationsNonUniformAMD(int);"
3515             "ivec2 maxInvocationsNonUniformAMD(ivec2);"
3516             "ivec3 maxInvocationsNonUniformAMD(ivec3);"
3517             "ivec4 maxInvocationsNonUniformAMD(ivec4);"
3518 
3519             "uint  maxInvocationsNonUniformAMD(uint);"
3520             "uvec2 maxInvocationsNonUniformAMD(uvec2);"
3521             "uvec3 maxInvocationsNonUniformAMD(uvec3);"
3522             "uvec4 maxInvocationsNonUniformAMD(uvec4);"
3523 
3524             "double maxInvocationsNonUniformAMD(double);"
3525             "dvec2  maxInvocationsNonUniformAMD(dvec2);"
3526             "dvec3  maxInvocationsNonUniformAMD(dvec3);"
3527             "dvec4  maxInvocationsNonUniformAMD(dvec4);"
3528 
3529             "int64_t maxInvocationsNonUniformAMD(int64_t);"
3530             "i64vec2 maxInvocationsNonUniformAMD(i64vec2);"
3531             "i64vec3 maxInvocationsNonUniformAMD(i64vec3);"
3532             "i64vec4 maxInvocationsNonUniformAMD(i64vec4);"
3533 
3534             "uint64_t maxInvocationsNonUniformAMD(uint64_t);"
3535             "u64vec2  maxInvocationsNonUniformAMD(u64vec2);"
3536             "u64vec3  maxInvocationsNonUniformAMD(u64vec3);"
3537             "u64vec4  maxInvocationsNonUniformAMD(u64vec4);"
3538 
3539             "float16_t maxInvocationsNonUniformAMD(float16_t);"
3540             "f16vec2   maxInvocationsNonUniformAMD(f16vec2);"
3541             "f16vec3   maxInvocationsNonUniformAMD(f16vec3);"
3542             "f16vec4   maxInvocationsNonUniformAMD(f16vec4);"
3543 
3544             "int16_t maxInvocationsNonUniformAMD(int16_t);"
3545             "i16vec2 maxInvocationsNonUniformAMD(i16vec2);"
3546             "i16vec3 maxInvocationsNonUniformAMD(i16vec3);"
3547             "i16vec4 maxInvocationsNonUniformAMD(i16vec4);"
3548 
3549             "uint16_t maxInvocationsNonUniformAMD(uint16_t);"
3550             "u16vec2  maxInvocationsNonUniformAMD(u16vec2);"
3551             "u16vec3  maxInvocationsNonUniformAMD(u16vec3);"
3552             "u16vec4  maxInvocationsNonUniformAMD(u16vec4);"
3553 
3554             "float maxInvocationsInclusiveScanNonUniformAMD(float);"
3555             "vec2  maxInvocationsInclusiveScanNonUniformAMD(vec2);"
3556             "vec3  maxInvocationsInclusiveScanNonUniformAMD(vec3);"
3557             "vec4  maxInvocationsInclusiveScanNonUniformAMD(vec4);"
3558 
3559             "int   maxInvocationsInclusiveScanNonUniformAMD(int);"
3560             "ivec2 maxInvocationsInclusiveScanNonUniformAMD(ivec2);"
3561             "ivec3 maxInvocationsInclusiveScanNonUniformAMD(ivec3);"
3562             "ivec4 maxInvocationsInclusiveScanNonUniformAMD(ivec4);"
3563 
3564             "uint  maxInvocationsInclusiveScanNonUniformAMD(uint);"
3565             "uvec2 maxInvocationsInclusiveScanNonUniformAMD(uvec2);"
3566             "uvec3 maxInvocationsInclusiveScanNonUniformAMD(uvec3);"
3567             "uvec4 maxInvocationsInclusiveScanNonUniformAMD(uvec4);"
3568 
3569             "double maxInvocationsInclusiveScanNonUniformAMD(double);"
3570             "dvec2  maxInvocationsInclusiveScanNonUniformAMD(dvec2);"
3571             "dvec3  maxInvocationsInclusiveScanNonUniformAMD(dvec3);"
3572             "dvec4  maxInvocationsInclusiveScanNonUniformAMD(dvec4);"
3573 
3574             "int64_t maxInvocationsInclusiveScanNonUniformAMD(int64_t);"
3575             "i64vec2 maxInvocationsInclusiveScanNonUniformAMD(i64vec2);"
3576             "i64vec3 maxInvocationsInclusiveScanNonUniformAMD(i64vec3);"
3577             "i64vec4 maxInvocationsInclusiveScanNonUniformAMD(i64vec4);"
3578 
3579             "uint64_t maxInvocationsInclusiveScanNonUniformAMD(uint64_t);"
3580             "u64vec2  maxInvocationsInclusiveScanNonUniformAMD(u64vec2);"
3581             "u64vec3  maxInvocationsInclusiveScanNonUniformAMD(u64vec3);"
3582             "u64vec4  maxInvocationsInclusiveScanNonUniformAMD(u64vec4);"
3583 
3584             "float16_t maxInvocationsInclusiveScanNonUniformAMD(float16_t);"
3585             "f16vec2   maxInvocationsInclusiveScanNonUniformAMD(f16vec2);"
3586             "f16vec3   maxInvocationsInclusiveScanNonUniformAMD(f16vec3);"
3587             "f16vec4   maxInvocationsInclusiveScanNonUniformAMD(f16vec4);"
3588 
3589             "int16_t maxInvocationsInclusiveScanNonUniformAMD(int16_t);"
3590             "i16vec2 maxInvocationsInclusiveScanNonUniformAMD(i16vec2);"
3591             "i16vec3 maxInvocationsInclusiveScanNonUniformAMD(i16vec3);"
3592             "i16vec4 maxInvocationsInclusiveScanNonUniformAMD(i16vec4);"
3593 
3594             "uint16_t maxInvocationsInclusiveScanNonUniformAMD(uint16_t);"
3595             "u16vec2  maxInvocationsInclusiveScanNonUniformAMD(u16vec2);"
3596             "u16vec3  maxInvocationsInclusiveScanNonUniformAMD(u16vec3);"
3597             "u16vec4  maxInvocationsInclusiveScanNonUniformAMD(u16vec4);"
3598 
3599             "float maxInvocationsExclusiveScanNonUniformAMD(float);"
3600             "vec2  maxInvocationsExclusiveScanNonUniformAMD(vec2);"
3601             "vec3  maxInvocationsExclusiveScanNonUniformAMD(vec3);"
3602             "vec4  maxInvocationsExclusiveScanNonUniformAMD(vec4);"
3603 
3604             "int   maxInvocationsExclusiveScanNonUniformAMD(int);"
3605             "ivec2 maxInvocationsExclusiveScanNonUniformAMD(ivec2);"
3606             "ivec3 maxInvocationsExclusiveScanNonUniformAMD(ivec3);"
3607             "ivec4 maxInvocationsExclusiveScanNonUniformAMD(ivec4);"
3608 
3609             "uint  maxInvocationsExclusiveScanNonUniformAMD(uint);"
3610             "uvec2 maxInvocationsExclusiveScanNonUniformAMD(uvec2);"
3611             "uvec3 maxInvocationsExclusiveScanNonUniformAMD(uvec3);"
3612             "uvec4 maxInvocationsExclusiveScanNonUniformAMD(uvec4);"
3613 
3614             "double maxInvocationsExclusiveScanNonUniformAMD(double);"
3615             "dvec2  maxInvocationsExclusiveScanNonUniformAMD(dvec2);"
3616             "dvec3  maxInvocationsExclusiveScanNonUniformAMD(dvec3);"
3617             "dvec4  maxInvocationsExclusiveScanNonUniformAMD(dvec4);"
3618 
3619             "int64_t maxInvocationsExclusiveScanNonUniformAMD(int64_t);"
3620             "i64vec2 maxInvocationsExclusiveScanNonUniformAMD(i64vec2);"
3621             "i64vec3 maxInvocationsExclusiveScanNonUniformAMD(i64vec3);"
3622             "i64vec4 maxInvocationsExclusiveScanNonUniformAMD(i64vec4);"
3623 
3624             "uint64_t maxInvocationsExclusiveScanNonUniformAMD(uint64_t);"
3625             "u64vec2  maxInvocationsExclusiveScanNonUniformAMD(u64vec2);"
3626             "u64vec3  maxInvocationsExclusiveScanNonUniformAMD(u64vec3);"
3627             "u64vec4  maxInvocationsExclusiveScanNonUniformAMD(u64vec4);"
3628 
3629             "float16_t maxInvocationsExclusiveScanNonUniformAMD(float16_t);"
3630             "f16vec2   maxInvocationsExclusiveScanNonUniformAMD(f16vec2);"
3631             "f16vec3   maxInvocationsExclusiveScanNonUniformAMD(f16vec3);"
3632             "f16vec4   maxInvocationsExclusiveScanNonUniformAMD(f16vec4);"
3633 
3634             "int16_t maxInvocationsExclusiveScanNonUniformAMD(int16_t);"
3635             "i16vec2 maxInvocationsExclusiveScanNonUniformAMD(i16vec2);"
3636             "i16vec3 maxInvocationsExclusiveScanNonUniformAMD(i16vec3);"
3637             "i16vec4 maxInvocationsExclusiveScanNonUniformAMD(i16vec4);"
3638 
3639             "uint16_t maxInvocationsExclusiveScanNonUniformAMD(uint16_t);"
3640             "u16vec2  maxInvocationsExclusiveScanNonUniformAMD(u16vec2);"
3641             "u16vec3  maxInvocationsExclusiveScanNonUniformAMD(u16vec3);"
3642             "u16vec4  maxInvocationsExclusiveScanNonUniformAMD(u16vec4);"
3643 
3644             "float addInvocationsNonUniformAMD(float);"
3645             "vec2  addInvocationsNonUniformAMD(vec2);"
3646             "vec3  addInvocationsNonUniformAMD(vec3);"
3647             "vec4  addInvocationsNonUniformAMD(vec4);"
3648 
3649             "int   addInvocationsNonUniformAMD(int);"
3650             "ivec2 addInvocationsNonUniformAMD(ivec2);"
3651             "ivec3 addInvocationsNonUniformAMD(ivec3);"
3652             "ivec4 addInvocationsNonUniformAMD(ivec4);"
3653 
3654             "uint  addInvocationsNonUniformAMD(uint);"
3655             "uvec2 addInvocationsNonUniformAMD(uvec2);"
3656             "uvec3 addInvocationsNonUniformAMD(uvec3);"
3657             "uvec4 addInvocationsNonUniformAMD(uvec4);"
3658 
3659             "double addInvocationsNonUniformAMD(double);"
3660             "dvec2  addInvocationsNonUniformAMD(dvec2);"
3661             "dvec3  addInvocationsNonUniformAMD(dvec3);"
3662             "dvec4  addInvocationsNonUniformAMD(dvec4);"
3663 
3664             "int64_t addInvocationsNonUniformAMD(int64_t);"
3665             "i64vec2 addInvocationsNonUniformAMD(i64vec2);"
3666             "i64vec3 addInvocationsNonUniformAMD(i64vec3);"
3667             "i64vec4 addInvocationsNonUniformAMD(i64vec4);"
3668 
3669             "uint64_t addInvocationsNonUniformAMD(uint64_t);"
3670             "u64vec2  addInvocationsNonUniformAMD(u64vec2);"
3671             "u64vec3  addInvocationsNonUniformAMD(u64vec3);"
3672             "u64vec4  addInvocationsNonUniformAMD(u64vec4);"
3673 
3674             "float16_t addInvocationsNonUniformAMD(float16_t);"
3675             "f16vec2   addInvocationsNonUniformAMD(f16vec2);"
3676             "f16vec3   addInvocationsNonUniformAMD(f16vec3);"
3677             "f16vec4   addInvocationsNonUniformAMD(f16vec4);"
3678 
3679             "int16_t addInvocationsNonUniformAMD(int16_t);"
3680             "i16vec2 addInvocationsNonUniformAMD(i16vec2);"
3681             "i16vec3 addInvocationsNonUniformAMD(i16vec3);"
3682             "i16vec4 addInvocationsNonUniformAMD(i16vec4);"
3683 
3684             "uint16_t addInvocationsNonUniformAMD(uint16_t);"
3685             "u16vec2  addInvocationsNonUniformAMD(u16vec2);"
3686             "u16vec3  addInvocationsNonUniformAMD(u16vec3);"
3687             "u16vec4  addInvocationsNonUniformAMD(u16vec4);"
3688 
3689             "float addInvocationsInclusiveScanNonUniformAMD(float);"
3690             "vec2  addInvocationsInclusiveScanNonUniformAMD(vec2);"
3691             "vec3  addInvocationsInclusiveScanNonUniformAMD(vec3);"
3692             "vec4  addInvocationsInclusiveScanNonUniformAMD(vec4);"
3693 
3694             "int   addInvocationsInclusiveScanNonUniformAMD(int);"
3695             "ivec2 addInvocationsInclusiveScanNonUniformAMD(ivec2);"
3696             "ivec3 addInvocationsInclusiveScanNonUniformAMD(ivec3);"
3697             "ivec4 addInvocationsInclusiveScanNonUniformAMD(ivec4);"
3698 
3699             "uint  addInvocationsInclusiveScanNonUniformAMD(uint);"
3700             "uvec2 addInvocationsInclusiveScanNonUniformAMD(uvec2);"
3701             "uvec3 addInvocationsInclusiveScanNonUniformAMD(uvec3);"
3702             "uvec4 addInvocationsInclusiveScanNonUniformAMD(uvec4);"
3703 
3704             "double addInvocationsInclusiveScanNonUniformAMD(double);"
3705             "dvec2  addInvocationsInclusiveScanNonUniformAMD(dvec2);"
3706             "dvec3  addInvocationsInclusiveScanNonUniformAMD(dvec3);"
3707             "dvec4  addInvocationsInclusiveScanNonUniformAMD(dvec4);"
3708 
3709             "int64_t addInvocationsInclusiveScanNonUniformAMD(int64_t);"
3710             "i64vec2 addInvocationsInclusiveScanNonUniformAMD(i64vec2);"
3711             "i64vec3 addInvocationsInclusiveScanNonUniformAMD(i64vec3);"
3712             "i64vec4 addInvocationsInclusiveScanNonUniformAMD(i64vec4);"
3713 
3714             "uint64_t addInvocationsInclusiveScanNonUniformAMD(uint64_t);"
3715             "u64vec2  addInvocationsInclusiveScanNonUniformAMD(u64vec2);"
3716             "u64vec3  addInvocationsInclusiveScanNonUniformAMD(u64vec3);"
3717             "u64vec4  addInvocationsInclusiveScanNonUniformAMD(u64vec4);"
3718 
3719             "float16_t addInvocationsInclusiveScanNonUniformAMD(float16_t);"
3720             "f16vec2   addInvocationsInclusiveScanNonUniformAMD(f16vec2);"
3721             "f16vec3   addInvocationsInclusiveScanNonUniformAMD(f16vec3);"
3722             "f16vec4   addInvocationsInclusiveScanNonUniformAMD(f16vec4);"
3723 
3724             "int16_t addInvocationsInclusiveScanNonUniformAMD(int16_t);"
3725             "i16vec2 addInvocationsInclusiveScanNonUniformAMD(i16vec2);"
3726             "i16vec3 addInvocationsInclusiveScanNonUniformAMD(i16vec3);"
3727             "i16vec4 addInvocationsInclusiveScanNonUniformAMD(i16vec4);"
3728 
3729             "uint16_t addInvocationsInclusiveScanNonUniformAMD(uint16_t);"
3730             "u16vec2  addInvocationsInclusiveScanNonUniformAMD(u16vec2);"
3731             "u16vec3  addInvocationsInclusiveScanNonUniformAMD(u16vec3);"
3732             "u16vec4  addInvocationsInclusiveScanNonUniformAMD(u16vec4);"
3733 
3734             "float addInvocationsExclusiveScanNonUniformAMD(float);"
3735             "vec2  addInvocationsExclusiveScanNonUniformAMD(vec2);"
3736             "vec3  addInvocationsExclusiveScanNonUniformAMD(vec3);"
3737             "vec4  addInvocationsExclusiveScanNonUniformAMD(vec4);"
3738 
3739             "int   addInvocationsExclusiveScanNonUniformAMD(int);"
3740             "ivec2 addInvocationsExclusiveScanNonUniformAMD(ivec2);"
3741             "ivec3 addInvocationsExclusiveScanNonUniformAMD(ivec3);"
3742             "ivec4 addInvocationsExclusiveScanNonUniformAMD(ivec4);"
3743 
3744             "uint  addInvocationsExclusiveScanNonUniformAMD(uint);"
3745             "uvec2 addInvocationsExclusiveScanNonUniformAMD(uvec2);"
3746             "uvec3 addInvocationsExclusiveScanNonUniformAMD(uvec3);"
3747             "uvec4 addInvocationsExclusiveScanNonUniformAMD(uvec4);"
3748 
3749             "double addInvocationsExclusiveScanNonUniformAMD(double);"
3750             "dvec2  addInvocationsExclusiveScanNonUniformAMD(dvec2);"
3751             "dvec3  addInvocationsExclusiveScanNonUniformAMD(dvec3);"
3752             "dvec4  addInvocationsExclusiveScanNonUniformAMD(dvec4);"
3753 
3754             "int64_t addInvocationsExclusiveScanNonUniformAMD(int64_t);"
3755             "i64vec2 addInvocationsExclusiveScanNonUniformAMD(i64vec2);"
3756             "i64vec3 addInvocationsExclusiveScanNonUniformAMD(i64vec3);"
3757             "i64vec4 addInvocationsExclusiveScanNonUniformAMD(i64vec4);"
3758 
3759             "uint64_t addInvocationsExclusiveScanNonUniformAMD(uint64_t);"
3760             "u64vec2  addInvocationsExclusiveScanNonUniformAMD(u64vec2);"
3761             "u64vec3  addInvocationsExclusiveScanNonUniformAMD(u64vec3);"
3762             "u64vec4  addInvocationsExclusiveScanNonUniformAMD(u64vec4);"
3763 
3764             "float16_t addInvocationsExclusiveScanNonUniformAMD(float16_t);"
3765             "f16vec2   addInvocationsExclusiveScanNonUniformAMD(f16vec2);"
3766             "f16vec3   addInvocationsExclusiveScanNonUniformAMD(f16vec3);"
3767             "f16vec4   addInvocationsExclusiveScanNonUniformAMD(f16vec4);"
3768 
3769             "int16_t addInvocationsExclusiveScanNonUniformAMD(int16_t);"
3770             "i16vec2 addInvocationsExclusiveScanNonUniformAMD(i16vec2);"
3771             "i16vec3 addInvocationsExclusiveScanNonUniformAMD(i16vec3);"
3772             "i16vec4 addInvocationsExclusiveScanNonUniformAMD(i16vec4);"
3773 
3774             "uint16_t addInvocationsExclusiveScanNonUniformAMD(uint16_t);"
3775             "u16vec2  addInvocationsExclusiveScanNonUniformAMD(u16vec2);"
3776             "u16vec3  addInvocationsExclusiveScanNonUniformAMD(u16vec3);"
3777             "u16vec4  addInvocationsExclusiveScanNonUniformAMD(u16vec4);"
3778 
3779             "float swizzleInvocationsAMD(float, uvec4);"
3780             "vec2  swizzleInvocationsAMD(vec2,  uvec4);"
3781             "vec3  swizzleInvocationsAMD(vec3,  uvec4);"
3782             "vec4  swizzleInvocationsAMD(vec4,  uvec4);"
3783 
3784             "int   swizzleInvocationsAMD(int,   uvec4);"
3785             "ivec2 swizzleInvocationsAMD(ivec2, uvec4);"
3786             "ivec3 swizzleInvocationsAMD(ivec3, uvec4);"
3787             "ivec4 swizzleInvocationsAMD(ivec4, uvec4);"
3788 
3789             "uint  swizzleInvocationsAMD(uint,  uvec4);"
3790             "uvec2 swizzleInvocationsAMD(uvec2, uvec4);"
3791             "uvec3 swizzleInvocationsAMD(uvec3, uvec4);"
3792             "uvec4 swizzleInvocationsAMD(uvec4, uvec4);"
3793 
3794             "float swizzleInvocationsMaskedAMD(float, uvec3);"
3795             "vec2  swizzleInvocationsMaskedAMD(vec2,  uvec3);"
3796             "vec3  swizzleInvocationsMaskedAMD(vec3,  uvec3);"
3797             "vec4  swizzleInvocationsMaskedAMD(vec4,  uvec3);"
3798 
3799             "int   swizzleInvocationsMaskedAMD(int,   uvec3);"
3800             "ivec2 swizzleInvocationsMaskedAMD(ivec2, uvec3);"
3801             "ivec3 swizzleInvocationsMaskedAMD(ivec3, uvec3);"
3802             "ivec4 swizzleInvocationsMaskedAMD(ivec4, uvec3);"
3803 
3804             "uint  swizzleInvocationsMaskedAMD(uint,  uvec3);"
3805             "uvec2 swizzleInvocationsMaskedAMD(uvec2, uvec3);"
3806             "uvec3 swizzleInvocationsMaskedAMD(uvec3, uvec3);"
3807             "uvec4 swizzleInvocationsMaskedAMD(uvec4, uvec3);"
3808 
3809             "float writeInvocationAMD(float, float, uint);"
3810             "vec2  writeInvocationAMD(vec2,  vec2,  uint);"
3811             "vec3  writeInvocationAMD(vec3,  vec3,  uint);"
3812             "vec4  writeInvocationAMD(vec4,  vec4,  uint);"
3813 
3814             "int   writeInvocationAMD(int,   int,   uint);"
3815             "ivec2 writeInvocationAMD(ivec2, ivec2, uint);"
3816             "ivec3 writeInvocationAMD(ivec3, ivec3, uint);"
3817             "ivec4 writeInvocationAMD(ivec4, ivec4, uint);"
3818 
3819             "uint  writeInvocationAMD(uint,  uint,  uint);"
3820             "uvec2 writeInvocationAMD(uvec2, uvec2, uint);"
3821             "uvec3 writeInvocationAMD(uvec3, uvec3, uint);"
3822             "uvec4 writeInvocationAMD(uvec4, uvec4, uint);"
3823 
3824             "uint mbcntAMD(uint64_t);"
3825 
3826             "\n");
3827     }
3828 
3829     // GL_AMD_gcn_shader
3830     if (profile != EEsProfile && version >= 450) {
3831         commonBuiltins.append(
3832             "float cubeFaceIndexAMD(vec3);"
3833             "vec2  cubeFaceCoordAMD(vec3);"
3834             "uint64_t timeAMD();"
3835 
3836             "\n");
3837     }
3838 
3839     // GL_AMD_shader_fragment_mask
3840     if (profile != EEsProfile && version >= 450) {
3841         commonBuiltins.append(
3842             "uint fragmentMaskFetchAMD(sampler2DMS,       ivec2);"
3843             "uint fragmentMaskFetchAMD(isampler2DMS,      ivec2);"
3844             "uint fragmentMaskFetchAMD(usampler2DMS,      ivec2);"
3845 
3846             "uint fragmentMaskFetchAMD(sampler2DMSArray,  ivec3);"
3847             "uint fragmentMaskFetchAMD(isampler2DMSArray, ivec3);"
3848             "uint fragmentMaskFetchAMD(usampler2DMSArray, ivec3);"
3849 
3850             "vec4  fragmentFetchAMD(sampler2DMS,       ivec2, uint);"
3851             "ivec4 fragmentFetchAMD(isampler2DMS,      ivec2, uint);"
3852             "uvec4 fragmentFetchAMD(usampler2DMS,      ivec2, uint);"
3853 
3854             "vec4  fragmentFetchAMD(sampler2DMSArray,  ivec3, uint);"
3855             "ivec4 fragmentFetchAMD(isampler2DMSArray, ivec3, uint);"
3856             "uvec4 fragmentFetchAMD(usampler2DMSArray, ivec3, uint);"
3857 
3858             "\n");
3859     }
3860 
3861 #endif  // AMD_EXTENSIONS
3862 
3863 
3864 #ifdef NV_EXTENSIONS
3865     if ((profile != EEsProfile && version >= 450) ||
3866         (profile == EEsProfile && version >= 320)) {
3867         commonBuiltins.append(
3868             "struct gl_TextureFootprint2DNV {"
3869                 "uvec2 anchor;"
3870                 "uvec2 offset;"
3871                 "uvec2 mask;"
3872                 "uint lod;"
3873                 "uint granularity;"
3874             "};"
3875 
3876             "struct gl_TextureFootprint3DNV {"
3877                 "uvec3 anchor;"
3878                 "uvec3 offset;"
3879                 "uvec2 mask;"
3880                 "uint lod;"
3881                 "uint granularity;"
3882             "};"
3883             "bool textureFootprintNV(sampler2D, vec2, int, bool, out gl_TextureFootprint2DNV);"
3884             "bool textureFootprintNV(sampler3D, vec3, int, bool, out gl_TextureFootprint3DNV);"
3885             "bool textureFootprintNV(sampler2D, vec2, int, bool, out gl_TextureFootprint2DNV, float);"
3886             "bool textureFootprintNV(sampler3D, vec3, int, bool, out gl_TextureFootprint3DNV, float);"
3887             "bool textureFootprintClampNV(sampler2D, vec2, float, int, bool, out gl_TextureFootprint2DNV);"
3888             "bool textureFootprintClampNV(sampler3D, vec3, float, int, bool, out gl_TextureFootprint3DNV);"
3889             "bool textureFootprintClampNV(sampler2D, vec2, float, int, bool, out gl_TextureFootprint2DNV, float);"
3890             "bool textureFootprintClampNV(sampler3D, vec3, float, int, bool, out gl_TextureFootprint3DNV, float);"
3891             "bool textureFootprintLodNV(sampler2D, vec2, float, int, bool, out gl_TextureFootprint2DNV);"
3892             "bool textureFootprintLodNV(sampler3D, vec3, float, int, bool, out gl_TextureFootprint3DNV);"
3893             "bool textureFootprintGradNV(sampler2D, vec2, vec2, vec2, int, bool, out gl_TextureFootprint2DNV);"
3894             "bool textureFootprintGradClampNV(sampler2D, vec2, vec2, vec2, float, int, bool, out gl_TextureFootprint2DNV);"
3895             "\n");
3896     }
3897 
3898 #endif // NV_EXTENSIONS
3899     // GL_AMD_gpu_shader_half_float/Explicit types
3900     if (profile != EEsProfile && version >= 450) {
3901         commonBuiltins.append(
3902             "float16_t radians(float16_t);"
3903             "f16vec2   radians(f16vec2);"
3904             "f16vec3   radians(f16vec3);"
3905             "f16vec4   radians(f16vec4);"
3906 
3907             "float16_t degrees(float16_t);"
3908             "f16vec2   degrees(f16vec2);"
3909             "f16vec3   degrees(f16vec3);"
3910             "f16vec4   degrees(f16vec4);"
3911 
3912             "float16_t sin(float16_t);"
3913             "f16vec2   sin(f16vec2);"
3914             "f16vec3   sin(f16vec3);"
3915             "f16vec4   sin(f16vec4);"
3916 
3917             "float16_t cos(float16_t);"
3918             "f16vec2   cos(f16vec2);"
3919             "f16vec3   cos(f16vec3);"
3920             "f16vec4   cos(f16vec4);"
3921 
3922             "float16_t tan(float16_t);"
3923             "f16vec2   tan(f16vec2);"
3924             "f16vec3   tan(f16vec3);"
3925             "f16vec4   tan(f16vec4);"
3926 
3927             "float16_t asin(float16_t);"
3928             "f16vec2   asin(f16vec2);"
3929             "f16vec3   asin(f16vec3);"
3930             "f16vec4   asin(f16vec4);"
3931 
3932             "float16_t acos(float16_t);"
3933             "f16vec2   acos(f16vec2);"
3934             "f16vec3   acos(f16vec3);"
3935             "f16vec4   acos(f16vec4);"
3936 
3937             "float16_t atan(float16_t, float16_t);"
3938             "f16vec2   atan(f16vec2,   f16vec2);"
3939             "f16vec3   atan(f16vec3,   f16vec3);"
3940             "f16vec4   atan(f16vec4,   f16vec4);"
3941 
3942             "float16_t atan(float16_t);"
3943             "f16vec2   atan(f16vec2);"
3944             "f16vec3   atan(f16vec3);"
3945             "f16vec4   atan(f16vec4);"
3946 
3947             "float16_t sinh(float16_t);"
3948             "f16vec2   sinh(f16vec2);"
3949             "f16vec3   sinh(f16vec3);"
3950             "f16vec4   sinh(f16vec4);"
3951 
3952             "float16_t cosh(float16_t);"
3953             "f16vec2   cosh(f16vec2);"
3954             "f16vec3   cosh(f16vec3);"
3955             "f16vec4   cosh(f16vec4);"
3956 
3957             "float16_t tanh(float16_t);"
3958             "f16vec2   tanh(f16vec2);"
3959             "f16vec3   tanh(f16vec3);"
3960             "f16vec4   tanh(f16vec4);"
3961 
3962             "float16_t asinh(float16_t);"
3963             "f16vec2   asinh(f16vec2);"
3964             "f16vec3   asinh(f16vec3);"
3965             "f16vec4   asinh(f16vec4);"
3966 
3967             "float16_t acosh(float16_t);"
3968             "f16vec2   acosh(f16vec2);"
3969             "f16vec3   acosh(f16vec3);"
3970             "f16vec4   acosh(f16vec4);"
3971 
3972             "float16_t atanh(float16_t);"
3973             "f16vec2   atanh(f16vec2);"
3974             "f16vec3   atanh(f16vec3);"
3975             "f16vec4   atanh(f16vec4);"
3976 
3977             "float16_t pow(float16_t, float16_t);"
3978             "f16vec2   pow(f16vec2,   f16vec2);"
3979             "f16vec3   pow(f16vec3,   f16vec3);"
3980             "f16vec4   pow(f16vec4,   f16vec4);"
3981 
3982             "float16_t exp(float16_t);"
3983             "f16vec2   exp(f16vec2);"
3984             "f16vec3   exp(f16vec3);"
3985             "f16vec4   exp(f16vec4);"
3986 
3987             "float16_t log(float16_t);"
3988             "f16vec2   log(f16vec2);"
3989             "f16vec3   log(f16vec3);"
3990             "f16vec4   log(f16vec4);"
3991 
3992             "float16_t exp2(float16_t);"
3993             "f16vec2   exp2(f16vec2);"
3994             "f16vec3   exp2(f16vec3);"
3995             "f16vec4   exp2(f16vec4);"
3996 
3997             "float16_t log2(float16_t);"
3998             "f16vec2   log2(f16vec2);"
3999             "f16vec3   log2(f16vec3);"
4000             "f16vec4   log2(f16vec4);"
4001 
4002             "float16_t sqrt(float16_t);"
4003             "f16vec2   sqrt(f16vec2);"
4004             "f16vec3   sqrt(f16vec3);"
4005             "f16vec4   sqrt(f16vec4);"
4006 
4007             "float16_t inversesqrt(float16_t);"
4008             "f16vec2   inversesqrt(f16vec2);"
4009             "f16vec3   inversesqrt(f16vec3);"
4010             "f16vec4   inversesqrt(f16vec4);"
4011 
4012             "float16_t abs(float16_t);"
4013             "f16vec2   abs(f16vec2);"
4014             "f16vec3   abs(f16vec3);"
4015             "f16vec4   abs(f16vec4);"
4016 
4017             "float16_t sign(float16_t);"
4018             "f16vec2   sign(f16vec2);"
4019             "f16vec3   sign(f16vec3);"
4020             "f16vec4   sign(f16vec4);"
4021 
4022             "float16_t floor(float16_t);"
4023             "f16vec2   floor(f16vec2);"
4024             "f16vec3   floor(f16vec3);"
4025             "f16vec4   floor(f16vec4);"
4026 
4027             "float16_t trunc(float16_t);"
4028             "f16vec2   trunc(f16vec2);"
4029             "f16vec3   trunc(f16vec3);"
4030             "f16vec4   trunc(f16vec4);"
4031 
4032             "float16_t round(float16_t);"
4033             "f16vec2   round(f16vec2);"
4034             "f16vec3   round(f16vec3);"
4035             "f16vec4   round(f16vec4);"
4036 
4037             "float16_t roundEven(float16_t);"
4038             "f16vec2   roundEven(f16vec2);"
4039             "f16vec3   roundEven(f16vec3);"
4040             "f16vec4   roundEven(f16vec4);"
4041 
4042             "float16_t ceil(float16_t);"
4043             "f16vec2   ceil(f16vec2);"
4044             "f16vec3   ceil(f16vec3);"
4045             "f16vec4   ceil(f16vec4);"
4046 
4047             "float16_t fract(float16_t);"
4048             "f16vec2   fract(f16vec2);"
4049             "f16vec3   fract(f16vec3);"
4050             "f16vec4   fract(f16vec4);"
4051 
4052             "float16_t mod(float16_t, float16_t);"
4053             "f16vec2   mod(f16vec2,   float16_t);"
4054             "f16vec3   mod(f16vec3,   float16_t);"
4055             "f16vec4   mod(f16vec4,   float16_t);"
4056             "f16vec2   mod(f16vec2,   f16vec2);"
4057             "f16vec3   mod(f16vec3,   f16vec3);"
4058             "f16vec4   mod(f16vec4,   f16vec4);"
4059 
4060             "float16_t modf(float16_t, out float16_t);"
4061             "f16vec2   modf(f16vec2,   out f16vec2);"
4062             "f16vec3   modf(f16vec3,   out f16vec3);"
4063             "f16vec4   modf(f16vec4,   out f16vec4);"
4064 
4065             "float16_t min(float16_t, float16_t);"
4066             "f16vec2   min(f16vec2,   float16_t);"
4067             "f16vec3   min(f16vec3,   float16_t);"
4068             "f16vec4   min(f16vec4,   float16_t);"
4069             "f16vec2   min(f16vec2,   f16vec2);"
4070             "f16vec3   min(f16vec3,   f16vec3);"
4071             "f16vec4   min(f16vec4,   f16vec4);"
4072 
4073             "float16_t max(float16_t, float16_t);"
4074             "f16vec2   max(f16vec2,   float16_t);"
4075             "f16vec3   max(f16vec3,   float16_t);"
4076             "f16vec4   max(f16vec4,   float16_t);"
4077             "f16vec2   max(f16vec2,   f16vec2);"
4078             "f16vec3   max(f16vec3,   f16vec3);"
4079             "f16vec4   max(f16vec4,   f16vec4);"
4080 
4081             "float16_t clamp(float16_t, float16_t, float16_t);"
4082             "f16vec2   clamp(f16vec2,   float16_t, float16_t);"
4083             "f16vec3   clamp(f16vec3,   float16_t, float16_t);"
4084             "f16vec4   clamp(f16vec4,   float16_t, float16_t);"
4085             "f16vec2   clamp(f16vec2,   f16vec2,   f16vec2);"
4086             "f16vec3   clamp(f16vec3,   f16vec3,   f16vec3);"
4087             "f16vec4   clamp(f16vec4,   f16vec4,   f16vec4);"
4088 
4089             "float16_t mix(float16_t, float16_t, float16_t);"
4090             "f16vec2   mix(f16vec2,   f16vec2,   float16_t);"
4091             "f16vec3   mix(f16vec3,   f16vec3,   float16_t);"
4092             "f16vec4   mix(f16vec4,   f16vec4,   float16_t);"
4093             "f16vec2   mix(f16vec2,   f16vec2,   f16vec2);"
4094             "f16vec3   mix(f16vec3,   f16vec3,   f16vec3);"
4095             "f16vec4   mix(f16vec4,   f16vec4,   f16vec4);"
4096             "float16_t mix(float16_t, float16_t, bool);"
4097             "f16vec2   mix(f16vec2,   f16vec2,   bvec2);"
4098             "f16vec3   mix(f16vec3,   f16vec3,   bvec3);"
4099             "f16vec4   mix(f16vec4,   f16vec4,   bvec4);"
4100 
4101             "float16_t step(float16_t, float16_t);"
4102             "f16vec2   step(f16vec2,   f16vec2);"
4103             "f16vec3   step(f16vec3,   f16vec3);"
4104             "f16vec4   step(f16vec4,   f16vec4);"
4105             "f16vec2   step(float16_t, f16vec2);"
4106             "f16vec3   step(float16_t, f16vec3);"
4107             "f16vec4   step(float16_t, f16vec4);"
4108 
4109             "float16_t smoothstep(float16_t, float16_t, float16_t);"
4110             "f16vec2   smoothstep(f16vec2,   f16vec2,   f16vec2);"
4111             "f16vec3   smoothstep(f16vec3,   f16vec3,   f16vec3);"
4112             "f16vec4   smoothstep(f16vec4,   f16vec4,   f16vec4);"
4113             "f16vec2   smoothstep(float16_t, float16_t, f16vec2);"
4114             "f16vec3   smoothstep(float16_t, float16_t, f16vec3);"
4115             "f16vec4   smoothstep(float16_t, float16_t, f16vec4);"
4116 
4117             "bool  isnan(float16_t);"
4118             "bvec2 isnan(f16vec2);"
4119             "bvec3 isnan(f16vec3);"
4120             "bvec4 isnan(f16vec4);"
4121 
4122             "bool  isinf(float16_t);"
4123             "bvec2 isinf(f16vec2);"
4124             "bvec3 isinf(f16vec3);"
4125             "bvec4 isinf(f16vec4);"
4126 
4127             "float16_t fma(float16_t, float16_t, float16_t);"
4128             "f16vec2   fma(f16vec2,   f16vec2,   f16vec2);"
4129             "f16vec3   fma(f16vec3,   f16vec3,   f16vec3);"
4130             "f16vec4   fma(f16vec4,   f16vec4,   f16vec4);"
4131 
4132             "float16_t frexp(float16_t, out int);"
4133             "f16vec2   frexp(f16vec2,   out ivec2);"
4134             "f16vec3   frexp(f16vec3,   out ivec3);"
4135             "f16vec4   frexp(f16vec4,   out ivec4);"
4136 
4137             "float16_t ldexp(float16_t, in int);"
4138             "f16vec2   ldexp(f16vec2,   in ivec2);"
4139             "f16vec3   ldexp(f16vec3,   in ivec3);"
4140             "f16vec4   ldexp(f16vec4,   in ivec4);"
4141 
4142             "uint    packFloat2x16(f16vec2);"
4143             "f16vec2 unpackFloat2x16(uint);"
4144 
4145             "float16_t length(float16_t);"
4146             "float16_t length(f16vec2);"
4147             "float16_t length(f16vec3);"
4148             "float16_t length(f16vec4);"
4149 
4150             "float16_t distance(float16_t, float16_t);"
4151             "float16_t distance(f16vec2,   f16vec2);"
4152             "float16_t distance(f16vec3,   f16vec3);"
4153             "float16_t distance(f16vec4,   f16vec4);"
4154 
4155             "float16_t dot(float16_t, float16_t);"
4156             "float16_t dot(f16vec2,   f16vec2);"
4157             "float16_t dot(f16vec3,   f16vec3);"
4158             "float16_t dot(f16vec4,   f16vec4);"
4159 
4160             "f16vec3 cross(f16vec3, f16vec3);"
4161 
4162             "float16_t normalize(float16_t);"
4163             "f16vec2   normalize(f16vec2);"
4164             "f16vec3   normalize(f16vec3);"
4165             "f16vec4   normalize(f16vec4);"
4166 
4167             "float16_t faceforward(float16_t, float16_t, float16_t);"
4168             "f16vec2   faceforward(f16vec2,   f16vec2,   f16vec2);"
4169             "f16vec3   faceforward(f16vec3,   f16vec3,   f16vec3);"
4170             "f16vec4   faceforward(f16vec4,   f16vec4,   f16vec4);"
4171 
4172             "float16_t reflect(float16_t, float16_t);"
4173             "f16vec2   reflect(f16vec2,   f16vec2);"
4174             "f16vec3   reflect(f16vec3,   f16vec3);"
4175             "f16vec4   reflect(f16vec4,   f16vec4);"
4176 
4177             "float16_t refract(float16_t, float16_t, float16_t);"
4178             "f16vec2   refract(f16vec2,   f16vec2,   float16_t);"
4179             "f16vec3   refract(f16vec3,   f16vec3,   float16_t);"
4180             "f16vec4   refract(f16vec4,   f16vec4,   float16_t);"
4181 
4182             "f16mat2   matrixCompMult(f16mat2,   f16mat2);"
4183             "f16mat3   matrixCompMult(f16mat3,   f16mat3);"
4184             "f16mat4   matrixCompMult(f16mat4,   f16mat4);"
4185             "f16mat2x3 matrixCompMult(f16mat2x3, f16mat2x3);"
4186             "f16mat2x4 matrixCompMult(f16mat2x4, f16mat2x4);"
4187             "f16mat3x2 matrixCompMult(f16mat3x2, f16mat3x2);"
4188             "f16mat3x4 matrixCompMult(f16mat3x4, f16mat3x4);"
4189             "f16mat4x2 matrixCompMult(f16mat4x2, f16mat4x2);"
4190             "f16mat4x3 matrixCompMult(f16mat4x3, f16mat4x3);"
4191 
4192             "f16mat2   outerProduct(f16vec2, f16vec2);"
4193             "f16mat3   outerProduct(f16vec3, f16vec3);"
4194             "f16mat4   outerProduct(f16vec4, f16vec4);"
4195             "f16mat2x3 outerProduct(f16vec3, f16vec2);"
4196             "f16mat3x2 outerProduct(f16vec2, f16vec3);"
4197             "f16mat2x4 outerProduct(f16vec4, f16vec2);"
4198             "f16mat4x2 outerProduct(f16vec2, f16vec4);"
4199             "f16mat3x4 outerProduct(f16vec4, f16vec3);"
4200             "f16mat4x3 outerProduct(f16vec3, f16vec4);"
4201 
4202             "f16mat2   transpose(f16mat2);"
4203             "f16mat3   transpose(f16mat3);"
4204             "f16mat4   transpose(f16mat4);"
4205             "f16mat2x3 transpose(f16mat3x2);"
4206             "f16mat3x2 transpose(f16mat2x3);"
4207             "f16mat2x4 transpose(f16mat4x2);"
4208             "f16mat4x2 transpose(f16mat2x4);"
4209             "f16mat3x4 transpose(f16mat4x3);"
4210             "f16mat4x3 transpose(f16mat3x4);"
4211 
4212             "float16_t determinant(f16mat2);"
4213             "float16_t determinant(f16mat3);"
4214             "float16_t determinant(f16mat4);"
4215 
4216             "f16mat2 inverse(f16mat2);"
4217             "f16mat3 inverse(f16mat3);"
4218             "f16mat4 inverse(f16mat4);"
4219 
4220             "bvec2 lessThan(f16vec2, f16vec2);"
4221             "bvec3 lessThan(f16vec3, f16vec3);"
4222             "bvec4 lessThan(f16vec4, f16vec4);"
4223 
4224             "bvec2 lessThanEqual(f16vec2, f16vec2);"
4225             "bvec3 lessThanEqual(f16vec3, f16vec3);"
4226             "bvec4 lessThanEqual(f16vec4, f16vec4);"
4227 
4228             "bvec2 greaterThan(f16vec2, f16vec2);"
4229             "bvec3 greaterThan(f16vec3, f16vec3);"
4230             "bvec4 greaterThan(f16vec4, f16vec4);"
4231 
4232             "bvec2 greaterThanEqual(f16vec2, f16vec2);"
4233             "bvec3 greaterThanEqual(f16vec3, f16vec3);"
4234             "bvec4 greaterThanEqual(f16vec4, f16vec4);"
4235 
4236             "bvec2 equal(f16vec2, f16vec2);"
4237             "bvec3 equal(f16vec3, f16vec3);"
4238             "bvec4 equal(f16vec4, f16vec4);"
4239 
4240             "bvec2 notEqual(f16vec2, f16vec2);"
4241             "bvec3 notEqual(f16vec3, f16vec3);"
4242             "bvec4 notEqual(f16vec4, f16vec4);"
4243 
4244             "\n");
4245     }
4246 
4247     // Explicit types
4248     if (profile != EEsProfile && version >= 450) {
4249         commonBuiltins.append(
4250             "int8_t abs(int8_t);"
4251             "i8vec2 abs(i8vec2);"
4252             "i8vec3 abs(i8vec3);"
4253             "i8vec4 abs(i8vec4);"
4254 
4255             "int8_t sign(int8_t);"
4256             "i8vec2 sign(i8vec2);"
4257             "i8vec3 sign(i8vec3);"
4258             "i8vec4 sign(i8vec4);"
4259 
4260             "int8_t min(int8_t x, int8_t y);"
4261             "i8vec2 min(i8vec2 x, int8_t y);"
4262             "i8vec3 min(i8vec3 x, int8_t y);"
4263             "i8vec4 min(i8vec4 x, int8_t y);"
4264             "i8vec2 min(i8vec2 x, i8vec2 y);"
4265             "i8vec3 min(i8vec3 x, i8vec3 y);"
4266             "i8vec4 min(i8vec4 x, i8vec4 y);"
4267 
4268             "uint8_t min(uint8_t x, uint8_t y);"
4269             "u8vec2 min(u8vec2 x, uint8_t y);"
4270             "u8vec3 min(u8vec3 x, uint8_t y);"
4271             "u8vec4 min(u8vec4 x, uint8_t y);"
4272             "u8vec2 min(u8vec2 x, u8vec2 y);"
4273             "u8vec3 min(u8vec3 x, u8vec3 y);"
4274             "u8vec4 min(u8vec4 x, u8vec4 y);"
4275 
4276             "int8_t max(int8_t x, int8_t y);"
4277             "i8vec2 max(i8vec2 x, int8_t y);"
4278             "i8vec3 max(i8vec3 x, int8_t y);"
4279             "i8vec4 max(i8vec4 x, int8_t y);"
4280             "i8vec2 max(i8vec2 x, i8vec2 y);"
4281             "i8vec3 max(i8vec3 x, i8vec3 y);"
4282             "i8vec4 max(i8vec4 x, i8vec4 y);"
4283 
4284             "uint8_t max(uint8_t x, uint8_t y);"
4285             "u8vec2 max(u8vec2 x, uint8_t y);"
4286             "u8vec3 max(u8vec3 x, uint8_t y);"
4287             "u8vec4 max(u8vec4 x, uint8_t y);"
4288             "u8vec2 max(u8vec2 x, u8vec2 y);"
4289             "u8vec3 max(u8vec3 x, u8vec3 y);"
4290             "u8vec4 max(u8vec4 x, u8vec4 y);"
4291 
4292             "int8_t    clamp(int8_t x, int8_t minVal, int8_t maxVal);"
4293             "i8vec2  clamp(i8vec2  x, int8_t minVal, int8_t maxVal);"
4294             "i8vec3  clamp(i8vec3  x, int8_t minVal, int8_t maxVal);"
4295             "i8vec4  clamp(i8vec4  x, int8_t minVal, int8_t maxVal);"
4296             "i8vec2  clamp(i8vec2  x, i8vec2  minVal, i8vec2  maxVal);"
4297             "i8vec3  clamp(i8vec3  x, i8vec3  minVal, i8vec3  maxVal);"
4298             "i8vec4  clamp(i8vec4  x, i8vec4  minVal, i8vec4  maxVal);"
4299 
4300             "uint8_t   clamp(uint8_t x, uint8_t minVal, uint8_t maxVal);"
4301             "u8vec2  clamp(u8vec2  x, uint8_t minVal, uint8_t maxVal);"
4302             "u8vec3  clamp(u8vec3  x, uint8_t minVal, uint8_t maxVal);"
4303             "u8vec4  clamp(u8vec4  x, uint8_t minVal, uint8_t maxVal);"
4304             "u8vec2  clamp(u8vec2  x, u8vec2  minVal, u8vec2  maxVal);"
4305             "u8vec3  clamp(u8vec3  x, u8vec3  minVal, u8vec3  maxVal);"
4306             "u8vec4  clamp(u8vec4  x, u8vec4  minVal, u8vec4  maxVal);"
4307 
4308             "int8_t  mix(int8_t,  int8_t,  bool);"
4309             "i8vec2  mix(i8vec2,  i8vec2,  bvec2);"
4310             "i8vec3  mix(i8vec3,  i8vec3,  bvec3);"
4311             "i8vec4  mix(i8vec4,  i8vec4,  bvec4);"
4312             "uint8_t mix(uint8_t, uint8_t, bool);"
4313             "u8vec2  mix(u8vec2,  u8vec2,  bvec2);"
4314             "u8vec3  mix(u8vec3,  u8vec3,  bvec3);"
4315             "u8vec4  mix(u8vec4,  u8vec4,  bvec4);"
4316 
4317             "bvec2 lessThan(i8vec2, i8vec2);"
4318             "bvec3 lessThan(i8vec3, i8vec3);"
4319             "bvec4 lessThan(i8vec4, i8vec4);"
4320             "bvec2 lessThan(u8vec2, u8vec2);"
4321             "bvec3 lessThan(u8vec3, u8vec3);"
4322             "bvec4 lessThan(u8vec4, u8vec4);"
4323 
4324             "bvec2 lessThanEqual(i8vec2, i8vec2);"
4325             "bvec3 lessThanEqual(i8vec3, i8vec3);"
4326             "bvec4 lessThanEqual(i8vec4, i8vec4);"
4327             "bvec2 lessThanEqual(u8vec2, u8vec2);"
4328             "bvec3 lessThanEqual(u8vec3, u8vec3);"
4329             "bvec4 lessThanEqual(u8vec4, u8vec4);"
4330 
4331             "bvec2 greaterThan(i8vec2, i8vec2);"
4332             "bvec3 greaterThan(i8vec3, i8vec3);"
4333             "bvec4 greaterThan(i8vec4, i8vec4);"
4334             "bvec2 greaterThan(u8vec2, u8vec2);"
4335             "bvec3 greaterThan(u8vec3, u8vec3);"
4336             "bvec4 greaterThan(u8vec4, u8vec4);"
4337 
4338             "bvec2 greaterThanEqual(i8vec2, i8vec2);"
4339             "bvec3 greaterThanEqual(i8vec3, i8vec3);"
4340             "bvec4 greaterThanEqual(i8vec4, i8vec4);"
4341             "bvec2 greaterThanEqual(u8vec2, u8vec2);"
4342             "bvec3 greaterThanEqual(u8vec3, u8vec3);"
4343             "bvec4 greaterThanEqual(u8vec4, u8vec4);"
4344 
4345             "bvec2 equal(i8vec2, i8vec2);"
4346             "bvec3 equal(i8vec3, i8vec3);"
4347             "bvec4 equal(i8vec4, i8vec4);"
4348             "bvec2 equal(u8vec2, u8vec2);"
4349             "bvec3 equal(u8vec3, u8vec3);"
4350             "bvec4 equal(u8vec4, u8vec4);"
4351 
4352             "bvec2 notEqual(i8vec2, i8vec2);"
4353             "bvec3 notEqual(i8vec3, i8vec3);"
4354             "bvec4 notEqual(i8vec4, i8vec4);"
4355             "bvec2 notEqual(u8vec2, u8vec2);"
4356             "bvec3 notEqual(u8vec3, u8vec3);"
4357             "bvec4 notEqual(u8vec4, u8vec4);"
4358 
4359             "  int8_t bitfieldExtract(  int8_t, int8_t, int8_t);"
4360             "i8vec2 bitfieldExtract(i8vec2, int8_t, int8_t);"
4361             "i8vec3 bitfieldExtract(i8vec3, int8_t, int8_t);"
4362             "i8vec4 bitfieldExtract(i8vec4, int8_t, int8_t);"
4363 
4364             " uint8_t bitfieldExtract( uint8_t, int8_t, int8_t);"
4365             "u8vec2 bitfieldExtract(u8vec2, int8_t, int8_t);"
4366             "u8vec3 bitfieldExtract(u8vec3, int8_t, int8_t);"
4367             "u8vec4 bitfieldExtract(u8vec4, int8_t, int8_t);"
4368 
4369             "  int8_t bitfieldInsert(  int8_t base,   int8_t, int8_t, int8_t);"
4370             "i8vec2 bitfieldInsert(i8vec2 base, i8vec2, int8_t, int8_t);"
4371             "i8vec3 bitfieldInsert(i8vec3 base, i8vec3, int8_t, int8_t);"
4372             "i8vec4 bitfieldInsert(i8vec4 base, i8vec4, int8_t, int8_t);"
4373 
4374             " uint8_t bitfieldInsert( uint8_t base,  uint8_t, int8_t, int8_t);"
4375             "u8vec2 bitfieldInsert(u8vec2 base, u8vec2, int8_t, int8_t);"
4376             "u8vec3 bitfieldInsert(u8vec3 base, u8vec3, int8_t, int8_t);"
4377             "u8vec4 bitfieldInsert(u8vec4 base, u8vec4, int8_t, int8_t);"
4378 
4379             "  int8_t bitCount(  int8_t);"
4380             "i8vec2 bitCount(i8vec2);"
4381             "i8vec3 bitCount(i8vec3);"
4382             "i8vec4 bitCount(i8vec4);"
4383 
4384             "  int8_t bitCount( uint8_t);"
4385             "i8vec2 bitCount(u8vec2);"
4386             "i8vec3 bitCount(u8vec3);"
4387             "i8vec4 bitCount(u8vec4);"
4388 
4389             "  int8_t findLSB(  int8_t);"
4390             "i8vec2 findLSB(i8vec2);"
4391             "i8vec3 findLSB(i8vec3);"
4392             "i8vec4 findLSB(i8vec4);"
4393 
4394             "  int8_t findLSB( uint8_t);"
4395             "i8vec2 findLSB(u8vec2);"
4396             "i8vec3 findLSB(u8vec3);"
4397             "i8vec4 findLSB(u8vec4);"
4398 
4399             "  int8_t findMSB(  int8_t);"
4400             "i8vec2 findMSB(i8vec2);"
4401             "i8vec3 findMSB(i8vec3);"
4402             "i8vec4 findMSB(i8vec4);"
4403 
4404             "  int8_t findMSB( uint8_t);"
4405             "i8vec2 findMSB(u8vec2);"
4406             "i8vec3 findMSB(u8vec3);"
4407             "i8vec4 findMSB(u8vec4);"
4408 
4409             "int16_t abs(int16_t);"
4410             "i16vec2 abs(i16vec2);"
4411             "i16vec3 abs(i16vec3);"
4412             "i16vec4 abs(i16vec4);"
4413 
4414             "int16_t sign(int16_t);"
4415             "i16vec2 sign(i16vec2);"
4416             "i16vec3 sign(i16vec3);"
4417             "i16vec4 sign(i16vec4);"
4418 
4419             "int16_t min(int16_t x, int16_t y);"
4420             "i16vec2 min(i16vec2 x, int16_t y);"
4421             "i16vec3 min(i16vec3 x, int16_t y);"
4422             "i16vec4 min(i16vec4 x, int16_t y);"
4423             "i16vec2 min(i16vec2 x, i16vec2 y);"
4424             "i16vec3 min(i16vec3 x, i16vec3 y);"
4425             "i16vec4 min(i16vec4 x, i16vec4 y);"
4426 
4427             "uint16_t min(uint16_t x, uint16_t y);"
4428             "u16vec2 min(u16vec2 x, uint16_t y);"
4429             "u16vec3 min(u16vec3 x, uint16_t y);"
4430             "u16vec4 min(u16vec4 x, uint16_t y);"
4431             "u16vec2 min(u16vec2 x, u16vec2 y);"
4432             "u16vec3 min(u16vec3 x, u16vec3 y);"
4433             "u16vec4 min(u16vec4 x, u16vec4 y);"
4434 
4435             "int16_t max(int16_t x, int16_t y);"
4436             "i16vec2 max(i16vec2 x, int16_t y);"
4437             "i16vec3 max(i16vec3 x, int16_t y);"
4438             "i16vec4 max(i16vec4 x, int16_t y);"
4439             "i16vec2 max(i16vec2 x, i16vec2 y);"
4440             "i16vec3 max(i16vec3 x, i16vec3 y);"
4441             "i16vec4 max(i16vec4 x, i16vec4 y);"
4442 
4443             "uint16_t max(uint16_t x, uint16_t y);"
4444             "u16vec2 max(u16vec2 x, uint16_t y);"
4445             "u16vec3 max(u16vec3 x, uint16_t y);"
4446             "u16vec4 max(u16vec4 x, uint16_t y);"
4447             "u16vec2 max(u16vec2 x, u16vec2 y);"
4448             "u16vec3 max(u16vec3 x, u16vec3 y);"
4449             "u16vec4 max(u16vec4 x, u16vec4 y);"
4450 
4451             "int16_t    clamp(int16_t x, int16_t minVal, int16_t maxVal);"
4452             "i16vec2  clamp(i16vec2  x, int16_t minVal, int16_t maxVal);"
4453             "i16vec3  clamp(i16vec3  x, int16_t minVal, int16_t maxVal);"
4454             "i16vec4  clamp(i16vec4  x, int16_t minVal, int16_t maxVal);"
4455             "i16vec2  clamp(i16vec2  x, i16vec2  minVal, i16vec2  maxVal);"
4456             "i16vec3  clamp(i16vec3  x, i16vec3  minVal, i16vec3  maxVal);"
4457             "i16vec4  clamp(i16vec4  x, i16vec4  minVal, i16vec4  maxVal);"
4458 
4459             "uint16_t   clamp(uint16_t x, uint16_t minVal, uint16_t maxVal);"
4460             "u16vec2  clamp(u16vec2  x, uint16_t minVal, uint16_t maxVal);"
4461             "u16vec3  clamp(u16vec3  x, uint16_t minVal, uint16_t maxVal);"
4462             "u16vec4  clamp(u16vec4  x, uint16_t minVal, uint16_t maxVal);"
4463             "u16vec2  clamp(u16vec2  x, u16vec2  minVal, u16vec2  maxVal);"
4464             "u16vec3  clamp(u16vec3  x, u16vec3  minVal, u16vec3  maxVal);"
4465             "u16vec4  clamp(u16vec4  x, u16vec4  minVal, u16vec4  maxVal);"
4466 
4467             "int16_t  mix(int16_t,  int16_t,  bool);"
4468             "i16vec2  mix(i16vec2,  i16vec2,  bvec2);"
4469             "i16vec3  mix(i16vec3,  i16vec3,  bvec3);"
4470             "i16vec4  mix(i16vec4,  i16vec4,  bvec4);"
4471             "uint16_t mix(uint16_t, uint16_t, bool);"
4472             "u16vec2  mix(u16vec2,  u16vec2,  bvec2);"
4473             "u16vec3  mix(u16vec3,  u16vec3,  bvec3);"
4474             "u16vec4  mix(u16vec4,  u16vec4,  bvec4);"
4475 
4476             "float16_t frexp(float16_t, out int16_t);"
4477             "f16vec2   frexp(f16vec2,   out i16vec2);"
4478             "f16vec3   frexp(f16vec3,   out i16vec3);"
4479             "f16vec4   frexp(f16vec4,   out i16vec4);"
4480 
4481             "float16_t ldexp(float16_t, int16_t);"
4482             "f16vec2   ldexp(f16vec2,   i16vec2);"
4483             "f16vec3   ldexp(f16vec3,   i16vec3);"
4484             "f16vec4   ldexp(f16vec4,   i16vec4);"
4485 
4486             "int16_t halfBitsToInt16(float16_t);"
4487             "i16vec2 halfBitsToInt16(f16vec2);"
4488             "i16vec3 halhBitsToInt16(f16vec3);"
4489             "i16vec4 halfBitsToInt16(f16vec4);"
4490 
4491             "uint16_t halfBitsToUint16(float16_t);"
4492             "u16vec2  halfBitsToUint16(f16vec2);"
4493             "u16vec3  halfBitsToUint16(f16vec3);"
4494             "u16vec4  halfBitsToUint16(f16vec4);"
4495 
4496             "int16_t float16BitsToInt16(float16_t);"
4497             "i16vec2 float16BitsToInt16(f16vec2);"
4498             "i16vec3 float16BitsToInt16(f16vec3);"
4499             "i16vec4 float16BitsToInt16(f16vec4);"
4500 
4501             "uint16_t float16BitsToUint16(float16_t);"
4502             "u16vec2  float16BitsToUint16(f16vec2);"
4503             "u16vec3  float16BitsToUint16(f16vec3);"
4504             "u16vec4  float16BitsToUint16(f16vec4);"
4505 
4506             "float16_t int16BitsToFloat16(int16_t);"
4507             "f16vec2   int16BitsToFloat16(i16vec2);"
4508             "f16vec3   int16BitsToFloat16(i16vec3);"
4509             "f16vec4   int16BitsToFloat16(i16vec4);"
4510 
4511             "float16_t uint16BitsToFloat16(uint16_t);"
4512             "f16vec2   uint16BitsToFloat16(u16vec2);"
4513             "f16vec3   uint16BitsToFloat16(u16vec3);"
4514             "f16vec4   uint16BitsToFloat16(u16vec4);"
4515 
4516             "float16_t int16BitsToHalf(int16_t);"
4517             "f16vec2   int16BitsToHalf(i16vec2);"
4518             "f16vec3   int16BitsToHalf(i16vec3);"
4519             "f16vec4   int16BitsToHalf(i16vec4);"
4520 
4521             "float16_t uint16BitsToHalf(uint16_t);"
4522             "f16vec2   uint16BitsToHalf(u16vec2);"
4523             "f16vec3   uint16BitsToHalf(u16vec3);"
4524             "f16vec4   uint16BitsToHalf(u16vec4);"
4525 
4526             "int      packInt2x16(i16vec2);"
4527             "uint     packUint2x16(u16vec2);"
4528             "int64_t  packInt4x16(i16vec4);"
4529             "uint64_t packUint4x16(u16vec4);"
4530             "i16vec2  unpackInt2x16(int);"
4531             "u16vec2  unpackUint2x16(uint);"
4532             "i16vec4  unpackInt4x16(int64_t);"
4533             "u16vec4  unpackUint4x16(uint64_t);"
4534 
4535             "bvec2 lessThan(i16vec2, i16vec2);"
4536             "bvec3 lessThan(i16vec3, i16vec3);"
4537             "bvec4 lessThan(i16vec4, i16vec4);"
4538             "bvec2 lessThan(u16vec2, u16vec2);"
4539             "bvec3 lessThan(u16vec3, u16vec3);"
4540             "bvec4 lessThan(u16vec4, u16vec4);"
4541 
4542             "bvec2 lessThanEqual(i16vec2, i16vec2);"
4543             "bvec3 lessThanEqual(i16vec3, i16vec3);"
4544             "bvec4 lessThanEqual(i16vec4, i16vec4);"
4545             "bvec2 lessThanEqual(u16vec2, u16vec2);"
4546             "bvec3 lessThanEqual(u16vec3, u16vec3);"
4547             "bvec4 lessThanEqual(u16vec4, u16vec4);"
4548 
4549             "bvec2 greaterThan(i16vec2, i16vec2);"
4550             "bvec3 greaterThan(i16vec3, i16vec3);"
4551             "bvec4 greaterThan(i16vec4, i16vec4);"
4552             "bvec2 greaterThan(u16vec2, u16vec2);"
4553             "bvec3 greaterThan(u16vec3, u16vec3);"
4554             "bvec4 greaterThan(u16vec4, u16vec4);"
4555 
4556             "bvec2 greaterThanEqual(i16vec2, i16vec2);"
4557             "bvec3 greaterThanEqual(i16vec3, i16vec3);"
4558             "bvec4 greaterThanEqual(i16vec4, i16vec4);"
4559             "bvec2 greaterThanEqual(u16vec2, u16vec2);"
4560             "bvec3 greaterThanEqual(u16vec3, u16vec3);"
4561             "bvec4 greaterThanEqual(u16vec4, u16vec4);"
4562 
4563             "bvec2 equal(i16vec2, i16vec2);"
4564             "bvec3 equal(i16vec3, i16vec3);"
4565             "bvec4 equal(i16vec4, i16vec4);"
4566             "bvec2 equal(u16vec2, u16vec2);"
4567             "bvec3 equal(u16vec3, u16vec3);"
4568             "bvec4 equal(u16vec4, u16vec4);"
4569 
4570             "bvec2 notEqual(i16vec2, i16vec2);"
4571             "bvec3 notEqual(i16vec3, i16vec3);"
4572             "bvec4 notEqual(i16vec4, i16vec4);"
4573             "bvec2 notEqual(u16vec2, u16vec2);"
4574             "bvec3 notEqual(u16vec3, u16vec3);"
4575             "bvec4 notEqual(u16vec4, u16vec4);"
4576 
4577             "  int16_t bitfieldExtract(  int16_t, int16_t, int16_t);"
4578             "i16vec2 bitfieldExtract(i16vec2, int16_t, int16_t);"
4579             "i16vec3 bitfieldExtract(i16vec3, int16_t, int16_t);"
4580             "i16vec4 bitfieldExtract(i16vec4, int16_t, int16_t);"
4581 
4582             " uint16_t bitfieldExtract( uint16_t, int16_t, int16_t);"
4583             "u16vec2 bitfieldExtract(u16vec2, int16_t, int16_t);"
4584             "u16vec3 bitfieldExtract(u16vec3, int16_t, int16_t);"
4585             "u16vec4 bitfieldExtract(u16vec4, int16_t, int16_t);"
4586 
4587             "  int16_t bitfieldInsert(  int16_t base,   int16_t, int16_t, int16_t);"
4588             "i16vec2 bitfieldInsert(i16vec2 base, i16vec2, int16_t, int16_t);"
4589             "i16vec3 bitfieldInsert(i16vec3 base, i16vec3, int16_t, int16_t);"
4590             "i16vec4 bitfieldInsert(i16vec4 base, i16vec4, int16_t, int16_t);"
4591 
4592             " uint16_t bitfieldInsert( uint16_t base,  uint16_t, int16_t, int16_t);"
4593             "u16vec2 bitfieldInsert(u16vec2 base, u16vec2, int16_t, int16_t);"
4594             "u16vec3 bitfieldInsert(u16vec3 base, u16vec3, int16_t, int16_t);"
4595             "u16vec4 bitfieldInsert(u16vec4 base, u16vec4, int16_t, int16_t);"
4596 
4597             "  int16_t bitCount(  int16_t);"
4598             "i16vec2 bitCount(i16vec2);"
4599             "i16vec3 bitCount(i16vec3);"
4600             "i16vec4 bitCount(i16vec4);"
4601 
4602             "  int16_t bitCount( uint16_t);"
4603             "i16vec2 bitCount(u16vec2);"
4604             "i16vec3 bitCount(u16vec3);"
4605             "i16vec4 bitCount(u16vec4);"
4606 
4607             "  int16_t findLSB(  int16_t);"
4608             "i16vec2 findLSB(i16vec2);"
4609             "i16vec3 findLSB(i16vec3);"
4610             "i16vec4 findLSB(i16vec4);"
4611 
4612             "  int16_t findLSB( uint16_t);"
4613             "i16vec2 findLSB(u16vec2);"
4614             "i16vec3 findLSB(u16vec3);"
4615             "i16vec4 findLSB(u16vec4);"
4616 
4617             "  int16_t findMSB(  int16_t);"
4618             "i16vec2 findMSB(i16vec2);"
4619             "i16vec3 findMSB(i16vec3);"
4620             "i16vec4 findMSB(i16vec4);"
4621 
4622             "  int16_t findMSB( uint16_t);"
4623             "i16vec2 findMSB(u16vec2);"
4624             "i16vec3 findMSB(u16vec3);"
4625             "i16vec4 findMSB(u16vec4);"
4626 
4627             "int16_t  pack16(i8vec2);"
4628             "uint16_t pack16(u8vec2);"
4629             "int32_t  pack32(i8vec4);"
4630             "uint32_t pack32(u8vec4);"
4631             "int32_t  pack32(i16vec2);"
4632             "uint32_t pack32(u16vec2);"
4633             "int64_t  pack64(i16vec4);"
4634             "uint64_t pack64(u16vec4);"
4635             "int64_t  pack64(i32vec2);"
4636             "uint64_t pack64(u32vec2);"
4637 
4638             "i8vec2   unpack8(int16_t);"
4639             "u8vec2   unpack8(uint16_t);"
4640             "i8vec4   unpack8(int32_t);"
4641             "u8vec4   unpack8(uint32_t);"
4642             "i16vec2  unpack16(int32_t);"
4643             "u16vec2  unpack16(uint32_t);"
4644             "i16vec4  unpack16(int64_t);"
4645             "u16vec4  unpack16(uint64_t);"
4646             "i32vec2  unpack32(int64_t);"
4647             "u32vec2  unpack32(uint64_t);"
4648 
4649             "float64_t radians(float64_t);"
4650             "f64vec2   radians(f64vec2);"
4651             "f64vec3   radians(f64vec3);"
4652             "f64vec4   radians(f64vec4);"
4653 
4654             "float64_t degrees(float64_t);"
4655             "f64vec2   degrees(f64vec2);"
4656             "f64vec3   degrees(f64vec3);"
4657             "f64vec4   degrees(f64vec4);"
4658 
4659             "float64_t sin(float64_t);"
4660             "f64vec2   sin(f64vec2);"
4661             "f64vec3   sin(f64vec3);"
4662             "f64vec4   sin(f64vec4);"
4663 
4664             "float64_t cos(float64_t);"
4665             "f64vec2   cos(f64vec2);"
4666             "f64vec3   cos(f64vec3);"
4667             "f64vec4   cos(f64vec4);"
4668 
4669             "float64_t tan(float64_t);"
4670             "f64vec2   tan(f64vec2);"
4671             "f64vec3   tan(f64vec3);"
4672             "f64vec4   tan(f64vec4);"
4673 
4674             "float64_t asin(float64_t);"
4675             "f64vec2   asin(f64vec2);"
4676             "f64vec3   asin(f64vec3);"
4677             "f64vec4   asin(f64vec4);"
4678 
4679             "float64_t acos(float64_t);"
4680             "f64vec2   acos(f64vec2);"
4681             "f64vec3   acos(f64vec3);"
4682             "f64vec4   acos(f64vec4);"
4683 
4684             "float64_t atan(float64_t, float64_t);"
4685             "f64vec2   atan(f64vec2,   f64vec2);"
4686             "f64vec3   atan(f64vec3,   f64vec3);"
4687             "f64vec4   atan(f64vec4,   f64vec4);"
4688 
4689             "float64_t atan(float64_t);"
4690             "f64vec2   atan(f64vec2);"
4691             "f64vec3   atan(f64vec3);"
4692             "f64vec4   atan(f64vec4);"
4693 
4694             "float64_t sinh(float64_t);"
4695             "f64vec2   sinh(f64vec2);"
4696             "f64vec3   sinh(f64vec3);"
4697             "f64vec4   sinh(f64vec4);"
4698 
4699             "float64_t cosh(float64_t);"
4700             "f64vec2   cosh(f64vec2);"
4701             "f64vec3   cosh(f64vec3);"
4702             "f64vec4   cosh(f64vec4);"
4703 
4704             "float64_t tanh(float64_t);"
4705             "f64vec2   tanh(f64vec2);"
4706             "f64vec3   tanh(f64vec3);"
4707             "f64vec4   tanh(f64vec4);"
4708 
4709             "float64_t asinh(float64_t);"
4710             "f64vec2   asinh(f64vec2);"
4711             "f64vec3   asinh(f64vec3);"
4712             "f64vec4   asinh(f64vec4);"
4713 
4714             "float64_t acosh(float64_t);"
4715             "f64vec2   acosh(f64vec2);"
4716             "f64vec3   acosh(f64vec3);"
4717             "f64vec4   acosh(f64vec4);"
4718 
4719             "float64_t atanh(float64_t);"
4720             "f64vec2   atanh(f64vec2);"
4721             "f64vec3   atanh(f64vec3);"
4722             "f64vec4   atanh(f64vec4);"
4723 
4724             "float64_t pow(float64_t, float64_t);"
4725             "f64vec2   pow(f64vec2,   f64vec2);"
4726             "f64vec3   pow(f64vec3,   f64vec3);"
4727             "f64vec4   pow(f64vec4,   f64vec4);"
4728 
4729             "float64_t exp(float64_t);"
4730             "f64vec2   exp(f64vec2);"
4731             "f64vec3   exp(f64vec3);"
4732             "f64vec4   exp(f64vec4);"
4733 
4734             "float64_t log(float64_t);"
4735             "f64vec2   log(f64vec2);"
4736             "f64vec3   log(f64vec3);"
4737             "f64vec4   log(f64vec4);"
4738 
4739             "float64_t exp2(float64_t);"
4740             "f64vec2   exp2(f64vec2);"
4741             "f64vec3   exp2(f64vec3);"
4742             "f64vec4   exp2(f64vec4);"
4743 
4744             "float64_t log2(float64_t);"
4745             "f64vec2   log2(f64vec2);"
4746             "f64vec3   log2(f64vec3);"
4747             "f64vec4   log2(f64vec4);"
4748             "\n");
4749         }
4750         if (profile != EEsProfile && version >= 450) {
4751             stageBuiltins[EShLangFragment].append(derivativesAndControl64bits);
4752             stageBuiltins[EShLangFragment].append(
4753                 "float64_t interpolateAtCentroid(float64_t);"
4754                 "f64vec2   interpolateAtCentroid(f64vec2);"
4755                 "f64vec3   interpolateAtCentroid(f64vec3);"
4756                 "f64vec4   interpolateAtCentroid(f64vec4);"
4757 
4758                 "float64_t interpolateAtSample(float64_t, int);"
4759                 "f64vec2   interpolateAtSample(f64vec2,   int);"
4760                 "f64vec3   interpolateAtSample(f64vec3,   int);"
4761                 "f64vec4   interpolateAtSample(f64vec4,   int);"
4762 
4763                 "float64_t interpolateAtOffset(float64_t, f64vec2);"
4764                 "f64vec2   interpolateAtOffset(f64vec2,   f64vec2);"
4765                 "f64vec3   interpolateAtOffset(f64vec3,   f64vec2);"
4766                 "f64vec4   interpolateAtOffset(f64vec4,   f64vec2);"
4767 
4768                 "\n");
4769 
4770     }
4771 
4772     //============================================================================
4773     //
4774     // Prototypes for built-in functions seen by vertex shaders only.
4775     // (Except legacy lod functions, where it depends which release they are
4776     // vertex only.)
4777     //
4778     //============================================================================
4779 
4780     //
4781     // Geometric Functions.
4782     //
4783     if (IncludeLegacy(version, profile, spvVersion))
4784         stageBuiltins[EShLangVertex].append("vec4 ftransform();");
4785 
4786     //
4787     // Original-style texture Functions with lod.
4788     //
4789     TString* s;
4790     if (version == 100)
4791         s = &stageBuiltins[EShLangVertex];
4792     else
4793         s = &commonBuiltins;
4794     if ((profile == EEsProfile && version == 100) ||
4795          profile == ECompatibilityProfile ||
4796         (profile == ECoreProfile && version < 420) ||
4797          profile == ENoProfile) {
4798         if (spvVersion.spv == 0) {
4799             s->append(
4800                 "vec4 texture2DLod(sampler2D, vec2, float);"         // GL_ARB_shader_texture_lod
4801                 "vec4 texture2DProjLod(sampler2D, vec3, float);"     // GL_ARB_shader_texture_lod
4802                 "vec4 texture2DProjLod(sampler2D, vec4, float);"     // GL_ARB_shader_texture_lod
4803                 "vec4 texture3DLod(sampler3D, vec3, float);"         // GL_ARB_shader_texture_lod  // OES_texture_3D, but caught by keyword check
4804                 "vec4 texture3DProjLod(sampler3D, vec4, float);"     // GL_ARB_shader_texture_lod  // OES_texture_3D, but caught by keyword check
4805                 "vec4 textureCubeLod(samplerCube, vec3, float);"     // GL_ARB_shader_texture_lod
4806 
4807                 "\n");
4808         }
4809     }
4810     if ( profile == ECompatibilityProfile ||
4811         (profile == ECoreProfile && version < 420) ||
4812          profile == ENoProfile) {
4813         if (spvVersion.spv == 0) {
4814             s->append(
4815                 "vec4 texture1DLod(sampler1D, float, float);"                          // GL_ARB_shader_texture_lod
4816                 "vec4 texture1DProjLod(sampler1D, vec2, float);"                       // GL_ARB_shader_texture_lod
4817                 "vec4 texture1DProjLod(sampler1D, vec4, float);"                       // GL_ARB_shader_texture_lod
4818                 "vec4 shadow1DLod(sampler1DShadow, vec3, float);"                      // GL_ARB_shader_texture_lod
4819                 "vec4 shadow2DLod(sampler2DShadow, vec3, float);"                      // GL_ARB_shader_texture_lod
4820                 "vec4 shadow1DProjLod(sampler1DShadow, vec4, float);"                  // GL_ARB_shader_texture_lod
4821                 "vec4 shadow2DProjLod(sampler2DShadow, vec4, float);"                  // GL_ARB_shader_texture_lod
4822 
4823                 "vec4 texture1DGradARB(sampler1D, float, float, float);"               // GL_ARB_shader_texture_lod
4824                 "vec4 texture1DProjGradARB(sampler1D, vec2, float, float);"            // GL_ARB_shader_texture_lod
4825                 "vec4 texture1DProjGradARB(sampler1D, vec4, float, float);"            // GL_ARB_shader_texture_lod
4826                 "vec4 texture2DGradARB(sampler2D, vec2, vec2, vec2);"                  // GL_ARB_shader_texture_lod
4827                 "vec4 texture2DProjGradARB(sampler2D, vec3, vec2, vec2);"              // GL_ARB_shader_texture_lod
4828                 "vec4 texture2DProjGradARB(sampler2D, vec4, vec2, vec2);"              // GL_ARB_shader_texture_lod
4829                 "vec4 texture3DGradARB(sampler3D, vec3, vec3, vec3);"                  // GL_ARB_shader_texture_lod
4830                 "vec4 texture3DProjGradARB(sampler3D, vec4, vec3, vec3);"              // GL_ARB_shader_texture_lod
4831                 "vec4 textureCubeGradARB(samplerCube, vec3, vec3, vec3);"              // GL_ARB_shader_texture_lod
4832                 "vec4 shadow1DGradARB(sampler1DShadow, vec3, float, float);"           // GL_ARB_shader_texture_lod
4833                 "vec4 shadow1DProjGradARB( sampler1DShadow, vec4, float, float);"      // GL_ARB_shader_texture_lod
4834                 "vec4 shadow2DGradARB(sampler2DShadow, vec3, vec2, vec2);"             // GL_ARB_shader_texture_lod
4835                 "vec4 shadow2DProjGradARB( sampler2DShadow, vec4, vec2, vec2);"        // GL_ARB_shader_texture_lod
4836                 "vec4 texture2DRectGradARB(sampler2DRect, vec2, vec2, vec2);"          // GL_ARB_shader_texture_lod
4837                 "vec4 texture2DRectProjGradARB( sampler2DRect, vec3, vec2, vec2);"     // GL_ARB_shader_texture_lod
4838                 "vec4 texture2DRectProjGradARB( sampler2DRect, vec4, vec2, vec2);"     // GL_ARB_shader_texture_lod
4839                 "vec4 shadow2DRectGradARB( sampler2DRectShadow, vec3, vec2, vec2);"    // GL_ARB_shader_texture_lod
4840                 "vec4 shadow2DRectProjGradARB(sampler2DRectShadow, vec4, vec2, vec2);" // GL_ARB_shader_texture_lod
4841 
4842                 "\n");
4843         }
4844     }
4845 
4846     if ((profile != EEsProfile && version >= 150) ||
4847         (profile == EEsProfile && version >= 310)) {
4848         //============================================================================
4849         //
4850         // Prototypes for built-in functions seen by geometry shaders only.
4851         //
4852         //============================================================================
4853 
4854         if (profile != EEsProfile && version >= 400) {
4855             stageBuiltins[EShLangGeometry].append(
4856                 "void EmitStreamVertex(int);"
4857                 "void EndStreamPrimitive(int);"
4858                 );
4859         }
4860         stageBuiltins[EShLangGeometry].append(
4861             "void EmitVertex();"
4862             "void EndPrimitive();"
4863             "\n");
4864     }
4865 
4866     //============================================================================
4867     //
4868     // Prototypes for all control functions.
4869     //
4870     //============================================================================
4871     bool esBarrier = (profile == EEsProfile && version >= 310);
4872     if ((profile != EEsProfile && version >= 150) || esBarrier)
4873         stageBuiltins[EShLangTessControl].append(
4874             "void barrier();"
4875             );
4876     if ((profile != EEsProfile && version >= 420) || esBarrier)
4877         stageBuiltins[EShLangCompute].append(
4878             "void barrier();"
4879             );
4880 #ifdef NV_EXTENSIONS
4881     if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
4882         stageBuiltins[EShLangMeshNV].append(
4883             "void barrier();"
4884             );
4885         stageBuiltins[EShLangTaskNV].append(
4886             "void barrier();"
4887             );
4888     }
4889 #endif
4890     if ((profile != EEsProfile && version >= 130) || esBarrier)
4891         commonBuiltins.append(
4892             "void memoryBarrier();"
4893             );
4894     if ((profile != EEsProfile && version >= 420) || esBarrier) {
4895         commonBuiltins.append(
4896             "void memoryBarrierAtomicCounter();"
4897             "void memoryBarrierBuffer();"
4898             "void memoryBarrierImage();"
4899             );
4900         stageBuiltins[EShLangCompute].append(
4901             "void memoryBarrierShared();"
4902             "void groupMemoryBarrier();"
4903             );
4904     }
4905 #ifdef NV_EXTENSIONS
4906     if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
4907         stageBuiltins[EShLangMeshNV].append(
4908             "void memoryBarrierShared();"
4909             "void groupMemoryBarrier();"
4910         );
4911         stageBuiltins[EShLangTaskNV].append(
4912             "void memoryBarrierShared();"
4913             "void groupMemoryBarrier();"
4914         );
4915     }
4916 #endif
4917 
4918     commonBuiltins.append("void controlBarrier(int, int, int, int);\n"
4919                           "void memoryBarrier(int, int, int);\n");
4920 
4921     //============================================================================
4922     //
4923     // Prototypes for built-in functions seen by fragment shaders only.
4924     //
4925     //============================================================================
4926 
4927     //
4928     // Original-style texture Functions with bias.
4929     //
4930     if (spvVersion.spv == 0 && (profile != EEsProfile || version == 100)) {
4931         stageBuiltins[EShLangFragment].append(
4932             "vec4 texture2D(sampler2D, vec2, float);"
4933             "vec4 texture2DProj(sampler2D, vec3, float);"
4934             "vec4 texture2DProj(sampler2D, vec4, float);"
4935             "vec4 texture3D(sampler3D, vec3, float);"        // OES_texture_3D
4936             "vec4 texture3DProj(sampler3D, vec4, float);"    // OES_texture_3D
4937             "vec4 textureCube(samplerCube, vec3, float);"
4938 
4939             "\n");
4940     }
4941     if (spvVersion.spv == 0 && (profile != EEsProfile && version > 100)) {
4942         stageBuiltins[EShLangFragment].append(
4943             "vec4 texture1D(sampler1D, float, float);"
4944             "vec4 texture1DProj(sampler1D, vec2, float);"
4945             "vec4 texture1DProj(sampler1D, vec4, float);"
4946             "vec4 shadow1D(sampler1DShadow, vec3, float);"
4947             "vec4 shadow2D(sampler2DShadow, vec3, float);"
4948             "vec4 shadow1DProj(sampler1DShadow, vec4, float);"
4949             "vec4 shadow2DProj(sampler2DShadow, vec4, float);"
4950 
4951             "\n");
4952     }
4953     if (spvVersion.spv == 0 && profile == EEsProfile) {
4954         stageBuiltins[EShLangFragment].append(
4955             "vec4 texture2DLodEXT(sampler2D, vec2, float);"      // GL_EXT_shader_texture_lod
4956             "vec4 texture2DProjLodEXT(sampler2D, vec3, float);"  // GL_EXT_shader_texture_lod
4957             "vec4 texture2DProjLodEXT(sampler2D, vec4, float);"  // GL_EXT_shader_texture_lod
4958             "vec4 textureCubeLodEXT(samplerCube, vec3, float);"  // GL_EXT_shader_texture_lod
4959 
4960             "\n");
4961     }
4962 
4963     stageBuiltins[EShLangFragment].append(derivatives);
4964     stageBuiltins[EShLangFragment].append("\n");
4965 
4966     // GL_ARB_derivative_control
4967     if (profile != EEsProfile && version >= 400) {
4968         stageBuiltins[EShLangFragment].append(derivativeControls);
4969         stageBuiltins[EShLangFragment].append("\n");
4970     }
4971 
4972     // GL_OES_shader_multisample_interpolation
4973     if ((profile == EEsProfile && version >= 310) ||
4974         (profile != EEsProfile && version >= 400)) {
4975         stageBuiltins[EShLangFragment].append(
4976             "float interpolateAtCentroid(float);"
4977             "vec2  interpolateAtCentroid(vec2);"
4978             "vec3  interpolateAtCentroid(vec3);"
4979             "vec4  interpolateAtCentroid(vec4);"
4980 
4981             "float interpolateAtSample(float, int);"
4982             "vec2  interpolateAtSample(vec2,  int);"
4983             "vec3  interpolateAtSample(vec3,  int);"
4984             "vec4  interpolateAtSample(vec4,  int);"
4985 
4986             "float interpolateAtOffset(float, vec2);"
4987             "vec2  interpolateAtOffset(vec2,  vec2);"
4988             "vec3  interpolateAtOffset(vec3,  vec2);"
4989             "vec4  interpolateAtOffset(vec4,  vec2);"
4990 
4991             "\n");
4992     }
4993 
4994 #ifdef AMD_EXTENSIONS
4995     // GL_AMD_shader_explicit_vertex_parameter
4996     if (profile != EEsProfile && version >= 450) {
4997         stageBuiltins[EShLangFragment].append(
4998             "float interpolateAtVertexAMD(float, uint);"
4999             "vec2  interpolateAtVertexAMD(vec2,  uint);"
5000             "vec3  interpolateAtVertexAMD(vec3,  uint);"
5001             "vec4  interpolateAtVertexAMD(vec4,  uint);"
5002 
5003             "int   interpolateAtVertexAMD(int,   uint);"
5004             "ivec2 interpolateAtVertexAMD(ivec2, uint);"
5005             "ivec3 interpolateAtVertexAMD(ivec3, uint);"
5006             "ivec4 interpolateAtVertexAMD(ivec4, uint);"
5007 
5008             "uint  interpolateAtVertexAMD(uint,  uint);"
5009             "uvec2 interpolateAtVertexAMD(uvec2, uint);"
5010             "uvec3 interpolateAtVertexAMD(uvec3, uint);"
5011             "uvec4 interpolateAtVertexAMD(uvec4, uint);"
5012 
5013             "float16_t interpolateAtVertexAMD(float16_t, uint);"
5014             "f16vec2   interpolateAtVertexAMD(f16vec2,   uint);"
5015             "f16vec3   interpolateAtVertexAMD(f16vec3,   uint);"
5016             "f16vec4   interpolateAtVertexAMD(f16vec4,   uint);"
5017 
5018             "\n");
5019     }
5020 
5021     // GL_AMD_gpu_shader_half_float
5022     if (profile != EEsProfile && version >= 450) {
5023         stageBuiltins[EShLangFragment].append(derivativesAndControl16bits);
5024         stageBuiltins[EShLangFragment].append("\n");
5025 
5026         stageBuiltins[EShLangFragment].append(
5027             "float16_t interpolateAtCentroid(float16_t);"
5028             "f16vec2   interpolateAtCentroid(f16vec2);"
5029             "f16vec3   interpolateAtCentroid(f16vec3);"
5030             "f16vec4   interpolateAtCentroid(f16vec4);"
5031 
5032             "float16_t interpolateAtSample(float16_t, int);"
5033             "f16vec2   interpolateAtSample(f16vec2,   int);"
5034             "f16vec3   interpolateAtSample(f16vec3,   int);"
5035             "f16vec4   interpolateAtSample(f16vec4,   int);"
5036 
5037             "float16_t interpolateAtOffset(float16_t, f16vec2);"
5038             "f16vec2   interpolateAtOffset(f16vec2,   f16vec2);"
5039             "f16vec3   interpolateAtOffset(f16vec3,   f16vec2);"
5040             "f16vec4   interpolateAtOffset(f16vec4,   f16vec2);"
5041 
5042             "\n");
5043     }
5044 
5045     // GL_AMD_shader_fragment_mask
5046     if (profile != EEsProfile && version >= 450 && spvVersion.vulkan > 0) {
5047         stageBuiltins[EShLangFragment].append(
5048             "uint fragmentMaskFetchAMD(subpassInputMS);"
5049             "uint fragmentMaskFetchAMD(isubpassInputMS);"
5050             "uint fragmentMaskFetchAMD(usubpassInputMS);"
5051 
5052             "vec4  fragmentFetchAMD(subpassInputMS,  uint);"
5053             "ivec4 fragmentFetchAMD(isubpassInputMS, uint);"
5054             "uvec4 fragmentFetchAMD(usubpassInputMS, uint);"
5055 
5056             "\n");
5057         }
5058 #endif
5059 
5060 #ifdef NV_EXTENSIONS
5061 
5062     // Builtins for GL_NV_ray_tracing
5063     if (profile != EEsProfile && version >= 460) {
5064         stageBuiltins[EShLangRayGenNV].append(
5065             "void traceNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
5066             "void executeCallableNV(uint, int);"
5067             "\n");
5068         stageBuiltins[EShLangIntersectNV].append(
5069             "bool reportIntersectionNV(float, uint);"
5070             "\n");
5071         stageBuiltins[EShLangAnyHitNV].append(
5072             "void ignoreIntersectionNV();"
5073             "void terminateRayNV();"
5074             "\n");
5075         stageBuiltins[EShLangClosestHitNV].append(
5076             "void traceNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
5077             "void executeCallableNV(uint, int);"
5078             "\n");
5079         stageBuiltins[EShLangMissNV].append(
5080             "void traceNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
5081             "void executeCallableNV(uint, int);"
5082             "\n");
5083         stageBuiltins[EShLangCallableNV].append(
5084             "void executeCallableNV(uint, int);"
5085             "\n");
5086     }
5087 
5088     //E_SPV_NV_compute_shader_derivatives
5089 
5090     stageBuiltins[EShLangCompute].append(derivatives);
5091     stageBuiltins[EShLangCompute].append(derivativeControls);
5092     stageBuiltins[EShLangCompute].append("\n");
5093 
5094 
5095     if (profile != EEsProfile && version >= 450) {
5096 
5097         stageBuiltins[EShLangCompute].append(derivativesAndControl16bits);
5098         stageBuiltins[EShLangCompute].append(derivativesAndControl64bits);
5099         stageBuiltins[EShLangCompute].append("\n");
5100     }
5101 
5102     // Builtins for GL_NV_mesh_shader
5103     if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
5104         stageBuiltins[EShLangMeshNV].append(
5105             "void writePackedPrimitiveIndices4x8NV(uint, uint);"
5106             "\n");
5107     }
5108 #endif
5109 
5110     //============================================================================
5111     //
5112     // Standard Uniforms
5113     //
5114     //============================================================================
5115 
5116     //
5117     // Depth range in window coordinates, p. 33
5118     //
5119     if (spvVersion.spv == 0) {
5120         commonBuiltins.append(
5121             "struct gl_DepthRangeParameters {"
5122             );
5123         if (profile == EEsProfile) {
5124             commonBuiltins.append(
5125                 "highp float near;"   // n
5126                 "highp float far;"    // f
5127                 "highp float diff;"   // f - n
5128                 );
5129         } else {
5130             commonBuiltins.append(
5131                 "float near;"  // n
5132                 "float far;"   // f
5133                 "float diff;"  // f - n
5134                 );
5135         }
5136 
5137         commonBuiltins.append(
5138             "};"
5139             "uniform gl_DepthRangeParameters gl_DepthRange;"
5140             "\n");
5141     }
5142 
5143     if (spvVersion.spv == 0 && IncludeLegacy(version, profile, spvVersion)) {
5144         //
5145         // Matrix state. p. 31, 32, 37, 39, 40.
5146         //
5147         commonBuiltins.append(
5148             "uniform mat4  gl_ModelViewMatrix;"
5149             "uniform mat4  gl_ProjectionMatrix;"
5150             "uniform mat4  gl_ModelViewProjectionMatrix;"
5151 
5152             //
5153             // Derived matrix state that provides inverse and transposed versions
5154             // of the matrices above.
5155             //
5156             "uniform mat3  gl_NormalMatrix;"
5157 
5158             "uniform mat4  gl_ModelViewMatrixInverse;"
5159             "uniform mat4  gl_ProjectionMatrixInverse;"
5160             "uniform mat4  gl_ModelViewProjectionMatrixInverse;"
5161 
5162             "uniform mat4  gl_ModelViewMatrixTranspose;"
5163             "uniform mat4  gl_ProjectionMatrixTranspose;"
5164             "uniform mat4  gl_ModelViewProjectionMatrixTranspose;"
5165 
5166             "uniform mat4  gl_ModelViewMatrixInverseTranspose;"
5167             "uniform mat4  gl_ProjectionMatrixInverseTranspose;"
5168             "uniform mat4  gl_ModelViewProjectionMatrixInverseTranspose;"
5169 
5170             //
5171             // Normal scaling p. 39.
5172             //
5173             "uniform float gl_NormalScale;"
5174 
5175             //
5176             // Point Size, p. 66, 67.
5177             //
5178             "struct gl_PointParameters {"
5179                 "float size;"
5180                 "float sizeMin;"
5181                 "float sizeMax;"
5182                 "float fadeThresholdSize;"
5183                 "float distanceConstantAttenuation;"
5184                 "float distanceLinearAttenuation;"
5185                 "float distanceQuadraticAttenuation;"
5186             "};"
5187 
5188             "uniform gl_PointParameters gl_Point;"
5189 
5190             //
5191             // Material State p. 50, 55.
5192             //
5193             "struct gl_MaterialParameters {"
5194                 "vec4  emission;"    // Ecm
5195                 "vec4  ambient;"     // Acm
5196                 "vec4  diffuse;"     // Dcm
5197                 "vec4  specular;"    // Scm
5198                 "float shininess;"   // Srm
5199             "};"
5200             "uniform gl_MaterialParameters  gl_FrontMaterial;"
5201             "uniform gl_MaterialParameters  gl_BackMaterial;"
5202 
5203             //
5204             // Light State p 50, 53, 55.
5205             //
5206             "struct gl_LightSourceParameters {"
5207                 "vec4  ambient;"             // Acli
5208                 "vec4  diffuse;"             // Dcli
5209                 "vec4  specular;"            // Scli
5210                 "vec4  position;"            // Ppli
5211                 "vec4  halfVector;"          // Derived: Hi
5212                 "vec3  spotDirection;"       // Sdli
5213                 "float spotExponent;"        // Srli
5214                 "float spotCutoff;"          // Crli
5215                                                         // (range: [0.0,90.0], 180.0)
5216                 "float spotCosCutoff;"       // Derived: cos(Crli)
5217                                                         // (range: [1.0,0.0],-1.0)
5218                 "float constantAttenuation;" // K0
5219                 "float linearAttenuation;"   // K1
5220                 "float quadraticAttenuation;"// K2
5221             "};"
5222 
5223             "struct gl_LightModelParameters {"
5224                 "vec4  ambient;"       // Acs
5225             "};"
5226 
5227             "uniform gl_LightModelParameters  gl_LightModel;"
5228 
5229             //
5230             // Derived state from products of light and material.
5231             //
5232             "struct gl_LightModelProducts {"
5233                 "vec4  sceneColor;"     // Derived. Ecm + Acm * Acs
5234             "};"
5235 
5236             "uniform gl_LightModelProducts gl_FrontLightModelProduct;"
5237             "uniform gl_LightModelProducts gl_BackLightModelProduct;"
5238 
5239             "struct gl_LightProducts {"
5240                 "vec4  ambient;"        // Acm * Acli
5241                 "vec4  diffuse;"        // Dcm * Dcli
5242                 "vec4  specular;"       // Scm * Scli
5243             "};"
5244 
5245             //
5246             // Fog p. 161
5247             //
5248             "struct gl_FogParameters {"
5249                 "vec4  color;"
5250                 "float density;"
5251                 "float start;"
5252                 "float end;"
5253                 "float scale;"   //  1 / (gl_FogEnd - gl_FogStart)
5254             "};"
5255 
5256             "uniform gl_FogParameters gl_Fog;"
5257 
5258             "\n");
5259     }
5260 
5261     //============================================================================
5262     //
5263     // Define the interface to the compute shader.
5264     //
5265     //============================================================================
5266 
5267     if ((profile != EEsProfile && version >= 420) ||
5268         (profile == EEsProfile && version >= 310)) {
5269         stageBuiltins[EShLangCompute].append(
5270             "in    highp uvec3 gl_NumWorkGroups;"
5271             "const highp uvec3 gl_WorkGroupSize = uvec3(1,1,1);"
5272 
5273             "in highp uvec3 gl_WorkGroupID;"
5274             "in highp uvec3 gl_LocalInvocationID;"
5275 
5276             "in highp uvec3 gl_GlobalInvocationID;"
5277             "in highp uint gl_LocalInvocationIndex;"
5278 
5279             "\n");
5280     }
5281 
5282     if ((profile != EEsProfile && version >= 140) ||
5283         (profile == EEsProfile && version >= 310)) {
5284         stageBuiltins[EShLangCompute].append(
5285             "in highp int gl_DeviceIndex;"     // GL_EXT_device_group
5286             "\n");
5287     }
5288 
5289 #ifdef NV_EXTENSIONS
5290     //============================================================================
5291     //
5292     // Define the interface to the mesh/task shader.
5293     //
5294     //============================================================================
5295 
5296     if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
5297         // per-vertex attributes
5298         stageBuiltins[EShLangMeshNV].append(
5299             "out gl_MeshPerVertexNV {"
5300                 "vec4 gl_Position;"
5301                 "float gl_PointSize;"
5302                 "float gl_ClipDistance[];"
5303                 "float gl_CullDistance[];"
5304                 "perviewNV vec4 gl_PositionPerViewNV[];"
5305                 "perviewNV float gl_ClipDistancePerViewNV[][];"
5306                 "perviewNV float gl_CullDistancePerViewNV[][];"
5307             "} gl_MeshVerticesNV[];"
5308         );
5309 
5310         // per-primitive attributes
5311         stageBuiltins[EShLangMeshNV].append(
5312             "perprimitiveNV out gl_MeshPerPrimitiveNV {"
5313                 "int gl_PrimitiveID;"
5314                 "int gl_Layer;"
5315                 "int gl_ViewportIndex;"
5316                 "int gl_ViewportMask[];"
5317                 "perviewNV int gl_LayerPerViewNV[];"
5318                 "perviewNV int gl_ViewportMaskPerViewNV[][];"
5319             "} gl_MeshPrimitivesNV[];"
5320         );
5321 
5322         stageBuiltins[EShLangMeshNV].append(
5323             "out uint gl_PrimitiveCountNV;"
5324             "out uint gl_PrimitiveIndicesNV[];"
5325 
5326             "in uint gl_MeshViewCountNV;"
5327             "in uint gl_MeshViewIndicesNV[4];"
5328 
5329             "const highp uvec3 gl_WorkGroupSize = uvec3(1,1,1);"
5330 
5331             "in highp uvec3 gl_WorkGroupID;"
5332             "in highp uvec3 gl_LocalInvocationID;"
5333 
5334             "in highp uvec3 gl_GlobalInvocationID;"
5335             "in highp uint gl_LocalInvocationIndex;"
5336 
5337             "\n");
5338 
5339         stageBuiltins[EShLangTaskNV].append(
5340             "out uint gl_TaskCountNV;"
5341 
5342             "const highp uvec3 gl_WorkGroupSize = uvec3(1,1,1);"
5343 
5344             "in highp uvec3 gl_WorkGroupID;"
5345             "in highp uvec3 gl_LocalInvocationID;"
5346 
5347             "in highp uvec3 gl_GlobalInvocationID;"
5348             "in highp uint gl_LocalInvocationIndex;"
5349 
5350             "\n");
5351     }
5352 
5353     if (profile != EEsProfile && version >= 450) {
5354         stageBuiltins[EShLangMeshNV].append(
5355             "in highp int gl_DeviceIndex;"     // GL_EXT_device_group
5356             "in int gl_DrawIDARB;"             // GL_ARB_shader_draw_parameters
5357             "\n");
5358 
5359         stageBuiltins[EShLangTaskNV].append(
5360             "in highp int gl_DeviceIndex;"     // GL_EXT_device_group
5361             "in int gl_DrawIDARB;"             // GL_ARB_shader_draw_parameters
5362             "\n");
5363 
5364         if (version >= 460) {
5365             stageBuiltins[EShLangMeshNV].append(
5366                 "in int gl_DrawID;"
5367                 "\n");
5368 
5369             stageBuiltins[EShLangTaskNV].append(
5370                 "in int gl_DrawID;"
5371                 "\n");
5372         }
5373     }
5374 #endif
5375 
5376     //============================================================================
5377     //
5378     // Define the interface to the vertex shader.
5379     //
5380     //============================================================================
5381 
5382     if (profile != EEsProfile) {
5383         if (version < 130) {
5384             stageBuiltins[EShLangVertex].append(
5385                 "attribute vec4  gl_Color;"
5386                 "attribute vec4  gl_SecondaryColor;"
5387                 "attribute vec3  gl_Normal;"
5388                 "attribute vec4  gl_Vertex;"
5389                 "attribute vec4  gl_MultiTexCoord0;"
5390                 "attribute vec4  gl_MultiTexCoord1;"
5391                 "attribute vec4  gl_MultiTexCoord2;"
5392                 "attribute vec4  gl_MultiTexCoord3;"
5393                 "attribute vec4  gl_MultiTexCoord4;"
5394                 "attribute vec4  gl_MultiTexCoord5;"
5395                 "attribute vec4  gl_MultiTexCoord6;"
5396                 "attribute vec4  gl_MultiTexCoord7;"
5397                 "attribute float gl_FogCoord;"
5398                 "\n");
5399         } else if (IncludeLegacy(version, profile, spvVersion)) {
5400             stageBuiltins[EShLangVertex].append(
5401                 "in vec4  gl_Color;"
5402                 "in vec4  gl_SecondaryColor;"
5403                 "in vec3  gl_Normal;"
5404                 "in vec4  gl_Vertex;"
5405                 "in vec4  gl_MultiTexCoord0;"
5406                 "in vec4  gl_MultiTexCoord1;"
5407                 "in vec4  gl_MultiTexCoord2;"
5408                 "in vec4  gl_MultiTexCoord3;"
5409                 "in vec4  gl_MultiTexCoord4;"
5410                 "in vec4  gl_MultiTexCoord5;"
5411                 "in vec4  gl_MultiTexCoord6;"
5412                 "in vec4  gl_MultiTexCoord7;"
5413                 "in float gl_FogCoord;"
5414                 "\n");
5415         }
5416 
5417         if (version < 150) {
5418             if (version < 130) {
5419                 stageBuiltins[EShLangVertex].append(
5420                     "        vec4  gl_ClipVertex;"       // needs qualifier fixed later
5421                     "varying vec4  gl_FrontColor;"
5422                     "varying vec4  gl_BackColor;"
5423                     "varying vec4  gl_FrontSecondaryColor;"
5424                     "varying vec4  gl_BackSecondaryColor;"
5425                     "varying vec4  gl_TexCoord[];"
5426                     "varying float gl_FogFragCoord;"
5427                     "\n");
5428             } else if (IncludeLegacy(version, profile, spvVersion)) {
5429                 stageBuiltins[EShLangVertex].append(
5430                     "    vec4  gl_ClipVertex;"       // needs qualifier fixed later
5431                     "out vec4  gl_FrontColor;"
5432                     "out vec4  gl_BackColor;"
5433                     "out vec4  gl_FrontSecondaryColor;"
5434                     "out vec4  gl_BackSecondaryColor;"
5435                     "out vec4  gl_TexCoord[];"
5436                     "out float gl_FogFragCoord;"
5437                     "\n");
5438             }
5439             stageBuiltins[EShLangVertex].append(
5440                 "vec4 gl_Position;"   // needs qualifier fixed later
5441                 "float gl_PointSize;" // needs qualifier fixed later
5442                 );
5443 
5444             if (version == 130 || version == 140)
5445                 stageBuiltins[EShLangVertex].append(
5446                     "out float gl_ClipDistance[];"
5447                     );
5448         } else {
5449             // version >= 150
5450             stageBuiltins[EShLangVertex].append(
5451                 "out gl_PerVertex {"
5452                     "vec4 gl_Position;"     // needs qualifier fixed later
5453                     "float gl_PointSize;"   // needs qualifier fixed later
5454                     "float gl_ClipDistance[];"
5455                     );
5456             if (IncludeLegacy(version, profile, spvVersion))
5457                 stageBuiltins[EShLangVertex].append(
5458                     "vec4 gl_ClipVertex;"   // needs qualifier fixed later
5459                     "vec4 gl_FrontColor;"
5460                     "vec4 gl_BackColor;"
5461                     "vec4 gl_FrontSecondaryColor;"
5462                     "vec4 gl_BackSecondaryColor;"
5463                     "vec4 gl_TexCoord[];"
5464                     "float gl_FogFragCoord;"
5465                     );
5466             if (version >= 450)
5467                 stageBuiltins[EShLangVertex].append(
5468                     "float gl_CullDistance[];"
5469                     );
5470             stageBuiltins[EShLangVertex].append(
5471                 "};"
5472                 "\n");
5473         }
5474         if (version >= 130 && spvVersion.vulkan == 0)
5475             stageBuiltins[EShLangVertex].append(
5476                 "int gl_VertexID;"            // needs qualifier fixed later
5477                 );
5478         if (version >= 140 && spvVersion.vulkan == 0)
5479             stageBuiltins[EShLangVertex].append(
5480                 "int gl_InstanceID;"          // needs qualifier fixed later
5481                 );
5482         if (spvVersion.vulkan > 0 && version >= 140)
5483             stageBuiltins[EShLangVertex].append(
5484                 "in int gl_VertexIndex;"
5485                 "in int gl_InstanceIndex;"
5486                 );
5487         if (version >= 440) {
5488             stageBuiltins[EShLangVertex].append(
5489                 "in int gl_BaseVertexARB;"
5490                 "in int gl_BaseInstanceARB;"
5491                 "in int gl_DrawIDARB;"
5492                 );
5493         }
5494         if (version >= 410) {
5495             stageBuiltins[EShLangVertex].append(
5496                 "out int gl_ViewportIndex;"
5497                 "out int gl_Layer;"
5498                 );
5499         }
5500         if (version >= 460) {
5501             stageBuiltins[EShLangVertex].append(
5502                 "in int gl_BaseVertex;"
5503                 "in int gl_BaseInstance;"
5504                 "in int gl_DrawID;"
5505                 );
5506         }
5507 
5508 #ifdef NV_EXTENSIONS
5509         if (version >= 450)
5510             stageBuiltins[EShLangVertex].append(
5511                 "out int gl_ViewportMask[];"             // GL_NV_viewport_array2
5512                 "out int gl_SecondaryViewportMaskNV[];"  // GL_NV_stereo_view_rendering
5513                 "out vec4 gl_SecondaryPositionNV;"       // GL_NV_stereo_view_rendering
5514                 "out vec4 gl_PositionPerViewNV[];"       // GL_NVX_multiview_per_view_attributes
5515                 "out int  gl_ViewportMaskPerViewNV[];"   // GL_NVX_multiview_per_view_attributes
5516                 );
5517 #endif
5518 
5519     } else {
5520         // ES profile
5521         if (version == 100) {
5522             stageBuiltins[EShLangVertex].append(
5523                 "highp   vec4  gl_Position;"  // needs qualifier fixed later
5524                 "mediump float gl_PointSize;" // needs qualifier fixed later
5525                 );
5526         } else {
5527             if (spvVersion.vulkan == 0)
5528                 stageBuiltins[EShLangVertex].append(
5529                     "in highp int gl_VertexID;"      // needs qualifier fixed later
5530                     "in highp int gl_InstanceID;"    // needs qualifier fixed later
5531                     );
5532             if (spvVersion.vulkan > 0)
5533                 stageBuiltins[EShLangVertex].append(
5534                     "in highp int gl_VertexIndex;"
5535                     "in highp int gl_InstanceIndex;"
5536                     );
5537             if (version < 310)
5538                 stageBuiltins[EShLangVertex].append(
5539                     "highp vec4  gl_Position;"    // needs qualifier fixed later
5540                     "highp float gl_PointSize;"   // needs qualifier fixed later
5541                     );
5542             else
5543                 stageBuiltins[EShLangVertex].append(
5544                     "out gl_PerVertex {"
5545                         "highp vec4  gl_Position;"    // needs qualifier fixed later
5546                         "highp float gl_PointSize;"   // needs qualifier fixed later
5547                     "};"
5548                     );
5549         }
5550     }
5551 
5552     if ((profile != EEsProfile && version >= 140) ||
5553         (profile == EEsProfile && version >= 310)) {
5554         stageBuiltins[EShLangVertex].append(
5555             "in highp int gl_DeviceIndex;"     // GL_EXT_device_group
5556             "in highp int gl_ViewIndex;"       // GL_EXT_multiview
5557             "\n");
5558     }
5559 
5560     if (version >= 300 /* both ES and non-ES */) {
5561         stageBuiltins[EShLangVertex].append(
5562             "in highp uint gl_ViewID_OVR;"     // GL_OVR_multiview, GL_OVR_multiview2
5563             "\n");
5564     }
5565 
5566 
5567     //============================================================================
5568     //
5569     // Define the interface to the geometry shader.
5570     //
5571     //============================================================================
5572 
5573     if (profile == ECoreProfile || profile == ECompatibilityProfile) {
5574         stageBuiltins[EShLangGeometry].append(
5575             "in gl_PerVertex {"
5576                 "vec4 gl_Position;"
5577                 "float gl_PointSize;"
5578                 "float gl_ClipDistance[];"
5579                 );
5580         if (profile == ECompatibilityProfile)
5581             stageBuiltins[EShLangGeometry].append(
5582                 "vec4 gl_ClipVertex;"
5583                 "vec4 gl_FrontColor;"
5584                 "vec4 gl_BackColor;"
5585                 "vec4 gl_FrontSecondaryColor;"
5586                 "vec4 gl_BackSecondaryColor;"
5587                 "vec4 gl_TexCoord[];"
5588                 "float gl_FogFragCoord;"
5589                 );
5590         if (version >= 450)
5591             stageBuiltins[EShLangGeometry].append(
5592                 "float gl_CullDistance[];"
5593 #ifdef NV_EXTENSIONS
5594                 "vec4 gl_SecondaryPositionNV;"   // GL_NV_stereo_view_rendering
5595                 "vec4 gl_PositionPerViewNV[];"   // GL_NVX_multiview_per_view_attributes
5596 #endif
5597                 );
5598         stageBuiltins[EShLangGeometry].append(
5599             "} gl_in[];"
5600 
5601             "in int gl_PrimitiveIDIn;"
5602             "out gl_PerVertex {"
5603                 "vec4 gl_Position;"
5604                 "float gl_PointSize;"
5605                 "float gl_ClipDistance[];"
5606                 "\n");
5607         if (profile == ECompatibilityProfile && version >= 400)
5608             stageBuiltins[EShLangGeometry].append(
5609                 "vec4 gl_ClipVertex;"
5610                 "vec4 gl_FrontColor;"
5611                 "vec4 gl_BackColor;"
5612                 "vec4 gl_FrontSecondaryColor;"
5613                 "vec4 gl_BackSecondaryColor;"
5614                 "vec4 gl_TexCoord[];"
5615                 "float gl_FogFragCoord;"
5616                 );
5617         if (version >= 450)
5618             stageBuiltins[EShLangGeometry].append(
5619                 "float gl_CullDistance[];"
5620                 );
5621         stageBuiltins[EShLangGeometry].append(
5622             "};"
5623 
5624             "out int gl_PrimitiveID;"
5625             "out int gl_Layer;");
5626 
5627         if (version >= 150)
5628             stageBuiltins[EShLangGeometry].append(
5629             "out int gl_ViewportIndex;"
5630             );
5631 
5632         if (profile == ECompatibilityProfile && version < 400)
5633             stageBuiltins[EShLangGeometry].append(
5634             "out vec4 gl_ClipVertex;"
5635             );
5636 
5637         if (version >= 400)
5638             stageBuiltins[EShLangGeometry].append(
5639             "in int gl_InvocationID;"
5640             );
5641 
5642 #ifdef NV_EXTENSIONS
5643         if (version >= 450)
5644             stageBuiltins[EShLangGeometry].append(
5645                 "out int gl_ViewportMask[];"               // GL_NV_viewport_array2
5646                 "out int gl_SecondaryViewportMaskNV[];"    // GL_NV_stereo_view_rendering
5647                 "out vec4 gl_SecondaryPositionNV;"         // GL_NV_stereo_view_rendering
5648                 "out vec4 gl_PositionPerViewNV[];"         // GL_NVX_multiview_per_view_attributes
5649                 "out int  gl_ViewportMaskPerViewNV[];"     // GL_NVX_multiview_per_view_attributes
5650             );
5651 #endif
5652 
5653         stageBuiltins[EShLangGeometry].append("\n");
5654     } else if (profile == EEsProfile && version >= 310) {
5655         stageBuiltins[EShLangGeometry].append(
5656             "in gl_PerVertex {"
5657                 "highp vec4 gl_Position;"
5658                 "highp float gl_PointSize;"
5659             "} gl_in[];"
5660             "\n"
5661             "in highp int gl_PrimitiveIDIn;"
5662             "in highp int gl_InvocationID;"
5663             "\n"
5664             "out gl_PerVertex {"
5665                 "highp vec4 gl_Position;"
5666                 "highp float gl_PointSize;"
5667             "};"
5668             "\n"
5669             "out highp int gl_PrimitiveID;"
5670             "out highp int gl_Layer;"
5671             "\n"
5672             );
5673     }
5674 
5675     if ((profile != EEsProfile && version >= 140) ||
5676         (profile == EEsProfile && version >= 310)) {
5677         stageBuiltins[EShLangGeometry].append(
5678             "in highp int gl_DeviceIndex;"     // GL_EXT_device_group
5679             "in highp int gl_ViewIndex;"       // GL_EXT_multiview
5680             "\n");
5681     }
5682 
5683     //============================================================================
5684     //
5685     // Define the interface to the tessellation control shader.
5686     //
5687     //============================================================================
5688 
5689     if (profile != EEsProfile && version >= 150) {
5690         // Note:  "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below,
5691         // as it depends on the resource sizing of gl_MaxPatchVertices.
5692 
5693         stageBuiltins[EShLangTessControl].append(
5694             "in int gl_PatchVerticesIn;"
5695             "in int gl_PrimitiveID;"
5696             "in int gl_InvocationID;"
5697 
5698             "out gl_PerVertex {"
5699                 "vec4 gl_Position;"
5700                 "float gl_PointSize;"
5701                 "float gl_ClipDistance[];"
5702                 );
5703         if (profile == ECompatibilityProfile)
5704             stageBuiltins[EShLangTessControl].append(
5705                 "vec4 gl_ClipVertex;"
5706                 "vec4 gl_FrontColor;"
5707                 "vec4 gl_BackColor;"
5708                 "vec4 gl_FrontSecondaryColor;"
5709                 "vec4 gl_BackSecondaryColor;"
5710                 "vec4 gl_TexCoord[];"
5711                 "float gl_FogFragCoord;"
5712                 );
5713         if (version >= 450)
5714             stageBuiltins[EShLangTessControl].append(
5715                 "float gl_CullDistance[];"
5716 #ifdef NV_EXTENSIONS
5717                 "int  gl_ViewportMask[];"             // GL_NV_viewport_array2
5718                 "vec4 gl_SecondaryPositionNV;"        // GL_NV_stereo_view_rendering
5719                 "int  gl_SecondaryViewportMaskNV[];"  // GL_NV_stereo_view_rendering
5720                 "vec4 gl_PositionPerViewNV[];"        // GL_NVX_multiview_per_view_attributes
5721                 "int  gl_ViewportMaskPerViewNV[];"    // GL_NVX_multiview_per_view_attributes
5722 #endif
5723                 );
5724         stageBuiltins[EShLangTessControl].append(
5725             "} gl_out[];"
5726 
5727             "patch out float gl_TessLevelOuter[4];"
5728             "patch out float gl_TessLevelInner[2];"
5729             "\n");
5730 
5731         if (version >= 410)
5732             stageBuiltins[EShLangTessControl].append(
5733                 "out int gl_ViewportIndex;"
5734                 "out int gl_Layer;"
5735                 "\n");
5736 
5737     } else {
5738         // Note:  "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below,
5739         // as it depends on the resource sizing of gl_MaxPatchVertices.
5740 
5741         stageBuiltins[EShLangTessControl].append(
5742             "in highp int gl_PatchVerticesIn;"
5743             "in highp int gl_PrimitiveID;"
5744             "in highp int gl_InvocationID;"
5745 
5746             "out gl_PerVertex {"
5747                 "highp vec4 gl_Position;"
5748                 "highp float gl_PointSize;"
5749                 );
5750         stageBuiltins[EShLangTessControl].append(
5751             "} gl_out[];"
5752 
5753             "patch out highp float gl_TessLevelOuter[4];"
5754             "patch out highp float gl_TessLevelInner[2];"
5755             "patch out highp vec4 gl_BoundingBoxOES[2];"
5756             "\n");
5757     }
5758 
5759     if ((profile != EEsProfile && version >= 140) ||
5760         (profile == EEsProfile && version >= 310)) {
5761         stageBuiltins[EShLangTessControl].append(
5762             "in highp int gl_DeviceIndex;"     // GL_EXT_device_group
5763             "in highp int gl_ViewIndex;"       // GL_EXT_multiview
5764             "\n");
5765     }
5766 
5767     //============================================================================
5768     //
5769     // Define the interface to the tessellation evaluation shader.
5770     //
5771     //============================================================================
5772 
5773     if (profile != EEsProfile && version >= 150) {
5774         // Note:  "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below,
5775         // as it depends on the resource sizing of gl_MaxPatchVertices.
5776 
5777         stageBuiltins[EShLangTessEvaluation].append(
5778             "in int gl_PatchVerticesIn;"
5779             "in int gl_PrimitiveID;"
5780             "in vec3 gl_TessCoord;"
5781 
5782             "patch in float gl_TessLevelOuter[4];"
5783             "patch in float gl_TessLevelInner[2];"
5784 
5785             "out gl_PerVertex {"
5786                 "vec4 gl_Position;"
5787                 "float gl_PointSize;"
5788                 "float gl_ClipDistance[];"
5789             );
5790         if (version >= 400 && profile == ECompatibilityProfile)
5791             stageBuiltins[EShLangTessEvaluation].append(
5792                 "vec4 gl_ClipVertex;"
5793                 "vec4 gl_FrontColor;"
5794                 "vec4 gl_BackColor;"
5795                 "vec4 gl_FrontSecondaryColor;"
5796                 "vec4 gl_BackSecondaryColor;"
5797                 "vec4 gl_TexCoord[];"
5798                 "float gl_FogFragCoord;"
5799                 );
5800         if (version >= 450)
5801             stageBuiltins[EShLangTessEvaluation].append(
5802                 "float gl_CullDistance[];"
5803                 );
5804         stageBuiltins[EShLangTessEvaluation].append(
5805             "};"
5806             "\n");
5807 
5808         if (version >= 410)
5809             stageBuiltins[EShLangTessEvaluation].append(
5810                 "out int gl_ViewportIndex;"
5811                 "out int gl_Layer;"
5812                 "\n");
5813 
5814 #ifdef NV_EXTENSIONS
5815         if (version >= 450)
5816             stageBuiltins[EShLangTessEvaluation].append(
5817                 "out int  gl_ViewportMask[];"             // GL_NV_viewport_array2
5818                 "out vec4 gl_SecondaryPositionNV;"        // GL_NV_stereo_view_rendering
5819                 "out int  gl_SecondaryViewportMaskNV[];"  // GL_NV_stereo_view_rendering
5820                 "out vec4 gl_PositionPerViewNV[];"        // GL_NVX_multiview_per_view_attributes
5821                 "out int  gl_ViewportMaskPerViewNV[];"    // GL_NVX_multiview_per_view_attributes
5822                 );
5823 #endif
5824 
5825     } else if (profile == EEsProfile && version >= 310) {
5826         // Note:  "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below,
5827         // as it depends on the resource sizing of gl_MaxPatchVertices.
5828 
5829         stageBuiltins[EShLangTessEvaluation].append(
5830             "in highp int gl_PatchVerticesIn;"
5831             "in highp int gl_PrimitiveID;"
5832             "in highp vec3 gl_TessCoord;"
5833 
5834             "patch in highp float gl_TessLevelOuter[4];"
5835             "patch in highp float gl_TessLevelInner[2];"
5836 
5837             "out gl_PerVertex {"
5838                 "highp vec4 gl_Position;"
5839                 "highp float gl_PointSize;"
5840             );
5841         stageBuiltins[EShLangTessEvaluation].append(
5842             "};"
5843             "\n");
5844     }
5845 
5846     if ((profile != EEsProfile && version >= 140) ||
5847         (profile == EEsProfile && version >= 310)) {
5848         stageBuiltins[EShLangTessEvaluation].append(
5849             "in highp int gl_DeviceIndex;"     // GL_EXT_device_group
5850             "in highp int gl_ViewIndex;"       // GL_EXT_multiview
5851             "\n");
5852     }
5853 
5854     //============================================================================
5855     //
5856     // Define the interface to the fragment shader.
5857     //
5858     //============================================================================
5859 
5860     if (profile != EEsProfile) {
5861 
5862         stageBuiltins[EShLangFragment].append(
5863             "vec4  gl_FragCoord;"   // needs qualifier fixed later
5864             "bool  gl_FrontFacing;" // needs qualifier fixed later
5865             "float gl_FragDepth;"   // needs qualifier fixed later
5866             );
5867         if (version >= 120)
5868             stageBuiltins[EShLangFragment].append(
5869                 "vec2 gl_PointCoord;"  // needs qualifier fixed later
5870                 );
5871         if (version >= 140)
5872             stageBuiltins[EShLangFragment].append(
5873                 "out int gl_FragStencilRefARB;"
5874                 );
5875         if (IncludeLegacy(version, profile, spvVersion) || (! ForwardCompatibility && version < 420))
5876             stageBuiltins[EShLangFragment].append(
5877                 "vec4 gl_FragColor;"   // needs qualifier fixed later
5878                 );
5879 
5880         if (version < 130) {
5881             stageBuiltins[EShLangFragment].append(
5882                 "varying vec4  gl_Color;"
5883                 "varying vec4  gl_SecondaryColor;"
5884                 "varying vec4  gl_TexCoord[];"
5885                 "varying float gl_FogFragCoord;"
5886                 );
5887         } else {
5888             stageBuiltins[EShLangFragment].append(
5889                 "in float gl_ClipDistance[];"
5890                 );
5891 
5892             if (IncludeLegacy(version, profile, spvVersion)) {
5893                 if (version < 150)
5894                     stageBuiltins[EShLangFragment].append(
5895                         "in float gl_FogFragCoord;"
5896                         "in vec4  gl_TexCoord[];"
5897                         "in vec4  gl_Color;"
5898                         "in vec4  gl_SecondaryColor;"
5899                         );
5900                 else
5901                     stageBuiltins[EShLangFragment].append(
5902                         "in gl_PerFragment {"
5903                             "in float gl_FogFragCoord;"
5904                             "in vec4  gl_TexCoord[];"
5905                             "in vec4  gl_Color;"
5906                             "in vec4  gl_SecondaryColor;"
5907                         "};"
5908                         );
5909             }
5910         }
5911 
5912         if (version >= 150)
5913             stageBuiltins[EShLangFragment].append(
5914                 "flat in int gl_PrimitiveID;"
5915                 );
5916 
5917         if (version >= 400) {
5918             stageBuiltins[EShLangFragment].append(
5919                 "flat in  int  gl_SampleID;"
5920                 "     in  vec2 gl_SamplePosition;"
5921                 "flat in  int  gl_SampleMaskIn[];"
5922                 "     out int  gl_SampleMask[];"
5923                 );
5924             if (spvVersion.spv == 0)
5925                 stageBuiltins[EShLangFragment].append(
5926                     "uniform int gl_NumSamples;"
5927                     );
5928         }
5929 
5930         if (version >= 430)
5931             stageBuiltins[EShLangFragment].append(
5932                 "flat in int gl_Layer;"
5933                 "flat in int gl_ViewportIndex;"
5934                 );
5935 
5936         if (version >= 450)
5937             stageBuiltins[EShLangFragment].append(
5938                 "in float gl_CullDistance[];"
5939                 "bool gl_HelperInvocation;"     // needs qualifier fixed later
5940                 );
5941 
5942         if (version >= 450)
5943             stageBuiltins[EShLangFragment].append( // GL_EXT_fragment_invocation_density
5944                 "flat in ivec2 gl_FragSizeEXT;"
5945                 "flat in int   gl_FragInvocationCountEXT;"
5946                 );
5947 
5948 #ifdef AMD_EXTENSIONS
5949         if (version >= 450)
5950             stageBuiltins[EShLangFragment].append(
5951                 "in vec2 gl_BaryCoordNoPerspAMD;"
5952                 "in vec2 gl_BaryCoordNoPerspCentroidAMD;"
5953                 "in vec2 gl_BaryCoordNoPerspSampleAMD;"
5954                 "in vec2 gl_BaryCoordSmoothAMD;"
5955                 "in vec2 gl_BaryCoordSmoothCentroidAMD;"
5956                 "in vec2 gl_BaryCoordSmoothSampleAMD;"
5957                 "in vec3 gl_BaryCoordPullModelAMD;"
5958                 );
5959 #endif
5960 
5961 #ifdef NV_EXTENSIONS
5962         if (version >= 430)
5963             stageBuiltins[EShLangFragment].append(
5964                 "in bool gl_FragFullyCoveredNV;"
5965                 );
5966         if (version >= 450)
5967             stageBuiltins[EShLangFragment].append(
5968                 "flat in ivec2 gl_FragmentSizeNV;"          // GL_NV_shading_rate_image
5969                 "flat in int   gl_InvocationsPerPixelNV;"
5970                 "in vec3 gl_BaryCoordNV;"                   // GL_NV_fragment_shader_barycentric
5971                 "in vec3 gl_BaryCoordNoPerspNV;"
5972                 );
5973 
5974 #endif
5975     } else {
5976         // ES profile
5977 
5978         if (version == 100) {
5979             stageBuiltins[EShLangFragment].append(
5980                 "mediump vec4 gl_FragCoord;"    // needs qualifier fixed later
5981                 "        bool gl_FrontFacing;"  // needs qualifier fixed later
5982                 "mediump vec4 gl_FragColor;"    // needs qualifier fixed later
5983                 "mediump vec2 gl_PointCoord;"   // needs qualifier fixed later
5984                 );
5985         }
5986         if (version >= 300) {
5987             stageBuiltins[EShLangFragment].append(
5988                 "highp   vec4  gl_FragCoord;"    // needs qualifier fixed later
5989                 "        bool  gl_FrontFacing;"  // needs qualifier fixed later
5990                 "mediump vec2  gl_PointCoord;"   // needs qualifier fixed later
5991                 "highp   float gl_FragDepth;"    // needs qualifier fixed later
5992                 );
5993         }
5994         if (version >= 310) {
5995             stageBuiltins[EShLangFragment].append(
5996                 "bool gl_HelperInvocation;"          // needs qualifier fixed later
5997                 "flat in highp int gl_PrimitiveID;"  // needs qualifier fixed later
5998                 "flat in highp int gl_Layer;"        // needs qualifier fixed later
5999                 );
6000 
6001             stageBuiltins[EShLangFragment].append(  // GL_OES_sample_variables
6002                 "flat  in lowp     int gl_SampleID;"
6003                 "      in mediump vec2 gl_SamplePosition;"
6004                 "flat  in highp    int gl_SampleMaskIn[];"
6005                 "     out highp    int gl_SampleMask[];"
6006                 );
6007             if (spvVersion.spv == 0)
6008                 stageBuiltins[EShLangFragment].append(  // GL_OES_sample_variables
6009                     "uniform lowp int gl_NumSamples;"
6010                     );
6011         }
6012         stageBuiltins[EShLangFragment].append(
6013             "highp float gl_FragDepthEXT;"       // GL_EXT_frag_depth
6014             );
6015 
6016         if (version >= 310)
6017             stageBuiltins[EShLangFragment].append( // GL_EXT_fragment_invocation_density
6018                 "flat in ivec2 gl_FragSizeEXT;"
6019                 "flat in int   gl_FragInvocationCountEXT;"
6020             );
6021 #ifdef NV_EXTENSIONS
6022         if (version >= 320)
6023             stageBuiltins[EShLangFragment].append( // GL_NV_shading_rate_image
6024                 "flat in ivec2 gl_FragmentSizeNV;"
6025                 "flat in int   gl_InvocationsPerPixelNV;"
6026             );
6027         if (version >= 320)
6028             stageBuiltins[EShLangFragment].append(
6029                 "in vec3 gl_BaryCoordNV;"
6030                 "in vec3 gl_BaryCoordNoPerspNV;"
6031                 );
6032 #endif
6033 
6034     }
6035     stageBuiltins[EShLangFragment].append("\n");
6036 
6037     if (version >= 130)
6038         add2ndGenerationSamplingImaging(version, profile, spvVersion);
6039 
6040     // GL_ARB_shader_ballot
6041     if (profile != EEsProfile && version >= 450) {
6042         const char* ballotDecls =
6043             "uniform uint gl_SubGroupSizeARB;"
6044             "in uint     gl_SubGroupInvocationARB;"
6045             "in uint64_t gl_SubGroupEqMaskARB;"
6046             "in uint64_t gl_SubGroupGeMaskARB;"
6047             "in uint64_t gl_SubGroupGtMaskARB;"
6048             "in uint64_t gl_SubGroupLeMaskARB;"
6049             "in uint64_t gl_SubGroupLtMaskARB;"
6050             "\n";
6051         const char* fragmentBallotDecls =
6052             "uniform uint gl_SubGroupSizeARB;"
6053             "flat in uint     gl_SubGroupInvocationARB;"
6054             "flat in uint64_t gl_SubGroupEqMaskARB;"
6055             "flat in uint64_t gl_SubGroupGeMaskARB;"
6056             "flat in uint64_t gl_SubGroupGtMaskARB;"
6057             "flat in uint64_t gl_SubGroupLeMaskARB;"
6058             "flat in uint64_t gl_SubGroupLtMaskARB;"
6059             "\n";
6060         stageBuiltins[EShLangVertex]        .append(ballotDecls);
6061         stageBuiltins[EShLangTessControl]   .append(ballotDecls);
6062         stageBuiltins[EShLangTessEvaluation].append(ballotDecls);
6063         stageBuiltins[EShLangGeometry]      .append(ballotDecls);
6064         stageBuiltins[EShLangCompute]       .append(ballotDecls);
6065         stageBuiltins[EShLangFragment]      .append(fragmentBallotDecls);
6066 #ifdef NV_EXTENSIONS
6067         stageBuiltins[EShLangMeshNV]        .append(ballotDecls);
6068         stageBuiltins[EShLangTaskNV]        .append(ballotDecls);
6069 #endif
6070     }
6071 
6072     if ((profile != EEsProfile && version >= 140) ||
6073         (profile == EEsProfile && version >= 310)) {
6074         stageBuiltins[EShLangFragment].append(
6075             "flat in highp int gl_DeviceIndex;"     // GL_EXT_device_group
6076             "flat in highp int gl_ViewIndex;"       // GL_EXT_multiview
6077             "\n");
6078     }
6079 
6080     // GL_KHR_shader_subgroup
6081     if (spvVersion.vulkan > 0) {
6082         const char* ballotDecls =
6083             "in mediump uint  gl_SubgroupSize;"
6084             "in mediump uint  gl_SubgroupInvocationID;"
6085             "in highp   uvec4 gl_SubgroupEqMask;"
6086             "in highp   uvec4 gl_SubgroupGeMask;"
6087             "in highp   uvec4 gl_SubgroupGtMask;"
6088             "in highp   uvec4 gl_SubgroupLeMask;"
6089             "in highp   uvec4 gl_SubgroupLtMask;"
6090             "\n";
6091         const char* fragmentBallotDecls =
6092             "flat in mediump uint  gl_SubgroupSize;"
6093             "flat in mediump uint  gl_SubgroupInvocationID;"
6094             "flat in highp   uvec4 gl_SubgroupEqMask;"
6095             "flat in highp   uvec4 gl_SubgroupGeMask;"
6096             "flat in highp   uvec4 gl_SubgroupGtMask;"
6097             "flat in highp   uvec4 gl_SubgroupLeMask;"
6098             "flat in highp   uvec4 gl_SubgroupLtMask;"
6099             "\n";
6100         stageBuiltins[EShLangVertex]        .append(ballotDecls);
6101         stageBuiltins[EShLangTessControl]   .append(ballotDecls);
6102         stageBuiltins[EShLangTessEvaluation].append(ballotDecls);
6103         stageBuiltins[EShLangGeometry]      .append(ballotDecls);
6104         stageBuiltins[EShLangCompute]       .append(ballotDecls);
6105         stageBuiltins[EShLangFragment]      .append(fragmentBallotDecls);
6106 #ifdef NV_EXTENSIONS
6107         stageBuiltins[EShLangMeshNV]        .append(ballotDecls);
6108         stageBuiltins[EShLangTaskNV]        .append(ballotDecls);
6109 #endif
6110 
6111         stageBuiltins[EShLangCompute].append(
6112             "highp   in uint  gl_NumSubgroups;"
6113             "highp   in uint  gl_SubgroupID;"
6114             "\n");
6115 #ifdef NV_EXTENSIONS
6116         stageBuiltins[EShLangMeshNV].append(
6117             "highp   in uint  gl_NumSubgroups;"
6118             "highp   in uint  gl_SubgroupID;"
6119             "\n");
6120         stageBuiltins[EShLangTaskNV].append(
6121             "highp   in uint  gl_NumSubgroups;"
6122             "highp   in uint  gl_SubgroupID;"
6123             "\n");
6124 #endif
6125     }
6126 
6127 #ifdef NV_EXTENSIONS
6128     // GL_NV_ray_tracing
6129     if (profile != EEsProfile && version >= 460) {
6130 
6131         const char *constRayFlags =
6132             "const uint gl_RayFlagsNoneNV = 0U;"
6133             "const uint gl_RayFlagsOpaqueNV = 1U;"
6134             "const uint gl_RayFlagsNoOpaqueNV = 2U;"
6135             "const uint gl_RayFlagsTerminateOnFirstHitNV = 4U;"
6136             "const uint gl_RayFlagsSkipClosestHitShaderNV = 8U;"
6137             "const uint gl_RayFlagsCullBackFacingTrianglesNV = 16U;"
6138             "const uint gl_RayFlagsCullFrontFacingTrianglesNV = 32U;"
6139             "const uint gl_RayFlagsCullOpaqueNV = 64U;"
6140             "const uint gl_RayFlagsCullNoOpaqueNV = 128U;"
6141             "\n";
6142         const char *rayGenDecls =
6143             "in    uvec3  gl_LaunchIDNV;"
6144             "in    uvec3  gl_LaunchSizeNV;"
6145             "\n";
6146         const char *intersectDecls =
6147             "in    uvec3  gl_LaunchIDNV;"
6148             "in    uvec3  gl_LaunchSizeNV;"
6149             "in     int   gl_PrimitiveID;"
6150             "in     int   gl_InstanceID;"
6151             "in     int   gl_InstanceCustomIndexNV;"
6152             "in    vec3   gl_WorldRayOriginNV;"
6153             "in    vec3   gl_WorldRayDirectionNV;"
6154             "in    vec3   gl_ObjectRayOriginNV;"
6155             "in    vec3   gl_ObjectRayDirectionNV;"
6156             "in    float  gl_RayTminNV;"
6157             "in    float  gl_RayTmaxNV;"
6158             "in    mat4x3 gl_ObjectToWorldNV;"
6159             "in    mat4x3 gl_WorldToObjectNV;"
6160             "in    uint   gl_IncomingRayFlagsNV;"
6161             "\n";
6162         const char *hitDecls =
6163             "in    uvec3  gl_LaunchIDNV;"
6164             "in    uvec3  gl_LaunchSizeNV;"
6165             "in     int   gl_PrimitiveID;"
6166             "in     int   gl_InstanceID;"
6167             "in     int   gl_InstanceCustomIndexNV;"
6168             "in    vec3   gl_WorldRayOriginNV;"
6169             "in    vec3   gl_WorldRayDirectionNV;"
6170             "in    vec3   gl_ObjectRayOriginNV;"
6171             "in    vec3   gl_ObjectRayDirectionNV;"
6172             "in    float  gl_RayTminNV;"
6173             "in    float  gl_RayTmaxNV;"
6174             "in    float  gl_HitTNV;"
6175             "in    uint   gl_HitKindNV;"
6176             "in    mat4x3 gl_ObjectToWorldNV;"
6177             "in    mat4x3 gl_WorldToObjectNV;"
6178             "in    uint   gl_IncomingRayFlagsNV;"
6179             "\n";
6180         const char *missDecls =
6181             "in    uvec3  gl_LaunchIDNV;"
6182             "in    uvec3  gl_LaunchSizeNV;"
6183             "in    vec3   gl_WorldRayOriginNV;"
6184             "in    vec3   gl_WorldRayDirectionNV;"
6185             "in    vec3   gl_ObjectRayOriginNV;"
6186             "in    vec3   gl_ObjectRayDirectionNV;"
6187             "in    float  gl_RayTminNV;"
6188             "in    float  gl_RayTmaxNV;"
6189             "in    uint   gl_IncomingRayFlagsNV;"
6190             "\n";
6191 
6192         const char *callableDecls =
6193             "in    uvec3  gl_LaunchIDNV;"
6194             "in    uvec3  gl_LaunchSizeNV;"
6195             "in    uint   gl_IncomingRayFlagsNV;"
6196             "\n";
6197 
6198         stageBuiltins[EShLangRayGenNV].append(rayGenDecls);
6199         stageBuiltins[EShLangRayGenNV].append(constRayFlags);
6200 
6201         stageBuiltins[EShLangIntersectNV].append(intersectDecls);
6202         stageBuiltins[EShLangIntersectNV].append(constRayFlags);
6203 
6204         stageBuiltins[EShLangAnyHitNV].append(hitDecls);
6205         stageBuiltins[EShLangAnyHitNV].append(constRayFlags);
6206 
6207         stageBuiltins[EShLangClosestHitNV].append(hitDecls);
6208         stageBuiltins[EShLangClosestHitNV].append(constRayFlags);
6209 
6210         stageBuiltins[EShLangMissNV].append(missDecls);
6211         stageBuiltins[EShLangMissNV].append(constRayFlags);
6212 
6213         stageBuiltins[EShLangCallableNV].append(callableDecls);
6214         stageBuiltins[EShLangCallableNV].append(constRayFlags);
6215 
6216     }
6217     if ((profile != EEsProfile && version >= 140)) {
6218         const char *deviceIndex =
6219             "in highp int gl_DeviceIndex;"     // GL_EXT_device_group
6220             "\n";
6221 
6222         stageBuiltins[EShLangRayGenNV].append(deviceIndex);
6223         stageBuiltins[EShLangIntersectNV].append(deviceIndex);
6224         stageBuiltins[EShLangAnyHitNV].append(deviceIndex);
6225         stageBuiltins[EShLangClosestHitNV].append(deviceIndex);
6226         stageBuiltins[EShLangMissNV].append(deviceIndex);
6227     }
6228 #endif
6229 
6230     if (version >= 300 /* both ES and non-ES */) {
6231         stageBuiltins[EShLangFragment].append(
6232             "flat in highp uint gl_ViewID_OVR;"     // GL_OVR_multiview, GL_OVR_multiview2
6233             "\n");
6234     }
6235 
6236     if ((profile != EEsProfile && version >= 420) ||
6237         (profile == EEsProfile && version >= 310)) {
6238         commonBuiltins.append("const int gl_ScopeDevice      = 1;\n");
6239         commonBuiltins.append("const int gl_ScopeWorkgroup   = 2;\n");
6240         commonBuiltins.append("const int gl_ScopeSubgroup    = 3;\n");
6241         commonBuiltins.append("const int gl_ScopeInvocation  = 4;\n");
6242         commonBuiltins.append("const int gl_ScopeQueueFamily = 5;\n");
6243 
6244         commonBuiltins.append("const int gl_SemanticsRelaxed         = 0x0;\n");
6245         commonBuiltins.append("const int gl_SemanticsAcquire         = 0x2;\n");
6246         commonBuiltins.append("const int gl_SemanticsRelease         = 0x4;\n");
6247         commonBuiltins.append("const int gl_SemanticsAcquireRelease  = 0x8;\n");
6248         commonBuiltins.append("const int gl_SemanticsMakeAvailable   = 0x2000;\n");
6249         commonBuiltins.append("const int gl_SemanticsMakeVisible     = 0x4000;\n");
6250 
6251         commonBuiltins.append("const int gl_StorageSemanticsNone     = 0x0;\n");
6252         commonBuiltins.append("const int gl_StorageSemanticsBuffer   = 0x40;\n");
6253         commonBuiltins.append("const int gl_StorageSemanticsShared   = 0x100;\n");
6254         commonBuiltins.append("const int gl_StorageSemanticsImage    = 0x800;\n");
6255         commonBuiltins.append("const int gl_StorageSemanticsOutput   = 0x1000;\n");
6256     }
6257 
6258     // printf("%s\n", commonBuiltins.c_str());
6259     // printf("%s\n", stageBuiltins[EShLangFragment].c_str());
6260 }
6261 
6262 //
6263 // Helper function for initialize(), to add the second set of names for texturing,
6264 // when adding context-independent built-in functions.
6265 //
add2ndGenerationSamplingImaging(int version,EProfile profile,const SpvVersion & spvVersion)6266 void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile, const SpvVersion& spvVersion)
6267 {
6268     //
6269     // In this function proper, enumerate the types, then calls the next set of functions
6270     // to enumerate all the uses for that type.
6271     //
6272 #ifdef AMD_EXTENSIONS
6273     TBasicType bTypes[4] = { EbtFloat, EbtFloat16, EbtInt, EbtUint };
6274 #else
6275     TBasicType bTypes[3] = { EbtFloat, EbtInt, EbtUint };
6276 #endif
6277     bool skipBuffer = (profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 140);
6278     bool skipCubeArrayed = (profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 130);
6279 
6280     // enumerate all the types
6281     for (int image = 0; image <= 1; ++image) { // loop over "bool" image vs sampler
6282 
6283         for (int shadow = 0; shadow <= 1; ++shadow) { // loop over "bool" shadow or not
6284             for (int ms = 0; ms <=1; ++ms) {
6285                 if ((ms || image) && shadow)
6286                     continue;
6287                 if (ms && profile != EEsProfile && version < 150)
6288                     continue;
6289                 if (ms && image && profile == EEsProfile)
6290                     continue;
6291                 if (ms && profile == EEsProfile && version < 310)
6292                     continue;
6293 
6294                 for (int arrayed = 0; arrayed <= 1; ++arrayed) { // loop over "bool" arrayed or not
6295                     for (int dim = Esd1D; dim < EsdNumDims; ++dim) { // 1D, 2D, ..., buffer
6296                         if (dim == EsdSubpass && spvVersion.vulkan == 0)
6297                             continue;
6298                         if (dim == EsdSubpass && (image || shadow || arrayed))
6299                             continue;
6300                         if ((dim == Esd1D || dim == EsdRect) && profile == EEsProfile)
6301                             continue;
6302                         if (dim != Esd2D && dim != EsdSubpass && ms)
6303                             continue;
6304                         if ((dim == Esd3D || dim == EsdRect) && arrayed)
6305                             continue;
6306                         if (dim == Esd3D && shadow)
6307                             continue;
6308                         if (dim == EsdCube && arrayed && skipCubeArrayed)
6309                             continue;
6310                         if (dim == EsdBuffer && skipBuffer)
6311                             continue;
6312                         if (dim == EsdBuffer && (shadow || arrayed || ms))
6313                             continue;
6314                         if (ms && arrayed && profile == EEsProfile && version < 310)
6315                             continue;
6316 #ifdef AMD_EXTENSIONS
6317                         for (int bType = 0; bType < 4; ++bType) { // float, float16, int, uint results
6318 
6319                             if (shadow && bType > 1)
6320                                 continue;
6321 
6322                             if (bTypes[bType] == EbtFloat16 && (profile == EEsProfile ||version < 450))
6323                                 continue;
6324 #else
6325                         for (int bType = 0; bType < 3; ++bType) { // float, int, uint results
6326 
6327                             if (shadow && bType > 0)
6328                                 continue;
6329 #endif
6330                             if (dim == EsdRect && version < 140 && bType > 0)
6331                                 continue;
6332 
6333                             //
6334                             // Now, make all the function prototypes for the type we just built...
6335                             //
6336 
6337                             TSampler sampler;
6338                             if (dim == EsdSubpass) {
6339                                 sampler.setSubpass(bTypes[bType], ms ? true : false);
6340                             } else if (image) {
6341                                 sampler.setImage(bTypes[bType], (TSamplerDim)dim, arrayed ? true : false,
6342                                                                                   shadow  ? true : false,
6343                                                                                   ms      ? true : false);
6344                             } else {
6345                                 sampler.set(bTypes[bType], (TSamplerDim)dim, arrayed ? true : false,
6346                                                                              shadow  ? true : false,
6347                                                                              ms      ? true : false);
6348                             }
6349 
6350                             TString typeName = sampler.getString();
6351 
6352                             if (dim == EsdSubpass) {
6353                                 addSubpassSampling(sampler, typeName, version, profile);
6354                                 continue;
6355                             }
6356 
6357                             addQueryFunctions(sampler, typeName, version, profile);
6358 
6359                             if (image)
6360                                 addImageFunctions(sampler, typeName, version, profile);
6361                             else {
6362                                 addSamplingFunctions(sampler, typeName, version, profile);
6363                                 addGatherFunctions(sampler, typeName, version, profile);
6364 
6365                                 if (spvVersion.vulkan > 0 && sampler.isCombined() && !sampler.shadow) {
6366                                     // Base Vulkan allows texelFetch() for
6367                                     // textureBuffer (i.e. without sampler).
6368                                     //
6369                                     // GL_EXT_samplerless_texture_functions
6370                                     // allows texelFetch() and query functions
6371                                     // (other than textureQueryLod()) for all
6372                                     // texture types.
6373                                     sampler.setTexture(sampler.type, sampler.dim, sampler.arrayed, sampler.shadow,
6374                                                        sampler.ms);
6375                                     TString textureTypeName = sampler.getString();
6376                                     addSamplingFunctions(sampler, textureTypeName, version, profile);
6377                                     addQueryFunctions(sampler, textureTypeName, version, profile);
6378                                 }
6379                             }
6380                         }
6381                     }
6382                 }
6383             }
6384         }
6385     }
6386 
6387     //
6388     // sparseTexelsResidentARB()
6389     //
6390 
6391     if (profile != EEsProfile && version >= 450) {
6392         commonBuiltins.append("bool sparseTexelsResidentARB(int code);\n");
6393     }
6394 }
6395 
6396 //
6397 // Helper function for add2ndGenerationSamplingImaging(),
6398 // when adding context-independent built-in functions.
6399 //
6400 // Add all the query functions for the given type.
6401 //
6402 void TBuiltIns::addQueryFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile)
6403 {
6404     if (sampler.image && ((profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 430)))
6405         return;
6406 
6407     //
6408     // textureSize() and imageSize()
6409     //
6410 
6411     int sizeDims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0) - (sampler.dim == EsdCube ? 1 : 0);
6412     if (profile == EEsProfile)
6413         commonBuiltins.append("highp ");
6414     if (sizeDims == 1)
6415         commonBuiltins.append("int");
6416     else {
6417         commonBuiltins.append("ivec");
6418         commonBuiltins.append(postfixes[sizeDims]);
6419     }
6420     if (sampler.image)
6421         commonBuiltins.append(" imageSize(readonly writeonly volatile coherent ");
6422     else
6423         commonBuiltins.append(" textureSize(");
6424     commonBuiltins.append(typeName);
6425     if (! sampler.image && sampler.dim != EsdRect && sampler.dim != EsdBuffer && ! sampler.ms)
6426         commonBuiltins.append(",int);\n");
6427     else
6428         commonBuiltins.append(");\n");
6429 
6430     //
6431     // textureSamples() and imageSamples()
6432     //
6433 
6434     // GL_ARB_shader_texture_image_samples
6435     // TODO: spec issue? there are no memory qualifiers; how to query a writeonly/readonly image, etc?
6436     if (profile != EEsProfile && version >= 430 && sampler.ms) {
6437         commonBuiltins.append("int ");
6438         if (sampler.image)
6439             commonBuiltins.append("imageSamples(readonly writeonly volatile coherent ");
6440         else
6441             commonBuiltins.append("textureSamples(");
6442         commonBuiltins.append(typeName);
6443         commonBuiltins.append(");\n");
6444     }
6445 
6446     //
6447     // textureQueryLod(), fragment stage only
6448     //
6449 
6450     if (profile != EEsProfile && version >= 400 && sampler.combined && sampler.dim != EsdRect && ! sampler.ms && sampler.dim != EsdBuffer) {
6451 #ifdef AMD_EXTENSIONS
6452         for (int f16TexAddr = 0; f16TexAddr < 2; ++f16TexAddr) {
6453             if (f16TexAddr && sampler.type != EbtFloat16)
6454                 continue;
6455 #endif
6456             stageBuiltins[EShLangFragment].append("vec2 textureQueryLod(");
6457             stageBuiltins[EShLangFragment].append(typeName);
6458             if (dimMap[sampler.dim] == 1)
6459 #ifdef AMD_EXTENSIONS
6460                 if (f16TexAddr)
6461                     stageBuiltins[EShLangFragment].append(", float16_t");
6462                 else
6463                     stageBuiltins[EShLangFragment].append(", float");
6464 #else
6465                 stageBuiltins[EShLangFragment].append(", float");
6466 #endif
6467             else {
6468 #ifdef AMD_EXTENSIONS
6469                 if (f16TexAddr)
6470                     stageBuiltins[EShLangFragment].append(", f16vec");
6471                 else
6472                     stageBuiltins[EShLangFragment].append(", vec");
6473 #else
6474                 stageBuiltins[EShLangFragment].append(", vec");
6475 #endif
6476                 stageBuiltins[EShLangFragment].append(postfixes[dimMap[sampler.dim]]);
6477             }
6478             stageBuiltins[EShLangFragment].append(");\n");
6479 #ifdef AMD_EXTENSIONS
6480         }
6481 #endif
6482 
6483 #ifdef NV_EXTENSIONS
6484         stageBuiltins[EShLangCompute].append("vec2 textureQueryLod(");
6485         stageBuiltins[EShLangCompute].append(typeName);
6486         if (dimMap[sampler.dim] == 1)
6487             stageBuiltins[EShLangCompute].append(", float");
6488         else {
6489             stageBuiltins[EShLangCompute].append(", vec");
6490             stageBuiltins[EShLangCompute].append(postfixes[dimMap[sampler.dim]]);
6491         }
6492         stageBuiltins[EShLangCompute].append(");\n");
6493 #endif
6494     }
6495 
6496     //
6497     // textureQueryLevels()
6498     //
6499 
6500     if (profile != EEsProfile && version >= 430 && ! sampler.image && sampler.dim != EsdRect && ! sampler.ms && sampler.dim != EsdBuffer) {
6501         commonBuiltins.append("int textureQueryLevels(");
6502         commonBuiltins.append(typeName);
6503         commonBuiltins.append(");\n");
6504     }
6505 }
6506 
6507 //
6508 // Helper function for add2ndGenerationSamplingImaging(),
6509 // when adding context-independent built-in functions.
6510 //
6511 // Add all the image access functions for the given type.
6512 //
6513 void TBuiltIns::addImageFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile)
6514 {
6515     int dims = dimMap[sampler.dim];
6516     // most things with an array add a dimension, except for cubemaps
6517     if (sampler.arrayed && sampler.dim != EsdCube)
6518         ++dims;
6519 
6520     TString imageParams = typeName;
6521     if (dims == 1)
6522         imageParams.append(", int");
6523     else {
6524         imageParams.append(", ivec");
6525         imageParams.append(postfixes[dims]);
6526     }
6527     if (sampler.ms)
6528         imageParams.append(", int");
6529 
6530     if (profile == EEsProfile)
6531         commonBuiltins.append("highp ");
6532     commonBuiltins.append(prefixes[sampler.type]);
6533     commonBuiltins.append("vec4 imageLoad(readonly volatile coherent ");
6534     commonBuiltins.append(imageParams);
6535     commonBuiltins.append(");\n");
6536 
6537     commonBuiltins.append("void imageStore(writeonly volatile coherent ");
6538     commonBuiltins.append(imageParams);
6539     commonBuiltins.append(", ");
6540     commonBuiltins.append(prefixes[sampler.type]);
6541     commonBuiltins.append("vec4);\n");
6542 
6543     if (sampler.dim != Esd1D && sampler.dim != EsdBuffer && profile != EEsProfile && version >= 450) {
6544         commonBuiltins.append("int sparseImageLoadARB(readonly volatile coherent ");
6545         commonBuiltins.append(imageParams);
6546         commonBuiltins.append(", out ");
6547         commonBuiltins.append(prefixes[sampler.type]);
6548         commonBuiltins.append("vec4");
6549         commonBuiltins.append(");\n");
6550     }
6551 
6552     if ( profile != EEsProfile ||
6553         (profile == EEsProfile && version >= 310)) {
6554         if (sampler.type == EbtInt || sampler.type == EbtUint) {
6555             const char* dataType = sampler.type == EbtInt ? "highp int" : "highp uint";
6556 
6557             const int numBuiltins = 7;
6558 
6559             static const char* atomicFunc[numBuiltins] = {
6560                 " imageAtomicAdd(volatile coherent ",
6561                 " imageAtomicMin(volatile coherent ",
6562                 " imageAtomicMax(volatile coherent ",
6563                 " imageAtomicAnd(volatile coherent ",
6564                 " imageAtomicOr(volatile coherent ",
6565                 " imageAtomicXor(volatile coherent ",
6566                 " imageAtomicExchange(volatile coherent "
6567             };
6568 
6569             // Loop twice to add prototypes with/without scope/semantics
6570             for (int j = 0; j < 2; ++j) {
6571                 for (size_t i = 0; i < numBuiltins; ++i) {
6572                     commonBuiltins.append(dataType);
6573                     commonBuiltins.append(atomicFunc[i]);
6574                     commonBuiltins.append(imageParams);
6575                     commonBuiltins.append(", ");
6576                     commonBuiltins.append(dataType);
6577                     if (j == 1) {
6578                         commonBuiltins.append(", int, int, int");
6579                     }
6580                     commonBuiltins.append(");\n");
6581                 }
6582 
6583                 commonBuiltins.append(dataType);
6584                 commonBuiltins.append(" imageAtomicCompSwap(volatile coherent ");
6585                 commonBuiltins.append(imageParams);
6586                 commonBuiltins.append(", ");
6587                 commonBuiltins.append(dataType);
6588                 commonBuiltins.append(", ");
6589                 commonBuiltins.append(dataType);
6590                 if (j == 1) {
6591                     commonBuiltins.append(", int, int, int, int, int");
6592                 }
6593                 commonBuiltins.append(");\n");
6594             }
6595 
6596             commonBuiltins.append(dataType);
6597             commonBuiltins.append(" imageAtomicLoad(volatile coherent ");
6598             commonBuiltins.append(imageParams);
6599             commonBuiltins.append(", int, int, int);\n");
6600 
6601             commonBuiltins.append("void imageAtomicStore(volatile coherent ");
6602             commonBuiltins.append(imageParams);
6603             commonBuiltins.append(", ");
6604             commonBuiltins.append(dataType);
6605             commonBuiltins.append(", int, int, int);\n");
6606 
6607         } else {
6608             // not int or uint
6609             // GL_ARB_ES3_1_compatibility
6610             // TODO: spec issue: are there restrictions on the kind of layout() that can be used?  what about dropping memory qualifiers?
6611             if ((profile != EEsProfile && version >= 450) ||
6612                 (profile == EEsProfile && version >= 310)) {
6613                 commonBuiltins.append("float imageAtomicExchange(volatile coherent ");
6614                 commonBuiltins.append(imageParams);
6615                 commonBuiltins.append(", float);\n");
6616             }
6617         }
6618     }
6619 
6620 #ifdef AMD_EXTENSIONS
6621     if (sampler.dim == EsdRect || sampler.dim == EsdBuffer || sampler.shadow || sampler.ms)
6622         return;
6623 
6624     if (profile == EEsProfile || version < 450)
6625         return;
6626 
6627     TString imageLodParams = typeName;
6628     if (dims == 1)
6629         imageLodParams.append(", int");
6630     else {
6631         imageLodParams.append(", ivec");
6632         imageLodParams.append(postfixes[dims]);
6633     }
6634     imageLodParams.append(", int");
6635 
6636     commonBuiltins.append(prefixes[sampler.type]);
6637     commonBuiltins.append("vec4 imageLoadLodAMD(readonly volatile coherent ");
6638     commonBuiltins.append(imageLodParams);
6639     commonBuiltins.append(");\n");
6640 
6641     commonBuiltins.append("void imageStoreLodAMD(writeonly volatile coherent ");
6642     commonBuiltins.append(imageLodParams);
6643     commonBuiltins.append(", ");
6644     commonBuiltins.append(prefixes[sampler.type]);
6645     commonBuiltins.append("vec4);\n");
6646 
6647     if (sampler.dim != Esd1D) {
6648         commonBuiltins.append("int sparseImageLoadLodAMD(readonly volatile coherent ");
6649         commonBuiltins.append(imageLodParams);
6650         commonBuiltins.append(", out ");
6651         commonBuiltins.append(prefixes[sampler.type]);
6652         commonBuiltins.append("vec4");
6653         commonBuiltins.append(");\n");
6654     }
6655 #endif
6656 }
6657 
6658 //
6659 // Helper function for initialize(),
6660 // when adding context-independent built-in functions.
6661 //
6662 // Add all the subpass access functions for the given type.
6663 //
6664 void TBuiltIns::addSubpassSampling(TSampler sampler, const TString& typeName, int /*version*/, EProfile /*profile*/)
6665 {
6666     stageBuiltins[EShLangFragment].append(prefixes[sampler.type]);
6667     stageBuiltins[EShLangFragment].append("vec4 subpassLoad");
6668     stageBuiltins[EShLangFragment].append("(");
6669     stageBuiltins[EShLangFragment].append(typeName.c_str());
6670     if (sampler.ms)
6671         stageBuiltins[EShLangFragment].append(", int");
6672     stageBuiltins[EShLangFragment].append(");\n");
6673 }
6674 
6675 //
6676 // Helper function for add2ndGenerationSamplingImaging(),
6677 // when adding context-independent built-in functions.
6678 //
6679 // Add all the texture lookup functions for the given type.
6680 //
6681 void TBuiltIns::addSamplingFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile)
6682 {
6683     //
6684     // texturing
6685     //
6686     for (int proj = 0; proj <= 1; ++proj) { // loop over "bool" projective or not
6687 
6688         if (proj && (sampler.dim == EsdCube || sampler.dim == EsdBuffer || sampler.arrayed || sampler.ms || !sampler.combined))
6689             continue;
6690 
6691         for (int lod = 0; lod <= 1; ++lod) {
6692 
6693             if (lod && (sampler.dim == EsdBuffer || sampler.dim == EsdRect || sampler.ms || !sampler.combined))
6694                 continue;
6695             if (lod && sampler.dim == Esd2D && sampler.arrayed && sampler.shadow)
6696                 continue;
6697             if (lod && sampler.dim == EsdCube && sampler.shadow)
6698                 continue;
6699 
6700             for (int bias = 0; bias <= 1; ++bias) {
6701 
6702                 if (bias && (lod || sampler.ms || !sampler.combined))
6703                     continue;
6704                 if (bias && (sampler.dim == Esd2D || sampler.dim == EsdCube) && sampler.shadow && sampler.arrayed)
6705                     continue;
6706                 if (bias && (sampler.dim == EsdRect || sampler.dim == EsdBuffer))
6707                     continue;
6708 
6709                 for (int offset = 0; offset <= 1; ++offset) { // loop over "bool" offset or not
6710 
6711                     if (proj + offset + bias + lod > 3)
6712                         continue;
6713                     if (offset && (sampler.dim == EsdCube || sampler.dim == EsdBuffer || sampler.ms))
6714                         continue;
6715 
6716                     for (int fetch = 0; fetch <= 1; ++fetch) { // loop over "bool" fetch or not
6717 
6718                         if (proj + offset + fetch + bias + lod > 3)
6719                             continue;
6720                         if (fetch && (lod || bias))
6721                             continue;
6722                         if (fetch && (sampler.shadow || sampler.dim == EsdCube))
6723                             continue;
6724                         if (fetch == 0 && (sampler.ms || sampler.dim == EsdBuffer || !sampler.combined))
6725                             continue;
6726 
6727                         for (int grad = 0; grad <= 1; ++grad) { // loop over "bool" grad or not
6728 
6729                             if (grad && (lod || bias || sampler.ms || !sampler.combined))
6730                                 continue;
6731                             if (grad && sampler.dim == EsdBuffer)
6732                                 continue;
6733                             if (proj + offset + fetch + grad + bias + lod > 3)
6734                                 continue;
6735 
6736                             for (int extraProj = 0; extraProj <= 1; ++extraProj) {
6737                                 bool compare = false;
6738                                 int totalDims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0);
6739                                 // skip dummy unused second component for 1D non-array shadows
6740                                 if (sampler.shadow && totalDims < 2)
6741                                     totalDims = 2;
6742                                 totalDims += (sampler.shadow ? 1 : 0) + proj;
6743                                 if (totalDims > 4 && sampler.shadow) {
6744                                     compare = true;
6745                                     totalDims = 4;
6746                                 }
6747                                 assert(totalDims <= 4);
6748 
6749                                 if (extraProj && ! proj)
6750                                     continue;
6751                                 if (extraProj && (sampler.dim == Esd3D || sampler.shadow || !sampler.combined))
6752                                     continue;
6753 #ifdef AMD_EXTENSIONS
6754                                 for (int f16TexAddr = 0; f16TexAddr <= 1; ++f16TexAddr) { // loop over 16-bit floating-point texel addressing
6755 
6756                                     if (f16TexAddr && sampler.type != EbtFloat16)
6757                                         continue;
6758                                     if (f16TexAddr && sampler.shadow && ! compare) {
6759                                         compare = true; // compare argument is always present
6760                                         totalDims--;
6761                                     }
6762 #endif
6763                                     for (int lodClamp = 0; lodClamp <= 1 ;++lodClamp) { // loop over "bool" lod clamp
6764 
6765                                         if (lodClamp && (profile == EEsProfile || version < 450))
6766                                             continue;
6767                                         if (lodClamp && (proj || lod || fetch))
6768                                             continue;
6769 
6770                                         for (int sparse = 0; sparse <= 1; ++sparse) { // loop over "bool" sparse or not
6771 
6772                                             if (sparse && (profile == EEsProfile || version < 450))
6773                                                 continue;
6774                                             // Sparse sampling is not for 1D/1D array texture, buffer texture, and projective texture
6775                                             if (sparse && (sampler.dim == Esd1D || sampler.dim == EsdBuffer || proj))
6776                                                 continue;
6777 
6778                                             TString s;
6779 
6780                                             // return type
6781                                             if (sparse)
6782                                                 s.append("int ");
6783                                             else {
6784                                                 if (sampler.shadow)
6785 #ifdef AMD_EXTENSIONS
6786                                                     if (sampler.type == EbtFloat16)
6787                                                         s.append("float16_t ");
6788                                                     else
6789                                                         s.append("float ");
6790 #else
6791                                                     s.append("float ");
6792 #endif
6793                                                 else {
6794                                                     s.append(prefixes[sampler.type]);
6795                                                     s.append("vec4 ");
6796                                                 }
6797                                             }
6798 
6799                                             // name
6800                                             if (sparse) {
6801                                                 if (fetch)
6802                                                     s.append("sparseTexel");
6803                                                 else
6804                                                     s.append("sparseTexture");
6805                                             }
6806                                             else {
6807                                                 if (fetch)
6808                                                     s.append("texel");
6809                                                 else
6810                                                     s.append("texture");
6811                                             }
6812                                             if (proj)
6813                                                 s.append("Proj");
6814                                             if (lod)
6815                                                 s.append("Lod");
6816                                             if (grad)
6817                                                 s.append("Grad");
6818                                             if (fetch)
6819                                                 s.append("Fetch");
6820                                             if (offset)
6821                                                 s.append("Offset");
6822                                             if (lodClamp)
6823                                                 s.append("Clamp");
6824                                             if (lodClamp || sparse)
6825                                                 s.append("ARB");
6826                                             s.append("(");
6827 
6828                                             // sampler type
6829                                             s.append(typeName);
6830 #ifdef AMD_EXTENSIONS
6831                                             // P coordinate
6832                                             if (extraProj) {
6833                                                 if (f16TexAddr)
6834                                                     s.append(",f16vec4");
6835                                                 else
6836                                                     s.append(",vec4");
6837                                             } else {
6838                                                 s.append(",");
6839                                                 TBasicType t = fetch ? EbtInt : (f16TexAddr ? EbtFloat16 : EbtFloat);
6840                                                 if (totalDims == 1)
6841                                                     s.append(TType::getBasicString(t));
6842                                                 else {
6843                                                     s.append(prefixes[t]);
6844                                                     s.append("vec");
6845                                                     s.append(postfixes[totalDims]);
6846                                                 }
6847                                             }
6848 #else
6849                                             // P coordinate
6850                                             if (extraProj)
6851                                                 s.append(",vec4");
6852                                             else {
6853                                                 s.append(",");
6854                                                 TBasicType t = fetch ? EbtInt : EbtFloat;
6855                                                 if (totalDims == 1)
6856                                                     s.append(TType::getBasicString(t));
6857                                                 else {
6858                                                     s.append(prefixes[t]);
6859                                                     s.append("vec");
6860                                                     s.append(postfixes[totalDims]);
6861                                                 }
6862                                             }
6863 #endif
6864                                             // non-optional compare
6865                                             if (compare)
6866                                                 s.append(",float");
6867 
6868                                             // non-optional lod argument (lod that's not driven by lod loop) or sample
6869                                             if ((fetch && sampler.dim != EsdBuffer && sampler.dim != EsdRect && !sampler.ms) ||
6870                                                 (sampler.ms && fetch))
6871                                                 s.append(",int");
6872 #ifdef AMD_EXTENSIONS
6873                                             // non-optional lod
6874                                             if (lod) {
6875                                                 if (f16TexAddr)
6876                                                     s.append(",float16_t");
6877                                                 else
6878                                                     s.append(",float");
6879                                             }
6880 
6881                                             // gradient arguments
6882                                             if (grad) {
6883                                                 if (dimMap[sampler.dim] == 1) {
6884                                                     if (f16TexAddr)
6885                                                         s.append(",float16_t,float16_t");
6886                                                     else
6887                                                         s.append(",float,float");
6888                                                 } else {
6889                                                     if (f16TexAddr)
6890                                                         s.append(",f16vec");
6891                                                     else
6892                                                         s.append(",vec");
6893                                                     s.append(postfixes[dimMap[sampler.dim]]);
6894                                                     if (f16TexAddr)
6895                                                         s.append(",f16vec");
6896                                                     else
6897                                                         s.append(",vec");
6898                                                     s.append(postfixes[dimMap[sampler.dim]]);
6899                                                 }
6900                                             }
6901 #else
6902                                             // non-optional lod
6903                                             if (lod)
6904                                                 s.append(",float");
6905 
6906                                             // gradient arguments
6907                                             if (grad) {
6908                                                 if (dimMap[sampler.dim] == 1)
6909                                                     s.append(",float,float");
6910                                                 else {
6911                                                     s.append(",vec");
6912                                                     s.append(postfixes[dimMap[sampler.dim]]);
6913                                                     s.append(",vec");
6914                                                     s.append(postfixes[dimMap[sampler.dim]]);
6915                                                 }
6916                                             }
6917 #endif
6918                                             // offset
6919                                             if (offset) {
6920                                                 if (dimMap[sampler.dim] == 1)
6921                                                     s.append(",int");
6922                                                 else {
6923                                                     s.append(",ivec");
6924                                                     s.append(postfixes[dimMap[sampler.dim]]);
6925                                                 }
6926                                             }
6927 
6928 #ifdef AMD_EXTENSIONS
6929                                             // lod clamp
6930                                             if (lodClamp) {
6931                                                 if (f16TexAddr)
6932                                                     s.append(",float16_t");
6933                                                 else
6934                                                     s.append(",float");
6935                                             }
6936 #else
6937                                             // lod clamp
6938                                             if (lodClamp)
6939                                                 s.append(",float");
6940 #endif
6941                                             // texel out (for sparse texture)
6942                                             if (sparse) {
6943                                                 s.append(",out ");
6944                                                 if (sampler.shadow)
6945 #ifdef AMD_EXTENSIONS
6946                                                     if (sampler.type == EbtFloat16)
6947                                                         s.append("float16_t");
6948                                                     else
6949                                                         s.append("float");
6950 #else
6951                                                     s.append("float");
6952 #endif
6953                                                 else {
6954                                                     s.append(prefixes[sampler.type]);
6955                                                     s.append("vec4");
6956                                                 }
6957                                             }
6958 #ifdef AMD_EXTENSIONS
6959                                             // optional bias
6960                                             if (bias) {
6961                                                 if (f16TexAddr)
6962                                                     s.append(",float16_t");
6963                                                 else
6964                                                     s.append(",float");
6965                                             }
6966 #else
6967                                             // optional bias
6968                                             if (bias)
6969                                                 s.append(",float");
6970 #endif
6971                                             s.append(");\n");
6972 
6973                                             // Add to the per-language set of built-ins
6974                                             if (bias || lodClamp) {
6975                                                 stageBuiltins[EShLangFragment].append(s);
6976 #ifdef NV_EXTENSIONS
6977                                                 stageBuiltins[EShLangCompute].append(s);
6978 #endif
6979                                             } else
6980                                                 commonBuiltins.append(s);
6981 
6982                                         }
6983                                     }
6984 #ifdef AMD_EXTENSIONS
6985                                 }
6986 #endif
6987                             }
6988                         }
6989                     }
6990                 }
6991             }
6992         }
6993     }
6994 }
6995 
6996 //
6997 // Helper function for add2ndGenerationSamplingImaging(),
6998 // when adding context-independent built-in functions.
6999 //
7000 // Add all the texture gather functions for the given type.
7001 //
7002 void TBuiltIns::addGatherFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile)
7003 {
7004     switch (sampler.dim) {
7005     case Esd2D:
7006     case EsdRect:
7007     case EsdCube:
7008         break;
7009     default:
7010         return;
7011     }
7012 
7013     if (sampler.ms)
7014         return;
7015 
7016     if (version < 140 && sampler.dim == EsdRect && sampler.type != EbtFloat)
7017         return;
7018 
7019 #ifdef AMD_EXTENSIONS
7020     for (int f16TexAddr = 0; f16TexAddr <= 1; ++f16TexAddr) { // loop over 16-bit floating-point texel addressing
7021 
7022         if (f16TexAddr && sampler.type != EbtFloat16)
7023             continue;
7024 #endif
7025         for (int offset = 0; offset < 3; ++offset) { // loop over three forms of offset in the call name:  none, Offset, and Offsets
7026 
7027             for (int comp = 0; comp < 2; ++comp) { // loop over presence of comp argument
7028 
7029                 if (comp > 0 && sampler.shadow)
7030                     continue;
7031 
7032                 if (offset > 0 && sampler.dim == EsdCube)
7033                     continue;
7034 
7035                 for (int sparse = 0; sparse <= 1; ++sparse) { // loop over "bool" sparse or not
7036                     if (sparse && (profile == EEsProfile || version < 450))
7037                         continue;
7038 
7039                     TString s;
7040 
7041                     // return type
7042                     if (sparse)
7043                         s.append("int ");
7044                     else {
7045                         s.append(prefixes[sampler.type]);
7046                         s.append("vec4 ");
7047                     }
7048 
7049                     // name
7050                     if (sparse)
7051                         s.append("sparseTextureGather");
7052                     else
7053                         s.append("textureGather");
7054                     switch (offset) {
7055                     case 1:
7056                         s.append("Offset");
7057                         break;
7058                     case 2:
7059                         s.append("Offsets");
7060                         break;
7061                     default:
7062                         break;
7063                     }
7064                     if (sparse)
7065                         s.append("ARB");
7066                     s.append("(");
7067 
7068                     // sampler type argument
7069                     s.append(typeName);
7070 
7071                     // P coordinate argument
7072 #ifdef AMD_EXTENSIONS
7073                     if (f16TexAddr)
7074                         s.append(",f16vec");
7075                     else
7076                         s.append(",vec");
7077 #else
7078                     s.append(",vec");
7079 #endif
7080                     int totalDims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0);
7081                     s.append(postfixes[totalDims]);
7082 
7083                     // refZ argument
7084                     if (sampler.shadow)
7085                         s.append(",float");
7086 
7087                     // offset argument
7088                     if (offset > 0) {
7089                         s.append(",ivec2");
7090                         if (offset == 2)
7091                             s.append("[4]");
7092                     }
7093 
7094                     // texel out (for sparse texture)
7095                     if (sparse) {
7096                         s.append(",out ");
7097                         s.append(prefixes[sampler.type]);
7098                         s.append("vec4 ");
7099                     }
7100 
7101                     // comp argument
7102                     if (comp)
7103                         s.append(",int");
7104 
7105                     s.append(");\n");
7106                     commonBuiltins.append(s);
7107 #ifdef AMD_EXTENSIONS
7108                 }
7109 #endif
7110             }
7111         }
7112     }
7113 
7114 #ifdef AMD_EXTENSIONS
7115     if (sampler.dim == EsdRect || sampler.shadow)
7116         return;
7117 
7118     if (profile == EEsProfile || version < 450)
7119         return;
7120 
7121     for (int bias = 0; bias < 2; ++bias) { // loop over presence of bias argument
7122 
7123         for (int lod = 0; lod < 2; ++lod) { // loop over presence of lod argument
7124 
7125             if ((lod && bias) || (lod == 0 && bias == 0))
7126                 continue;
7127 
7128             for (int f16TexAddr = 0; f16TexAddr <= 1; ++f16TexAddr) { // loop over 16-bit floating-point texel addressing
7129 
7130                 if (f16TexAddr && sampler.type != EbtFloat16)
7131                     continue;
7132 
7133                 for (int offset = 0; offset < 3; ++offset) { // loop over three forms of offset in the call name:  none, Offset, and Offsets
7134 
7135                     for (int comp = 0; comp < 2; ++comp) { // loop over presence of comp argument
7136 
7137                         if (comp == 0 && bias)
7138                             continue;
7139 
7140                         if (offset > 0 && sampler.dim == EsdCube)
7141                             continue;
7142 
7143                         for (int sparse = 0; sparse <= 1; ++sparse) { // loop over "bool" sparse or not
7144                             if (sparse && (profile == EEsProfile || version < 450))
7145                                 continue;
7146 
7147                             TString s;
7148 
7149                             // return type
7150                             if (sparse)
7151                                 s.append("int ");
7152                             else {
7153                                 s.append(prefixes[sampler.type]);
7154                                 s.append("vec4 ");
7155                             }
7156 
7157                             // name
7158                             if (sparse)
7159                                 s.append("sparseTextureGather");
7160                             else
7161                                 s.append("textureGather");
7162 
7163                             if (lod)
7164                                 s.append("Lod");
7165 
7166                             switch (offset) {
7167                             case 1:
7168                                 s.append("Offset");
7169                                 break;
7170                             case 2:
7171                                 s.append("Offsets");
7172                                 break;
7173                             default:
7174                                 break;
7175                             }
7176 
7177                             if (lod)
7178                                 s.append("AMD");
7179                             else if (sparse)
7180                                 s.append("ARB");
7181 
7182                             s.append("(");
7183 
7184                             // sampler type argument
7185                             s.append(typeName);
7186 
7187                             // P coordinate argument
7188                             if (f16TexAddr)
7189                                 s.append(",f16vec");
7190                             else
7191                                 s.append(",vec");
7192                             int totalDims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0);
7193                             s.append(postfixes[totalDims]);
7194 
7195                             // lod argument
7196                             if (lod) {
7197                                 if (f16TexAddr)
7198                                     s.append(",float16_t");
7199                                 else
7200                                     s.append(",float");
7201                             }
7202 
7203                             // offset argument
7204                             if (offset > 0) {
7205                                 s.append(",ivec2");
7206                                 if (offset == 2)
7207                                     s.append("[4]");
7208                             }
7209 
7210                             // texel out (for sparse texture)
7211                             if (sparse) {
7212                                 s.append(",out ");
7213                                 s.append(prefixes[sampler.type]);
7214                                 s.append("vec4 ");
7215                             }
7216 
7217                             // comp argument
7218                             if (comp)
7219                                 s.append(",int");
7220 
7221                             // bias argument
7222                             if (bias) {
7223                                 if (f16TexAddr)
7224                                     s.append(",float16_t");
7225                                 else
7226                                     s.append(",float");
7227                             }
7228 
7229                             s.append(");\n");
7230                             if (bias)
7231                                 stageBuiltins[EShLangFragment].append(s);
7232                             else
7233                                 commonBuiltins.append(s);
7234                         }
7235                     }
7236                 }
7237             }
7238         }
7239     }
7240 #endif
7241 }
7242 
7243 //
7244 // Add context-dependent built-in functions and variables that are present
7245 // for the given version and profile.  All the results are put into just the
7246 // commonBuiltins, because it is called for just a specific stage.  So,
7247 // add stage-specific entries to the commonBuiltins, and only if that stage
7248 // was requested.
7249 //
7250 void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language)
7251 {
7252     //
7253     // Initialize the context-dependent (resource-dependent) built-in strings for parsing.
7254     //
7255 
7256     //============================================================================
7257     //
7258     // Standard Uniforms
7259     //
7260     //============================================================================
7261 
7262     TString& s = commonBuiltins;
7263     const int maxSize = 80;
7264     char builtInConstant[maxSize];
7265 
7266     //
7267     // Build string of implementation dependent constants.
7268     //
7269 
7270     if (profile == EEsProfile) {
7271         snprintf(builtInConstant, maxSize, "const mediump int  gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs);
7272         s.append(builtInConstant);
7273 
7274         snprintf(builtInConstant, maxSize, "const mediump int  gl_MaxVertexUniformVectors = %d;", resources.maxVertexUniformVectors);
7275         s.append(builtInConstant);
7276 
7277         snprintf(builtInConstant, maxSize, "const mediump int  gl_MaxVertexTextureImageUnits = %d;", resources.maxVertexTextureImageUnits);
7278         s.append(builtInConstant);
7279 
7280         snprintf(builtInConstant, maxSize, "const mediump int  gl_MaxCombinedTextureImageUnits = %d;", resources.maxCombinedTextureImageUnits);
7281         s.append(builtInConstant);
7282 
7283         snprintf(builtInConstant, maxSize, "const mediump int  gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits);
7284         s.append(builtInConstant);
7285 
7286         snprintf(builtInConstant, maxSize, "const mediump int  gl_MaxFragmentUniformVectors = %d;", resources.maxFragmentUniformVectors);
7287         s.append(builtInConstant);
7288 
7289         snprintf(builtInConstant, maxSize, "const mediump int  gl_MaxDrawBuffers = %d;", resources.maxDrawBuffers);
7290         s.append(builtInConstant);
7291 
7292         if (version == 100) {
7293             snprintf(builtInConstant, maxSize, "const mediump int  gl_MaxVaryingVectors = %d;", resources.maxVaryingVectors);
7294             s.append(builtInConstant);
7295         } else {
7296             snprintf(builtInConstant, maxSize, "const mediump int  gl_MaxVertexOutputVectors = %d;", resources.maxVertexOutputVectors);
7297             s.append(builtInConstant);
7298 
7299             snprintf(builtInConstant, maxSize, "const mediump int  gl_MaxFragmentInputVectors = %d;", resources.maxFragmentInputVectors);
7300             s.append(builtInConstant);
7301 
7302             snprintf(builtInConstant, maxSize, "const mediump int  gl_MinProgramTexelOffset = %d;", resources.minProgramTexelOffset);
7303             s.append(builtInConstant);
7304 
7305             snprintf(builtInConstant, maxSize, "const mediump int  gl_MaxProgramTexelOffset = %d;", resources.maxProgramTexelOffset);
7306             s.append(builtInConstant);
7307         }
7308 
7309         if (version >= 310) {
7310             // geometry
7311 
7312             snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryInputComponents = %d;", resources.maxGeometryInputComponents);
7313             s.append(builtInConstant);
7314             snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryOutputComponents = %d;", resources.maxGeometryOutputComponents);
7315             s.append(builtInConstant);
7316             snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryImageUniforms = %d;", resources.maxGeometryImageUniforms);
7317             s.append(builtInConstant);
7318             snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryTextureImageUnits = %d;", resources.maxGeometryTextureImageUnits);
7319             s.append(builtInConstant);
7320             snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryOutputVertices = %d;", resources.maxGeometryOutputVertices);
7321             s.append(builtInConstant);
7322             snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryTotalOutputComponents = %d;", resources.maxGeometryTotalOutputComponents);
7323             s.append(builtInConstant);
7324             snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryUniformComponents = %d;", resources.maxGeometryUniformComponents);
7325             s.append(builtInConstant);
7326             snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounters = %d;", resources.maxGeometryAtomicCounters);
7327             s.append(builtInConstant);
7328             snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounterBuffers = %d;", resources.maxGeometryAtomicCounterBuffers);
7329             s.append(builtInConstant);
7330 
7331             // tessellation
7332 
7333             snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlInputComponents = %d;", resources.maxTessControlInputComponents);
7334             s.append(builtInConstant);
7335             snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlOutputComponents = %d;", resources.maxTessControlOutputComponents);
7336             s.append(builtInConstant);
7337             snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlTextureImageUnits = %d;", resources.maxTessControlTextureImageUnits);
7338             s.append(builtInConstant);
7339             snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlUniformComponents = %d;", resources.maxTessControlUniformComponents);
7340             s.append(builtInConstant);
7341             snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlTotalOutputComponents = %d;", resources.maxTessControlTotalOutputComponents);
7342             s.append(builtInConstant);
7343 
7344             snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationInputComponents = %d;", resources.maxTessEvaluationInputComponents);
7345             s.append(builtInConstant);
7346             snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationOutputComponents = %d;", resources.maxTessEvaluationOutputComponents);
7347             s.append(builtInConstant);
7348             snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationTextureImageUnits = %d;", resources.maxTessEvaluationTextureImageUnits);
7349             s.append(builtInConstant);
7350             snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationUniformComponents = %d;", resources.maxTessEvaluationUniformComponents);
7351             s.append(builtInConstant);
7352 
7353             snprintf(builtInConstant, maxSize, "const int gl_MaxTessPatchComponents = %d;", resources.maxTessPatchComponents);
7354             s.append(builtInConstant);
7355 
7356             snprintf(builtInConstant, maxSize, "const int gl_MaxPatchVertices = %d;", resources.maxPatchVertices);
7357             s.append(builtInConstant);
7358             snprintf(builtInConstant, maxSize, "const int gl_MaxTessGenLevel = %d;", resources.maxTessGenLevel);
7359             s.append(builtInConstant);
7360 
7361             // this is here instead of with the others in initialize(version, profile) due to the dependence on gl_MaxPatchVertices
7362             if (language == EShLangTessControl || language == EShLangTessEvaluation) {
7363                 s.append(
7364                     "in gl_PerVertex {"
7365                         "highp vec4 gl_Position;"
7366                         "highp float gl_PointSize;"
7367 #ifdef NV_EXTENSIONS
7368                         "highp vec4 gl_SecondaryPositionNV;"  // GL_NV_stereo_view_rendering
7369                         "highp vec4 gl_PositionPerViewNV[];"  // GL_NVX_multiview_per_view_attributes
7370 #endif
7371                     "} gl_in[gl_MaxPatchVertices];"
7372                     "\n");
7373             }
7374         }
7375 
7376     } else {
7377         // non-ES profile
7378 
7379         snprintf(builtInConstant, maxSize, "const int  gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs);
7380         s.append(builtInConstant);
7381 
7382         snprintf(builtInConstant, maxSize, "const int  gl_MaxVertexTextureImageUnits = %d;", resources.maxVertexTextureImageUnits);
7383         s.append(builtInConstant);
7384 
7385         snprintf(builtInConstant, maxSize, "const int  gl_MaxCombinedTextureImageUnits = %d;", resources.maxCombinedTextureImageUnits);
7386         s.append(builtInConstant);
7387 
7388         snprintf(builtInConstant, maxSize, "const int  gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits);
7389         s.append(builtInConstant);
7390 
7391         snprintf(builtInConstant, maxSize, "const int  gl_MaxDrawBuffers = %d;", resources.maxDrawBuffers);
7392         s.append(builtInConstant);
7393 
7394         snprintf(builtInConstant, maxSize, "const int  gl_MaxLights = %d;", resources.maxLights);
7395         s.append(builtInConstant);
7396 
7397         snprintf(builtInConstant, maxSize, "const int  gl_MaxClipPlanes = %d;", resources.maxClipPlanes);
7398         s.append(builtInConstant);
7399 
7400         snprintf(builtInConstant, maxSize, "const int  gl_MaxTextureUnits = %d;", resources.maxTextureUnits);
7401         s.append(builtInConstant);
7402 
7403         snprintf(builtInConstant, maxSize, "const int  gl_MaxTextureCoords = %d;", resources.maxTextureCoords);
7404         s.append(builtInConstant);
7405 
7406         snprintf(builtInConstant, maxSize, "const int  gl_MaxVertexUniformComponents = %d;", resources.maxVertexUniformComponents);
7407         s.append(builtInConstant);
7408 
7409         if (version < 150 || ARBCompatibility) {
7410             snprintf(builtInConstant, maxSize, "const int  gl_MaxVaryingFloats = %d;", resources.maxVaryingFloats);
7411             s.append(builtInConstant);
7412         }
7413 
7414         snprintf(builtInConstant, maxSize, "const int  gl_MaxFragmentUniformComponents = %d;", resources.maxFragmentUniformComponents);
7415         s.append(builtInConstant);
7416 
7417         if (spvVersion.spv == 0 && IncludeLegacy(version, profile, spvVersion)) {
7418             //
7419             // OpenGL'uniform' state.  Page numbers are in reference to version
7420             // 1.4 of the OpenGL specification.
7421             //
7422 
7423             //
7424             // Matrix state. p. 31, 32, 37, 39, 40.
7425             //
7426             s.append("uniform mat4  gl_TextureMatrix[gl_MaxTextureCoords];"
7427 
7428             //
7429             // Derived matrix state that provides inverse and transposed versions
7430             // of the matrices above.
7431             //
7432                         "uniform mat4  gl_TextureMatrixInverse[gl_MaxTextureCoords];"
7433 
7434                         "uniform mat4  gl_TextureMatrixTranspose[gl_MaxTextureCoords];"
7435 
7436                         "uniform mat4  gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords];"
7437 
7438             //
7439             // Clip planes p. 42.
7440             //
7441                         "uniform vec4  gl_ClipPlane[gl_MaxClipPlanes];"
7442 
7443             //
7444             // Light State p 50, 53, 55.
7445             //
7446                         "uniform gl_LightSourceParameters  gl_LightSource[gl_MaxLights];"
7447 
7448             //
7449             // Derived state from products of light.
7450             //
7451                         "uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];"
7452                         "uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];"
7453 
7454             //
7455             // Texture Environment and Generation, p. 152, p. 40-42.
7456             //
7457                         "uniform vec4  gl_TextureEnvColor[gl_MaxTextureImageUnits];"
7458                         "uniform vec4  gl_EyePlaneS[gl_MaxTextureCoords];"
7459                         "uniform vec4  gl_EyePlaneT[gl_MaxTextureCoords];"
7460                         "uniform vec4  gl_EyePlaneR[gl_MaxTextureCoords];"
7461                         "uniform vec4  gl_EyePlaneQ[gl_MaxTextureCoords];"
7462                         "uniform vec4  gl_ObjectPlaneS[gl_MaxTextureCoords];"
7463                         "uniform vec4  gl_ObjectPlaneT[gl_MaxTextureCoords];"
7464                         "uniform vec4  gl_ObjectPlaneR[gl_MaxTextureCoords];"
7465                         "uniform vec4  gl_ObjectPlaneQ[gl_MaxTextureCoords];");
7466         }
7467 
7468         if (version >= 130) {
7469             snprintf(builtInConstant, maxSize, "const int gl_MaxClipDistances = %d;", resources.maxClipDistances);
7470             s.append(builtInConstant);
7471             snprintf(builtInConstant, maxSize, "const int gl_MaxVaryingComponents = %d;", resources.maxVaryingComponents);
7472             s.append(builtInConstant);
7473 
7474             // GL_ARB_shading_language_420pack
7475             snprintf(builtInConstant, maxSize, "const mediump int  gl_MinProgramTexelOffset = %d;", resources.minProgramTexelOffset);
7476             s.append(builtInConstant);
7477             snprintf(builtInConstant, maxSize, "const mediump int  gl_MaxProgramTexelOffset = %d;", resources.maxProgramTexelOffset);
7478             s.append(builtInConstant);
7479         }
7480 
7481         // geometry
7482         if (version >= 150) {
7483             snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryInputComponents = %d;", resources.maxGeometryInputComponents);
7484             s.append(builtInConstant);
7485             snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryOutputComponents = %d;", resources.maxGeometryOutputComponents);
7486             s.append(builtInConstant);
7487             snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryTextureImageUnits = %d;", resources.maxGeometryTextureImageUnits);
7488             s.append(builtInConstant);
7489             snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryOutputVertices = %d;", resources.maxGeometryOutputVertices);
7490             s.append(builtInConstant);
7491             snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryTotalOutputComponents = %d;", resources.maxGeometryTotalOutputComponents);
7492             s.append(builtInConstant);
7493             snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryUniformComponents = %d;", resources.maxGeometryUniformComponents);
7494             s.append(builtInConstant);
7495             snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryVaryingComponents = %d;", resources.maxGeometryVaryingComponents);
7496             s.append(builtInConstant);
7497 
7498         }
7499 
7500         if (version >= 150) {
7501             snprintf(builtInConstant, maxSize, "const int gl_MaxVertexOutputComponents = %d;", resources.maxVertexOutputComponents);
7502             s.append(builtInConstant);
7503             snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentInputComponents = %d;", resources.maxFragmentInputComponents);
7504             s.append(builtInConstant);
7505         }
7506 
7507         // tessellation
7508         if (version >= 150) {
7509             snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlInputComponents = %d;", resources.maxTessControlInputComponents);
7510             s.append(builtInConstant);
7511             snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlOutputComponents = %d;", resources.maxTessControlOutputComponents);
7512             s.append(builtInConstant);
7513             snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlTextureImageUnits = %d;", resources.maxTessControlTextureImageUnits);
7514             s.append(builtInConstant);
7515             snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlUniformComponents = %d;", resources.maxTessControlUniformComponents);
7516             s.append(builtInConstant);
7517             snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlTotalOutputComponents = %d;", resources.maxTessControlTotalOutputComponents);
7518             s.append(builtInConstant);
7519 
7520             snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationInputComponents = %d;", resources.maxTessEvaluationInputComponents);
7521             s.append(builtInConstant);
7522             snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationOutputComponents = %d;", resources.maxTessEvaluationOutputComponents);
7523             s.append(builtInConstant);
7524             snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationTextureImageUnits = %d;", resources.maxTessEvaluationTextureImageUnits);
7525             s.append(builtInConstant);
7526             snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationUniformComponents = %d;", resources.maxTessEvaluationUniformComponents);
7527             s.append(builtInConstant);
7528 
7529             snprintf(builtInConstant, maxSize, "const int gl_MaxTessPatchComponents = %d;", resources.maxTessPatchComponents);
7530             s.append(builtInConstant);
7531             snprintf(builtInConstant, maxSize, "const int gl_MaxTessGenLevel = %d;", resources.maxTessGenLevel);
7532             s.append(builtInConstant);
7533             snprintf(builtInConstant, maxSize, "const int gl_MaxPatchVertices = %d;", resources.maxPatchVertices);
7534             s.append(builtInConstant);
7535 
7536             // this is here instead of with the others in initialize(version, profile) due to the dependence on gl_MaxPatchVertices
7537             if (language == EShLangTessControl || language == EShLangTessEvaluation) {
7538                 s.append(
7539                     "in gl_PerVertex {"
7540                         "vec4 gl_Position;"
7541                         "float gl_PointSize;"
7542                         "float gl_ClipDistance[];"
7543                     );
7544                 if (profile == ECompatibilityProfile)
7545                     s.append(
7546                         "vec4 gl_ClipVertex;"
7547                         "vec4 gl_FrontColor;"
7548                         "vec4 gl_BackColor;"
7549                         "vec4 gl_FrontSecondaryColor;"
7550                         "vec4 gl_BackSecondaryColor;"
7551                         "vec4 gl_TexCoord[];"
7552                         "float gl_FogFragCoord;"
7553                         );
7554                 if (profile != EEsProfile && version >= 450)
7555                     s.append(
7556                         "float gl_CullDistance[];"
7557 #ifdef NV_EXTENSIONS
7558                         "vec4 gl_SecondaryPositionNV;"  // GL_NV_stereo_view_rendering
7559                         "vec4 gl_PositionPerViewNV[];"  // GL_NVX_multiview_per_view_attributes
7560 #endif
7561                        );
7562                 s.append(
7563                     "} gl_in[gl_MaxPatchVertices];"
7564                     "\n");
7565             }
7566         }
7567 
7568         if (version >= 150) {
7569             snprintf(builtInConstant, maxSize, "const int gl_MaxViewports = %d;", resources.maxViewports);
7570             s.append(builtInConstant);
7571         }
7572 
7573         // images
7574         if (version >= 130) {
7575             snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedImageUnitsAndFragmentOutputs = %d;", resources.maxCombinedImageUnitsAndFragmentOutputs);
7576             s.append(builtInConstant);
7577             snprintf(builtInConstant, maxSize, "const int gl_MaxImageSamples = %d;", resources.maxImageSamples);
7578             s.append(builtInConstant);
7579             snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlImageUniforms = %d;", resources.maxTessControlImageUniforms);
7580             s.append(builtInConstant);
7581             snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationImageUniforms = %d;", resources.maxTessEvaluationImageUniforms);
7582             s.append(builtInConstant);
7583             snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryImageUniforms = %d;", resources.maxGeometryImageUniforms);
7584             s.append(builtInConstant);
7585         }
7586 
7587         // enhanced layouts
7588         if (version >= 430) {
7589             snprintf(builtInConstant, maxSize, "const int gl_MaxTransformFeedbackBuffers = %d;", resources.maxTransformFeedbackBuffers);
7590             s.append(builtInConstant);
7591             snprintf(builtInConstant, maxSize, "const int gl_MaxTransformFeedbackInterleavedComponents = %d;", resources.maxTransformFeedbackInterleavedComponents);
7592             s.append(builtInConstant);
7593         }
7594     }
7595 
7596     // images (some in compute below)
7597     if ((profile == EEsProfile && version >= 310) ||
7598         (profile != EEsProfile && version >= 130)) {
7599         snprintf(builtInConstant, maxSize, "const int gl_MaxImageUnits = %d;", resources.maxImageUnits);
7600         s.append(builtInConstant);
7601         snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedShaderOutputResources = %d;", resources.maxCombinedShaderOutputResources);
7602         s.append(builtInConstant);
7603         snprintf(builtInConstant, maxSize, "const int gl_MaxVertexImageUniforms = %d;", resources.maxVertexImageUniforms);
7604         s.append(builtInConstant);
7605         snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentImageUniforms = %d;", resources.maxFragmentImageUniforms);
7606         s.append(builtInConstant);
7607         snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedImageUniforms = %d;", resources.maxCombinedImageUniforms);
7608         s.append(builtInConstant);
7609     }
7610 
7611     // atomic counters (some in compute below)
7612     if ((profile == EEsProfile && version >= 310) ||
7613         (profile != EEsProfile && version >= 420)) {
7614         snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAtomicCounters = %d;", resources.               maxVertexAtomicCounters);
7615         s.append(builtInConstant);
7616         snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentAtomicCounters = %d;", resources.             maxFragmentAtomicCounters);
7617         s.append(builtInConstant);
7618         snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedAtomicCounters = %d;", resources.             maxCombinedAtomicCounters);
7619         s.append(builtInConstant);
7620         snprintf(builtInConstant, maxSize, "const int gl_MaxAtomicCounterBindings = %d;", resources.              maxAtomicCounterBindings);
7621         s.append(builtInConstant);
7622         snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAtomicCounterBuffers = %d;", resources.         maxVertexAtomicCounterBuffers);
7623         s.append(builtInConstant);
7624         snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentAtomicCounterBuffers = %d;", resources.       maxFragmentAtomicCounterBuffers);
7625         s.append(builtInConstant);
7626         snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedAtomicCounterBuffers = %d;", resources.       maxCombinedAtomicCounterBuffers);
7627         s.append(builtInConstant);
7628         snprintf(builtInConstant, maxSize, "const int gl_MaxAtomicCounterBufferSize = %d;", resources.            maxAtomicCounterBufferSize);
7629         s.append(builtInConstant);
7630     }
7631     if (profile != EEsProfile && version >= 420) {
7632         snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounters = %d;", resources.          maxTessControlAtomicCounters);
7633         s.append(builtInConstant);
7634         snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounters = %d;", resources.       maxTessEvaluationAtomicCounters);
7635         s.append(builtInConstant);
7636         snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounters = %d;", resources.             maxGeometryAtomicCounters);
7637         s.append(builtInConstant);
7638         snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounterBuffers = %d;", resources.    maxTessControlAtomicCounterBuffers);
7639         s.append(builtInConstant);
7640         snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounterBuffers = %d;", resources. maxTessEvaluationAtomicCounterBuffers);
7641         s.append(builtInConstant);
7642         snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounterBuffers = %d;", resources.       maxGeometryAtomicCounterBuffers);
7643         s.append(builtInConstant);
7644 
7645         s.append("\n");
7646     }
7647 
7648     // compute
7649     if ((profile == EEsProfile && version >= 310) || (profile != EEsProfile && version >= 420)) {
7650         snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxComputeWorkGroupCount = ivec3(%d,%d,%d);", resources.maxComputeWorkGroupCountX,
7651                                                                                                          resources.maxComputeWorkGroupCountY,
7652                                                                                                          resources.maxComputeWorkGroupCountZ);
7653         s.append(builtInConstant);
7654         snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxComputeWorkGroupSize = ivec3(%d,%d,%d);", resources.maxComputeWorkGroupSizeX,
7655                                                                                                         resources.maxComputeWorkGroupSizeY,
7656                                                                                                         resources.maxComputeWorkGroupSizeZ);
7657         s.append(builtInConstant);
7658 
7659         snprintf(builtInConstant, maxSize, "const int gl_MaxComputeUniformComponents = %d;", resources.maxComputeUniformComponents);
7660         s.append(builtInConstant);
7661         snprintf(builtInConstant, maxSize, "const int gl_MaxComputeTextureImageUnits = %d;", resources.maxComputeTextureImageUnits);
7662         s.append(builtInConstant);
7663         snprintf(builtInConstant, maxSize, "const int gl_MaxComputeImageUniforms = %d;", resources.maxComputeImageUniforms);
7664         s.append(builtInConstant);
7665         snprintf(builtInConstant, maxSize, "const int gl_MaxComputeAtomicCounters = %d;", resources.maxComputeAtomicCounters);
7666         s.append(builtInConstant);
7667         snprintf(builtInConstant, maxSize, "const int gl_MaxComputeAtomicCounterBuffers = %d;", resources.maxComputeAtomicCounterBuffers);
7668         s.append(builtInConstant);
7669 
7670         s.append("\n");
7671     }
7672 
7673     // GL_ARB_cull_distance
7674     if (profile != EEsProfile && version >= 450) {
7675         snprintf(builtInConstant, maxSize, "const int gl_MaxCullDistances = %d;",                resources.maxCullDistances);
7676         s.append(builtInConstant);
7677         snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedClipAndCullDistances = %d;", resources.maxCombinedClipAndCullDistances);
7678         s.append(builtInConstant);
7679     }
7680 
7681     // GL_ARB_ES3_1_compatibility
7682     if ((profile != EEsProfile && version >= 450) ||
7683         (profile == EEsProfile && version >= 310)) {
7684         snprintf(builtInConstant, maxSize, "const int gl_MaxSamples = %d;", resources.maxSamples);
7685         s.append(builtInConstant);
7686     }
7687 
7688 #ifdef AMD_EXTENSIONS
7689     // GL_AMD_gcn_shader
7690     if (profile != EEsProfile && version >= 450) {
7691         snprintf(builtInConstant, maxSize, "const int gl_SIMDGroupSizeAMD = 64;");
7692         s.append(builtInConstant);
7693     }
7694 #endif
7695 
7696 #ifdef NV_EXTENSIONS
7697     // SPV_NV_mesh_shader
7698     if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
7699         snprintf(builtInConstant, maxSize, "const int gl_MaxMeshOutputVerticesNV = %d;", resources.maxMeshOutputVerticesNV);
7700         s.append(builtInConstant);
7701 
7702         snprintf(builtInConstant, maxSize, "const int gl_MaxMeshOutputPrimitivesNV = %d;", resources.maxMeshOutputPrimitivesNV);
7703         s.append(builtInConstant);
7704 
7705         snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxMeshWorkGroupSizeNV = ivec3(%d,%d,%d);", resources.maxMeshWorkGroupSizeX_NV,
7706                                                                                                        resources.maxMeshWorkGroupSizeY_NV,
7707                                                                                                        resources.maxMeshWorkGroupSizeZ_NV);
7708         s.append(builtInConstant);
7709         snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxTaskWorkGroupSizeNV = ivec3(%d,%d,%d);", resources.maxTaskWorkGroupSizeX_NV,
7710                                                                                                        resources.maxTaskWorkGroupSizeY_NV,
7711                                                                                                        resources.maxTaskWorkGroupSizeZ_NV);
7712         s.append(builtInConstant);
7713 
7714         snprintf(builtInConstant, maxSize, "const int gl_MaxMeshViewCountNV = %d;", resources.maxMeshViewCountNV);
7715         s.append(builtInConstant);
7716 
7717         s.append("\n");
7718     }
7719 #endif
7720 
7721     s.append("\n");
7722 }
7723 
7724 //
7725 // To support special built-ins that have a special qualifier that cannot be declared textually
7726 // in a shader, like gl_Position.
7727 //
7728 // This lets the type of the built-in be declared textually, and then have just its qualifier be
7729 // updated afterward.
7730 //
7731 // Safe to call even if name is not present.
7732 //
7733 // Only use this for built-in variables that have a special qualifier in TStorageQualifier.
7734 // New built-in variables should use a generic (textually declarable) qualifier in
7735 // TStoraregQualifier and only call BuiltInVariable().
7736 //
7737 static void SpecialQualifier(const char* name, TStorageQualifier qualifier, TBuiltInVariable builtIn, TSymbolTable& symbolTable)
7738 {
7739     TSymbol* symbol = symbolTable.find(name);
7740     if (symbol) {
7741         TQualifier& symQualifier = symbol->getWritableType().getQualifier();
7742         symQualifier.storage = qualifier;
7743         symQualifier.builtIn = builtIn;
7744     }
7745 }
7746 
7747 //
7748 // To tag built-in variables with their TBuiltInVariable enum.  Use this when the
7749 // normal declaration text already gets the qualifier right, and all that's needed
7750 // is setting the builtIn field.  This should be the normal way for all new
7751 // built-in variables.
7752 //
7753 // If SpecialQualifier() was called, this does not need to be called.
7754 //
7755 // Safe to call even if name is not present.
7756 //
7757 static void BuiltInVariable(const char* name, TBuiltInVariable builtIn, TSymbolTable& symbolTable)
7758 {
7759     TSymbol* symbol = symbolTable.find(name);
7760     if (! symbol)
7761         return;
7762 
7763     TQualifier& symQualifier = symbol->getWritableType().getQualifier();
7764     symQualifier.builtIn = builtIn;
7765 }
7766 
7767 //
7768 // For built-in variables inside a named block.
7769 // SpecialQualifier() won't ever go inside a block; their member's qualifier come
7770 // from the qualification of the block.
7771 //
7772 // See comments above for other detail.
7773 //
7774 static void BuiltInVariable(const char* blockName, const char* name, TBuiltInVariable builtIn, TSymbolTable& symbolTable)
7775 {
7776     TSymbol* symbol = symbolTable.find(blockName);
7777     if (! symbol)
7778         return;
7779 
7780     TTypeList& structure = *symbol->getWritableType().getWritableStruct();
7781     for (int i = 0; i < (int)structure.size(); ++i) {
7782         if (structure[i].type->getFieldName().compare(name) == 0) {
7783             structure[i].type->getQualifier().builtIn = builtIn;
7784             return;
7785         }
7786     }
7787 }
7788 
7789 //
7790 // Finish adding/processing context-independent built-in symbols.
7791 // 1) Programmatically add symbols that could not be added by simple text strings above.
7792 // 2) Map built-in functions to operators, for those that will turn into an operation node
7793 //    instead of remaining a function call.
7794 // 3) Tag extension-related symbols added to their base version with their extensions, so
7795 //    that if an early version has the extension turned off, there is an error reported on use.
7796 //
7797 void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable)
7798 {
7799     //
7800     // Tag built-in variables and functions with additional qualifier and extension information
7801     // that cannot be declared with the text strings.
7802     //
7803 
7804     // N.B.: a symbol should only be tagged once, and this function is called multiple times, once
7805     // per stage that's used for this profile.  So
7806     //  - generally, stick common ones in the fragment stage to ensure they are tagged exactly once
7807     //  - for ES, which has different precisions for different stages, the coarsest-grained tagging
7808     //    for a built-in used in many stages needs to be once for the fragment stage and once for
7809     //    the vertex stage
7810 
7811     switch(language) {
7812     case EShLangVertex:
7813         if (profile != EEsProfile) {
7814             if (version >= 440) {
7815                 symbolTable.setVariableExtensions("gl_BaseVertexARB",   1, &E_GL_ARB_shader_draw_parameters);
7816                 symbolTable.setVariableExtensions("gl_BaseInstanceARB", 1, &E_GL_ARB_shader_draw_parameters);
7817                 symbolTable.setVariableExtensions("gl_DrawIDARB",       1, &E_GL_ARB_shader_draw_parameters);
7818                 BuiltInVariable("gl_BaseVertexARB",   EbvBaseVertex,   symbolTable);
7819                 BuiltInVariable("gl_BaseInstanceARB", EbvBaseInstance, symbolTable);
7820                 BuiltInVariable("gl_DrawIDARB",       EbvDrawId,       symbolTable);
7821             }
7822             if (version >= 460) {
7823                 BuiltInVariable("gl_BaseVertex",   EbvBaseVertex,   symbolTable);
7824                 BuiltInVariable("gl_BaseInstance", EbvBaseInstance, symbolTable);
7825                 BuiltInVariable("gl_DrawID",       EbvDrawId,       symbolTable);
7826             }
7827             symbolTable.setVariableExtensions("gl_SubGroupSizeARB",       1, &E_GL_ARB_shader_ballot);
7828             symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
7829             symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB",     1, &E_GL_ARB_shader_ballot);
7830             symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB",     1, &E_GL_ARB_shader_ballot);
7831             symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB",     1, &E_GL_ARB_shader_ballot);
7832             symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB",     1, &E_GL_ARB_shader_ballot);
7833             symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB",     1, &E_GL_ARB_shader_ballot);
7834 
7835             symbolTable.setFunctionExtensions("ballotARB",              1, &E_GL_ARB_shader_ballot);
7836             symbolTable.setFunctionExtensions("readInvocationARB",      1, &E_GL_ARB_shader_ballot);
7837             symbolTable.setFunctionExtensions("readFirstInvocationARB", 1, &E_GL_ARB_shader_ballot);
7838 
7839             BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
7840             BuiltInVariable("gl_SubGroupEqMaskARB",     EbvSubGroupEqMask,     symbolTable);
7841             BuiltInVariable("gl_SubGroupGeMaskARB",     EbvSubGroupGeMask,     symbolTable);
7842             BuiltInVariable("gl_SubGroupGtMaskARB",     EbvSubGroupGtMask,     symbolTable);
7843             BuiltInVariable("gl_SubGroupLeMaskARB",     EbvSubGroupLeMask,     symbolTable);
7844             BuiltInVariable("gl_SubGroupLtMaskARB",     EbvSubGroupLtMask,     symbolTable);
7845 
7846             if (spvVersion.vulkan > 0)
7847                 // Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
7848                 SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
7849             else
7850                 BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
7851 
7852             if (version >= 430) {
7853                 symbolTable.setFunctionExtensions("anyInvocationARB",       1, &E_GL_ARB_shader_group_vote);
7854                 symbolTable.setFunctionExtensions("allInvocationsARB",      1, &E_GL_ARB_shader_group_vote);
7855                 symbolTable.setFunctionExtensions("allInvocationsEqualARB", 1, &E_GL_ARB_shader_group_vote);
7856             }
7857         }
7858 
7859 #ifdef AMD_EXTENSIONS
7860         if (profile != EEsProfile) {
7861             symbolTable.setFunctionExtensions("minInvocationsAMD",                1, &E_GL_AMD_shader_ballot);
7862             symbolTable.setFunctionExtensions("maxInvocationsAMD",                1, &E_GL_AMD_shader_ballot);
7863             symbolTable.setFunctionExtensions("addInvocationsAMD",                1, &E_GL_AMD_shader_ballot);
7864             symbolTable.setFunctionExtensions("minInvocationsNonUniformAMD",      1, &E_GL_AMD_shader_ballot);
7865             symbolTable.setFunctionExtensions("maxInvocationsNonUniformAMD",      1, &E_GL_AMD_shader_ballot);
7866             symbolTable.setFunctionExtensions("addInvocationsNonUniformAMD",      1, &E_GL_AMD_shader_ballot);
7867             symbolTable.setFunctionExtensions("swizzleInvocationsAMD",            1, &E_GL_AMD_shader_ballot);
7868             symbolTable.setFunctionExtensions("swizzleInvocationsWithPatternAMD", 1, &E_GL_AMD_shader_ballot);
7869             symbolTable.setFunctionExtensions("writeInvocationAMD",               1, &E_GL_AMD_shader_ballot);
7870             symbolTable.setFunctionExtensions("mbcntAMD",                         1, &E_GL_AMD_shader_ballot);
7871 
7872             symbolTable.setFunctionExtensions("minInvocationsInclusiveScanAMD",             1, &E_GL_AMD_shader_ballot);
7873             symbolTable.setFunctionExtensions("maxInvocationsInclusiveScanAMD",             1, &E_GL_AMD_shader_ballot);
7874             symbolTable.setFunctionExtensions("addInvocationsInclusiveScanAMD",             1, &E_GL_AMD_shader_ballot);
7875             symbolTable.setFunctionExtensions("minInvocationsInclusiveScanNonUniformAMD",   1, &E_GL_AMD_shader_ballot);
7876             symbolTable.setFunctionExtensions("maxInvocationsInclusiveScanNonUniformAMD",   1, &E_GL_AMD_shader_ballot);
7877             symbolTable.setFunctionExtensions("addInvocationsInclusiveScanNonUniformAMD",   1, &E_GL_AMD_shader_ballot);
7878             symbolTable.setFunctionExtensions("minInvocationsExclusiveScanAMD",             1, &E_GL_AMD_shader_ballot);
7879             symbolTable.setFunctionExtensions("maxInvocationsExclusiveScanAMD",             1, &E_GL_AMD_shader_ballot);
7880             symbolTable.setFunctionExtensions("addInvocationsExclusiveScanAMD",             1, &E_GL_AMD_shader_ballot);
7881             symbolTable.setFunctionExtensions("minInvocationsExclusiveScanNonUniformAMD",   1, &E_GL_AMD_shader_ballot);
7882             symbolTable.setFunctionExtensions("maxInvocationsExclusiveScanNonUniformAMD",   1, &E_GL_AMD_shader_ballot);
7883             symbolTable.setFunctionExtensions("addInvocationsExclusiveScanNonUniformAMD",   1, &E_GL_AMD_shader_ballot);
7884         }
7885 
7886         if (profile != EEsProfile) {
7887             symbolTable.setFunctionExtensions("min3", 1, &E_GL_AMD_shader_trinary_minmax);
7888             symbolTable.setFunctionExtensions("max3", 1, &E_GL_AMD_shader_trinary_minmax);
7889             symbolTable.setFunctionExtensions("mid3", 1, &E_GL_AMD_shader_trinary_minmax);
7890         }
7891 
7892         if (profile != EEsProfile) {
7893             symbolTable.setFunctionExtensions("cubeFaceIndexAMD", 1, &E_GL_AMD_gcn_shader);
7894             symbolTable.setFunctionExtensions("cubeFaceCoordAMD", 1, &E_GL_AMD_gcn_shader);
7895             symbolTable.setFunctionExtensions("timeAMD",          1, &E_GL_AMD_gcn_shader);
7896         }
7897 
7898         if (profile != EEsProfile) {
7899             symbolTable.setFunctionExtensions("fragmentMaskFetchAMD", 1, &E_GL_AMD_shader_fragment_mask);
7900             symbolTable.setFunctionExtensions("fragmentFetchAMD",     1, &E_GL_AMD_shader_fragment_mask);
7901         }
7902 #endif
7903 
7904 #ifdef NV_EXTENSIONS
7905         symbolTable.setFunctionExtensions("textureFootprintNV",          1, &E_GL_NV_shader_texture_footprint);
7906         symbolTable.setFunctionExtensions("textureFootprintClampNV",     1, &E_GL_NV_shader_texture_footprint);
7907         symbolTable.setFunctionExtensions("textureFootprintLodNV",       1, &E_GL_NV_shader_texture_footprint);
7908         symbolTable.setFunctionExtensions("textureFootprintGradNV",      1, &E_GL_NV_shader_texture_footprint);
7909         symbolTable.setFunctionExtensions("textureFootprintGradClampNV", 1, &E_GL_NV_shader_texture_footprint);
7910 #endif
7911         // Compatibility variables, vertex only
7912         if (spvVersion.spv == 0) {
7913             BuiltInVariable("gl_Color",          EbvColor,          symbolTable);
7914             BuiltInVariable("gl_SecondaryColor", EbvSecondaryColor, symbolTable);
7915             BuiltInVariable("gl_Normal",         EbvNormal,         symbolTable);
7916             BuiltInVariable("gl_Vertex",         EbvVertex,         symbolTable);
7917             BuiltInVariable("gl_MultiTexCoord0", EbvMultiTexCoord0, symbolTable);
7918             BuiltInVariable("gl_MultiTexCoord1", EbvMultiTexCoord1, symbolTable);
7919             BuiltInVariable("gl_MultiTexCoord2", EbvMultiTexCoord2, symbolTable);
7920             BuiltInVariable("gl_MultiTexCoord3", EbvMultiTexCoord3, symbolTable);
7921             BuiltInVariable("gl_MultiTexCoord4", EbvMultiTexCoord4, symbolTable);
7922             BuiltInVariable("gl_MultiTexCoord5", EbvMultiTexCoord5, symbolTable);
7923             BuiltInVariable("gl_MultiTexCoord6", EbvMultiTexCoord6, symbolTable);
7924             BuiltInVariable("gl_MultiTexCoord7", EbvMultiTexCoord7, symbolTable);
7925             BuiltInVariable("gl_FogCoord",       EbvFogFragCoord,   symbolTable);
7926         }
7927 
7928         if (profile == EEsProfile) {
7929             if (spvVersion.spv == 0) {
7930                 symbolTable.setFunctionExtensions("texture2DGradEXT",     1, &E_GL_EXT_shader_texture_lod);
7931                 symbolTable.setFunctionExtensions("texture2DProjGradEXT", 1, &E_GL_EXT_shader_texture_lod);
7932                 symbolTable.setFunctionExtensions("textureCubeGradEXT",   1, &E_GL_EXT_shader_texture_lod);
7933                 if (version == 310)
7934                     symbolTable.setFunctionExtensions("textureGatherOffsets", Num_AEP_gpu_shader5, AEP_gpu_shader5);
7935             }
7936             if (version == 310)
7937                 symbolTable.setFunctionExtensions("fma", Num_AEP_gpu_shader5, AEP_gpu_shader5);
7938         }
7939 
7940         if (profile == EEsProfile && version < 320) {
7941             symbolTable.setFunctionExtensions("imageAtomicAdd",      1, &E_GL_OES_shader_image_atomic);
7942             symbolTable.setFunctionExtensions("imageAtomicMin",      1, &E_GL_OES_shader_image_atomic);
7943             symbolTable.setFunctionExtensions("imageAtomicMax",      1, &E_GL_OES_shader_image_atomic);
7944             symbolTable.setFunctionExtensions("imageAtomicAnd",      1, &E_GL_OES_shader_image_atomic);
7945             symbolTable.setFunctionExtensions("imageAtomicOr",       1, &E_GL_OES_shader_image_atomic);
7946             symbolTable.setFunctionExtensions("imageAtomicXor",      1, &E_GL_OES_shader_image_atomic);
7947             symbolTable.setFunctionExtensions("imageAtomicExchange", 1, &E_GL_OES_shader_image_atomic);
7948             symbolTable.setFunctionExtensions("imageAtomicCompSwap", 1, &E_GL_OES_shader_image_atomic);
7949         }
7950 
7951         if (spvVersion.vulkan == 0) {
7952             SpecialQualifier("gl_VertexID",   EvqVertexId,   EbvVertexId,   symbolTable);
7953             SpecialQualifier("gl_InstanceID", EvqInstanceId, EbvInstanceId, symbolTable);
7954         }
7955 
7956         if (spvVersion.vulkan > 0) {
7957             BuiltInVariable("gl_VertexIndex",   EbvVertexIndex,   symbolTable);
7958             BuiltInVariable("gl_InstanceIndex", EbvInstanceIndex, symbolTable);
7959         }
7960 
7961         if (version >= 300 /* both ES and non-ES */) {
7962             symbolTable.setVariableExtensions("gl_ViewID_OVR", Num_OVR_multiview_EXTs, OVR_multiview_EXTs);
7963             BuiltInVariable("gl_ViewID_OVR", EbvViewIndex, symbolTable);
7964         }
7965 
7966         if (profile == EEsProfile) {
7967             symbolTable.setFunctionExtensions("shadow2DEXT",        1, &E_GL_EXT_shadow_samplers);
7968             symbolTable.setFunctionExtensions("shadow2DProjEXT",    1, &E_GL_EXT_shadow_samplers);
7969         }
7970 
7971         // Fall through
7972 
7973     case EShLangTessControl:
7974         if (profile == EEsProfile && version >= 310) {
7975             BuiltInVariable("gl_BoundingBoxOES", EbvBoundingBox, symbolTable);
7976             if (version < 320)
7977                 symbolTable.setVariableExtensions("gl_BoundingBoxOES", Num_AEP_primitive_bounding_box,
7978                                                   AEP_primitive_bounding_box);
7979         }
7980 
7981         // Fall through
7982 
7983     case EShLangTessEvaluation:
7984     case EShLangGeometry:
7985         SpecialQualifier("gl_Position",   EvqPosition,   EbvPosition,   symbolTable);
7986         SpecialQualifier("gl_PointSize",  EvqPointSize,  EbvPointSize,  symbolTable);
7987         SpecialQualifier("gl_ClipVertex", EvqClipVertex, EbvClipVertex, symbolTable);
7988 
7989         BuiltInVariable("gl_in",  "gl_Position",     EbvPosition,     symbolTable);
7990         BuiltInVariable("gl_in",  "gl_PointSize",    EbvPointSize,    symbolTable);
7991         BuiltInVariable("gl_in",  "gl_ClipDistance", EbvClipDistance, symbolTable);
7992         BuiltInVariable("gl_in",  "gl_CullDistance", EbvCullDistance, symbolTable);
7993 
7994         BuiltInVariable("gl_out", "gl_Position",     EbvPosition,     symbolTable);
7995         BuiltInVariable("gl_out", "gl_PointSize",    EbvPointSize,    symbolTable);
7996         BuiltInVariable("gl_out", "gl_ClipDistance", EbvClipDistance, symbolTable);
7997         BuiltInVariable("gl_out", "gl_CullDistance", EbvCullDistance, symbolTable);
7998 
7999         BuiltInVariable("gl_ClipDistance",    EbvClipDistance,   symbolTable);
8000         BuiltInVariable("gl_CullDistance",    EbvCullDistance,   symbolTable);
8001         BuiltInVariable("gl_PrimitiveIDIn",   EbvPrimitiveId,    symbolTable);
8002         BuiltInVariable("gl_PrimitiveID",     EbvPrimitiveId,    symbolTable);
8003         BuiltInVariable("gl_InvocationID",    EbvInvocationId,   symbolTable);
8004         BuiltInVariable("gl_Layer",           EbvLayer,          symbolTable);
8005         BuiltInVariable("gl_ViewportIndex",   EbvViewportIndex,  symbolTable);
8006 
8007 #ifdef NV_EXTENSIONS
8008         if (language != EShLangGeometry) {
8009             symbolTable.setVariableExtensions("gl_Layer",         Num_viewportEXTs, viewportEXTs);
8010             symbolTable.setVariableExtensions("gl_ViewportIndex", Num_viewportEXTs, viewportEXTs);
8011         }
8012 #else
8013         if (language != EShLangGeometry && version >= 410) {
8014             symbolTable.setVariableExtensions("gl_Layer",         1, &E_GL_ARB_shader_viewport_layer_array);
8015             symbolTable.setVariableExtensions("gl_ViewportIndex", 1, &E_GL_ARB_shader_viewport_layer_array);
8016         }
8017 #endif
8018 
8019 #ifdef NV_EXTENSIONS
8020         symbolTable.setVariableExtensions("gl_ViewportMask",            1, &E_GL_NV_viewport_array2);
8021         symbolTable.setVariableExtensions("gl_SecondaryPositionNV",     1, &E_GL_NV_stereo_view_rendering);
8022         symbolTable.setVariableExtensions("gl_SecondaryViewportMaskNV", 1, &E_GL_NV_stereo_view_rendering);
8023         symbolTable.setVariableExtensions("gl_PositionPerViewNV",       1, &E_GL_NVX_multiview_per_view_attributes);
8024         symbolTable.setVariableExtensions("gl_ViewportMaskPerViewNV",   1, &E_GL_NVX_multiview_per_view_attributes);
8025 
8026         BuiltInVariable("gl_ViewportMask",              EbvViewportMaskNV,          symbolTable);
8027         BuiltInVariable("gl_SecondaryPositionNV",       EbvSecondaryPositionNV,     symbolTable);
8028         BuiltInVariable("gl_SecondaryViewportMaskNV",   EbvSecondaryViewportMaskNV, symbolTable);
8029         BuiltInVariable("gl_PositionPerViewNV",         EbvPositionPerViewNV,       symbolTable);
8030         BuiltInVariable("gl_ViewportMaskPerViewNV",     EbvViewportMaskPerViewNV,   symbolTable);
8031 
8032         if (language != EShLangVertex) {
8033             BuiltInVariable("gl_in", "gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable);
8034             BuiltInVariable("gl_in", "gl_PositionPerViewNV",   EbvPositionPerViewNV,   symbolTable);
8035         }
8036         BuiltInVariable("gl_out", "gl_ViewportMask",            EbvViewportMaskNV,          symbolTable);
8037         BuiltInVariable("gl_out", "gl_SecondaryPositionNV",     EbvSecondaryPositionNV,     symbolTable);
8038         BuiltInVariable("gl_out", "gl_SecondaryViewportMaskNV", EbvSecondaryViewportMaskNV, symbolTable);
8039         BuiltInVariable("gl_out", "gl_PositionPerViewNV",       EbvPositionPerViewNV,       symbolTable);
8040         BuiltInVariable("gl_out", "gl_ViewportMaskPerViewNV",   EbvViewportMaskPerViewNV,   symbolTable);
8041 #endif
8042 
8043         BuiltInVariable("gl_PatchVerticesIn", EbvPatchVertices,  symbolTable);
8044         BuiltInVariable("gl_TessLevelOuter",  EbvTessLevelOuter, symbolTable);
8045         BuiltInVariable("gl_TessLevelInner",  EbvTessLevelInner, symbolTable);
8046         BuiltInVariable("gl_TessCoord",       EbvTessCoord,      symbolTable);
8047 
8048         if (version < 410)
8049             symbolTable.setVariableExtensions("gl_ViewportIndex", 1, &E_GL_ARB_viewport_array);
8050 
8051         // Compatibility variables
8052 
8053         BuiltInVariable("gl_in", "gl_ClipVertex",          EbvClipVertex,          symbolTable);
8054         BuiltInVariable("gl_in", "gl_FrontColor",          EbvFrontColor,          symbolTable);
8055         BuiltInVariable("gl_in", "gl_BackColor",           EbvBackColor,           symbolTable);
8056         BuiltInVariable("gl_in", "gl_FrontSecondaryColor", EbvFrontSecondaryColor, symbolTable);
8057         BuiltInVariable("gl_in", "gl_BackSecondaryColor",  EbvBackSecondaryColor,  symbolTable);
8058         BuiltInVariable("gl_in", "gl_TexCoord",            EbvTexCoord,            symbolTable);
8059         BuiltInVariable("gl_in", "gl_FogFragCoord",        EbvFogFragCoord,        symbolTable);
8060 
8061         BuiltInVariable("gl_out", "gl_ClipVertex",          EbvClipVertex,          symbolTable);
8062         BuiltInVariable("gl_out", "gl_FrontColor",          EbvFrontColor,          symbolTable);
8063         BuiltInVariable("gl_out", "gl_BackColor",           EbvBackColor,           symbolTable);
8064         BuiltInVariable("gl_out", "gl_FrontSecondaryColor", EbvFrontSecondaryColor, symbolTable);
8065         BuiltInVariable("gl_out", "gl_BackSecondaryColor",  EbvBackSecondaryColor,  symbolTable);
8066         BuiltInVariable("gl_out", "gl_TexCoord",            EbvTexCoord,            symbolTable);
8067         BuiltInVariable("gl_out", "gl_FogFragCoord",        EbvFogFragCoord,        symbolTable);
8068 
8069         BuiltInVariable("gl_ClipVertex",          EbvClipVertex,          symbolTable);
8070         BuiltInVariable("gl_FrontColor",          EbvFrontColor,          symbolTable);
8071         BuiltInVariable("gl_BackColor",           EbvBackColor,           symbolTable);
8072         BuiltInVariable("gl_FrontSecondaryColor", EbvFrontSecondaryColor, symbolTable);
8073         BuiltInVariable("gl_BackSecondaryColor",  EbvBackSecondaryColor,  symbolTable);
8074         BuiltInVariable("gl_TexCoord",            EbvTexCoord,            symbolTable);
8075         BuiltInVariable("gl_FogFragCoord",        EbvFogFragCoord,        symbolTable);
8076 
8077         // gl_PointSize, when it needs to be tied to an extension, is always a member of a block.
8078         // (Sometimes with an instance name, sometimes anonymous).
8079         // However, the current automatic extension scheme does not work per block member,
8080         // so for now check when parsing.
8081         //
8082         // if (profile == EEsProfile) {
8083         //    if (language == EShLangGeometry)
8084         //        symbolTable.setVariableExtensions("gl_PointSize", Num_AEP_geometry_point_size, AEP_geometry_point_size);
8085         //    else if (language == EShLangTessEvaluation || language == EShLangTessControl)
8086         //        symbolTable.setVariableExtensions("gl_PointSize", Num_AEP_tessellation_point_size, AEP_tessellation_point_size);
8087         //}
8088 
8089         if ((profile != EEsProfile && version >= 140) ||
8090             (profile == EEsProfile && version >= 310)) {
8091             symbolTable.setVariableExtensions("gl_DeviceIndex",  1, &E_GL_EXT_device_group);
8092             BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
8093             symbolTable.setVariableExtensions("gl_ViewIndex", 1, &E_GL_EXT_multiview);
8094             BuiltInVariable("gl_ViewIndex", EbvViewIndex, symbolTable);
8095         }
8096 
8097         // GL_KHR_shader_subgroup
8098         if (spvVersion.vulkan > 0) {
8099             symbolTable.setVariableExtensions("gl_SubgroupSize",         1, &E_GL_KHR_shader_subgroup_basic);
8100             symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
8101             symbolTable.setVariableExtensions("gl_SubgroupEqMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8102             symbolTable.setVariableExtensions("gl_SubgroupGeMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8103             symbolTable.setVariableExtensions("gl_SubgroupGtMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8104             symbolTable.setVariableExtensions("gl_SubgroupLeMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8105             symbolTable.setVariableExtensions("gl_SubgroupLtMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8106 
8107             BuiltInVariable("gl_SubgroupSize",         EbvSubgroupSize2,       symbolTable);
8108             BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
8109             BuiltInVariable("gl_SubgroupEqMask",       EbvSubgroupEqMask2,     symbolTable);
8110             BuiltInVariable("gl_SubgroupGeMask",       EbvSubgroupGeMask2,     symbolTable);
8111             BuiltInVariable("gl_SubgroupGtMask",       EbvSubgroupGtMask2,     symbolTable);
8112             BuiltInVariable("gl_SubgroupLeMask",       EbvSubgroupLeMask2,     symbolTable);
8113             BuiltInVariable("gl_SubgroupLtMask",       EbvSubgroupLtMask2,     symbolTable);
8114         }
8115 
8116         break;
8117 
8118     case EShLangFragment:
8119         SpecialQualifier("gl_FrontFacing",      EvqFace,       EbvFace,             symbolTable);
8120         SpecialQualifier("gl_FragCoord",        EvqFragCoord,  EbvFragCoord,        symbolTable);
8121         SpecialQualifier("gl_PointCoord",       EvqPointCoord, EbvPointCoord,       symbolTable);
8122         if (spvVersion.spv == 0)
8123             SpecialQualifier("gl_FragColor",    EvqFragColor,  EbvFragColor,        symbolTable);
8124         else {
8125             TSymbol* symbol = symbolTable.find("gl_FragColor");
8126             if (symbol) {
8127                 symbol->getWritableType().getQualifier().storage = EvqVaryingOut;
8128                 symbol->getWritableType().getQualifier().layoutLocation = 0;
8129             }
8130         }
8131         SpecialQualifier("gl_FragDepth",        EvqFragDepth,  EbvFragDepth,        symbolTable);
8132         SpecialQualifier("gl_FragDepthEXT",     EvqFragDepth,  EbvFragDepth,        symbolTable);
8133         SpecialQualifier("gl_HelperInvocation", EvqVaryingIn,  EbvHelperInvocation, symbolTable);
8134 
8135         BuiltInVariable("gl_ClipDistance",    EbvClipDistance,   symbolTable);
8136         BuiltInVariable("gl_CullDistance",    EbvCullDistance,   symbolTable);
8137         BuiltInVariable("gl_PrimitiveID",     EbvPrimitiveId,    symbolTable);
8138 
8139         if (profile != EEsProfile && version >= 140) {
8140             symbolTable.setVariableExtensions("gl_FragStencilRefARB", 1, &E_GL_ARB_shader_stencil_export);
8141             BuiltInVariable("gl_FragStencilRefARB", EbvFragStencilRef, symbolTable);
8142         }
8143 
8144         if ((profile != EEsProfile && version >= 400) ||
8145             (profile == EEsProfile && version >= 310)) {
8146             BuiltInVariable("gl_SampleID",        EbvSampleId,       symbolTable);
8147             BuiltInVariable("gl_SamplePosition",  EbvSamplePosition, symbolTable);
8148             BuiltInVariable("gl_SampleMaskIn",    EbvSampleMask,     symbolTable);
8149             BuiltInVariable("gl_SampleMask",      EbvSampleMask,     symbolTable);
8150             if (profile == EEsProfile && version < 320) {
8151                 symbolTable.setVariableExtensions("gl_SampleID",       1, &E_GL_OES_sample_variables);
8152                 symbolTable.setVariableExtensions("gl_SamplePosition", 1, &E_GL_OES_sample_variables);
8153                 symbolTable.setVariableExtensions("gl_SampleMaskIn",   1, &E_GL_OES_sample_variables);
8154                 symbolTable.setVariableExtensions("gl_SampleMask",     1, &E_GL_OES_sample_variables);
8155                 symbolTable.setVariableExtensions("gl_NumSamples",     1, &E_GL_OES_sample_variables);
8156             }
8157         }
8158 
8159         BuiltInVariable("gl_Layer",           EbvLayer,          symbolTable);
8160         BuiltInVariable("gl_ViewportIndex",   EbvViewportIndex,  symbolTable);
8161 
8162         // Compatibility variables
8163 
8164         BuiltInVariable("gl_in", "gl_FogFragCoord",   EbvFogFragCoord,   symbolTable);
8165         BuiltInVariable("gl_in", "gl_TexCoord",       EbvTexCoord,       symbolTable);
8166         BuiltInVariable("gl_in", "gl_Color",          EbvColor,          symbolTable);
8167         BuiltInVariable("gl_in", "gl_SecondaryColor", EbvSecondaryColor, symbolTable);
8168 
8169         BuiltInVariable("gl_FogFragCoord",   EbvFogFragCoord,   symbolTable);
8170         BuiltInVariable("gl_TexCoord",       EbvTexCoord,       symbolTable);
8171         BuiltInVariable("gl_Color",          EbvColor,          symbolTable);
8172         BuiltInVariable("gl_SecondaryColor", EbvSecondaryColor, symbolTable);
8173 
8174         // built-in functions
8175 
8176         if (profile == EEsProfile) {
8177             if (spvVersion.spv == 0) {
8178                 symbolTable.setFunctionExtensions("texture2DLodEXT",      1, &E_GL_EXT_shader_texture_lod);
8179                 symbolTable.setFunctionExtensions("texture2DProjLodEXT",  1, &E_GL_EXT_shader_texture_lod);
8180                 symbolTable.setFunctionExtensions("textureCubeLodEXT",    1, &E_GL_EXT_shader_texture_lod);
8181                 symbolTable.setFunctionExtensions("texture2DGradEXT",     1, &E_GL_EXT_shader_texture_lod);
8182                 symbolTable.setFunctionExtensions("texture2DProjGradEXT", 1, &E_GL_EXT_shader_texture_lod);
8183                 symbolTable.setFunctionExtensions("textureCubeGradEXT",   1, &E_GL_EXT_shader_texture_lod);
8184                 if (version < 320)
8185                     symbolTable.setFunctionExtensions("textureGatherOffsets", Num_AEP_gpu_shader5, AEP_gpu_shader5);
8186             }
8187             if (version == 100) {
8188                 symbolTable.setFunctionExtensions("dFdx",   1, &E_GL_OES_standard_derivatives);
8189                 symbolTable.setFunctionExtensions("dFdy",   1, &E_GL_OES_standard_derivatives);
8190                 symbolTable.setFunctionExtensions("fwidth", 1, &E_GL_OES_standard_derivatives);
8191             }
8192             if (version == 310) {
8193                 symbolTable.setFunctionExtensions("fma", Num_AEP_gpu_shader5, AEP_gpu_shader5);
8194                 symbolTable.setFunctionExtensions("interpolateAtCentroid", 1, &E_GL_OES_shader_multisample_interpolation);
8195                 symbolTable.setFunctionExtensions("interpolateAtSample",   1, &E_GL_OES_shader_multisample_interpolation);
8196                 symbolTable.setFunctionExtensions("interpolateAtOffset",   1, &E_GL_OES_shader_multisample_interpolation);
8197             }
8198         } else if (version < 130) {
8199             if (spvVersion.spv == 0) {
8200                 symbolTable.setFunctionExtensions("texture1DLod",        1, &E_GL_ARB_shader_texture_lod);
8201                 symbolTable.setFunctionExtensions("texture2DLod",        1, &E_GL_ARB_shader_texture_lod);
8202                 symbolTable.setFunctionExtensions("texture3DLod",        1, &E_GL_ARB_shader_texture_lod);
8203                 symbolTable.setFunctionExtensions("textureCubeLod",      1, &E_GL_ARB_shader_texture_lod);
8204                 symbolTable.setFunctionExtensions("texture1DProjLod",    1, &E_GL_ARB_shader_texture_lod);
8205                 symbolTable.setFunctionExtensions("texture2DProjLod",    1, &E_GL_ARB_shader_texture_lod);
8206                 symbolTable.setFunctionExtensions("texture3DProjLod",    1, &E_GL_ARB_shader_texture_lod);
8207                 symbolTable.setFunctionExtensions("shadow1DLod",         1, &E_GL_ARB_shader_texture_lod);
8208                 symbolTable.setFunctionExtensions("shadow2DLod",         1, &E_GL_ARB_shader_texture_lod);
8209                 symbolTable.setFunctionExtensions("shadow1DProjLod",     1, &E_GL_ARB_shader_texture_lod);
8210                 symbolTable.setFunctionExtensions("shadow2DProjLod",     1, &E_GL_ARB_shader_texture_lod);
8211             }
8212         }
8213 
8214         // E_GL_ARB_shader_texture_lod functions usable only with the extension enabled
8215         if (profile != EEsProfile && spvVersion.spv == 0) {
8216             symbolTable.setFunctionExtensions("texture1DGradARB",         1, &E_GL_ARB_shader_texture_lod);
8217             symbolTable.setFunctionExtensions("texture1DProjGradARB",     1, &E_GL_ARB_shader_texture_lod);
8218             symbolTable.setFunctionExtensions("texture2DGradARB",         1, &E_GL_ARB_shader_texture_lod);
8219             symbolTable.setFunctionExtensions("texture2DProjGradARB",     1, &E_GL_ARB_shader_texture_lod);
8220             symbolTable.setFunctionExtensions("texture3DGradARB",         1, &E_GL_ARB_shader_texture_lod);
8221             symbolTable.setFunctionExtensions("texture3DProjGradARB",     1, &E_GL_ARB_shader_texture_lod);
8222             symbolTable.setFunctionExtensions("textureCubeGradARB",       1, &E_GL_ARB_shader_texture_lod);
8223             symbolTable.setFunctionExtensions("shadow1DGradARB",          1, &E_GL_ARB_shader_texture_lod);
8224             symbolTable.setFunctionExtensions("shadow1DProjGradARB",      1, &E_GL_ARB_shader_texture_lod);
8225             symbolTable.setFunctionExtensions("shadow2DGradARB",          1, &E_GL_ARB_shader_texture_lod);
8226             symbolTable.setFunctionExtensions("shadow2DProjGradARB",      1, &E_GL_ARB_shader_texture_lod);
8227             symbolTable.setFunctionExtensions("texture2DRectGradARB",     1, &E_GL_ARB_shader_texture_lod);
8228             symbolTable.setFunctionExtensions("texture2DRectProjGradARB", 1, &E_GL_ARB_shader_texture_lod);
8229             symbolTable.setFunctionExtensions("shadow2DRectGradARB",      1, &E_GL_ARB_shader_texture_lod);
8230             symbolTable.setFunctionExtensions("shadow2DRectProjGradARB",  1, &E_GL_ARB_shader_texture_lod);
8231         }
8232 
8233         // E_GL_ARB_shader_image_load_store
8234         if (profile != EEsProfile && version < 420)
8235             symbolTable.setFunctionExtensions("memoryBarrier", 1, &E_GL_ARB_shader_image_load_store);
8236         // All the image access functions are protected by checks on the type of the first argument.
8237 
8238         // E_GL_ARB_shader_atomic_counters
8239         if (profile != EEsProfile && version < 420) {
8240             symbolTable.setFunctionExtensions("atomicCounterIncrement", 1, &E_GL_ARB_shader_atomic_counters);
8241             symbolTable.setFunctionExtensions("atomicCounterDecrement", 1, &E_GL_ARB_shader_atomic_counters);
8242             symbolTable.setFunctionExtensions("atomicCounter"         , 1, &E_GL_ARB_shader_atomic_counters);
8243         }
8244 
8245         // E_GL_ARB_derivative_control
8246         if (profile != EEsProfile && version < 450) {
8247             symbolTable.setFunctionExtensions("dFdxFine",     1, &E_GL_ARB_derivative_control);
8248             symbolTable.setFunctionExtensions("dFdyFine",     1, &E_GL_ARB_derivative_control);
8249             symbolTable.setFunctionExtensions("fwidthFine",   1, &E_GL_ARB_derivative_control);
8250             symbolTable.setFunctionExtensions("dFdxCoarse",   1, &E_GL_ARB_derivative_control);
8251             symbolTable.setFunctionExtensions("dFdyCoarse",   1, &E_GL_ARB_derivative_control);
8252             symbolTable.setFunctionExtensions("fwidthCoarse", 1, &E_GL_ARB_derivative_control);
8253         }
8254 
8255         // E_GL_ARB_sparse_texture2
8256         if (profile != EEsProfile)
8257         {
8258             symbolTable.setFunctionExtensions("sparseTextureARB",              1, &E_GL_ARB_sparse_texture2);
8259             symbolTable.setFunctionExtensions("sparseTextureLodARB",           1, &E_GL_ARB_sparse_texture2);
8260             symbolTable.setFunctionExtensions("sparseTextureOffsetARB",        1, &E_GL_ARB_sparse_texture2);
8261             symbolTable.setFunctionExtensions("sparseTexelFetchARB",           1, &E_GL_ARB_sparse_texture2);
8262             symbolTable.setFunctionExtensions("sparseTexelFetchOffsetARB",     1, &E_GL_ARB_sparse_texture2);
8263             symbolTable.setFunctionExtensions("sparseTextureLodOffsetARB",     1, &E_GL_ARB_sparse_texture2);
8264             symbolTable.setFunctionExtensions("sparseTextureGradARB",          1, &E_GL_ARB_sparse_texture2);
8265             symbolTable.setFunctionExtensions("sparseTextureGradOffsetARB",    1, &E_GL_ARB_sparse_texture2);
8266             symbolTable.setFunctionExtensions("sparseTextureGatherARB",        1, &E_GL_ARB_sparse_texture2);
8267             symbolTable.setFunctionExtensions("sparseTextureGatherOffsetARB",  1, &E_GL_ARB_sparse_texture2);
8268             symbolTable.setFunctionExtensions("sparseTextureGatherOffsetsARB", 1, &E_GL_ARB_sparse_texture2);
8269             symbolTable.setFunctionExtensions("sparseImageLoadARB",            1, &E_GL_ARB_sparse_texture2);
8270             symbolTable.setFunctionExtensions("sparseTexelsResident",          1, &E_GL_ARB_sparse_texture2);
8271         }
8272 
8273         // E_GL_ARB_sparse_texture_clamp
8274         if (profile != EEsProfile)
8275         {
8276             symbolTable.setFunctionExtensions("sparseTextureClampARB",              1, &E_GL_ARB_sparse_texture_clamp);
8277             symbolTable.setFunctionExtensions("sparseTextureOffsetClampARB",        1, &E_GL_ARB_sparse_texture_clamp);
8278             symbolTable.setFunctionExtensions("sparseTextureGradClampARB",          1, &E_GL_ARB_sparse_texture_clamp);
8279             symbolTable.setFunctionExtensions("sparseTextureGradOffsetClampARB",    1, &E_GL_ARB_sparse_texture_clamp);
8280             symbolTable.setFunctionExtensions("textureClampARB",                    1, &E_GL_ARB_sparse_texture_clamp);
8281             symbolTable.setFunctionExtensions("textureOffsetClampARB",              1, &E_GL_ARB_sparse_texture_clamp);
8282             symbolTable.setFunctionExtensions("textureGradClampARB",                1, &E_GL_ARB_sparse_texture_clamp);
8283             symbolTable.setFunctionExtensions("textureGradOffsetClampARB",          1, &E_GL_ARB_sparse_texture_clamp);
8284         }
8285 
8286 #ifdef AMD_EXTENSIONS
8287         // E_GL_AMD_shader_explicit_vertex_parameter
8288         if (profile != EEsProfile) {
8289             symbolTable.setVariableExtensions("gl_BaryCoordNoPerspAMD",         1, &E_GL_AMD_shader_explicit_vertex_parameter);
8290             symbolTable.setVariableExtensions("gl_BaryCoordNoPerspCentroidAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter);
8291             symbolTable.setVariableExtensions("gl_BaryCoordNoPerspSampleAMD",   1, &E_GL_AMD_shader_explicit_vertex_parameter);
8292             symbolTable.setVariableExtensions("gl_BaryCoordSmoothAMD",          1, &E_GL_AMD_shader_explicit_vertex_parameter);
8293             symbolTable.setVariableExtensions("gl_BaryCoordSmoothCentroidAMD",  1, &E_GL_AMD_shader_explicit_vertex_parameter);
8294             symbolTable.setVariableExtensions("gl_BaryCoordSmoothSampleAMD",    1, &E_GL_AMD_shader_explicit_vertex_parameter);
8295             symbolTable.setVariableExtensions("gl_BaryCoordPullModelAMD",       1, &E_GL_AMD_shader_explicit_vertex_parameter);
8296 
8297             symbolTable.setFunctionExtensions("interpolateAtVertexAMD",         1, &E_GL_AMD_shader_explicit_vertex_parameter);
8298 
8299             BuiltInVariable("gl_BaryCoordNoPerspAMD",           EbvBaryCoordNoPersp,         symbolTable);
8300             BuiltInVariable("gl_BaryCoordNoPerspCentroidAMD",   EbvBaryCoordNoPerspCentroid, symbolTable);
8301             BuiltInVariable("gl_BaryCoordNoPerspSampleAMD",     EbvBaryCoordNoPerspSample,   symbolTable);
8302             BuiltInVariable("gl_BaryCoordSmoothAMD",            EbvBaryCoordSmooth,          symbolTable);
8303             BuiltInVariable("gl_BaryCoordSmoothCentroidAMD",    EbvBaryCoordSmoothCentroid,  symbolTable);
8304             BuiltInVariable("gl_BaryCoordSmoothSampleAMD",      EbvBaryCoordSmoothSample,    symbolTable);
8305             BuiltInVariable("gl_BaryCoordPullModelAMD",         EbvBaryCoordPullModel,       symbolTable);
8306         }
8307 
8308         // E_GL_AMD_texture_gather_bias_lod
8309         if (profile != EEsProfile) {
8310             symbolTable.setFunctionExtensions("textureGatherLodAMD",                1, &E_GL_AMD_texture_gather_bias_lod);
8311             symbolTable.setFunctionExtensions("textureGatherLodOffsetAMD",          1, &E_GL_AMD_texture_gather_bias_lod);
8312             symbolTable.setFunctionExtensions("textureGatherLodOffsetsAMD",         1, &E_GL_AMD_texture_gather_bias_lod);
8313             symbolTable.setFunctionExtensions("sparseTextureGatherLodAMD",          1, &E_GL_AMD_texture_gather_bias_lod);
8314             symbolTable.setFunctionExtensions("sparseTextureGatherLodOffsetAMD",    1, &E_GL_AMD_texture_gather_bias_lod);
8315             symbolTable.setFunctionExtensions("sparseTextureGatherLodOffsetsAMD",   1, &E_GL_AMD_texture_gather_bias_lod);
8316         }
8317 
8318         // E_GL_AMD_shader_image_load_store_lod
8319         if (profile != EEsProfile) {
8320             symbolTable.setFunctionExtensions("imageLoadLodAMD",        1, &E_GL_AMD_shader_image_load_store_lod);
8321             symbolTable.setFunctionExtensions("imageStoreLodAMD",       1, &E_GL_AMD_shader_image_load_store_lod);
8322             symbolTable.setFunctionExtensions("sparseImageLoadLodAMD",  1, &E_GL_AMD_shader_image_load_store_lod);
8323         }
8324 #endif
8325 
8326 #ifdef NV_EXTENSIONS
8327         if (profile != EEsProfile && version >= 430) {
8328             symbolTable.setVariableExtensions("gl_FragFullyCoveredNV", 1, &E_GL_NV_conservative_raster_underestimation);
8329             BuiltInVariable("gl_FragFullyCoveredNV", EbvFragFullyCoveredNV, symbolTable);
8330         }
8331         if ((profile != EEsProfile && version >= 450) ||
8332             (profile == EEsProfile && version >= 320)) {
8333             symbolTable.setVariableExtensions("gl_FragmentSizeNV",        1, &E_GL_NV_shading_rate_image);
8334             symbolTable.setVariableExtensions("gl_InvocationsPerPixelNV", 1, &E_GL_NV_shading_rate_image);
8335             BuiltInVariable("gl_FragmentSizeNV",        EbvFragmentSizeNV, symbolTable);
8336             BuiltInVariable("gl_InvocationsPerPixelNV", EbvInvocationsPerPixelNV, symbolTable);
8337             symbolTable.setVariableExtensions("gl_BaryCoordNV",        1, &E_GL_NV_fragment_shader_barycentric);
8338             symbolTable.setVariableExtensions("gl_BaryCoordNoPerspNV", 1, &E_GL_NV_fragment_shader_barycentric);
8339             BuiltInVariable("gl_BaryCoordNV",        EbvBaryCoordNV,        symbolTable);
8340             BuiltInVariable("gl_BaryCoordNoPerspNV", EbvBaryCoordNoPerspNV, symbolTable);
8341         }
8342         if (((profile != EEsProfile && version >= 450) ||
8343             (profile == EEsProfile && version >= 320)) &&
8344             language == EShLangCompute) {
8345             symbolTable.setFunctionExtensions("dFdx",                   1, &E_GL_NV_compute_shader_derivatives);
8346             symbolTable.setFunctionExtensions("dFdy",                   1, &E_GL_NV_compute_shader_derivatives);
8347             symbolTable.setFunctionExtensions("fwidth",                 1, &E_GL_NV_compute_shader_derivatives);
8348             symbolTable.setFunctionExtensions("dFdxFine",               1, &E_GL_NV_compute_shader_derivatives);
8349             symbolTable.setFunctionExtensions("dFdyFine",               1, &E_GL_NV_compute_shader_derivatives);
8350             symbolTable.setFunctionExtensions("fwidthFine",             1, &E_GL_NV_compute_shader_derivatives);
8351             symbolTable.setFunctionExtensions("dFdxCoarse",             1, &E_GL_NV_compute_shader_derivatives);
8352             symbolTable.setFunctionExtensions("dFdyCoarse",             1, &E_GL_NV_compute_shader_derivatives);
8353             symbolTable.setFunctionExtensions("fwidthCoarse",           1, &E_GL_NV_compute_shader_derivatives);
8354         }
8355 #endif
8356 
8357         if ((profile != EEsProfile && version >= 450) ||
8358             (profile == EEsProfile && version >= 310)) {
8359             symbolTable.setVariableExtensions("gl_FragSizeEXT",            1, &E_GL_EXT_fragment_invocation_density);
8360             symbolTable.setVariableExtensions("gl_FragInvocationCountEXT", 1, &E_GL_EXT_fragment_invocation_density);
8361             BuiltInVariable("gl_FragSizeEXT",            EbvFragSizeEXT, symbolTable);
8362             BuiltInVariable("gl_FragInvocationCountEXT", EbvFragInvocationCountEXT, symbolTable);
8363         }
8364 
8365         symbolTable.setVariableExtensions("gl_FragDepthEXT", 1, &E_GL_EXT_frag_depth);
8366 
8367         if (profile == EEsProfile && version < 320) {
8368             symbolTable.setVariableExtensions("gl_PrimitiveID",  Num_AEP_geometry_shader, AEP_geometry_shader);
8369             symbolTable.setVariableExtensions("gl_Layer",        Num_AEP_geometry_shader, AEP_geometry_shader);
8370         }
8371 
8372         if (profile == EEsProfile && version < 320) {
8373             symbolTable.setFunctionExtensions("imageAtomicAdd",      1, &E_GL_OES_shader_image_atomic);
8374             symbolTable.setFunctionExtensions("imageAtomicMin",      1, &E_GL_OES_shader_image_atomic);
8375             symbolTable.setFunctionExtensions("imageAtomicMax",      1, &E_GL_OES_shader_image_atomic);
8376             symbolTable.setFunctionExtensions("imageAtomicAnd",      1, &E_GL_OES_shader_image_atomic);
8377             symbolTable.setFunctionExtensions("imageAtomicOr",       1, &E_GL_OES_shader_image_atomic);
8378             symbolTable.setFunctionExtensions("imageAtomicXor",      1, &E_GL_OES_shader_image_atomic);
8379             symbolTable.setFunctionExtensions("imageAtomicExchange", 1, &E_GL_OES_shader_image_atomic);
8380             symbolTable.setFunctionExtensions("imageAtomicCompSwap", 1, &E_GL_OES_shader_image_atomic);
8381         }
8382 
8383         symbolTable.setVariableExtensions("gl_DeviceIndex",  1, &E_GL_EXT_device_group);
8384         BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
8385         symbolTable.setVariableExtensions("gl_ViewIndex", 1, &E_GL_EXT_multiview);
8386         BuiltInVariable("gl_ViewIndex", EbvViewIndex, symbolTable);
8387         if (version >= 300 /* both ES and non-ES */) {
8388             symbolTable.setVariableExtensions("gl_ViewID_OVR", Num_OVR_multiview_EXTs, OVR_multiview_EXTs);
8389             BuiltInVariable("gl_ViewID_OVR", EbvViewIndex, symbolTable);
8390         }
8391 
8392         // GL_ARB_shader_ballot
8393         if (profile != EEsProfile) {
8394             symbolTable.setVariableExtensions("gl_SubGroupSizeARB",       1, &E_GL_ARB_shader_ballot);
8395             symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
8396             symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB",     1, &E_GL_ARB_shader_ballot);
8397             symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB",     1, &E_GL_ARB_shader_ballot);
8398             symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB",     1, &E_GL_ARB_shader_ballot);
8399             symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB",     1, &E_GL_ARB_shader_ballot);
8400             symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB",     1, &E_GL_ARB_shader_ballot);
8401 
8402             BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
8403             BuiltInVariable("gl_SubGroupEqMaskARB",     EbvSubGroupEqMask,     symbolTable);
8404             BuiltInVariable("gl_SubGroupGeMaskARB",     EbvSubGroupGeMask,     symbolTable);
8405             BuiltInVariable("gl_SubGroupGtMaskARB",     EbvSubGroupGtMask,     symbolTable);
8406             BuiltInVariable("gl_SubGroupLeMaskARB",     EbvSubGroupLeMask,     symbolTable);
8407             BuiltInVariable("gl_SubGroupLtMaskARB",     EbvSubGroupLtMask,     symbolTable);
8408 
8409             if (spvVersion.vulkan > 0)
8410                 // Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
8411                 SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
8412             else
8413                 BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
8414         }
8415 
8416         // GL_KHR_shader_subgroup
8417         if (spvVersion.vulkan > 0) {
8418             symbolTable.setVariableExtensions("gl_SubgroupSize",         1, &E_GL_KHR_shader_subgroup_basic);
8419             symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
8420             symbolTable.setVariableExtensions("gl_SubgroupEqMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8421             symbolTable.setVariableExtensions("gl_SubgroupGeMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8422             symbolTable.setVariableExtensions("gl_SubgroupGtMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8423             symbolTable.setVariableExtensions("gl_SubgroupLeMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8424             symbolTable.setVariableExtensions("gl_SubgroupLtMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8425 
8426             BuiltInVariable("gl_SubgroupSize",         EbvSubgroupSize2,       symbolTable);
8427             BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
8428             BuiltInVariable("gl_SubgroupEqMask",       EbvSubgroupEqMask2,     symbolTable);
8429             BuiltInVariable("gl_SubgroupGeMask",       EbvSubgroupGeMask2,     symbolTable);
8430             BuiltInVariable("gl_SubgroupGtMask",       EbvSubgroupGtMask2,     symbolTable);
8431             BuiltInVariable("gl_SubgroupLeMask",       EbvSubgroupLeMask2,     symbolTable);
8432             BuiltInVariable("gl_SubgroupLtMask",       EbvSubgroupLtMask2,     symbolTable);
8433 
8434             symbolTable.setFunctionExtensions("subgroupBarrier",                 1, &E_GL_KHR_shader_subgroup_basic);
8435             symbolTable.setFunctionExtensions("subgroupMemoryBarrier",           1, &E_GL_KHR_shader_subgroup_basic);
8436             symbolTable.setFunctionExtensions("subgroupMemoryBarrierBuffer",     1, &E_GL_KHR_shader_subgroup_basic);
8437             symbolTable.setFunctionExtensions("subgroupMemoryBarrierImage",      1, &E_GL_KHR_shader_subgroup_basic);
8438             symbolTable.setFunctionExtensions("subgroupElect",                   1, &E_GL_KHR_shader_subgroup_basic);
8439             symbolTable.setFunctionExtensions("subgroupAll",                     1, &E_GL_KHR_shader_subgroup_vote);
8440             symbolTable.setFunctionExtensions("subgroupAny",                     1, &E_GL_KHR_shader_subgroup_vote);
8441             symbolTable.setFunctionExtensions("subgroupAllEqual",                1, &E_GL_KHR_shader_subgroup_vote);
8442             symbolTable.setFunctionExtensions("subgroupBroadcast",               1, &E_GL_KHR_shader_subgroup_ballot);
8443             symbolTable.setFunctionExtensions("subgroupBroadcastFirst",          1, &E_GL_KHR_shader_subgroup_ballot);
8444             symbolTable.setFunctionExtensions("subgroupBallot",                  1, &E_GL_KHR_shader_subgroup_ballot);
8445             symbolTable.setFunctionExtensions("subgroupInverseBallot",           1, &E_GL_KHR_shader_subgroup_ballot);
8446             symbolTable.setFunctionExtensions("subgroupBallotBitExtract",        1, &E_GL_KHR_shader_subgroup_ballot);
8447             symbolTable.setFunctionExtensions("subgroupBallotBitCount",          1, &E_GL_KHR_shader_subgroup_ballot);
8448             symbolTable.setFunctionExtensions("subgroupBallotInclusiveBitCount", 1, &E_GL_KHR_shader_subgroup_ballot);
8449             symbolTable.setFunctionExtensions("subgroupBallotExclusiveBitCount", 1, &E_GL_KHR_shader_subgroup_ballot);
8450             symbolTable.setFunctionExtensions("subgroupBallotFindLSB",           1, &E_GL_KHR_shader_subgroup_ballot);
8451             symbolTable.setFunctionExtensions("subgroupBallotFindMSB",           1, &E_GL_KHR_shader_subgroup_ballot);
8452             symbolTable.setFunctionExtensions("subgroupShuffle",                 1, &E_GL_KHR_shader_subgroup_shuffle);
8453             symbolTable.setFunctionExtensions("subgroupShuffleXor",              1, &E_GL_KHR_shader_subgroup_shuffle);
8454             symbolTable.setFunctionExtensions("subgroupShuffleUp",               1, &E_GL_KHR_shader_subgroup_shuffle_relative);
8455             symbolTable.setFunctionExtensions("subgroupShuffleDown",             1, &E_GL_KHR_shader_subgroup_shuffle_relative);
8456             symbolTable.setFunctionExtensions("subgroupAdd",                     1, &E_GL_KHR_shader_subgroup_arithmetic);
8457             symbolTable.setFunctionExtensions("subgroupMul",                     1, &E_GL_KHR_shader_subgroup_arithmetic);
8458             symbolTable.setFunctionExtensions("subgroupMin",                     1, &E_GL_KHR_shader_subgroup_arithmetic);
8459             symbolTable.setFunctionExtensions("subgroupMax",                     1, &E_GL_KHR_shader_subgroup_arithmetic);
8460             symbolTable.setFunctionExtensions("subgroupAnd",                     1, &E_GL_KHR_shader_subgroup_arithmetic);
8461             symbolTable.setFunctionExtensions("subgroupOr",                      1, &E_GL_KHR_shader_subgroup_arithmetic);
8462             symbolTable.setFunctionExtensions("subgroupXor",                     1, &E_GL_KHR_shader_subgroup_arithmetic);
8463             symbolTable.setFunctionExtensions("subgroupInclusiveAdd",            1, &E_GL_KHR_shader_subgroup_arithmetic);
8464             symbolTable.setFunctionExtensions("subgroupInclusiveMul",            1, &E_GL_KHR_shader_subgroup_arithmetic);
8465             symbolTable.setFunctionExtensions("subgroupInclusiveMin",            1, &E_GL_KHR_shader_subgroup_arithmetic);
8466             symbolTable.setFunctionExtensions("subgroupInclusiveMax",            1, &E_GL_KHR_shader_subgroup_arithmetic);
8467             symbolTable.setFunctionExtensions("subgroupInclusiveAnd",            1, &E_GL_KHR_shader_subgroup_arithmetic);
8468             symbolTable.setFunctionExtensions("subgroupInclusiveOr",             1, &E_GL_KHR_shader_subgroup_arithmetic);
8469             symbolTable.setFunctionExtensions("subgroupInclusiveXor",            1, &E_GL_KHR_shader_subgroup_arithmetic);
8470             symbolTable.setFunctionExtensions("subgroupExclusiveAdd",            1, &E_GL_KHR_shader_subgroup_arithmetic);
8471             symbolTable.setFunctionExtensions("subgroupExclusiveMul",            1, &E_GL_KHR_shader_subgroup_arithmetic);
8472             symbolTable.setFunctionExtensions("subgroupExclusiveMin",            1, &E_GL_KHR_shader_subgroup_arithmetic);
8473             symbolTable.setFunctionExtensions("subgroupExclusiveMax",            1, &E_GL_KHR_shader_subgroup_arithmetic);
8474             symbolTable.setFunctionExtensions("subgroupExclusiveAnd",            1, &E_GL_KHR_shader_subgroup_arithmetic);
8475             symbolTable.setFunctionExtensions("subgroupExclusiveOr",             1, &E_GL_KHR_shader_subgroup_arithmetic);
8476             symbolTable.setFunctionExtensions("subgroupExclusiveXor",            1, &E_GL_KHR_shader_subgroup_arithmetic);
8477             symbolTable.setFunctionExtensions("subgroupClusteredAdd",            1, &E_GL_KHR_shader_subgroup_clustered);
8478             symbolTable.setFunctionExtensions("subgroupClusteredMul",            1, &E_GL_KHR_shader_subgroup_clustered);
8479             symbolTable.setFunctionExtensions("subgroupClusteredMin",            1, &E_GL_KHR_shader_subgroup_clustered);
8480             symbolTable.setFunctionExtensions("subgroupClusteredMax",            1, &E_GL_KHR_shader_subgroup_clustered);
8481             symbolTable.setFunctionExtensions("subgroupClusteredAnd",            1, &E_GL_KHR_shader_subgroup_clustered);
8482             symbolTable.setFunctionExtensions("subgroupClusteredOr",             1, &E_GL_KHR_shader_subgroup_clustered);
8483             symbolTable.setFunctionExtensions("subgroupClusteredXor",            1, &E_GL_KHR_shader_subgroup_clustered);
8484             symbolTable.setFunctionExtensions("subgroupQuadBroadcast",           1, &E_GL_KHR_shader_subgroup_quad);
8485             symbolTable.setFunctionExtensions("subgroupQuadSwapHorizontal",      1, &E_GL_KHR_shader_subgroup_quad);
8486             symbolTable.setFunctionExtensions("subgroupQuadSwapVertical",        1, &E_GL_KHR_shader_subgroup_quad);
8487             symbolTable.setFunctionExtensions("subgroupQuadSwapDiagonal",        1, &E_GL_KHR_shader_subgroup_quad);
8488 
8489 #ifdef NV_EXTENSIONS
8490             symbolTable.setFunctionExtensions("subgroupPartitionNV",                          1, &E_GL_NV_shader_subgroup_partitioned);
8491             symbolTable.setFunctionExtensions("subgroupPartitionedAddNV",                     1, &E_GL_NV_shader_subgroup_partitioned);
8492             symbolTable.setFunctionExtensions("subgroupPartitionedMulNV",                     1, &E_GL_NV_shader_subgroup_partitioned);
8493             symbolTable.setFunctionExtensions("subgroupPartitionedMinNV",                     1, &E_GL_NV_shader_subgroup_partitioned);
8494             symbolTable.setFunctionExtensions("subgroupPartitionedMaxNV",                     1, &E_GL_NV_shader_subgroup_partitioned);
8495             symbolTable.setFunctionExtensions("subgroupPartitionedAndNV",                     1, &E_GL_NV_shader_subgroup_partitioned);
8496             symbolTable.setFunctionExtensions("subgroupPartitionedOrNV",                      1, &E_GL_NV_shader_subgroup_partitioned);
8497             symbolTable.setFunctionExtensions("subgroupPartitionedXorNV",                     1, &E_GL_NV_shader_subgroup_partitioned);
8498             symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveAddNV",            1, &E_GL_NV_shader_subgroup_partitioned);
8499             symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveMulNV",            1, &E_GL_NV_shader_subgroup_partitioned);
8500             symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveMinNV",            1, &E_GL_NV_shader_subgroup_partitioned);
8501             symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveMaxNV",            1, &E_GL_NV_shader_subgroup_partitioned);
8502             symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveAndNV",            1, &E_GL_NV_shader_subgroup_partitioned);
8503             symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveOrNV",             1, &E_GL_NV_shader_subgroup_partitioned);
8504             symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveXorNV",            1, &E_GL_NV_shader_subgroup_partitioned);
8505             symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveAddNV",            1, &E_GL_NV_shader_subgroup_partitioned);
8506             symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveMulNV",            1, &E_GL_NV_shader_subgroup_partitioned);
8507             symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveMinNV",            1, &E_GL_NV_shader_subgroup_partitioned);
8508             symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveMaxNV",            1, &E_GL_NV_shader_subgroup_partitioned);
8509             symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveAndNV",            1, &E_GL_NV_shader_subgroup_partitioned);
8510             symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveOrNV",             1, &E_GL_NV_shader_subgroup_partitioned);
8511             symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveXorNV",            1, &E_GL_NV_shader_subgroup_partitioned);
8512 #endif
8513 
8514         }
8515 
8516         if (profile == EEsProfile) {
8517             symbolTable.setFunctionExtensions("shadow2DEXT",        1, &E_GL_EXT_shadow_samplers);
8518             symbolTable.setFunctionExtensions("shadow2DProjEXT",    1, &E_GL_EXT_shadow_samplers);
8519         }
8520 
8521         if (spvVersion.vulkan > 0) {
8522             symbolTable.setVariableExtensions("gl_ScopeDevice",             1, &E_GL_KHR_memory_scope_semantics);
8523             symbolTable.setVariableExtensions("gl_ScopeWorkgroup",          1, &E_GL_KHR_memory_scope_semantics);
8524             symbolTable.setVariableExtensions("gl_ScopeSubgroup",           1, &E_GL_KHR_memory_scope_semantics);
8525             symbolTable.setVariableExtensions("gl_ScopeInvocation",         1, &E_GL_KHR_memory_scope_semantics);
8526 
8527             symbolTable.setVariableExtensions("gl_SemanticsRelaxed",        1, &E_GL_KHR_memory_scope_semantics);
8528             symbolTable.setVariableExtensions("gl_SemanticsAcquire",        1, &E_GL_KHR_memory_scope_semantics);
8529             symbolTable.setVariableExtensions("gl_SemanticsRelease",        1, &E_GL_KHR_memory_scope_semantics);
8530             symbolTable.setVariableExtensions("gl_SemanticsAcquireRelease", 1, &E_GL_KHR_memory_scope_semantics);
8531             symbolTable.setVariableExtensions("gl_SemanticsMakeAvailable",  1, &E_GL_KHR_memory_scope_semantics);
8532             symbolTable.setVariableExtensions("gl_SemanticsMakeVisible",    1, &E_GL_KHR_memory_scope_semantics);
8533 
8534             symbolTable.setVariableExtensions("gl_StorageSemanticsNone",    1, &E_GL_KHR_memory_scope_semantics);
8535             symbolTable.setVariableExtensions("gl_StorageSemanticsBuffer",  1, &E_GL_KHR_memory_scope_semantics);
8536             symbolTable.setVariableExtensions("gl_StorageSemanticsShared",  1, &E_GL_KHR_memory_scope_semantics);
8537             symbolTable.setVariableExtensions("gl_StorageSemanticsImage",   1, &E_GL_KHR_memory_scope_semantics);
8538             symbolTable.setVariableExtensions("gl_StorageSemanticsOutput",  1, &E_GL_KHR_memory_scope_semantics);
8539         }
8540         break;
8541 
8542     case EShLangCompute:
8543         BuiltInVariable("gl_NumWorkGroups",         EbvNumWorkGroups,        symbolTable);
8544         BuiltInVariable("gl_WorkGroupSize",         EbvWorkGroupSize,        symbolTable);
8545         BuiltInVariable("gl_WorkGroupID",           EbvWorkGroupId,          symbolTable);
8546         BuiltInVariable("gl_LocalInvocationID",     EbvLocalInvocationId,    symbolTable);
8547         BuiltInVariable("gl_GlobalInvocationID",    EbvGlobalInvocationId,   symbolTable);
8548         BuiltInVariable("gl_LocalInvocationIndex",  EbvLocalInvocationIndex, symbolTable);
8549 
8550         if (profile != EEsProfile && version < 430) {
8551             symbolTable.setVariableExtensions("gl_NumWorkGroups",        1, &E_GL_ARB_compute_shader);
8552             symbolTable.setVariableExtensions("gl_WorkGroupSize",        1, &E_GL_ARB_compute_shader);
8553             symbolTable.setVariableExtensions("gl_WorkGroupID",          1, &E_GL_ARB_compute_shader);
8554             symbolTable.setVariableExtensions("gl_LocalInvocationID",    1, &E_GL_ARB_compute_shader);
8555             symbolTable.setVariableExtensions("gl_GlobalInvocationID",   1, &E_GL_ARB_compute_shader);
8556             symbolTable.setVariableExtensions("gl_LocalInvocationIndex", 1, &E_GL_ARB_compute_shader);
8557 
8558             symbolTable.setVariableExtensions("gl_MaxComputeWorkGroupCount",       1, &E_GL_ARB_compute_shader);
8559             symbolTable.setVariableExtensions("gl_MaxComputeWorkGroupSize",        1, &E_GL_ARB_compute_shader);
8560             symbolTable.setVariableExtensions("gl_MaxComputeUniformComponents",    1, &E_GL_ARB_compute_shader);
8561             symbolTable.setVariableExtensions("gl_MaxComputeTextureImageUnits",    1, &E_GL_ARB_compute_shader);
8562             symbolTable.setVariableExtensions("gl_MaxComputeImageUniforms",        1, &E_GL_ARB_compute_shader);
8563             symbolTable.setVariableExtensions("gl_MaxComputeAtomicCounters",       1, &E_GL_ARB_compute_shader);
8564             symbolTable.setVariableExtensions("gl_MaxComputeAtomicCounterBuffers", 1, &E_GL_ARB_compute_shader);
8565 
8566             symbolTable.setFunctionExtensions("barrier",                    1, &E_GL_ARB_compute_shader);
8567             symbolTable.setFunctionExtensions("memoryBarrierAtomicCounter", 1, &E_GL_ARB_compute_shader);
8568             symbolTable.setFunctionExtensions("memoryBarrierBuffer",        1, &E_GL_ARB_compute_shader);
8569             symbolTable.setFunctionExtensions("memoryBarrierImage",         1, &E_GL_ARB_compute_shader);
8570             symbolTable.setFunctionExtensions("memoryBarrierShared",        1, &E_GL_ARB_compute_shader);
8571             symbolTable.setFunctionExtensions("groupMemoryBarrier",         1, &E_GL_ARB_compute_shader);
8572         }
8573 
8574         symbolTable.setFunctionExtensions("controlBarrier",                 1, &E_GL_KHR_memory_scope_semantics);
8575 
8576         // GL_ARB_shader_ballot
8577         if (profile != EEsProfile) {
8578             symbolTable.setVariableExtensions("gl_SubGroupSizeARB",       1, &E_GL_ARB_shader_ballot);
8579             symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
8580             symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB",     1, &E_GL_ARB_shader_ballot);
8581             symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB",     1, &E_GL_ARB_shader_ballot);
8582             symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB",     1, &E_GL_ARB_shader_ballot);
8583             symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB",     1, &E_GL_ARB_shader_ballot);
8584             symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB",     1, &E_GL_ARB_shader_ballot);
8585 
8586             BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
8587             BuiltInVariable("gl_SubGroupEqMaskARB",     EbvSubGroupEqMask,     symbolTable);
8588             BuiltInVariable("gl_SubGroupGeMaskARB",     EbvSubGroupGeMask,     symbolTable);
8589             BuiltInVariable("gl_SubGroupGtMaskARB",     EbvSubGroupGtMask,     symbolTable);
8590             BuiltInVariable("gl_SubGroupLeMaskARB",     EbvSubGroupLeMask,     symbolTable);
8591             BuiltInVariable("gl_SubGroupLtMaskARB",     EbvSubGroupLtMask,     symbolTable);
8592 
8593             if (spvVersion.vulkan > 0)
8594                 // Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
8595                 SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
8596             else
8597                 BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
8598         }
8599 
8600         // GL_KHR_shader_subgroup
8601         if (spvVersion.vulkan > 0) {
8602             symbolTable.setVariableExtensions("gl_SubgroupSize",         1, &E_GL_KHR_shader_subgroup_basic);
8603             symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
8604             symbolTable.setVariableExtensions("gl_SubgroupEqMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8605             symbolTable.setVariableExtensions("gl_SubgroupGeMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8606             symbolTable.setVariableExtensions("gl_SubgroupGtMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8607             symbolTable.setVariableExtensions("gl_SubgroupLeMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8608             symbolTable.setVariableExtensions("gl_SubgroupLtMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8609 
8610             BuiltInVariable("gl_SubgroupSize",         EbvSubgroupSize2,       symbolTable);
8611             BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
8612             BuiltInVariable("gl_SubgroupEqMask",       EbvSubgroupEqMask2,     symbolTable);
8613             BuiltInVariable("gl_SubgroupGeMask",       EbvSubgroupGeMask2,     symbolTable);
8614             BuiltInVariable("gl_SubgroupGtMask",       EbvSubgroupGtMask2,     symbolTable);
8615             BuiltInVariable("gl_SubgroupLeMask",       EbvSubgroupLeMask2,     symbolTable);
8616             BuiltInVariable("gl_SubgroupLtMask",       EbvSubgroupLtMask2,     symbolTable);
8617         }
8618 
8619         if ((profile != EEsProfile && version >= 140) ||
8620             (profile == EEsProfile && version >= 310)) {
8621             symbolTable.setVariableExtensions("gl_DeviceIndex",  1, &E_GL_EXT_device_group);
8622             BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
8623             symbolTable.setVariableExtensions("gl_ViewIndex", 1, &E_GL_EXT_multiview);
8624             BuiltInVariable("gl_ViewIndex", EbvViewIndex, symbolTable);
8625         }
8626 
8627         // GL_KHR_shader_subgroup
8628         if (spvVersion.vulkan > 0) {
8629             symbolTable.setVariableExtensions("gl_NumSubgroups", 1, &E_GL_KHR_shader_subgroup_basic);
8630             symbolTable.setVariableExtensions("gl_SubgroupID",   1, &E_GL_KHR_shader_subgroup_basic);
8631 
8632             BuiltInVariable("gl_NumSubgroups", EbvNumSubgroups, symbolTable);
8633             BuiltInVariable("gl_SubgroupID",   EbvSubgroupID,   symbolTable);
8634 
8635             symbolTable.setFunctionExtensions("subgroupMemoryBarrierShared", 1, &E_GL_KHR_shader_subgroup_basic);
8636         }
8637         break;
8638 #ifdef NV_EXTENSIONS
8639     case EShLangRayGenNV:
8640     case EShLangIntersectNV:
8641     case EShLangAnyHitNV:
8642     case EShLangClosestHitNV:
8643     case EShLangMissNV:
8644     case EShLangCallableNV:
8645         if (profile != EEsProfile && version >= 460) {
8646             symbolTable.setVariableExtensions("gl_LaunchIDNV", 1, &E_GL_NV_ray_tracing);
8647             symbolTable.setVariableExtensions("gl_LaunchSizeNV", 1, &E_GL_NV_ray_tracing);
8648             symbolTable.setVariableExtensions("gl_PrimitiveID", 1, &E_GL_NV_ray_tracing);
8649             symbolTable.setVariableExtensions("gl_InstanceID", 1, &E_GL_NV_ray_tracing);
8650             symbolTable.setVariableExtensions("gl_InstanceCustomIndexNV", 1, &E_GL_NV_ray_tracing);
8651             symbolTable.setVariableExtensions("gl_WorldRayOriginNV", 1, &E_GL_NV_ray_tracing);
8652             symbolTable.setVariableExtensions("gl_WorldRayDirectionNV", 1, &E_GL_NV_ray_tracing);
8653             symbolTable.setVariableExtensions("gl_ObjectRayOriginNV", 1, &E_GL_NV_ray_tracing);
8654             symbolTable.setVariableExtensions("gl_ObjectRayDirectionNV", 1, &E_GL_NV_ray_tracing);
8655             symbolTable.setVariableExtensions("gl_RayTminNV", 1, &E_GL_NV_ray_tracing);
8656             symbolTable.setVariableExtensions("gl_RayTmaxNV", 1, &E_GL_NV_ray_tracing);
8657             symbolTable.setVariableExtensions("gl_HitTNV", 1, &E_GL_NV_ray_tracing);
8658             symbolTable.setVariableExtensions("gl_HitKindNV", 1, &E_GL_NV_ray_tracing);
8659             symbolTable.setVariableExtensions("gl_ObjectToWorldNV", 1, &E_GL_NV_ray_tracing);
8660             symbolTable.setVariableExtensions("gl_WorldToObjectNV", 1, &E_GL_NV_ray_tracing);
8661             symbolTable.setVariableExtensions("gl_IncomingRayFlagsNV", 1, &E_GL_NV_ray_tracing);
8662 
8663             symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
8664 
8665             BuiltInVariable("gl_LaunchIDNV",            EbvLaunchIdNV,           symbolTable);
8666             BuiltInVariable("gl_LaunchSizeNV",          EbvLaunchSizeNV,         symbolTable);
8667             BuiltInVariable("gl_PrimitiveID",           EbvPrimitiveId,          symbolTable);
8668             BuiltInVariable("gl_InstanceID",            EbvInstanceId,           symbolTable);
8669             BuiltInVariable("gl_InstanceCustomIndexNV", EbvInstanceCustomIndexNV,symbolTable);
8670             BuiltInVariable("gl_WorldRayOriginNV",      EbvWorldRayOriginNV,     symbolTable);
8671             BuiltInVariable("gl_WorldRayDirectionNV",   EbvWorldRayDirectionNV,  symbolTable);
8672             BuiltInVariable("gl_ObjectRayOriginNV",     EbvObjectRayOriginNV,    symbolTable);
8673             BuiltInVariable("gl_ObjectRayDirectionNV",  EbvObjectRayDirectionNV, symbolTable);
8674             BuiltInVariable("gl_RayTminNV",             EbvRayTminNV,            symbolTable);
8675             BuiltInVariable("gl_RayTmaxNV",             EbvRayTmaxNV,            symbolTable);
8676             BuiltInVariable("gl_HitTNV",                EbvHitTNV,               symbolTable);
8677             BuiltInVariable("gl_HitKindNV",             EbvHitKindNV,            symbolTable);
8678             BuiltInVariable("gl_ObjectToWorldNV",       EbvObjectToWorldNV,      symbolTable);
8679             BuiltInVariable("gl_WorldToObjectNV",       EbvWorldToObjectNV,      symbolTable);
8680             BuiltInVariable("gl_IncomingRayFlagsNV",    EbvIncomingRayFlagsNV,   symbolTable);
8681             BuiltInVariable("gl_DeviceIndex",           EbvDeviceIndex,          symbolTable);
8682         }
8683         break;
8684     case EShLangMeshNV:
8685         if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
8686             // Per-vertex builtins
8687             BuiltInVariable("gl_MeshVerticesNV", "gl_Position",     EbvPosition,     symbolTable);
8688             BuiltInVariable("gl_MeshVerticesNV", "gl_PointSize",    EbvPointSize,    symbolTable);
8689             BuiltInVariable("gl_MeshVerticesNV", "gl_ClipDistance", EbvClipDistance, symbolTable);
8690             BuiltInVariable("gl_MeshVerticesNV", "gl_CullDistance", EbvCullDistance, symbolTable);
8691             // Per-view builtins
8692             BuiltInVariable("gl_MeshVerticesNV", "gl_PositionPerViewNV",     EbvPositionPerViewNV,     symbolTable);
8693             BuiltInVariable("gl_MeshVerticesNV", "gl_ClipDistancePerViewNV", EbvClipDistancePerViewNV, symbolTable);
8694             BuiltInVariable("gl_MeshVerticesNV", "gl_CullDistancePerViewNV", EbvCullDistancePerViewNV, symbolTable);
8695 
8696             // Per-primitive builtins
8697             BuiltInVariable("gl_MeshPrimitivesNV", "gl_PrimitiveID",   EbvPrimitiveId,    symbolTable);
8698             BuiltInVariable("gl_MeshPrimitivesNV", "gl_Layer",         EbvLayer,          symbolTable);
8699             BuiltInVariable("gl_MeshPrimitivesNV", "gl_ViewportIndex", EbvViewportIndex,  symbolTable);
8700             BuiltInVariable("gl_MeshPrimitivesNV", "gl_ViewportMask",  EbvViewportMaskNV, symbolTable);
8701             // Per-view builtins
8702             BuiltInVariable("gl_MeshPrimitivesNV", "gl_LayerPerViewNV",        EbvLayerPerViewNV,        symbolTable);
8703             BuiltInVariable("gl_MeshPrimitivesNV", "gl_ViewportMaskPerViewNV", EbvViewportMaskPerViewNV, symbolTable);
8704 
8705             symbolTable.setVariableExtensions("gl_PrimitiveCountNV",     1, &E_GL_NV_mesh_shader);
8706             symbolTable.setVariableExtensions("gl_PrimitiveIndicesNV",   1, &E_GL_NV_mesh_shader);
8707             symbolTable.setVariableExtensions("gl_MeshViewCountNV",      1, &E_GL_NV_mesh_shader);
8708             symbolTable.setVariableExtensions("gl_MeshViewIndicesNV",    1, &E_GL_NV_mesh_shader);
8709             symbolTable.setVariableExtensions("gl_WorkGroupSize",        1, &E_GL_NV_mesh_shader);
8710             symbolTable.setVariableExtensions("gl_WorkGroupID",          1, &E_GL_NV_mesh_shader);
8711             symbolTable.setVariableExtensions("gl_LocalInvocationID",    1, &E_GL_NV_mesh_shader);
8712             symbolTable.setVariableExtensions("gl_GlobalInvocationID",   1, &E_GL_NV_mesh_shader);
8713             symbolTable.setVariableExtensions("gl_LocalInvocationIndex", 1, &E_GL_NV_mesh_shader);
8714 
8715             BuiltInVariable("gl_PrimitiveCountNV",     EbvPrimitiveCountNV,     symbolTable);
8716             BuiltInVariable("gl_PrimitiveIndicesNV",   EbvPrimitiveIndicesNV,   symbolTable);
8717             BuiltInVariable("gl_MeshViewCountNV",      EbvMeshViewCountNV,      symbolTable);
8718             BuiltInVariable("gl_MeshViewIndicesNV",    EbvMeshViewIndicesNV,    symbolTable);
8719             BuiltInVariable("gl_WorkGroupSize",        EbvWorkGroupSize,        symbolTable);
8720             BuiltInVariable("gl_WorkGroupID",          EbvWorkGroupId,          symbolTable);
8721             BuiltInVariable("gl_LocalInvocationID",    EbvLocalInvocationId,    symbolTable);
8722             BuiltInVariable("gl_GlobalInvocationID",   EbvGlobalInvocationId,   symbolTable);
8723             BuiltInVariable("gl_LocalInvocationIndex", EbvLocalInvocationIndex, symbolTable);
8724 
8725             symbolTable.setVariableExtensions("gl_MaxMeshOutputVerticesNV",   1, &E_GL_NV_mesh_shader);
8726             symbolTable.setVariableExtensions("gl_MaxMeshOutputPrimitivesNV", 1, &E_GL_NV_mesh_shader);
8727             symbolTable.setVariableExtensions("gl_MaxMeshWorkGroupSizeNV",    1, &E_GL_NV_mesh_shader);
8728             symbolTable.setVariableExtensions("gl_MaxMeshViewCountNV",        1, &E_GL_NV_mesh_shader);
8729 
8730             symbolTable.setFunctionExtensions("barrier",                      1, &E_GL_NV_mesh_shader);
8731             symbolTable.setFunctionExtensions("memoryBarrierShared",          1, &E_GL_NV_mesh_shader);
8732             symbolTable.setFunctionExtensions("groupMemoryBarrier",           1, &E_GL_NV_mesh_shader);
8733         }
8734 
8735         if (profile != EEsProfile && version >= 450) {
8736             // GL_EXT_device_group
8737             symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
8738             BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
8739 
8740             // GL_ARB_shader_draw_parameters
8741             symbolTable.setVariableExtensions("gl_DrawIDARB", 1, &E_GL_ARB_shader_draw_parameters);
8742             BuiltInVariable("gl_DrawIDARB", EbvDrawId, symbolTable);
8743             if (version >= 460) {
8744                 BuiltInVariable("gl_DrawID", EbvDrawId, symbolTable);
8745             }
8746 
8747             // GL_ARB_shader_ballot
8748             symbolTable.setVariableExtensions("gl_SubGroupSizeARB",       1, &E_GL_ARB_shader_ballot);
8749             symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
8750             symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB",     1, &E_GL_ARB_shader_ballot);
8751             symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB",     1, &E_GL_ARB_shader_ballot);
8752             symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB",     1, &E_GL_ARB_shader_ballot);
8753             symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB",     1, &E_GL_ARB_shader_ballot);
8754             symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB",     1, &E_GL_ARB_shader_ballot);
8755 
8756             BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
8757             BuiltInVariable("gl_SubGroupEqMaskARB",     EbvSubGroupEqMask,     symbolTable);
8758             BuiltInVariable("gl_SubGroupGeMaskARB",     EbvSubGroupGeMask,     symbolTable);
8759             BuiltInVariable("gl_SubGroupGtMaskARB",     EbvSubGroupGtMask,     symbolTable);
8760             BuiltInVariable("gl_SubGroupLeMaskARB",     EbvSubGroupLeMask,     symbolTable);
8761             BuiltInVariable("gl_SubGroupLtMaskARB",     EbvSubGroupLtMask,     symbolTable);
8762 
8763             if (spvVersion.vulkan > 0)
8764                 // Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
8765                 SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
8766             else
8767                 BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
8768         }
8769 
8770         // GL_KHR_shader_subgroup
8771         if (spvVersion.vulkan > 0) {
8772             symbolTable.setVariableExtensions("gl_NumSubgroups",         1, &E_GL_KHR_shader_subgroup_basic);
8773             symbolTable.setVariableExtensions("gl_SubgroupID",           1, &E_GL_KHR_shader_subgroup_basic);
8774             symbolTable.setVariableExtensions("gl_SubgroupSize",         1, &E_GL_KHR_shader_subgroup_basic);
8775             symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
8776             symbolTable.setVariableExtensions("gl_SubgroupEqMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8777             symbolTable.setVariableExtensions("gl_SubgroupGeMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8778             symbolTable.setVariableExtensions("gl_SubgroupGtMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8779             symbolTable.setVariableExtensions("gl_SubgroupLeMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8780             symbolTable.setVariableExtensions("gl_SubgroupLtMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8781 
8782             BuiltInVariable("gl_NumSubgroups",         EbvNumSubgroups,        symbolTable);
8783             BuiltInVariable("gl_SubgroupID",           EbvSubgroupID,          symbolTable);
8784             BuiltInVariable("gl_SubgroupSize",         EbvSubgroupSize2,       symbolTable);
8785             BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
8786             BuiltInVariable("gl_SubgroupEqMask",       EbvSubgroupEqMask2,     symbolTable);
8787             BuiltInVariable("gl_SubgroupGeMask",       EbvSubgroupGeMask2,     symbolTable);
8788             BuiltInVariable("gl_SubgroupGtMask",       EbvSubgroupGtMask2,     symbolTable);
8789             BuiltInVariable("gl_SubgroupLeMask",       EbvSubgroupLeMask2,     symbolTable);
8790             BuiltInVariable("gl_SubgroupLtMask",       EbvSubgroupLtMask2,     symbolTable);
8791 
8792             symbolTable.setFunctionExtensions("subgroupMemoryBarrierShared", 1, &E_GL_KHR_shader_subgroup_basic);
8793         }
8794         break;
8795 
8796     case EShLangTaskNV:
8797         if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
8798             symbolTable.setVariableExtensions("gl_TaskCountNV",          1, &E_GL_NV_mesh_shader);
8799             symbolTable.setVariableExtensions("gl_WorkGroupSize",        1, &E_GL_NV_mesh_shader);
8800             symbolTable.setVariableExtensions("gl_WorkGroupID",          1, &E_GL_NV_mesh_shader);
8801             symbolTable.setVariableExtensions("gl_LocalInvocationID",    1, &E_GL_NV_mesh_shader);
8802             symbolTable.setVariableExtensions("gl_GlobalInvocationID",   1, &E_GL_NV_mesh_shader);
8803             symbolTable.setVariableExtensions("gl_LocalInvocationIndex", 1, &E_GL_NV_mesh_shader);
8804 
8805             BuiltInVariable("gl_TaskCountNV",          EbvTaskCountNV,          symbolTable);
8806             BuiltInVariable("gl_WorkGroupSize",        EbvWorkGroupSize,        symbolTable);
8807             BuiltInVariable("gl_WorkGroupID",          EbvWorkGroupId,          symbolTable);
8808             BuiltInVariable("gl_LocalInvocationID",    EbvLocalInvocationId,    symbolTable);
8809             BuiltInVariable("gl_GlobalInvocationID",   EbvGlobalInvocationId,   symbolTable);
8810             BuiltInVariable("gl_LocalInvocationIndex", EbvLocalInvocationIndex, symbolTable);
8811 
8812             symbolTable.setVariableExtensions("gl_MaxTaskWorkGroupSizeNV", 1, &E_GL_NV_mesh_shader);
8813 
8814             symbolTable.setFunctionExtensions("barrier",                   1, &E_GL_NV_mesh_shader);
8815             symbolTable.setFunctionExtensions("memoryBarrierShared",       1, &E_GL_NV_mesh_shader);
8816             symbolTable.setFunctionExtensions("groupMemoryBarrier",        1, &E_GL_NV_mesh_shader);
8817         }
8818 
8819         if (profile != EEsProfile && version >= 450) {
8820             // GL_EXT_device_group
8821             symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
8822             BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
8823 
8824             // GL_ARB_shader_draw_parameters
8825             symbolTable.setVariableExtensions("gl_DrawIDARB", 1, &E_GL_ARB_shader_draw_parameters);
8826             BuiltInVariable("gl_DrawIDARB", EbvDrawId, symbolTable);
8827             if (version >= 460) {
8828                 BuiltInVariable("gl_DrawID", EbvDrawId, symbolTable);
8829             }
8830 
8831             // GL_ARB_shader_ballot
8832             symbolTable.setVariableExtensions("gl_SubGroupSizeARB",       1, &E_GL_ARB_shader_ballot);
8833             symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
8834             symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB",     1, &E_GL_ARB_shader_ballot);
8835             symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB",     1, &E_GL_ARB_shader_ballot);
8836             symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB",     1, &E_GL_ARB_shader_ballot);
8837             symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB",     1, &E_GL_ARB_shader_ballot);
8838             symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB",     1, &E_GL_ARB_shader_ballot);
8839 
8840             BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
8841             BuiltInVariable("gl_SubGroupEqMaskARB",     EbvSubGroupEqMask,     symbolTable);
8842             BuiltInVariable("gl_SubGroupGeMaskARB",     EbvSubGroupGeMask,     symbolTable);
8843             BuiltInVariable("gl_SubGroupGtMaskARB",     EbvSubGroupGtMask,     symbolTable);
8844             BuiltInVariable("gl_SubGroupLeMaskARB",     EbvSubGroupLeMask,     symbolTable);
8845             BuiltInVariable("gl_SubGroupLtMaskARB",     EbvSubGroupLtMask,     symbolTable);
8846 
8847             if (spvVersion.vulkan > 0)
8848                 // Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
8849                 SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
8850             else
8851                 BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
8852         }
8853 
8854         // GL_KHR_shader_subgroup
8855         if (spvVersion.vulkan > 0) {
8856             symbolTable.setVariableExtensions("gl_NumSubgroups",         1, &E_GL_KHR_shader_subgroup_basic);
8857             symbolTable.setVariableExtensions("gl_SubgroupID",           1, &E_GL_KHR_shader_subgroup_basic);
8858             symbolTable.setVariableExtensions("gl_SubgroupSize",         1, &E_GL_KHR_shader_subgroup_basic);
8859             symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
8860             symbolTable.setVariableExtensions("gl_SubgroupEqMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8861             symbolTable.setVariableExtensions("gl_SubgroupGeMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8862             symbolTable.setVariableExtensions("gl_SubgroupGtMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8863             symbolTable.setVariableExtensions("gl_SubgroupLeMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8864             symbolTable.setVariableExtensions("gl_SubgroupLtMask",       1, &E_GL_KHR_shader_subgroup_ballot);
8865 
8866             BuiltInVariable("gl_NumSubgroups",         EbvNumSubgroups,        symbolTable);
8867             BuiltInVariable("gl_SubgroupID",           EbvSubgroupID,          symbolTable);
8868             BuiltInVariable("gl_SubgroupSize",         EbvSubgroupSize2,       symbolTable);
8869             BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
8870             BuiltInVariable("gl_SubgroupEqMask",       EbvSubgroupEqMask2,     symbolTable);
8871             BuiltInVariable("gl_SubgroupGeMask",       EbvSubgroupGeMask2,     symbolTable);
8872             BuiltInVariable("gl_SubgroupGtMask",       EbvSubgroupGtMask2,     symbolTable);
8873             BuiltInVariable("gl_SubgroupLeMask",       EbvSubgroupLeMask2,     symbolTable);
8874             BuiltInVariable("gl_SubgroupLtMask",       EbvSubgroupLtMask2,     symbolTable);
8875 
8876             symbolTable.setFunctionExtensions("subgroupMemoryBarrierShared", 1, &E_GL_KHR_shader_subgroup_basic);
8877         }
8878         break;
8879 #endif
8880 
8881     default:
8882         assert(false && "Language not supported");
8883         break;
8884     }
8885 
8886     //
8887     // Next, identify which built-ins have a mapping to an operator.
8888     // If PureOperatorBuiltins is false, those that are not identified as such are
8889     // expected to be resolved through a library of functions, versus as
8890     // operations.
8891     //
8892     symbolTable.relateToOperator("not",              EOpVectorLogicalNot);
8893 
8894     symbolTable.relateToOperator("matrixCompMult",   EOpMul);
8895     // 120 and 150 are correct for both ES and desktop
8896     if (version >= 120) {
8897         symbolTable.relateToOperator("outerProduct", EOpOuterProduct);
8898         symbolTable.relateToOperator("transpose", EOpTranspose);
8899         if (version >= 150) {
8900             symbolTable.relateToOperator("determinant", EOpDeterminant);
8901             symbolTable.relateToOperator("inverse", EOpMatrixInverse);
8902         }
8903     }
8904 
8905     symbolTable.relateToOperator("mod",              EOpMod);
8906     symbolTable.relateToOperator("modf",             EOpModf);
8907 
8908     symbolTable.relateToOperator("equal",            EOpVectorEqual);
8909     symbolTable.relateToOperator("notEqual",         EOpVectorNotEqual);
8910     symbolTable.relateToOperator("lessThan",         EOpLessThan);
8911     symbolTable.relateToOperator("greaterThan",      EOpGreaterThan);
8912     symbolTable.relateToOperator("lessThanEqual",    EOpLessThanEqual);
8913     symbolTable.relateToOperator("greaterThanEqual", EOpGreaterThanEqual);
8914 
8915     symbolTable.relateToOperator("radians",      EOpRadians);
8916     symbolTable.relateToOperator("degrees",      EOpDegrees);
8917     symbolTable.relateToOperator("sin",          EOpSin);
8918     symbolTable.relateToOperator("cos",          EOpCos);
8919     symbolTable.relateToOperator("tan",          EOpTan);
8920     symbolTable.relateToOperator("asin",         EOpAsin);
8921     symbolTable.relateToOperator("acos",         EOpAcos);
8922     symbolTable.relateToOperator("atan",         EOpAtan);
8923     symbolTable.relateToOperator("sinh",         EOpSinh);
8924     symbolTable.relateToOperator("cosh",         EOpCosh);
8925     symbolTable.relateToOperator("tanh",         EOpTanh);
8926     symbolTable.relateToOperator("asinh",        EOpAsinh);
8927     symbolTable.relateToOperator("acosh",        EOpAcosh);
8928     symbolTable.relateToOperator("atanh",        EOpAtanh);
8929 
8930     symbolTable.relateToOperator("pow",          EOpPow);
8931     symbolTable.relateToOperator("exp2",         EOpExp2);
8932     symbolTable.relateToOperator("log",          EOpLog);
8933     symbolTable.relateToOperator("exp",          EOpExp);
8934     symbolTable.relateToOperator("log2",         EOpLog2);
8935     symbolTable.relateToOperator("sqrt",         EOpSqrt);
8936     symbolTable.relateToOperator("inversesqrt",  EOpInverseSqrt);
8937 
8938     symbolTable.relateToOperator("abs",          EOpAbs);
8939     symbolTable.relateToOperator("sign",         EOpSign);
8940     symbolTable.relateToOperator("floor",        EOpFloor);
8941     symbolTable.relateToOperator("trunc",        EOpTrunc);
8942     symbolTable.relateToOperator("round",        EOpRound);
8943     symbolTable.relateToOperator("roundEven",    EOpRoundEven);
8944     symbolTable.relateToOperator("ceil",         EOpCeil);
8945     symbolTable.relateToOperator("fract",        EOpFract);
8946     symbolTable.relateToOperator("min",          EOpMin);
8947     symbolTable.relateToOperator("max",          EOpMax);
8948     symbolTable.relateToOperator("clamp",        EOpClamp);
8949     symbolTable.relateToOperator("mix",          EOpMix);
8950     symbolTable.relateToOperator("step",         EOpStep);
8951     symbolTable.relateToOperator("smoothstep",   EOpSmoothStep);
8952 
8953     symbolTable.relateToOperator("isnan",  EOpIsNan);
8954     symbolTable.relateToOperator("isinf",  EOpIsInf);
8955 
8956     symbolTable.relateToOperator("floatBitsToInt",  EOpFloatBitsToInt);
8957     symbolTable.relateToOperator("floatBitsToUint", EOpFloatBitsToUint);
8958     symbolTable.relateToOperator("intBitsToFloat",  EOpIntBitsToFloat);
8959     symbolTable.relateToOperator("uintBitsToFloat", EOpUintBitsToFloat);
8960     symbolTable.relateToOperator("doubleBitsToInt64",  EOpDoubleBitsToInt64);
8961     symbolTable.relateToOperator("doubleBitsToUint64", EOpDoubleBitsToUint64);
8962     symbolTable.relateToOperator("int64BitsToDouble",  EOpInt64BitsToDouble);
8963     symbolTable.relateToOperator("uint64BitsToDouble", EOpUint64BitsToDouble);
8964     symbolTable.relateToOperator("halfBitsToInt16",  EOpFloat16BitsToInt16);
8965     symbolTable.relateToOperator("halfBitsToUint16", EOpFloat16BitsToUint16);
8966     symbolTable.relateToOperator("float16BitsToInt16",  EOpFloat16BitsToInt16);
8967     symbolTable.relateToOperator("float16BitsToUint16", EOpFloat16BitsToUint16);
8968     symbolTable.relateToOperator("int16BitsToFloat16",  EOpInt16BitsToFloat16);
8969     symbolTable.relateToOperator("uint16BitsToFloat16", EOpUint16BitsToFloat16);
8970 
8971     symbolTable.relateToOperator("int16BitsToHalf",  EOpInt16BitsToFloat16);
8972     symbolTable.relateToOperator("uint16BitsToHalf", EOpUint16BitsToFloat16);
8973 
8974     symbolTable.relateToOperator("packSnorm2x16",   EOpPackSnorm2x16);
8975     symbolTable.relateToOperator("unpackSnorm2x16", EOpUnpackSnorm2x16);
8976     symbolTable.relateToOperator("packUnorm2x16",   EOpPackUnorm2x16);
8977     symbolTable.relateToOperator("unpackUnorm2x16", EOpUnpackUnorm2x16);
8978 
8979     symbolTable.relateToOperator("packSnorm4x8",    EOpPackSnorm4x8);
8980     symbolTable.relateToOperator("unpackSnorm4x8",  EOpUnpackSnorm4x8);
8981     symbolTable.relateToOperator("packUnorm4x8",    EOpPackUnorm4x8);
8982     symbolTable.relateToOperator("unpackUnorm4x8",  EOpUnpackUnorm4x8);
8983 
8984     symbolTable.relateToOperator("packDouble2x32",    EOpPackDouble2x32);
8985     symbolTable.relateToOperator("unpackDouble2x32",  EOpUnpackDouble2x32);
8986 
8987     symbolTable.relateToOperator("packHalf2x16",    EOpPackHalf2x16);
8988     symbolTable.relateToOperator("unpackHalf2x16",  EOpUnpackHalf2x16);
8989 
8990     symbolTable.relateToOperator("packInt2x32",     EOpPackInt2x32);
8991     symbolTable.relateToOperator("unpackInt2x32",   EOpUnpackInt2x32);
8992     symbolTable.relateToOperator("packUint2x32",    EOpPackUint2x32);
8993     symbolTable.relateToOperator("unpackUint2x32",  EOpUnpackUint2x32);
8994 
8995     symbolTable.relateToOperator("packInt2x16",     EOpPackInt2x16);
8996     symbolTable.relateToOperator("unpackInt2x16",   EOpUnpackInt2x16);
8997     symbolTable.relateToOperator("packUint2x16",    EOpPackUint2x16);
8998     symbolTable.relateToOperator("unpackUint2x16",  EOpUnpackUint2x16);
8999 
9000     symbolTable.relateToOperator("packInt4x16",     EOpPackInt4x16);
9001     symbolTable.relateToOperator("unpackInt4x16",   EOpUnpackInt4x16);
9002     symbolTable.relateToOperator("packUint4x16",    EOpPackUint4x16);
9003     symbolTable.relateToOperator("unpackUint4x16",  EOpUnpackUint4x16);
9004     symbolTable.relateToOperator("packFloat2x16",   EOpPackFloat2x16);
9005     symbolTable.relateToOperator("unpackFloat2x16", EOpUnpackFloat2x16);
9006 
9007     symbolTable.relateToOperator("pack16",          EOpPack16);
9008     symbolTable.relateToOperator("pack32",          EOpPack32);
9009     symbolTable.relateToOperator("pack64",          EOpPack64);
9010 
9011     symbolTable.relateToOperator("unpack32",        EOpUnpack32);
9012     symbolTable.relateToOperator("unpack16",        EOpUnpack16);
9013     symbolTable.relateToOperator("unpack8",         EOpUnpack8);
9014 
9015     symbolTable.relateToOperator("length",       EOpLength);
9016     symbolTable.relateToOperator("distance",     EOpDistance);
9017     symbolTable.relateToOperator("dot",          EOpDot);
9018     symbolTable.relateToOperator("cross",        EOpCross);
9019     symbolTable.relateToOperator("normalize",    EOpNormalize);
9020     symbolTable.relateToOperator("faceforward",  EOpFaceForward);
9021     symbolTable.relateToOperator("reflect",      EOpReflect);
9022     symbolTable.relateToOperator("refract",      EOpRefract);
9023 
9024     symbolTable.relateToOperator("any",          EOpAny);
9025     symbolTable.relateToOperator("all",          EOpAll);
9026 
9027     symbolTable.relateToOperator("barrier",                    EOpBarrier);
9028     symbolTable.relateToOperator("controlBarrier",             EOpBarrier);
9029     symbolTable.relateToOperator("memoryBarrier",              EOpMemoryBarrier);
9030     symbolTable.relateToOperator("memoryBarrierAtomicCounter", EOpMemoryBarrierAtomicCounter);
9031     symbolTable.relateToOperator("memoryBarrierBuffer",        EOpMemoryBarrierBuffer);
9032     symbolTable.relateToOperator("memoryBarrierImage",         EOpMemoryBarrierImage);
9033 
9034     symbolTable.relateToOperator("atomicAdd",      EOpAtomicAdd);
9035     symbolTable.relateToOperator("atomicMin",      EOpAtomicMin);
9036     symbolTable.relateToOperator("atomicMax",      EOpAtomicMax);
9037     symbolTable.relateToOperator("atomicAnd",      EOpAtomicAnd);
9038     symbolTable.relateToOperator("atomicOr",       EOpAtomicOr);
9039     symbolTable.relateToOperator("atomicXor",      EOpAtomicXor);
9040     symbolTable.relateToOperator("atomicExchange", EOpAtomicExchange);
9041     symbolTable.relateToOperator("atomicCompSwap", EOpAtomicCompSwap);
9042     symbolTable.relateToOperator("atomicLoad",     EOpAtomicLoad);
9043     symbolTable.relateToOperator("atomicStore",    EOpAtomicStore);
9044 
9045     symbolTable.relateToOperator("atomicCounterIncrement", EOpAtomicCounterIncrement);
9046     symbolTable.relateToOperator("atomicCounterDecrement", EOpAtomicCounterDecrement);
9047     symbolTable.relateToOperator("atomicCounter",          EOpAtomicCounter);
9048 
9049     if (profile != EEsProfile && version >= 460) {
9050         symbolTable.relateToOperator("atomicCounterAdd",      EOpAtomicCounterAdd);
9051         symbolTable.relateToOperator("atomicCounterSubtract", EOpAtomicCounterSubtract);
9052         symbolTable.relateToOperator("atomicCounterMin",      EOpAtomicCounterMin);
9053         symbolTable.relateToOperator("atomicCounterMax",      EOpAtomicCounterMax);
9054         symbolTable.relateToOperator("atomicCounterAnd",      EOpAtomicCounterAnd);
9055         symbolTable.relateToOperator("atomicCounterOr",       EOpAtomicCounterOr);
9056         symbolTable.relateToOperator("atomicCounterXor",      EOpAtomicCounterXor);
9057         symbolTable.relateToOperator("atomicCounterExchange", EOpAtomicCounterExchange);
9058         symbolTable.relateToOperator("atomicCounterCompSwap", EOpAtomicCounterCompSwap);
9059     }
9060 
9061     symbolTable.relateToOperator("fma",               EOpFma);
9062     symbolTable.relateToOperator("frexp",             EOpFrexp);
9063     symbolTable.relateToOperator("ldexp",             EOpLdexp);
9064     symbolTable.relateToOperator("uaddCarry",         EOpAddCarry);
9065     symbolTable.relateToOperator("usubBorrow",        EOpSubBorrow);
9066     symbolTable.relateToOperator("umulExtended",      EOpUMulExtended);
9067     symbolTable.relateToOperator("imulExtended",      EOpIMulExtended);
9068     symbolTable.relateToOperator("bitfieldExtract",   EOpBitfieldExtract);
9069     symbolTable.relateToOperator("bitfieldInsert",    EOpBitfieldInsert);
9070     symbolTable.relateToOperator("bitfieldReverse",   EOpBitFieldReverse);
9071     symbolTable.relateToOperator("bitCount",          EOpBitCount);
9072     symbolTable.relateToOperator("findLSB",           EOpFindLSB);
9073     symbolTable.relateToOperator("findMSB",           EOpFindMSB);
9074 
9075     if (PureOperatorBuiltins) {
9076         symbolTable.relateToOperator("imageSize",               EOpImageQuerySize);
9077         symbolTable.relateToOperator("imageSamples",            EOpImageQuerySamples);
9078         symbolTable.relateToOperator("imageLoad",               EOpImageLoad);
9079         symbolTable.relateToOperator("imageStore",              EOpImageStore);
9080         symbolTable.relateToOperator("imageAtomicAdd",          EOpImageAtomicAdd);
9081         symbolTable.relateToOperator("imageAtomicMin",          EOpImageAtomicMin);
9082         symbolTable.relateToOperator("imageAtomicMax",          EOpImageAtomicMax);
9083         symbolTable.relateToOperator("imageAtomicAnd",          EOpImageAtomicAnd);
9084         symbolTable.relateToOperator("imageAtomicOr",           EOpImageAtomicOr);
9085         symbolTable.relateToOperator("imageAtomicXor",          EOpImageAtomicXor);
9086         symbolTable.relateToOperator("imageAtomicExchange",     EOpImageAtomicExchange);
9087         symbolTable.relateToOperator("imageAtomicCompSwap",     EOpImageAtomicCompSwap);
9088         symbolTable.relateToOperator("imageAtomicLoad",         EOpImageAtomicLoad);
9089         symbolTable.relateToOperator("imageAtomicStore",        EOpImageAtomicStore);
9090 
9091         symbolTable.relateToOperator("subpassLoad",             EOpSubpassLoad);
9092         symbolTable.relateToOperator("subpassLoadMS",           EOpSubpassLoadMS);
9093 
9094         symbolTable.relateToOperator("textureSize",             EOpTextureQuerySize);
9095         symbolTable.relateToOperator("textureQueryLod",         EOpTextureQueryLod);
9096         symbolTable.relateToOperator("textureQueryLevels",      EOpTextureQueryLevels);
9097         symbolTable.relateToOperator("textureSamples",          EOpTextureQuerySamples);
9098         symbolTable.relateToOperator("texture",                 EOpTexture);
9099         symbolTable.relateToOperator("textureProj",             EOpTextureProj);
9100         symbolTable.relateToOperator("textureLod",              EOpTextureLod);
9101         symbolTable.relateToOperator("textureOffset",           EOpTextureOffset);
9102         symbolTable.relateToOperator("texelFetch",              EOpTextureFetch);
9103         symbolTable.relateToOperator("texelFetchOffset",        EOpTextureFetchOffset);
9104         symbolTable.relateToOperator("textureProjOffset",       EOpTextureProjOffset);
9105         symbolTable.relateToOperator("textureLodOffset",        EOpTextureLodOffset);
9106         symbolTable.relateToOperator("textureProjLod",          EOpTextureProjLod);
9107         symbolTable.relateToOperator("textureProjLodOffset",    EOpTextureProjLodOffset);
9108         symbolTable.relateToOperator("textureGrad",             EOpTextureGrad);
9109         symbolTable.relateToOperator("textureGradOffset",       EOpTextureGradOffset);
9110         symbolTable.relateToOperator("textureProjGrad",         EOpTextureProjGrad);
9111         symbolTable.relateToOperator("textureProjGradOffset",   EOpTextureProjGradOffset);
9112         symbolTable.relateToOperator("textureGather",           EOpTextureGather);
9113         symbolTable.relateToOperator("textureGatherOffset",     EOpTextureGatherOffset);
9114         symbolTable.relateToOperator("textureGatherOffsets",    EOpTextureGatherOffsets);
9115 
9116         symbolTable.relateToOperator("noise1", EOpNoise);
9117         symbolTable.relateToOperator("noise2", EOpNoise);
9118         symbolTable.relateToOperator("noise3", EOpNoise);
9119         symbolTable.relateToOperator("noise4", EOpNoise);
9120 
9121 #ifdef NV_EXTENSIONS
9122         symbolTable.relateToOperator("textureFootprintNV",          EOpImageSampleFootprintNV);
9123         symbolTable.relateToOperator("textureFootprintClampNV",     EOpImageSampleFootprintClampNV);
9124         symbolTable.relateToOperator("textureFootprintLodNV",       EOpImageSampleFootprintLodNV);
9125         symbolTable.relateToOperator("textureFootprintGradNV",      EOpImageSampleFootprintGradNV);
9126         symbolTable.relateToOperator("textureFootprintGradClampNV", EOpImageSampleFootprintGradClampNV);
9127 #endif
9128 
9129         if (spvVersion.spv == 0 && (IncludeLegacy(version, profile, spvVersion) ||
9130             (profile == EEsProfile && version == 100))) {
9131             symbolTable.relateToOperator("ftransform",               EOpFtransform);
9132 
9133             symbolTable.relateToOperator("texture1D",                EOpTexture);
9134             symbolTable.relateToOperator("texture1DGradARB",         EOpTextureGrad);
9135             symbolTable.relateToOperator("texture1DProj",            EOpTextureProj);
9136             symbolTable.relateToOperator("texture1DProjGradARB",     EOpTextureProjGrad);
9137             symbolTable.relateToOperator("texture1DLod",             EOpTextureLod);
9138             symbolTable.relateToOperator("texture1DProjLod",         EOpTextureProjLod);
9139 
9140             symbolTable.relateToOperator("texture2DRect",            EOpTexture);
9141             symbolTable.relateToOperator("texture2DRectProj",        EOpTextureProj);
9142             symbolTable.relateToOperator("texture2DRectGradARB",     EOpTextureGrad);
9143             symbolTable.relateToOperator("texture2DRectProjGradARB", EOpTextureProjGrad);
9144             symbolTable.relateToOperator("shadow2DRect",             EOpTexture);
9145             symbolTable.relateToOperator("shadow2DRectProj",         EOpTextureProj);
9146             symbolTable.relateToOperator("shadow2DRectGradARB",      EOpTextureGrad);
9147             symbolTable.relateToOperator("shadow2DRectProjGradARB",  EOpTextureProjGrad);
9148 
9149             symbolTable.relateToOperator("texture2D",                EOpTexture);
9150             symbolTable.relateToOperator("texture2DProj",            EOpTextureProj);
9151             symbolTable.relateToOperator("texture2DGradEXT",         EOpTextureGrad);
9152             symbolTable.relateToOperator("texture2DGradARB",         EOpTextureGrad);
9153             symbolTable.relateToOperator("texture2DProjGradEXT",     EOpTextureProjGrad);
9154             symbolTable.relateToOperator("texture2DProjGradARB",     EOpTextureProjGrad);
9155             symbolTable.relateToOperator("texture2DLod",             EOpTextureLod);
9156             symbolTable.relateToOperator("texture2DLodEXT",          EOpTextureLod);
9157             symbolTable.relateToOperator("texture2DProjLod",         EOpTextureProjLod);
9158             symbolTable.relateToOperator("texture2DProjLodEXT",      EOpTextureProjLod);
9159 
9160             symbolTable.relateToOperator("texture3D",                EOpTexture);
9161             symbolTable.relateToOperator("texture3DGradARB",         EOpTextureGrad);
9162             symbolTable.relateToOperator("texture3DProj",            EOpTextureProj);
9163             symbolTable.relateToOperator("texture3DProjGradARB",     EOpTextureProjGrad);
9164             symbolTable.relateToOperator("texture3DLod",             EOpTextureLod);
9165             symbolTable.relateToOperator("texture3DProjLod",         EOpTextureProjLod);
9166             symbolTable.relateToOperator("textureCube",              EOpTexture);
9167             symbolTable.relateToOperator("textureCubeGradEXT",       EOpTextureGrad);
9168             symbolTable.relateToOperator("textureCubeGradARB",       EOpTextureGrad);
9169             symbolTable.relateToOperator("textureCubeLod",           EOpTextureLod);
9170             symbolTable.relateToOperator("textureCubeLodEXT",        EOpTextureLod);
9171             symbolTable.relateToOperator("shadow1D",                 EOpTexture);
9172             symbolTable.relateToOperator("shadow1DGradARB",          EOpTextureGrad);
9173             symbolTable.relateToOperator("shadow2D",                 EOpTexture);
9174             symbolTable.relateToOperator("shadow2DGradARB",          EOpTextureGrad);
9175             symbolTable.relateToOperator("shadow1DProj",             EOpTextureProj);
9176             symbolTable.relateToOperator("shadow2DProj",             EOpTextureProj);
9177             symbolTable.relateToOperator("shadow1DProjGradARB",      EOpTextureProjGrad);
9178             symbolTable.relateToOperator("shadow2DProjGradARB",      EOpTextureProjGrad);
9179             symbolTable.relateToOperator("shadow1DLod",              EOpTextureLod);
9180             symbolTable.relateToOperator("shadow2DLod",              EOpTextureLod);
9181             symbolTable.relateToOperator("shadow1DProjLod",          EOpTextureProjLod);
9182             symbolTable.relateToOperator("shadow2DProjLod",          EOpTextureProjLod);
9183         }
9184 
9185         if (profile != EEsProfile) {
9186             symbolTable.relateToOperator("sparseTextureARB",                EOpSparseTexture);
9187             symbolTable.relateToOperator("sparseTextureLodARB",             EOpSparseTextureLod);
9188             symbolTable.relateToOperator("sparseTextureOffsetARB",          EOpSparseTextureOffset);
9189             symbolTable.relateToOperator("sparseTexelFetchARB",             EOpSparseTextureFetch);
9190             symbolTable.relateToOperator("sparseTexelFetchOffsetARB",       EOpSparseTextureFetchOffset);
9191             symbolTable.relateToOperator("sparseTextureLodOffsetARB",       EOpSparseTextureLodOffset);
9192             symbolTable.relateToOperator("sparseTextureGradARB",            EOpSparseTextureGrad);
9193             symbolTable.relateToOperator("sparseTextureGradOffsetARB",      EOpSparseTextureGradOffset);
9194             symbolTable.relateToOperator("sparseTextureGatherARB",          EOpSparseTextureGather);
9195             symbolTable.relateToOperator("sparseTextureGatherOffsetARB",    EOpSparseTextureGatherOffset);
9196             symbolTable.relateToOperator("sparseTextureGatherOffsetsARB",   EOpSparseTextureGatherOffsets);
9197             symbolTable.relateToOperator("sparseImageLoadARB",              EOpSparseImageLoad);
9198             symbolTable.relateToOperator("sparseTexelsResidentARB",         EOpSparseTexelsResident);
9199 
9200             symbolTable.relateToOperator("sparseTextureClampARB",           EOpSparseTextureClamp);
9201             symbolTable.relateToOperator("sparseTextureOffsetClampARB",     EOpSparseTextureOffsetClamp);
9202             symbolTable.relateToOperator("sparseTextureGradClampARB",       EOpSparseTextureGradClamp);
9203             symbolTable.relateToOperator("sparseTextureGradOffsetClampARB", EOpSparseTextureGradOffsetClamp);
9204             symbolTable.relateToOperator("textureClampARB",                 EOpTextureClamp);
9205             symbolTable.relateToOperator("textureOffsetClampARB",           EOpTextureOffsetClamp);
9206             symbolTable.relateToOperator("textureGradClampARB",             EOpTextureGradClamp);
9207             symbolTable.relateToOperator("textureGradOffsetClampARB",       EOpTextureGradOffsetClamp);
9208 
9209             symbolTable.relateToOperator("ballotARB",                       EOpBallot);
9210             symbolTable.relateToOperator("readInvocationARB",               EOpReadInvocation);
9211             symbolTable.relateToOperator("readFirstInvocationARB",          EOpReadFirstInvocation);
9212 
9213             if (version >= 430) {
9214                 symbolTable.relateToOperator("anyInvocationARB",            EOpAnyInvocation);
9215                 symbolTable.relateToOperator("allInvocationsARB",           EOpAllInvocations);
9216                 symbolTable.relateToOperator("allInvocationsEqualARB",      EOpAllInvocationsEqual);
9217             }
9218             if (version >= 460) {
9219                 symbolTable.relateToOperator("anyInvocation",               EOpAnyInvocation);
9220                 symbolTable.relateToOperator("allInvocations",              EOpAllInvocations);
9221                 symbolTable.relateToOperator("allInvocationsEqual",         EOpAllInvocationsEqual);
9222             }
9223 #ifdef AMD_EXTENSIONS
9224             symbolTable.relateToOperator("minInvocationsAMD",                           EOpMinInvocations);
9225             symbolTable.relateToOperator("maxInvocationsAMD",                           EOpMaxInvocations);
9226             symbolTable.relateToOperator("addInvocationsAMD",                           EOpAddInvocations);
9227             symbolTable.relateToOperator("minInvocationsNonUniformAMD",                 EOpMinInvocationsNonUniform);
9228             symbolTable.relateToOperator("maxInvocationsNonUniformAMD",                 EOpMaxInvocationsNonUniform);
9229             symbolTable.relateToOperator("addInvocationsNonUniformAMD",                 EOpAddInvocationsNonUniform);
9230             symbolTable.relateToOperator("minInvocationsInclusiveScanAMD",              EOpMinInvocationsInclusiveScan);
9231             symbolTable.relateToOperator("maxInvocationsInclusiveScanAMD",              EOpMaxInvocationsInclusiveScan);
9232             symbolTable.relateToOperator("addInvocationsInclusiveScanAMD",              EOpAddInvocationsInclusiveScan);
9233             symbolTable.relateToOperator("minInvocationsInclusiveScanNonUniformAMD",    EOpMinInvocationsInclusiveScanNonUniform);
9234             symbolTable.relateToOperator("maxInvocationsInclusiveScanNonUniformAMD",    EOpMaxInvocationsInclusiveScanNonUniform);
9235             symbolTable.relateToOperator("addInvocationsInclusiveScanNonUniformAMD",    EOpAddInvocationsInclusiveScanNonUniform);
9236             symbolTable.relateToOperator("minInvocationsExclusiveScanAMD",              EOpMinInvocationsExclusiveScan);
9237             symbolTable.relateToOperator("maxInvocationsExclusiveScanAMD",              EOpMaxInvocationsExclusiveScan);
9238             symbolTable.relateToOperator("addInvocationsExclusiveScanAMD",              EOpAddInvocationsExclusiveScan);
9239             symbolTable.relateToOperator("minInvocationsExclusiveScanNonUniformAMD",    EOpMinInvocationsExclusiveScanNonUniform);
9240             symbolTable.relateToOperator("maxInvocationsExclusiveScanNonUniformAMD",    EOpMaxInvocationsExclusiveScanNonUniform);
9241             symbolTable.relateToOperator("addInvocationsExclusiveScanNonUniformAMD",    EOpAddInvocationsExclusiveScanNonUniform);
9242             symbolTable.relateToOperator("swizzleInvocationsAMD",                       EOpSwizzleInvocations);
9243             symbolTable.relateToOperator("swizzleInvocationsMaskedAMD",                 EOpSwizzleInvocationsMasked);
9244             symbolTable.relateToOperator("writeInvocationAMD",                          EOpWriteInvocation);
9245             symbolTable.relateToOperator("mbcntAMD",                                    EOpMbcnt);
9246 
9247             symbolTable.relateToOperator("min3",    EOpMin3);
9248             symbolTable.relateToOperator("max3",    EOpMax3);
9249             symbolTable.relateToOperator("mid3",    EOpMid3);
9250 
9251             symbolTable.relateToOperator("cubeFaceIndexAMD",    EOpCubeFaceIndex);
9252             symbolTable.relateToOperator("cubeFaceCoordAMD",    EOpCubeFaceCoord);
9253             symbolTable.relateToOperator("timeAMD",             EOpTime);
9254 
9255             symbolTable.relateToOperator("textureGatherLodAMD",                 EOpTextureGatherLod);
9256             symbolTable.relateToOperator("textureGatherLodOffsetAMD",           EOpTextureGatherLodOffset);
9257             symbolTable.relateToOperator("textureGatherLodOffsetsAMD",          EOpTextureGatherLodOffsets);
9258             symbolTable.relateToOperator("sparseTextureGatherLodAMD",           EOpSparseTextureGatherLod);
9259             symbolTable.relateToOperator("sparseTextureGatherLodOffsetAMD",     EOpSparseTextureGatherLodOffset);
9260             symbolTable.relateToOperator("sparseTextureGatherLodOffsetsAMD",    EOpSparseTextureGatherLodOffsets);
9261 
9262             symbolTable.relateToOperator("imageLoadLodAMD",                     EOpImageLoadLod);
9263             symbolTable.relateToOperator("imageStoreLodAMD",                    EOpImageStoreLod);
9264             symbolTable.relateToOperator("sparseImageLoadLodAMD",               EOpSparseImageLoadLod);
9265 
9266             symbolTable.relateToOperator("fragmentMaskFetchAMD",                EOpFragmentMaskFetch);
9267             symbolTable.relateToOperator("fragmentFetchAMD",                    EOpFragmentFetch);
9268 #endif
9269         }
9270 
9271         // GL_KHR_shader_subgroup
9272         if (spvVersion.vulkan > 0) {
9273             symbolTable.relateToOperator("subgroupBarrier",                 EOpSubgroupBarrier);
9274             symbolTable.relateToOperator("subgroupMemoryBarrier",           EOpSubgroupMemoryBarrier);
9275             symbolTable.relateToOperator("subgroupMemoryBarrierBuffer",     EOpSubgroupMemoryBarrierBuffer);
9276             symbolTable.relateToOperator("subgroupMemoryBarrierImage",      EOpSubgroupMemoryBarrierImage);
9277             symbolTable.relateToOperator("subgroupElect",                   EOpSubgroupElect);
9278             symbolTable.relateToOperator("subgroupAll",                     EOpSubgroupAll);
9279             symbolTable.relateToOperator("subgroupAny",                     EOpSubgroupAny);
9280             symbolTable.relateToOperator("subgroupAllEqual",                EOpSubgroupAllEqual);
9281             symbolTable.relateToOperator("subgroupBroadcast",               EOpSubgroupBroadcast);
9282             symbolTable.relateToOperator("subgroupBroadcastFirst",          EOpSubgroupBroadcastFirst);
9283             symbolTable.relateToOperator("subgroupBallot",                  EOpSubgroupBallot);
9284             symbolTable.relateToOperator("subgroupInverseBallot",           EOpSubgroupInverseBallot);
9285             symbolTable.relateToOperator("subgroupBallotBitExtract",        EOpSubgroupBallotBitExtract);
9286             symbolTable.relateToOperator("subgroupBallotBitCount",          EOpSubgroupBallotBitCount);
9287             symbolTable.relateToOperator("subgroupBallotInclusiveBitCount", EOpSubgroupBallotInclusiveBitCount);
9288             symbolTable.relateToOperator("subgroupBallotExclusiveBitCount", EOpSubgroupBallotExclusiveBitCount);
9289             symbolTable.relateToOperator("subgroupBallotFindLSB",           EOpSubgroupBallotFindLSB);
9290             symbolTable.relateToOperator("subgroupBallotFindMSB",           EOpSubgroupBallotFindMSB);
9291             symbolTable.relateToOperator("subgroupShuffle",                 EOpSubgroupShuffle);
9292             symbolTable.relateToOperator("subgroupShuffleXor",              EOpSubgroupShuffleXor);
9293             symbolTable.relateToOperator("subgroupShuffleUp",               EOpSubgroupShuffleUp);
9294             symbolTable.relateToOperator("subgroupShuffleDown",             EOpSubgroupShuffleDown);
9295             symbolTable.relateToOperator("subgroupAdd",                     EOpSubgroupAdd);
9296             symbolTable.relateToOperator("subgroupMul",                     EOpSubgroupMul);
9297             symbolTable.relateToOperator("subgroupMin",                     EOpSubgroupMin);
9298             symbolTable.relateToOperator("subgroupMax",                     EOpSubgroupMax);
9299             symbolTable.relateToOperator("subgroupAnd",                     EOpSubgroupAnd);
9300             symbolTable.relateToOperator("subgroupOr",                      EOpSubgroupOr);
9301             symbolTable.relateToOperator("subgroupXor",                     EOpSubgroupXor);
9302             symbolTable.relateToOperator("subgroupInclusiveAdd",            EOpSubgroupInclusiveAdd);
9303             symbolTable.relateToOperator("subgroupInclusiveMul",            EOpSubgroupInclusiveMul);
9304             symbolTable.relateToOperator("subgroupInclusiveMin",            EOpSubgroupInclusiveMin);
9305             symbolTable.relateToOperator("subgroupInclusiveMax",            EOpSubgroupInclusiveMax);
9306             symbolTable.relateToOperator("subgroupInclusiveAnd",            EOpSubgroupInclusiveAnd);
9307             symbolTable.relateToOperator("subgroupInclusiveOr",             EOpSubgroupInclusiveOr);
9308             symbolTable.relateToOperator("subgroupInclusiveXor",            EOpSubgroupInclusiveXor);
9309             symbolTable.relateToOperator("subgroupExclusiveAdd",            EOpSubgroupExclusiveAdd);
9310             symbolTable.relateToOperator("subgroupExclusiveMul",            EOpSubgroupExclusiveMul);
9311             symbolTable.relateToOperator("subgroupExclusiveMin",            EOpSubgroupExclusiveMin);
9312             symbolTable.relateToOperator("subgroupExclusiveMax",            EOpSubgroupExclusiveMax);
9313             symbolTable.relateToOperator("subgroupExclusiveAnd",            EOpSubgroupExclusiveAnd);
9314             symbolTable.relateToOperator("subgroupExclusiveOr",             EOpSubgroupExclusiveOr);
9315             symbolTable.relateToOperator("subgroupExclusiveXor",            EOpSubgroupExclusiveXor);
9316             symbolTable.relateToOperator("subgroupClusteredAdd",            EOpSubgroupClusteredAdd);
9317             symbolTable.relateToOperator("subgroupClusteredMul",            EOpSubgroupClusteredMul);
9318             symbolTable.relateToOperator("subgroupClusteredMin",            EOpSubgroupClusteredMin);
9319             symbolTable.relateToOperator("subgroupClusteredMax",            EOpSubgroupClusteredMax);
9320             symbolTable.relateToOperator("subgroupClusteredAnd",            EOpSubgroupClusteredAnd);
9321             symbolTable.relateToOperator("subgroupClusteredOr",             EOpSubgroupClusteredOr);
9322             symbolTable.relateToOperator("subgroupClusteredXor",            EOpSubgroupClusteredXor);
9323             symbolTable.relateToOperator("subgroupQuadBroadcast",           EOpSubgroupQuadBroadcast);
9324             symbolTable.relateToOperator("subgroupQuadSwapHorizontal",      EOpSubgroupQuadSwapHorizontal);
9325             symbolTable.relateToOperator("subgroupQuadSwapVertical",        EOpSubgroupQuadSwapVertical);
9326             symbolTable.relateToOperator("subgroupQuadSwapDiagonal",        EOpSubgroupQuadSwapDiagonal);
9327 
9328 #ifdef NV_EXTENSIONS
9329             symbolTable.relateToOperator("subgroupPartitionNV",                          EOpSubgroupPartition);
9330             symbolTable.relateToOperator("subgroupPartitionedAddNV",                     EOpSubgroupPartitionedAdd);
9331             symbolTable.relateToOperator("subgroupPartitionedMulNV",                     EOpSubgroupPartitionedMul);
9332             symbolTable.relateToOperator("subgroupPartitionedMinNV",                     EOpSubgroupPartitionedMin);
9333             symbolTable.relateToOperator("subgroupPartitionedMaxNV",                     EOpSubgroupPartitionedMax);
9334             symbolTable.relateToOperator("subgroupPartitionedAndNV",                     EOpSubgroupPartitionedAnd);
9335             symbolTable.relateToOperator("subgroupPartitionedOrNV",                      EOpSubgroupPartitionedOr);
9336             symbolTable.relateToOperator("subgroupPartitionedXorNV",                     EOpSubgroupPartitionedXor);
9337             symbolTable.relateToOperator("subgroupPartitionedInclusiveAddNV",            EOpSubgroupPartitionedInclusiveAdd);
9338             symbolTable.relateToOperator("subgroupPartitionedInclusiveMulNV",            EOpSubgroupPartitionedInclusiveMul);
9339             symbolTable.relateToOperator("subgroupPartitionedInclusiveMinNV",            EOpSubgroupPartitionedInclusiveMin);
9340             symbolTable.relateToOperator("subgroupPartitionedInclusiveMaxNV",            EOpSubgroupPartitionedInclusiveMax);
9341             symbolTable.relateToOperator("subgroupPartitionedInclusiveAndNV",            EOpSubgroupPartitionedInclusiveAnd);
9342             symbolTable.relateToOperator("subgroupPartitionedInclusiveOrNV",             EOpSubgroupPartitionedInclusiveOr);
9343             symbolTable.relateToOperator("subgroupPartitionedInclusiveXorNV",            EOpSubgroupPartitionedInclusiveXor);
9344             symbolTable.relateToOperator("subgroupPartitionedExclusiveAddNV",            EOpSubgroupPartitionedExclusiveAdd);
9345             symbolTable.relateToOperator("subgroupPartitionedExclusiveMulNV",            EOpSubgroupPartitionedExclusiveMul);
9346             symbolTable.relateToOperator("subgroupPartitionedExclusiveMinNV",            EOpSubgroupPartitionedExclusiveMin);
9347             symbolTable.relateToOperator("subgroupPartitionedExclusiveMaxNV",            EOpSubgroupPartitionedExclusiveMax);
9348             symbolTable.relateToOperator("subgroupPartitionedExclusiveAndNV",            EOpSubgroupPartitionedExclusiveAnd);
9349             symbolTable.relateToOperator("subgroupPartitionedExclusiveOrNV",             EOpSubgroupPartitionedExclusiveOr);
9350             symbolTable.relateToOperator("subgroupPartitionedExclusiveXorNV",            EOpSubgroupPartitionedExclusiveXor);
9351 #endif
9352         }
9353 
9354         if (profile == EEsProfile) {
9355             symbolTable.relateToOperator("shadow2DEXT",              EOpTexture);
9356             symbolTable.relateToOperator("shadow2DProjEXT",          EOpTextureProj);
9357         }
9358     }
9359 
9360     switch(language) {
9361     case EShLangVertex:
9362         break;
9363 
9364     case EShLangTessControl:
9365     case EShLangTessEvaluation:
9366         break;
9367 
9368     case EShLangGeometry:
9369         symbolTable.relateToOperator("EmitStreamVertex",   EOpEmitStreamVertex);
9370         symbolTable.relateToOperator("EndStreamPrimitive", EOpEndStreamPrimitive);
9371         symbolTable.relateToOperator("EmitVertex",         EOpEmitVertex);
9372         symbolTable.relateToOperator("EndPrimitive",       EOpEndPrimitive);
9373         break;
9374 
9375     case EShLangFragment:
9376         symbolTable.relateToOperator("dFdx",         EOpDPdx);
9377         symbolTable.relateToOperator("dFdy",         EOpDPdy);
9378         symbolTable.relateToOperator("fwidth",       EOpFwidth);
9379         if (profile != EEsProfile && version >= 400) {
9380             symbolTable.relateToOperator("dFdxFine",     EOpDPdxFine);
9381             symbolTable.relateToOperator("dFdyFine",     EOpDPdyFine);
9382             symbolTable.relateToOperator("fwidthFine",   EOpFwidthFine);
9383             symbolTable.relateToOperator("dFdxCoarse",   EOpDPdxCoarse);
9384             symbolTable.relateToOperator("dFdyCoarse",   EOpDPdyCoarse);
9385             symbolTable.relateToOperator("fwidthCoarse", EOpFwidthCoarse);
9386         }
9387         symbolTable.relateToOperator("interpolateAtCentroid", EOpInterpolateAtCentroid);
9388         symbolTable.relateToOperator("interpolateAtSample",   EOpInterpolateAtSample);
9389         symbolTable.relateToOperator("interpolateAtOffset",   EOpInterpolateAtOffset);
9390 
9391 #ifdef AMD_EXTENSIONS
9392         if (profile != EEsProfile)
9393             symbolTable.relateToOperator("interpolateAtVertexAMD", EOpInterpolateAtVertex);
9394 #endif
9395         break;
9396 
9397     case EShLangCompute:
9398         symbolTable.relateToOperator("memoryBarrierShared",         EOpMemoryBarrierShared);
9399         symbolTable.relateToOperator("groupMemoryBarrier",          EOpGroupMemoryBarrier);
9400         symbolTable.relateToOperator("subgroupMemoryBarrierShared", EOpSubgroupMemoryBarrierShared);
9401 #ifdef NV_EXTENSIONS
9402         if ((profile != EEsProfile && version >= 450) ||
9403             (profile == EEsProfile && version >= 320)) {
9404             symbolTable.relateToOperator("dFdx",        EOpDPdx);
9405             symbolTable.relateToOperator("dFdy",        EOpDPdy);
9406             symbolTable.relateToOperator("fwidth",      EOpFwidth);
9407             symbolTable.relateToOperator("dFdxFine",    EOpDPdxFine);
9408             symbolTable.relateToOperator("dFdyFine",    EOpDPdyFine);
9409             symbolTable.relateToOperator("fwidthFine",  EOpFwidthFine);
9410             symbolTable.relateToOperator("dFdxCoarse",  EOpDPdxCoarse);
9411             symbolTable.relateToOperator("dFdyCoarse",  EOpDPdyCoarse);
9412             symbolTable.relateToOperator("fwidthCoarse",EOpFwidthCoarse);
9413         }
9414 #endif
9415         break;
9416 
9417 #ifdef NV_EXTENSIONS
9418     case EShLangRayGenNV:
9419     case EShLangClosestHitNV:
9420     case EShLangMissNV:
9421         if (profile != EEsProfile && version >= 460) {
9422             symbolTable.relateToOperator("traceNV", EOpTraceNV);
9423             symbolTable.relateToOperator("executeCallableNV", EOpExecuteCallableNV);
9424         }
9425         break;
9426     case EShLangIntersectNV:
9427         if (profile != EEsProfile && version >= 460)
9428             symbolTable.relateToOperator("reportIntersectionNV", EOpReportIntersectionNV);
9429         break;
9430     case EShLangAnyHitNV:
9431         if (profile != EEsProfile && version >= 460) {
9432             symbolTable.relateToOperator("ignoreIntersectionNV", EOpIgnoreIntersectionNV);
9433             symbolTable.relateToOperator("terminateRayNV", EOpTerminateRayNV);
9434         }
9435         break;
9436     case EShLangCallableNV:
9437         if (profile != EEsProfile && version >= 460) {
9438             symbolTable.relateToOperator("executeCallableNV", EOpExecuteCallableNV);
9439         }
9440         break;
9441     case EShLangMeshNV:
9442         if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
9443             symbolTable.relateToOperator("writePackedPrimitiveIndices4x8NV", EOpWritePackedPrimitiveIndices4x8NV);
9444         }
9445         // fall through
9446     case EShLangTaskNV:
9447         if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
9448             symbolTable.relateToOperator("memoryBarrierShared", EOpMemoryBarrierShared);
9449             symbolTable.relateToOperator("groupMemoryBarrier", EOpGroupMemoryBarrier);
9450         }
9451         break;
9452 #endif
9453 
9454     default:
9455         assert(false && "Language not supported");
9456     }
9457 }
9458 
9459 //
9460 // Add context-dependent (resource-specific) built-ins not handled by the above.  These
9461 // would be ones that need to be programmatically added because they cannot
9462 // be added by simple text strings.  For these, also
9463 // 1) Map built-in functions to operators, for those that will turn into an operation node
9464 //    instead of remaining a function call.
9465 // 2) Tag extension-related symbols added to their base version with their extensions, so
9466 //    that if an early version has the extension turned off, there is an error reported on use.
9467 //
9468 void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources)
9469 {
9470     if (profile != EEsProfile && version >= 430 && version < 440) {
9471         symbolTable.setVariableExtensions("gl_MaxTransformFeedbackBuffers", 1, &E_GL_ARB_enhanced_layouts);
9472         symbolTable.setVariableExtensions("gl_MaxTransformFeedbackInterleavedComponents", 1, &E_GL_ARB_enhanced_layouts);
9473     }
9474     if (profile != EEsProfile && version >= 130 && version < 420) {
9475         symbolTable.setVariableExtensions("gl_MinProgramTexelOffset", 1, &E_GL_ARB_shading_language_420pack);
9476         symbolTable.setVariableExtensions("gl_MaxProgramTexelOffset", 1, &E_GL_ARB_shading_language_420pack);
9477     }
9478     if (profile != EEsProfile && version >= 150 && version < 410)
9479         symbolTable.setVariableExtensions("gl_MaxViewports", 1, &E_GL_ARB_viewport_array);
9480 
9481     switch(language) {
9482     case EShLangFragment:
9483         // Set up gl_FragData based on current array size.
9484         if (version == 100 || IncludeLegacy(version, profile, spvVersion) || (! ForwardCompatibility && profile != EEsProfile && version < 420)) {
9485             TPrecisionQualifier pq = profile == EEsProfile ? EpqMedium : EpqNone;
9486             TType fragData(EbtFloat, EvqFragColor, pq, 4);
9487             TArraySizes* arraySizes = new TArraySizes;
9488             arraySizes->addInnerSize(resources.maxDrawBuffers);
9489             fragData.transferArraySizes(arraySizes);
9490             symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));
9491             SpecialQualifier("gl_FragData", EvqFragColor, EbvFragData, symbolTable);
9492         }
9493         break;
9494 
9495     case EShLangTessControl:
9496     case EShLangTessEvaluation:
9497         // Because of the context-dependent array size (gl_MaxPatchVertices),
9498         // these variables were added later than the others and need to be mapped now.
9499 
9500         // standard members
9501         BuiltInVariable("gl_in", "gl_Position",     EbvPosition,     symbolTable);
9502         BuiltInVariable("gl_in", "gl_PointSize",    EbvPointSize,    symbolTable);
9503         BuiltInVariable("gl_in", "gl_ClipDistance", EbvClipDistance, symbolTable);
9504         BuiltInVariable("gl_in", "gl_CullDistance", EbvCullDistance, symbolTable);
9505 
9506         // compatibility members
9507         BuiltInVariable("gl_in", "gl_ClipVertex",          EbvClipVertex,          symbolTable);
9508         BuiltInVariable("gl_in", "gl_FrontColor",          EbvFrontColor,          symbolTable);
9509         BuiltInVariable("gl_in", "gl_BackColor",           EbvBackColor,           symbolTable);
9510         BuiltInVariable("gl_in", "gl_FrontSecondaryColor", EbvFrontSecondaryColor, symbolTable);
9511         BuiltInVariable("gl_in", "gl_BackSecondaryColor",  EbvBackSecondaryColor,  symbolTable);
9512         BuiltInVariable("gl_in", "gl_TexCoord",            EbvTexCoord,            symbolTable);
9513         BuiltInVariable("gl_in", "gl_FogFragCoord",        EbvFogFragCoord,        symbolTable);
9514         break;
9515 
9516     default:
9517         break;
9518     }
9519 }
9520 
9521 } // end namespace glslang
9522