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