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.
8 // All rights reserved.
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions
14 // Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
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.
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.
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.
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.
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
54 #include "../Include/intermediate.h"
55 #include "Initialize.h"
59 // TODO: ARB_Compatability: do full extension support
60 const bool ARBCompatibility = true;
62 const bool ForwardCompatibility = false;
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;
71 // A set of definitions for tabling of the built-in functions.
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",
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'
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
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);
107 // The relationships between arguments and return type, whether anything is
108 // output, or other unusual situations.
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
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);
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
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
144 EProfile EDesktopProfile = static_cast<EProfile>(ENoProfile | ECoreProfile | ECompatibilityProfile);
146 // Declare pointers to put into the table for versioning.
148 const Versioning* Es300Desktop130 = nullptr;
149 const Versioning* Es310Desktop420 = nullptr;
150 #elif defined(GLSLANG_ANGLE)
151 const Versioning* Es300Desktop130 = nullptr;
152 const Versioning* Es310Desktop420 = nullptr;
153 const Versioning* Es310Desktop450 = nullptr;
155 const Versioning Es300Desktop130Version[] = { { EEsProfile, 0, 300, 0, nullptr },
156 { EDesktopProfile, 0, 130, 0, nullptr },
158 const Versioning* Es300Desktop130 = &Es300Desktop130Version[0];
160 const Versioning Es310Desktop420Version[] = { { EEsProfile, 0, 310, 0, nullptr },
161 { EDesktopProfile, 0, 420, 0, nullptr },
163 const Versioning* Es310Desktop420 = &Es310Desktop420Version[0];
165 const Versioning Es310Desktop450Version[] = { { EEsProfile, 0, 310, 0, nullptr },
166 { EDesktopProfile, 0, 450, 0, nullptr },
168 const Versioning* Es310Desktop450 = &Es310Desktop450Version[0];
171 // The main descriptor of what a set of function prototypes can look like, and
172 // a pointer to extra versioning information, when needed.
173 struct BuiltInFunction {
174 TOperator op; // operator to map the name to
175 const char* name; // function name
176 int numArguments; // number of arguments (overloads with varying arguments need different entries)
177 ArgType types; // ArgType mask
178 ArgClass classes; // the ways this particular function entry manifests
179 const Versioning* versioning; // nullptr means always a valid version
182 // The tables can have the same built-in function name more than one time,
183 // but the exact same prototype must be indicated at most once.
184 // The prototypes that get declared are the union of all those indicated.
185 // This is important when different releases add new prototypes for the same name.
186 // It also also congnitively simpler tiling of the prototype space.
187 // In practice, most names can be fully represented with one entry.
189 // Table is terminated by an OpNull TOperator.
191 const BuiltInFunction BaseFunctions[] = {
192 // TOperator, name, arg-count, ArgType, ArgClass, versioning
193 // --------- ---- --------- ------- -------- ----------
194 { EOpRadians, "radians", 1, TypeF, ClassRegular, nullptr },
195 { EOpDegrees, "degrees", 1, TypeF, ClassRegular, nullptr },
196 { EOpSin, "sin", 1, TypeF, ClassRegular, nullptr },
197 { EOpCos, "cos", 1, TypeF, ClassRegular, nullptr },
198 { EOpTan, "tan", 1, TypeF, ClassRegular, nullptr },
199 { EOpAsin, "asin", 1, TypeF, ClassRegular, nullptr },
200 { EOpAcos, "acos", 1, TypeF, ClassRegular, nullptr },
201 { EOpAtan, "atan", 2, TypeF, ClassRegular, nullptr },
202 { EOpAtan, "atan", 1, TypeF, ClassRegular, nullptr },
203 { EOpPow, "pow", 2, TypeF, ClassRegular, nullptr },
204 { EOpExp, "exp", 1, TypeF, ClassRegular, nullptr },
205 { EOpLog, "log", 1, TypeF, ClassRegular, nullptr },
206 { EOpExp2, "exp2", 1, TypeF, ClassRegular, nullptr },
207 { EOpLog2, "log2", 1, TypeF, ClassRegular, nullptr },
208 { EOpSqrt, "sqrt", 1, TypeF, ClassRegular, nullptr },
209 { EOpInverseSqrt, "inversesqrt", 1, TypeF, ClassRegular, nullptr },
210 { EOpAbs, "abs", 1, TypeF, ClassRegular, nullptr },
211 { EOpSign, "sign", 1, TypeF, ClassRegular, nullptr },
212 { EOpFloor, "floor", 1, TypeF, ClassRegular, nullptr },
213 { EOpCeil, "ceil", 1, TypeF, ClassRegular, nullptr },
214 { EOpFract, "fract", 1, TypeF, ClassRegular, nullptr },
215 { EOpMod, "mod", 2, TypeF, ClassLS, nullptr },
216 { EOpMin, "min", 2, TypeF, ClassLS, nullptr },
217 { EOpMax, "max", 2, TypeF, ClassLS, nullptr },
218 { EOpClamp, "clamp", 3, TypeF, ClassLS2, nullptr },
219 { EOpMix, "mix", 3, TypeF, ClassLS, nullptr },
220 { EOpStep, "step", 2, TypeF, ClassFS, nullptr },
221 { EOpSmoothStep, "smoothstep", 3, TypeF, ClassFS2, nullptr },
222 { EOpNormalize, "normalize", 1, TypeF, ClassRegular, nullptr },
223 { EOpFaceForward, "faceforward", 3, TypeF, ClassRegular, nullptr },
224 { EOpReflect, "reflect", 2, TypeF, ClassRegular, nullptr },
225 { EOpRefract, "refract", 3, TypeF, ClassXLS, nullptr },
226 { EOpLength, "length", 1, TypeF, ClassRS, nullptr },
227 { EOpDistance, "distance", 2, TypeF, ClassRS, nullptr },
228 { EOpDot, "dot", 2, TypeF, ClassRS, nullptr },
229 { EOpCross, "cross", 2, TypeF, ClassV3, nullptr },
230 { EOpLessThan, "lessThan", 2, TypeFI, ClassBNS, nullptr },
231 { EOpLessThanEqual, "lessThanEqual", 2, TypeFI, ClassBNS, nullptr },
232 { EOpGreaterThan, "greaterThan", 2, TypeFI, ClassBNS, nullptr },
233 { EOpGreaterThanEqual, "greaterThanEqual", 2, TypeFI, ClassBNS, nullptr },
234 { EOpVectorEqual, "equal", 2, TypeFIB, ClassBNS, nullptr },
235 { EOpVectorNotEqual, "notEqual", 2, TypeFIB, ClassBNS, nullptr },
236 { EOpAny, "any", 1, TypeB, ClassRSNS, nullptr },
237 { EOpAll, "all", 1, TypeB, ClassRSNS, nullptr },
238 { EOpVectorLogicalNot, "not", 1, TypeB, ClassNS, nullptr },
239 { EOpSinh, "sinh", 1, TypeF, ClassRegular, Es300Desktop130 },
240 { EOpCosh, "cosh", 1, TypeF, ClassRegular, Es300Desktop130 },
241 { EOpTanh, "tanh", 1, TypeF, ClassRegular, Es300Desktop130 },
242 { EOpAsinh, "asinh", 1, TypeF, ClassRegular, Es300Desktop130 },
243 { EOpAcosh, "acosh", 1, TypeF, ClassRegular, Es300Desktop130 },
244 { EOpAtanh, "atanh", 1, TypeF, ClassRegular, Es300Desktop130 },
245 { EOpAbs, "abs", 1, TypeI, ClassRegular, Es300Desktop130 },
246 { EOpSign, "sign", 1, TypeI, ClassRegular, Es300Desktop130 },
247 { EOpTrunc, "trunc", 1, TypeF, ClassRegular, Es300Desktop130 },
248 { EOpRound, "round", 1, TypeF, ClassRegular, Es300Desktop130 },
249 { EOpRoundEven, "roundEven", 1, TypeF, ClassRegular, Es300Desktop130 },
250 { EOpModf, "modf", 2, TypeF, ClassLO, Es300Desktop130 },
251 { EOpMin, "min", 2, TypeIU, ClassLS, Es300Desktop130 },
252 { EOpMax, "max", 2, TypeIU, ClassLS, Es300Desktop130 },
253 { EOpClamp, "clamp", 3, TypeIU, ClassLS2, Es300Desktop130 },
254 { EOpMix, "mix", 3, TypeF, ClassLB, Es300Desktop130 },
255 { EOpIsInf, "isinf", 1, TypeF, ClassB, Es300Desktop130 },
256 { EOpIsNan, "isnan", 1, TypeF, ClassB, Es300Desktop130 },
257 { EOpLessThan, "lessThan", 2, TypeU, ClassBNS, Es300Desktop130 },
258 { EOpLessThanEqual, "lessThanEqual", 2, TypeU, ClassBNS, Es300Desktop130 },
259 { EOpGreaterThan, "greaterThan", 2, TypeU, ClassBNS, Es300Desktop130 },
260 { EOpGreaterThanEqual, "greaterThanEqual", 2, TypeU, ClassBNS, Es300Desktop130 },
261 { EOpVectorEqual, "equal", 2, TypeU, ClassBNS, Es300Desktop130 },
262 { EOpVectorNotEqual, "notEqual", 2, TypeU, ClassBNS, Es300Desktop130 },
263 { EOpAtomicAdd, "atomicAdd", 2, TypeIU, ClassV1FIOCV, Es310Desktop420 },
264 { EOpAtomicMin, "atomicMin", 2, TypeIU, ClassV1FIOCV, Es310Desktop420 },
265 { EOpAtomicMax, "atomicMax", 2, TypeIU, ClassV1FIOCV, Es310Desktop420 },
266 { EOpAtomicAnd, "atomicAnd", 2, TypeIU, ClassV1FIOCV, Es310Desktop420 },
267 { EOpAtomicOr, "atomicOr", 2, TypeIU, ClassV1FIOCV, Es310Desktop420 },
268 { EOpAtomicXor, "atomicXor", 2, TypeIU, ClassV1FIOCV, Es310Desktop420 },
269 { EOpAtomicExchange, "atomicExchange", 2, TypeIU, ClassV1FIOCV, Es310Desktop420 },
270 { EOpAtomicCompSwap, "atomicCompSwap", 3, TypeIU, ClassV1FIOCV, Es310Desktop420 },
272 { EOpMix, "mix", 3, TypeB, ClassRegular, Es310Desktop450 },
273 { EOpMix, "mix", 3, TypeIU, ClassLB, Es310Desktop450 },
279 const BuiltInFunction DerivativeFunctions[] = {
280 { EOpDPdx, "dFdx", 1, TypeF, ClassRegular, nullptr },
281 { EOpDPdy, "dFdy", 1, TypeF, ClassRegular, nullptr },
282 { EOpFwidth, "fwidth", 1, TypeF, ClassRegular, nullptr },
286 // For functions declared some other way, but still use the table to relate to operator.
287 struct CustomFunction {
288 TOperator op; // operator to map the name to
289 const char* name; // function name
290 const Versioning* versioning; // nullptr means always a valid version
293 const CustomFunction CustomFunctions[] = {
294 { EOpBarrier, "barrier", nullptr },
295 { EOpMemoryBarrierShared, "memoryBarrierShared", nullptr },
296 { EOpGroupMemoryBarrier, "groupMemoryBarrier", nullptr },
297 { EOpMemoryBarrier, "memoryBarrier", nullptr },
298 { EOpMemoryBarrierBuffer, "memoryBarrierBuffer", nullptr },
300 { EOpPackSnorm2x16, "packSnorm2x16", nullptr },
301 { EOpUnpackSnorm2x16, "unpackSnorm2x16", nullptr },
302 { EOpPackUnorm2x16, "packUnorm2x16", nullptr },
303 { EOpUnpackUnorm2x16, "unpackUnorm2x16", nullptr },
304 { EOpPackHalf2x16, "packHalf2x16", nullptr },
305 { EOpUnpackHalf2x16, "unpackHalf2x16", nullptr },
307 { EOpMul, "matrixCompMult", nullptr },
308 { EOpOuterProduct, "outerProduct", nullptr },
309 { EOpTranspose, "transpose", nullptr },
310 { EOpDeterminant, "determinant", nullptr },
311 { EOpMatrixInverse, "inverse", nullptr },
312 { EOpFloatBitsToInt, "floatBitsToInt", nullptr },
313 { EOpFloatBitsToUint, "floatBitsToUint", nullptr },
314 { EOpIntBitsToFloat, "intBitsToFloat", nullptr },
315 { EOpUintBitsToFloat, "uintBitsToFloat", nullptr },
317 { EOpTextureQuerySize, "textureSize", nullptr },
318 { EOpTextureQueryLod, "textureQueryLod", nullptr },
319 { EOpTextureQueryLevels, "textureQueryLevels", nullptr },
320 { EOpTextureQuerySamples, "textureSamples", nullptr },
321 { EOpTexture, "texture", nullptr },
322 { EOpTextureProj, "textureProj", nullptr },
323 { EOpTextureLod, "textureLod", nullptr },
324 { EOpTextureOffset, "textureOffset", nullptr },
325 { EOpTextureFetch, "texelFetch", nullptr },
326 { EOpTextureFetchOffset, "texelFetchOffset", nullptr },
327 { EOpTextureProjOffset, "textureProjOffset", nullptr },
328 { EOpTextureLodOffset, "textureLodOffset", nullptr },
329 { EOpTextureProjLod, "textureProjLod", nullptr },
330 { EOpTextureProjLodOffset, "textureProjLodOffset", nullptr },
331 { EOpTextureGrad, "textureGrad", nullptr },
332 { EOpTextureGradOffset, "textureGradOffset", nullptr },
333 { EOpTextureProjGrad, "textureProjGrad", nullptr },
334 { EOpTextureProjGradOffset, "textureProjGradOffset", nullptr },
339 // For the given table of functions, add all the indicated prototypes for each
340 // one, to be returned in the passed in decls.
341 void AddTabledBuiltin(TString& decls, const BuiltInFunction& function)
343 const auto isScalarType = [](int type) { return (type & TypeStringColumnMask) == 0; };
345 // loop across these two:
346 // 0: the varying arg set, and
347 // 1: the fixed scalar args
348 const ArgClass ClassFixed = (ArgClass)(ClassLS | ClassXLS | ClassLS2 | ClassFS | ClassFS2);
349 for (int fixed = 0; fixed < ((function.classes & ClassFixed) > 0 ? 2 : 1); ++fixed) {
351 if (fixed == 0 && (function.classes & ClassXLS))
354 // walk the type strings in TypeString[]
355 for (int type = 0; type < TypeStringCount; ++type) {
356 // skip types not selected: go from type to row number to type bit
357 if ((function.types & (1 << (type >> TypeStringRowShift))) == 0)
360 // if we aren't on a scalar, and should be, skip
361 if ((function.classes & ClassV1) && !isScalarType(type))
364 // if we aren't on a 3-vector, and should be, skip
365 if ((function.classes & ClassV3) && (type & TypeStringColumnMask) != 2)
368 // skip replication of all arg scalars between the varying arg set and the fixed args
369 if (fixed == 1 && type == (type & TypeStringScalarMask) && (function.classes & ClassXLS) == 0)
372 // skip scalars when we are told to
373 if ((function.classes & ClassNS) && isScalarType(type))
377 if (function.classes & ClassB)
378 decls.append(TypeString[type & TypeStringColumnMask]);
379 else if (function.classes & ClassRS)
380 decls.append(TypeString[type & TypeStringScalarMask]);
382 decls.append(TypeString[type]);
384 decls.append(function.name);
388 for (int arg = 0; arg < function.numArguments; ++arg) {
389 if (arg == function.numArguments - 1 && (function.classes & ClassLO))
390 decls.append("out ");
393 if (function.classes & ClassCV)
394 decls.append("coherent volatile ");
396 if (function.classes & ClassFIO)
397 decls.append("inout ");
398 if (function.classes & ClassFO)
399 decls.append("out ");
401 if ((function.classes & ClassLB) && arg == function.numArguments - 1)
402 decls.append(TypeString[type & TypeStringColumnMask]);
403 else if (fixed && ((arg == function.numArguments - 1 && (function.classes & (ClassLS | ClassXLS |
405 (arg == function.numArguments - 2 && (function.classes & ClassLS2)) ||
406 (arg == 0 && (function.classes & (ClassFS | ClassFS2))) ||
407 (arg == 1 && (function.classes & ClassFS2))))
408 decls.append(TypeString[type & TypeStringScalarMask]);
410 decls.append(TypeString[type]);
411 if (arg < function.numArguments - 1)
414 decls.append(");\n");
419 // See if the tabled versioning information allows the current version.
420 bool ValidVersion(const BuiltInFunction& function, int version, EProfile profile, const SpvVersion& /* spVersion */)
422 #if defined(GLSLANG_WEB) || defined(GLSLANG_ANGLE)
423 // all entries in table are valid
427 // nullptr means always valid
428 if (function.versioning == nullptr)
431 // check for what is said about our current profile
432 for (const Versioning* v = function.versioning; v->profiles != EBadProfile; ++v) {
433 if ((v->profiles & profile) != 0) {
434 if (v->minCoreVersion <= version || (v->numExtensions > 0 && v->minExtendedVersion <= version))
442 // Relate a single table of built-ins to their AST operator.
443 // This can get called redundantly (especially for the common built-ins, when
444 // called once per stage). This is a performance issue only, not a correctness
445 // concern. It is done for quality arising from simplicity, as there are subtleties
446 // to get correct if instead trying to do it surgically.
447 template<class FunctionT>
448 void RelateTabledBuiltins(const FunctionT* functions, TSymbolTable& symbolTable)
450 while (functions->op != EOpNull) {
451 symbolTable.relateToOperator(functions->name, functions->op);
456 } // end anonymous namespace
458 // Add declarations for all tables of built-in functions.
459 void TBuiltIns::addTabledBuiltins(int version, EProfile profile, const SpvVersion& spvVersion)
461 const auto forEachFunction = [&](TString& decls, const BuiltInFunction* function) {
462 while (function->op != EOpNull) {
463 if (ValidVersion(*function, version, profile, spvVersion))
464 AddTabledBuiltin(decls, *function);
469 forEachFunction(commonBuiltins, BaseFunctions);
470 forEachFunction(stageBuiltins[EShLangFragment], DerivativeFunctions);
472 if ((profile == EEsProfile && version >= 320) || (profile != EEsProfile && version >= 450))
473 forEachFunction(stageBuiltins[EShLangCompute], DerivativeFunctions);
476 // Relate all tables of built-ins to the AST operators.
477 void TBuiltIns::relateTabledBuiltins(int /* version */, EProfile /* profile */, const SpvVersion& /* spvVersion */, EShLanguage /* stage */, TSymbolTable& symbolTable)
479 RelateTabledBuiltins(BaseFunctions, symbolTable);
480 RelateTabledBuiltins(DerivativeFunctions, symbolTable);
481 RelateTabledBuiltins(CustomFunctions, symbolTable);
484 inline bool IncludeLegacy(int version, EProfile profile, const SpvVersion& spvVersion)
486 return profile != EEsProfile && (version <= 130 || (spvVersion.spv == 0 && version == 140 && ARBCompatibility) ||
487 profile == ECompatibilityProfile);
490 // Construct TBuiltInParseables base class. This can be used for language-common constructs.
491 TBuiltInParseables::TBuiltInParseables()
495 // Destroy TBuiltInParseables.
496 TBuiltInParseables::~TBuiltInParseables()
500 TBuiltIns::TBuiltIns()
502 // Set up textual representations for making all the permutations
503 // of texturing/imaging functions.
504 prefixes[EbtFloat] = "";
505 prefixes[EbtInt] = "i";
506 prefixes[EbtUint] = "u";
507 #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
508 prefixes[EbtFloat16] = "f16";
509 prefixes[EbtInt8] = "i8";
510 prefixes[EbtUint8] = "u8";
511 prefixes[EbtInt16] = "i16";
512 prefixes[EbtUint16] = "u16";
513 prefixes[EbtInt64] = "i64";
514 prefixes[EbtUint64] = "u64";
521 // Map from symbolic class of texturing dimension to numeric dimensions.
526 #ifndef GLSLANG_ANGLE
530 dimMap[EsdBuffer] = 1;
531 dimMap[EsdSubpass] = 2; // potentially unused for now
535 TBuiltIns::~TBuiltIns()
541 // Add all context-independent built-in functions and variables that are present
542 // for the given version and profile. Share common ones across stages, otherwise
543 // make stage-specific entries.
545 // Most built-ins variables can be added as simple text strings. Some need to
546 // be added programmatically, which is done later in IdentifyBuiltIns() below.
548 void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvVersion)
552 profile = EEsProfile;
553 #elif defined(GLSLANG_ANGLE)
555 profile = ECoreProfile;
557 addTabledBuiltins(version, profile, spvVersion);
559 //============================================================================
561 // Prototypes for built-in functions used repeatly by different shaders
563 //============================================================================
567 // Derivatives Functions.
569 TString derivativeControls (
570 "float dFdxFine(float p);"
571 "vec2 dFdxFine(vec2 p);"
572 "vec3 dFdxFine(vec3 p);"
573 "vec4 dFdxFine(vec4 p);"
575 "float dFdyFine(float p);"
576 "vec2 dFdyFine(vec2 p);"
577 "vec3 dFdyFine(vec3 p);"
578 "vec4 dFdyFine(vec4 p);"
580 "float fwidthFine(float p);"
581 "vec2 fwidthFine(vec2 p);"
582 "vec3 fwidthFine(vec3 p);"
583 "vec4 fwidthFine(vec4 p);"
585 "float dFdxCoarse(float p);"
586 "vec2 dFdxCoarse(vec2 p);"
587 "vec3 dFdxCoarse(vec3 p);"
588 "vec4 dFdxCoarse(vec4 p);"
590 "float dFdyCoarse(float p);"
591 "vec2 dFdyCoarse(vec2 p);"
592 "vec3 dFdyCoarse(vec3 p);"
593 "vec4 dFdyCoarse(vec4 p);"
595 "float fwidthCoarse(float p);"
596 "vec2 fwidthCoarse(vec2 p);"
597 "vec3 fwidthCoarse(vec3 p);"
598 "vec4 fwidthCoarse(vec4 p);"
601 #ifndef GLSLANG_ANGLE
602 TString derivativesAndControl16bits (
603 "float16_t dFdx(float16_t);"
604 "f16vec2 dFdx(f16vec2);"
605 "f16vec3 dFdx(f16vec3);"
606 "f16vec4 dFdx(f16vec4);"
608 "float16_t dFdy(float16_t);"
609 "f16vec2 dFdy(f16vec2);"
610 "f16vec3 dFdy(f16vec3);"
611 "f16vec4 dFdy(f16vec4);"
613 "float16_t dFdxFine(float16_t);"
614 "f16vec2 dFdxFine(f16vec2);"
615 "f16vec3 dFdxFine(f16vec3);"
616 "f16vec4 dFdxFine(f16vec4);"
618 "float16_t dFdyFine(float16_t);"
619 "f16vec2 dFdyFine(f16vec2);"
620 "f16vec3 dFdyFine(f16vec3);"
621 "f16vec4 dFdyFine(f16vec4);"
623 "float16_t dFdxCoarse(float16_t);"
624 "f16vec2 dFdxCoarse(f16vec2);"
625 "f16vec3 dFdxCoarse(f16vec3);"
626 "f16vec4 dFdxCoarse(f16vec4);"
628 "float16_t dFdyCoarse(float16_t);"
629 "f16vec2 dFdyCoarse(f16vec2);"
630 "f16vec3 dFdyCoarse(f16vec3);"
631 "f16vec4 dFdyCoarse(f16vec4);"
633 "float16_t fwidth(float16_t);"
634 "f16vec2 fwidth(f16vec2);"
635 "f16vec3 fwidth(f16vec3);"
636 "f16vec4 fwidth(f16vec4);"
638 "float16_t fwidthFine(float16_t);"
639 "f16vec2 fwidthFine(f16vec2);"
640 "f16vec3 fwidthFine(f16vec3);"
641 "f16vec4 fwidthFine(f16vec4);"
643 "float16_t fwidthCoarse(float16_t);"
644 "f16vec2 fwidthCoarse(f16vec2);"
645 "f16vec3 fwidthCoarse(f16vec3);"
646 "f16vec4 fwidthCoarse(f16vec4);"
649 TString derivativesAndControl64bits (
650 "float64_t dFdx(float64_t);"
651 "f64vec2 dFdx(f64vec2);"
652 "f64vec3 dFdx(f64vec3);"
653 "f64vec4 dFdx(f64vec4);"
655 "float64_t dFdy(float64_t);"
656 "f64vec2 dFdy(f64vec2);"
657 "f64vec3 dFdy(f64vec3);"
658 "f64vec4 dFdy(f64vec4);"
660 "float64_t dFdxFine(float64_t);"
661 "f64vec2 dFdxFine(f64vec2);"
662 "f64vec3 dFdxFine(f64vec3);"
663 "f64vec4 dFdxFine(f64vec4);"
665 "float64_t dFdyFine(float64_t);"
666 "f64vec2 dFdyFine(f64vec2);"
667 "f64vec3 dFdyFine(f64vec3);"
668 "f64vec4 dFdyFine(f64vec4);"
670 "float64_t dFdxCoarse(float64_t);"
671 "f64vec2 dFdxCoarse(f64vec2);"
672 "f64vec3 dFdxCoarse(f64vec3);"
673 "f64vec4 dFdxCoarse(f64vec4);"
675 "float64_t dFdyCoarse(float64_t);"
676 "f64vec2 dFdyCoarse(f64vec2);"
677 "f64vec3 dFdyCoarse(f64vec3);"
678 "f64vec4 dFdyCoarse(f64vec4);"
680 "float64_t fwidth(float64_t);"
681 "f64vec2 fwidth(f64vec2);"
682 "f64vec3 fwidth(f64vec3);"
683 "f64vec4 fwidth(f64vec4);"
685 "float64_t fwidthFine(float64_t);"
686 "f64vec2 fwidthFine(f64vec2);"
687 "f64vec3 fwidthFine(f64vec3);"
688 "f64vec4 fwidthFine(f64vec4);"
690 "float64_t fwidthCoarse(float64_t);"
691 "f64vec2 fwidthCoarse(f64vec2);"
692 "f64vec3 fwidthCoarse(f64vec3);"
693 "f64vec4 fwidthCoarse(f64vec4);"
696 //============================================================================
698 // Prototypes for built-in functions seen by both vertex and fragment shaders.
700 //============================================================================
703 // double functions added to desktop 4.00, but not fma, frexp, ldexp, or pack/unpack
705 if (profile != EEsProfile && version >= 150) { // ARB_gpu_shader_fp64
706 commonBuiltins.append(
708 "double sqrt(double);"
713 "double inversesqrt(double);"
714 "dvec2 inversesqrt(dvec2);"
715 "dvec3 inversesqrt(dvec3);"
716 "dvec4 inversesqrt(dvec4);"
718 "double abs(double);"
723 "double sign(double);"
728 "double floor(double);"
729 "dvec2 floor(dvec2);"
730 "dvec3 floor(dvec3);"
731 "dvec4 floor(dvec4);"
733 "double trunc(double);"
734 "dvec2 trunc(dvec2);"
735 "dvec3 trunc(dvec3);"
736 "dvec4 trunc(dvec4);"
738 "double round(double);"
739 "dvec2 round(dvec2);"
740 "dvec3 round(dvec3);"
741 "dvec4 round(dvec4);"
743 "double roundEven(double);"
744 "dvec2 roundEven(dvec2);"
745 "dvec3 roundEven(dvec3);"
746 "dvec4 roundEven(dvec4);"
748 "double ceil(double);"
753 "double fract(double);"
754 "dvec2 fract(dvec2);"
755 "dvec3 fract(dvec3);"
756 "dvec4 fract(dvec4);"
758 "double mod(double, double);"
759 "dvec2 mod(dvec2 , double);"
760 "dvec3 mod(dvec3 , double);"
761 "dvec4 mod(dvec4 , double);"
762 "dvec2 mod(dvec2 , dvec2);"
763 "dvec3 mod(dvec3 , dvec3);"
764 "dvec4 mod(dvec4 , dvec4);"
766 "double modf(double, out double);"
767 "dvec2 modf(dvec2, out dvec2);"
768 "dvec3 modf(dvec3, out dvec3);"
769 "dvec4 modf(dvec4, out dvec4);"
771 "double min(double, double);"
772 "dvec2 min(dvec2, double);"
773 "dvec3 min(dvec3, double);"
774 "dvec4 min(dvec4, double);"
775 "dvec2 min(dvec2, dvec2);"
776 "dvec3 min(dvec3, dvec3);"
777 "dvec4 min(dvec4, dvec4);"
779 "double max(double, double);"
780 "dvec2 max(dvec2 , double);"
781 "dvec3 max(dvec3 , double);"
782 "dvec4 max(dvec4 , double);"
783 "dvec2 max(dvec2 , dvec2);"
784 "dvec3 max(dvec3 , dvec3);"
785 "dvec4 max(dvec4 , dvec4);"
787 "double clamp(double, double, double);"
788 "dvec2 clamp(dvec2 , double, double);"
789 "dvec3 clamp(dvec3 , double, double);"
790 "dvec4 clamp(dvec4 , double, double);"
791 "dvec2 clamp(dvec2 , dvec2 , dvec2);"
792 "dvec3 clamp(dvec3 , dvec3 , dvec3);"
793 "dvec4 clamp(dvec4 , dvec4 , dvec4);"
795 "double mix(double, double, double);"
796 "dvec2 mix(dvec2, dvec2, double);"
797 "dvec3 mix(dvec3, dvec3, double);"
798 "dvec4 mix(dvec4, dvec4, double);"
799 "dvec2 mix(dvec2, dvec2, dvec2);"
800 "dvec3 mix(dvec3, dvec3, dvec3);"
801 "dvec4 mix(dvec4, dvec4, dvec4);"
802 "double mix(double, double, bool);"
803 "dvec2 mix(dvec2, dvec2, bvec2);"
804 "dvec3 mix(dvec3, dvec3, bvec3);"
805 "dvec4 mix(dvec4, dvec4, bvec4);"
807 "double step(double, double);"
808 "dvec2 step(dvec2 , dvec2);"
809 "dvec3 step(dvec3 , dvec3);"
810 "dvec4 step(dvec4 , dvec4);"
811 "dvec2 step(double, dvec2);"
812 "dvec3 step(double, dvec3);"
813 "dvec4 step(double, dvec4);"
815 "double smoothstep(double, double, double);"
816 "dvec2 smoothstep(dvec2 , dvec2 , dvec2);"
817 "dvec3 smoothstep(dvec3 , dvec3 , dvec3);"
818 "dvec4 smoothstep(dvec4 , dvec4 , dvec4);"
819 "dvec2 smoothstep(double, double, dvec2);"
820 "dvec3 smoothstep(double, double, dvec3);"
821 "dvec4 smoothstep(double, double, dvec4);"
823 "bool isnan(double);"
824 "bvec2 isnan(dvec2);"
825 "bvec3 isnan(dvec3);"
826 "bvec4 isnan(dvec4);"
828 "bool isinf(double);"
829 "bvec2 isinf(dvec2);"
830 "bvec3 isinf(dvec3);"
831 "bvec4 isinf(dvec4);"
833 "double length(double);"
834 "double length(dvec2);"
835 "double length(dvec3);"
836 "double length(dvec4);"
838 "double distance(double, double);"
839 "double distance(dvec2 , dvec2);"
840 "double distance(dvec3 , dvec3);"
841 "double distance(dvec4 , dvec4);"
843 "double dot(double, double);"
844 "double dot(dvec2 , dvec2);"
845 "double dot(dvec3 , dvec3);"
846 "double dot(dvec4 , dvec4);"
848 "dvec3 cross(dvec3, dvec3);"
850 "double normalize(double);"
851 "dvec2 normalize(dvec2);"
852 "dvec3 normalize(dvec3);"
853 "dvec4 normalize(dvec4);"
855 "double faceforward(double, double, double);"
856 "dvec2 faceforward(dvec2, dvec2, dvec2);"
857 "dvec3 faceforward(dvec3, dvec3, dvec3);"
858 "dvec4 faceforward(dvec4, dvec4, dvec4);"
860 "double reflect(double, double);"
861 "dvec2 reflect(dvec2 , dvec2 );"
862 "dvec3 reflect(dvec3 , dvec3 );"
863 "dvec4 reflect(dvec4 , dvec4 );"
865 "double refract(double, double, double);"
866 "dvec2 refract(dvec2 , dvec2 , double);"
867 "dvec3 refract(dvec3 , dvec3 , double);"
868 "dvec4 refract(dvec4 , dvec4 , double);"
870 "dmat2 matrixCompMult(dmat2, dmat2);"
871 "dmat3 matrixCompMult(dmat3, dmat3);"
872 "dmat4 matrixCompMult(dmat4, dmat4);"
873 "dmat2x3 matrixCompMult(dmat2x3, dmat2x3);"
874 "dmat2x4 matrixCompMult(dmat2x4, dmat2x4);"
875 "dmat3x2 matrixCompMult(dmat3x2, dmat3x2);"
876 "dmat3x4 matrixCompMult(dmat3x4, dmat3x4);"
877 "dmat4x2 matrixCompMult(dmat4x2, dmat4x2);"
878 "dmat4x3 matrixCompMult(dmat4x3, dmat4x3);"
880 "dmat2 outerProduct(dvec2, dvec2);"
881 "dmat3 outerProduct(dvec3, dvec3);"
882 "dmat4 outerProduct(dvec4, dvec4);"
883 "dmat2x3 outerProduct(dvec3, dvec2);"
884 "dmat3x2 outerProduct(dvec2, dvec3);"
885 "dmat2x4 outerProduct(dvec4, dvec2);"
886 "dmat4x2 outerProduct(dvec2, dvec4);"
887 "dmat3x4 outerProduct(dvec4, dvec3);"
888 "dmat4x3 outerProduct(dvec3, dvec4);"
890 "dmat2 transpose(dmat2);"
891 "dmat3 transpose(dmat3);"
892 "dmat4 transpose(dmat4);"
893 "dmat2x3 transpose(dmat3x2);"
894 "dmat3x2 transpose(dmat2x3);"
895 "dmat2x4 transpose(dmat4x2);"
896 "dmat4x2 transpose(dmat2x4);"
897 "dmat3x4 transpose(dmat4x3);"
898 "dmat4x3 transpose(dmat3x4);"
900 "double determinant(dmat2);"
901 "double determinant(dmat3);"
902 "double determinant(dmat4);"
904 "dmat2 inverse(dmat2);"
905 "dmat3 inverse(dmat3);"
906 "dmat4 inverse(dmat4);"
908 "bvec2 lessThan(dvec2, dvec2);"
909 "bvec3 lessThan(dvec3, dvec3);"
910 "bvec4 lessThan(dvec4, dvec4);"
912 "bvec2 lessThanEqual(dvec2, dvec2);"
913 "bvec3 lessThanEqual(dvec3, dvec3);"
914 "bvec4 lessThanEqual(dvec4, dvec4);"
916 "bvec2 greaterThan(dvec2, dvec2);"
917 "bvec3 greaterThan(dvec3, dvec3);"
918 "bvec4 greaterThan(dvec4, dvec4);"
920 "bvec2 greaterThanEqual(dvec2, dvec2);"
921 "bvec3 greaterThanEqual(dvec3, dvec3);"
922 "bvec4 greaterThanEqual(dvec4, dvec4);"
924 "bvec2 equal(dvec2, dvec2);"
925 "bvec3 equal(dvec3, dvec3);"
926 "bvec4 equal(dvec4, dvec4);"
928 "bvec2 notEqual(dvec2, dvec2);"
929 "bvec3 notEqual(dvec3, dvec3);"
930 "bvec4 notEqual(dvec4, dvec4);"
935 if (profile == EEsProfile && version >= 310) { // Explicit Types
936 commonBuiltins.append(
938 "float64_t sqrt(float64_t);"
939 "f64vec2 sqrt(f64vec2);"
940 "f64vec3 sqrt(f64vec3);"
941 "f64vec4 sqrt(f64vec4);"
943 "float64_t inversesqrt(float64_t);"
944 "f64vec2 inversesqrt(f64vec2);"
945 "f64vec3 inversesqrt(f64vec3);"
946 "f64vec4 inversesqrt(f64vec4);"
948 "float64_t abs(float64_t);"
949 "f64vec2 abs(f64vec2);"
950 "f64vec3 abs(f64vec3);"
951 "f64vec4 abs(f64vec4);"
953 "float64_t sign(float64_t);"
954 "f64vec2 sign(f64vec2);"
955 "f64vec3 sign(f64vec3);"
956 "f64vec4 sign(f64vec4);"
958 "float64_t floor(float64_t);"
959 "f64vec2 floor(f64vec2);"
960 "f64vec3 floor(f64vec3);"
961 "f64vec4 floor(f64vec4);"
963 "float64_t trunc(float64_t);"
964 "f64vec2 trunc(f64vec2);"
965 "f64vec3 trunc(f64vec3);"
966 "f64vec4 trunc(f64vec4);"
968 "float64_t round(float64_t);"
969 "f64vec2 round(f64vec2);"
970 "f64vec3 round(f64vec3);"
971 "f64vec4 round(f64vec4);"
973 "float64_t roundEven(float64_t);"
974 "f64vec2 roundEven(f64vec2);"
975 "f64vec3 roundEven(f64vec3);"
976 "f64vec4 roundEven(f64vec4);"
978 "float64_t ceil(float64_t);"
979 "f64vec2 ceil(f64vec2);"
980 "f64vec3 ceil(f64vec3);"
981 "f64vec4 ceil(f64vec4);"
983 "float64_t fract(float64_t);"
984 "f64vec2 fract(f64vec2);"
985 "f64vec3 fract(f64vec3);"
986 "f64vec4 fract(f64vec4);"
988 "float64_t mod(float64_t, float64_t);"
989 "f64vec2 mod(f64vec2 , float64_t);"
990 "f64vec3 mod(f64vec3 , float64_t);"
991 "f64vec4 mod(f64vec4 , float64_t);"
992 "f64vec2 mod(f64vec2 , f64vec2);"
993 "f64vec3 mod(f64vec3 , f64vec3);"
994 "f64vec4 mod(f64vec4 , f64vec4);"
996 "float64_t modf(float64_t, out float64_t);"
997 "f64vec2 modf(f64vec2, out f64vec2);"
998 "f64vec3 modf(f64vec3, out f64vec3);"
999 "f64vec4 modf(f64vec4, out f64vec4);"
1001 "float64_t min(float64_t, float64_t);"
1002 "f64vec2 min(f64vec2, float64_t);"
1003 "f64vec3 min(f64vec3, float64_t);"
1004 "f64vec4 min(f64vec4, float64_t);"
1005 "f64vec2 min(f64vec2, f64vec2);"
1006 "f64vec3 min(f64vec3, f64vec3);"
1007 "f64vec4 min(f64vec4, f64vec4);"
1009 "float64_t max(float64_t, float64_t);"
1010 "f64vec2 max(f64vec2 , float64_t);"
1011 "f64vec3 max(f64vec3 , float64_t);"
1012 "f64vec4 max(f64vec4 , float64_t);"
1013 "f64vec2 max(f64vec2 , f64vec2);"
1014 "f64vec3 max(f64vec3 , f64vec3);"
1015 "f64vec4 max(f64vec4 , f64vec4);"
1017 "float64_t clamp(float64_t, float64_t, float64_t);"
1018 "f64vec2 clamp(f64vec2 , float64_t, float64_t);"
1019 "f64vec3 clamp(f64vec3 , float64_t, float64_t);"
1020 "f64vec4 clamp(f64vec4 , float64_t, float64_t);"
1021 "f64vec2 clamp(f64vec2 , f64vec2 , f64vec2);"
1022 "f64vec3 clamp(f64vec3 , f64vec3 , f64vec3);"
1023 "f64vec4 clamp(f64vec4 , f64vec4 , f64vec4);"
1025 "float64_t mix(float64_t, float64_t, float64_t);"
1026 "f64vec2 mix(f64vec2, f64vec2, float64_t);"
1027 "f64vec3 mix(f64vec3, f64vec3, float64_t);"
1028 "f64vec4 mix(f64vec4, f64vec4, float64_t);"
1029 "f64vec2 mix(f64vec2, f64vec2, f64vec2);"
1030 "f64vec3 mix(f64vec3, f64vec3, f64vec3);"
1031 "f64vec4 mix(f64vec4, f64vec4, f64vec4);"
1032 "float64_t mix(float64_t, float64_t, bool);"
1033 "f64vec2 mix(f64vec2, f64vec2, bvec2);"
1034 "f64vec3 mix(f64vec3, f64vec3, bvec3);"
1035 "f64vec4 mix(f64vec4, f64vec4, bvec4);"
1037 "float64_t step(float64_t, float64_t);"
1038 "f64vec2 step(f64vec2 , f64vec2);"
1039 "f64vec3 step(f64vec3 , f64vec3);"
1040 "f64vec4 step(f64vec4 , f64vec4);"
1041 "f64vec2 step(float64_t, f64vec2);"
1042 "f64vec3 step(float64_t, f64vec3);"
1043 "f64vec4 step(float64_t, f64vec4);"
1045 "float64_t smoothstep(float64_t, float64_t, float64_t);"
1046 "f64vec2 smoothstep(f64vec2 , f64vec2 , f64vec2);"
1047 "f64vec3 smoothstep(f64vec3 , f64vec3 , f64vec3);"
1048 "f64vec4 smoothstep(f64vec4 , f64vec4 , f64vec4);"
1049 "f64vec2 smoothstep(float64_t, float64_t, f64vec2);"
1050 "f64vec3 smoothstep(float64_t, float64_t, f64vec3);"
1051 "f64vec4 smoothstep(float64_t, float64_t, f64vec4);"
1053 "float64_t length(float64_t);"
1054 "float64_t length(f64vec2);"
1055 "float64_t length(f64vec3);"
1056 "float64_t length(f64vec4);"
1058 "float64_t distance(float64_t, float64_t);"
1059 "float64_t distance(f64vec2 , f64vec2);"
1060 "float64_t distance(f64vec3 , f64vec3);"
1061 "float64_t distance(f64vec4 , f64vec4);"
1063 "float64_t dot(float64_t, float64_t);"
1064 "float64_t dot(f64vec2 , f64vec2);"
1065 "float64_t dot(f64vec3 , f64vec3);"
1066 "float64_t dot(f64vec4 , f64vec4);"
1068 "f64vec3 cross(f64vec3, f64vec3);"
1070 "float64_t normalize(float64_t);"
1071 "f64vec2 normalize(f64vec2);"
1072 "f64vec3 normalize(f64vec3);"
1073 "f64vec4 normalize(f64vec4);"
1075 "float64_t faceforward(float64_t, float64_t, float64_t);"
1076 "f64vec2 faceforward(f64vec2, f64vec2, f64vec2);"
1077 "f64vec3 faceforward(f64vec3, f64vec3, f64vec3);"
1078 "f64vec4 faceforward(f64vec4, f64vec4, f64vec4);"
1080 "float64_t reflect(float64_t, float64_t);"
1081 "f64vec2 reflect(f64vec2 , f64vec2 );"
1082 "f64vec3 reflect(f64vec3 , f64vec3 );"
1083 "f64vec4 reflect(f64vec4 , f64vec4 );"
1085 "float64_t refract(float64_t, float64_t, float64_t);"
1086 "f64vec2 refract(f64vec2 , f64vec2 , float64_t);"
1087 "f64vec3 refract(f64vec3 , f64vec3 , float64_t);"
1088 "f64vec4 refract(f64vec4 , f64vec4 , float64_t);"
1090 "f64mat2 matrixCompMult(f64mat2, f64mat2);"
1091 "f64mat3 matrixCompMult(f64mat3, f64mat3);"
1092 "f64mat4 matrixCompMult(f64mat4, f64mat4);"
1093 "f64mat2x3 matrixCompMult(f64mat2x3, f64mat2x3);"
1094 "f64mat2x4 matrixCompMult(f64mat2x4, f64mat2x4);"
1095 "f64mat3x2 matrixCompMult(f64mat3x2, f64mat3x2);"
1096 "f64mat3x4 matrixCompMult(f64mat3x4, f64mat3x4);"
1097 "f64mat4x2 matrixCompMult(f64mat4x2, f64mat4x2);"
1098 "f64mat4x3 matrixCompMult(f64mat4x3, f64mat4x3);"
1100 "f64mat2 outerProduct(f64vec2, f64vec2);"
1101 "f64mat3 outerProduct(f64vec3, f64vec3);"
1102 "f64mat4 outerProduct(f64vec4, f64vec4);"
1103 "f64mat2x3 outerProduct(f64vec3, f64vec2);"
1104 "f64mat3x2 outerProduct(f64vec2, f64vec3);"
1105 "f64mat2x4 outerProduct(f64vec4, f64vec2);"
1106 "f64mat4x2 outerProduct(f64vec2, f64vec4);"
1107 "f64mat3x4 outerProduct(f64vec4, f64vec3);"
1108 "f64mat4x3 outerProduct(f64vec3, f64vec4);"
1110 "f64mat2 transpose(f64mat2);"
1111 "f64mat3 transpose(f64mat3);"
1112 "f64mat4 transpose(f64mat4);"
1113 "f64mat2x3 transpose(f64mat3x2);"
1114 "f64mat3x2 transpose(f64mat2x3);"
1115 "f64mat2x4 transpose(f64mat4x2);"
1116 "f64mat4x2 transpose(f64mat2x4);"
1117 "f64mat3x4 transpose(f64mat4x3);"
1118 "f64mat4x3 transpose(f64mat3x4);"
1120 "float64_t determinant(f64mat2);"
1121 "float64_t determinant(f64mat3);"
1122 "float64_t determinant(f64mat4);"
1124 "f64mat2 inverse(f64mat2);"
1125 "f64mat3 inverse(f64mat3);"
1126 "f64mat4 inverse(f64mat4);"
1131 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 310)) {
1132 commonBuiltins.append(
1134 "int64_t abs(int64_t);"
1135 "i64vec2 abs(i64vec2);"
1136 "i64vec3 abs(i64vec3);"
1137 "i64vec4 abs(i64vec4);"
1139 "int64_t sign(int64_t);"
1140 "i64vec2 sign(i64vec2);"
1141 "i64vec3 sign(i64vec3);"
1142 "i64vec4 sign(i64vec4);"
1144 "int64_t min(int64_t, int64_t);"
1145 "i64vec2 min(i64vec2, int64_t);"
1146 "i64vec3 min(i64vec3, int64_t);"
1147 "i64vec4 min(i64vec4, int64_t);"
1148 "i64vec2 min(i64vec2, i64vec2);"
1149 "i64vec3 min(i64vec3, i64vec3);"
1150 "i64vec4 min(i64vec4, i64vec4);"
1151 "uint64_t min(uint64_t, uint64_t);"
1152 "u64vec2 min(u64vec2, uint64_t);"
1153 "u64vec3 min(u64vec3, uint64_t);"
1154 "u64vec4 min(u64vec4, uint64_t);"
1155 "u64vec2 min(u64vec2, u64vec2);"
1156 "u64vec3 min(u64vec3, u64vec3);"
1157 "u64vec4 min(u64vec4, u64vec4);"
1159 "int64_t max(int64_t, int64_t);"
1160 "i64vec2 max(i64vec2, int64_t);"
1161 "i64vec3 max(i64vec3, int64_t);"
1162 "i64vec4 max(i64vec4, int64_t);"
1163 "i64vec2 max(i64vec2, i64vec2);"
1164 "i64vec3 max(i64vec3, i64vec3);"
1165 "i64vec4 max(i64vec4, i64vec4);"
1166 "uint64_t max(uint64_t, uint64_t);"
1167 "u64vec2 max(u64vec2, uint64_t);"
1168 "u64vec3 max(u64vec3, uint64_t);"
1169 "u64vec4 max(u64vec4, uint64_t);"
1170 "u64vec2 max(u64vec2, u64vec2);"
1171 "u64vec3 max(u64vec3, u64vec3);"
1172 "u64vec4 max(u64vec4, u64vec4);"
1174 "int64_t clamp(int64_t, int64_t, int64_t);"
1175 "i64vec2 clamp(i64vec2, int64_t, int64_t);"
1176 "i64vec3 clamp(i64vec3, int64_t, int64_t);"
1177 "i64vec4 clamp(i64vec4, int64_t, int64_t);"
1178 "i64vec2 clamp(i64vec2, i64vec2, i64vec2);"
1179 "i64vec3 clamp(i64vec3, i64vec3, i64vec3);"
1180 "i64vec4 clamp(i64vec4, i64vec4, i64vec4);"
1181 "uint64_t clamp(uint64_t, uint64_t, uint64_t);"
1182 "u64vec2 clamp(u64vec2, uint64_t, uint64_t);"
1183 "u64vec3 clamp(u64vec3, uint64_t, uint64_t);"
1184 "u64vec4 clamp(u64vec4, uint64_t, uint64_t);"
1185 "u64vec2 clamp(u64vec2, u64vec2, u64vec2);"
1186 "u64vec3 clamp(u64vec3, u64vec3, u64vec3);"
1187 "u64vec4 clamp(u64vec4, u64vec4, u64vec4);"
1189 "int64_t mix(int64_t, int64_t, bool);"
1190 "i64vec2 mix(i64vec2, i64vec2, bvec2);"
1191 "i64vec3 mix(i64vec3, i64vec3, bvec3);"
1192 "i64vec4 mix(i64vec4, i64vec4, bvec4);"
1193 "uint64_t mix(uint64_t, uint64_t, bool);"
1194 "u64vec2 mix(u64vec2, u64vec2, bvec2);"
1195 "u64vec3 mix(u64vec3, u64vec3, bvec3);"
1196 "u64vec4 mix(u64vec4, u64vec4, bvec4);"
1198 "int64_t doubleBitsToInt64(float64_t);"
1199 "i64vec2 doubleBitsToInt64(f64vec2);"
1200 "i64vec3 doubleBitsToInt64(f64vec3);"
1201 "i64vec4 doubleBitsToInt64(f64vec4);"
1203 "uint64_t doubleBitsToUint64(float64_t);"
1204 "u64vec2 doubleBitsToUint64(f64vec2);"
1205 "u64vec3 doubleBitsToUint64(f64vec3);"
1206 "u64vec4 doubleBitsToUint64(f64vec4);"
1208 "float64_t int64BitsToDouble(int64_t);"
1209 "f64vec2 int64BitsToDouble(i64vec2);"
1210 "f64vec3 int64BitsToDouble(i64vec3);"
1211 "f64vec4 int64BitsToDouble(i64vec4);"
1213 "float64_t uint64BitsToDouble(uint64_t);"
1214 "f64vec2 uint64BitsToDouble(u64vec2);"
1215 "f64vec3 uint64BitsToDouble(u64vec3);"
1216 "f64vec4 uint64BitsToDouble(u64vec4);"
1218 "int64_t packInt2x32(ivec2);"
1219 "uint64_t packUint2x32(uvec2);"
1220 "ivec2 unpackInt2x32(int64_t);"
1221 "uvec2 unpackUint2x32(uint64_t);"
1223 "bvec2 lessThan(i64vec2, i64vec2);"
1224 "bvec3 lessThan(i64vec3, i64vec3);"
1225 "bvec4 lessThan(i64vec4, i64vec4);"
1226 "bvec2 lessThan(u64vec2, u64vec2);"
1227 "bvec3 lessThan(u64vec3, u64vec3);"
1228 "bvec4 lessThan(u64vec4, u64vec4);"
1230 "bvec2 lessThanEqual(i64vec2, i64vec2);"
1231 "bvec3 lessThanEqual(i64vec3, i64vec3);"
1232 "bvec4 lessThanEqual(i64vec4, i64vec4);"
1233 "bvec2 lessThanEqual(u64vec2, u64vec2);"
1234 "bvec3 lessThanEqual(u64vec3, u64vec3);"
1235 "bvec4 lessThanEqual(u64vec4, u64vec4);"
1237 "bvec2 greaterThan(i64vec2, i64vec2);"
1238 "bvec3 greaterThan(i64vec3, i64vec3);"
1239 "bvec4 greaterThan(i64vec4, i64vec4);"
1240 "bvec2 greaterThan(u64vec2, u64vec2);"
1241 "bvec3 greaterThan(u64vec3, u64vec3);"
1242 "bvec4 greaterThan(u64vec4, u64vec4);"
1244 "bvec2 greaterThanEqual(i64vec2, i64vec2);"
1245 "bvec3 greaterThanEqual(i64vec3, i64vec3);"
1246 "bvec4 greaterThanEqual(i64vec4, i64vec4);"
1247 "bvec2 greaterThanEqual(u64vec2, u64vec2);"
1248 "bvec3 greaterThanEqual(u64vec3, u64vec3);"
1249 "bvec4 greaterThanEqual(u64vec4, u64vec4);"
1251 "bvec2 equal(i64vec2, i64vec2);"
1252 "bvec3 equal(i64vec3, i64vec3);"
1253 "bvec4 equal(i64vec4, i64vec4);"
1254 "bvec2 equal(u64vec2, u64vec2);"
1255 "bvec3 equal(u64vec3, u64vec3);"
1256 "bvec4 equal(u64vec4, u64vec4);"
1258 "bvec2 notEqual(i64vec2, i64vec2);"
1259 "bvec3 notEqual(i64vec3, i64vec3);"
1260 "bvec4 notEqual(i64vec4, i64vec4);"
1261 "bvec2 notEqual(u64vec2, u64vec2);"
1262 "bvec3 notEqual(u64vec3, u64vec3);"
1263 "bvec4 notEqual(u64vec4, u64vec4);"
1265 "int64_t bitCount(int64_t);"
1266 "i64vec2 bitCount(i64vec2);"
1267 "i64vec3 bitCount(i64vec3);"
1268 "i64vec4 bitCount(i64vec4);"
1270 "int64_t bitCount(uint64_t);"
1271 "i64vec2 bitCount(u64vec2);"
1272 "i64vec3 bitCount(u64vec3);"
1273 "i64vec4 bitCount(u64vec4);"
1275 "int64_t findLSB(int64_t);"
1276 "i64vec2 findLSB(i64vec2);"
1277 "i64vec3 findLSB(i64vec3);"
1278 "i64vec4 findLSB(i64vec4);"
1280 "int64_t findLSB(uint64_t);"
1281 "i64vec2 findLSB(u64vec2);"
1282 "i64vec3 findLSB(u64vec3);"
1283 "i64vec4 findLSB(u64vec4);"
1285 "int64_t findMSB(int64_t);"
1286 "i64vec2 findMSB(i64vec2);"
1287 "i64vec3 findMSB(i64vec3);"
1288 "i64vec4 findMSB(i64vec4);"
1290 "int64_t findMSB(uint64_t);"
1291 "i64vec2 findMSB(u64vec2);"
1292 "i64vec3 findMSB(u64vec3);"
1293 "i64vec4 findMSB(u64vec4);"
1299 // GL_AMD_shader_trinary_minmax
1300 if (profile != EEsProfile && version >= 430) {
1301 commonBuiltins.append(
1302 "float min3(float, float, float);"
1303 "vec2 min3(vec2, vec2, vec2);"
1304 "vec3 min3(vec3, vec3, vec3);"
1305 "vec4 min3(vec4, vec4, vec4);"
1307 "int min3(int, int, int);"
1308 "ivec2 min3(ivec2, ivec2, ivec2);"
1309 "ivec3 min3(ivec3, ivec3, ivec3);"
1310 "ivec4 min3(ivec4, ivec4, ivec4);"
1312 "uint min3(uint, uint, uint);"
1313 "uvec2 min3(uvec2, uvec2, uvec2);"
1314 "uvec3 min3(uvec3, uvec3, uvec3);"
1315 "uvec4 min3(uvec4, uvec4, uvec4);"
1317 "float max3(float, float, float);"
1318 "vec2 max3(vec2, vec2, vec2);"
1319 "vec3 max3(vec3, vec3, vec3);"
1320 "vec4 max3(vec4, vec4, vec4);"
1322 "int max3(int, int, int);"
1323 "ivec2 max3(ivec2, ivec2, ivec2);"
1324 "ivec3 max3(ivec3, ivec3, ivec3);"
1325 "ivec4 max3(ivec4, ivec4, ivec4);"
1327 "uint max3(uint, uint, uint);"
1328 "uvec2 max3(uvec2, uvec2, uvec2);"
1329 "uvec3 max3(uvec3, uvec3, uvec3);"
1330 "uvec4 max3(uvec4, uvec4, uvec4);"
1332 "float mid3(float, float, float);"
1333 "vec2 mid3(vec2, vec2, vec2);"
1334 "vec3 mid3(vec3, vec3, vec3);"
1335 "vec4 mid3(vec4, vec4, vec4);"
1337 "int mid3(int, int, int);"
1338 "ivec2 mid3(ivec2, ivec2, ivec2);"
1339 "ivec3 mid3(ivec3, ivec3, ivec3);"
1340 "ivec4 mid3(ivec4, ivec4, ivec4);"
1342 "uint mid3(uint, uint, uint);"
1343 "uvec2 mid3(uvec2, uvec2, uvec2);"
1344 "uvec3 mid3(uvec3, uvec3, uvec3);"
1345 "uvec4 mid3(uvec4, uvec4, uvec4);"
1347 "float16_t min3(float16_t, float16_t, float16_t);"
1348 "f16vec2 min3(f16vec2, f16vec2, f16vec2);"
1349 "f16vec3 min3(f16vec3, f16vec3, f16vec3);"
1350 "f16vec4 min3(f16vec4, f16vec4, f16vec4);"
1352 "float16_t max3(float16_t, float16_t, float16_t);"
1353 "f16vec2 max3(f16vec2, f16vec2, f16vec2);"
1354 "f16vec3 max3(f16vec3, f16vec3, f16vec3);"
1355 "f16vec4 max3(f16vec4, f16vec4, f16vec4);"
1357 "float16_t mid3(float16_t, float16_t, float16_t);"
1358 "f16vec2 mid3(f16vec2, f16vec2, f16vec2);"
1359 "f16vec3 mid3(f16vec3, f16vec3, f16vec3);"
1360 "f16vec4 mid3(f16vec4, f16vec4, f16vec4);"
1362 "int16_t min3(int16_t, int16_t, int16_t);"
1363 "i16vec2 min3(i16vec2, i16vec2, i16vec2);"
1364 "i16vec3 min3(i16vec3, i16vec3, i16vec3);"
1365 "i16vec4 min3(i16vec4, i16vec4, i16vec4);"
1367 "int16_t max3(int16_t, int16_t, int16_t);"
1368 "i16vec2 max3(i16vec2, i16vec2, i16vec2);"
1369 "i16vec3 max3(i16vec3, i16vec3, i16vec3);"
1370 "i16vec4 max3(i16vec4, i16vec4, i16vec4);"
1372 "int16_t mid3(int16_t, int16_t, int16_t);"
1373 "i16vec2 mid3(i16vec2, i16vec2, i16vec2);"
1374 "i16vec3 mid3(i16vec3, i16vec3, i16vec3);"
1375 "i16vec4 mid3(i16vec4, i16vec4, i16vec4);"
1377 "uint16_t min3(uint16_t, uint16_t, uint16_t);"
1378 "u16vec2 min3(u16vec2, u16vec2, u16vec2);"
1379 "u16vec3 min3(u16vec3, u16vec3, u16vec3);"
1380 "u16vec4 min3(u16vec4, u16vec4, u16vec4);"
1382 "uint16_t max3(uint16_t, uint16_t, uint16_t);"
1383 "u16vec2 max3(u16vec2, u16vec2, u16vec2);"
1384 "u16vec3 max3(u16vec3, u16vec3, u16vec3);"
1385 "u16vec4 max3(u16vec4, u16vec4, u16vec4);"
1387 "uint16_t mid3(uint16_t, uint16_t, uint16_t);"
1388 "u16vec2 mid3(u16vec2, u16vec2, u16vec2);"
1389 "u16vec3 mid3(u16vec3, u16vec3, u16vec3);"
1390 "u16vec4 mid3(u16vec4, u16vec4, u16vec4);"
1395 #endif // !GLSLANG_ANGLE
1397 if ((profile == EEsProfile && version >= 310) ||
1398 (profile != EEsProfile && version >= 430)) {
1399 commonBuiltins.append(
1400 "uint atomicAdd(coherent volatile inout uint, uint, int, int, int);"
1401 " int atomicAdd(coherent volatile inout int, int, int, int, int);"
1403 "uint atomicMin(coherent volatile inout uint, uint, int, int, int);"
1404 " int atomicMin(coherent volatile inout int, int, int, int, int);"
1406 "uint atomicMax(coherent volatile inout uint, uint, int, int, int);"
1407 " int atomicMax(coherent volatile inout int, int, int, int, int);"
1409 "uint atomicAnd(coherent volatile inout uint, uint, int, int, int);"
1410 " int atomicAnd(coherent volatile inout int, int, int, int, int);"
1412 "uint atomicOr (coherent volatile inout uint, uint, int, int, int);"
1413 " int atomicOr (coherent volatile inout int, int, int, int, int);"
1415 "uint atomicXor(coherent volatile inout uint, uint, int, int, int);"
1416 " int atomicXor(coherent volatile inout int, int, int, int, int);"
1418 "uint atomicExchange(coherent volatile inout uint, uint, int, int, int);"
1419 " int atomicExchange(coherent volatile inout int, int, int, int, int);"
1421 "uint atomicCompSwap(coherent volatile inout uint, uint, uint, int, int, int, int, int);"
1422 " int atomicCompSwap(coherent volatile inout int, int, int, int, int, int, int, int);"
1424 "uint atomicLoad(coherent volatile in uint, int, int, int);"
1425 " int atomicLoad(coherent volatile in int, int, int, int);"
1427 "void atomicStore(coherent volatile out uint, uint, int, int, int);"
1428 "void atomicStore(coherent volatile out int, int, int, int, int);"
1433 #ifndef GLSLANG_ANGLE
1434 if (profile != EEsProfile && version >= 440) {
1435 commonBuiltins.append(
1436 "uint64_t atomicMin(coherent volatile inout uint64_t, uint64_t);"
1437 " int64_t atomicMin(coherent volatile inout int64_t, int64_t);"
1438 "uint64_t atomicMin(coherent volatile inout uint64_t, uint64_t, int, int, int);"
1439 " int64_t atomicMin(coherent volatile inout int64_t, int64_t, int, int, int);"
1440 "float16_t atomicMin(coherent volatile inout float16_t, float16_t);"
1441 "float16_t atomicMin(coherent volatile inout float16_t, float16_t, int, int, int);"
1442 " float atomicMin(coherent volatile inout float, float);"
1443 " float atomicMin(coherent volatile inout float, float, int, int, int);"
1444 " double atomicMin(coherent volatile inout double, double);"
1445 " double atomicMin(coherent volatile inout double, double, int, int, int);"
1447 "uint64_t atomicMax(coherent volatile inout uint64_t, uint64_t);"
1448 " int64_t atomicMax(coherent volatile inout int64_t, int64_t);"
1449 "uint64_t atomicMax(coherent volatile inout uint64_t, uint64_t, int, int, int);"
1450 " int64_t atomicMax(coherent volatile inout int64_t, int64_t, int, int, int);"
1451 "float16_t atomicMax(coherent volatile inout float16_t, float16_t);"
1452 "float16_t atomicMax(coherent volatile inout float16_t, float16_t, int, int, int);"
1453 " float atomicMax(coherent volatile inout float, float);"
1454 " float atomicMax(coherent volatile inout float, float, int, int, int);"
1455 " double atomicMax(coherent volatile inout double, double);"
1456 " double atomicMax(coherent volatile inout double, double, int, int, int);"
1458 "uint64_t atomicAnd(coherent volatile inout uint64_t, uint64_t);"
1459 " int64_t atomicAnd(coherent volatile inout int64_t, int64_t);"
1460 "uint64_t atomicAnd(coherent volatile inout uint64_t, uint64_t, int, int, int);"
1461 " int64_t atomicAnd(coherent volatile inout int64_t, int64_t, int, int, int);"
1463 "uint64_t atomicOr (coherent volatile inout uint64_t, uint64_t);"
1464 " int64_t atomicOr (coherent volatile inout int64_t, int64_t);"
1465 "uint64_t atomicOr (coherent volatile inout uint64_t, uint64_t, int, int, int);"
1466 " int64_t atomicOr (coherent volatile inout int64_t, int64_t, int, int, int);"
1468 "uint64_t atomicXor(coherent volatile inout uint64_t, uint64_t);"
1469 " int64_t atomicXor(coherent volatile inout int64_t, int64_t);"
1470 "uint64_t atomicXor(coherent volatile inout uint64_t, uint64_t, int, int, int);"
1471 " int64_t atomicXor(coherent volatile inout int64_t, int64_t, int, int, int);"
1473 "uint64_t atomicAdd(coherent volatile inout uint64_t, uint64_t);"
1474 " int64_t atomicAdd(coherent volatile inout int64_t, int64_t);"
1475 "uint64_t atomicAdd(coherent volatile inout uint64_t, uint64_t, int, int, int);"
1476 " int64_t atomicAdd(coherent volatile inout int64_t, int64_t, int, int, int);"
1477 "float16_t atomicAdd(coherent volatile inout float16_t, float16_t);"
1478 "float16_t atomicAdd(coherent volatile inout float16_t, float16_t, int, int, int);"
1479 " float atomicAdd(coherent volatile inout float, float);"
1480 " float atomicAdd(coherent volatile inout float, float, int, int, int);"
1481 " double atomicAdd(coherent volatile inout double, double);"
1482 " double atomicAdd(coherent volatile inout double, double, int, int, int);"
1484 "uint64_t atomicExchange(coherent volatile inout uint64_t, uint64_t);"
1485 " int64_t atomicExchange(coherent volatile inout int64_t, int64_t);"
1486 "uint64_t atomicExchange(coherent volatile inout uint64_t, uint64_t, int, int, int);"
1487 " int64_t atomicExchange(coherent volatile inout int64_t, int64_t, int, int, int);"
1488 "float16_t atomicExchange(coherent volatile inout float16_t, float16_t);"
1489 "float16_t atomicExchange(coherent volatile inout float16_t, float16_t, int, int, int);"
1490 " float atomicExchange(coherent volatile inout float, float);"
1491 " float atomicExchange(coherent volatile inout float, float, int, int, int);"
1492 " double atomicExchange(coherent volatile inout double, double);"
1493 " double atomicExchange(coherent volatile inout double, double, int, int, int);"
1495 "uint64_t atomicCompSwap(coherent volatile inout uint64_t, uint64_t, uint64_t);"
1496 " int64_t atomicCompSwap(coherent volatile inout int64_t, int64_t, int64_t);"
1497 "uint64_t atomicCompSwap(coherent volatile inout uint64_t, uint64_t, uint64_t, int, int, int, int, int);"
1498 " int64_t atomicCompSwap(coherent volatile inout int64_t, int64_t, int64_t, int, int, int, int, int);"
1500 "uint64_t atomicLoad(coherent volatile in uint64_t, int, int, int);"
1501 " int64_t atomicLoad(coherent volatile in int64_t, int, int, int);"
1502 "float16_t atomicLoad(coherent volatile in float16_t, int, int, int);"
1503 " float atomicLoad(coherent volatile in float, int, int, int);"
1504 " double atomicLoad(coherent volatile in double, int, int, int);"
1506 "void atomicStore(coherent volatile out uint64_t, uint64_t, int, int, int);"
1507 "void atomicStore(coherent volatile out int64_t, int64_t, int, int, int);"
1508 "void atomicStore(coherent volatile out float16_t, float16_t, int, int, int);"
1509 "void atomicStore(coherent volatile out float, float, int, int, int);"
1510 "void atomicStore(coherent volatile out double, double, int, int, int);"
1513 #endif // !GLSLANG_ANGLE
1514 #endif // !GLSLANG_WEB
1516 if ((profile == EEsProfile && version >= 300) ||
1517 (profile != EEsProfile && version >= 150)) { // GL_ARB_shader_bit_encoding
1518 commonBuiltins.append(
1519 "int floatBitsToInt(highp float value);"
1520 "ivec2 floatBitsToInt(highp vec2 value);"
1521 "ivec3 floatBitsToInt(highp vec3 value);"
1522 "ivec4 floatBitsToInt(highp vec4 value);"
1524 "uint floatBitsToUint(highp float value);"
1525 "uvec2 floatBitsToUint(highp vec2 value);"
1526 "uvec3 floatBitsToUint(highp vec3 value);"
1527 "uvec4 floatBitsToUint(highp vec4 value);"
1529 "float intBitsToFloat(highp int value);"
1530 "vec2 intBitsToFloat(highp ivec2 value);"
1531 "vec3 intBitsToFloat(highp ivec3 value);"
1532 "vec4 intBitsToFloat(highp ivec4 value);"
1534 "float uintBitsToFloat(highp uint value);"
1535 "vec2 uintBitsToFloat(highp uvec2 value);"
1536 "vec3 uintBitsToFloat(highp uvec3 value);"
1537 "vec4 uintBitsToFloat(highp uvec4 value);"
1543 if ((profile != EEsProfile && version >= 400) ||
1544 (profile == EEsProfile && version >= 310)) { // GL_OES_gpu_shader5
1546 commonBuiltins.append(
1547 "float fma(float, float, float );"
1548 "vec2 fma(vec2, vec2, vec2 );"
1549 "vec3 fma(vec3, vec3, vec3 );"
1550 "vec4 fma(vec4, vec4, vec4 );"
1554 #ifndef GLSLANG_ANGLE
1555 if (profile != EEsProfile && version >= 150) { // ARB_gpu_shader_fp64
1556 commonBuiltins.append(
1557 "double fma(double, double, double);"
1558 "dvec2 fma(dvec2, dvec2, dvec2 );"
1559 "dvec3 fma(dvec3, dvec3, dvec3 );"
1560 "dvec4 fma(dvec4, dvec4, dvec4 );"
1564 if (profile == EEsProfile && version >= 310) { // ARB_gpu_shader_fp64
1565 commonBuiltins.append(
1566 "float64_t fma(float64_t, float64_t, float64_t);"
1567 "f64vec2 fma(f64vec2, f64vec2, f64vec2 );"
1568 "f64vec3 fma(f64vec3, f64vec3, f64vec3 );"
1569 "f64vec4 fma(f64vec4, f64vec4, f64vec4 );"
1574 if ((profile == EEsProfile && version >= 310) ||
1575 (profile != EEsProfile && version >= 400)) {
1576 commonBuiltins.append(
1577 "float frexp(highp float, out highp int);"
1578 "vec2 frexp(highp vec2, out highp ivec2);"
1579 "vec3 frexp(highp vec3, out highp ivec3);"
1580 "vec4 frexp(highp vec4, out highp ivec4);"
1582 "float ldexp(highp float, highp int);"
1583 "vec2 ldexp(highp vec2, highp ivec2);"
1584 "vec3 ldexp(highp vec3, highp ivec3);"
1585 "vec4 ldexp(highp vec4, highp ivec4);"
1590 #ifndef GLSLANG_ANGLE
1591 if (profile != EEsProfile && version >= 150) { // ARB_gpu_shader_fp64
1592 commonBuiltins.append(
1593 "double frexp(double, out int);"
1594 "dvec2 frexp( dvec2, out ivec2);"
1595 "dvec3 frexp( dvec3, out ivec3);"
1596 "dvec4 frexp( dvec4, out ivec4);"
1598 "double ldexp(double, int);"
1599 "dvec2 ldexp( dvec2, ivec2);"
1600 "dvec3 ldexp( dvec3, ivec3);"
1601 "dvec4 ldexp( dvec4, ivec4);"
1603 "double packDouble2x32(uvec2);"
1604 "uvec2 unpackDouble2x32(double);"
1609 if (profile == EEsProfile && version >= 310) { // ARB_gpu_shader_fp64
1610 commonBuiltins.append(
1611 "float64_t frexp(float64_t, out int);"
1612 "f64vec2 frexp( f64vec2, out ivec2);"
1613 "f64vec3 frexp( f64vec3, out ivec3);"
1614 "f64vec4 frexp( f64vec4, out ivec4);"
1616 "float64_t ldexp(float64_t, int);"
1617 "f64vec2 ldexp( f64vec2, ivec2);"
1618 "f64vec3 ldexp( f64vec3, ivec3);"
1619 "f64vec4 ldexp( f64vec4, ivec4);"
1626 if ((profile == EEsProfile && version >= 300) ||
1627 (profile != EEsProfile && version >= 150)) {
1628 commonBuiltins.append(
1629 "highp uint packUnorm2x16(vec2);"
1630 "vec2 unpackUnorm2x16(highp uint);"
1634 if ((profile == EEsProfile && version >= 300) ||
1635 (profile != EEsProfile && version >= 150)) {
1636 commonBuiltins.append(
1637 "highp uint packSnorm2x16(vec2);"
1638 " vec2 unpackSnorm2x16(highp uint);"
1639 "highp uint packHalf2x16(vec2);"
1643 if (profile == EEsProfile && version >= 300) {
1644 commonBuiltins.append(
1645 "mediump vec2 unpackHalf2x16(highp uint);"
1647 } else if (profile != EEsProfile && version >= 150) {
1648 commonBuiltins.append(
1649 " vec2 unpackHalf2x16(highp uint);"
1654 if ((profile == EEsProfile && version >= 310) ||
1655 (profile != EEsProfile && version >= 150)) {
1656 commonBuiltins.append(
1657 "highp uint packSnorm4x8(vec4);"
1658 "highp uint packUnorm4x8(vec4);"
1662 if (profile == EEsProfile && version >= 310) {
1663 commonBuiltins.append(
1664 "mediump vec4 unpackSnorm4x8(highp uint);"
1665 "mediump vec4 unpackUnorm4x8(highp uint);"
1667 } else if (profile != EEsProfile && version >= 150) {
1668 commonBuiltins.append(
1669 "vec4 unpackSnorm4x8(highp uint);"
1670 "vec4 unpackUnorm4x8(highp uint);"
1676 // Matrix Functions.
1678 commonBuiltins.append(
1679 "mat2 matrixCompMult(mat2 x, mat2 y);"
1680 "mat3 matrixCompMult(mat3 x, mat3 y);"
1681 "mat4 matrixCompMult(mat4 x, mat4 y);"
1685 // 120 is correct for both ES and desktop
1686 if (version >= 120) {
1687 commonBuiltins.append(
1688 "mat2 outerProduct(vec2 c, vec2 r);"
1689 "mat3 outerProduct(vec3 c, vec3 r);"
1690 "mat4 outerProduct(vec4 c, vec4 r);"
1691 "mat2x3 outerProduct(vec3 c, vec2 r);"
1692 "mat3x2 outerProduct(vec2 c, vec3 r);"
1693 "mat2x4 outerProduct(vec4 c, vec2 r);"
1694 "mat4x2 outerProduct(vec2 c, vec4 r);"
1695 "mat3x4 outerProduct(vec4 c, vec3 r);"
1696 "mat4x3 outerProduct(vec3 c, vec4 r);"
1698 "mat2 transpose(mat2 m);"
1699 "mat3 transpose(mat3 m);"
1700 "mat4 transpose(mat4 m);"
1701 "mat2x3 transpose(mat3x2 m);"
1702 "mat3x2 transpose(mat2x3 m);"
1703 "mat2x4 transpose(mat4x2 m);"
1704 "mat4x2 transpose(mat2x4 m);"
1705 "mat3x4 transpose(mat4x3 m);"
1706 "mat4x3 transpose(mat3x4 m);"
1708 "mat2x3 matrixCompMult(mat2x3, mat2x3);"
1709 "mat2x4 matrixCompMult(mat2x4, mat2x4);"
1710 "mat3x2 matrixCompMult(mat3x2, mat3x2);"
1711 "mat3x4 matrixCompMult(mat3x4, mat3x4);"
1712 "mat4x2 matrixCompMult(mat4x2, mat4x2);"
1713 "mat4x3 matrixCompMult(mat4x3, mat4x3);"
1717 // 150 is correct for both ES and desktop
1718 if (version >= 150) {
1719 commonBuiltins.append(
1720 "float determinant(mat2 m);"
1721 "float determinant(mat3 m);"
1722 "float determinant(mat4 m);"
1724 "mat2 inverse(mat2 m);"
1725 "mat3 inverse(mat3 m);"
1726 "mat4 inverse(mat4 m);"
1733 #ifndef GLSLANG_ANGLE
1735 // Original-style texture functions existing in all stages.
1736 // (Per-stage functions below.)
1738 if ((profile == EEsProfile && version == 100) ||
1739 profile == ECompatibilityProfile ||
1740 (profile == ECoreProfile && version < 420) ||
1741 profile == ENoProfile) {
1742 if (spvVersion.spv == 0) {
1743 commonBuiltins.append(
1744 "vec4 texture2D(sampler2D, vec2);"
1746 "vec4 texture2DProj(sampler2D, vec3);"
1747 "vec4 texture2DProj(sampler2D, vec4);"
1749 "vec4 texture3D(sampler3D, vec3);" // OES_texture_3D, but caught by keyword check
1750 "vec4 texture3DProj(sampler3D, vec4);" // OES_texture_3D, but caught by keyword check
1752 "vec4 textureCube(samplerCube, vec3);"
1758 if ( profile == ECompatibilityProfile ||
1759 (profile == ECoreProfile && version < 420) ||
1760 profile == ENoProfile) {
1761 if (spvVersion.spv == 0) {
1762 commonBuiltins.append(
1763 "vec4 texture1D(sampler1D, float);"
1765 "vec4 texture1DProj(sampler1D, vec2);"
1766 "vec4 texture1DProj(sampler1D, vec4);"
1768 "vec4 shadow1D(sampler1DShadow, vec3);"
1769 "vec4 shadow2D(sampler2DShadow, vec3);"
1770 "vec4 shadow1DProj(sampler1DShadow, vec4);"
1771 "vec4 shadow2DProj(sampler2DShadow, vec4);"
1773 "vec4 texture2DRect(sampler2DRect, vec2);" // GL_ARB_texture_rectangle, caught by keyword check
1774 "vec4 texture2DRectProj(sampler2DRect, vec3);" // GL_ARB_texture_rectangle, caught by keyword check
1775 "vec4 texture2DRectProj(sampler2DRect, vec4);" // GL_ARB_texture_rectangle, caught by keyword check
1776 "vec4 shadow2DRect(sampler2DRectShadow, vec3);" // GL_ARB_texture_rectangle, caught by keyword check
1777 "vec4 shadow2DRectProj(sampler2DRectShadow, vec4);" // GL_ARB_texture_rectangle, caught by keyword check
1783 if (profile == EEsProfile) {
1784 if (spvVersion.spv == 0) {
1785 if (version < 300) {
1786 commonBuiltins.append(
1787 "vec4 texture2D(samplerExternalOES, vec2 coord);" // GL_OES_EGL_image_external
1788 "vec4 texture2DProj(samplerExternalOES, vec3);" // GL_OES_EGL_image_external
1789 "vec4 texture2DProj(samplerExternalOES, vec4);" // GL_OES_EGL_image_external
1792 commonBuiltins.append(
1793 "highp ivec2 textureSize(samplerExternalOES, int lod);" // GL_OES_EGL_image_external_essl3
1794 "vec4 texture(samplerExternalOES, vec2);" // GL_OES_EGL_image_external_essl3
1795 "vec4 texture(samplerExternalOES, vec2, float bias);" // GL_OES_EGL_image_external_essl3
1796 "vec4 textureProj(samplerExternalOES, vec3);" // GL_OES_EGL_image_external_essl3
1797 "vec4 textureProj(samplerExternalOES, vec3, float bias);" // GL_OES_EGL_image_external_essl3
1798 "vec4 textureProj(samplerExternalOES, vec4);" // GL_OES_EGL_image_external_essl3
1799 "vec4 textureProj(samplerExternalOES, vec4, float bias);" // GL_OES_EGL_image_external_essl3
1800 "vec4 texelFetch(samplerExternalOES, ivec2, int lod);" // GL_OES_EGL_image_external_essl3
1803 commonBuiltins.append(
1804 "highp ivec2 textureSize(__samplerExternal2DY2YEXT, int lod);" // GL_EXT_YUV_target
1805 "vec4 texture(__samplerExternal2DY2YEXT, vec2);" // GL_EXT_YUV_target
1806 "vec4 texture(__samplerExternal2DY2YEXT, vec2, float bias);" // GL_EXT_YUV_target
1807 "vec4 textureProj(__samplerExternal2DY2YEXT, vec3);" // GL_EXT_YUV_target
1808 "vec4 textureProj(__samplerExternal2DY2YEXT, vec3, float bias);" // GL_EXT_YUV_target
1809 "vec4 textureProj(__samplerExternal2DY2YEXT, vec4);" // GL_EXT_YUV_target
1810 "vec4 textureProj(__samplerExternal2DY2YEXT, vec4, float bias);" // GL_EXT_YUV_target
1811 "vec4 texelFetch(__samplerExternal2DY2YEXT sampler, ivec2, int lod);" // GL_EXT_YUV_target
1813 commonBuiltins.append(
1814 "vec4 texture2DGradEXT(sampler2D, vec2, vec2, vec2);" // GL_EXT_shader_texture_lod
1815 "vec4 texture2DProjGradEXT(sampler2D, vec3, vec2, vec2);" // GL_EXT_shader_texture_lod
1816 "vec4 texture2DProjGradEXT(sampler2D, vec4, vec2, vec2);" // GL_EXT_shader_texture_lod
1817 "vec4 textureCubeGradEXT(samplerCube, vec3, vec3, vec3);" // GL_EXT_shader_texture_lod
1819 "float shadow2DEXT(sampler2DShadow, vec3);" // GL_EXT_shadow_samplers
1820 "float shadow2DProjEXT(sampler2DShadow, vec4);" // GL_EXT_shadow_samplers
1829 if (spvVersion.spv == 0 && profile != EEsProfile) {
1830 commonBuiltins.append(
1831 "float noise1(float x);"
1832 "float noise1(vec2 x);"
1833 "float noise1(vec3 x);"
1834 "float noise1(vec4 x);"
1836 "vec2 noise2(float x);"
1837 "vec2 noise2(vec2 x);"
1838 "vec2 noise2(vec3 x);"
1839 "vec2 noise2(vec4 x);"
1841 "vec3 noise3(float x);"
1842 "vec3 noise3(vec2 x);"
1843 "vec3 noise3(vec3 x);"
1844 "vec3 noise3(vec4 x);"
1846 "vec4 noise4(float x);"
1847 "vec4 noise4(vec2 x);"
1848 "vec4 noise4(vec3 x);"
1849 "vec4 noise4(vec4 x);"
1854 if (spvVersion.vulkan == 0) {
1856 // Atomic counter functions.
1858 if ((profile != EEsProfile && version >= 300) ||
1859 (profile == EEsProfile && version >= 310)) {
1860 commonBuiltins.append(
1861 "uint atomicCounterIncrement(atomic_uint);"
1862 "uint atomicCounterDecrement(atomic_uint);"
1863 "uint atomicCounter(atomic_uint);"
1867 if (profile != EEsProfile && version == 450) {
1868 commonBuiltins.append(
1869 "uint atomicCounterAddARB(atomic_uint, uint);"
1870 "uint atomicCounterSubtractARB(atomic_uint, uint);"
1871 "uint atomicCounterMinARB(atomic_uint, uint);"
1872 "uint atomicCounterMaxARB(atomic_uint, uint);"
1873 "uint atomicCounterAndARB(atomic_uint, uint);"
1874 "uint atomicCounterOrARB(atomic_uint, uint);"
1875 "uint atomicCounterXorARB(atomic_uint, uint);"
1876 "uint atomicCounterExchangeARB(atomic_uint, uint);"
1877 "uint atomicCounterCompSwapARB(atomic_uint, uint, uint);"
1883 if (profile != EEsProfile && version >= 460) {
1884 commonBuiltins.append(
1885 "uint atomicCounterAdd(atomic_uint, uint);"
1886 "uint atomicCounterSubtract(atomic_uint, uint);"
1887 "uint atomicCounterMin(atomic_uint, uint);"
1888 "uint atomicCounterMax(atomic_uint, uint);"
1889 "uint atomicCounterAnd(atomic_uint, uint);"
1890 "uint atomicCounterOr(atomic_uint, uint);"
1891 "uint atomicCounterXor(atomic_uint, uint);"
1892 "uint atomicCounterExchange(atomic_uint, uint);"
1893 "uint atomicCounterCompSwap(atomic_uint, uint, uint);"
1898 else if (spvVersion.vulkanRelaxed) {
1900 // Atomic counter functions act as aliases to normal atomic functions.
1901 // replace definitions to take 'volatile coherent uint' instead of 'atomic_uint'
1902 // and map to equivalent non-counter atomic op
1904 if ((profile != EEsProfile && version >= 300) ||
1905 (profile == EEsProfile && version >= 310)) {
1906 commonBuiltins.append(
1907 "uint atomicCounterIncrement(volatile coherent uint);"
1908 "uint atomicCounterDecrement(volatile coherent uint);"
1909 "uint atomicCounter(volatile coherent uint);"
1913 if (profile != EEsProfile && version >= 460) {
1914 commonBuiltins.append(
1915 "uint atomicCounterAdd(volatile coherent uint, uint);"
1916 "uint atomicCounterSubtract(volatile coherent uint, uint);"
1917 "uint atomicCounterMin(volatile coherent uint, uint);"
1918 "uint atomicCounterMax(volatile coherent uint, uint);"
1919 "uint atomicCounterAnd(volatile coherent uint, uint);"
1920 "uint atomicCounterOr(volatile coherent uint, uint);"
1921 "uint atomicCounterXor(volatile coherent uint, uint);"
1922 "uint atomicCounterExchange(volatile coherent uint, uint);"
1923 "uint atomicCounterCompSwap(volatile coherent uint, uint, uint);"
1928 #endif // !GLSLANG_ANGLE
1931 if ((profile == EEsProfile && version >= 310) ||
1932 (profile != EEsProfile && version >= 400)) {
1933 commonBuiltins.append(
1934 " int bitfieldExtract( int, int, int);"
1935 "ivec2 bitfieldExtract(ivec2, int, int);"
1936 "ivec3 bitfieldExtract(ivec3, int, int);"
1937 "ivec4 bitfieldExtract(ivec4, int, int);"
1939 " uint bitfieldExtract( uint, int, int);"
1940 "uvec2 bitfieldExtract(uvec2, int, int);"
1941 "uvec3 bitfieldExtract(uvec3, int, int);"
1942 "uvec4 bitfieldExtract(uvec4, int, int);"
1944 " int bitfieldInsert( int base, int, int, int);"
1945 "ivec2 bitfieldInsert(ivec2 base, ivec2, int, int);"
1946 "ivec3 bitfieldInsert(ivec3 base, ivec3, int, int);"
1947 "ivec4 bitfieldInsert(ivec4 base, ivec4, int, int);"
1949 " uint bitfieldInsert( uint base, uint, int, int);"
1950 "uvec2 bitfieldInsert(uvec2 base, uvec2, int, int);"
1951 "uvec3 bitfieldInsert(uvec3 base, uvec3, int, int);"
1952 "uvec4 bitfieldInsert(uvec4 base, uvec4, int, int);"
1957 if (profile != EEsProfile && version >= 400) {
1958 commonBuiltins.append(
1959 " int findLSB( int);"
1960 "ivec2 findLSB(ivec2);"
1961 "ivec3 findLSB(ivec3);"
1962 "ivec4 findLSB(ivec4);"
1964 " int findLSB( uint);"
1965 "ivec2 findLSB(uvec2);"
1966 "ivec3 findLSB(uvec3);"
1967 "ivec4 findLSB(uvec4);"
1970 } else if (profile == EEsProfile && version >= 310) {
1971 commonBuiltins.append(
1972 "lowp int findLSB( int);"
1973 "lowp ivec2 findLSB(ivec2);"
1974 "lowp ivec3 findLSB(ivec3);"
1975 "lowp ivec4 findLSB(ivec4);"
1977 "lowp int findLSB( uint);"
1978 "lowp ivec2 findLSB(uvec2);"
1979 "lowp ivec3 findLSB(uvec3);"
1980 "lowp ivec4 findLSB(uvec4);"
1985 if (profile != EEsProfile && version >= 400) {
1986 commonBuiltins.append(
1987 " int bitCount( int);"
1988 "ivec2 bitCount(ivec2);"
1989 "ivec3 bitCount(ivec3);"
1990 "ivec4 bitCount(ivec4);"
1992 " int bitCount( uint);"
1993 "ivec2 bitCount(uvec2);"
1994 "ivec3 bitCount(uvec3);"
1995 "ivec4 bitCount(uvec4);"
1997 " int findMSB(highp int);"
1998 "ivec2 findMSB(highp ivec2);"
1999 "ivec3 findMSB(highp ivec3);"
2000 "ivec4 findMSB(highp ivec4);"
2002 " int findMSB(highp uint);"
2003 "ivec2 findMSB(highp uvec2);"
2004 "ivec3 findMSB(highp uvec3);"
2005 "ivec4 findMSB(highp uvec4);"
2010 if ((profile == EEsProfile && version >= 310) ||
2011 (profile != EEsProfile && version >= 400)) {
2012 commonBuiltins.append(
2013 " uint uaddCarry(highp uint, highp uint, out lowp uint carry);"
2014 "uvec2 uaddCarry(highp uvec2, highp uvec2, out lowp uvec2 carry);"
2015 "uvec3 uaddCarry(highp uvec3, highp uvec3, out lowp uvec3 carry);"
2016 "uvec4 uaddCarry(highp uvec4, highp uvec4, out lowp uvec4 carry);"
2018 " uint usubBorrow(highp uint, highp uint, out lowp uint borrow);"
2019 "uvec2 usubBorrow(highp uvec2, highp uvec2, out lowp uvec2 borrow);"
2020 "uvec3 usubBorrow(highp uvec3, highp uvec3, out lowp uvec3 borrow);"
2021 "uvec4 usubBorrow(highp uvec4, highp uvec4, out lowp uvec4 borrow);"
2023 "void umulExtended(highp uint, highp uint, out highp uint, out highp uint lsb);"
2024 "void umulExtended(highp uvec2, highp uvec2, out highp uvec2, out highp uvec2 lsb);"
2025 "void umulExtended(highp uvec3, highp uvec3, out highp uvec3, out highp uvec3 lsb);"
2026 "void umulExtended(highp uvec4, highp uvec4, out highp uvec4, out highp uvec4 lsb);"
2028 "void imulExtended(highp int, highp int, out highp int, out highp int lsb);"
2029 "void imulExtended(highp ivec2, highp ivec2, out highp ivec2, out highp ivec2 lsb);"
2030 "void imulExtended(highp ivec3, highp ivec3, out highp ivec3, out highp ivec3 lsb);"
2031 "void imulExtended(highp ivec4, highp ivec4, out highp ivec4, out highp ivec4 lsb);"
2033 " int bitfieldReverse(highp int);"
2034 "ivec2 bitfieldReverse(highp ivec2);"
2035 "ivec3 bitfieldReverse(highp ivec3);"
2036 "ivec4 bitfieldReverse(highp ivec4);"
2038 " uint bitfieldReverse(highp uint);"
2039 "uvec2 bitfieldReverse(highp uvec2);"
2040 "uvec3 bitfieldReverse(highp uvec3);"
2041 "uvec4 bitfieldReverse(highp uvec4);"
2046 if (profile == EEsProfile && version >= 310) {
2047 commonBuiltins.append(
2048 "lowp int bitCount( int);"
2049 "lowp ivec2 bitCount(ivec2);"
2050 "lowp ivec3 bitCount(ivec3);"
2051 "lowp ivec4 bitCount(ivec4);"
2053 "lowp int bitCount( uint);"
2054 "lowp ivec2 bitCount(uvec2);"
2055 "lowp ivec3 bitCount(uvec3);"
2056 "lowp ivec4 bitCount(uvec4);"
2058 "lowp int findMSB(highp int);"
2059 "lowp ivec2 findMSB(highp ivec2);"
2060 "lowp ivec3 findMSB(highp ivec3);"
2061 "lowp ivec4 findMSB(highp ivec4);"
2063 "lowp int findMSB(highp uint);"
2064 "lowp ivec2 findMSB(highp uvec2);"
2065 "lowp ivec3 findMSB(highp uvec3);"
2066 "lowp ivec4 findMSB(highp uvec4);"
2071 #ifndef GLSLANG_ANGLE
2072 // GL_ARB_shader_ballot
2073 if (profile != EEsProfile && version >= 450) {
2074 commonBuiltins.append(
2075 "uint64_t ballotARB(bool);"
2077 "float readInvocationARB(float, uint);"
2078 "vec2 readInvocationARB(vec2, uint);"
2079 "vec3 readInvocationARB(vec3, uint);"
2080 "vec4 readInvocationARB(vec4, uint);"
2082 "int readInvocationARB(int, uint);"
2083 "ivec2 readInvocationARB(ivec2, uint);"
2084 "ivec3 readInvocationARB(ivec3, uint);"
2085 "ivec4 readInvocationARB(ivec4, uint);"
2087 "uint readInvocationARB(uint, uint);"
2088 "uvec2 readInvocationARB(uvec2, uint);"
2089 "uvec3 readInvocationARB(uvec3, uint);"
2090 "uvec4 readInvocationARB(uvec4, uint);"
2092 "float readFirstInvocationARB(float);"
2093 "vec2 readFirstInvocationARB(vec2);"
2094 "vec3 readFirstInvocationARB(vec3);"
2095 "vec4 readFirstInvocationARB(vec4);"
2097 "int readFirstInvocationARB(int);"
2098 "ivec2 readFirstInvocationARB(ivec2);"
2099 "ivec3 readFirstInvocationARB(ivec3);"
2100 "ivec4 readFirstInvocationARB(ivec4);"
2102 "uint readFirstInvocationARB(uint);"
2103 "uvec2 readFirstInvocationARB(uvec2);"
2104 "uvec3 readFirstInvocationARB(uvec3);"
2105 "uvec4 readFirstInvocationARB(uvec4);"
2110 // GL_ARB_shader_group_vote
2111 if (profile != EEsProfile && version >= 430) {
2112 commonBuiltins.append(
2113 "bool anyInvocationARB(bool);"
2114 "bool allInvocationsARB(bool);"
2115 "bool allInvocationsEqualARB(bool);"
2120 // GL_KHR_shader_subgroup
2121 if ((profile == EEsProfile && version >= 310) ||
2122 (profile != EEsProfile && version >= 140)) {
2123 commonBuiltins.append(
2124 "void subgroupBarrier();"
2125 "void subgroupMemoryBarrier();"
2126 "void subgroupMemoryBarrierBuffer();"
2127 "void subgroupMemoryBarrierImage();"
2128 "bool subgroupElect();"
2130 "bool subgroupAll(bool);\n"
2131 "bool subgroupAny(bool);\n"
2132 "uvec4 subgroupBallot(bool);\n"
2133 "bool subgroupInverseBallot(uvec4);\n"
2134 "bool subgroupBallotBitExtract(uvec4, uint);\n"
2135 "uint subgroupBallotBitCount(uvec4);\n"
2136 "uint subgroupBallotInclusiveBitCount(uvec4);\n"
2137 "uint subgroupBallotExclusiveBitCount(uvec4);\n"
2138 "uint subgroupBallotFindLSB(uvec4);\n"
2139 "uint subgroupBallotFindMSB(uvec4);\n"
2142 // Generate all flavors of subgroup ops.
2143 static const char *subgroupOps[] =
2145 "bool subgroupAllEqual(%s);\n",
2146 "%s subgroupBroadcast(%s, uint);\n",
2147 "%s subgroupBroadcastFirst(%s);\n",
2148 "%s subgroupShuffle(%s, uint);\n",
2149 "%s subgroupShuffleXor(%s, uint);\n",
2150 "%s subgroupShuffleUp(%s, uint delta);\n",
2151 "%s subgroupShuffleDown(%s, uint delta);\n",
2152 "%s subgroupAdd(%s);\n",
2153 "%s subgroupMul(%s);\n",
2154 "%s subgroupMin(%s);\n",
2155 "%s subgroupMax(%s);\n",
2156 "%s subgroupAnd(%s);\n",
2157 "%s subgroupOr(%s);\n",
2158 "%s subgroupXor(%s);\n",
2159 "%s subgroupInclusiveAdd(%s);\n",
2160 "%s subgroupInclusiveMul(%s);\n",
2161 "%s subgroupInclusiveMin(%s);\n",
2162 "%s subgroupInclusiveMax(%s);\n",
2163 "%s subgroupInclusiveAnd(%s);\n",
2164 "%s subgroupInclusiveOr(%s);\n",
2165 "%s subgroupInclusiveXor(%s);\n",
2166 "%s subgroupExclusiveAdd(%s);\n",
2167 "%s subgroupExclusiveMul(%s);\n",
2168 "%s subgroupExclusiveMin(%s);\n",
2169 "%s subgroupExclusiveMax(%s);\n",
2170 "%s subgroupExclusiveAnd(%s);\n",
2171 "%s subgroupExclusiveOr(%s);\n",
2172 "%s subgroupExclusiveXor(%s);\n",
2173 "%s subgroupClusteredAdd(%s, uint);\n",
2174 "%s subgroupClusteredMul(%s, uint);\n",
2175 "%s subgroupClusteredMin(%s, uint);\n",
2176 "%s subgroupClusteredMax(%s, uint);\n",
2177 "%s subgroupClusteredAnd(%s, uint);\n",
2178 "%s subgroupClusteredOr(%s, uint);\n",
2179 "%s subgroupClusteredXor(%s, uint);\n",
2180 "%s subgroupQuadBroadcast(%s, uint);\n",
2181 "%s subgroupQuadSwapHorizontal(%s);\n",
2182 "%s subgroupQuadSwapVertical(%s);\n",
2183 "%s subgroupQuadSwapDiagonal(%s);\n",
2184 "uvec4 subgroupPartitionNV(%s);\n",
2185 "%s subgroupPartitionedAddNV(%s, uvec4 ballot);\n",
2186 "%s subgroupPartitionedMulNV(%s, uvec4 ballot);\n",
2187 "%s subgroupPartitionedMinNV(%s, uvec4 ballot);\n",
2188 "%s subgroupPartitionedMaxNV(%s, uvec4 ballot);\n",
2189 "%s subgroupPartitionedAndNV(%s, uvec4 ballot);\n",
2190 "%s subgroupPartitionedOrNV(%s, uvec4 ballot);\n",
2191 "%s subgroupPartitionedXorNV(%s, uvec4 ballot);\n",
2192 "%s subgroupPartitionedInclusiveAddNV(%s, uvec4 ballot);\n",
2193 "%s subgroupPartitionedInclusiveMulNV(%s, uvec4 ballot);\n",
2194 "%s subgroupPartitionedInclusiveMinNV(%s, uvec4 ballot);\n",
2195 "%s subgroupPartitionedInclusiveMaxNV(%s, uvec4 ballot);\n",
2196 "%s subgroupPartitionedInclusiveAndNV(%s, uvec4 ballot);\n",
2197 "%s subgroupPartitionedInclusiveOrNV(%s, uvec4 ballot);\n",
2198 "%s subgroupPartitionedInclusiveXorNV(%s, uvec4 ballot);\n",
2199 "%s subgroupPartitionedExclusiveAddNV(%s, uvec4 ballot);\n",
2200 "%s subgroupPartitionedExclusiveMulNV(%s, uvec4 ballot);\n",
2201 "%s subgroupPartitionedExclusiveMinNV(%s, uvec4 ballot);\n",
2202 "%s subgroupPartitionedExclusiveMaxNV(%s, uvec4 ballot);\n",
2203 "%s subgroupPartitionedExclusiveAndNV(%s, uvec4 ballot);\n",
2204 "%s subgroupPartitionedExclusiveOrNV(%s, uvec4 ballot);\n",
2205 "%s subgroupPartitionedExclusiveXorNV(%s, uvec4 ballot);\n",
2208 static const char *floatTypes[] = {
2209 "float", "vec2", "vec3", "vec4",
2210 "float16_t", "f16vec2", "f16vec3", "f16vec4",
2212 static const char *doubleTypes[] = {
2213 "double", "dvec2", "dvec3", "dvec4",
2215 static const char *intTypes[] = {
2216 "int8_t", "i8vec2", "i8vec3", "i8vec4",
2217 "int16_t", "i16vec2", "i16vec3", "i16vec4",
2218 "int", "ivec2", "ivec3", "ivec4",
2219 "int64_t", "i64vec2", "i64vec3", "i64vec4",
2220 "uint8_t", "u8vec2", "u8vec3", "u8vec4",
2221 "uint16_t", "u16vec2", "u16vec3", "u16vec4",
2222 "uint", "uvec2", "uvec3", "uvec4",
2223 "uint64_t", "u64vec2", "u64vec3", "u64vec4",
2225 static const char *boolTypes[] = {
2226 "bool", "bvec2", "bvec3", "bvec4",
2229 for (size_t i = 0; i < sizeof(subgroupOps)/sizeof(subgroupOps[0]); ++i) {
2230 const char *op = subgroupOps[i];
2232 // Logical operations don't support float
2233 bool logicalOp = strstr(op, "Or") || strstr(op, "And") ||
2234 (strstr(op, "Xor") && !strstr(op, "ShuffleXor"));
2235 // Math operations don't support bool
2236 bool mathOp = strstr(op, "Add") || strstr(op, "Mul") || strstr(op, "Min") || strstr(op, "Max");
2238 const int bufSize = 256;
2242 for (size_t j = 0; j < sizeof(floatTypes)/sizeof(floatTypes[0]); ++j) {
2243 snprintf(buf, bufSize, op, floatTypes[j], floatTypes[j]);
2244 commonBuiltins.append(buf);
2246 if (profile != EEsProfile && version >= 400) {
2247 for (size_t j = 0; j < sizeof(doubleTypes)/sizeof(doubleTypes[0]); ++j) {
2248 snprintf(buf, bufSize, op, doubleTypes[j], doubleTypes[j]);
2249 commonBuiltins.append(buf);
2254 for (size_t j = 0; j < sizeof(boolTypes)/sizeof(boolTypes[0]); ++j) {
2255 snprintf(buf, bufSize, op, boolTypes[j], boolTypes[j]);
2256 commonBuiltins.append(buf);
2259 for (size_t j = 0; j < sizeof(intTypes)/sizeof(intTypes[0]); ++j) {
2260 snprintf(buf, bufSize, op, intTypes[j], intTypes[j]);
2261 commonBuiltins.append(buf);
2265 stageBuiltins[EShLangCompute].append(
2266 "void subgroupMemoryBarrierShared();"
2270 stageBuiltins[EShLangMeshNV].append(
2271 "void subgroupMemoryBarrierShared();"
2274 stageBuiltins[EShLangTaskNV].append(
2275 "void subgroupMemoryBarrierShared();"
2280 if (profile != EEsProfile && version >= 460) {
2281 commonBuiltins.append(
2282 "bool anyInvocation(bool);"
2283 "bool allInvocations(bool);"
2284 "bool allInvocationsEqual(bool);"
2289 // GL_AMD_shader_ballot
2290 if (profile != EEsProfile && version >= 450) {
2291 commonBuiltins.append(
2292 "float minInvocationsAMD(float);"
2293 "vec2 minInvocationsAMD(vec2);"
2294 "vec3 minInvocationsAMD(vec3);"
2295 "vec4 minInvocationsAMD(vec4);"
2297 "int minInvocationsAMD(int);"
2298 "ivec2 minInvocationsAMD(ivec2);"
2299 "ivec3 minInvocationsAMD(ivec3);"
2300 "ivec4 minInvocationsAMD(ivec4);"
2302 "uint minInvocationsAMD(uint);"
2303 "uvec2 minInvocationsAMD(uvec2);"
2304 "uvec3 minInvocationsAMD(uvec3);"
2305 "uvec4 minInvocationsAMD(uvec4);"
2307 "double minInvocationsAMD(double);"
2308 "dvec2 minInvocationsAMD(dvec2);"
2309 "dvec3 minInvocationsAMD(dvec3);"
2310 "dvec4 minInvocationsAMD(dvec4);"
2312 "int64_t minInvocationsAMD(int64_t);"
2313 "i64vec2 minInvocationsAMD(i64vec2);"
2314 "i64vec3 minInvocationsAMD(i64vec3);"
2315 "i64vec4 minInvocationsAMD(i64vec4);"
2317 "uint64_t minInvocationsAMD(uint64_t);"
2318 "u64vec2 minInvocationsAMD(u64vec2);"
2319 "u64vec3 minInvocationsAMD(u64vec3);"
2320 "u64vec4 minInvocationsAMD(u64vec4);"
2322 "float16_t minInvocationsAMD(float16_t);"
2323 "f16vec2 minInvocationsAMD(f16vec2);"
2324 "f16vec3 minInvocationsAMD(f16vec3);"
2325 "f16vec4 minInvocationsAMD(f16vec4);"
2327 "int16_t minInvocationsAMD(int16_t);"
2328 "i16vec2 minInvocationsAMD(i16vec2);"
2329 "i16vec3 minInvocationsAMD(i16vec3);"
2330 "i16vec4 minInvocationsAMD(i16vec4);"
2332 "uint16_t minInvocationsAMD(uint16_t);"
2333 "u16vec2 minInvocationsAMD(u16vec2);"
2334 "u16vec3 minInvocationsAMD(u16vec3);"
2335 "u16vec4 minInvocationsAMD(u16vec4);"
2337 "float minInvocationsInclusiveScanAMD(float);"
2338 "vec2 minInvocationsInclusiveScanAMD(vec2);"
2339 "vec3 minInvocationsInclusiveScanAMD(vec3);"
2340 "vec4 minInvocationsInclusiveScanAMD(vec4);"
2342 "int minInvocationsInclusiveScanAMD(int);"
2343 "ivec2 minInvocationsInclusiveScanAMD(ivec2);"
2344 "ivec3 minInvocationsInclusiveScanAMD(ivec3);"
2345 "ivec4 minInvocationsInclusiveScanAMD(ivec4);"
2347 "uint minInvocationsInclusiveScanAMD(uint);"
2348 "uvec2 minInvocationsInclusiveScanAMD(uvec2);"
2349 "uvec3 minInvocationsInclusiveScanAMD(uvec3);"
2350 "uvec4 minInvocationsInclusiveScanAMD(uvec4);"
2352 "double minInvocationsInclusiveScanAMD(double);"
2353 "dvec2 minInvocationsInclusiveScanAMD(dvec2);"
2354 "dvec3 minInvocationsInclusiveScanAMD(dvec3);"
2355 "dvec4 minInvocationsInclusiveScanAMD(dvec4);"
2357 "int64_t minInvocationsInclusiveScanAMD(int64_t);"
2358 "i64vec2 minInvocationsInclusiveScanAMD(i64vec2);"
2359 "i64vec3 minInvocationsInclusiveScanAMD(i64vec3);"
2360 "i64vec4 minInvocationsInclusiveScanAMD(i64vec4);"
2362 "uint64_t minInvocationsInclusiveScanAMD(uint64_t);"
2363 "u64vec2 minInvocationsInclusiveScanAMD(u64vec2);"
2364 "u64vec3 minInvocationsInclusiveScanAMD(u64vec3);"
2365 "u64vec4 minInvocationsInclusiveScanAMD(u64vec4);"
2367 "float16_t minInvocationsInclusiveScanAMD(float16_t);"
2368 "f16vec2 minInvocationsInclusiveScanAMD(f16vec2);"
2369 "f16vec3 minInvocationsInclusiveScanAMD(f16vec3);"
2370 "f16vec4 minInvocationsInclusiveScanAMD(f16vec4);"
2372 "int16_t minInvocationsInclusiveScanAMD(int16_t);"
2373 "i16vec2 minInvocationsInclusiveScanAMD(i16vec2);"
2374 "i16vec3 minInvocationsInclusiveScanAMD(i16vec3);"
2375 "i16vec4 minInvocationsInclusiveScanAMD(i16vec4);"
2377 "uint16_t minInvocationsInclusiveScanAMD(uint16_t);"
2378 "u16vec2 minInvocationsInclusiveScanAMD(u16vec2);"
2379 "u16vec3 minInvocationsInclusiveScanAMD(u16vec3);"
2380 "u16vec4 minInvocationsInclusiveScanAMD(u16vec4);"
2382 "float minInvocationsExclusiveScanAMD(float);"
2383 "vec2 minInvocationsExclusiveScanAMD(vec2);"
2384 "vec3 minInvocationsExclusiveScanAMD(vec3);"
2385 "vec4 minInvocationsExclusiveScanAMD(vec4);"
2387 "int minInvocationsExclusiveScanAMD(int);"
2388 "ivec2 minInvocationsExclusiveScanAMD(ivec2);"
2389 "ivec3 minInvocationsExclusiveScanAMD(ivec3);"
2390 "ivec4 minInvocationsExclusiveScanAMD(ivec4);"
2392 "uint minInvocationsExclusiveScanAMD(uint);"
2393 "uvec2 minInvocationsExclusiveScanAMD(uvec2);"
2394 "uvec3 minInvocationsExclusiveScanAMD(uvec3);"
2395 "uvec4 minInvocationsExclusiveScanAMD(uvec4);"
2397 "double minInvocationsExclusiveScanAMD(double);"
2398 "dvec2 minInvocationsExclusiveScanAMD(dvec2);"
2399 "dvec3 minInvocationsExclusiveScanAMD(dvec3);"
2400 "dvec4 minInvocationsExclusiveScanAMD(dvec4);"
2402 "int64_t minInvocationsExclusiveScanAMD(int64_t);"
2403 "i64vec2 minInvocationsExclusiveScanAMD(i64vec2);"
2404 "i64vec3 minInvocationsExclusiveScanAMD(i64vec3);"
2405 "i64vec4 minInvocationsExclusiveScanAMD(i64vec4);"
2407 "uint64_t minInvocationsExclusiveScanAMD(uint64_t);"
2408 "u64vec2 minInvocationsExclusiveScanAMD(u64vec2);"
2409 "u64vec3 minInvocationsExclusiveScanAMD(u64vec3);"
2410 "u64vec4 minInvocationsExclusiveScanAMD(u64vec4);"
2412 "float16_t minInvocationsExclusiveScanAMD(float16_t);"
2413 "f16vec2 minInvocationsExclusiveScanAMD(f16vec2);"
2414 "f16vec3 minInvocationsExclusiveScanAMD(f16vec3);"
2415 "f16vec4 minInvocationsExclusiveScanAMD(f16vec4);"
2417 "int16_t minInvocationsExclusiveScanAMD(int16_t);"
2418 "i16vec2 minInvocationsExclusiveScanAMD(i16vec2);"
2419 "i16vec3 minInvocationsExclusiveScanAMD(i16vec3);"
2420 "i16vec4 minInvocationsExclusiveScanAMD(i16vec4);"
2422 "uint16_t minInvocationsExclusiveScanAMD(uint16_t);"
2423 "u16vec2 minInvocationsExclusiveScanAMD(u16vec2);"
2424 "u16vec3 minInvocationsExclusiveScanAMD(u16vec3);"
2425 "u16vec4 minInvocationsExclusiveScanAMD(u16vec4);"
2427 "float maxInvocationsAMD(float);"
2428 "vec2 maxInvocationsAMD(vec2);"
2429 "vec3 maxInvocationsAMD(vec3);"
2430 "vec4 maxInvocationsAMD(vec4);"
2432 "int maxInvocationsAMD(int);"
2433 "ivec2 maxInvocationsAMD(ivec2);"
2434 "ivec3 maxInvocationsAMD(ivec3);"
2435 "ivec4 maxInvocationsAMD(ivec4);"
2437 "uint maxInvocationsAMD(uint);"
2438 "uvec2 maxInvocationsAMD(uvec2);"
2439 "uvec3 maxInvocationsAMD(uvec3);"
2440 "uvec4 maxInvocationsAMD(uvec4);"
2442 "double maxInvocationsAMD(double);"
2443 "dvec2 maxInvocationsAMD(dvec2);"
2444 "dvec3 maxInvocationsAMD(dvec3);"
2445 "dvec4 maxInvocationsAMD(dvec4);"
2447 "int64_t maxInvocationsAMD(int64_t);"
2448 "i64vec2 maxInvocationsAMD(i64vec2);"
2449 "i64vec3 maxInvocationsAMD(i64vec3);"
2450 "i64vec4 maxInvocationsAMD(i64vec4);"
2452 "uint64_t maxInvocationsAMD(uint64_t);"
2453 "u64vec2 maxInvocationsAMD(u64vec2);"
2454 "u64vec3 maxInvocationsAMD(u64vec3);"
2455 "u64vec4 maxInvocationsAMD(u64vec4);"
2457 "float16_t maxInvocationsAMD(float16_t);"
2458 "f16vec2 maxInvocationsAMD(f16vec2);"
2459 "f16vec3 maxInvocationsAMD(f16vec3);"
2460 "f16vec4 maxInvocationsAMD(f16vec4);"
2462 "int16_t maxInvocationsAMD(int16_t);"
2463 "i16vec2 maxInvocationsAMD(i16vec2);"
2464 "i16vec3 maxInvocationsAMD(i16vec3);"
2465 "i16vec4 maxInvocationsAMD(i16vec4);"
2467 "uint16_t maxInvocationsAMD(uint16_t);"
2468 "u16vec2 maxInvocationsAMD(u16vec2);"
2469 "u16vec3 maxInvocationsAMD(u16vec3);"
2470 "u16vec4 maxInvocationsAMD(u16vec4);"
2472 "float maxInvocationsInclusiveScanAMD(float);"
2473 "vec2 maxInvocationsInclusiveScanAMD(vec2);"
2474 "vec3 maxInvocationsInclusiveScanAMD(vec3);"
2475 "vec4 maxInvocationsInclusiveScanAMD(vec4);"
2477 "int maxInvocationsInclusiveScanAMD(int);"
2478 "ivec2 maxInvocationsInclusiveScanAMD(ivec2);"
2479 "ivec3 maxInvocationsInclusiveScanAMD(ivec3);"
2480 "ivec4 maxInvocationsInclusiveScanAMD(ivec4);"
2482 "uint maxInvocationsInclusiveScanAMD(uint);"
2483 "uvec2 maxInvocationsInclusiveScanAMD(uvec2);"
2484 "uvec3 maxInvocationsInclusiveScanAMD(uvec3);"
2485 "uvec4 maxInvocationsInclusiveScanAMD(uvec4);"
2487 "double maxInvocationsInclusiveScanAMD(double);"
2488 "dvec2 maxInvocationsInclusiveScanAMD(dvec2);"
2489 "dvec3 maxInvocationsInclusiveScanAMD(dvec3);"
2490 "dvec4 maxInvocationsInclusiveScanAMD(dvec4);"
2492 "int64_t maxInvocationsInclusiveScanAMD(int64_t);"
2493 "i64vec2 maxInvocationsInclusiveScanAMD(i64vec2);"
2494 "i64vec3 maxInvocationsInclusiveScanAMD(i64vec3);"
2495 "i64vec4 maxInvocationsInclusiveScanAMD(i64vec4);"
2497 "uint64_t maxInvocationsInclusiveScanAMD(uint64_t);"
2498 "u64vec2 maxInvocationsInclusiveScanAMD(u64vec2);"
2499 "u64vec3 maxInvocationsInclusiveScanAMD(u64vec3);"
2500 "u64vec4 maxInvocationsInclusiveScanAMD(u64vec4);"
2502 "float16_t maxInvocationsInclusiveScanAMD(float16_t);"
2503 "f16vec2 maxInvocationsInclusiveScanAMD(f16vec2);"
2504 "f16vec3 maxInvocationsInclusiveScanAMD(f16vec3);"
2505 "f16vec4 maxInvocationsInclusiveScanAMD(f16vec4);"
2507 "int16_t maxInvocationsInclusiveScanAMD(int16_t);"
2508 "i16vec2 maxInvocationsInclusiveScanAMD(i16vec2);"
2509 "i16vec3 maxInvocationsInclusiveScanAMD(i16vec3);"
2510 "i16vec4 maxInvocationsInclusiveScanAMD(i16vec4);"
2512 "uint16_t maxInvocationsInclusiveScanAMD(uint16_t);"
2513 "u16vec2 maxInvocationsInclusiveScanAMD(u16vec2);"
2514 "u16vec3 maxInvocationsInclusiveScanAMD(u16vec3);"
2515 "u16vec4 maxInvocationsInclusiveScanAMD(u16vec4);"
2517 "float maxInvocationsExclusiveScanAMD(float);"
2518 "vec2 maxInvocationsExclusiveScanAMD(vec2);"
2519 "vec3 maxInvocationsExclusiveScanAMD(vec3);"
2520 "vec4 maxInvocationsExclusiveScanAMD(vec4);"
2522 "int maxInvocationsExclusiveScanAMD(int);"
2523 "ivec2 maxInvocationsExclusiveScanAMD(ivec2);"
2524 "ivec3 maxInvocationsExclusiveScanAMD(ivec3);"
2525 "ivec4 maxInvocationsExclusiveScanAMD(ivec4);"
2527 "uint maxInvocationsExclusiveScanAMD(uint);"
2528 "uvec2 maxInvocationsExclusiveScanAMD(uvec2);"
2529 "uvec3 maxInvocationsExclusiveScanAMD(uvec3);"
2530 "uvec4 maxInvocationsExclusiveScanAMD(uvec4);"
2532 "double maxInvocationsExclusiveScanAMD(double);"
2533 "dvec2 maxInvocationsExclusiveScanAMD(dvec2);"
2534 "dvec3 maxInvocationsExclusiveScanAMD(dvec3);"
2535 "dvec4 maxInvocationsExclusiveScanAMD(dvec4);"
2537 "int64_t maxInvocationsExclusiveScanAMD(int64_t);"
2538 "i64vec2 maxInvocationsExclusiveScanAMD(i64vec2);"
2539 "i64vec3 maxInvocationsExclusiveScanAMD(i64vec3);"
2540 "i64vec4 maxInvocationsExclusiveScanAMD(i64vec4);"
2542 "uint64_t maxInvocationsExclusiveScanAMD(uint64_t);"
2543 "u64vec2 maxInvocationsExclusiveScanAMD(u64vec2);"
2544 "u64vec3 maxInvocationsExclusiveScanAMD(u64vec3);"
2545 "u64vec4 maxInvocationsExclusiveScanAMD(u64vec4);"
2547 "float16_t maxInvocationsExclusiveScanAMD(float16_t);"
2548 "f16vec2 maxInvocationsExclusiveScanAMD(f16vec2);"
2549 "f16vec3 maxInvocationsExclusiveScanAMD(f16vec3);"
2550 "f16vec4 maxInvocationsExclusiveScanAMD(f16vec4);"
2552 "int16_t maxInvocationsExclusiveScanAMD(int16_t);"
2553 "i16vec2 maxInvocationsExclusiveScanAMD(i16vec2);"
2554 "i16vec3 maxInvocationsExclusiveScanAMD(i16vec3);"
2555 "i16vec4 maxInvocationsExclusiveScanAMD(i16vec4);"
2557 "uint16_t maxInvocationsExclusiveScanAMD(uint16_t);"
2558 "u16vec2 maxInvocationsExclusiveScanAMD(u16vec2);"
2559 "u16vec3 maxInvocationsExclusiveScanAMD(u16vec3);"
2560 "u16vec4 maxInvocationsExclusiveScanAMD(u16vec4);"
2562 "float addInvocationsAMD(float);"
2563 "vec2 addInvocationsAMD(vec2);"
2564 "vec3 addInvocationsAMD(vec3);"
2565 "vec4 addInvocationsAMD(vec4);"
2567 "int addInvocationsAMD(int);"
2568 "ivec2 addInvocationsAMD(ivec2);"
2569 "ivec3 addInvocationsAMD(ivec3);"
2570 "ivec4 addInvocationsAMD(ivec4);"
2572 "uint addInvocationsAMD(uint);"
2573 "uvec2 addInvocationsAMD(uvec2);"
2574 "uvec3 addInvocationsAMD(uvec3);"
2575 "uvec4 addInvocationsAMD(uvec4);"
2577 "double addInvocationsAMD(double);"
2578 "dvec2 addInvocationsAMD(dvec2);"
2579 "dvec3 addInvocationsAMD(dvec3);"
2580 "dvec4 addInvocationsAMD(dvec4);"
2582 "int64_t addInvocationsAMD(int64_t);"
2583 "i64vec2 addInvocationsAMD(i64vec2);"
2584 "i64vec3 addInvocationsAMD(i64vec3);"
2585 "i64vec4 addInvocationsAMD(i64vec4);"
2587 "uint64_t addInvocationsAMD(uint64_t);"
2588 "u64vec2 addInvocationsAMD(u64vec2);"
2589 "u64vec3 addInvocationsAMD(u64vec3);"
2590 "u64vec4 addInvocationsAMD(u64vec4);"
2592 "float16_t addInvocationsAMD(float16_t);"
2593 "f16vec2 addInvocationsAMD(f16vec2);"
2594 "f16vec3 addInvocationsAMD(f16vec3);"
2595 "f16vec4 addInvocationsAMD(f16vec4);"
2597 "int16_t addInvocationsAMD(int16_t);"
2598 "i16vec2 addInvocationsAMD(i16vec2);"
2599 "i16vec3 addInvocationsAMD(i16vec3);"
2600 "i16vec4 addInvocationsAMD(i16vec4);"
2602 "uint16_t addInvocationsAMD(uint16_t);"
2603 "u16vec2 addInvocationsAMD(u16vec2);"
2604 "u16vec3 addInvocationsAMD(u16vec3);"
2605 "u16vec4 addInvocationsAMD(u16vec4);"
2607 "float addInvocationsInclusiveScanAMD(float);"
2608 "vec2 addInvocationsInclusiveScanAMD(vec2);"
2609 "vec3 addInvocationsInclusiveScanAMD(vec3);"
2610 "vec4 addInvocationsInclusiveScanAMD(vec4);"
2612 "int addInvocationsInclusiveScanAMD(int);"
2613 "ivec2 addInvocationsInclusiveScanAMD(ivec2);"
2614 "ivec3 addInvocationsInclusiveScanAMD(ivec3);"
2615 "ivec4 addInvocationsInclusiveScanAMD(ivec4);"
2617 "uint addInvocationsInclusiveScanAMD(uint);"
2618 "uvec2 addInvocationsInclusiveScanAMD(uvec2);"
2619 "uvec3 addInvocationsInclusiveScanAMD(uvec3);"
2620 "uvec4 addInvocationsInclusiveScanAMD(uvec4);"
2622 "double addInvocationsInclusiveScanAMD(double);"
2623 "dvec2 addInvocationsInclusiveScanAMD(dvec2);"
2624 "dvec3 addInvocationsInclusiveScanAMD(dvec3);"
2625 "dvec4 addInvocationsInclusiveScanAMD(dvec4);"
2627 "int64_t addInvocationsInclusiveScanAMD(int64_t);"
2628 "i64vec2 addInvocationsInclusiveScanAMD(i64vec2);"
2629 "i64vec3 addInvocationsInclusiveScanAMD(i64vec3);"
2630 "i64vec4 addInvocationsInclusiveScanAMD(i64vec4);"
2632 "uint64_t addInvocationsInclusiveScanAMD(uint64_t);"
2633 "u64vec2 addInvocationsInclusiveScanAMD(u64vec2);"
2634 "u64vec3 addInvocationsInclusiveScanAMD(u64vec3);"
2635 "u64vec4 addInvocationsInclusiveScanAMD(u64vec4);"
2637 "float16_t addInvocationsInclusiveScanAMD(float16_t);"
2638 "f16vec2 addInvocationsInclusiveScanAMD(f16vec2);"
2639 "f16vec3 addInvocationsInclusiveScanAMD(f16vec3);"
2640 "f16vec4 addInvocationsInclusiveScanAMD(f16vec4);"
2642 "int16_t addInvocationsInclusiveScanAMD(int16_t);"
2643 "i16vec2 addInvocationsInclusiveScanAMD(i16vec2);"
2644 "i16vec3 addInvocationsInclusiveScanAMD(i16vec3);"
2645 "i16vec4 addInvocationsInclusiveScanAMD(i16vec4);"
2647 "uint16_t addInvocationsInclusiveScanAMD(uint16_t);"
2648 "u16vec2 addInvocationsInclusiveScanAMD(u16vec2);"
2649 "u16vec3 addInvocationsInclusiveScanAMD(u16vec3);"
2650 "u16vec4 addInvocationsInclusiveScanAMD(u16vec4);"
2652 "float addInvocationsExclusiveScanAMD(float);"
2653 "vec2 addInvocationsExclusiveScanAMD(vec2);"
2654 "vec3 addInvocationsExclusiveScanAMD(vec3);"
2655 "vec4 addInvocationsExclusiveScanAMD(vec4);"
2657 "int addInvocationsExclusiveScanAMD(int);"
2658 "ivec2 addInvocationsExclusiveScanAMD(ivec2);"
2659 "ivec3 addInvocationsExclusiveScanAMD(ivec3);"
2660 "ivec4 addInvocationsExclusiveScanAMD(ivec4);"
2662 "uint addInvocationsExclusiveScanAMD(uint);"
2663 "uvec2 addInvocationsExclusiveScanAMD(uvec2);"
2664 "uvec3 addInvocationsExclusiveScanAMD(uvec3);"
2665 "uvec4 addInvocationsExclusiveScanAMD(uvec4);"
2667 "double addInvocationsExclusiveScanAMD(double);"
2668 "dvec2 addInvocationsExclusiveScanAMD(dvec2);"
2669 "dvec3 addInvocationsExclusiveScanAMD(dvec3);"
2670 "dvec4 addInvocationsExclusiveScanAMD(dvec4);"
2672 "int64_t addInvocationsExclusiveScanAMD(int64_t);"
2673 "i64vec2 addInvocationsExclusiveScanAMD(i64vec2);"
2674 "i64vec3 addInvocationsExclusiveScanAMD(i64vec3);"
2675 "i64vec4 addInvocationsExclusiveScanAMD(i64vec4);"
2677 "uint64_t addInvocationsExclusiveScanAMD(uint64_t);"
2678 "u64vec2 addInvocationsExclusiveScanAMD(u64vec2);"
2679 "u64vec3 addInvocationsExclusiveScanAMD(u64vec3);"
2680 "u64vec4 addInvocationsExclusiveScanAMD(u64vec4);"
2682 "float16_t addInvocationsExclusiveScanAMD(float16_t);"
2683 "f16vec2 addInvocationsExclusiveScanAMD(f16vec2);"
2684 "f16vec3 addInvocationsExclusiveScanAMD(f16vec3);"
2685 "f16vec4 addInvocationsExclusiveScanAMD(f16vec4);"
2687 "int16_t addInvocationsExclusiveScanAMD(int16_t);"
2688 "i16vec2 addInvocationsExclusiveScanAMD(i16vec2);"
2689 "i16vec3 addInvocationsExclusiveScanAMD(i16vec3);"
2690 "i16vec4 addInvocationsExclusiveScanAMD(i16vec4);"
2692 "uint16_t addInvocationsExclusiveScanAMD(uint16_t);"
2693 "u16vec2 addInvocationsExclusiveScanAMD(u16vec2);"
2694 "u16vec3 addInvocationsExclusiveScanAMD(u16vec3);"
2695 "u16vec4 addInvocationsExclusiveScanAMD(u16vec4);"
2697 "float minInvocationsNonUniformAMD(float);"
2698 "vec2 minInvocationsNonUniformAMD(vec2);"
2699 "vec3 minInvocationsNonUniformAMD(vec3);"
2700 "vec4 minInvocationsNonUniformAMD(vec4);"
2702 "int minInvocationsNonUniformAMD(int);"
2703 "ivec2 minInvocationsNonUniformAMD(ivec2);"
2704 "ivec3 minInvocationsNonUniformAMD(ivec3);"
2705 "ivec4 minInvocationsNonUniformAMD(ivec4);"
2707 "uint minInvocationsNonUniformAMD(uint);"
2708 "uvec2 minInvocationsNonUniformAMD(uvec2);"
2709 "uvec3 minInvocationsNonUniformAMD(uvec3);"
2710 "uvec4 minInvocationsNonUniformAMD(uvec4);"
2712 "double minInvocationsNonUniformAMD(double);"
2713 "dvec2 minInvocationsNonUniformAMD(dvec2);"
2714 "dvec3 minInvocationsNonUniformAMD(dvec3);"
2715 "dvec4 minInvocationsNonUniformAMD(dvec4);"
2717 "int64_t minInvocationsNonUniformAMD(int64_t);"
2718 "i64vec2 minInvocationsNonUniformAMD(i64vec2);"
2719 "i64vec3 minInvocationsNonUniformAMD(i64vec3);"
2720 "i64vec4 minInvocationsNonUniformAMD(i64vec4);"
2722 "uint64_t minInvocationsNonUniformAMD(uint64_t);"
2723 "u64vec2 minInvocationsNonUniformAMD(u64vec2);"
2724 "u64vec3 minInvocationsNonUniformAMD(u64vec3);"
2725 "u64vec4 minInvocationsNonUniformAMD(u64vec4);"
2727 "float16_t minInvocationsNonUniformAMD(float16_t);"
2728 "f16vec2 minInvocationsNonUniformAMD(f16vec2);"
2729 "f16vec3 minInvocationsNonUniformAMD(f16vec3);"
2730 "f16vec4 minInvocationsNonUniformAMD(f16vec4);"
2732 "int16_t minInvocationsNonUniformAMD(int16_t);"
2733 "i16vec2 minInvocationsNonUniformAMD(i16vec2);"
2734 "i16vec3 minInvocationsNonUniformAMD(i16vec3);"
2735 "i16vec4 minInvocationsNonUniformAMD(i16vec4);"
2737 "uint16_t minInvocationsNonUniformAMD(uint16_t);"
2738 "u16vec2 minInvocationsNonUniformAMD(u16vec2);"
2739 "u16vec3 minInvocationsNonUniformAMD(u16vec3);"
2740 "u16vec4 minInvocationsNonUniformAMD(u16vec4);"
2742 "float minInvocationsInclusiveScanNonUniformAMD(float);"
2743 "vec2 minInvocationsInclusiveScanNonUniformAMD(vec2);"
2744 "vec3 minInvocationsInclusiveScanNonUniformAMD(vec3);"
2745 "vec4 minInvocationsInclusiveScanNonUniformAMD(vec4);"
2747 "int minInvocationsInclusiveScanNonUniformAMD(int);"
2748 "ivec2 minInvocationsInclusiveScanNonUniformAMD(ivec2);"
2749 "ivec3 minInvocationsInclusiveScanNonUniformAMD(ivec3);"
2750 "ivec4 minInvocationsInclusiveScanNonUniformAMD(ivec4);"
2752 "uint minInvocationsInclusiveScanNonUniformAMD(uint);"
2753 "uvec2 minInvocationsInclusiveScanNonUniformAMD(uvec2);"
2754 "uvec3 minInvocationsInclusiveScanNonUniformAMD(uvec3);"
2755 "uvec4 minInvocationsInclusiveScanNonUniformAMD(uvec4);"
2757 "double minInvocationsInclusiveScanNonUniformAMD(double);"
2758 "dvec2 minInvocationsInclusiveScanNonUniformAMD(dvec2);"
2759 "dvec3 minInvocationsInclusiveScanNonUniformAMD(dvec3);"
2760 "dvec4 minInvocationsInclusiveScanNonUniformAMD(dvec4);"
2762 "int64_t minInvocationsInclusiveScanNonUniformAMD(int64_t);"
2763 "i64vec2 minInvocationsInclusiveScanNonUniformAMD(i64vec2);"
2764 "i64vec3 minInvocationsInclusiveScanNonUniformAMD(i64vec3);"
2765 "i64vec4 minInvocationsInclusiveScanNonUniformAMD(i64vec4);"
2767 "uint64_t minInvocationsInclusiveScanNonUniformAMD(uint64_t);"
2768 "u64vec2 minInvocationsInclusiveScanNonUniformAMD(u64vec2);"
2769 "u64vec3 minInvocationsInclusiveScanNonUniformAMD(u64vec3);"
2770 "u64vec4 minInvocationsInclusiveScanNonUniformAMD(u64vec4);"
2772 "float16_t minInvocationsInclusiveScanNonUniformAMD(float16_t);"
2773 "f16vec2 minInvocationsInclusiveScanNonUniformAMD(f16vec2);"
2774 "f16vec3 minInvocationsInclusiveScanNonUniformAMD(f16vec3);"
2775 "f16vec4 minInvocationsInclusiveScanNonUniformAMD(f16vec4);"
2777 "int16_t minInvocationsInclusiveScanNonUniformAMD(int16_t);"
2778 "i16vec2 minInvocationsInclusiveScanNonUniformAMD(i16vec2);"
2779 "i16vec3 minInvocationsInclusiveScanNonUniformAMD(i16vec3);"
2780 "i16vec4 minInvocationsInclusiveScanNonUniformAMD(i16vec4);"
2782 "uint16_t minInvocationsInclusiveScanNonUniformAMD(uint16_t);"
2783 "u16vec2 minInvocationsInclusiveScanNonUniformAMD(u16vec2);"
2784 "u16vec3 minInvocationsInclusiveScanNonUniformAMD(u16vec3);"
2785 "u16vec4 minInvocationsInclusiveScanNonUniformAMD(u16vec4);"
2787 "float minInvocationsExclusiveScanNonUniformAMD(float);"
2788 "vec2 minInvocationsExclusiveScanNonUniformAMD(vec2);"
2789 "vec3 minInvocationsExclusiveScanNonUniformAMD(vec3);"
2790 "vec4 minInvocationsExclusiveScanNonUniformAMD(vec4);"
2792 "int minInvocationsExclusiveScanNonUniformAMD(int);"
2793 "ivec2 minInvocationsExclusiveScanNonUniformAMD(ivec2);"
2794 "ivec3 minInvocationsExclusiveScanNonUniformAMD(ivec3);"
2795 "ivec4 minInvocationsExclusiveScanNonUniformAMD(ivec4);"
2797 "uint minInvocationsExclusiveScanNonUniformAMD(uint);"
2798 "uvec2 minInvocationsExclusiveScanNonUniformAMD(uvec2);"
2799 "uvec3 minInvocationsExclusiveScanNonUniformAMD(uvec3);"
2800 "uvec4 minInvocationsExclusiveScanNonUniformAMD(uvec4);"
2802 "double minInvocationsExclusiveScanNonUniformAMD(double);"
2803 "dvec2 minInvocationsExclusiveScanNonUniformAMD(dvec2);"
2804 "dvec3 minInvocationsExclusiveScanNonUniformAMD(dvec3);"
2805 "dvec4 minInvocationsExclusiveScanNonUniformAMD(dvec4);"
2807 "int64_t minInvocationsExclusiveScanNonUniformAMD(int64_t);"
2808 "i64vec2 minInvocationsExclusiveScanNonUniformAMD(i64vec2);"
2809 "i64vec3 minInvocationsExclusiveScanNonUniformAMD(i64vec3);"
2810 "i64vec4 minInvocationsExclusiveScanNonUniformAMD(i64vec4);"
2812 "uint64_t minInvocationsExclusiveScanNonUniformAMD(uint64_t);"
2813 "u64vec2 minInvocationsExclusiveScanNonUniformAMD(u64vec2);"
2814 "u64vec3 minInvocationsExclusiveScanNonUniformAMD(u64vec3);"
2815 "u64vec4 minInvocationsExclusiveScanNonUniformAMD(u64vec4);"
2817 "float16_t minInvocationsExclusiveScanNonUniformAMD(float16_t);"
2818 "f16vec2 minInvocationsExclusiveScanNonUniformAMD(f16vec2);"
2819 "f16vec3 minInvocationsExclusiveScanNonUniformAMD(f16vec3);"
2820 "f16vec4 minInvocationsExclusiveScanNonUniformAMD(f16vec4);"
2822 "int16_t minInvocationsExclusiveScanNonUniformAMD(int16_t);"
2823 "i16vec2 minInvocationsExclusiveScanNonUniformAMD(i16vec2);"
2824 "i16vec3 minInvocationsExclusiveScanNonUniformAMD(i16vec3);"
2825 "i16vec4 minInvocationsExclusiveScanNonUniformAMD(i16vec4);"
2827 "uint16_t minInvocationsExclusiveScanNonUniformAMD(uint16_t);"
2828 "u16vec2 minInvocationsExclusiveScanNonUniformAMD(u16vec2);"
2829 "u16vec3 minInvocationsExclusiveScanNonUniformAMD(u16vec3);"
2830 "u16vec4 minInvocationsExclusiveScanNonUniformAMD(u16vec4);"
2832 "float maxInvocationsNonUniformAMD(float);"
2833 "vec2 maxInvocationsNonUniformAMD(vec2);"
2834 "vec3 maxInvocationsNonUniformAMD(vec3);"
2835 "vec4 maxInvocationsNonUniformAMD(vec4);"
2837 "int maxInvocationsNonUniformAMD(int);"
2838 "ivec2 maxInvocationsNonUniformAMD(ivec2);"
2839 "ivec3 maxInvocationsNonUniformAMD(ivec3);"
2840 "ivec4 maxInvocationsNonUniformAMD(ivec4);"
2842 "uint maxInvocationsNonUniformAMD(uint);"
2843 "uvec2 maxInvocationsNonUniformAMD(uvec2);"
2844 "uvec3 maxInvocationsNonUniformAMD(uvec3);"
2845 "uvec4 maxInvocationsNonUniformAMD(uvec4);"
2847 "double maxInvocationsNonUniformAMD(double);"
2848 "dvec2 maxInvocationsNonUniformAMD(dvec2);"
2849 "dvec3 maxInvocationsNonUniformAMD(dvec3);"
2850 "dvec4 maxInvocationsNonUniformAMD(dvec4);"
2852 "int64_t maxInvocationsNonUniformAMD(int64_t);"
2853 "i64vec2 maxInvocationsNonUniformAMD(i64vec2);"
2854 "i64vec3 maxInvocationsNonUniformAMD(i64vec3);"
2855 "i64vec4 maxInvocationsNonUniformAMD(i64vec4);"
2857 "uint64_t maxInvocationsNonUniformAMD(uint64_t);"
2858 "u64vec2 maxInvocationsNonUniformAMD(u64vec2);"
2859 "u64vec3 maxInvocationsNonUniformAMD(u64vec3);"
2860 "u64vec4 maxInvocationsNonUniformAMD(u64vec4);"
2862 "float16_t maxInvocationsNonUniformAMD(float16_t);"
2863 "f16vec2 maxInvocationsNonUniformAMD(f16vec2);"
2864 "f16vec3 maxInvocationsNonUniformAMD(f16vec3);"
2865 "f16vec4 maxInvocationsNonUniformAMD(f16vec4);"
2867 "int16_t maxInvocationsNonUniformAMD(int16_t);"
2868 "i16vec2 maxInvocationsNonUniformAMD(i16vec2);"
2869 "i16vec3 maxInvocationsNonUniformAMD(i16vec3);"
2870 "i16vec4 maxInvocationsNonUniformAMD(i16vec4);"
2872 "uint16_t maxInvocationsNonUniformAMD(uint16_t);"
2873 "u16vec2 maxInvocationsNonUniformAMD(u16vec2);"
2874 "u16vec3 maxInvocationsNonUniformAMD(u16vec3);"
2875 "u16vec4 maxInvocationsNonUniformAMD(u16vec4);"
2877 "float maxInvocationsInclusiveScanNonUniformAMD(float);"
2878 "vec2 maxInvocationsInclusiveScanNonUniformAMD(vec2);"
2879 "vec3 maxInvocationsInclusiveScanNonUniformAMD(vec3);"
2880 "vec4 maxInvocationsInclusiveScanNonUniformAMD(vec4);"
2882 "int maxInvocationsInclusiveScanNonUniformAMD(int);"
2883 "ivec2 maxInvocationsInclusiveScanNonUniformAMD(ivec2);"
2884 "ivec3 maxInvocationsInclusiveScanNonUniformAMD(ivec3);"
2885 "ivec4 maxInvocationsInclusiveScanNonUniformAMD(ivec4);"
2887 "uint maxInvocationsInclusiveScanNonUniformAMD(uint);"
2888 "uvec2 maxInvocationsInclusiveScanNonUniformAMD(uvec2);"
2889 "uvec3 maxInvocationsInclusiveScanNonUniformAMD(uvec3);"
2890 "uvec4 maxInvocationsInclusiveScanNonUniformAMD(uvec4);"
2892 "double maxInvocationsInclusiveScanNonUniformAMD(double);"
2893 "dvec2 maxInvocationsInclusiveScanNonUniformAMD(dvec2);"
2894 "dvec3 maxInvocationsInclusiveScanNonUniformAMD(dvec3);"
2895 "dvec4 maxInvocationsInclusiveScanNonUniformAMD(dvec4);"
2897 "int64_t maxInvocationsInclusiveScanNonUniformAMD(int64_t);"
2898 "i64vec2 maxInvocationsInclusiveScanNonUniformAMD(i64vec2);"
2899 "i64vec3 maxInvocationsInclusiveScanNonUniformAMD(i64vec3);"
2900 "i64vec4 maxInvocationsInclusiveScanNonUniformAMD(i64vec4);"
2902 "uint64_t maxInvocationsInclusiveScanNonUniformAMD(uint64_t);"
2903 "u64vec2 maxInvocationsInclusiveScanNonUniformAMD(u64vec2);"
2904 "u64vec3 maxInvocationsInclusiveScanNonUniformAMD(u64vec3);"
2905 "u64vec4 maxInvocationsInclusiveScanNonUniformAMD(u64vec4);"
2907 "float16_t maxInvocationsInclusiveScanNonUniformAMD(float16_t);"
2908 "f16vec2 maxInvocationsInclusiveScanNonUniformAMD(f16vec2);"
2909 "f16vec3 maxInvocationsInclusiveScanNonUniformAMD(f16vec3);"
2910 "f16vec4 maxInvocationsInclusiveScanNonUniformAMD(f16vec4);"
2912 "int16_t maxInvocationsInclusiveScanNonUniformAMD(int16_t);"
2913 "i16vec2 maxInvocationsInclusiveScanNonUniformAMD(i16vec2);"
2914 "i16vec3 maxInvocationsInclusiveScanNonUniformAMD(i16vec3);"
2915 "i16vec4 maxInvocationsInclusiveScanNonUniformAMD(i16vec4);"
2917 "uint16_t maxInvocationsInclusiveScanNonUniformAMD(uint16_t);"
2918 "u16vec2 maxInvocationsInclusiveScanNonUniformAMD(u16vec2);"
2919 "u16vec3 maxInvocationsInclusiveScanNonUniformAMD(u16vec3);"
2920 "u16vec4 maxInvocationsInclusiveScanNonUniformAMD(u16vec4);"
2922 "float maxInvocationsExclusiveScanNonUniformAMD(float);"
2923 "vec2 maxInvocationsExclusiveScanNonUniformAMD(vec2);"
2924 "vec3 maxInvocationsExclusiveScanNonUniformAMD(vec3);"
2925 "vec4 maxInvocationsExclusiveScanNonUniformAMD(vec4);"
2927 "int maxInvocationsExclusiveScanNonUniformAMD(int);"
2928 "ivec2 maxInvocationsExclusiveScanNonUniformAMD(ivec2);"
2929 "ivec3 maxInvocationsExclusiveScanNonUniformAMD(ivec3);"
2930 "ivec4 maxInvocationsExclusiveScanNonUniformAMD(ivec4);"
2932 "uint maxInvocationsExclusiveScanNonUniformAMD(uint);"
2933 "uvec2 maxInvocationsExclusiveScanNonUniformAMD(uvec2);"
2934 "uvec3 maxInvocationsExclusiveScanNonUniformAMD(uvec3);"
2935 "uvec4 maxInvocationsExclusiveScanNonUniformAMD(uvec4);"
2937 "double maxInvocationsExclusiveScanNonUniformAMD(double);"
2938 "dvec2 maxInvocationsExclusiveScanNonUniformAMD(dvec2);"
2939 "dvec3 maxInvocationsExclusiveScanNonUniformAMD(dvec3);"
2940 "dvec4 maxInvocationsExclusiveScanNonUniformAMD(dvec4);"
2942 "int64_t maxInvocationsExclusiveScanNonUniformAMD(int64_t);"
2943 "i64vec2 maxInvocationsExclusiveScanNonUniformAMD(i64vec2);"
2944 "i64vec3 maxInvocationsExclusiveScanNonUniformAMD(i64vec3);"
2945 "i64vec4 maxInvocationsExclusiveScanNonUniformAMD(i64vec4);"
2947 "uint64_t maxInvocationsExclusiveScanNonUniformAMD(uint64_t);"
2948 "u64vec2 maxInvocationsExclusiveScanNonUniformAMD(u64vec2);"
2949 "u64vec3 maxInvocationsExclusiveScanNonUniformAMD(u64vec3);"
2950 "u64vec4 maxInvocationsExclusiveScanNonUniformAMD(u64vec4);"
2952 "float16_t maxInvocationsExclusiveScanNonUniformAMD(float16_t);"
2953 "f16vec2 maxInvocationsExclusiveScanNonUniformAMD(f16vec2);"
2954 "f16vec3 maxInvocationsExclusiveScanNonUniformAMD(f16vec3);"
2955 "f16vec4 maxInvocationsExclusiveScanNonUniformAMD(f16vec4);"
2957 "int16_t maxInvocationsExclusiveScanNonUniformAMD(int16_t);"
2958 "i16vec2 maxInvocationsExclusiveScanNonUniformAMD(i16vec2);"
2959 "i16vec3 maxInvocationsExclusiveScanNonUniformAMD(i16vec3);"
2960 "i16vec4 maxInvocationsExclusiveScanNonUniformAMD(i16vec4);"
2962 "uint16_t maxInvocationsExclusiveScanNonUniformAMD(uint16_t);"
2963 "u16vec2 maxInvocationsExclusiveScanNonUniformAMD(u16vec2);"
2964 "u16vec3 maxInvocationsExclusiveScanNonUniformAMD(u16vec3);"
2965 "u16vec4 maxInvocationsExclusiveScanNonUniformAMD(u16vec4);"
2967 "float addInvocationsNonUniformAMD(float);"
2968 "vec2 addInvocationsNonUniformAMD(vec2);"
2969 "vec3 addInvocationsNonUniformAMD(vec3);"
2970 "vec4 addInvocationsNonUniformAMD(vec4);"
2972 "int addInvocationsNonUniformAMD(int);"
2973 "ivec2 addInvocationsNonUniformAMD(ivec2);"
2974 "ivec3 addInvocationsNonUniformAMD(ivec3);"
2975 "ivec4 addInvocationsNonUniformAMD(ivec4);"
2977 "uint addInvocationsNonUniformAMD(uint);"
2978 "uvec2 addInvocationsNonUniformAMD(uvec2);"
2979 "uvec3 addInvocationsNonUniformAMD(uvec3);"
2980 "uvec4 addInvocationsNonUniformAMD(uvec4);"
2982 "double addInvocationsNonUniformAMD(double);"
2983 "dvec2 addInvocationsNonUniformAMD(dvec2);"
2984 "dvec3 addInvocationsNonUniformAMD(dvec3);"
2985 "dvec4 addInvocationsNonUniformAMD(dvec4);"
2987 "int64_t addInvocationsNonUniformAMD(int64_t);"
2988 "i64vec2 addInvocationsNonUniformAMD(i64vec2);"
2989 "i64vec3 addInvocationsNonUniformAMD(i64vec3);"
2990 "i64vec4 addInvocationsNonUniformAMD(i64vec4);"
2992 "uint64_t addInvocationsNonUniformAMD(uint64_t);"
2993 "u64vec2 addInvocationsNonUniformAMD(u64vec2);"
2994 "u64vec3 addInvocationsNonUniformAMD(u64vec3);"
2995 "u64vec4 addInvocationsNonUniformAMD(u64vec4);"
2997 "float16_t addInvocationsNonUniformAMD(float16_t);"
2998 "f16vec2 addInvocationsNonUniformAMD(f16vec2);"
2999 "f16vec3 addInvocationsNonUniformAMD(f16vec3);"
3000 "f16vec4 addInvocationsNonUniformAMD(f16vec4);"
3002 "int16_t addInvocationsNonUniformAMD(int16_t);"
3003 "i16vec2 addInvocationsNonUniformAMD(i16vec2);"
3004 "i16vec3 addInvocationsNonUniformAMD(i16vec3);"
3005 "i16vec4 addInvocationsNonUniformAMD(i16vec4);"
3007 "uint16_t addInvocationsNonUniformAMD(uint16_t);"
3008 "u16vec2 addInvocationsNonUniformAMD(u16vec2);"
3009 "u16vec3 addInvocationsNonUniformAMD(u16vec3);"
3010 "u16vec4 addInvocationsNonUniformAMD(u16vec4);"
3012 "float addInvocationsInclusiveScanNonUniformAMD(float);"
3013 "vec2 addInvocationsInclusiveScanNonUniformAMD(vec2);"
3014 "vec3 addInvocationsInclusiveScanNonUniformAMD(vec3);"
3015 "vec4 addInvocationsInclusiveScanNonUniformAMD(vec4);"
3017 "int addInvocationsInclusiveScanNonUniformAMD(int);"
3018 "ivec2 addInvocationsInclusiveScanNonUniformAMD(ivec2);"
3019 "ivec3 addInvocationsInclusiveScanNonUniformAMD(ivec3);"
3020 "ivec4 addInvocationsInclusiveScanNonUniformAMD(ivec4);"
3022 "uint addInvocationsInclusiveScanNonUniformAMD(uint);"
3023 "uvec2 addInvocationsInclusiveScanNonUniformAMD(uvec2);"
3024 "uvec3 addInvocationsInclusiveScanNonUniformAMD(uvec3);"
3025 "uvec4 addInvocationsInclusiveScanNonUniformAMD(uvec4);"
3027 "double addInvocationsInclusiveScanNonUniformAMD(double);"
3028 "dvec2 addInvocationsInclusiveScanNonUniformAMD(dvec2);"
3029 "dvec3 addInvocationsInclusiveScanNonUniformAMD(dvec3);"
3030 "dvec4 addInvocationsInclusiveScanNonUniformAMD(dvec4);"
3032 "int64_t addInvocationsInclusiveScanNonUniformAMD(int64_t);"
3033 "i64vec2 addInvocationsInclusiveScanNonUniformAMD(i64vec2);"
3034 "i64vec3 addInvocationsInclusiveScanNonUniformAMD(i64vec3);"
3035 "i64vec4 addInvocationsInclusiveScanNonUniformAMD(i64vec4);"
3037 "uint64_t addInvocationsInclusiveScanNonUniformAMD(uint64_t);"
3038 "u64vec2 addInvocationsInclusiveScanNonUniformAMD(u64vec2);"
3039 "u64vec3 addInvocationsInclusiveScanNonUniformAMD(u64vec3);"
3040 "u64vec4 addInvocationsInclusiveScanNonUniformAMD(u64vec4);"
3042 "float16_t addInvocationsInclusiveScanNonUniformAMD(float16_t);"
3043 "f16vec2 addInvocationsInclusiveScanNonUniformAMD(f16vec2);"
3044 "f16vec3 addInvocationsInclusiveScanNonUniformAMD(f16vec3);"
3045 "f16vec4 addInvocationsInclusiveScanNonUniformAMD(f16vec4);"
3047 "int16_t addInvocationsInclusiveScanNonUniformAMD(int16_t);"
3048 "i16vec2 addInvocationsInclusiveScanNonUniformAMD(i16vec2);"
3049 "i16vec3 addInvocationsInclusiveScanNonUniformAMD(i16vec3);"
3050 "i16vec4 addInvocationsInclusiveScanNonUniformAMD(i16vec4);"
3052 "uint16_t addInvocationsInclusiveScanNonUniformAMD(uint16_t);"
3053 "u16vec2 addInvocationsInclusiveScanNonUniformAMD(u16vec2);"
3054 "u16vec3 addInvocationsInclusiveScanNonUniformAMD(u16vec3);"
3055 "u16vec4 addInvocationsInclusiveScanNonUniformAMD(u16vec4);"
3057 "float addInvocationsExclusiveScanNonUniformAMD(float);"
3058 "vec2 addInvocationsExclusiveScanNonUniformAMD(vec2);"
3059 "vec3 addInvocationsExclusiveScanNonUniformAMD(vec3);"
3060 "vec4 addInvocationsExclusiveScanNonUniformAMD(vec4);"
3062 "int addInvocationsExclusiveScanNonUniformAMD(int);"
3063 "ivec2 addInvocationsExclusiveScanNonUniformAMD(ivec2);"
3064 "ivec3 addInvocationsExclusiveScanNonUniformAMD(ivec3);"
3065 "ivec4 addInvocationsExclusiveScanNonUniformAMD(ivec4);"
3067 "uint addInvocationsExclusiveScanNonUniformAMD(uint);"
3068 "uvec2 addInvocationsExclusiveScanNonUniformAMD(uvec2);"
3069 "uvec3 addInvocationsExclusiveScanNonUniformAMD(uvec3);"
3070 "uvec4 addInvocationsExclusiveScanNonUniformAMD(uvec4);"
3072 "double addInvocationsExclusiveScanNonUniformAMD(double);"
3073 "dvec2 addInvocationsExclusiveScanNonUniformAMD(dvec2);"
3074 "dvec3 addInvocationsExclusiveScanNonUniformAMD(dvec3);"
3075 "dvec4 addInvocationsExclusiveScanNonUniformAMD(dvec4);"
3077 "int64_t addInvocationsExclusiveScanNonUniformAMD(int64_t);"
3078 "i64vec2 addInvocationsExclusiveScanNonUniformAMD(i64vec2);"
3079 "i64vec3 addInvocationsExclusiveScanNonUniformAMD(i64vec3);"
3080 "i64vec4 addInvocationsExclusiveScanNonUniformAMD(i64vec4);"
3082 "uint64_t addInvocationsExclusiveScanNonUniformAMD(uint64_t);"
3083 "u64vec2 addInvocationsExclusiveScanNonUniformAMD(u64vec2);"
3084 "u64vec3 addInvocationsExclusiveScanNonUniformAMD(u64vec3);"
3085 "u64vec4 addInvocationsExclusiveScanNonUniformAMD(u64vec4);"
3087 "float16_t addInvocationsExclusiveScanNonUniformAMD(float16_t);"
3088 "f16vec2 addInvocationsExclusiveScanNonUniformAMD(f16vec2);"
3089 "f16vec3 addInvocationsExclusiveScanNonUniformAMD(f16vec3);"
3090 "f16vec4 addInvocationsExclusiveScanNonUniformAMD(f16vec4);"
3092 "int16_t addInvocationsExclusiveScanNonUniformAMD(int16_t);"
3093 "i16vec2 addInvocationsExclusiveScanNonUniformAMD(i16vec2);"
3094 "i16vec3 addInvocationsExclusiveScanNonUniformAMD(i16vec3);"
3095 "i16vec4 addInvocationsExclusiveScanNonUniformAMD(i16vec4);"
3097 "uint16_t addInvocationsExclusiveScanNonUniformAMD(uint16_t);"
3098 "u16vec2 addInvocationsExclusiveScanNonUniformAMD(u16vec2);"
3099 "u16vec3 addInvocationsExclusiveScanNonUniformAMD(u16vec3);"
3100 "u16vec4 addInvocationsExclusiveScanNonUniformAMD(u16vec4);"
3102 "float swizzleInvocationsAMD(float, uvec4);"
3103 "vec2 swizzleInvocationsAMD(vec2, uvec4);"
3104 "vec3 swizzleInvocationsAMD(vec3, uvec4);"
3105 "vec4 swizzleInvocationsAMD(vec4, uvec4);"
3107 "int swizzleInvocationsAMD(int, uvec4);"
3108 "ivec2 swizzleInvocationsAMD(ivec2, uvec4);"
3109 "ivec3 swizzleInvocationsAMD(ivec3, uvec4);"
3110 "ivec4 swizzleInvocationsAMD(ivec4, uvec4);"
3112 "uint swizzleInvocationsAMD(uint, uvec4);"
3113 "uvec2 swizzleInvocationsAMD(uvec2, uvec4);"
3114 "uvec3 swizzleInvocationsAMD(uvec3, uvec4);"
3115 "uvec4 swizzleInvocationsAMD(uvec4, uvec4);"
3117 "float swizzleInvocationsMaskedAMD(float, uvec3);"
3118 "vec2 swizzleInvocationsMaskedAMD(vec2, uvec3);"
3119 "vec3 swizzleInvocationsMaskedAMD(vec3, uvec3);"
3120 "vec4 swizzleInvocationsMaskedAMD(vec4, uvec3);"
3122 "int swizzleInvocationsMaskedAMD(int, uvec3);"
3123 "ivec2 swizzleInvocationsMaskedAMD(ivec2, uvec3);"
3124 "ivec3 swizzleInvocationsMaskedAMD(ivec3, uvec3);"
3125 "ivec4 swizzleInvocationsMaskedAMD(ivec4, uvec3);"
3127 "uint swizzleInvocationsMaskedAMD(uint, uvec3);"
3128 "uvec2 swizzleInvocationsMaskedAMD(uvec2, uvec3);"
3129 "uvec3 swizzleInvocationsMaskedAMD(uvec3, uvec3);"
3130 "uvec4 swizzleInvocationsMaskedAMD(uvec4, uvec3);"
3132 "float writeInvocationAMD(float, float, uint);"
3133 "vec2 writeInvocationAMD(vec2, vec2, uint);"
3134 "vec3 writeInvocationAMD(vec3, vec3, uint);"
3135 "vec4 writeInvocationAMD(vec4, vec4, uint);"
3137 "int writeInvocationAMD(int, int, uint);"
3138 "ivec2 writeInvocationAMD(ivec2, ivec2, uint);"
3139 "ivec3 writeInvocationAMD(ivec3, ivec3, uint);"
3140 "ivec4 writeInvocationAMD(ivec4, ivec4, uint);"
3142 "uint writeInvocationAMD(uint, uint, uint);"
3143 "uvec2 writeInvocationAMD(uvec2, uvec2, uint);"
3144 "uvec3 writeInvocationAMD(uvec3, uvec3, uint);"
3145 "uvec4 writeInvocationAMD(uvec4, uvec4, uint);"
3147 "uint mbcntAMD(uint64_t);"
3152 // GL_AMD_gcn_shader
3153 if (profile != EEsProfile && version >= 440) {
3154 commonBuiltins.append(
3155 "float cubeFaceIndexAMD(vec3);"
3156 "vec2 cubeFaceCoordAMD(vec3);"
3157 "uint64_t timeAMD();"
3159 "in int gl_SIMDGroupSizeAMD;"
3163 // GL_AMD_shader_fragment_mask
3164 if (profile != EEsProfile && version >= 450) {
3165 commonBuiltins.append(
3166 "uint fragmentMaskFetchAMD(sampler2DMS, ivec2);"
3167 "uint fragmentMaskFetchAMD(isampler2DMS, ivec2);"
3168 "uint fragmentMaskFetchAMD(usampler2DMS, ivec2);"
3170 "uint fragmentMaskFetchAMD(sampler2DMSArray, ivec3);"
3171 "uint fragmentMaskFetchAMD(isampler2DMSArray, ivec3);"
3172 "uint fragmentMaskFetchAMD(usampler2DMSArray, ivec3);"
3174 "vec4 fragmentFetchAMD(sampler2DMS, ivec2, uint);"
3175 "ivec4 fragmentFetchAMD(isampler2DMS, ivec2, uint);"
3176 "uvec4 fragmentFetchAMD(usampler2DMS, ivec2, uint);"
3178 "vec4 fragmentFetchAMD(sampler2DMSArray, ivec3, uint);"
3179 "ivec4 fragmentFetchAMD(isampler2DMSArray, ivec3, uint);"
3180 "uvec4 fragmentFetchAMD(usampler2DMSArray, ivec3, uint);"
3185 if ((profile != EEsProfile && version >= 130) ||
3186 (profile == EEsProfile && version >= 300)) {
3187 commonBuiltins.append(
3188 "uint countLeadingZeros(uint);"
3189 "uvec2 countLeadingZeros(uvec2);"
3190 "uvec3 countLeadingZeros(uvec3);"
3191 "uvec4 countLeadingZeros(uvec4);"
3193 "uint countTrailingZeros(uint);"
3194 "uvec2 countTrailingZeros(uvec2);"
3195 "uvec3 countTrailingZeros(uvec3);"
3196 "uvec4 countTrailingZeros(uvec4);"
3198 "uint absoluteDifference(int, int);"
3199 "uvec2 absoluteDifference(ivec2, ivec2);"
3200 "uvec3 absoluteDifference(ivec3, ivec3);"
3201 "uvec4 absoluteDifference(ivec4, ivec4);"
3203 "uint16_t absoluteDifference(int16_t, int16_t);"
3204 "u16vec2 absoluteDifference(i16vec2, i16vec2);"
3205 "u16vec3 absoluteDifference(i16vec3, i16vec3);"
3206 "u16vec4 absoluteDifference(i16vec4, i16vec4);"
3208 "uint64_t absoluteDifference(int64_t, int64_t);"
3209 "u64vec2 absoluteDifference(i64vec2, i64vec2);"
3210 "u64vec3 absoluteDifference(i64vec3, i64vec3);"
3211 "u64vec4 absoluteDifference(i64vec4, i64vec4);"
3213 "uint absoluteDifference(uint, uint);"
3214 "uvec2 absoluteDifference(uvec2, uvec2);"
3215 "uvec3 absoluteDifference(uvec3, uvec3);"
3216 "uvec4 absoluteDifference(uvec4, uvec4);"
3218 "uint16_t absoluteDifference(uint16_t, uint16_t);"
3219 "u16vec2 absoluteDifference(u16vec2, u16vec2);"
3220 "u16vec3 absoluteDifference(u16vec3, u16vec3);"
3221 "u16vec4 absoluteDifference(u16vec4, u16vec4);"
3223 "uint64_t absoluteDifference(uint64_t, uint64_t);"
3224 "u64vec2 absoluteDifference(u64vec2, u64vec2);"
3225 "u64vec3 absoluteDifference(u64vec3, u64vec3);"
3226 "u64vec4 absoluteDifference(u64vec4, u64vec4);"
3228 "int addSaturate(int, int);"
3229 "ivec2 addSaturate(ivec2, ivec2);"
3230 "ivec3 addSaturate(ivec3, ivec3);"
3231 "ivec4 addSaturate(ivec4, ivec4);"
3233 "int16_t addSaturate(int16_t, int16_t);"
3234 "i16vec2 addSaturate(i16vec2, i16vec2);"
3235 "i16vec3 addSaturate(i16vec3, i16vec3);"
3236 "i16vec4 addSaturate(i16vec4, i16vec4);"
3238 "int64_t addSaturate(int64_t, int64_t);"
3239 "i64vec2 addSaturate(i64vec2, i64vec2);"
3240 "i64vec3 addSaturate(i64vec3, i64vec3);"
3241 "i64vec4 addSaturate(i64vec4, i64vec4);"
3243 "uint addSaturate(uint, uint);"
3244 "uvec2 addSaturate(uvec2, uvec2);"
3245 "uvec3 addSaturate(uvec3, uvec3);"
3246 "uvec4 addSaturate(uvec4, uvec4);"
3248 "uint16_t addSaturate(uint16_t, uint16_t);"
3249 "u16vec2 addSaturate(u16vec2, u16vec2);"
3250 "u16vec3 addSaturate(u16vec3, u16vec3);"
3251 "u16vec4 addSaturate(u16vec4, u16vec4);"
3253 "uint64_t addSaturate(uint64_t, uint64_t);"
3254 "u64vec2 addSaturate(u64vec2, u64vec2);"
3255 "u64vec3 addSaturate(u64vec3, u64vec3);"
3256 "u64vec4 addSaturate(u64vec4, u64vec4);"
3258 "int subtractSaturate(int, int);"
3259 "ivec2 subtractSaturate(ivec2, ivec2);"
3260 "ivec3 subtractSaturate(ivec3, ivec3);"
3261 "ivec4 subtractSaturate(ivec4, ivec4);"
3263 "int16_t subtractSaturate(int16_t, int16_t);"
3264 "i16vec2 subtractSaturate(i16vec2, i16vec2);"
3265 "i16vec3 subtractSaturate(i16vec3, i16vec3);"
3266 "i16vec4 subtractSaturate(i16vec4, i16vec4);"
3268 "int64_t subtractSaturate(int64_t, int64_t);"
3269 "i64vec2 subtractSaturate(i64vec2, i64vec2);"
3270 "i64vec3 subtractSaturate(i64vec3, i64vec3);"
3271 "i64vec4 subtractSaturate(i64vec4, i64vec4);"
3273 "uint subtractSaturate(uint, uint);"
3274 "uvec2 subtractSaturate(uvec2, uvec2);"
3275 "uvec3 subtractSaturate(uvec3, uvec3);"
3276 "uvec4 subtractSaturate(uvec4, uvec4);"
3278 "uint16_t subtractSaturate(uint16_t, uint16_t);"
3279 "u16vec2 subtractSaturate(u16vec2, u16vec2);"
3280 "u16vec3 subtractSaturate(u16vec3, u16vec3);"
3281 "u16vec4 subtractSaturate(u16vec4, u16vec4);"
3283 "uint64_t subtractSaturate(uint64_t, uint64_t);"
3284 "u64vec2 subtractSaturate(u64vec2, u64vec2);"
3285 "u64vec3 subtractSaturate(u64vec3, u64vec3);"
3286 "u64vec4 subtractSaturate(u64vec4, u64vec4);"
3288 "int average(int, int);"
3289 "ivec2 average(ivec2, ivec2);"
3290 "ivec3 average(ivec3, ivec3);"
3291 "ivec4 average(ivec4, ivec4);"
3293 "int16_t average(int16_t, int16_t);"
3294 "i16vec2 average(i16vec2, i16vec2);"
3295 "i16vec3 average(i16vec3, i16vec3);"
3296 "i16vec4 average(i16vec4, i16vec4);"
3298 "int64_t average(int64_t, int64_t);"
3299 "i64vec2 average(i64vec2, i64vec2);"
3300 "i64vec3 average(i64vec3, i64vec3);"
3301 "i64vec4 average(i64vec4, i64vec4);"
3303 "uint average(uint, uint);"
3304 "uvec2 average(uvec2, uvec2);"
3305 "uvec3 average(uvec3, uvec3);"
3306 "uvec4 average(uvec4, uvec4);"
3308 "uint16_t average(uint16_t, uint16_t);"
3309 "u16vec2 average(u16vec2, u16vec2);"
3310 "u16vec3 average(u16vec3, u16vec3);"
3311 "u16vec4 average(u16vec4, u16vec4);"
3313 "uint64_t average(uint64_t, uint64_t);"
3314 "u64vec2 average(u64vec2, u64vec2);"
3315 "u64vec3 average(u64vec3, u64vec3);"
3316 "u64vec4 average(u64vec4, u64vec4);"
3318 "int averageRounded(int, int);"
3319 "ivec2 averageRounded(ivec2, ivec2);"
3320 "ivec3 averageRounded(ivec3, ivec3);"
3321 "ivec4 averageRounded(ivec4, ivec4);"
3323 "int16_t averageRounded(int16_t, int16_t);"
3324 "i16vec2 averageRounded(i16vec2, i16vec2);"
3325 "i16vec3 averageRounded(i16vec3, i16vec3);"
3326 "i16vec4 averageRounded(i16vec4, i16vec4);"
3328 "int64_t averageRounded(int64_t, int64_t);"
3329 "i64vec2 averageRounded(i64vec2, i64vec2);"
3330 "i64vec3 averageRounded(i64vec3, i64vec3);"
3331 "i64vec4 averageRounded(i64vec4, i64vec4);"
3333 "uint averageRounded(uint, uint);"
3334 "uvec2 averageRounded(uvec2, uvec2);"
3335 "uvec3 averageRounded(uvec3, uvec3);"
3336 "uvec4 averageRounded(uvec4, uvec4);"
3338 "uint16_t averageRounded(uint16_t, uint16_t);"
3339 "u16vec2 averageRounded(u16vec2, u16vec2);"
3340 "u16vec3 averageRounded(u16vec3, u16vec3);"
3341 "u16vec4 averageRounded(u16vec4, u16vec4);"
3343 "uint64_t averageRounded(uint64_t, uint64_t);"
3344 "u64vec2 averageRounded(u64vec2, u64vec2);"
3345 "u64vec3 averageRounded(u64vec3, u64vec3);"
3346 "u64vec4 averageRounded(u64vec4, u64vec4);"
3348 "int multiply32x16(int, int);"
3349 "ivec2 multiply32x16(ivec2, ivec2);"
3350 "ivec3 multiply32x16(ivec3, ivec3);"
3351 "ivec4 multiply32x16(ivec4, ivec4);"
3353 "uint multiply32x16(uint, uint);"
3354 "uvec2 multiply32x16(uvec2, uvec2);"
3355 "uvec3 multiply32x16(uvec3, uvec3);"
3356 "uvec4 multiply32x16(uvec4, uvec4);"
3360 if ((profile != EEsProfile && version >= 450) ||
3361 (profile == EEsProfile && version >= 320)) {
3362 commonBuiltins.append(
3363 "struct gl_TextureFootprint2DNV {"
3371 "struct gl_TextureFootprint3DNV {"
3378 "bool textureFootprintNV(sampler2D, vec2, int, bool, out gl_TextureFootprint2DNV);"
3379 "bool textureFootprintNV(sampler3D, vec3, int, bool, out gl_TextureFootprint3DNV);"
3380 "bool textureFootprintNV(sampler2D, vec2, int, bool, out gl_TextureFootprint2DNV, float);"
3381 "bool textureFootprintNV(sampler3D, vec3, int, bool, out gl_TextureFootprint3DNV, float);"
3382 "bool textureFootprintClampNV(sampler2D, vec2, float, int, bool, out gl_TextureFootprint2DNV);"
3383 "bool textureFootprintClampNV(sampler3D, vec3, float, int, bool, out gl_TextureFootprint3DNV);"
3384 "bool textureFootprintClampNV(sampler2D, vec2, float, int, bool, out gl_TextureFootprint2DNV, float);"
3385 "bool textureFootprintClampNV(sampler3D, vec3, float, int, bool, out gl_TextureFootprint3DNV, float);"
3386 "bool textureFootprintLodNV(sampler2D, vec2, float, int, bool, out gl_TextureFootprint2DNV);"
3387 "bool textureFootprintLodNV(sampler3D, vec3, float, int, bool, out gl_TextureFootprint3DNV);"
3388 "bool textureFootprintGradNV(sampler2D, vec2, vec2, vec2, int, bool, out gl_TextureFootprint2DNV);"
3389 "bool textureFootprintGradClampNV(sampler2D, vec2, vec2, vec2, float, int, bool, out gl_TextureFootprint2DNV);"
3392 #endif // !GLSLANG_ANGLE
3394 if ((profile == EEsProfile && version >= 300 && version < 310) ||
3395 (profile != EEsProfile && version >= 150 && version < 450)) { // GL_EXT_shader_integer_mix
3396 commonBuiltins.append("int mix(int, int, bool);"
3397 "ivec2 mix(ivec2, ivec2, bvec2);"
3398 "ivec3 mix(ivec3, ivec3, bvec3);"
3399 "ivec4 mix(ivec4, ivec4, bvec4);"
3400 "uint mix(uint, uint, bool );"
3401 "uvec2 mix(uvec2, uvec2, bvec2);"
3402 "uvec3 mix(uvec3, uvec3, bvec3);"
3403 "uvec4 mix(uvec4, uvec4, bvec4);"
3404 "bool mix(bool, bool, bool );"
3405 "bvec2 mix(bvec2, bvec2, bvec2);"
3406 "bvec3 mix(bvec3, bvec3, bvec3);"
3407 "bvec4 mix(bvec4, bvec4, bvec4);"
3412 #ifndef GLSLANG_ANGLE
3413 // GL_AMD_gpu_shader_half_float/Explicit types
3414 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 310)) {
3415 commonBuiltins.append(
3416 "float16_t radians(float16_t);"
3417 "f16vec2 radians(f16vec2);"
3418 "f16vec3 radians(f16vec3);"
3419 "f16vec4 radians(f16vec4);"
3421 "float16_t degrees(float16_t);"
3422 "f16vec2 degrees(f16vec2);"
3423 "f16vec3 degrees(f16vec3);"
3424 "f16vec4 degrees(f16vec4);"
3426 "float16_t sin(float16_t);"
3427 "f16vec2 sin(f16vec2);"
3428 "f16vec3 sin(f16vec3);"
3429 "f16vec4 sin(f16vec4);"
3431 "float16_t cos(float16_t);"
3432 "f16vec2 cos(f16vec2);"
3433 "f16vec3 cos(f16vec3);"
3434 "f16vec4 cos(f16vec4);"
3436 "float16_t tan(float16_t);"
3437 "f16vec2 tan(f16vec2);"
3438 "f16vec3 tan(f16vec3);"
3439 "f16vec4 tan(f16vec4);"
3441 "float16_t asin(float16_t);"
3442 "f16vec2 asin(f16vec2);"
3443 "f16vec3 asin(f16vec3);"
3444 "f16vec4 asin(f16vec4);"
3446 "float16_t acos(float16_t);"
3447 "f16vec2 acos(f16vec2);"
3448 "f16vec3 acos(f16vec3);"
3449 "f16vec4 acos(f16vec4);"
3451 "float16_t atan(float16_t, float16_t);"
3452 "f16vec2 atan(f16vec2, f16vec2);"
3453 "f16vec3 atan(f16vec3, f16vec3);"
3454 "f16vec4 atan(f16vec4, f16vec4);"
3456 "float16_t atan(float16_t);"
3457 "f16vec2 atan(f16vec2);"
3458 "f16vec3 atan(f16vec3);"
3459 "f16vec4 atan(f16vec4);"
3461 "float16_t sinh(float16_t);"
3462 "f16vec2 sinh(f16vec2);"
3463 "f16vec3 sinh(f16vec3);"
3464 "f16vec4 sinh(f16vec4);"
3466 "float16_t cosh(float16_t);"
3467 "f16vec2 cosh(f16vec2);"
3468 "f16vec3 cosh(f16vec3);"
3469 "f16vec4 cosh(f16vec4);"
3471 "float16_t tanh(float16_t);"
3472 "f16vec2 tanh(f16vec2);"
3473 "f16vec3 tanh(f16vec3);"
3474 "f16vec4 tanh(f16vec4);"
3476 "float16_t asinh(float16_t);"
3477 "f16vec2 asinh(f16vec2);"
3478 "f16vec3 asinh(f16vec3);"
3479 "f16vec4 asinh(f16vec4);"
3481 "float16_t acosh(float16_t);"
3482 "f16vec2 acosh(f16vec2);"
3483 "f16vec3 acosh(f16vec3);"
3484 "f16vec4 acosh(f16vec4);"
3486 "float16_t atanh(float16_t);"
3487 "f16vec2 atanh(f16vec2);"
3488 "f16vec3 atanh(f16vec3);"
3489 "f16vec4 atanh(f16vec4);"
3491 "float16_t pow(float16_t, float16_t);"
3492 "f16vec2 pow(f16vec2, f16vec2);"
3493 "f16vec3 pow(f16vec3, f16vec3);"
3494 "f16vec4 pow(f16vec4, f16vec4);"
3496 "float16_t exp(float16_t);"
3497 "f16vec2 exp(f16vec2);"
3498 "f16vec3 exp(f16vec3);"
3499 "f16vec4 exp(f16vec4);"
3501 "float16_t log(float16_t);"
3502 "f16vec2 log(f16vec2);"
3503 "f16vec3 log(f16vec3);"
3504 "f16vec4 log(f16vec4);"
3506 "float16_t exp2(float16_t);"
3507 "f16vec2 exp2(f16vec2);"
3508 "f16vec3 exp2(f16vec3);"
3509 "f16vec4 exp2(f16vec4);"
3511 "float16_t log2(float16_t);"
3512 "f16vec2 log2(f16vec2);"
3513 "f16vec3 log2(f16vec3);"
3514 "f16vec4 log2(f16vec4);"
3516 "float16_t sqrt(float16_t);"
3517 "f16vec2 sqrt(f16vec2);"
3518 "f16vec3 sqrt(f16vec3);"
3519 "f16vec4 sqrt(f16vec4);"
3521 "float16_t inversesqrt(float16_t);"
3522 "f16vec2 inversesqrt(f16vec2);"
3523 "f16vec3 inversesqrt(f16vec3);"
3524 "f16vec4 inversesqrt(f16vec4);"
3526 "float16_t abs(float16_t);"
3527 "f16vec2 abs(f16vec2);"
3528 "f16vec3 abs(f16vec3);"
3529 "f16vec4 abs(f16vec4);"
3531 "float16_t sign(float16_t);"
3532 "f16vec2 sign(f16vec2);"
3533 "f16vec3 sign(f16vec3);"
3534 "f16vec4 sign(f16vec4);"
3536 "float16_t floor(float16_t);"
3537 "f16vec2 floor(f16vec2);"
3538 "f16vec3 floor(f16vec3);"
3539 "f16vec4 floor(f16vec4);"
3541 "float16_t trunc(float16_t);"
3542 "f16vec2 trunc(f16vec2);"
3543 "f16vec3 trunc(f16vec3);"
3544 "f16vec4 trunc(f16vec4);"
3546 "float16_t round(float16_t);"
3547 "f16vec2 round(f16vec2);"
3548 "f16vec3 round(f16vec3);"
3549 "f16vec4 round(f16vec4);"
3551 "float16_t roundEven(float16_t);"
3552 "f16vec2 roundEven(f16vec2);"
3553 "f16vec3 roundEven(f16vec3);"
3554 "f16vec4 roundEven(f16vec4);"
3556 "float16_t ceil(float16_t);"
3557 "f16vec2 ceil(f16vec2);"
3558 "f16vec3 ceil(f16vec3);"
3559 "f16vec4 ceil(f16vec4);"
3561 "float16_t fract(float16_t);"
3562 "f16vec2 fract(f16vec2);"
3563 "f16vec3 fract(f16vec3);"
3564 "f16vec4 fract(f16vec4);"
3566 "float16_t mod(float16_t, float16_t);"
3567 "f16vec2 mod(f16vec2, float16_t);"
3568 "f16vec3 mod(f16vec3, float16_t);"
3569 "f16vec4 mod(f16vec4, float16_t);"
3570 "f16vec2 mod(f16vec2, f16vec2);"
3571 "f16vec3 mod(f16vec3, f16vec3);"
3572 "f16vec4 mod(f16vec4, f16vec4);"
3574 "float16_t modf(float16_t, out float16_t);"
3575 "f16vec2 modf(f16vec2, out f16vec2);"
3576 "f16vec3 modf(f16vec3, out f16vec3);"
3577 "f16vec4 modf(f16vec4, out f16vec4);"
3579 "float16_t min(float16_t, float16_t);"
3580 "f16vec2 min(f16vec2, float16_t);"
3581 "f16vec3 min(f16vec3, float16_t);"
3582 "f16vec4 min(f16vec4, float16_t);"
3583 "f16vec2 min(f16vec2, f16vec2);"
3584 "f16vec3 min(f16vec3, f16vec3);"
3585 "f16vec4 min(f16vec4, f16vec4);"
3587 "float16_t max(float16_t, float16_t);"
3588 "f16vec2 max(f16vec2, float16_t);"
3589 "f16vec3 max(f16vec3, float16_t);"
3590 "f16vec4 max(f16vec4, float16_t);"
3591 "f16vec2 max(f16vec2, f16vec2);"
3592 "f16vec3 max(f16vec3, f16vec3);"
3593 "f16vec4 max(f16vec4, f16vec4);"
3595 "float16_t clamp(float16_t, float16_t, float16_t);"
3596 "f16vec2 clamp(f16vec2, float16_t, float16_t);"
3597 "f16vec3 clamp(f16vec3, float16_t, float16_t);"
3598 "f16vec4 clamp(f16vec4, float16_t, float16_t);"
3599 "f16vec2 clamp(f16vec2, f16vec2, f16vec2);"
3600 "f16vec3 clamp(f16vec3, f16vec3, f16vec3);"
3601 "f16vec4 clamp(f16vec4, f16vec4, f16vec4);"
3603 "float16_t mix(float16_t, float16_t, float16_t);"
3604 "f16vec2 mix(f16vec2, f16vec2, float16_t);"
3605 "f16vec3 mix(f16vec3, f16vec3, float16_t);"
3606 "f16vec4 mix(f16vec4, f16vec4, float16_t);"
3607 "f16vec2 mix(f16vec2, f16vec2, f16vec2);"
3608 "f16vec3 mix(f16vec3, f16vec3, f16vec3);"
3609 "f16vec4 mix(f16vec4, f16vec4, f16vec4);"
3610 "float16_t mix(float16_t, float16_t, bool);"
3611 "f16vec2 mix(f16vec2, f16vec2, bvec2);"
3612 "f16vec3 mix(f16vec3, f16vec3, bvec3);"
3613 "f16vec4 mix(f16vec4, f16vec4, bvec4);"
3615 "float16_t step(float16_t, float16_t);"
3616 "f16vec2 step(f16vec2, f16vec2);"
3617 "f16vec3 step(f16vec3, f16vec3);"
3618 "f16vec4 step(f16vec4, f16vec4);"
3619 "f16vec2 step(float16_t, f16vec2);"
3620 "f16vec3 step(float16_t, f16vec3);"
3621 "f16vec4 step(float16_t, f16vec4);"
3623 "float16_t smoothstep(float16_t, float16_t, float16_t);"
3624 "f16vec2 smoothstep(f16vec2, f16vec2, f16vec2);"
3625 "f16vec3 smoothstep(f16vec3, f16vec3, f16vec3);"
3626 "f16vec4 smoothstep(f16vec4, f16vec4, f16vec4);"
3627 "f16vec2 smoothstep(float16_t, float16_t, f16vec2);"
3628 "f16vec3 smoothstep(float16_t, float16_t, f16vec3);"
3629 "f16vec4 smoothstep(float16_t, float16_t, f16vec4);"
3631 "bool isnan(float16_t);"
3632 "bvec2 isnan(f16vec2);"
3633 "bvec3 isnan(f16vec3);"
3634 "bvec4 isnan(f16vec4);"
3636 "bool isinf(float16_t);"
3637 "bvec2 isinf(f16vec2);"
3638 "bvec3 isinf(f16vec3);"
3639 "bvec4 isinf(f16vec4);"
3641 "float16_t fma(float16_t, float16_t, float16_t);"
3642 "f16vec2 fma(f16vec2, f16vec2, f16vec2);"
3643 "f16vec3 fma(f16vec3, f16vec3, f16vec3);"
3644 "f16vec4 fma(f16vec4, f16vec4, f16vec4);"
3646 "float16_t frexp(float16_t, out int);"
3647 "f16vec2 frexp(f16vec2, out ivec2);"
3648 "f16vec3 frexp(f16vec3, out ivec3);"
3649 "f16vec4 frexp(f16vec4, out ivec4);"
3651 "float16_t ldexp(float16_t, in int);"
3652 "f16vec2 ldexp(f16vec2, in ivec2);"
3653 "f16vec3 ldexp(f16vec3, in ivec3);"
3654 "f16vec4 ldexp(f16vec4, in ivec4);"
3656 "uint packFloat2x16(f16vec2);"
3657 "f16vec2 unpackFloat2x16(uint);"
3659 "float16_t length(float16_t);"
3660 "float16_t length(f16vec2);"
3661 "float16_t length(f16vec3);"
3662 "float16_t length(f16vec4);"
3664 "float16_t distance(float16_t, float16_t);"
3665 "float16_t distance(f16vec2, f16vec2);"
3666 "float16_t distance(f16vec3, f16vec3);"
3667 "float16_t distance(f16vec4, f16vec4);"
3669 "float16_t dot(float16_t, float16_t);"
3670 "float16_t dot(f16vec2, f16vec2);"
3671 "float16_t dot(f16vec3, f16vec3);"
3672 "float16_t dot(f16vec4, f16vec4);"
3674 "f16vec3 cross(f16vec3, f16vec3);"
3676 "float16_t normalize(float16_t);"
3677 "f16vec2 normalize(f16vec2);"
3678 "f16vec3 normalize(f16vec3);"
3679 "f16vec4 normalize(f16vec4);"
3681 "float16_t faceforward(float16_t, float16_t, float16_t);"
3682 "f16vec2 faceforward(f16vec2, f16vec2, f16vec2);"
3683 "f16vec3 faceforward(f16vec3, f16vec3, f16vec3);"
3684 "f16vec4 faceforward(f16vec4, f16vec4, f16vec4);"
3686 "float16_t reflect(float16_t, float16_t);"
3687 "f16vec2 reflect(f16vec2, f16vec2);"
3688 "f16vec3 reflect(f16vec3, f16vec3);"
3689 "f16vec4 reflect(f16vec4, f16vec4);"
3691 "float16_t refract(float16_t, float16_t, float16_t);"
3692 "f16vec2 refract(f16vec2, f16vec2, float16_t);"
3693 "f16vec3 refract(f16vec3, f16vec3, float16_t);"
3694 "f16vec4 refract(f16vec4, f16vec4, float16_t);"
3696 "f16mat2 matrixCompMult(f16mat2, f16mat2);"
3697 "f16mat3 matrixCompMult(f16mat3, f16mat3);"
3698 "f16mat4 matrixCompMult(f16mat4, f16mat4);"
3699 "f16mat2x3 matrixCompMult(f16mat2x3, f16mat2x3);"
3700 "f16mat2x4 matrixCompMult(f16mat2x4, f16mat2x4);"
3701 "f16mat3x2 matrixCompMult(f16mat3x2, f16mat3x2);"
3702 "f16mat3x4 matrixCompMult(f16mat3x4, f16mat3x4);"
3703 "f16mat4x2 matrixCompMult(f16mat4x2, f16mat4x2);"
3704 "f16mat4x3 matrixCompMult(f16mat4x3, f16mat4x3);"
3706 "f16mat2 outerProduct(f16vec2, f16vec2);"
3707 "f16mat3 outerProduct(f16vec3, f16vec3);"
3708 "f16mat4 outerProduct(f16vec4, f16vec4);"
3709 "f16mat2x3 outerProduct(f16vec3, f16vec2);"
3710 "f16mat3x2 outerProduct(f16vec2, f16vec3);"
3711 "f16mat2x4 outerProduct(f16vec4, f16vec2);"
3712 "f16mat4x2 outerProduct(f16vec2, f16vec4);"
3713 "f16mat3x4 outerProduct(f16vec4, f16vec3);"
3714 "f16mat4x3 outerProduct(f16vec3, f16vec4);"
3716 "f16mat2 transpose(f16mat2);"
3717 "f16mat3 transpose(f16mat3);"
3718 "f16mat4 transpose(f16mat4);"
3719 "f16mat2x3 transpose(f16mat3x2);"
3720 "f16mat3x2 transpose(f16mat2x3);"
3721 "f16mat2x4 transpose(f16mat4x2);"
3722 "f16mat4x2 transpose(f16mat2x4);"
3723 "f16mat3x4 transpose(f16mat4x3);"
3724 "f16mat4x3 transpose(f16mat3x4);"
3726 "float16_t determinant(f16mat2);"
3727 "float16_t determinant(f16mat3);"
3728 "float16_t determinant(f16mat4);"
3730 "f16mat2 inverse(f16mat2);"
3731 "f16mat3 inverse(f16mat3);"
3732 "f16mat4 inverse(f16mat4);"
3734 "bvec2 lessThan(f16vec2, f16vec2);"
3735 "bvec3 lessThan(f16vec3, f16vec3);"
3736 "bvec4 lessThan(f16vec4, f16vec4);"
3738 "bvec2 lessThanEqual(f16vec2, f16vec2);"
3739 "bvec3 lessThanEqual(f16vec3, f16vec3);"
3740 "bvec4 lessThanEqual(f16vec4, f16vec4);"
3742 "bvec2 greaterThan(f16vec2, f16vec2);"
3743 "bvec3 greaterThan(f16vec3, f16vec3);"
3744 "bvec4 greaterThan(f16vec4, f16vec4);"
3746 "bvec2 greaterThanEqual(f16vec2, f16vec2);"
3747 "bvec3 greaterThanEqual(f16vec3, f16vec3);"
3748 "bvec4 greaterThanEqual(f16vec4, f16vec4);"
3750 "bvec2 equal(f16vec2, f16vec2);"
3751 "bvec3 equal(f16vec3, f16vec3);"
3752 "bvec4 equal(f16vec4, f16vec4);"
3754 "bvec2 notEqual(f16vec2, f16vec2);"
3755 "bvec3 notEqual(f16vec3, f16vec3);"
3756 "bvec4 notEqual(f16vec4, f16vec4);"
3762 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 310)) {
3763 commonBuiltins.append(
3764 "int8_t abs(int8_t);"
3765 "i8vec2 abs(i8vec2);"
3766 "i8vec3 abs(i8vec3);"
3767 "i8vec4 abs(i8vec4);"
3769 "int8_t sign(int8_t);"
3770 "i8vec2 sign(i8vec2);"
3771 "i8vec3 sign(i8vec3);"
3772 "i8vec4 sign(i8vec4);"
3774 "int8_t min(int8_t x, int8_t y);"
3775 "i8vec2 min(i8vec2 x, int8_t y);"
3776 "i8vec3 min(i8vec3 x, int8_t y);"
3777 "i8vec4 min(i8vec4 x, int8_t y);"
3778 "i8vec2 min(i8vec2 x, i8vec2 y);"
3779 "i8vec3 min(i8vec3 x, i8vec3 y);"
3780 "i8vec4 min(i8vec4 x, i8vec4 y);"
3782 "uint8_t min(uint8_t x, uint8_t y);"
3783 "u8vec2 min(u8vec2 x, uint8_t y);"
3784 "u8vec3 min(u8vec3 x, uint8_t y);"
3785 "u8vec4 min(u8vec4 x, uint8_t y);"
3786 "u8vec2 min(u8vec2 x, u8vec2 y);"
3787 "u8vec3 min(u8vec3 x, u8vec3 y);"
3788 "u8vec4 min(u8vec4 x, u8vec4 y);"
3790 "int8_t max(int8_t x, int8_t y);"
3791 "i8vec2 max(i8vec2 x, int8_t y);"
3792 "i8vec3 max(i8vec3 x, int8_t y);"
3793 "i8vec4 max(i8vec4 x, int8_t y);"
3794 "i8vec2 max(i8vec2 x, i8vec2 y);"
3795 "i8vec3 max(i8vec3 x, i8vec3 y);"
3796 "i8vec4 max(i8vec4 x, i8vec4 y);"
3798 "uint8_t max(uint8_t x, uint8_t y);"
3799 "u8vec2 max(u8vec2 x, uint8_t y);"
3800 "u8vec3 max(u8vec3 x, uint8_t y);"
3801 "u8vec4 max(u8vec4 x, uint8_t y);"
3802 "u8vec2 max(u8vec2 x, u8vec2 y);"
3803 "u8vec3 max(u8vec3 x, u8vec3 y);"
3804 "u8vec4 max(u8vec4 x, u8vec4 y);"
3806 "int8_t clamp(int8_t x, int8_t minVal, int8_t maxVal);"
3807 "i8vec2 clamp(i8vec2 x, int8_t minVal, int8_t maxVal);"
3808 "i8vec3 clamp(i8vec3 x, int8_t minVal, int8_t maxVal);"
3809 "i8vec4 clamp(i8vec4 x, int8_t minVal, int8_t maxVal);"
3810 "i8vec2 clamp(i8vec2 x, i8vec2 minVal, i8vec2 maxVal);"
3811 "i8vec3 clamp(i8vec3 x, i8vec3 minVal, i8vec3 maxVal);"
3812 "i8vec4 clamp(i8vec4 x, i8vec4 minVal, i8vec4 maxVal);"
3814 "uint8_t clamp(uint8_t x, uint8_t minVal, uint8_t maxVal);"
3815 "u8vec2 clamp(u8vec2 x, uint8_t minVal, uint8_t maxVal);"
3816 "u8vec3 clamp(u8vec3 x, uint8_t minVal, uint8_t maxVal);"
3817 "u8vec4 clamp(u8vec4 x, uint8_t minVal, uint8_t maxVal);"
3818 "u8vec2 clamp(u8vec2 x, u8vec2 minVal, u8vec2 maxVal);"
3819 "u8vec3 clamp(u8vec3 x, u8vec3 minVal, u8vec3 maxVal);"
3820 "u8vec4 clamp(u8vec4 x, u8vec4 minVal, u8vec4 maxVal);"
3822 "int8_t mix(int8_t, int8_t, bool);"
3823 "i8vec2 mix(i8vec2, i8vec2, bvec2);"
3824 "i8vec3 mix(i8vec3, i8vec3, bvec3);"
3825 "i8vec4 mix(i8vec4, i8vec4, bvec4);"
3826 "uint8_t mix(uint8_t, uint8_t, bool);"
3827 "u8vec2 mix(u8vec2, u8vec2, bvec2);"
3828 "u8vec3 mix(u8vec3, u8vec3, bvec3);"
3829 "u8vec4 mix(u8vec4, u8vec4, bvec4);"
3831 "bvec2 lessThan(i8vec2, i8vec2);"
3832 "bvec3 lessThan(i8vec3, i8vec3);"
3833 "bvec4 lessThan(i8vec4, i8vec4);"
3834 "bvec2 lessThan(u8vec2, u8vec2);"
3835 "bvec3 lessThan(u8vec3, u8vec3);"
3836 "bvec4 lessThan(u8vec4, u8vec4);"
3838 "bvec2 lessThanEqual(i8vec2, i8vec2);"
3839 "bvec3 lessThanEqual(i8vec3, i8vec3);"
3840 "bvec4 lessThanEqual(i8vec4, i8vec4);"
3841 "bvec2 lessThanEqual(u8vec2, u8vec2);"
3842 "bvec3 lessThanEqual(u8vec3, u8vec3);"
3843 "bvec4 lessThanEqual(u8vec4, u8vec4);"
3845 "bvec2 greaterThan(i8vec2, i8vec2);"
3846 "bvec3 greaterThan(i8vec3, i8vec3);"
3847 "bvec4 greaterThan(i8vec4, i8vec4);"
3848 "bvec2 greaterThan(u8vec2, u8vec2);"
3849 "bvec3 greaterThan(u8vec3, u8vec3);"
3850 "bvec4 greaterThan(u8vec4, u8vec4);"
3852 "bvec2 greaterThanEqual(i8vec2, i8vec2);"
3853 "bvec3 greaterThanEqual(i8vec3, i8vec3);"
3854 "bvec4 greaterThanEqual(i8vec4, i8vec4);"
3855 "bvec2 greaterThanEqual(u8vec2, u8vec2);"
3856 "bvec3 greaterThanEqual(u8vec3, u8vec3);"
3857 "bvec4 greaterThanEqual(u8vec4, u8vec4);"
3859 "bvec2 equal(i8vec2, i8vec2);"
3860 "bvec3 equal(i8vec3, i8vec3);"
3861 "bvec4 equal(i8vec4, i8vec4);"
3862 "bvec2 equal(u8vec2, u8vec2);"
3863 "bvec3 equal(u8vec3, u8vec3);"
3864 "bvec4 equal(u8vec4, u8vec4);"
3866 "bvec2 notEqual(i8vec2, i8vec2);"
3867 "bvec3 notEqual(i8vec3, i8vec3);"
3868 "bvec4 notEqual(i8vec4, i8vec4);"
3869 "bvec2 notEqual(u8vec2, u8vec2);"
3870 "bvec3 notEqual(u8vec3, u8vec3);"
3871 "bvec4 notEqual(u8vec4, u8vec4);"
3873 " int8_t bitfieldExtract( int8_t, int8_t, int8_t);"
3874 "i8vec2 bitfieldExtract(i8vec2, int8_t, int8_t);"
3875 "i8vec3 bitfieldExtract(i8vec3, int8_t, int8_t);"
3876 "i8vec4 bitfieldExtract(i8vec4, int8_t, int8_t);"
3878 " uint8_t bitfieldExtract( uint8_t, int8_t, int8_t);"
3879 "u8vec2 bitfieldExtract(u8vec2, int8_t, int8_t);"
3880 "u8vec3 bitfieldExtract(u8vec3, int8_t, int8_t);"
3881 "u8vec4 bitfieldExtract(u8vec4, int8_t, int8_t);"
3883 " int8_t bitfieldInsert( int8_t base, int8_t, int8_t, int8_t);"
3884 "i8vec2 bitfieldInsert(i8vec2 base, i8vec2, int8_t, int8_t);"
3885 "i8vec3 bitfieldInsert(i8vec3 base, i8vec3, int8_t, int8_t);"
3886 "i8vec4 bitfieldInsert(i8vec4 base, i8vec4, int8_t, int8_t);"
3888 " uint8_t bitfieldInsert( uint8_t base, uint8_t, int8_t, int8_t);"
3889 "u8vec2 bitfieldInsert(u8vec2 base, u8vec2, int8_t, int8_t);"
3890 "u8vec3 bitfieldInsert(u8vec3 base, u8vec3, int8_t, int8_t);"
3891 "u8vec4 bitfieldInsert(u8vec4 base, u8vec4, int8_t, int8_t);"
3893 " int8_t bitCount( int8_t);"
3894 "i8vec2 bitCount(i8vec2);"
3895 "i8vec3 bitCount(i8vec3);"
3896 "i8vec4 bitCount(i8vec4);"
3898 " int8_t bitCount( uint8_t);"
3899 "i8vec2 bitCount(u8vec2);"
3900 "i8vec3 bitCount(u8vec3);"
3901 "i8vec4 bitCount(u8vec4);"
3903 " int8_t findLSB( int8_t);"
3904 "i8vec2 findLSB(i8vec2);"
3905 "i8vec3 findLSB(i8vec3);"
3906 "i8vec4 findLSB(i8vec4);"
3908 " int8_t findLSB( uint8_t);"
3909 "i8vec2 findLSB(u8vec2);"
3910 "i8vec3 findLSB(u8vec3);"
3911 "i8vec4 findLSB(u8vec4);"
3913 " int8_t findMSB( int8_t);"
3914 "i8vec2 findMSB(i8vec2);"
3915 "i8vec3 findMSB(i8vec3);"
3916 "i8vec4 findMSB(i8vec4);"
3918 " int8_t findMSB( uint8_t);"
3919 "i8vec2 findMSB(u8vec2);"
3920 "i8vec3 findMSB(u8vec3);"
3921 "i8vec4 findMSB(u8vec4);"
3923 "int16_t abs(int16_t);"
3924 "i16vec2 abs(i16vec2);"
3925 "i16vec3 abs(i16vec3);"
3926 "i16vec4 abs(i16vec4);"
3928 "int16_t sign(int16_t);"
3929 "i16vec2 sign(i16vec2);"
3930 "i16vec3 sign(i16vec3);"
3931 "i16vec4 sign(i16vec4);"
3933 "int16_t min(int16_t x, int16_t y);"
3934 "i16vec2 min(i16vec2 x, int16_t y);"
3935 "i16vec3 min(i16vec3 x, int16_t y);"
3936 "i16vec4 min(i16vec4 x, int16_t y);"
3937 "i16vec2 min(i16vec2 x, i16vec2 y);"
3938 "i16vec3 min(i16vec3 x, i16vec3 y);"
3939 "i16vec4 min(i16vec4 x, i16vec4 y);"
3941 "uint16_t min(uint16_t x, uint16_t y);"
3942 "u16vec2 min(u16vec2 x, uint16_t y);"
3943 "u16vec3 min(u16vec3 x, uint16_t y);"
3944 "u16vec4 min(u16vec4 x, uint16_t y);"
3945 "u16vec2 min(u16vec2 x, u16vec2 y);"
3946 "u16vec3 min(u16vec3 x, u16vec3 y);"
3947 "u16vec4 min(u16vec4 x, u16vec4 y);"
3949 "int16_t max(int16_t x, int16_t y);"
3950 "i16vec2 max(i16vec2 x, int16_t y);"
3951 "i16vec3 max(i16vec3 x, int16_t y);"
3952 "i16vec4 max(i16vec4 x, int16_t y);"
3953 "i16vec2 max(i16vec2 x, i16vec2 y);"
3954 "i16vec3 max(i16vec3 x, i16vec3 y);"
3955 "i16vec4 max(i16vec4 x, i16vec4 y);"
3957 "uint16_t max(uint16_t x, uint16_t y);"
3958 "u16vec2 max(u16vec2 x, uint16_t y);"
3959 "u16vec3 max(u16vec3 x, uint16_t y);"
3960 "u16vec4 max(u16vec4 x, uint16_t y);"
3961 "u16vec2 max(u16vec2 x, u16vec2 y);"
3962 "u16vec3 max(u16vec3 x, u16vec3 y);"
3963 "u16vec4 max(u16vec4 x, u16vec4 y);"
3965 "int16_t clamp(int16_t x, int16_t minVal, int16_t maxVal);"
3966 "i16vec2 clamp(i16vec2 x, int16_t minVal, int16_t maxVal);"
3967 "i16vec3 clamp(i16vec3 x, int16_t minVal, int16_t maxVal);"
3968 "i16vec4 clamp(i16vec4 x, int16_t minVal, int16_t maxVal);"
3969 "i16vec2 clamp(i16vec2 x, i16vec2 minVal, i16vec2 maxVal);"
3970 "i16vec3 clamp(i16vec3 x, i16vec3 minVal, i16vec3 maxVal);"
3971 "i16vec4 clamp(i16vec4 x, i16vec4 minVal, i16vec4 maxVal);"
3973 "uint16_t clamp(uint16_t x, uint16_t minVal, uint16_t maxVal);"
3974 "u16vec2 clamp(u16vec2 x, uint16_t minVal, uint16_t maxVal);"
3975 "u16vec3 clamp(u16vec3 x, uint16_t minVal, uint16_t maxVal);"
3976 "u16vec4 clamp(u16vec4 x, uint16_t minVal, uint16_t maxVal);"
3977 "u16vec2 clamp(u16vec2 x, u16vec2 minVal, u16vec2 maxVal);"
3978 "u16vec3 clamp(u16vec3 x, u16vec3 minVal, u16vec3 maxVal);"
3979 "u16vec4 clamp(u16vec4 x, u16vec4 minVal, u16vec4 maxVal);"
3981 "int16_t mix(int16_t, int16_t, bool);"
3982 "i16vec2 mix(i16vec2, i16vec2, bvec2);"
3983 "i16vec3 mix(i16vec3, i16vec3, bvec3);"
3984 "i16vec4 mix(i16vec4, i16vec4, bvec4);"
3985 "uint16_t mix(uint16_t, uint16_t, bool);"
3986 "u16vec2 mix(u16vec2, u16vec2, bvec2);"
3987 "u16vec3 mix(u16vec3, u16vec3, bvec3);"
3988 "u16vec4 mix(u16vec4, u16vec4, bvec4);"
3990 "float16_t frexp(float16_t, out int16_t);"
3991 "f16vec2 frexp(f16vec2, out i16vec2);"
3992 "f16vec3 frexp(f16vec3, out i16vec3);"
3993 "f16vec4 frexp(f16vec4, out i16vec4);"
3995 "float16_t ldexp(float16_t, int16_t);"
3996 "f16vec2 ldexp(f16vec2, i16vec2);"
3997 "f16vec3 ldexp(f16vec3, i16vec3);"
3998 "f16vec4 ldexp(f16vec4, i16vec4);"
4000 "int16_t halfBitsToInt16(float16_t);"
4001 "i16vec2 halfBitsToInt16(f16vec2);"
4002 "i16vec3 halhBitsToInt16(f16vec3);"
4003 "i16vec4 halfBitsToInt16(f16vec4);"
4005 "uint16_t halfBitsToUint16(float16_t);"
4006 "u16vec2 halfBitsToUint16(f16vec2);"
4007 "u16vec3 halfBitsToUint16(f16vec3);"
4008 "u16vec4 halfBitsToUint16(f16vec4);"
4010 "int16_t float16BitsToInt16(float16_t);"
4011 "i16vec2 float16BitsToInt16(f16vec2);"
4012 "i16vec3 float16BitsToInt16(f16vec3);"
4013 "i16vec4 float16BitsToInt16(f16vec4);"
4015 "uint16_t float16BitsToUint16(float16_t);"
4016 "u16vec2 float16BitsToUint16(f16vec2);"
4017 "u16vec3 float16BitsToUint16(f16vec3);"
4018 "u16vec4 float16BitsToUint16(f16vec4);"
4020 "float16_t int16BitsToFloat16(int16_t);"
4021 "f16vec2 int16BitsToFloat16(i16vec2);"
4022 "f16vec3 int16BitsToFloat16(i16vec3);"
4023 "f16vec4 int16BitsToFloat16(i16vec4);"
4025 "float16_t uint16BitsToFloat16(uint16_t);"
4026 "f16vec2 uint16BitsToFloat16(u16vec2);"
4027 "f16vec3 uint16BitsToFloat16(u16vec3);"
4028 "f16vec4 uint16BitsToFloat16(u16vec4);"
4030 "float16_t int16BitsToHalf(int16_t);"
4031 "f16vec2 int16BitsToHalf(i16vec2);"
4032 "f16vec3 int16BitsToHalf(i16vec3);"
4033 "f16vec4 int16BitsToHalf(i16vec4);"
4035 "float16_t uint16BitsToHalf(uint16_t);"
4036 "f16vec2 uint16BitsToHalf(u16vec2);"
4037 "f16vec3 uint16BitsToHalf(u16vec3);"
4038 "f16vec4 uint16BitsToHalf(u16vec4);"
4040 "int packInt2x16(i16vec2);"
4041 "uint packUint2x16(u16vec2);"
4042 "int64_t packInt4x16(i16vec4);"
4043 "uint64_t packUint4x16(u16vec4);"
4044 "i16vec2 unpackInt2x16(int);"
4045 "u16vec2 unpackUint2x16(uint);"
4046 "i16vec4 unpackInt4x16(int64_t);"
4047 "u16vec4 unpackUint4x16(uint64_t);"
4049 "bvec2 lessThan(i16vec2, i16vec2);"
4050 "bvec3 lessThan(i16vec3, i16vec3);"
4051 "bvec4 lessThan(i16vec4, i16vec4);"
4052 "bvec2 lessThan(u16vec2, u16vec2);"
4053 "bvec3 lessThan(u16vec3, u16vec3);"
4054 "bvec4 lessThan(u16vec4, u16vec4);"
4056 "bvec2 lessThanEqual(i16vec2, i16vec2);"
4057 "bvec3 lessThanEqual(i16vec3, i16vec3);"
4058 "bvec4 lessThanEqual(i16vec4, i16vec4);"
4059 "bvec2 lessThanEqual(u16vec2, u16vec2);"
4060 "bvec3 lessThanEqual(u16vec3, u16vec3);"
4061 "bvec4 lessThanEqual(u16vec4, u16vec4);"
4063 "bvec2 greaterThan(i16vec2, i16vec2);"
4064 "bvec3 greaterThan(i16vec3, i16vec3);"
4065 "bvec4 greaterThan(i16vec4, i16vec4);"
4066 "bvec2 greaterThan(u16vec2, u16vec2);"
4067 "bvec3 greaterThan(u16vec3, u16vec3);"
4068 "bvec4 greaterThan(u16vec4, u16vec4);"
4070 "bvec2 greaterThanEqual(i16vec2, i16vec2);"
4071 "bvec3 greaterThanEqual(i16vec3, i16vec3);"
4072 "bvec4 greaterThanEqual(i16vec4, i16vec4);"
4073 "bvec2 greaterThanEqual(u16vec2, u16vec2);"
4074 "bvec3 greaterThanEqual(u16vec3, u16vec3);"
4075 "bvec4 greaterThanEqual(u16vec4, u16vec4);"
4077 "bvec2 equal(i16vec2, i16vec2);"
4078 "bvec3 equal(i16vec3, i16vec3);"
4079 "bvec4 equal(i16vec4, i16vec4);"
4080 "bvec2 equal(u16vec2, u16vec2);"
4081 "bvec3 equal(u16vec3, u16vec3);"
4082 "bvec4 equal(u16vec4, u16vec4);"
4084 "bvec2 notEqual(i16vec2, i16vec2);"
4085 "bvec3 notEqual(i16vec3, i16vec3);"
4086 "bvec4 notEqual(i16vec4, i16vec4);"
4087 "bvec2 notEqual(u16vec2, u16vec2);"
4088 "bvec3 notEqual(u16vec3, u16vec3);"
4089 "bvec4 notEqual(u16vec4, u16vec4);"
4091 " int16_t bitfieldExtract( int16_t, int16_t, int16_t);"
4092 "i16vec2 bitfieldExtract(i16vec2, int16_t, int16_t);"
4093 "i16vec3 bitfieldExtract(i16vec3, int16_t, int16_t);"
4094 "i16vec4 bitfieldExtract(i16vec4, int16_t, int16_t);"
4096 " uint16_t bitfieldExtract( uint16_t, int16_t, int16_t);"
4097 "u16vec2 bitfieldExtract(u16vec2, int16_t, int16_t);"
4098 "u16vec3 bitfieldExtract(u16vec3, int16_t, int16_t);"
4099 "u16vec4 bitfieldExtract(u16vec4, int16_t, int16_t);"
4101 " int16_t bitfieldInsert( int16_t base, int16_t, int16_t, int16_t);"
4102 "i16vec2 bitfieldInsert(i16vec2 base, i16vec2, int16_t, int16_t);"
4103 "i16vec3 bitfieldInsert(i16vec3 base, i16vec3, int16_t, int16_t);"
4104 "i16vec4 bitfieldInsert(i16vec4 base, i16vec4, int16_t, int16_t);"
4106 " uint16_t bitfieldInsert( uint16_t base, uint16_t, int16_t, int16_t);"
4107 "u16vec2 bitfieldInsert(u16vec2 base, u16vec2, int16_t, int16_t);"
4108 "u16vec3 bitfieldInsert(u16vec3 base, u16vec3, int16_t, int16_t);"
4109 "u16vec4 bitfieldInsert(u16vec4 base, u16vec4, int16_t, int16_t);"
4111 " int16_t bitCount( int16_t);"
4112 "i16vec2 bitCount(i16vec2);"
4113 "i16vec3 bitCount(i16vec3);"
4114 "i16vec4 bitCount(i16vec4);"
4116 " int16_t bitCount( uint16_t);"
4117 "i16vec2 bitCount(u16vec2);"
4118 "i16vec3 bitCount(u16vec3);"
4119 "i16vec4 bitCount(u16vec4);"
4121 " int16_t findLSB( int16_t);"
4122 "i16vec2 findLSB(i16vec2);"
4123 "i16vec3 findLSB(i16vec3);"
4124 "i16vec4 findLSB(i16vec4);"
4126 " int16_t findLSB( uint16_t);"
4127 "i16vec2 findLSB(u16vec2);"
4128 "i16vec3 findLSB(u16vec3);"
4129 "i16vec4 findLSB(u16vec4);"
4131 " int16_t findMSB( int16_t);"
4132 "i16vec2 findMSB(i16vec2);"
4133 "i16vec3 findMSB(i16vec3);"
4134 "i16vec4 findMSB(i16vec4);"
4136 " int16_t findMSB( uint16_t);"
4137 "i16vec2 findMSB(u16vec2);"
4138 "i16vec3 findMSB(u16vec3);"
4139 "i16vec4 findMSB(u16vec4);"
4141 "int16_t pack16(i8vec2);"
4142 "uint16_t pack16(u8vec2);"
4143 "int32_t pack32(i8vec4);"
4144 "uint32_t pack32(u8vec4);"
4145 "int32_t pack32(i16vec2);"
4146 "uint32_t pack32(u16vec2);"
4147 "int64_t pack64(i16vec4);"
4148 "uint64_t pack64(u16vec4);"
4149 "int64_t pack64(i32vec2);"
4150 "uint64_t pack64(u32vec2);"
4152 "i8vec2 unpack8(int16_t);"
4153 "u8vec2 unpack8(uint16_t);"
4154 "i8vec4 unpack8(int32_t);"
4155 "u8vec4 unpack8(uint32_t);"
4156 "i16vec2 unpack16(int32_t);"
4157 "u16vec2 unpack16(uint32_t);"
4158 "i16vec4 unpack16(int64_t);"
4159 "u16vec4 unpack16(uint64_t);"
4160 "i32vec2 unpack32(int64_t);"
4161 "u32vec2 unpack32(uint64_t);"
4165 if (profile != EEsProfile && version >= 450) {
4166 stageBuiltins[EShLangFragment].append(derivativesAndControl64bits);
4167 stageBuiltins[EShLangFragment].append(
4168 "float64_t interpolateAtCentroid(float64_t);"
4169 "f64vec2 interpolateAtCentroid(f64vec2);"
4170 "f64vec3 interpolateAtCentroid(f64vec3);"
4171 "f64vec4 interpolateAtCentroid(f64vec4);"
4173 "float64_t interpolateAtSample(float64_t, int);"
4174 "f64vec2 interpolateAtSample(f64vec2, int);"
4175 "f64vec3 interpolateAtSample(f64vec3, int);"
4176 "f64vec4 interpolateAtSample(f64vec4, int);"
4178 "float64_t interpolateAtOffset(float64_t, f64vec2);"
4179 "f64vec2 interpolateAtOffset(f64vec2, f64vec2);"
4180 "f64vec3 interpolateAtOffset(f64vec3, f64vec2);"
4181 "f64vec4 interpolateAtOffset(f64vec4, f64vec2);"
4186 #endif // !GLSLANG_ANGLE
4188 //============================================================================
4190 // Prototypes for built-in functions seen by vertex shaders only.
4191 // (Except legacy lod functions, where it depends which release they are
4194 //============================================================================
4197 // Geometric Functions.
4199 if (spvVersion.vulkan == 0 && IncludeLegacy(version, profile, spvVersion))
4200 stageBuiltins[EShLangVertex].append("vec4 ftransform();");
4202 #ifndef GLSLANG_ANGLE
4204 // Original-style texture Functions with lod.
4208 s = &stageBuiltins[EShLangVertex];
4210 s = &commonBuiltins;
4211 if ((profile == EEsProfile && version == 100) ||
4212 profile == ECompatibilityProfile ||
4213 (profile == ECoreProfile && version < 420) ||
4214 profile == ENoProfile) {
4215 if (spvVersion.spv == 0) {
4217 "vec4 texture2DLod(sampler2D, vec2, float);" // GL_ARB_shader_texture_lod
4218 "vec4 texture2DProjLod(sampler2D, vec3, float);" // GL_ARB_shader_texture_lod
4219 "vec4 texture2DProjLod(sampler2D, vec4, float);" // GL_ARB_shader_texture_lod
4220 "vec4 texture3DLod(sampler3D, vec3, float);" // GL_ARB_shader_texture_lod // OES_texture_3D, but caught by keyword check
4221 "vec4 texture3DProjLod(sampler3D, vec4, float);" // GL_ARB_shader_texture_lod // OES_texture_3D, but caught by keyword check
4222 "vec4 textureCubeLod(samplerCube, vec3, float);" // GL_ARB_shader_texture_lod
4227 if ( profile == ECompatibilityProfile ||
4228 (profile == ECoreProfile && version < 420) ||
4229 profile == ENoProfile) {
4230 if (spvVersion.spv == 0) {
4232 "vec4 texture1DLod(sampler1D, float, float);" // GL_ARB_shader_texture_lod
4233 "vec4 texture1DProjLod(sampler1D, vec2, float);" // GL_ARB_shader_texture_lod
4234 "vec4 texture1DProjLod(sampler1D, vec4, float);" // GL_ARB_shader_texture_lod
4235 "vec4 shadow1DLod(sampler1DShadow, vec3, float);" // GL_ARB_shader_texture_lod
4236 "vec4 shadow2DLod(sampler2DShadow, vec3, float);" // GL_ARB_shader_texture_lod
4237 "vec4 shadow1DProjLod(sampler1DShadow, vec4, float);" // GL_ARB_shader_texture_lod
4238 "vec4 shadow2DProjLod(sampler2DShadow, vec4, float);" // GL_ARB_shader_texture_lod
4240 "vec4 texture1DGradARB(sampler1D, float, float, float);" // GL_ARB_shader_texture_lod
4241 "vec4 texture1DProjGradARB(sampler1D, vec2, float, float);" // GL_ARB_shader_texture_lod
4242 "vec4 texture1DProjGradARB(sampler1D, vec4, float, float);" // GL_ARB_shader_texture_lod
4243 "vec4 texture2DGradARB(sampler2D, vec2, vec2, vec2);" // GL_ARB_shader_texture_lod
4244 "vec4 texture2DProjGradARB(sampler2D, vec3, vec2, vec2);" // GL_ARB_shader_texture_lod
4245 "vec4 texture2DProjGradARB(sampler2D, vec4, vec2, vec2);" // GL_ARB_shader_texture_lod
4246 "vec4 texture3DGradARB(sampler3D, vec3, vec3, vec3);" // GL_ARB_shader_texture_lod
4247 "vec4 texture3DProjGradARB(sampler3D, vec4, vec3, vec3);" // GL_ARB_shader_texture_lod
4248 "vec4 textureCubeGradARB(samplerCube, vec3, vec3, vec3);" // GL_ARB_shader_texture_lod
4249 "vec4 shadow1DGradARB(sampler1DShadow, vec3, float, float);" // GL_ARB_shader_texture_lod
4250 "vec4 shadow1DProjGradARB( sampler1DShadow, vec4, float, float);" // GL_ARB_shader_texture_lod
4251 "vec4 shadow2DGradARB(sampler2DShadow, vec3, vec2, vec2);" // GL_ARB_shader_texture_lod
4252 "vec4 shadow2DProjGradARB( sampler2DShadow, vec4, vec2, vec2);" // GL_ARB_shader_texture_lod
4253 "vec4 texture2DRectGradARB(sampler2DRect, vec2, vec2, vec2);" // GL_ARB_shader_texture_lod
4254 "vec4 texture2DRectProjGradARB( sampler2DRect, vec3, vec2, vec2);" // GL_ARB_shader_texture_lod
4255 "vec4 texture2DRectProjGradARB( sampler2DRect, vec4, vec2, vec2);" // GL_ARB_shader_texture_lod
4256 "vec4 shadow2DRectGradARB( sampler2DRectShadow, vec3, vec2, vec2);" // GL_ARB_shader_texture_lod
4257 "vec4 shadow2DRectProjGradARB(sampler2DRectShadow, vec4, vec2, vec2);" // GL_ARB_shader_texture_lod
4262 #endif // !GLSLANG_ANGLE
4264 if ((profile != EEsProfile && version >= 150) ||
4265 (profile == EEsProfile && version >= 310)) {
4266 //============================================================================
4268 // Prototypes for built-in functions seen by geometry shaders only.
4270 //============================================================================
4272 if (profile != EEsProfile && version >= 400) {
4273 stageBuiltins[EShLangGeometry].append(
4274 "void EmitStreamVertex(int);"
4275 "void EndStreamPrimitive(int);"
4278 stageBuiltins[EShLangGeometry].append(
4279 "void EmitVertex();"
4280 "void EndPrimitive();"
4283 #endif // !GLSLANG_WEB
4285 //============================================================================
4287 // Prototypes for all control functions.
4289 //============================================================================
4290 bool esBarrier = (profile == EEsProfile && version >= 310);
4291 if ((profile != EEsProfile && version >= 150) || esBarrier)
4292 stageBuiltins[EShLangTessControl].append(
4295 if ((profile != EEsProfile && version >= 420) || esBarrier)
4296 stageBuiltins[EShLangCompute].append(
4299 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
4300 stageBuiltins[EShLangMeshNV].append(
4303 stageBuiltins[EShLangTaskNV].append(
4307 if ((profile != EEsProfile && version >= 130) || esBarrier)
4308 commonBuiltins.append(
4309 "void memoryBarrier();"
4311 if ((profile != EEsProfile && version >= 420) || esBarrier) {
4312 commonBuiltins.append(
4313 "void memoryBarrierBuffer();"
4315 stageBuiltins[EShLangCompute].append(
4316 "void memoryBarrierShared();"
4317 "void groupMemoryBarrier();"
4321 if ((profile != EEsProfile && version >= 420) || esBarrier) {
4322 if (spvVersion.vulkan == 0 || spvVersion.vulkanRelaxed) {
4323 commonBuiltins.append("void memoryBarrierAtomicCounter();");
4325 commonBuiltins.append("void memoryBarrierImage();");
4327 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
4328 stageBuiltins[EShLangMeshNV].append(
4329 "void memoryBarrierShared();"
4330 "void groupMemoryBarrier();"
4332 stageBuiltins[EShLangTaskNV].append(
4333 "void memoryBarrierShared();"
4334 "void groupMemoryBarrier();"
4338 commonBuiltins.append("void controlBarrier(int, int, int, int);\n"
4339 "void memoryBarrier(int, int, int);\n");
4341 commonBuiltins.append("void debugPrintfEXT();\n");
4343 #ifndef GLSLANG_ANGLE
4344 if (profile != EEsProfile && version >= 450) {
4345 // coopMatStoreNV perhaps ought to have "out" on the buf parameter, but
4346 // adding it introduces undesirable tempArgs on the stack. What we want
4347 // is more like "buf" thought of as a pointer value being an in parameter.
4348 stageBuiltins[EShLangCompute].append(
4349 "void coopMatLoadNV(out fcoopmatNV m, volatile coherent float16_t[] buf, uint element, uint stride, bool colMajor);\n"
4350 "void coopMatLoadNV(out fcoopmatNV m, volatile coherent float[] buf, uint element, uint stride, bool colMajor);\n"
4351 "void coopMatLoadNV(out fcoopmatNV m, volatile coherent uint8_t[] buf, uint element, uint stride, bool colMajor);\n"
4352 "void coopMatLoadNV(out fcoopmatNV m, volatile coherent uint16_t[] buf, uint element, uint stride, bool colMajor);\n"
4353 "void coopMatLoadNV(out fcoopmatNV m, volatile coherent uint[] buf, uint element, uint stride, bool colMajor);\n"
4354 "void coopMatLoadNV(out fcoopmatNV m, volatile coherent uint64_t[] buf, uint element, uint stride, bool colMajor);\n"
4355 "void coopMatLoadNV(out fcoopmatNV m, volatile coherent uvec2[] buf, uint element, uint stride, bool colMajor);\n"
4356 "void coopMatLoadNV(out fcoopmatNV m, volatile coherent uvec4[] buf, uint element, uint stride, bool colMajor);\n"
4358 "void coopMatStoreNV(fcoopmatNV m, volatile coherent float16_t[] buf, uint element, uint stride, bool colMajor);\n"
4359 "void coopMatStoreNV(fcoopmatNV m, volatile coherent float[] buf, uint element, uint stride, bool colMajor);\n"
4360 "void coopMatStoreNV(fcoopmatNV m, volatile coherent float64_t[] buf, uint element, uint stride, bool colMajor);\n"
4361 "void coopMatStoreNV(fcoopmatNV m, volatile coherent uint8_t[] buf, uint element, uint stride, bool colMajor);\n"
4362 "void coopMatStoreNV(fcoopmatNV m, volatile coherent uint16_t[] buf, uint element, uint stride, bool colMajor);\n"
4363 "void coopMatStoreNV(fcoopmatNV m, volatile coherent uint[] buf, uint element, uint stride, bool colMajor);\n"
4364 "void coopMatStoreNV(fcoopmatNV m, volatile coherent uint64_t[] buf, uint element, uint stride, bool colMajor);\n"
4365 "void coopMatStoreNV(fcoopmatNV m, volatile coherent uvec2[] buf, uint element, uint stride, bool colMajor);\n"
4366 "void coopMatStoreNV(fcoopmatNV m, volatile coherent uvec4[] buf, uint element, uint stride, bool colMajor);\n"
4368 "fcoopmatNV coopMatMulAddNV(fcoopmatNV A, fcoopmatNV B, fcoopmatNV C);\n"
4369 "void coopMatLoadNV(out icoopmatNV m, volatile coherent int8_t[] buf, uint element, uint stride, bool colMajor);\n"
4370 "void coopMatLoadNV(out icoopmatNV m, volatile coherent int16_t[] buf, uint element, uint stride, bool colMajor);\n"
4371 "void coopMatLoadNV(out icoopmatNV m, volatile coherent int[] buf, uint element, uint stride, bool colMajor);\n"
4372 "void coopMatLoadNV(out icoopmatNV m, volatile coherent int64_t[] buf, uint element, uint stride, bool colMajor);\n"
4373 "void coopMatLoadNV(out icoopmatNV m, volatile coherent ivec2[] buf, uint element, uint stride, bool colMajor);\n"
4374 "void coopMatLoadNV(out icoopmatNV m, volatile coherent ivec4[] buf, uint element, uint stride, bool colMajor);\n"
4375 "void coopMatLoadNV(out icoopmatNV m, volatile coherent uint8_t[] buf, uint element, uint stride, bool colMajor);\n"
4376 "void coopMatLoadNV(out icoopmatNV m, volatile coherent uint16_t[] buf, uint element, uint stride, bool colMajor);\n"
4377 "void coopMatLoadNV(out icoopmatNV m, volatile coherent uint[] buf, uint element, uint stride, bool colMajor);\n"
4378 "void coopMatLoadNV(out icoopmatNV m, volatile coherent uint64_t[] buf, uint element, uint stride, bool colMajor);\n"
4379 "void coopMatLoadNV(out icoopmatNV m, volatile coherent uvec2[] buf, uint element, uint stride, bool colMajor);\n"
4380 "void coopMatLoadNV(out icoopmatNV m, volatile coherent uvec4[] buf, uint element, uint stride, bool colMajor);\n"
4382 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent int8_t[] buf, uint element, uint stride, bool colMajor);\n"
4383 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent int16_t[] buf, uint element, uint stride, bool colMajor);\n"
4384 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent int[] buf, uint element, uint stride, bool colMajor);\n"
4385 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent int64_t[] buf, uint element, uint stride, bool colMajor);\n"
4386 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent ivec2[] buf, uint element, uint stride, bool colMajor);\n"
4387 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent ivec4[] buf, uint element, uint stride, bool colMajor);\n"
4388 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent uint8_t[] buf, uint element, uint stride, bool colMajor);\n"
4389 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent uint16_t[] buf, uint element, uint stride, bool colMajor);\n"
4390 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent uint[] buf, uint element, uint stride, bool colMajor);\n"
4391 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent uint64_t[] buf, uint element, uint stride, bool colMajor);\n"
4392 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent uvec2[] buf, uint element, uint stride, bool colMajor);\n"
4393 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent uvec4[] buf, uint element, uint stride, bool colMajor);\n"
4395 "void coopMatStoreNV(icoopmatNV m, volatile coherent int8_t[] buf, uint element, uint stride, bool colMajor);\n"
4396 "void coopMatStoreNV(icoopmatNV m, volatile coherent int16_t[] buf, uint element, uint stride, bool colMajor);\n"
4397 "void coopMatStoreNV(icoopmatNV m, volatile coherent int[] buf, uint element, uint stride, bool colMajor);\n"
4398 "void coopMatStoreNV(icoopmatNV m, volatile coherent int64_t[] buf, uint element, uint stride, bool colMajor);\n"
4399 "void coopMatStoreNV(icoopmatNV m, volatile coherent ivec2[] buf, uint element, uint stride, bool colMajor);\n"
4400 "void coopMatStoreNV(icoopmatNV m, volatile coherent ivec4[] buf, uint element, uint stride, bool colMajor);\n"
4401 "void coopMatStoreNV(icoopmatNV m, volatile coherent uint8_t[] buf, uint element, uint stride, bool colMajor);\n"
4402 "void coopMatStoreNV(icoopmatNV m, volatile coherent uint16_t[] buf, uint element, uint stride, bool colMajor);\n"
4403 "void coopMatStoreNV(icoopmatNV m, volatile coherent uint[] buf, uint element, uint stride, bool colMajor);\n"
4404 "void coopMatStoreNV(icoopmatNV m, volatile coherent uint64_t[] buf, uint element, uint stride, bool colMajor);\n"
4405 "void coopMatStoreNV(icoopmatNV m, volatile coherent uvec2[] buf, uint element, uint stride, bool colMajor);\n"
4406 "void coopMatStoreNV(icoopmatNV m, volatile coherent uvec4[] buf, uint element, uint stride, bool colMajor);\n"
4408 "void coopMatStoreNV(ucoopmatNV m, volatile coherent int8_t[] buf, uint element, uint stride, bool colMajor);\n"
4409 "void coopMatStoreNV(ucoopmatNV m, volatile coherent int16_t[] buf, uint element, uint stride, bool colMajor);\n"
4410 "void coopMatStoreNV(ucoopmatNV m, volatile coherent int[] buf, uint element, uint stride, bool colMajor);\n"
4411 "void coopMatStoreNV(ucoopmatNV m, volatile coherent int64_t[] buf, uint element, uint stride, bool colMajor);\n"
4412 "void coopMatStoreNV(ucoopmatNV m, volatile coherent ivec2[] buf, uint element, uint stride, bool colMajor);\n"
4413 "void coopMatStoreNV(ucoopmatNV m, volatile coherent ivec4[] buf, uint element, uint stride, bool colMajor);\n"
4414 "void coopMatStoreNV(ucoopmatNV m, volatile coherent uint8_t[] buf, uint element, uint stride, bool colMajor);\n"
4415 "void coopMatStoreNV(ucoopmatNV m, volatile coherent uint16_t[] buf, uint element, uint stride, bool colMajor);\n"
4416 "void coopMatStoreNV(ucoopmatNV m, volatile coherent uint[] buf, uint element, uint stride, bool colMajor);\n"
4417 "void coopMatStoreNV(ucoopmatNV m, volatile coherent uint64_t[] buf, uint element, uint stride, bool colMajor);\n"
4418 "void coopMatStoreNV(ucoopmatNV m, volatile coherent uvec2[] buf, uint element, uint stride, bool colMajor);\n"
4419 "void coopMatStoreNV(ucoopmatNV m, volatile coherent uvec4[] buf, uint element, uint stride, bool colMajor);\n"
4421 "icoopmatNV coopMatMulAddNV(icoopmatNV A, icoopmatNV B, icoopmatNV C);\n"
4422 "ucoopmatNV coopMatMulAddNV(ucoopmatNV A, ucoopmatNV B, ucoopmatNV C);\n"
4426 //============================================================================
4428 // Prototypes for built-in functions seen by fragment shaders only.
4430 //============================================================================
4433 // Original-style texture Functions with bias.
4435 if (spvVersion.spv == 0 && (profile != EEsProfile || version == 100)) {
4436 stageBuiltins[EShLangFragment].append(
4437 "vec4 texture2D(sampler2D, vec2, float);"
4438 "vec4 texture2DProj(sampler2D, vec3, float);"
4439 "vec4 texture2DProj(sampler2D, vec4, float);"
4440 "vec4 texture3D(sampler3D, vec3, float);" // OES_texture_3D
4441 "vec4 texture3DProj(sampler3D, vec4, float);" // OES_texture_3D
4442 "vec4 textureCube(samplerCube, vec3, float);"
4446 if (spvVersion.spv == 0 && (profile != EEsProfile && version > 100)) {
4447 stageBuiltins[EShLangFragment].append(
4448 "vec4 texture1D(sampler1D, float, float);"
4449 "vec4 texture1DProj(sampler1D, vec2, float);"
4450 "vec4 texture1DProj(sampler1D, vec4, float);"
4451 "vec4 shadow1D(sampler1DShadow, vec3, float);"
4452 "vec4 shadow2D(sampler2DShadow, vec3, float);"
4453 "vec4 shadow1DProj(sampler1DShadow, vec4, float);"
4454 "vec4 shadow2DProj(sampler2DShadow, vec4, float);"
4458 if (spvVersion.spv == 0 && profile == EEsProfile) {
4459 stageBuiltins[EShLangFragment].append(
4460 "vec4 texture2DLodEXT(sampler2D, vec2, float);" // GL_EXT_shader_texture_lod
4461 "vec4 texture2DProjLodEXT(sampler2D, vec3, float);" // GL_EXT_shader_texture_lod
4462 "vec4 texture2DProjLodEXT(sampler2D, vec4, float);" // GL_EXT_shader_texture_lod
4463 "vec4 textureCubeLodEXT(samplerCube, vec3, float);" // GL_EXT_shader_texture_lod
4467 #endif // !GLSLANG_ANGLE
4469 // GL_ARB_derivative_control
4470 if (profile != EEsProfile && version >= 400) {
4471 stageBuiltins[EShLangFragment].append(derivativeControls);
4472 stageBuiltins[EShLangFragment].append("\n");
4475 // GL_OES_shader_multisample_interpolation
4476 if ((profile == EEsProfile && version >= 310) ||
4477 (profile != EEsProfile && version >= 400)) {
4478 stageBuiltins[EShLangFragment].append(
4479 "float interpolateAtCentroid(float);"
4480 "vec2 interpolateAtCentroid(vec2);"
4481 "vec3 interpolateAtCentroid(vec3);"
4482 "vec4 interpolateAtCentroid(vec4);"
4484 "float interpolateAtSample(float, int);"
4485 "vec2 interpolateAtSample(vec2, int);"
4486 "vec3 interpolateAtSample(vec3, int);"
4487 "vec4 interpolateAtSample(vec4, int);"
4489 "float interpolateAtOffset(float, vec2);"
4490 "vec2 interpolateAtOffset(vec2, vec2);"
4491 "vec3 interpolateAtOffset(vec3, vec2);"
4492 "vec4 interpolateAtOffset(vec4, vec2);"
4497 stageBuiltins[EShLangFragment].append(
4498 "void beginInvocationInterlockARB(void);"
4499 "void endInvocationInterlockARB(void);");
4501 stageBuiltins[EShLangFragment].append(
4502 "bool helperInvocationEXT();"
4505 #ifndef GLSLANG_ANGLE
4506 // GL_AMD_shader_explicit_vertex_parameter
4507 if (profile != EEsProfile && version >= 450) {
4508 stageBuiltins[EShLangFragment].append(
4509 "float interpolateAtVertexAMD(float, uint);"
4510 "vec2 interpolateAtVertexAMD(vec2, uint);"
4511 "vec3 interpolateAtVertexAMD(vec3, uint);"
4512 "vec4 interpolateAtVertexAMD(vec4, uint);"
4514 "int interpolateAtVertexAMD(int, uint);"
4515 "ivec2 interpolateAtVertexAMD(ivec2, uint);"
4516 "ivec3 interpolateAtVertexAMD(ivec3, uint);"
4517 "ivec4 interpolateAtVertexAMD(ivec4, uint);"
4519 "uint interpolateAtVertexAMD(uint, uint);"
4520 "uvec2 interpolateAtVertexAMD(uvec2, uint);"
4521 "uvec3 interpolateAtVertexAMD(uvec3, uint);"
4522 "uvec4 interpolateAtVertexAMD(uvec4, uint);"
4524 "float16_t interpolateAtVertexAMD(float16_t, uint);"
4525 "f16vec2 interpolateAtVertexAMD(f16vec2, uint);"
4526 "f16vec3 interpolateAtVertexAMD(f16vec3, uint);"
4527 "f16vec4 interpolateAtVertexAMD(f16vec4, uint);"
4532 // GL_AMD_gpu_shader_half_float
4533 if (profile != EEsProfile && version >= 450) {
4534 stageBuiltins[EShLangFragment].append(derivativesAndControl16bits);
4535 stageBuiltins[EShLangFragment].append("\n");
4537 stageBuiltins[EShLangFragment].append(
4538 "float16_t interpolateAtCentroid(float16_t);"
4539 "f16vec2 interpolateAtCentroid(f16vec2);"
4540 "f16vec3 interpolateAtCentroid(f16vec3);"
4541 "f16vec4 interpolateAtCentroid(f16vec4);"
4543 "float16_t interpolateAtSample(float16_t, int);"
4544 "f16vec2 interpolateAtSample(f16vec2, int);"
4545 "f16vec3 interpolateAtSample(f16vec3, int);"
4546 "f16vec4 interpolateAtSample(f16vec4, int);"
4548 "float16_t interpolateAtOffset(float16_t, f16vec2);"
4549 "f16vec2 interpolateAtOffset(f16vec2, f16vec2);"
4550 "f16vec3 interpolateAtOffset(f16vec3, f16vec2);"
4551 "f16vec4 interpolateAtOffset(f16vec4, f16vec2);"
4556 // GL_ARB_shader_clock
4557 if (profile != EEsProfile && version >= 450) {
4558 commonBuiltins.append(
4559 "uvec2 clock2x32ARB();"
4560 "uint64_t clockARB();"
4564 // GL_AMD_shader_fragment_mask
4565 if (profile != EEsProfile && version >= 450 && spvVersion.vulkan > 0) {
4566 stageBuiltins[EShLangFragment].append(
4567 "uint fragmentMaskFetchAMD(subpassInputMS);"
4568 "uint fragmentMaskFetchAMD(isubpassInputMS);"
4569 "uint fragmentMaskFetchAMD(usubpassInputMS);"
4571 "vec4 fragmentFetchAMD(subpassInputMS, uint);"
4572 "ivec4 fragmentFetchAMD(isubpassInputMS, uint);"
4573 "uvec4 fragmentFetchAMD(usubpassInputMS, uint);"
4578 // Builtins for GL_NV_ray_tracing/GL_NV_ray_tracing_motion_blur/GL_EXT_ray_tracing/GL_EXT_ray_query
4579 if (profile != EEsProfile && version >= 460) {
4580 commonBuiltins.append("void rayQueryInitializeEXT(rayQueryEXT, accelerationStructureEXT, uint, uint, vec3, float, vec3, float);"
4581 "void rayQueryTerminateEXT(rayQueryEXT);"
4582 "void rayQueryGenerateIntersectionEXT(rayQueryEXT, float);"
4583 "void rayQueryConfirmIntersectionEXT(rayQueryEXT);"
4584 "bool rayQueryProceedEXT(rayQueryEXT);"
4585 "uint rayQueryGetIntersectionTypeEXT(rayQueryEXT, bool);"
4586 "float rayQueryGetRayTMinEXT(rayQueryEXT);"
4587 "uint rayQueryGetRayFlagsEXT(rayQueryEXT);"
4588 "vec3 rayQueryGetWorldRayOriginEXT(rayQueryEXT);"
4589 "vec3 rayQueryGetWorldRayDirectionEXT(rayQueryEXT);"
4590 "float rayQueryGetIntersectionTEXT(rayQueryEXT, bool);"
4591 "int rayQueryGetIntersectionInstanceCustomIndexEXT(rayQueryEXT, bool);"
4592 "int rayQueryGetIntersectionInstanceIdEXT(rayQueryEXT, bool);"
4593 "uint rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT(rayQueryEXT, bool);"
4594 "int rayQueryGetIntersectionGeometryIndexEXT(rayQueryEXT, bool);"
4595 "int rayQueryGetIntersectionPrimitiveIndexEXT(rayQueryEXT, bool);"
4596 "vec2 rayQueryGetIntersectionBarycentricsEXT(rayQueryEXT, bool);"
4597 "bool rayQueryGetIntersectionFrontFaceEXT(rayQueryEXT, bool);"
4598 "bool rayQueryGetIntersectionCandidateAABBOpaqueEXT(rayQueryEXT);"
4599 "vec3 rayQueryGetIntersectionObjectRayDirectionEXT(rayQueryEXT, bool);"
4600 "vec3 rayQueryGetIntersectionObjectRayOriginEXT(rayQueryEXT, bool);"
4601 "mat4x3 rayQueryGetIntersectionObjectToWorldEXT(rayQueryEXT, bool);"
4602 "mat4x3 rayQueryGetIntersectionWorldToObjectEXT(rayQueryEXT, bool);"
4605 stageBuiltins[EShLangRayGen].append(
4606 "void traceNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
4607 "void traceRayMotionNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,float,int);"
4608 "void traceRayEXT(accelerationStructureEXT,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
4609 "void executeCallableNV(uint, int);"
4610 "void executeCallableEXT(uint, int);"
4612 stageBuiltins[EShLangIntersect].append(
4613 "bool reportIntersectionNV(float, uint);"
4614 "bool reportIntersectionEXT(float, uint);"
4616 stageBuiltins[EShLangAnyHit].append(
4617 "void ignoreIntersectionNV();"
4618 "void terminateRayNV();"
4620 stageBuiltins[EShLangClosestHit].append(
4621 "void traceNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
4622 "void traceRayMotionNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,float,int);"
4623 "void traceRayEXT(accelerationStructureEXT,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
4624 "void executeCallableNV(uint, int);"
4625 "void executeCallableEXT(uint, int);"
4627 stageBuiltins[EShLangMiss].append(
4628 "void traceNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
4629 "void traceRayMotionNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,float,int);"
4630 "void traceRayEXT(accelerationStructureEXT,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
4631 "void executeCallableNV(uint, int);"
4632 "void executeCallableEXT(uint, int);"
4634 stageBuiltins[EShLangCallable].append(
4635 "void executeCallableNV(uint, int);"
4636 "void executeCallableEXT(uint, int);"
4639 #endif // !GLSLANG_ANGLE
4641 //E_SPV_NV_compute_shader_derivatives
4642 if ((profile == EEsProfile && version >= 320) || (profile != EEsProfile && version >= 450)) {
4643 stageBuiltins[EShLangCompute].append(derivativeControls);
4644 stageBuiltins[EShLangCompute].append("\n");
4646 #ifndef GLSLANG_ANGLE
4647 if (profile != EEsProfile && version >= 450) {
4648 stageBuiltins[EShLangCompute].append(derivativesAndControl16bits);
4649 stageBuiltins[EShLangCompute].append(derivativesAndControl64bits);
4650 stageBuiltins[EShLangCompute].append("\n");
4653 // Builtins for GL_NV_mesh_shader
4654 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
4655 stageBuiltins[EShLangMeshNV].append(
4656 "void writePackedPrimitiveIndices4x8NV(uint, uint);"
4659 #endif // !GLSLANG_ANGLE
4660 #endif // !GLSLANG_WEB
4662 //============================================================================
4664 // Standard Uniforms
4666 //============================================================================
4669 // Depth range in window coordinates, p. 33
4671 if (spvVersion.spv == 0) {
4672 commonBuiltins.append(
4673 "struct gl_DepthRangeParameters {"
4675 if (profile == EEsProfile) {
4676 commonBuiltins.append(
4677 "highp float near;" // n
4678 "highp float far;" // f
4679 "highp float diff;" // f - n
4683 commonBuiltins.append(
4686 "float diff;" // f - n
4691 commonBuiltins.append(
4693 "uniform gl_DepthRangeParameters gl_DepthRange;"
4697 #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
4698 if (spvVersion.spv == 0 && IncludeLegacy(version, profile, spvVersion)) {
4700 // Matrix state. p. 31, 32, 37, 39, 40.
4702 commonBuiltins.append(
4703 "uniform mat4 gl_ModelViewMatrix;"
4704 "uniform mat4 gl_ProjectionMatrix;"
4705 "uniform mat4 gl_ModelViewProjectionMatrix;"
4708 // Derived matrix state that provides inverse and transposed versions
4709 // of the matrices above.
4711 "uniform mat3 gl_NormalMatrix;"
4713 "uniform mat4 gl_ModelViewMatrixInverse;"
4714 "uniform mat4 gl_ProjectionMatrixInverse;"
4715 "uniform mat4 gl_ModelViewProjectionMatrixInverse;"
4717 "uniform mat4 gl_ModelViewMatrixTranspose;"
4718 "uniform mat4 gl_ProjectionMatrixTranspose;"
4719 "uniform mat4 gl_ModelViewProjectionMatrixTranspose;"
4721 "uniform mat4 gl_ModelViewMatrixInverseTranspose;"
4722 "uniform mat4 gl_ProjectionMatrixInverseTranspose;"
4723 "uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;"
4726 // Normal scaling p. 39.
4728 "uniform float gl_NormalScale;"
4731 // Point Size, p. 66, 67.
4733 "struct gl_PointParameters {"
4737 "float fadeThresholdSize;"
4738 "float distanceConstantAttenuation;"
4739 "float distanceLinearAttenuation;"
4740 "float distanceQuadraticAttenuation;"
4743 "uniform gl_PointParameters gl_Point;"
4746 // Material State p. 50, 55.
4748 "struct gl_MaterialParameters {"
4749 "vec4 emission;" // Ecm
4750 "vec4 ambient;" // Acm
4751 "vec4 diffuse;" // Dcm
4752 "vec4 specular;" // Scm
4753 "float shininess;" // Srm
4755 "uniform gl_MaterialParameters gl_FrontMaterial;"
4756 "uniform gl_MaterialParameters gl_BackMaterial;"
4759 // Light State p 50, 53, 55.
4761 "struct gl_LightSourceParameters {"
4762 "vec4 ambient;" // Acli
4763 "vec4 diffuse;" // Dcli
4764 "vec4 specular;" // Scli
4765 "vec4 position;" // Ppli
4766 "vec4 halfVector;" // Derived: Hi
4767 "vec3 spotDirection;" // Sdli
4768 "float spotExponent;" // Srli
4769 "float spotCutoff;" // Crli
4770 // (range: [0.0,90.0], 180.0)
4771 "float spotCosCutoff;" // Derived: cos(Crli)
4772 // (range: [1.0,0.0],-1.0)
4773 "float constantAttenuation;" // K0
4774 "float linearAttenuation;" // K1
4775 "float quadraticAttenuation;"// K2
4778 "struct gl_LightModelParameters {"
4779 "vec4 ambient;" // Acs
4782 "uniform gl_LightModelParameters gl_LightModel;"
4785 // Derived state from products of light and material.
4787 "struct gl_LightModelProducts {"
4788 "vec4 sceneColor;" // Derived. Ecm + Acm * Acs
4791 "uniform gl_LightModelProducts gl_FrontLightModelProduct;"
4792 "uniform gl_LightModelProducts gl_BackLightModelProduct;"
4794 "struct gl_LightProducts {"
4795 "vec4 ambient;" // Acm * Acli
4796 "vec4 diffuse;" // Dcm * Dcli
4797 "vec4 specular;" // Scm * Scli
4803 "struct gl_FogParameters {"
4808 "float scale;" // 1 / (gl_FogEnd - gl_FogStart)
4811 "uniform gl_FogParameters gl_Fog;"
4815 #endif // !GLSLANG_WEB && !GLSLANG_ANGLE
4817 //============================================================================
4819 // Define the interface to the compute shader.
4821 //============================================================================
4823 if ((profile != EEsProfile && version >= 420) ||
4824 (profile == EEsProfile && version >= 310)) {
4825 stageBuiltins[EShLangCompute].append(
4826 "in highp uvec3 gl_NumWorkGroups;"
4827 "const highp uvec3 gl_WorkGroupSize = uvec3(1,1,1);"
4829 "in highp uvec3 gl_WorkGroupID;"
4830 "in highp uvec3 gl_LocalInvocationID;"
4832 "in highp uvec3 gl_GlobalInvocationID;"
4833 "in highp uint gl_LocalInvocationIndex;"
4838 if ((profile != EEsProfile && version >= 140) ||
4839 (profile == EEsProfile && version >= 310)) {
4840 stageBuiltins[EShLangCompute].append(
4841 "in highp int gl_DeviceIndex;" // GL_EXT_device_group
4846 #ifndef GLSLANG_ANGLE
4847 //============================================================================
4849 // Define the interface to the mesh/task shader.
4851 //============================================================================
4853 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
4854 // per-vertex attributes
4855 stageBuiltins[EShLangMeshNV].append(
4856 "out gl_MeshPerVertexNV {"
4858 "float gl_PointSize;"
4859 "float gl_ClipDistance[];"
4860 "float gl_CullDistance[];"
4861 "perviewNV vec4 gl_PositionPerViewNV[];"
4862 "perviewNV float gl_ClipDistancePerViewNV[][];"
4863 "perviewNV float gl_CullDistancePerViewNV[][];"
4864 "} gl_MeshVerticesNV[];"
4867 // per-primitive attributes
4868 stageBuiltins[EShLangMeshNV].append(
4869 "perprimitiveNV out gl_MeshPerPrimitiveNV {"
4870 "int gl_PrimitiveID;"
4872 "int gl_ViewportIndex;"
4873 "int gl_ViewportMask[];"
4874 "perviewNV int gl_LayerPerViewNV[];"
4875 "perviewNV int gl_ViewportMaskPerViewNV[][];"
4876 "} gl_MeshPrimitivesNV[];"
4879 stageBuiltins[EShLangMeshNV].append(
4880 "out uint gl_PrimitiveCountNV;"
4881 "out uint gl_PrimitiveIndicesNV[];"
4883 "in uint gl_MeshViewCountNV;"
4884 "in uint gl_MeshViewIndicesNV[4];"
4886 "const highp uvec3 gl_WorkGroupSize = uvec3(1,1,1);"
4888 "in highp uvec3 gl_WorkGroupID;"
4889 "in highp uvec3 gl_LocalInvocationID;"
4891 "in highp uvec3 gl_GlobalInvocationID;"
4892 "in highp uint gl_LocalInvocationIndex;"
4896 stageBuiltins[EShLangTaskNV].append(
4897 "out uint gl_TaskCountNV;"
4899 "const highp uvec3 gl_WorkGroupSize = uvec3(1,1,1);"
4901 "in highp uvec3 gl_WorkGroupID;"
4902 "in highp uvec3 gl_LocalInvocationID;"
4904 "in highp uvec3 gl_GlobalInvocationID;"
4905 "in highp uint gl_LocalInvocationIndex;"
4907 "in uint gl_MeshViewCountNV;"
4908 "in uint gl_MeshViewIndicesNV[4];"
4913 if (profile != EEsProfile && version >= 450) {
4914 stageBuiltins[EShLangMeshNV].append(
4915 "in highp int gl_DeviceIndex;" // GL_EXT_device_group
4916 "in int gl_DrawIDARB;" // GL_ARB_shader_draw_parameters
4919 stageBuiltins[EShLangTaskNV].append(
4920 "in highp int gl_DeviceIndex;" // GL_EXT_device_group
4921 "in int gl_DrawIDARB;" // GL_ARB_shader_draw_parameters
4924 if (version >= 460) {
4925 stageBuiltins[EShLangMeshNV].append(
4929 stageBuiltins[EShLangTaskNV].append(
4934 #endif // !GLSLANG_ANGLE
4936 //============================================================================
4938 // Define the interface to the vertex shader.
4940 //============================================================================
4942 if (profile != EEsProfile) {
4943 if (version < 130) {
4944 stageBuiltins[EShLangVertex].append(
4945 "attribute vec4 gl_Color;"
4946 "attribute vec4 gl_SecondaryColor;"
4947 "attribute vec3 gl_Normal;"
4948 "attribute vec4 gl_Vertex;"
4949 "attribute vec4 gl_MultiTexCoord0;"
4950 "attribute vec4 gl_MultiTexCoord1;"
4951 "attribute vec4 gl_MultiTexCoord2;"
4952 "attribute vec4 gl_MultiTexCoord3;"
4953 "attribute vec4 gl_MultiTexCoord4;"
4954 "attribute vec4 gl_MultiTexCoord5;"
4955 "attribute vec4 gl_MultiTexCoord6;"
4956 "attribute vec4 gl_MultiTexCoord7;"
4957 "attribute float gl_FogCoord;"
4959 } else if (IncludeLegacy(version, profile, spvVersion)) {
4960 stageBuiltins[EShLangVertex].append(
4962 "in vec4 gl_SecondaryColor;"
4963 "in vec3 gl_Normal;"
4964 "in vec4 gl_Vertex;"
4965 "in vec4 gl_MultiTexCoord0;"
4966 "in vec4 gl_MultiTexCoord1;"
4967 "in vec4 gl_MultiTexCoord2;"
4968 "in vec4 gl_MultiTexCoord3;"
4969 "in vec4 gl_MultiTexCoord4;"
4970 "in vec4 gl_MultiTexCoord5;"
4971 "in vec4 gl_MultiTexCoord6;"
4972 "in vec4 gl_MultiTexCoord7;"
4973 "in float gl_FogCoord;"
4977 if (version < 150) {
4978 if (version < 130) {
4979 stageBuiltins[EShLangVertex].append(
4980 " vec4 gl_ClipVertex;" // needs qualifier fixed later
4981 "varying vec4 gl_FrontColor;"
4982 "varying vec4 gl_BackColor;"
4983 "varying vec4 gl_FrontSecondaryColor;"
4984 "varying vec4 gl_BackSecondaryColor;"
4985 "varying vec4 gl_TexCoord[];"
4986 "varying float gl_FogFragCoord;"
4988 } else if (IncludeLegacy(version, profile, spvVersion)) {
4989 stageBuiltins[EShLangVertex].append(
4990 " vec4 gl_ClipVertex;" // needs qualifier fixed later
4991 "out vec4 gl_FrontColor;"
4992 "out vec4 gl_BackColor;"
4993 "out vec4 gl_FrontSecondaryColor;"
4994 "out vec4 gl_BackSecondaryColor;"
4995 "out vec4 gl_TexCoord[];"
4996 "out float gl_FogFragCoord;"
4999 stageBuiltins[EShLangVertex].append(
5000 "vec4 gl_Position;" // needs qualifier fixed later
5001 "float gl_PointSize;" // needs qualifier fixed later
5004 if (version == 130 || version == 140)
5005 stageBuiltins[EShLangVertex].append(
5006 "out float gl_ClipDistance[];"
5010 stageBuiltins[EShLangVertex].append(
5011 "out gl_PerVertex {"
5012 "vec4 gl_Position;" // needs qualifier fixed later
5013 "float gl_PointSize;" // needs qualifier fixed later
5014 "float gl_ClipDistance[];"
5016 if (IncludeLegacy(version, profile, spvVersion))
5017 stageBuiltins[EShLangVertex].append(
5018 "vec4 gl_ClipVertex;" // needs qualifier fixed later
5019 "vec4 gl_FrontColor;"
5020 "vec4 gl_BackColor;"
5021 "vec4 gl_FrontSecondaryColor;"
5022 "vec4 gl_BackSecondaryColor;"
5023 "vec4 gl_TexCoord[];"
5024 "float gl_FogFragCoord;"
5027 stageBuiltins[EShLangVertex].append(
5028 "float gl_CullDistance[];"
5030 stageBuiltins[EShLangVertex].append(
5034 if (version >= 130 && spvVersion.vulkan == 0)
5035 stageBuiltins[EShLangVertex].append(
5036 "int gl_VertexID;" // needs qualifier fixed later
5038 if (version >= 140 && spvVersion.vulkan == 0)
5039 stageBuiltins[EShLangVertex].append(
5040 "int gl_InstanceID;" // needs qualifier fixed later
5042 if (spvVersion.vulkan > 0 && version >= 140)
5043 stageBuiltins[EShLangVertex].append(
5044 "in int gl_VertexIndex;"
5045 "in int gl_InstanceIndex;"
5048 if (spvVersion.vulkan > 0 && version >= 140 && spvVersion.vulkanRelaxed)
5049 stageBuiltins[EShLangVertex].append(
5050 "in int gl_VertexID;" // declare with 'in' qualifier
5051 "in int gl_InstanceID;"
5054 if (version >= 440) {
5055 stageBuiltins[EShLangVertex].append(
5056 "in int gl_BaseVertexARB;"
5057 "in int gl_BaseInstanceARB;"
5058 "in int gl_DrawIDARB;"
5061 if (version >= 410) {
5062 stageBuiltins[EShLangVertex].append(
5063 "out int gl_ViewportIndex;"
5067 if (version >= 460) {
5068 stageBuiltins[EShLangVertex].append(
5069 "in int gl_BaseVertex;"
5070 "in int gl_BaseInstance;"
5076 stageBuiltins[EShLangVertex].append(
5077 "out int gl_ViewportMask[];" // GL_NV_viewport_array2
5081 stageBuiltins[EShLangVertex].append(
5082 "out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering
5083 "out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
5084 "out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
5085 "out int gl_ViewportMaskPerViewNV[];" // GL_NVX_multiview_per_view_attributes
5089 if (version == 100) {
5090 stageBuiltins[EShLangVertex].append(
5091 "highp vec4 gl_Position;" // needs qualifier fixed later
5092 "mediump float gl_PointSize;" // needs qualifier fixed later
5095 if (spvVersion.vulkan == 0 || spvVersion.vulkanRelaxed)
5096 stageBuiltins[EShLangVertex].append(
5097 "in highp int gl_VertexID;" // needs qualifier fixed later
5098 "in highp int gl_InstanceID;" // needs qualifier fixed later
5100 if (spvVersion.vulkan > 0)
5102 stageBuiltins[EShLangVertex].append(
5103 "in highp int gl_VertexIndex;"
5104 "in highp int gl_InstanceIndex;"
5109 stageBuiltins[EShLangVertex].append(
5110 "highp vec4 gl_Position;" // needs qualifier fixed later
5111 "highp float gl_PointSize;" // needs qualifier fixed later
5115 stageBuiltins[EShLangVertex].append(
5116 "out gl_PerVertex {"
5117 "highp vec4 gl_Position;" // needs qualifier fixed later
5118 "highp float gl_PointSize;" // needs qualifier fixed later
5124 if ((profile != EEsProfile && version >= 140) ||
5125 (profile == EEsProfile && version >= 310)) {
5126 stageBuiltins[EShLangVertex].append(
5127 "in highp int gl_DeviceIndex;" // GL_EXT_device_group
5128 "in highp int gl_ViewIndex;" // GL_EXT_multiview
5132 if (version >= 300 /* both ES and non-ES */) {
5133 stageBuiltins[EShLangVertex].append(
5134 "in highp uint gl_ViewID_OVR;" // GL_OVR_multiview, GL_OVR_multiview2
5138 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 310)) {
5139 stageBuiltins[EShLangVertex].append(
5140 "out highp int gl_PrimitiveShadingRateEXT;" // GL_EXT_fragment_shading_rate
5144 //============================================================================
5146 // Define the interface to the geometry shader.
5148 //============================================================================
5150 if (profile == ECoreProfile || profile == ECompatibilityProfile) {
5151 stageBuiltins[EShLangGeometry].append(
5154 "float gl_PointSize;"
5155 "float gl_ClipDistance[];"
5157 if (profile == ECompatibilityProfile)
5158 stageBuiltins[EShLangGeometry].append(
5159 "vec4 gl_ClipVertex;"
5160 "vec4 gl_FrontColor;"
5161 "vec4 gl_BackColor;"
5162 "vec4 gl_FrontSecondaryColor;"
5163 "vec4 gl_BackSecondaryColor;"
5164 "vec4 gl_TexCoord[];"
5165 "float gl_FogFragCoord;"
5168 stageBuiltins[EShLangGeometry].append(
5169 "float gl_CullDistance[];"
5170 "vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
5171 "vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
5173 stageBuiltins[EShLangGeometry].append(
5176 "in int gl_PrimitiveIDIn;"
5177 "out gl_PerVertex {"
5179 "float gl_PointSize;"
5180 "float gl_ClipDistance[];"
5182 if (profile == ECompatibilityProfile && version >= 400)
5183 stageBuiltins[EShLangGeometry].append(
5184 "vec4 gl_ClipVertex;"
5185 "vec4 gl_FrontColor;"
5186 "vec4 gl_BackColor;"
5187 "vec4 gl_FrontSecondaryColor;"
5188 "vec4 gl_BackSecondaryColor;"
5189 "vec4 gl_TexCoord[];"
5190 "float gl_FogFragCoord;"
5193 stageBuiltins[EShLangGeometry].append(
5194 "float gl_CullDistance[];"
5196 stageBuiltins[EShLangGeometry].append(
5199 "out int gl_PrimitiveID;"
5200 "out int gl_Layer;");
5203 stageBuiltins[EShLangGeometry].append(
5204 "out int gl_ViewportIndex;"
5207 if (profile == ECompatibilityProfile && version < 400)
5208 stageBuiltins[EShLangGeometry].append(
5209 "out vec4 gl_ClipVertex;"
5213 stageBuiltins[EShLangGeometry].append(
5214 "in int gl_InvocationID;"
5218 stageBuiltins[EShLangGeometry].append(
5219 "out int gl_ViewportMask[];" // GL_NV_viewport_array2
5223 stageBuiltins[EShLangGeometry].append(
5224 "out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering
5225 "out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
5226 "out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
5227 "out int gl_ViewportMaskPerViewNV[];" // GL_NVX_multiview_per_view_attributes
5230 stageBuiltins[EShLangGeometry].append("\n");
5231 } else if (profile == EEsProfile && version >= 310) {
5232 stageBuiltins[EShLangGeometry].append(
5234 "highp vec4 gl_Position;"
5235 "highp float gl_PointSize;"
5238 "in highp int gl_PrimitiveIDIn;"
5239 "in highp int gl_InvocationID;"
5241 "out gl_PerVertex {"
5242 "highp vec4 gl_Position;"
5243 "highp float gl_PointSize;"
5246 "out highp int gl_PrimitiveID;"
5247 "out highp int gl_Layer;"
5252 if ((profile != EEsProfile && version >= 140) ||
5253 (profile == EEsProfile && version >= 310)) {
5254 stageBuiltins[EShLangGeometry].append(
5255 "in highp int gl_DeviceIndex;" // GL_EXT_device_group
5256 "in highp int gl_ViewIndex;" // GL_EXT_multiview
5260 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 310)) {
5261 stageBuiltins[EShLangGeometry].append(
5262 "out highp int gl_PrimitiveShadingRateEXT;" // GL_EXT_fragment_shading_rate
5266 //============================================================================
5268 // Define the interface to the tessellation control shader.
5270 //============================================================================
5272 if (profile != EEsProfile && version >= 150) {
5273 // Note: "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below,
5274 // as it depends on the resource sizing of gl_MaxPatchVertices.
5276 stageBuiltins[EShLangTessControl].append(
5277 "in int gl_PatchVerticesIn;"
5278 "in int gl_PrimitiveID;"
5279 "in int gl_InvocationID;"
5281 "out gl_PerVertex {"
5283 "float gl_PointSize;"
5284 "float gl_ClipDistance[];"
5286 if (profile == ECompatibilityProfile)
5287 stageBuiltins[EShLangTessControl].append(
5288 "vec4 gl_ClipVertex;"
5289 "vec4 gl_FrontColor;"
5290 "vec4 gl_BackColor;"
5291 "vec4 gl_FrontSecondaryColor;"
5292 "vec4 gl_BackSecondaryColor;"
5293 "vec4 gl_TexCoord[];"
5294 "float gl_FogFragCoord;"
5297 stageBuiltins[EShLangTessControl].append(
5298 "float gl_CullDistance[];"
5301 stageBuiltins[EShLangTessControl].append(
5302 "int gl_ViewportMask[];" // GL_NV_viewport_array2
5305 stageBuiltins[EShLangTessControl].append(
5306 "vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
5307 "int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering
5308 "vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
5309 "int gl_ViewportMaskPerViewNV[];" // GL_NVX_multiview_per_view_attributes
5311 stageBuiltins[EShLangTessControl].append(
5314 "patch out float gl_TessLevelOuter[4];"
5315 "patch out float gl_TessLevelInner[2];"
5319 stageBuiltins[EShLangTessControl].append(
5320 "out int gl_ViewportIndex;"
5325 // Note: "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below,
5326 // as it depends on the resource sizing of gl_MaxPatchVertices.
5328 stageBuiltins[EShLangTessControl].append(
5329 "in highp int gl_PatchVerticesIn;"
5330 "in highp int gl_PrimitiveID;"
5331 "in highp int gl_InvocationID;"
5333 "out gl_PerVertex {"
5334 "highp vec4 gl_Position;"
5335 "highp float gl_PointSize;"
5337 stageBuiltins[EShLangTessControl].append(
5340 "patch out highp float gl_TessLevelOuter[4];"
5341 "patch out highp float gl_TessLevelInner[2];"
5342 "patch out highp vec4 gl_BoundingBoxOES[2];"
5343 "patch out highp vec4 gl_BoundingBoxEXT[2];"
5345 if (profile == EEsProfile && version >= 320) {
5346 stageBuiltins[EShLangTessControl].append(
5347 "patch out highp vec4 gl_BoundingBox[2];"
5353 if ((profile != EEsProfile && version >= 140) ||
5354 (profile == EEsProfile && version >= 310)) {
5355 stageBuiltins[EShLangTessControl].append(
5356 "in highp int gl_DeviceIndex;" // GL_EXT_device_group
5357 "in highp int gl_ViewIndex;" // GL_EXT_multiview
5361 //============================================================================
5363 // Define the interface to the tessellation evaluation shader.
5365 //============================================================================
5367 if (profile != EEsProfile && version >= 150) {
5368 // Note: "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below,
5369 // as it depends on the resource sizing of gl_MaxPatchVertices.
5371 stageBuiltins[EShLangTessEvaluation].append(
5372 "in int gl_PatchVerticesIn;"
5373 "in int gl_PrimitiveID;"
5374 "in vec3 gl_TessCoord;"
5376 "patch in float gl_TessLevelOuter[4];"
5377 "patch in float gl_TessLevelInner[2];"
5379 "out gl_PerVertex {"
5381 "float gl_PointSize;"
5382 "float gl_ClipDistance[];"
5384 if (version >= 400 && profile == ECompatibilityProfile)
5385 stageBuiltins[EShLangTessEvaluation].append(
5386 "vec4 gl_ClipVertex;"
5387 "vec4 gl_FrontColor;"
5388 "vec4 gl_BackColor;"
5389 "vec4 gl_FrontSecondaryColor;"
5390 "vec4 gl_BackSecondaryColor;"
5391 "vec4 gl_TexCoord[];"
5392 "float gl_FogFragCoord;"
5395 stageBuiltins[EShLangTessEvaluation].append(
5396 "float gl_CullDistance[];"
5398 stageBuiltins[EShLangTessEvaluation].append(
5403 stageBuiltins[EShLangTessEvaluation].append(
5404 "out int gl_ViewportIndex;"
5409 stageBuiltins[EShLangTessEvaluation].append(
5410 "out int gl_ViewportMask[];" // GL_NV_viewport_array2
5414 stageBuiltins[EShLangTessEvaluation].append(
5415 "out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
5416 "out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering
5417 "out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
5418 "out int gl_ViewportMaskPerViewNV[];" // GL_NVX_multiview_per_view_attributes
5421 } else if (profile == EEsProfile && version >= 310) {
5422 // Note: "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below,
5423 // as it depends on the resource sizing of gl_MaxPatchVertices.
5425 stageBuiltins[EShLangTessEvaluation].append(
5426 "in highp int gl_PatchVerticesIn;"
5427 "in highp int gl_PrimitiveID;"
5428 "in highp vec3 gl_TessCoord;"
5430 "patch in highp float gl_TessLevelOuter[4];"
5431 "patch in highp float gl_TessLevelInner[2];"
5433 "out gl_PerVertex {"
5434 "highp vec4 gl_Position;"
5435 "highp float gl_PointSize;"
5437 stageBuiltins[EShLangTessEvaluation].append(
5442 if ((profile != EEsProfile && version >= 140) ||
5443 (profile == EEsProfile && version >= 310)) {
5444 stageBuiltins[EShLangTessEvaluation].append(
5445 "in highp int gl_DeviceIndex;" // GL_EXT_device_group
5446 "in highp int gl_ViewIndex;" // GL_EXT_multiview
5450 //============================================================================
5452 // Define the interface to the fragment shader.
5454 //============================================================================
5456 if (profile != EEsProfile) {
5458 stageBuiltins[EShLangFragment].append(
5459 "vec4 gl_FragCoord;" // needs qualifier fixed later
5460 "bool gl_FrontFacing;" // needs qualifier fixed later
5461 "float gl_FragDepth;" // needs qualifier fixed later
5464 stageBuiltins[EShLangFragment].append(
5465 "vec2 gl_PointCoord;" // needs qualifier fixed later
5468 stageBuiltins[EShLangFragment].append(
5469 "out int gl_FragStencilRefARB;"
5471 if (IncludeLegacy(version, profile, spvVersion) || (! ForwardCompatibility && version < 420))
5472 stageBuiltins[EShLangFragment].append(
5473 "vec4 gl_FragColor;" // needs qualifier fixed later
5476 if (version < 130) {
5477 stageBuiltins[EShLangFragment].append(
5478 "varying vec4 gl_Color;"
5479 "varying vec4 gl_SecondaryColor;"
5480 "varying vec4 gl_TexCoord[];"
5481 "varying float gl_FogFragCoord;"
5484 stageBuiltins[EShLangFragment].append(
5485 "in float gl_ClipDistance[];"
5488 if (IncludeLegacy(version, profile, spvVersion)) {
5490 stageBuiltins[EShLangFragment].append(
5491 "in float gl_FogFragCoord;"
5492 "in vec4 gl_TexCoord[];"
5494 "in vec4 gl_SecondaryColor;"
5497 stageBuiltins[EShLangFragment].append(
5498 "in gl_PerFragment {"
5499 "in float gl_FogFragCoord;"
5500 "in vec4 gl_TexCoord[];"
5502 "in vec4 gl_SecondaryColor;"
5509 stageBuiltins[EShLangFragment].append(
5510 "flat in int gl_PrimitiveID;"
5513 if (version >= 130) { // ARB_sample_shading
5514 stageBuiltins[EShLangFragment].append(
5515 "flat in int gl_SampleID;"
5516 " in vec2 gl_SamplePosition;"
5517 " out int gl_SampleMask[];"
5520 if (spvVersion.spv == 0) {
5521 stageBuiltins[EShLangFragment].append(
5522 "uniform int gl_NumSamples;"
5528 stageBuiltins[EShLangFragment].append(
5529 "flat in int gl_SampleMaskIn[];"
5533 stageBuiltins[EShLangFragment].append(
5534 "flat in int gl_Layer;"
5535 "flat in int gl_ViewportIndex;"
5539 stageBuiltins[EShLangFragment].append(
5540 "in float gl_CullDistance[];"
5541 "bool gl_HelperInvocation;" // needs qualifier fixed later
5545 stageBuiltins[EShLangFragment].append( // GL_EXT_fragment_invocation_density
5546 "flat in ivec2 gl_FragSizeEXT;"
5547 "flat in int gl_FragInvocationCountEXT;"
5551 stageBuiltins[EShLangFragment].append(
5552 "in vec2 gl_BaryCoordNoPerspAMD;"
5553 "in vec2 gl_BaryCoordNoPerspCentroidAMD;"
5554 "in vec2 gl_BaryCoordNoPerspSampleAMD;"
5555 "in vec2 gl_BaryCoordSmoothAMD;"
5556 "in vec2 gl_BaryCoordSmoothCentroidAMD;"
5557 "in vec2 gl_BaryCoordSmoothSampleAMD;"
5558 "in vec3 gl_BaryCoordPullModelAMD;"
5562 stageBuiltins[EShLangFragment].append(
5563 "in bool gl_FragFullyCoveredNV;"
5566 stageBuiltins[EShLangFragment].append(
5567 "flat in ivec2 gl_FragmentSizeNV;" // GL_NV_shading_rate_image
5568 "flat in int gl_InvocationsPerPixelNV;"
5569 "in vec3 gl_BaryCoordNV;" // GL_NV_fragment_shader_barycentric
5570 "in vec3 gl_BaryCoordNoPerspNV;"
5574 stageBuiltins[EShLangFragment].append(
5575 "flat in int gl_ShadingRateEXT;" // GL_EXT_fragment_shading_rate
5581 if (version == 100) {
5582 stageBuiltins[EShLangFragment].append(
5583 "mediump vec4 gl_FragCoord;" // needs qualifier fixed later
5584 " bool gl_FrontFacing;" // needs qualifier fixed later
5585 "mediump vec4 gl_FragColor;" // needs qualifier fixed later
5586 "mediump vec2 gl_PointCoord;" // needs qualifier fixed later
5590 if (version >= 300) {
5591 stageBuiltins[EShLangFragment].append(
5592 "highp vec4 gl_FragCoord;" // needs qualifier fixed later
5593 " bool gl_FrontFacing;" // needs qualifier fixed later
5594 "mediump vec2 gl_PointCoord;" // needs qualifier fixed later
5595 "highp float gl_FragDepth;" // needs qualifier fixed later
5599 if (version >= 310) {
5600 stageBuiltins[EShLangFragment].append(
5601 "bool gl_HelperInvocation;" // needs qualifier fixed later
5602 "flat in highp int gl_PrimitiveID;" // needs qualifier fixed later
5603 "flat in highp int gl_Layer;" // needs qualifier fixed later
5606 stageBuiltins[EShLangFragment].append( // GL_OES_sample_variables
5607 "flat in lowp int gl_SampleID;"
5608 " in mediump vec2 gl_SamplePosition;"
5609 "flat in highp int gl_SampleMaskIn[];"
5610 " out highp int gl_SampleMask[];"
5612 if (spvVersion.spv == 0)
5613 stageBuiltins[EShLangFragment].append( // GL_OES_sample_variables
5614 "uniform lowp int gl_NumSamples;"
5617 stageBuiltins[EShLangFragment].append(
5618 "highp float gl_FragDepthEXT;" // GL_EXT_frag_depth
5622 stageBuiltins[EShLangFragment].append( // GL_EXT_fragment_invocation_density
5623 "flat in ivec2 gl_FragSizeEXT;"
5624 "flat in int gl_FragInvocationCountEXT;"
5627 stageBuiltins[EShLangFragment].append( // GL_NV_shading_rate_image
5628 "flat in ivec2 gl_FragmentSizeNV;"
5629 "flat in int gl_InvocationsPerPixelNV;"
5632 stageBuiltins[EShLangFragment].append(
5633 "in vec3 gl_BaryCoordNV;"
5634 "in vec3 gl_BaryCoordNoPerspNV;"
5637 stageBuiltins[EShLangFragment].append(
5638 "flat in highp int gl_ShadingRateEXT;" // GL_EXT_fragment_shading_rate
5643 stageBuiltins[EShLangFragment].append("\n");
5646 add2ndGenerationSamplingImaging(version, profile, spvVersion);
5650 if ((profile != EEsProfile && version >= 140) ||
5651 (profile == EEsProfile && version >= 310)) {
5652 stageBuiltins[EShLangFragment].append(
5653 "flat in highp int gl_DeviceIndex;" // GL_EXT_device_group
5654 "flat in highp int gl_ViewIndex;" // GL_EXT_multiview
5658 if (version >= 300 /* both ES and non-ES */) {
5659 stageBuiltins[EShLangFragment].append(
5660 "flat in highp uint gl_ViewID_OVR;" // GL_OVR_multiview, GL_OVR_multiview2
5664 #ifndef GLSLANG_ANGLE
5665 // GL_ARB_shader_ballot
5666 if (profile != EEsProfile && version >= 450) {
5667 const char* ballotDecls =
5668 "uniform uint gl_SubGroupSizeARB;"
5669 "in uint gl_SubGroupInvocationARB;"
5670 "in uint64_t gl_SubGroupEqMaskARB;"
5671 "in uint64_t gl_SubGroupGeMaskARB;"
5672 "in uint64_t gl_SubGroupGtMaskARB;"
5673 "in uint64_t gl_SubGroupLeMaskARB;"
5674 "in uint64_t gl_SubGroupLtMaskARB;"
5676 const char* rtBallotDecls =
5677 "uniform volatile uint gl_SubGroupSizeARB;"
5678 "in volatile uint gl_SubGroupInvocationARB;"
5679 "in volatile uint64_t gl_SubGroupEqMaskARB;"
5680 "in volatile uint64_t gl_SubGroupGeMaskARB;"
5681 "in volatile uint64_t gl_SubGroupGtMaskARB;"
5682 "in volatile uint64_t gl_SubGroupLeMaskARB;"
5683 "in volatile uint64_t gl_SubGroupLtMaskARB;"
5685 const char* fragmentBallotDecls =
5686 "uniform uint gl_SubGroupSizeARB;"
5687 "flat in uint gl_SubGroupInvocationARB;"
5688 "flat in uint64_t gl_SubGroupEqMaskARB;"
5689 "flat in uint64_t gl_SubGroupGeMaskARB;"
5690 "flat in uint64_t gl_SubGroupGtMaskARB;"
5691 "flat in uint64_t gl_SubGroupLeMaskARB;"
5692 "flat in uint64_t gl_SubGroupLtMaskARB;"
5694 stageBuiltins[EShLangVertex] .append(ballotDecls);
5695 stageBuiltins[EShLangTessControl] .append(ballotDecls);
5696 stageBuiltins[EShLangTessEvaluation].append(ballotDecls);
5697 stageBuiltins[EShLangGeometry] .append(ballotDecls);
5698 stageBuiltins[EShLangCompute] .append(ballotDecls);
5699 stageBuiltins[EShLangFragment] .append(fragmentBallotDecls);
5700 stageBuiltins[EShLangMeshNV] .append(ballotDecls);
5701 stageBuiltins[EShLangTaskNV] .append(ballotDecls);
5702 stageBuiltins[EShLangRayGen] .append(rtBallotDecls);
5703 stageBuiltins[EShLangIntersect] .append(rtBallotDecls);
5704 // No volatile qualifier on these builtins in any-hit
5705 stageBuiltins[EShLangAnyHit] .append(ballotDecls);
5706 stageBuiltins[EShLangClosestHit] .append(rtBallotDecls);
5707 stageBuiltins[EShLangMiss] .append(rtBallotDecls);
5708 stageBuiltins[EShLangCallable] .append(rtBallotDecls);
5711 // GL_KHR_shader_subgroup
5712 if ((profile == EEsProfile && version >= 310) ||
5713 (profile != EEsProfile && version >= 140)) {
5714 const char* subgroupDecls =
5715 "in mediump uint gl_SubgroupSize;"
5716 "in mediump uint gl_SubgroupInvocationID;"
5717 "in highp uvec4 gl_SubgroupEqMask;"
5718 "in highp uvec4 gl_SubgroupGeMask;"
5719 "in highp uvec4 gl_SubgroupGtMask;"
5720 "in highp uvec4 gl_SubgroupLeMask;"
5721 "in highp uvec4 gl_SubgroupLtMask;"
5722 // GL_NV_shader_sm_builtins
5723 "in highp uint gl_WarpsPerSMNV;"
5724 "in highp uint gl_SMCountNV;"
5725 "in highp uint gl_WarpIDNV;"
5726 "in highp uint gl_SMIDNV;"
5728 const char* fragmentSubgroupDecls =
5729 "flat in mediump uint gl_SubgroupSize;"
5730 "flat in mediump uint gl_SubgroupInvocationID;"
5731 "flat in highp uvec4 gl_SubgroupEqMask;"
5732 "flat in highp uvec4 gl_SubgroupGeMask;"
5733 "flat in highp uvec4 gl_SubgroupGtMask;"
5734 "flat in highp uvec4 gl_SubgroupLeMask;"
5735 "flat in highp uvec4 gl_SubgroupLtMask;"
5736 // GL_NV_shader_sm_builtins
5737 "flat in highp uint gl_WarpsPerSMNV;"
5738 "flat in highp uint gl_SMCountNV;"
5739 "flat in highp uint gl_WarpIDNV;"
5740 "flat in highp uint gl_SMIDNV;"
5742 const char* computeSubgroupDecls =
5743 "in highp uint gl_NumSubgroups;"
5744 "in highp uint gl_SubgroupID;"
5746 // These builtins are volatile for RT stages
5747 const char* rtSubgroupDecls =
5748 "in mediump volatile uint gl_SubgroupSize;"
5749 "in mediump volatile uint gl_SubgroupInvocationID;"
5750 "in highp volatile uvec4 gl_SubgroupEqMask;"
5751 "in highp volatile uvec4 gl_SubgroupGeMask;"
5752 "in highp volatile uvec4 gl_SubgroupGtMask;"
5753 "in highp volatile uvec4 gl_SubgroupLeMask;"
5754 "in highp volatile uvec4 gl_SubgroupLtMask;"
5755 // GL_NV_shader_sm_builtins
5756 "in highp uint gl_WarpsPerSMNV;"
5757 "in highp uint gl_SMCountNV;"
5758 "in highp volatile uint gl_WarpIDNV;"
5759 "in highp volatile uint gl_SMIDNV;"
5762 stageBuiltins[EShLangVertex] .append(subgroupDecls);
5763 stageBuiltins[EShLangTessControl] .append(subgroupDecls);
5764 stageBuiltins[EShLangTessEvaluation].append(subgroupDecls);
5765 stageBuiltins[EShLangGeometry] .append(subgroupDecls);
5766 stageBuiltins[EShLangCompute] .append(subgroupDecls);
5767 stageBuiltins[EShLangCompute] .append(computeSubgroupDecls);
5768 stageBuiltins[EShLangFragment] .append(fragmentSubgroupDecls);
5769 stageBuiltins[EShLangMeshNV] .append(subgroupDecls);
5770 stageBuiltins[EShLangMeshNV] .append(computeSubgroupDecls);
5771 stageBuiltins[EShLangTaskNV] .append(subgroupDecls);
5772 stageBuiltins[EShLangTaskNV] .append(computeSubgroupDecls);
5773 stageBuiltins[EShLangRayGen] .append(rtSubgroupDecls);
5774 stageBuiltins[EShLangIntersect] .append(rtSubgroupDecls);
5775 // No volatile qualifier on these builtins in any-hit
5776 stageBuiltins[EShLangAnyHit] .append(subgroupDecls);
5777 stageBuiltins[EShLangClosestHit] .append(rtSubgroupDecls);
5778 stageBuiltins[EShLangMiss] .append(rtSubgroupDecls);
5779 stageBuiltins[EShLangCallable] .append(rtSubgroupDecls);
5782 // GL_NV_ray_tracing/GL_EXT_ray_tracing
5783 if (profile != EEsProfile && version >= 460) {
5785 const char *constRayFlags =
5786 "const uint gl_RayFlagsNoneNV = 0U;"
5787 "const uint gl_RayFlagsNoneEXT = 0U;"
5788 "const uint gl_RayFlagsOpaqueNV = 1U;"
5789 "const uint gl_RayFlagsOpaqueEXT = 1U;"
5790 "const uint gl_RayFlagsNoOpaqueNV = 2U;"
5791 "const uint gl_RayFlagsNoOpaqueEXT = 2U;"
5792 "const uint gl_RayFlagsTerminateOnFirstHitNV = 4U;"
5793 "const uint gl_RayFlagsTerminateOnFirstHitEXT = 4U;"
5794 "const uint gl_RayFlagsSkipClosestHitShaderNV = 8U;"
5795 "const uint gl_RayFlagsSkipClosestHitShaderEXT = 8U;"
5796 "const uint gl_RayFlagsCullBackFacingTrianglesNV = 16U;"
5797 "const uint gl_RayFlagsCullBackFacingTrianglesEXT = 16U;"
5798 "const uint gl_RayFlagsCullFrontFacingTrianglesNV = 32U;"
5799 "const uint gl_RayFlagsCullFrontFacingTrianglesEXT = 32U;"
5800 "const uint gl_RayFlagsCullOpaqueNV = 64U;"
5801 "const uint gl_RayFlagsCullOpaqueEXT = 64U;"
5802 "const uint gl_RayFlagsCullNoOpaqueNV = 128U;"
5803 "const uint gl_RayFlagsCullNoOpaqueEXT = 128U;"
5804 "const uint gl_RayFlagsSkipTrianglesEXT = 256U;"
5805 "const uint gl_RayFlagsSkipAABBEXT = 512U;"
5806 "const uint gl_HitKindFrontFacingTriangleEXT = 254U;"
5807 "const uint gl_HitKindBackFacingTriangleEXT = 255U;"
5810 const char *constRayQueryIntersection =
5811 "const uint gl_RayQueryCandidateIntersectionEXT = 0U;"
5812 "const uint gl_RayQueryCommittedIntersectionEXT = 1U;"
5813 "const uint gl_RayQueryCommittedIntersectionNoneEXT = 0U;"
5814 "const uint gl_RayQueryCommittedIntersectionTriangleEXT = 1U;"
5815 "const uint gl_RayQueryCommittedIntersectionGeneratedEXT = 2U;"
5816 "const uint gl_RayQueryCandidateIntersectionTriangleEXT = 0U;"
5817 "const uint gl_RayQueryCandidateIntersectionAABBEXT = 1U;"
5820 const char *rayGenDecls =
5821 "in uvec3 gl_LaunchIDNV;"
5822 "in uvec3 gl_LaunchIDEXT;"
5823 "in uvec3 gl_LaunchSizeNV;"
5824 "in uvec3 gl_LaunchSizeEXT;"
5826 const char *intersectDecls =
5827 "in uvec3 gl_LaunchIDNV;"
5828 "in uvec3 gl_LaunchIDEXT;"
5829 "in uvec3 gl_LaunchSizeNV;"
5830 "in uvec3 gl_LaunchSizeEXT;"
5831 "in int gl_PrimitiveID;"
5832 "in int gl_InstanceID;"
5833 "in int gl_InstanceCustomIndexNV;"
5834 "in int gl_InstanceCustomIndexEXT;"
5835 "in int gl_GeometryIndexEXT;"
5836 "in vec3 gl_WorldRayOriginNV;"
5837 "in vec3 gl_WorldRayOriginEXT;"
5838 "in vec3 gl_WorldRayDirectionNV;"
5839 "in vec3 gl_WorldRayDirectionEXT;"
5840 "in vec3 gl_ObjectRayOriginNV;"
5841 "in vec3 gl_ObjectRayOriginEXT;"
5842 "in vec3 gl_ObjectRayDirectionNV;"
5843 "in vec3 gl_ObjectRayDirectionEXT;"
5844 "in float gl_RayTminNV;"
5845 "in float gl_RayTminEXT;"
5846 "in float gl_RayTmaxNV;"
5847 "in volatile float gl_RayTmaxEXT;"
5848 "in mat4x3 gl_ObjectToWorldNV;"
5849 "in mat4x3 gl_ObjectToWorldEXT;"
5850 "in mat3x4 gl_ObjectToWorld3x4EXT;"
5851 "in mat4x3 gl_WorldToObjectNV;"
5852 "in mat4x3 gl_WorldToObjectEXT;"
5853 "in mat3x4 gl_WorldToObject3x4EXT;"
5854 "in uint gl_IncomingRayFlagsNV;"
5855 "in uint gl_IncomingRayFlagsEXT;"
5856 "in float gl_CurrentRayTimeNV;"
5858 const char *hitDecls =
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 float gl_RayTmaxEXT;"
5880 "in float gl_HitTNV;"
5881 "in float gl_HitTEXT;"
5882 "in uint gl_HitKindNV;"
5883 "in uint gl_HitKindEXT;"
5884 "in mat4x3 gl_ObjectToWorldNV;"
5885 "in mat4x3 gl_ObjectToWorldEXT;"
5886 "in mat3x4 gl_ObjectToWorld3x4EXT;"
5887 "in mat4x3 gl_WorldToObjectNV;"
5888 "in mat4x3 gl_WorldToObjectEXT;"
5889 "in mat3x4 gl_WorldToObject3x4EXT;"
5890 "in uint gl_IncomingRayFlagsNV;"
5891 "in uint gl_IncomingRayFlagsEXT;"
5892 "in float gl_CurrentRayTimeNV;"
5894 const char *missDecls =
5895 "in uvec3 gl_LaunchIDNV;"
5896 "in uvec3 gl_LaunchIDEXT;"
5897 "in uvec3 gl_LaunchSizeNV;"
5898 "in uvec3 gl_LaunchSizeEXT;"
5899 "in vec3 gl_WorldRayOriginNV;"
5900 "in vec3 gl_WorldRayOriginEXT;"
5901 "in vec3 gl_WorldRayDirectionNV;"
5902 "in vec3 gl_WorldRayDirectionEXT;"
5903 "in vec3 gl_ObjectRayOriginNV;"
5904 "in vec3 gl_ObjectRayDirectionNV;"
5905 "in float gl_RayTminNV;"
5906 "in float gl_RayTminEXT;"
5907 "in float gl_RayTmaxNV;"
5908 "in float gl_RayTmaxEXT;"
5909 "in uint gl_IncomingRayFlagsNV;"
5910 "in uint gl_IncomingRayFlagsEXT;"
5911 "in float gl_CurrentRayTimeNV;"
5914 const char *callableDecls =
5915 "in uvec3 gl_LaunchIDNV;"
5916 "in uvec3 gl_LaunchIDEXT;"
5917 "in uvec3 gl_LaunchSizeNV;"
5918 "in uvec3 gl_LaunchSizeEXT;"
5922 commonBuiltins.append(constRayQueryIntersection);
5923 commonBuiltins.append(constRayFlags);
5925 stageBuiltins[EShLangRayGen].append(rayGenDecls);
5926 stageBuiltins[EShLangIntersect].append(intersectDecls);
5927 stageBuiltins[EShLangAnyHit].append(hitDecls);
5928 stageBuiltins[EShLangClosestHit].append(hitDecls);
5929 stageBuiltins[EShLangMiss].append(missDecls);
5930 stageBuiltins[EShLangCallable].append(callableDecls);
5934 if ((profile != EEsProfile && version >= 140)) {
5935 const char *deviceIndex =
5936 "in highp int gl_DeviceIndex;" // GL_EXT_device_group
5939 stageBuiltins[EShLangRayGen].append(deviceIndex);
5940 stageBuiltins[EShLangIntersect].append(deviceIndex);
5941 stageBuiltins[EShLangAnyHit].append(deviceIndex);
5942 stageBuiltins[EShLangClosestHit].append(deviceIndex);
5943 stageBuiltins[EShLangMiss].append(deviceIndex);
5946 if ((profile != EEsProfile && version >= 420) ||
5947 (profile == EEsProfile && version >= 310)) {
5948 commonBuiltins.append("const int gl_ScopeDevice = 1;\n");
5949 commonBuiltins.append("const int gl_ScopeWorkgroup = 2;\n");
5950 commonBuiltins.append("const int gl_ScopeSubgroup = 3;\n");
5951 commonBuiltins.append("const int gl_ScopeInvocation = 4;\n");
5952 commonBuiltins.append("const int gl_ScopeQueueFamily = 5;\n");
5953 commonBuiltins.append("const int gl_ScopeShaderCallEXT = 6;\n");
5955 commonBuiltins.append("const int gl_SemanticsRelaxed = 0x0;\n");
5956 commonBuiltins.append("const int gl_SemanticsAcquire = 0x2;\n");
5957 commonBuiltins.append("const int gl_SemanticsRelease = 0x4;\n");
5958 commonBuiltins.append("const int gl_SemanticsAcquireRelease = 0x8;\n");
5959 commonBuiltins.append("const int gl_SemanticsMakeAvailable = 0x2000;\n");
5960 commonBuiltins.append("const int gl_SemanticsMakeVisible = 0x4000;\n");
5961 commonBuiltins.append("const int gl_SemanticsVolatile = 0x8000;\n");
5963 commonBuiltins.append("const int gl_StorageSemanticsNone = 0x0;\n");
5964 commonBuiltins.append("const int gl_StorageSemanticsBuffer = 0x40;\n");
5965 commonBuiltins.append("const int gl_StorageSemanticsShared = 0x100;\n");
5966 commonBuiltins.append("const int gl_StorageSemanticsImage = 0x800;\n");
5967 commonBuiltins.append("const int gl_StorageSemanticsOutput = 0x1000;\n");
5970 // Adding these to common built-ins triggers an assert due to a memory corruption in related code when testing
5971 // So instead add to each stage individually, avoiding the GLSLang bug
5972 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 310)) {
5973 for (int stage=EShLangVertex; stage<EShLangCount; stage++)
5975 stageBuiltins[static_cast<EShLanguage>(stage)].append("const highp int gl_ShadingRateFlag2VerticalPixelsEXT = 1;\n");
5976 stageBuiltins[static_cast<EShLanguage>(stage)].append("const highp int gl_ShadingRateFlag4VerticalPixelsEXT = 2;\n");
5977 stageBuiltins[static_cast<EShLanguage>(stage)].append("const highp int gl_ShadingRateFlag2HorizontalPixelsEXT = 4;\n");
5978 stageBuiltins[static_cast<EShLanguage>(stage)].append("const highp int gl_ShadingRateFlag4HorizontalPixelsEXT = 8;\n");
5982 // GL_EXT_shader_image_int64
5983 if ((profile != EEsProfile && version >= 420) ||
5984 (profile == EEsProfile && version >= 310)) {
5986 const TBasicType bTypes[] = { EbtInt64, EbtUint64 };
5987 for (int ms = 0; ms <= 1; ++ms) { // loop over "bool" multisample or not
5988 for (int arrayed = 0; arrayed <= 1; ++arrayed) { // loop over "bool" arrayed or not
5989 for (int dim = Esd1D; dim < EsdSubpass; ++dim) { // 1D, ..., buffer
5990 if ((dim == Esd1D || dim == EsdRect) && profile == EEsProfile)
5993 if ((dim == Esd3D || dim == EsdRect || dim == EsdBuffer) && arrayed)
5996 if (dim != Esd2D && ms)
5999 // Loop over the bTypes
6000 for (size_t bType = 0; bType < sizeof(bTypes)/sizeof(TBasicType); ++bType) {
6002 // Now, make all the function prototypes for the type we just built...
6006 sampler.setImage(bTypes[bType], (TSamplerDim)dim, arrayed ? true : false,
6010 TString typeName = sampler.getString();
6012 addQueryFunctions(sampler, typeName, version, profile);
6013 addImageFunctions(sampler, typeName, version, profile);
6019 #endif // !GLSLANG_ANGLE
6021 #endif // !GLSLANG_WEB
6023 // printf("%s\n", commonBuiltins.c_str());
6024 // printf("%s\n", stageBuiltins[EShLangFragment].c_str());
6028 // Helper function for initialize(), to add the second set of names for texturing,
6029 // when adding context-independent built-in functions.
6031 void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile, const SpvVersion& spvVersion)
6034 // In this function proper, enumerate the types, then calls the next set of functions
6035 // to enumerate all the uses for that type.
6038 // enumerate all the types
6039 const TBasicType bTypes[] = { EbtFloat, EbtInt, EbtUint,
6040 #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
6045 bool skipBuffer = true;
6046 bool skipCubeArrayed = true;
6047 const int image = 0;
6049 bool skipBuffer = (profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 140);
6050 bool skipCubeArrayed = (profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 130);
6051 for (int image = 0; image <= 1; ++image) // loop over "bool" image vs sampler
6054 for (int shadow = 0; shadow <= 1; ++shadow) { // loop over "bool" shadow or not
6058 for (int ms = 0; ms <= 1; ++ms) // loop over "bool" multisample or not
6061 if ((ms || image) && shadow)
6063 if (ms && profile != EEsProfile && version < 150)
6065 if (ms && image && profile == EEsProfile)
6067 if (ms && profile == EEsProfile && version < 310)
6070 for (int arrayed = 0; arrayed <= 1; ++arrayed) { // loop over "bool" arrayed or not
6072 for (int dim = Esd2D; dim <= EsdCube; ++dim) { // 2D, 3D, and Cube
6074 #if defined(GLSLANG_ANGLE)
6075 for (int dim = Esd2D; dim < EsdNumDims; ++dim) { // 2D, ..., buffer, subpass
6077 for (int dim = Esd1D; dim < EsdNumDims; ++dim) { // 1D, ..., buffer, subpass
6079 if (dim == EsdSubpass && spvVersion.vulkan == 0)
6081 if (dim == EsdSubpass && (image || shadow || arrayed))
6083 if ((dim == Esd1D || dim == EsdRect) && profile == EEsProfile)
6085 if (dim == EsdSubpass && spvVersion.vulkan == 0)
6087 if (dim == EsdSubpass && (image || shadow || arrayed))
6089 if ((dim == Esd1D || dim == EsdRect) && profile == EEsProfile)
6091 if (dim != Esd2D && dim != EsdSubpass && ms)
6093 if (dim == EsdBuffer && skipBuffer)
6095 if (dim == EsdBuffer && (shadow || arrayed || ms))
6097 if (ms && arrayed && profile == EEsProfile && version < 310)
6100 if (dim == Esd3D && shadow)
6102 if (dim == EsdCube && arrayed && skipCubeArrayed)
6104 if ((dim == Esd3D || dim == EsdRect) && arrayed)
6107 // Loop over the bTypes
6108 for (size_t bType = 0; bType < sizeof(bTypes)/sizeof(TBasicType); ++bType) {
6110 if (bTypes[bType] == EbtFloat16 && (profile == EEsProfile || version < 450))
6112 if (dim == EsdRect && version < 140 && bType > 0)
6115 if (shadow && (bTypes[bType] == EbtInt || bTypes[bType] == EbtUint))
6118 // Now, make all the function prototypes for the type we just built...
6122 if (dim == EsdSubpass) {
6123 sampler.setSubpass(bTypes[bType], ms ? true : false);
6127 sampler.setImage(bTypes[bType], (TSamplerDim)dim, arrayed ? true : false,
6128 shadow ? true : false,
6131 sampler.set(bTypes[bType], (TSamplerDim)dim, arrayed ? true : false,
6132 shadow ? true : false,
6136 TString typeName = sampler.getString();
6139 if (dim == EsdSubpass) {
6140 addSubpassSampling(sampler, typeName, version, profile);
6145 addQueryFunctions(sampler, typeName, version, profile);
6148 addImageFunctions(sampler, typeName, version, profile);
6150 addSamplingFunctions(sampler, typeName, version, profile);
6152 addGatherFunctions(sampler, typeName, version, profile);
6153 if (spvVersion.vulkan > 0 && sampler.isCombined() && !sampler.shadow) {
6154 // Base Vulkan allows texelFetch() for
6155 // textureBuffer (i.e. without sampler).
6157 // GL_EXT_samplerless_texture_functions
6158 // allows texelFetch() and query functions
6159 // (other than textureQueryLod()) for all
6161 sampler.setTexture(sampler.type, sampler.dim, sampler.arrayed, sampler.shadow,
6163 TString textureTypeName = sampler.getString();
6164 addSamplingFunctions(sampler, textureTypeName, version, profile);
6165 addQueryFunctions(sampler, textureTypeName, version, profile);
6177 // sparseTexelsResidentARB()
6179 if (profile != EEsProfile && version >= 450) {
6180 commonBuiltins.append("bool sparseTexelsResidentARB(int code);\n");
6185 // Helper function for add2ndGenerationSamplingImaging(),
6186 // when adding context-independent built-in functions.
6188 // Add all the query functions for the given type.
6190 void TBuiltIns::addQueryFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile)
6193 // textureSize() and imageSize()
6196 int sizeDims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0) - (sampler.dim == EsdCube ? 1 : 0);
6199 commonBuiltins.append("highp ");
6200 commonBuiltins.append("ivec");
6201 commonBuiltins.append(postfixes[sizeDims]);
6202 commonBuiltins.append(" textureSize(");
6203 commonBuiltins.append(typeName);
6204 commonBuiltins.append(",int);\n");
6208 if (sampler.isImage() && ((profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 420)))
6211 if (profile == EEsProfile)
6212 commonBuiltins.append("highp ");
6214 commonBuiltins.append("int");
6216 commonBuiltins.append("ivec");
6217 commonBuiltins.append(postfixes[sizeDims]);
6219 if (sampler.isImage())
6220 commonBuiltins.append(" imageSize(readonly writeonly volatile coherent ");
6222 commonBuiltins.append(" textureSize(");
6223 commonBuiltins.append(typeName);
6224 if (! sampler.isImage() && ! sampler.isRect() && ! sampler.isBuffer() && ! sampler.isMultiSample())
6225 commonBuiltins.append(",int);\n");
6227 commonBuiltins.append(");\n");
6230 // textureSamples() and imageSamples()
6233 // GL_ARB_shader_texture_image_samples
6234 // TODO: spec issue? there are no memory qualifiers; how to query a writeonly/readonly image, etc?
6235 if (profile != EEsProfile && version >= 430 && sampler.isMultiSample()) {
6236 commonBuiltins.append("int ");
6237 if (sampler.isImage())
6238 commonBuiltins.append("imageSamples(readonly writeonly volatile coherent ");
6240 commonBuiltins.append("textureSamples(");
6241 commonBuiltins.append(typeName);
6242 commonBuiltins.append(");\n");
6246 // textureQueryLod(), fragment stage only
6247 // Also enabled with extension GL_ARB_texture_query_lod
6249 if (profile != EEsProfile && version >= 150 && sampler.isCombined() && sampler.dim != EsdRect &&
6250 ! sampler.isMultiSample() && ! sampler.isBuffer()) {
6251 for (int f16TexAddr = 0; f16TexAddr < 2; ++f16TexAddr) {
6252 if (f16TexAddr && sampler.type != EbtFloat16)
6254 stageBuiltins[EShLangFragment].append("vec2 textureQueryLod(");
6255 stageBuiltins[EShLangFragment].append(typeName);
6256 if (dimMap[sampler.dim] == 1)
6258 stageBuiltins[EShLangFragment].append(", float16_t");
6260 stageBuiltins[EShLangFragment].append(", float");
6263 stageBuiltins[EShLangFragment].append(", f16vec");
6265 stageBuiltins[EShLangFragment].append(", vec");
6266 stageBuiltins[EShLangFragment].append(postfixes[dimMap[sampler.dim]]);
6268 stageBuiltins[EShLangFragment].append(");\n");
6271 stageBuiltins[EShLangCompute].append("vec2 textureQueryLod(");
6272 stageBuiltins[EShLangCompute].append(typeName);
6273 if (dimMap[sampler.dim] == 1)
6274 stageBuiltins[EShLangCompute].append(", float");
6276 stageBuiltins[EShLangCompute].append(", vec");
6277 stageBuiltins[EShLangCompute].append(postfixes[dimMap[sampler.dim]]);
6279 stageBuiltins[EShLangCompute].append(");\n");
6283 // textureQueryLevels()
6286 if (profile != EEsProfile && version >= 430 && ! sampler.isImage() && sampler.dim != EsdRect &&
6287 ! sampler.isMultiSample() && ! sampler.isBuffer()) {
6288 commonBuiltins.append("int textureQueryLevels(");
6289 commonBuiltins.append(typeName);
6290 commonBuiltins.append(");\n");
6295 // Helper function for add2ndGenerationSamplingImaging(),
6296 // when adding context-independent built-in functions.
6298 // Add all the image access functions for the given type.
6300 void TBuiltIns::addImageFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile)
6302 int dims = dimMap[sampler.dim];
6303 // most things with an array add a dimension, except for cubemaps
6304 if (sampler.arrayed && sampler.dim != EsdCube)
6307 TString imageParams = typeName;
6309 imageParams.append(", int");
6311 imageParams.append(", ivec");
6312 imageParams.append(postfixes[dims]);
6314 if (sampler.isMultiSample())
6315 imageParams.append(", int");
6317 if (profile == EEsProfile)
6318 commonBuiltins.append("highp ");
6319 commonBuiltins.append(prefixes[sampler.type]);
6320 commonBuiltins.append("vec4 imageLoad(readonly volatile coherent ");
6321 commonBuiltins.append(imageParams);
6322 commonBuiltins.append(");\n");
6324 commonBuiltins.append("void imageStore(writeonly volatile coherent ");
6325 commonBuiltins.append(imageParams);
6326 commonBuiltins.append(", ");
6327 commonBuiltins.append(prefixes[sampler.type]);
6328 commonBuiltins.append("vec4);\n");
6330 if (! sampler.is1D() && ! sampler.isBuffer() && profile != EEsProfile && version >= 450) {
6331 commonBuiltins.append("int sparseImageLoadARB(readonly volatile coherent ");
6332 commonBuiltins.append(imageParams);
6333 commonBuiltins.append(", out ");
6334 commonBuiltins.append(prefixes[sampler.type]);
6335 commonBuiltins.append("vec4");
6336 commonBuiltins.append(");\n");
6339 if ( profile != EEsProfile ||
6340 (profile == EEsProfile && version >= 310)) {
6341 if (sampler.type == EbtInt || sampler.type == EbtUint || sampler.type == EbtInt64 || sampler.type == EbtUint64 ) {
6343 const char* dataType;
6344 switch (sampler.type) {
6345 case(EbtInt): dataType = "highp int"; break;
6346 case(EbtUint): dataType = "highp uint"; break;
6347 case(EbtInt64): dataType = "highp int64_t"; break;
6348 case(EbtUint64): dataType = "highp uint64_t"; break;
6349 default: dataType = "";
6352 const int numBuiltins = 7;
6354 static const char* atomicFunc[numBuiltins] = {
6355 " imageAtomicAdd(volatile coherent ",
6356 " imageAtomicMin(volatile coherent ",
6357 " imageAtomicMax(volatile coherent ",
6358 " imageAtomicAnd(volatile coherent ",
6359 " imageAtomicOr(volatile coherent ",
6360 " imageAtomicXor(volatile coherent ",
6361 " imageAtomicExchange(volatile coherent "
6364 // Loop twice to add prototypes with/without scope/semantics
6365 for (int j = 0; j < 2; ++j) {
6366 for (size_t i = 0; i < numBuiltins; ++i) {
6367 commonBuiltins.append(dataType);
6368 commonBuiltins.append(atomicFunc[i]);
6369 commonBuiltins.append(imageParams);
6370 commonBuiltins.append(", ");
6371 commonBuiltins.append(dataType);
6373 commonBuiltins.append(", int, int, int");
6375 commonBuiltins.append(");\n");
6378 commonBuiltins.append(dataType);
6379 commonBuiltins.append(" imageAtomicCompSwap(volatile coherent ");
6380 commonBuiltins.append(imageParams);
6381 commonBuiltins.append(", ");
6382 commonBuiltins.append(dataType);
6383 commonBuiltins.append(", ");
6384 commonBuiltins.append(dataType);
6386 commonBuiltins.append(", int, int, int, int, int");
6388 commonBuiltins.append(");\n");
6391 commonBuiltins.append(dataType);
6392 commonBuiltins.append(" imageAtomicLoad(volatile coherent ");
6393 commonBuiltins.append(imageParams);
6394 commonBuiltins.append(", int, int, int);\n");
6396 commonBuiltins.append("void imageAtomicStore(volatile coherent ");
6397 commonBuiltins.append(imageParams);
6398 commonBuiltins.append(", ");
6399 commonBuiltins.append(dataType);
6400 commonBuiltins.append(", int, int, int);\n");
6404 // GL_ARB_ES3_1_compatibility
6405 // TODO: spec issue: are there restrictions on the kind of layout() that can be used? what about dropping memory qualifiers?
6406 if (profile == EEsProfile && version >= 310) {
6407 commonBuiltins.append("float imageAtomicExchange(volatile coherent ");
6408 commonBuiltins.append(imageParams);
6409 commonBuiltins.append(", float);\n");
6411 if (profile != EEsProfile && version >= 450) {
6412 commonBuiltins.append("float imageAtomicAdd(volatile coherent ");
6413 commonBuiltins.append(imageParams);
6414 commonBuiltins.append(", float);\n");
6416 commonBuiltins.append("float imageAtomicAdd(volatile coherent ");
6417 commonBuiltins.append(imageParams);
6418 commonBuiltins.append(", float");
6419 commonBuiltins.append(", int, int, int);\n");
6421 commonBuiltins.append("float imageAtomicExchange(volatile coherent ");
6422 commonBuiltins.append(imageParams);
6423 commonBuiltins.append(", float);\n");
6425 commonBuiltins.append("float imageAtomicExchange(volatile coherent ");
6426 commonBuiltins.append(imageParams);
6427 commonBuiltins.append(", float");
6428 commonBuiltins.append(", int, int, int);\n");
6430 commonBuiltins.append("float imageAtomicLoad(readonly volatile coherent ");
6431 commonBuiltins.append(imageParams);
6432 commonBuiltins.append(", int, int, int);\n");
6434 commonBuiltins.append("void imageAtomicStore(writeonly volatile coherent ");
6435 commonBuiltins.append(imageParams);
6436 commonBuiltins.append(", float");
6437 commonBuiltins.append(", int, int, int);\n");
6439 commonBuiltins.append("float imageAtomicMin(volatile coherent ");
6440 commonBuiltins.append(imageParams);
6441 commonBuiltins.append(", float);\n");
6443 commonBuiltins.append("float imageAtomicMin(volatile coherent ");
6444 commonBuiltins.append(imageParams);
6445 commonBuiltins.append(", float");
6446 commonBuiltins.append(", int, int, int);\n");
6448 commonBuiltins.append("float imageAtomicMax(volatile coherent ");
6449 commonBuiltins.append(imageParams);
6450 commonBuiltins.append(", float);\n");
6452 commonBuiltins.append("float imageAtomicMax(volatile coherent ");
6453 commonBuiltins.append(imageParams);
6454 commonBuiltins.append(", float");
6455 commonBuiltins.append(", int, int, int);\n");
6460 if (sampler.dim == EsdRect || sampler.dim == EsdBuffer || sampler.shadow || sampler.isMultiSample())
6463 if (profile == EEsProfile || version < 450)
6466 TString imageLodParams = typeName;
6468 imageLodParams.append(", int");
6470 imageLodParams.append(", ivec");
6471 imageLodParams.append(postfixes[dims]);
6473 imageLodParams.append(", int");
6475 commonBuiltins.append(prefixes[sampler.type]);
6476 commonBuiltins.append("vec4 imageLoadLodAMD(readonly volatile coherent ");
6477 commonBuiltins.append(imageLodParams);
6478 commonBuiltins.append(");\n");
6480 commonBuiltins.append("void imageStoreLodAMD(writeonly volatile coherent ");
6481 commonBuiltins.append(imageLodParams);
6482 commonBuiltins.append(", ");
6483 commonBuiltins.append(prefixes[sampler.type]);
6484 commonBuiltins.append("vec4);\n");
6486 if (! sampler.is1D()) {
6487 commonBuiltins.append("int sparseImageLoadLodAMD(readonly volatile coherent ");
6488 commonBuiltins.append(imageLodParams);
6489 commonBuiltins.append(", out ");
6490 commonBuiltins.append(prefixes[sampler.type]);
6491 commonBuiltins.append("vec4");
6492 commonBuiltins.append(");\n");
6497 // Helper function for initialize(),
6498 // when adding context-independent built-in functions.
6500 // Add all the subpass access functions for the given type.
6502 void TBuiltIns::addSubpassSampling(TSampler sampler, const TString& typeName, int /*version*/, EProfile /*profile*/)
6504 stageBuiltins[EShLangFragment].append(prefixes[sampler.type]);
6505 stageBuiltins[EShLangFragment].append("vec4 subpassLoad");
6506 stageBuiltins[EShLangFragment].append("(");
6507 stageBuiltins[EShLangFragment].append(typeName.c_str());
6508 if (sampler.isMultiSample())
6509 stageBuiltins[EShLangFragment].append(", int");
6510 stageBuiltins[EShLangFragment].append(");\n");
6514 // Helper function for add2ndGenerationSamplingImaging(),
6515 // when adding context-independent built-in functions.
6517 // Add all the texture lookup functions for the given type.
6519 void TBuiltIns::addSamplingFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile)
6522 profile = EEsProfile;
6524 #elif defined(GLSLANG_ANGLE)
6525 profile = ECoreProfile;
6532 for (int proj = 0; proj <= 1; ++proj) { // loop over "bool" projective or not
6534 if (proj && (sampler.dim == EsdCube || sampler.isBuffer() || sampler.arrayed || sampler.isMultiSample()
6535 || !sampler.isCombined()))
6538 for (int lod = 0; lod <= 1; ++lod) {
6540 if (lod && (sampler.isBuffer() || sampler.isRect() || sampler.isMultiSample() || !sampler.isCombined()))
6542 if (lod && sampler.dim == Esd2D && sampler.arrayed && sampler.shadow)
6544 if (lod && sampler.dim == EsdCube && sampler.shadow)
6547 for (int bias = 0; bias <= 1; ++bias) {
6549 if (bias && (lod || sampler.isMultiSample() || !sampler.isCombined()))
6551 if (bias && (sampler.dim == Esd2D || sampler.dim == EsdCube) && sampler.shadow && sampler.arrayed)
6553 if (bias && (sampler.isRect() || sampler.isBuffer()))
6556 for (int offset = 0; offset <= 1; ++offset) { // loop over "bool" offset or not
6558 if (proj + offset + bias + lod > 3)
6560 if (offset && (sampler.dim == EsdCube || sampler.isBuffer() || sampler.isMultiSample()))
6563 for (int fetch = 0; fetch <= 1; ++fetch) { // loop over "bool" fetch or not
6565 if (proj + offset + fetch + bias + lod > 3)
6567 if (fetch && (lod || bias))
6569 if (fetch && (sampler.shadow || sampler.dim == EsdCube))
6571 if (fetch == 0 && (sampler.isMultiSample() || sampler.isBuffer()
6572 || !sampler.isCombined()))
6575 for (int grad = 0; grad <= 1; ++grad) { // loop over "bool" grad or not
6577 if (grad && (lod || bias || sampler.isMultiSample() || !sampler.isCombined()))
6579 if (grad && sampler.isBuffer())
6581 if (proj + offset + fetch + grad + bias + lod > 3)
6584 for (int extraProj = 0; extraProj <= 1; ++extraProj) {
6585 bool compare = false;
6586 int totalDims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0);
6587 // skip dummy unused second component for 1D non-array shadows
6588 if (sampler.shadow && totalDims < 2)
6590 totalDims += (sampler.shadow ? 1 : 0) + proj;
6591 if (totalDims > 4 && sampler.shadow) {
6595 assert(totalDims <= 4);
6597 if (extraProj && ! proj)
6599 if (extraProj && (sampler.dim == Esd3D || sampler.shadow || !sampler.isCombined()))
6602 // loop over 16-bit floating-point texel addressing
6603 #if defined(GLSLANG_WEB) || defined(GLSLANG_ANGLE)
6604 const int f16TexAddr = 0;
6606 for (int f16TexAddr = 0; f16TexAddr <= 1; ++f16TexAddr)
6609 if (f16TexAddr && sampler.type != EbtFloat16)
6611 if (f16TexAddr && sampler.shadow && ! compare) {
6612 compare = true; // compare argument is always present
6615 // loop over "bool" lod clamp
6616 #if defined(GLSLANG_WEB) || defined(GLSLANG_ANGLE)
6617 const int lodClamp = 0;
6619 for (int lodClamp = 0; lodClamp <= 1 ;++lodClamp)
6622 if (lodClamp && (profile == EEsProfile || version < 450))
6624 if (lodClamp && (proj || lod || fetch))
6627 // loop over "bool" sparse or not
6628 #if defined(GLSLANG_WEB) || defined(GLSLANG_ANGLE)
6629 const int sparse = 0;
6631 for (int sparse = 0; sparse <= 1; ++sparse)
6634 if (sparse && (profile == EEsProfile || version < 450))
6636 // Sparse sampling is not for 1D/1D array texture, buffer texture, and
6637 // projective texture
6638 if (sparse && (sampler.is1D() || sampler.isBuffer() || proj))
6648 if (sampler.type == EbtFloat16)
6649 s.append("float16_t ");
6653 s.append(prefixes[sampler.type]);
6661 s.append("sparseTexel");
6663 s.append("sparseTexture");
6669 s.append("texture");
6683 if (lodClamp != 0 || sparse)
6692 s.append(",f16vec4");
6697 TBasicType t = fetch ? EbtInt : (f16TexAddr ? EbtFloat16 : EbtFloat);
6699 s.append(TType::getBasicString(t));
6701 s.append(prefixes[t]);
6703 s.append(postfixes[totalDims]);
6706 // non-optional compare
6710 // non-optional lod argument (lod that's not driven by lod loop) or sample
6711 if ((fetch && !sampler.isBuffer() &&
6712 !sampler.isRect() && !sampler.isMultiSample())
6713 || (sampler.isMultiSample() && fetch))
6718 s.append(",float16_t");
6723 // gradient arguments
6725 if (dimMap[sampler.dim] == 1) {
6727 s.append(",float16_t,float16_t");
6729 s.append(",float,float");
6732 s.append(",f16vec");
6735 s.append(postfixes[dimMap[sampler.dim]]);
6737 s.append(",f16vec");
6740 s.append(postfixes[dimMap[sampler.dim]]);
6745 if (dimMap[sampler.dim] == 1)
6749 s.append(postfixes[dimMap[sampler.dim]]);
6756 s.append(",float16_t");
6760 // texel out (for sparse texture)
6764 if (sampler.type == EbtFloat16)
6765 s.append("float16_t");
6769 s.append(prefixes[sampler.type]);
6776 s.append(",float16_t");
6782 // Add to the per-language set of built-ins
6783 if (!grad && (bias || lodClamp != 0)) {
6784 stageBuiltins[EShLangFragment].append(s);
6785 stageBuiltins[EShLangCompute].append(s);
6787 commonBuiltins.append(s);
6802 // Helper function for add2ndGenerationSamplingImaging(),
6803 // when adding context-independent built-in functions.
6805 // Add all the texture gather functions for the given type.
6807 void TBuiltIns::addGatherFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile)
6810 profile = EEsProfile;
6812 #elif defined(GLSLANG_ANGLE)
6813 profile = ECoreProfile;
6817 switch (sampler.dim) {
6826 if (sampler.isMultiSample())
6829 if (version < 140 && sampler.dim == EsdRect && sampler.type != EbtFloat)
6832 for (int f16TexAddr = 0; f16TexAddr <= 1; ++f16TexAddr) { // loop over 16-bit floating-point texel addressing
6834 if (f16TexAddr && sampler.type != EbtFloat16)
6836 for (int offset = 0; offset < 3; ++offset) { // loop over three forms of offset in the call name: none, Offset, and Offsets
6838 for (int comp = 0; comp < 2; ++comp) { // loop over presence of comp argument
6840 if (comp > 0 && sampler.shadow)
6843 if (offset > 0 && sampler.dim == EsdCube)
6846 for (int sparse = 0; sparse <= 1; ++sparse) { // loop over "bool" sparse or not
6847 if (sparse && (profile == EEsProfile || version < 450))
6856 s.append(prefixes[sampler.type]);
6862 s.append("sparseTextureGather");
6864 s.append("textureGather");
6870 s.append("Offsets");
6879 // sampler type argument
6882 // P coordinate argument
6884 s.append(",f16vec");
6887 int totalDims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0);
6888 s.append(postfixes[totalDims]);
6901 // texel out (for sparse texture)
6904 s.append(prefixes[sampler.type]);
6913 commonBuiltins.append(s);
6919 if (sampler.dim == EsdRect || sampler.shadow)
6922 if (profile == EEsProfile || version < 450)
6925 for (int bias = 0; bias < 2; ++bias) { // loop over presence of bias argument
6927 for (int lod = 0; lod < 2; ++lod) { // loop over presence of lod argument
6929 if ((lod && bias) || (lod == 0 && bias == 0))
6932 for (int f16TexAddr = 0; f16TexAddr <= 1; ++f16TexAddr) { // loop over 16-bit floating-point texel addressing
6934 if (f16TexAddr && sampler.type != EbtFloat16)
6937 for (int offset = 0; offset < 3; ++offset) { // loop over three forms of offset in the call name: none, Offset, and Offsets
6939 for (int comp = 0; comp < 2; ++comp) { // loop over presence of comp argument
6941 if (comp == 0 && bias)
6944 if (offset > 0 && sampler.dim == EsdCube)
6947 for (int sparse = 0; sparse <= 1; ++sparse) { // loop over "bool" sparse or not
6948 if (sparse && (profile == EEsProfile || version < 450))
6957 s.append(prefixes[sampler.type]);
6963 s.append("sparseTextureGather");
6965 s.append("textureGather");
6975 s.append("Offsets");
6988 // sampler type argument
6991 // P coordinate argument
6993 s.append(",f16vec");
6996 int totalDims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0);
6997 s.append(postfixes[totalDims]);
7002 s.append(",float16_t");
7014 // texel out (for sparse texture)
7017 s.append(prefixes[sampler.type]);
7028 s.append(",float16_t");
7035 stageBuiltins[EShLangFragment].append(s);
7037 commonBuiltins.append(s);
7047 // Add context-dependent built-in functions and variables that are present
7048 // for the given version and profile. All the results are put into just the
7049 // commonBuiltins, because it is called for just a specific stage. So,
7050 // add stage-specific entries to the commonBuiltins, and only if that stage
7053 void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language)
7057 profile = EEsProfile;
7058 #elif defined(GLSLANG_ANGLE)
7060 profile = ECoreProfile;
7064 // Initialize the context-dependent (resource-dependent) built-in strings for parsing.
7067 //============================================================================
7069 // Standard Uniforms
7071 //============================================================================
7073 TString& s = commonBuiltins;
7074 const int maxSize = 200;
7075 char builtInConstant[maxSize];
7078 // Build string of implementation dependent constants.
7081 if (profile == EEsProfile) {
7082 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs);
7083 s.append(builtInConstant);
7085 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxVertexUniformVectors = %d;", resources.maxVertexUniformVectors);
7086 s.append(builtInConstant);
7088 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxVertexTextureImageUnits = %d;", resources.maxVertexTextureImageUnits);
7089 s.append(builtInConstant);
7091 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxCombinedTextureImageUnits = %d;", resources.maxCombinedTextureImageUnits);
7092 s.append(builtInConstant);
7094 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits);
7095 s.append(builtInConstant);
7097 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxFragmentUniformVectors = %d;", resources.maxFragmentUniformVectors);
7098 s.append(builtInConstant);
7100 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxDrawBuffers = %d;", resources.maxDrawBuffers);
7101 s.append(builtInConstant);
7103 if (version == 100) {
7104 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxVaryingVectors = %d;", resources.maxVaryingVectors);
7105 s.append(builtInConstant);
7107 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxVertexOutputVectors = %d;", resources.maxVertexOutputVectors);
7108 s.append(builtInConstant);
7110 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxFragmentInputVectors = %d;", resources.maxFragmentInputVectors);
7111 s.append(builtInConstant);
7113 snprintf(builtInConstant, maxSize, "const mediump int gl_MinProgramTexelOffset = %d;", resources.minProgramTexelOffset);
7114 s.append(builtInConstant);
7116 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxProgramTexelOffset = %d;", resources.maxProgramTexelOffset);
7117 s.append(builtInConstant);
7121 if (version >= 310) {
7124 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryInputComponents = %d;", resources.maxGeometryInputComponents);
7125 s.append(builtInConstant);
7126 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryOutputComponents = %d;", resources.maxGeometryOutputComponents);
7127 s.append(builtInConstant);
7128 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryImageUniforms = %d;", resources.maxGeometryImageUniforms);
7129 s.append(builtInConstant);
7130 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryTextureImageUnits = %d;", resources.maxGeometryTextureImageUnits);
7131 s.append(builtInConstant);
7132 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryOutputVertices = %d;", resources.maxGeometryOutputVertices);
7133 s.append(builtInConstant);
7134 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryTotalOutputComponents = %d;", resources.maxGeometryTotalOutputComponents);
7135 s.append(builtInConstant);
7136 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryUniformComponents = %d;", resources.maxGeometryUniformComponents);
7137 s.append(builtInConstant);
7138 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounters = %d;", resources.maxGeometryAtomicCounters);
7139 s.append(builtInConstant);
7140 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounterBuffers = %d;", resources.maxGeometryAtomicCounterBuffers);
7141 s.append(builtInConstant);
7145 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlInputComponents = %d;", resources.maxTessControlInputComponents);
7146 s.append(builtInConstant);
7147 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlOutputComponents = %d;", resources.maxTessControlOutputComponents);
7148 s.append(builtInConstant);
7149 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlTextureImageUnits = %d;", resources.maxTessControlTextureImageUnits);
7150 s.append(builtInConstant);
7151 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlUniformComponents = %d;", resources.maxTessControlUniformComponents);
7152 s.append(builtInConstant);
7153 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlTotalOutputComponents = %d;", resources.maxTessControlTotalOutputComponents);
7154 s.append(builtInConstant);
7156 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationInputComponents = %d;", resources.maxTessEvaluationInputComponents);
7157 s.append(builtInConstant);
7158 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationOutputComponents = %d;", resources.maxTessEvaluationOutputComponents);
7159 s.append(builtInConstant);
7160 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationTextureImageUnits = %d;", resources.maxTessEvaluationTextureImageUnits);
7161 s.append(builtInConstant);
7162 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationUniformComponents = %d;", resources.maxTessEvaluationUniformComponents);
7163 s.append(builtInConstant);
7165 snprintf(builtInConstant, maxSize, "const int gl_MaxTessPatchComponents = %d;", resources.maxTessPatchComponents);
7166 s.append(builtInConstant);
7168 snprintf(builtInConstant, maxSize, "const int gl_MaxPatchVertices = %d;", resources.maxPatchVertices);
7169 s.append(builtInConstant);
7170 snprintf(builtInConstant, maxSize, "const int gl_MaxTessGenLevel = %d;", resources.maxTessGenLevel);
7171 s.append(builtInConstant);
7173 // this is here instead of with the others in initialize(version, profile) due to the dependence on gl_MaxPatchVertices
7174 if (language == EShLangTessControl || language == EShLangTessEvaluation) {
7177 "highp vec4 gl_Position;"
7178 "highp float gl_PointSize;"
7179 "highp vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
7180 "highp vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
7181 "} gl_in[gl_MaxPatchVertices];"
7186 if (version >= 320) {
7189 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlImageUniforms = %d;", resources.maxTessControlImageUniforms);
7190 s.append(builtInConstant);
7191 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationImageUniforms = %d;", resources.maxTessEvaluationImageUniforms);
7192 s.append(builtInConstant);
7193 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounters = %d;", resources.maxTessControlAtomicCounters);
7194 s.append(builtInConstant);
7195 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounters = %d;", resources.maxTessEvaluationAtomicCounters);
7196 s.append(builtInConstant);
7197 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounterBuffers = %d;", resources.maxTessControlAtomicCounterBuffers);
7198 s.append(builtInConstant);
7199 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounterBuffers = %d;", resources.maxTessEvaluationAtomicCounterBuffers);
7200 s.append(builtInConstant);
7203 if (version >= 100) {
7204 // GL_EXT_blend_func_extended
7205 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxDualSourceDrawBuffersEXT = %d;", resources.maxDualSourceDrawBuffersEXT);
7206 s.append(builtInConstant);
7207 // this is here instead of with the others in initialize(version, profile) due to the dependence on gl_MaxDualSourceDrawBuffersEXT
7208 if (language == EShLangFragment) {
7210 "mediump vec4 gl_SecondaryFragColorEXT;"
7211 "mediump vec4 gl_SecondaryFragDataEXT[gl_MaxDualSourceDrawBuffersEXT];"
7218 if (version > 400) {
7219 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexUniformVectors = %d;", resources.maxVertexUniformVectors);
7220 s.append(builtInConstant);
7222 snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentUniformVectors = %d;", resources.maxFragmentUniformVectors);
7223 s.append(builtInConstant);
7225 snprintf(builtInConstant, maxSize, "const int gl_MaxVaryingVectors = %d;", resources.maxVaryingVectors);
7226 s.append(builtInConstant);
7229 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs);
7230 s.append(builtInConstant);
7232 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexTextureImageUnits = %d;", resources.maxVertexTextureImageUnits);
7233 s.append(builtInConstant);
7235 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedTextureImageUnits = %d;", resources.maxCombinedTextureImageUnits);
7236 s.append(builtInConstant);
7238 snprintf(builtInConstant, maxSize, "const int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits);
7239 s.append(builtInConstant);
7241 snprintf(builtInConstant, maxSize, "const int gl_MaxDrawBuffers = %d;", resources.maxDrawBuffers);
7242 s.append(builtInConstant);
7244 snprintf(builtInConstant, maxSize, "const int gl_MaxLights = %d;", resources.maxLights);
7245 s.append(builtInConstant);
7247 snprintf(builtInConstant, maxSize, "const int gl_MaxClipPlanes = %d;", resources.maxClipPlanes);
7248 s.append(builtInConstant);
7250 snprintf(builtInConstant, maxSize, "const int gl_MaxTextureUnits = %d;", resources.maxTextureUnits);
7251 s.append(builtInConstant);
7253 snprintf(builtInConstant, maxSize, "const int gl_MaxTextureCoords = %d;", resources.maxTextureCoords);
7254 s.append(builtInConstant);
7256 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexUniformComponents = %d;", resources.maxVertexUniformComponents);
7257 s.append(builtInConstant);
7259 // Moved from just being deprecated into compatibility profile only as of 4.20
7260 if (version < 420 || profile == ECompatibilityProfile) {
7261 snprintf(builtInConstant, maxSize, "const int gl_MaxVaryingFloats = %d;", resources.maxVaryingFloats);
7262 s.append(builtInConstant);
7265 snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentUniformComponents = %d;", resources.maxFragmentUniformComponents);
7266 s.append(builtInConstant);
7268 if (spvVersion.spv == 0 && IncludeLegacy(version, profile, spvVersion)) {
7270 // OpenGL'uniform' state. Page numbers are in reference to version
7271 // 1.4 of the OpenGL specification.
7275 // Matrix state. p. 31, 32, 37, 39, 40.
7277 s.append("uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];"
7280 // Derived matrix state that provides inverse and transposed versions
7281 // of the matrices above.
7283 "uniform mat4 gl_TextureMatrixInverse[gl_MaxTextureCoords];"
7285 "uniform mat4 gl_TextureMatrixTranspose[gl_MaxTextureCoords];"
7287 "uniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords];"
7290 // Clip planes p. 42.
7292 "uniform vec4 gl_ClipPlane[gl_MaxClipPlanes];"
7295 // Light State p 50, 53, 55.
7297 "uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];"
7300 // Derived state from products of light.
7302 "uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];"
7303 "uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];"
7306 // Texture Environment and Generation, p. 152, p. 40-42.
7308 "uniform vec4 gl_TextureEnvColor[gl_MaxTextureImageUnits];"
7309 "uniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];"
7310 "uniform vec4 gl_EyePlaneT[gl_MaxTextureCoords];"
7311 "uniform vec4 gl_EyePlaneR[gl_MaxTextureCoords];"
7312 "uniform vec4 gl_EyePlaneQ[gl_MaxTextureCoords];"
7313 "uniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoords];"
7314 "uniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoords];"
7315 "uniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoords];"
7316 "uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoords];");
7319 if (version >= 130) {
7320 snprintf(builtInConstant, maxSize, "const int gl_MaxClipDistances = %d;", resources.maxClipDistances);
7321 s.append(builtInConstant);
7322 snprintf(builtInConstant, maxSize, "const int gl_MaxVaryingComponents = %d;", resources.maxVaryingComponents);
7323 s.append(builtInConstant);
7325 // GL_ARB_shading_language_420pack
7326 snprintf(builtInConstant, maxSize, "const mediump int gl_MinProgramTexelOffset = %d;", resources.minProgramTexelOffset);
7327 s.append(builtInConstant);
7328 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxProgramTexelOffset = %d;", resources.maxProgramTexelOffset);
7329 s.append(builtInConstant);
7333 if (version >= 150) {
7334 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryInputComponents = %d;", resources.maxGeometryInputComponents);
7335 s.append(builtInConstant);
7336 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryOutputComponents = %d;", resources.maxGeometryOutputComponents);
7337 s.append(builtInConstant);
7338 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryTextureImageUnits = %d;", resources.maxGeometryTextureImageUnits);
7339 s.append(builtInConstant);
7340 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryOutputVertices = %d;", resources.maxGeometryOutputVertices);
7341 s.append(builtInConstant);
7342 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryTotalOutputComponents = %d;", resources.maxGeometryTotalOutputComponents);
7343 s.append(builtInConstant);
7344 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryUniformComponents = %d;", resources.maxGeometryUniformComponents);
7345 s.append(builtInConstant);
7346 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryVaryingComponents = %d;", resources.maxGeometryVaryingComponents);
7347 s.append(builtInConstant);
7351 if (version >= 150) {
7352 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexOutputComponents = %d;", resources.maxVertexOutputComponents);
7353 s.append(builtInConstant);
7354 snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentInputComponents = %d;", resources.maxFragmentInputComponents);
7355 s.append(builtInConstant);
7359 if (version >= 150) {
7360 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlInputComponents = %d;", resources.maxTessControlInputComponents);
7361 s.append(builtInConstant);
7362 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlOutputComponents = %d;", resources.maxTessControlOutputComponents);
7363 s.append(builtInConstant);
7364 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlTextureImageUnits = %d;", resources.maxTessControlTextureImageUnits);
7365 s.append(builtInConstant);
7366 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlUniformComponents = %d;", resources.maxTessControlUniformComponents);
7367 s.append(builtInConstant);
7368 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlTotalOutputComponents = %d;", resources.maxTessControlTotalOutputComponents);
7369 s.append(builtInConstant);
7371 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationInputComponents = %d;", resources.maxTessEvaluationInputComponents);
7372 s.append(builtInConstant);
7373 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationOutputComponents = %d;", resources.maxTessEvaluationOutputComponents);
7374 s.append(builtInConstant);
7375 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationTextureImageUnits = %d;", resources.maxTessEvaluationTextureImageUnits);
7376 s.append(builtInConstant);
7377 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationUniformComponents = %d;", resources.maxTessEvaluationUniformComponents);
7378 s.append(builtInConstant);
7380 snprintf(builtInConstant, maxSize, "const int gl_MaxTessPatchComponents = %d;", resources.maxTessPatchComponents);
7381 s.append(builtInConstant);
7382 snprintf(builtInConstant, maxSize, "const int gl_MaxTessGenLevel = %d;", resources.maxTessGenLevel);
7383 s.append(builtInConstant);
7384 snprintf(builtInConstant, maxSize, "const int gl_MaxPatchVertices = %d;", resources.maxPatchVertices);
7385 s.append(builtInConstant);
7387 // this is here instead of with the others in initialize(version, profile) due to the dependence on gl_MaxPatchVertices
7388 if (language == EShLangTessControl || language == EShLangTessEvaluation) {
7392 "float gl_PointSize;"
7393 "float gl_ClipDistance[];"
7395 if (profile == ECompatibilityProfile)
7397 "vec4 gl_ClipVertex;"
7398 "vec4 gl_FrontColor;"
7399 "vec4 gl_BackColor;"
7400 "vec4 gl_FrontSecondaryColor;"
7401 "vec4 gl_BackSecondaryColor;"
7402 "vec4 gl_TexCoord[];"
7403 "float gl_FogFragCoord;"
7405 if (profile != EEsProfile && version >= 450)
7407 "float gl_CullDistance[];"
7408 "vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
7409 "vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
7412 "} gl_in[gl_MaxPatchVertices];"
7417 if (version >= 150) {
7418 snprintf(builtInConstant, maxSize, "const int gl_MaxViewports = %d;", resources.maxViewports);
7419 s.append(builtInConstant);
7423 if (version >= 130) {
7424 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedImageUnitsAndFragmentOutputs = %d;", resources.maxCombinedImageUnitsAndFragmentOutputs);
7425 s.append(builtInConstant);
7426 snprintf(builtInConstant, maxSize, "const int gl_MaxImageSamples = %d;", resources.maxImageSamples);
7427 s.append(builtInConstant);
7428 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlImageUniforms = %d;", resources.maxTessControlImageUniforms);
7429 s.append(builtInConstant);
7430 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationImageUniforms = %d;", resources.maxTessEvaluationImageUniforms);
7431 s.append(builtInConstant);
7432 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryImageUniforms = %d;", resources.maxGeometryImageUniforms);
7433 s.append(builtInConstant);
7437 if (version >= 430) {
7438 snprintf(builtInConstant, maxSize, "const int gl_MaxTransformFeedbackBuffers = %d;", resources.maxTransformFeedbackBuffers);
7439 s.append(builtInConstant);
7440 snprintf(builtInConstant, maxSize, "const int gl_MaxTransformFeedbackInterleavedComponents = %d;", resources.maxTransformFeedbackInterleavedComponents);
7441 s.append(builtInConstant);
7447 if ((profile == EEsProfile && version >= 310) || (profile != EEsProfile && version >= 420)) {
7448 snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxComputeWorkGroupCount = ivec3(%d,%d,%d);", resources.maxComputeWorkGroupCountX,
7449 resources.maxComputeWorkGroupCountY,
7450 resources.maxComputeWorkGroupCountZ);
7451 s.append(builtInConstant);
7452 snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxComputeWorkGroupSize = ivec3(%d,%d,%d);", resources.maxComputeWorkGroupSizeX,
7453 resources.maxComputeWorkGroupSizeY,
7454 resources.maxComputeWorkGroupSizeZ);
7455 s.append(builtInConstant);
7457 snprintf(builtInConstant, maxSize, "const int gl_MaxComputeUniformComponents = %d;", resources.maxComputeUniformComponents);
7458 s.append(builtInConstant);
7459 snprintf(builtInConstant, maxSize, "const int gl_MaxComputeTextureImageUnits = %d;", resources.maxComputeTextureImageUnits);
7460 s.append(builtInConstant);
7466 // images (some in compute below)
7467 if ((profile == EEsProfile && version >= 310) ||
7468 (profile != EEsProfile && version >= 130)) {
7469 snprintf(builtInConstant, maxSize, "const int gl_MaxImageUnits = %d;", resources.maxImageUnits);
7470 s.append(builtInConstant);
7471 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedShaderOutputResources = %d;", resources.maxCombinedShaderOutputResources);
7472 s.append(builtInConstant);
7473 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexImageUniforms = %d;", resources.maxVertexImageUniforms);
7474 s.append(builtInConstant);
7475 snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentImageUniforms = %d;", resources.maxFragmentImageUniforms);
7476 s.append(builtInConstant);
7477 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedImageUniforms = %d;", resources.maxCombinedImageUniforms);
7478 s.append(builtInConstant);
7482 if ((profile == EEsProfile && version >= 310) || (profile != EEsProfile && version >= 420)) {
7483 snprintf(builtInConstant, maxSize, "const int gl_MaxComputeImageUniforms = %d;", resources.maxComputeImageUniforms);
7484 s.append(builtInConstant);
7485 snprintf(builtInConstant, maxSize, "const int gl_MaxComputeAtomicCounters = %d;", resources.maxComputeAtomicCounters);
7486 s.append(builtInConstant);
7487 snprintf(builtInConstant, maxSize, "const int gl_MaxComputeAtomicCounterBuffers = %d;", resources.maxComputeAtomicCounterBuffers);
7488 s.append(builtInConstant);
7493 #ifndef GLSLANG_ANGLE
7494 // atomic counters (some in compute below)
7495 if ((profile == EEsProfile && version >= 310) ||
7496 (profile != EEsProfile && version >= 420)) {
7497 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAtomicCounters = %d;", resources. maxVertexAtomicCounters);
7498 s.append(builtInConstant);
7499 snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentAtomicCounters = %d;", resources. maxFragmentAtomicCounters);
7500 s.append(builtInConstant);
7501 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedAtomicCounters = %d;", resources. maxCombinedAtomicCounters);
7502 s.append(builtInConstant);
7503 snprintf(builtInConstant, maxSize, "const int gl_MaxAtomicCounterBindings = %d;", resources. maxAtomicCounterBindings);
7504 s.append(builtInConstant);
7505 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAtomicCounterBuffers = %d;", resources. maxVertexAtomicCounterBuffers);
7506 s.append(builtInConstant);
7507 snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentAtomicCounterBuffers = %d;", resources. maxFragmentAtomicCounterBuffers);
7508 s.append(builtInConstant);
7509 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedAtomicCounterBuffers = %d;", resources. maxCombinedAtomicCounterBuffers);
7510 s.append(builtInConstant);
7511 snprintf(builtInConstant, maxSize, "const int gl_MaxAtomicCounterBufferSize = %d;", resources. maxAtomicCounterBufferSize);
7512 s.append(builtInConstant);
7514 if (profile != EEsProfile && version >= 420) {
7515 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounters = %d;", resources. maxTessControlAtomicCounters);
7516 s.append(builtInConstant);
7517 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounters = %d;", resources. maxTessEvaluationAtomicCounters);
7518 s.append(builtInConstant);
7519 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounters = %d;", resources. maxGeometryAtomicCounters);
7520 s.append(builtInConstant);
7521 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounterBuffers = %d;", resources. maxTessControlAtomicCounterBuffers);
7522 s.append(builtInConstant);
7523 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounterBuffers = %d;", resources. maxTessEvaluationAtomicCounterBuffers);
7524 s.append(builtInConstant);
7525 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounterBuffers = %d;", resources. maxGeometryAtomicCounterBuffers);
7526 s.append(builtInConstant);
7530 #endif // !GLSLANG_ANGLE
7532 // GL_ARB_cull_distance
7533 if (profile != EEsProfile && version >= 450) {
7534 snprintf(builtInConstant, maxSize, "const int gl_MaxCullDistances = %d;", resources.maxCullDistances);
7535 s.append(builtInConstant);
7536 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedClipAndCullDistances = %d;", resources.maxCombinedClipAndCullDistances);
7537 s.append(builtInConstant);
7540 // GL_ARB_ES3_1_compatibility
7541 if ((profile != EEsProfile && version >= 450) ||
7542 (profile == EEsProfile && version >= 310)) {
7543 snprintf(builtInConstant, maxSize, "const int gl_MaxSamples = %d;", resources.maxSamples);
7544 s.append(builtInConstant);
7547 #ifndef GLSLANG_ANGLE
7548 // SPV_NV_mesh_shader
7549 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
7550 snprintf(builtInConstant, maxSize, "const int gl_MaxMeshOutputVerticesNV = %d;", resources.maxMeshOutputVerticesNV);
7551 s.append(builtInConstant);
7553 snprintf(builtInConstant, maxSize, "const int gl_MaxMeshOutputPrimitivesNV = %d;", resources.maxMeshOutputPrimitivesNV);
7554 s.append(builtInConstant);
7556 snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxMeshWorkGroupSizeNV = ivec3(%d,%d,%d);", resources.maxMeshWorkGroupSizeX_NV,
7557 resources.maxMeshWorkGroupSizeY_NV,
7558 resources.maxMeshWorkGroupSizeZ_NV);
7559 s.append(builtInConstant);
7560 snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxTaskWorkGroupSizeNV = ivec3(%d,%d,%d);", resources.maxTaskWorkGroupSizeX_NV,
7561 resources.maxTaskWorkGroupSizeY_NV,
7562 resources.maxTaskWorkGroupSizeZ_NV);
7563 s.append(builtInConstant);
7565 snprintf(builtInConstant, maxSize, "const int gl_MaxMeshViewCountNV = %d;", resources.maxMeshViewCountNV);
7566 s.append(builtInConstant);
7577 // To support special built-ins that have a special qualifier that cannot be declared textually
7578 // in a shader, like gl_Position.
7580 // This lets the type of the built-in be declared textually, and then have just its qualifier be
7581 // updated afterward.
7583 // Safe to call even if name is not present.
7585 // Only use this for built-in variables that have a special qualifier in TStorageQualifier.
7586 // New built-in variables should use a generic (textually declarable) qualifier in
7587 // TStoraregQualifier and only call BuiltInVariable().
7589 static void SpecialQualifier(const char* name, TStorageQualifier qualifier, TBuiltInVariable builtIn, TSymbolTable& symbolTable)
7591 TSymbol* symbol = symbolTable.find(name);
7592 if (symbol == nullptr)
7595 TQualifier& symQualifier = symbol->getWritableType().getQualifier();
7596 symQualifier.storage = qualifier;
7597 symQualifier.builtIn = builtIn;
7601 // To tag built-in variables with their TBuiltInVariable enum. Use this when the
7602 // normal declaration text already gets the qualifier right, and all that's needed
7603 // is setting the builtIn field. This should be the normal way for all new
7604 // built-in variables.
7606 // If SpecialQualifier() was called, this does not need to be called.
7608 // Safe to call even if name is not present.
7610 static void BuiltInVariable(const char* name, TBuiltInVariable builtIn, TSymbolTable& symbolTable)
7612 TSymbol* symbol = symbolTable.find(name);
7613 if (symbol == nullptr)
7616 TQualifier& symQualifier = symbol->getWritableType().getQualifier();
7617 symQualifier.builtIn = builtIn;
7620 static void RetargetVariable(const char* from, const char* to, TSymbolTable& symbolTable)
7622 symbolTable.retargetSymbol(from, to);
7626 // For built-in variables inside a named block.
7627 // SpecialQualifier() won't ever go inside a block; their member's qualifier come
7628 // from the qualification of the block.
7630 // See comments above for other detail.
7632 static void BuiltInVariable(const char* blockName, const char* name, TBuiltInVariable builtIn, TSymbolTable& symbolTable)
7634 TSymbol* symbol = symbolTable.find(blockName);
7635 if (symbol == nullptr)
7638 TTypeList& structure = *symbol->getWritableType().getWritableStruct();
7639 for (int i = 0; i < (int)structure.size(); ++i) {
7640 if (structure[i].type->getFieldName().compare(name) == 0) {
7641 structure[i].type->getQualifier().builtIn = builtIn;
7648 // Finish adding/processing context-independent built-in symbols.
7649 // 1) Programmatically add symbols that could not be added by simple text strings above.
7650 // 2) Map built-in functions to operators, for those that will turn into an operation node
7651 // instead of remaining a function call.
7652 // 3) Tag extension-related symbols added to their base version with their extensions, so
7653 // that if an early version has the extension turned off, there is an error reported on use.
7655 void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable)
7659 profile = EEsProfile;
7660 #elif defined(GLSLANG_ANGLE)
7662 profile = ECoreProfile;
7666 // Tag built-in variables and functions with additional qualifier and extension information
7667 // that cannot be declared with the text strings.
7670 // N.B.: a symbol should only be tagged once, and this function is called multiple times, once
7671 // per stage that's used for this profile. So
7672 // - generally, stick common ones in the fragment stage to ensure they are tagged exactly once
7673 // - for ES, which has different precisions for different stages, the coarsest-grained tagging
7674 // for a built-in used in many stages needs to be once for the fragment stage and once for
7679 if (spvVersion.vulkan > 0) {
7680 BuiltInVariable("gl_VertexIndex", EbvVertexIndex, symbolTable);
7681 BuiltInVariable("gl_InstanceIndex", EbvInstanceIndex, symbolTable);
7685 if (spvVersion.vulkan == 0) {
7686 SpecialQualifier("gl_VertexID", EvqVertexId, EbvVertexId, symbolTable);
7687 SpecialQualifier("gl_InstanceID", EvqInstanceId, EbvInstanceId, symbolTable);
7690 if (spvVersion.vulkan > 0 && spvVersion.vulkanRelaxed) {
7691 // treat these built-ins as aliases of VertexIndex and InstanceIndex
7692 RetargetVariable("gl_InstanceID", "gl_InstanceIndex", symbolTable);
7693 RetargetVariable("gl_VertexID", "gl_VertexIndex", symbolTable);
7696 if (profile != EEsProfile) {
7697 if (version >= 440) {
7698 symbolTable.setVariableExtensions("gl_BaseVertexARB", 1, &E_GL_ARB_shader_draw_parameters);
7699 symbolTable.setVariableExtensions("gl_BaseInstanceARB", 1, &E_GL_ARB_shader_draw_parameters);
7700 symbolTable.setVariableExtensions("gl_DrawIDARB", 1, &E_GL_ARB_shader_draw_parameters);
7701 BuiltInVariable("gl_BaseVertexARB", EbvBaseVertex, symbolTable);
7702 BuiltInVariable("gl_BaseInstanceARB", EbvBaseInstance, symbolTable);
7703 BuiltInVariable("gl_DrawIDARB", EbvDrawId, symbolTable);
7705 if (version >= 460) {
7706 BuiltInVariable("gl_BaseVertex", EbvBaseVertex, symbolTable);
7707 BuiltInVariable("gl_BaseInstance", EbvBaseInstance, symbolTable);
7708 BuiltInVariable("gl_DrawID", EbvDrawId, symbolTable);
7710 symbolTable.setVariableExtensions("gl_SubGroupSizeARB", 1, &E_GL_ARB_shader_ballot);
7711 symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
7712 symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB", 1, &E_GL_ARB_shader_ballot);
7713 symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB", 1, &E_GL_ARB_shader_ballot);
7714 symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB", 1, &E_GL_ARB_shader_ballot);
7715 symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB", 1, &E_GL_ARB_shader_ballot);
7716 symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB", 1, &E_GL_ARB_shader_ballot);
7718 symbolTable.setFunctionExtensions("ballotARB", 1, &E_GL_ARB_shader_ballot);
7719 symbolTable.setFunctionExtensions("readInvocationARB", 1, &E_GL_ARB_shader_ballot);
7720 symbolTable.setFunctionExtensions("readFirstInvocationARB", 1, &E_GL_ARB_shader_ballot);
7722 if (version >= 430) {
7723 symbolTable.setFunctionExtensions("anyInvocationARB", 1, &E_GL_ARB_shader_group_vote);
7724 symbolTable.setFunctionExtensions("allInvocationsARB", 1, &E_GL_ARB_shader_group_vote);
7725 symbolTable.setFunctionExtensions("allInvocationsEqualARB", 1, &E_GL_ARB_shader_group_vote);
7730 if (profile != EEsProfile) {
7731 symbolTable.setFunctionExtensions("minInvocationsAMD", 1, &E_GL_AMD_shader_ballot);
7732 symbolTable.setFunctionExtensions("maxInvocationsAMD", 1, &E_GL_AMD_shader_ballot);
7733 symbolTable.setFunctionExtensions("addInvocationsAMD", 1, &E_GL_AMD_shader_ballot);
7734 symbolTable.setFunctionExtensions("minInvocationsNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
7735 symbolTable.setFunctionExtensions("maxInvocationsNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
7736 symbolTable.setFunctionExtensions("addInvocationsNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
7737 symbolTable.setFunctionExtensions("swizzleInvocationsAMD", 1, &E_GL_AMD_shader_ballot);
7738 symbolTable.setFunctionExtensions("swizzleInvocationsWithPatternAMD", 1, &E_GL_AMD_shader_ballot);
7739 symbolTable.setFunctionExtensions("writeInvocationAMD", 1, &E_GL_AMD_shader_ballot);
7740 symbolTable.setFunctionExtensions("mbcntAMD", 1, &E_GL_AMD_shader_ballot);
7742 symbolTable.setFunctionExtensions("minInvocationsInclusiveScanAMD", 1, &E_GL_AMD_shader_ballot);
7743 symbolTable.setFunctionExtensions("maxInvocationsInclusiveScanAMD", 1, &E_GL_AMD_shader_ballot);
7744 symbolTable.setFunctionExtensions("addInvocationsInclusiveScanAMD", 1, &E_GL_AMD_shader_ballot);
7745 symbolTable.setFunctionExtensions("minInvocationsInclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
7746 symbolTable.setFunctionExtensions("maxInvocationsInclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
7747 symbolTable.setFunctionExtensions("addInvocationsInclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
7748 symbolTable.setFunctionExtensions("minInvocationsExclusiveScanAMD", 1, &E_GL_AMD_shader_ballot);
7749 symbolTable.setFunctionExtensions("maxInvocationsExclusiveScanAMD", 1, &E_GL_AMD_shader_ballot);
7750 symbolTable.setFunctionExtensions("addInvocationsExclusiveScanAMD", 1, &E_GL_AMD_shader_ballot);
7751 symbolTable.setFunctionExtensions("minInvocationsExclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
7752 symbolTable.setFunctionExtensions("maxInvocationsExclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
7753 symbolTable.setFunctionExtensions("addInvocationsExclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
7756 if (profile != EEsProfile) {
7757 symbolTable.setFunctionExtensions("min3", 1, &E_GL_AMD_shader_trinary_minmax);
7758 symbolTable.setFunctionExtensions("max3", 1, &E_GL_AMD_shader_trinary_minmax);
7759 symbolTable.setFunctionExtensions("mid3", 1, &E_GL_AMD_shader_trinary_minmax);
7762 if (profile != EEsProfile) {
7763 symbolTable.setVariableExtensions("gl_SIMDGroupSizeAMD", 1, &E_GL_AMD_gcn_shader);
7764 SpecialQualifier("gl_SIMDGroupSizeAMD", EvqVaryingIn, EbvSubGroupSize, symbolTable);
7766 symbolTable.setFunctionExtensions("cubeFaceIndexAMD", 1, &E_GL_AMD_gcn_shader);
7767 symbolTable.setFunctionExtensions("cubeFaceCoordAMD", 1, &E_GL_AMD_gcn_shader);
7768 symbolTable.setFunctionExtensions("timeAMD", 1, &E_GL_AMD_gcn_shader);
7771 if (profile != EEsProfile) {
7772 symbolTable.setFunctionExtensions("fragmentMaskFetchAMD", 1, &E_GL_AMD_shader_fragment_mask);
7773 symbolTable.setFunctionExtensions("fragmentFetchAMD", 1, &E_GL_AMD_shader_fragment_mask);
7776 symbolTable.setFunctionExtensions("countLeadingZeros", 1, &E_GL_INTEL_shader_integer_functions2);
7777 symbolTable.setFunctionExtensions("countTrailingZeros", 1, &E_GL_INTEL_shader_integer_functions2);
7778 symbolTable.setFunctionExtensions("absoluteDifference", 1, &E_GL_INTEL_shader_integer_functions2);
7779 symbolTable.setFunctionExtensions("addSaturate", 1, &E_GL_INTEL_shader_integer_functions2);
7780 symbolTable.setFunctionExtensions("subtractSaturate", 1, &E_GL_INTEL_shader_integer_functions2);
7781 symbolTable.setFunctionExtensions("average", 1, &E_GL_INTEL_shader_integer_functions2);
7782 symbolTable.setFunctionExtensions("averageRounded", 1, &E_GL_INTEL_shader_integer_functions2);
7783 symbolTable.setFunctionExtensions("multiply32x16", 1, &E_GL_INTEL_shader_integer_functions2);
7785 symbolTable.setFunctionExtensions("textureFootprintNV", 1, &E_GL_NV_shader_texture_footprint);
7786 symbolTable.setFunctionExtensions("textureFootprintClampNV", 1, &E_GL_NV_shader_texture_footprint);
7787 symbolTable.setFunctionExtensions("textureFootprintLodNV", 1, &E_GL_NV_shader_texture_footprint);
7788 symbolTable.setFunctionExtensions("textureFootprintGradNV", 1, &E_GL_NV_shader_texture_footprint);
7789 symbolTable.setFunctionExtensions("textureFootprintGradClampNV", 1, &E_GL_NV_shader_texture_footprint);
7790 // Compatibility variables, vertex only
7791 if (spvVersion.spv == 0) {
7792 BuiltInVariable("gl_Color", EbvColor, symbolTable);
7793 BuiltInVariable("gl_SecondaryColor", EbvSecondaryColor, symbolTable);
7794 BuiltInVariable("gl_Normal", EbvNormal, symbolTable);
7795 BuiltInVariable("gl_Vertex", EbvVertex, symbolTable);
7796 BuiltInVariable("gl_MultiTexCoord0", EbvMultiTexCoord0, symbolTable);
7797 BuiltInVariable("gl_MultiTexCoord1", EbvMultiTexCoord1, symbolTable);
7798 BuiltInVariable("gl_MultiTexCoord2", EbvMultiTexCoord2, symbolTable);
7799 BuiltInVariable("gl_MultiTexCoord3", EbvMultiTexCoord3, symbolTable);
7800 BuiltInVariable("gl_MultiTexCoord4", EbvMultiTexCoord4, symbolTable);
7801 BuiltInVariable("gl_MultiTexCoord5", EbvMultiTexCoord5, symbolTable);
7802 BuiltInVariable("gl_MultiTexCoord6", EbvMultiTexCoord6, symbolTable);
7803 BuiltInVariable("gl_MultiTexCoord7", EbvMultiTexCoord7, symbolTable);
7804 BuiltInVariable("gl_FogCoord", EbvFogFragCoord, symbolTable);
7807 if (profile == EEsProfile) {
7808 if (spvVersion.spv == 0) {
7809 symbolTable.setFunctionExtensions("texture2DGradEXT", 1, &E_GL_EXT_shader_texture_lod);
7810 symbolTable.setFunctionExtensions("texture2DProjGradEXT", 1, &E_GL_EXT_shader_texture_lod);
7811 symbolTable.setFunctionExtensions("textureCubeGradEXT", 1, &E_GL_EXT_shader_texture_lod);
7813 symbolTable.setFunctionExtensions("textureGatherOffsets", Num_AEP_gpu_shader5, AEP_gpu_shader5);
7816 symbolTable.setFunctionExtensions("fma", Num_AEP_gpu_shader5, AEP_gpu_shader5);
7819 if (profile == EEsProfile && version < 320) {
7820 symbolTable.setFunctionExtensions("imageAtomicAdd", 1, &E_GL_OES_shader_image_atomic);
7821 symbolTable.setFunctionExtensions("imageAtomicMin", 1, &E_GL_OES_shader_image_atomic);
7822 symbolTable.setFunctionExtensions("imageAtomicMax", 1, &E_GL_OES_shader_image_atomic);
7823 symbolTable.setFunctionExtensions("imageAtomicAnd", 1, &E_GL_OES_shader_image_atomic);
7824 symbolTable.setFunctionExtensions("imageAtomicOr", 1, &E_GL_OES_shader_image_atomic);
7825 symbolTable.setFunctionExtensions("imageAtomicXor", 1, &E_GL_OES_shader_image_atomic);
7826 symbolTable.setFunctionExtensions("imageAtomicExchange", 1, &E_GL_OES_shader_image_atomic);
7827 symbolTable.setFunctionExtensions("imageAtomicCompSwap", 1, &E_GL_OES_shader_image_atomic);
7830 if (version >= 300 /* both ES and non-ES */) {
7831 symbolTable.setVariableExtensions("gl_ViewID_OVR", Num_OVR_multiview_EXTs, OVR_multiview_EXTs);
7832 BuiltInVariable("gl_ViewID_OVR", EbvViewIndex, symbolTable);
7835 if (profile == EEsProfile) {
7836 symbolTable.setFunctionExtensions("shadow2DEXT", 1, &E_GL_EXT_shadow_samplers);
7837 symbolTable.setFunctionExtensions("shadow2DProjEXT", 1, &E_GL_EXT_shadow_samplers);
7841 case EShLangTessControl:
7842 if (profile == EEsProfile && version >= 310) {
7843 BuiltInVariable("gl_BoundingBoxEXT", EbvBoundingBox, symbolTable);
7844 symbolTable.setVariableExtensions("gl_BoundingBoxEXT", 1,
7845 &E_GL_EXT_primitive_bounding_box);
7846 BuiltInVariable("gl_BoundingBoxOES", EbvBoundingBox, symbolTable);
7847 symbolTable.setVariableExtensions("gl_BoundingBoxOES", 1,
7848 &E_GL_OES_primitive_bounding_box);
7850 if (version >= 320) {
7851 BuiltInVariable("gl_BoundingBox", EbvBoundingBox, symbolTable);
7856 case EShLangTessEvaluation:
7857 case EShLangGeometry:
7858 #endif // !GLSLANG_WEB
7859 SpecialQualifier("gl_Position", EvqPosition, EbvPosition, symbolTable);
7860 SpecialQualifier("gl_PointSize", EvqPointSize, EbvPointSize, symbolTable);
7862 BuiltInVariable("gl_in", "gl_Position", EbvPosition, symbolTable);
7863 BuiltInVariable("gl_in", "gl_PointSize", EbvPointSize, symbolTable);
7865 BuiltInVariable("gl_out", "gl_Position", EbvPosition, symbolTable);
7866 BuiltInVariable("gl_out", "gl_PointSize", EbvPointSize, symbolTable);
7869 SpecialQualifier("gl_ClipVertex", EvqClipVertex, EbvClipVertex, symbolTable);
7871 BuiltInVariable("gl_in", "gl_ClipDistance", EbvClipDistance, symbolTable);
7872 BuiltInVariable("gl_in", "gl_CullDistance", EbvCullDistance, symbolTable);
7874 BuiltInVariable("gl_out", "gl_ClipDistance", EbvClipDistance, symbolTable);
7875 BuiltInVariable("gl_out", "gl_CullDistance", EbvCullDistance, symbolTable);
7877 BuiltInVariable("gl_ClipDistance", EbvClipDistance, symbolTable);
7878 BuiltInVariable("gl_CullDistance", EbvCullDistance, symbolTable);
7879 BuiltInVariable("gl_PrimitiveIDIn", EbvPrimitiveId, symbolTable);
7880 BuiltInVariable("gl_PrimitiveID", EbvPrimitiveId, symbolTable);
7881 BuiltInVariable("gl_InvocationID", EbvInvocationId, symbolTable);
7882 BuiltInVariable("gl_Layer", EbvLayer, symbolTable);
7883 BuiltInVariable("gl_ViewportIndex", EbvViewportIndex, symbolTable);
7885 if (language != EShLangGeometry) {
7886 symbolTable.setVariableExtensions("gl_Layer", Num_viewportEXTs, viewportEXTs);
7887 symbolTable.setVariableExtensions("gl_ViewportIndex", Num_viewportEXTs, viewportEXTs);
7889 symbolTable.setVariableExtensions("gl_ViewportMask", 1, &E_GL_NV_viewport_array2);
7890 symbolTable.setVariableExtensions("gl_SecondaryPositionNV", 1, &E_GL_NV_stereo_view_rendering);
7891 symbolTable.setVariableExtensions("gl_SecondaryViewportMaskNV", 1, &E_GL_NV_stereo_view_rendering);
7892 symbolTable.setVariableExtensions("gl_PositionPerViewNV", 1, &E_GL_NVX_multiview_per_view_attributes);
7893 symbolTable.setVariableExtensions("gl_ViewportMaskPerViewNV", 1, &E_GL_NVX_multiview_per_view_attributes);
7895 BuiltInVariable("gl_ViewportMask", EbvViewportMaskNV, symbolTable);
7896 BuiltInVariable("gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable);
7897 BuiltInVariable("gl_SecondaryViewportMaskNV", EbvSecondaryViewportMaskNV, symbolTable);
7898 BuiltInVariable("gl_PositionPerViewNV", EbvPositionPerViewNV, symbolTable);
7899 BuiltInVariable("gl_ViewportMaskPerViewNV", EbvViewportMaskPerViewNV, symbolTable);
7901 if (language == EShLangVertex || language == EShLangGeometry) {
7902 symbolTable.setVariableExtensions("gl_in", "gl_SecondaryPositionNV", 1, &E_GL_NV_stereo_view_rendering);
7903 symbolTable.setVariableExtensions("gl_in", "gl_PositionPerViewNV", 1, &E_GL_NVX_multiview_per_view_attributes);
7905 BuiltInVariable("gl_in", "gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable);
7906 BuiltInVariable("gl_in", "gl_PositionPerViewNV", EbvPositionPerViewNV, symbolTable);
7908 symbolTable.setVariableExtensions("gl_out", "gl_ViewportMask", 1, &E_GL_NV_viewport_array2);
7909 symbolTable.setVariableExtensions("gl_out", "gl_SecondaryPositionNV", 1, &E_GL_NV_stereo_view_rendering);
7910 symbolTable.setVariableExtensions("gl_out", "gl_SecondaryViewportMaskNV", 1, &E_GL_NV_stereo_view_rendering);
7911 symbolTable.setVariableExtensions("gl_out", "gl_PositionPerViewNV", 1, &E_GL_NVX_multiview_per_view_attributes);
7912 symbolTable.setVariableExtensions("gl_out", "gl_ViewportMaskPerViewNV", 1, &E_GL_NVX_multiview_per_view_attributes);
7914 BuiltInVariable("gl_out", "gl_ViewportMask", EbvViewportMaskNV, symbolTable);
7915 BuiltInVariable("gl_out", "gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable);
7916 BuiltInVariable("gl_out", "gl_SecondaryViewportMaskNV", EbvSecondaryViewportMaskNV, symbolTable);
7917 BuiltInVariable("gl_out", "gl_PositionPerViewNV", EbvPositionPerViewNV, symbolTable);
7918 BuiltInVariable("gl_out", "gl_ViewportMaskPerViewNV", EbvViewportMaskPerViewNV, symbolTable);
7920 BuiltInVariable("gl_PatchVerticesIn", EbvPatchVertices, symbolTable);
7921 BuiltInVariable("gl_TessLevelOuter", EbvTessLevelOuter, symbolTable);
7922 BuiltInVariable("gl_TessLevelInner", EbvTessLevelInner, symbolTable);
7923 BuiltInVariable("gl_TessCoord", EbvTessCoord, symbolTable);
7926 symbolTable.setVariableExtensions("gl_ViewportIndex", 1, &E_GL_ARB_viewport_array);
7928 // Compatibility variables
7930 BuiltInVariable("gl_in", "gl_ClipVertex", EbvClipVertex, symbolTable);
7931 BuiltInVariable("gl_in", "gl_FrontColor", EbvFrontColor, symbolTable);
7932 BuiltInVariable("gl_in", "gl_BackColor", EbvBackColor, symbolTable);
7933 BuiltInVariable("gl_in", "gl_FrontSecondaryColor", EbvFrontSecondaryColor, symbolTable);
7934 BuiltInVariable("gl_in", "gl_BackSecondaryColor", EbvBackSecondaryColor, symbolTable);
7935 BuiltInVariable("gl_in", "gl_TexCoord", EbvTexCoord, symbolTable);
7936 BuiltInVariable("gl_in", "gl_FogFragCoord", EbvFogFragCoord, symbolTable);
7938 BuiltInVariable("gl_out", "gl_ClipVertex", EbvClipVertex, symbolTable);
7939 BuiltInVariable("gl_out", "gl_FrontColor", EbvFrontColor, symbolTable);
7940 BuiltInVariable("gl_out", "gl_BackColor", EbvBackColor, symbolTable);
7941 BuiltInVariable("gl_out", "gl_FrontSecondaryColor", EbvFrontSecondaryColor, symbolTable);
7942 BuiltInVariable("gl_out", "gl_BackSecondaryColor", EbvBackSecondaryColor, symbolTable);
7943 BuiltInVariable("gl_out", "gl_TexCoord", EbvTexCoord, symbolTable);
7944 BuiltInVariable("gl_out", "gl_FogFragCoord", EbvFogFragCoord, symbolTable);
7946 BuiltInVariable("gl_ClipVertex", EbvClipVertex, symbolTable);
7947 BuiltInVariable("gl_FrontColor", EbvFrontColor, symbolTable);
7948 BuiltInVariable("gl_BackColor", EbvBackColor, symbolTable);
7949 BuiltInVariable("gl_FrontSecondaryColor", EbvFrontSecondaryColor, symbolTable);
7950 BuiltInVariable("gl_BackSecondaryColor", EbvBackSecondaryColor, symbolTable);
7951 BuiltInVariable("gl_TexCoord", EbvTexCoord, symbolTable);
7952 BuiltInVariable("gl_FogFragCoord", EbvFogFragCoord, symbolTable);
7954 // gl_PointSize, when it needs to be tied to an extension, is always a member of a block.
7955 // (Sometimes with an instance name, sometimes anonymous).
7956 if (profile == EEsProfile) {
7957 if (language == EShLangGeometry) {
7958 symbolTable.setVariableExtensions("gl_PointSize", Num_AEP_geometry_point_size, AEP_geometry_point_size);
7959 symbolTable.setVariableExtensions("gl_in", "gl_PointSize", Num_AEP_geometry_point_size, AEP_geometry_point_size);
7960 } else if (language == EShLangTessEvaluation || language == EShLangTessControl) {
7961 // gl_in tessellation settings of gl_PointSize are in the context-dependent paths
7962 symbolTable.setVariableExtensions("gl_PointSize", Num_AEP_tessellation_point_size, AEP_tessellation_point_size);
7963 symbolTable.setVariableExtensions("gl_out", "gl_PointSize", Num_AEP_tessellation_point_size, AEP_tessellation_point_size);
7967 if ((profile != EEsProfile && version >= 140) ||
7968 (profile == EEsProfile && version >= 310)) {
7969 symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
7970 BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
7971 symbolTable.setVariableExtensions("gl_ViewIndex", 1, &E_GL_EXT_multiview);
7972 BuiltInVariable("gl_ViewIndex", EbvViewIndex, symbolTable);
7975 if (profile != EEsProfile) {
7976 BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
7977 BuiltInVariable("gl_SubGroupEqMaskARB", EbvSubGroupEqMask, symbolTable);
7978 BuiltInVariable("gl_SubGroupGeMaskARB", EbvSubGroupGeMask, symbolTable);
7979 BuiltInVariable("gl_SubGroupGtMaskARB", EbvSubGroupGtMask, symbolTable);
7980 BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
7981 BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
7983 if (spvVersion.vulkan > 0)
7984 // Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
7985 SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
7987 BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
7990 // GL_KHR_shader_subgroup
7991 if ((profile == EEsProfile && version >= 310) ||
7992 (profile != EEsProfile && version >= 140)) {
7993 symbolTable.setVariableExtensions("gl_SubgroupSize", 1, &E_GL_KHR_shader_subgroup_basic);
7994 symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
7995 symbolTable.setVariableExtensions("gl_SubgroupEqMask", 1, &E_GL_KHR_shader_subgroup_ballot);
7996 symbolTable.setVariableExtensions("gl_SubgroupGeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
7997 symbolTable.setVariableExtensions("gl_SubgroupGtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
7998 symbolTable.setVariableExtensions("gl_SubgroupLeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
7999 symbolTable.setVariableExtensions("gl_SubgroupLtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8001 BuiltInVariable("gl_SubgroupSize", EbvSubgroupSize2, symbolTable);
8002 BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
8003 BuiltInVariable("gl_SubgroupEqMask", EbvSubgroupEqMask2, symbolTable);
8004 BuiltInVariable("gl_SubgroupGeMask", EbvSubgroupGeMask2, symbolTable);
8005 BuiltInVariable("gl_SubgroupGtMask", EbvSubgroupGtMask2, symbolTable);
8006 BuiltInVariable("gl_SubgroupLeMask", EbvSubgroupLeMask2, symbolTable);
8007 BuiltInVariable("gl_SubgroupLtMask", EbvSubgroupLtMask2, symbolTable);
8009 // GL_NV_shader_sm_builtins
8010 symbolTable.setVariableExtensions("gl_WarpsPerSMNV", 1, &E_GL_NV_shader_sm_builtins);
8011 symbolTable.setVariableExtensions("gl_SMCountNV", 1, &E_GL_NV_shader_sm_builtins);
8012 symbolTable.setVariableExtensions("gl_WarpIDNV", 1, &E_GL_NV_shader_sm_builtins);
8013 symbolTable.setVariableExtensions("gl_SMIDNV", 1, &E_GL_NV_shader_sm_builtins);
8014 BuiltInVariable("gl_WarpsPerSMNV", EbvWarpsPerSM, symbolTable);
8015 BuiltInVariable("gl_SMCountNV", EbvSMCount, symbolTable);
8016 BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable);
8017 BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable);
8020 if (language == EShLangGeometry || language == EShLangVertex) {
8021 if ((profile == EEsProfile && version >= 310) ||
8022 (profile != EEsProfile && version >= 450)) {
8023 symbolTable.setVariableExtensions("gl_PrimitiveShadingRateEXT", 1, &E_GL_EXT_fragment_shading_rate);
8024 BuiltInVariable("gl_PrimitiveShadingRateEXT", EbvPrimitiveShadingRateKHR, symbolTable);
8026 symbolTable.setVariableExtensions("gl_ShadingRateFlag2VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8027 symbolTable.setVariableExtensions("gl_ShadingRateFlag4VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8028 symbolTable.setVariableExtensions("gl_ShadingRateFlag2HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8029 symbolTable.setVariableExtensions("gl_ShadingRateFlag4HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8033 #endif // !GLSLANG_WEB
8036 case EShLangFragment:
8037 SpecialQualifier("gl_FrontFacing", EvqFace, EbvFace, symbolTable);
8038 SpecialQualifier("gl_FragCoord", EvqFragCoord, EbvFragCoord, symbolTable);
8039 SpecialQualifier("gl_PointCoord", EvqPointCoord, EbvPointCoord, symbolTable);
8040 if (spvVersion.spv == 0)
8041 SpecialQualifier("gl_FragColor", EvqFragColor, EbvFragColor, symbolTable);
8043 TSymbol* symbol = symbolTable.find("gl_FragColor");
8045 symbol->getWritableType().getQualifier().storage = EvqVaryingOut;
8046 symbol->getWritableType().getQualifier().layoutLocation = 0;
8049 SpecialQualifier("gl_FragDepth", EvqFragDepth, EbvFragDepth, symbolTable);
8051 SpecialQualifier("gl_FragDepthEXT", EvqFragDepth, EbvFragDepth, symbolTable);
8052 SpecialQualifier("gl_HelperInvocation", EvqVaryingIn, EbvHelperInvocation, symbolTable);
8054 BuiltInVariable("gl_ClipDistance", EbvClipDistance, symbolTable);
8055 BuiltInVariable("gl_CullDistance", EbvCullDistance, symbolTable);
8056 BuiltInVariable("gl_PrimitiveID", EbvPrimitiveId, symbolTable);
8058 if (profile != EEsProfile && version >= 140) {
8059 symbolTable.setVariableExtensions("gl_FragStencilRefARB", 1, &E_GL_ARB_shader_stencil_export);
8060 BuiltInVariable("gl_FragStencilRefARB", EbvFragStencilRef, symbolTable);
8063 if (profile != EEsProfile && version < 400) {
8064 symbolTable.setFunctionExtensions("textureQueryLod", 1, &E_GL_ARB_texture_query_lod);
8067 if (profile != EEsProfile && version >= 460) {
8068 symbolTable.setFunctionExtensions("rayQueryInitializeEXT", 1, &E_GL_EXT_ray_query);
8069 symbolTable.setFunctionExtensions("rayQueryTerminateEXT", 1, &E_GL_EXT_ray_query);
8070 symbolTable.setFunctionExtensions("rayQueryGenerateIntersectionEXT", 1, &E_GL_EXT_ray_query);
8071 symbolTable.setFunctionExtensions("rayQueryConfirmIntersectionEXT", 1, &E_GL_EXT_ray_query);
8072 symbolTable.setFunctionExtensions("rayQueryProceedEXT", 1, &E_GL_EXT_ray_query);
8073 symbolTable.setFunctionExtensions("rayQueryGetIntersectionTypeEXT", 1, &E_GL_EXT_ray_query);
8074 symbolTable.setFunctionExtensions("rayQueryGetIntersectionTEXT", 1, &E_GL_EXT_ray_query);
8075 symbolTable.setFunctionExtensions("rayQueryGetRayFlagsEXT", 1, &E_GL_EXT_ray_query);
8076 symbolTable.setFunctionExtensions("rayQueryGetRayTMinEXT", 1, &E_GL_EXT_ray_query);
8077 symbolTable.setFunctionExtensions("rayQueryGetIntersectionInstanceCustomIndexEXT", 1, &E_GL_EXT_ray_query);
8078 symbolTable.setFunctionExtensions("rayQueryGetIntersectionInstanceIdEXT", 1, &E_GL_EXT_ray_query);
8079 symbolTable.setFunctionExtensions("rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT", 1, &E_GL_EXT_ray_query);
8080 symbolTable.setFunctionExtensions("rayQueryGetIntersectionGeometryIndexEXT", 1, &E_GL_EXT_ray_query);
8081 symbolTable.setFunctionExtensions("rayQueryGetIntersectionPrimitiveIndexEXT", 1, &E_GL_EXT_ray_query);
8082 symbolTable.setFunctionExtensions("rayQueryGetIntersectionBarycentricsEXT", 1, &E_GL_EXT_ray_query);
8083 symbolTable.setFunctionExtensions("rayQueryGetIntersectionFrontFaceEXT", 1, &E_GL_EXT_ray_query);
8084 symbolTable.setFunctionExtensions("rayQueryGetIntersectionCandidateAABBOpaqueEXT", 1, &E_GL_EXT_ray_query);
8085 symbolTable.setFunctionExtensions("rayQueryGetIntersectionObjectRayDirectionEXT", 1, &E_GL_EXT_ray_query);
8086 symbolTable.setFunctionExtensions("rayQueryGetIntersectionObjectRayOriginEXT", 1, &E_GL_EXT_ray_query);
8087 symbolTable.setFunctionExtensions("rayQueryGetIntersectionObjectToWorldEXT", 1, &E_GL_EXT_ray_query);
8088 symbolTable.setFunctionExtensions("rayQueryGetIntersectionWorldToObjectEXT", 1, &E_GL_EXT_ray_query);
8089 symbolTable.setFunctionExtensions("rayQueryGetWorldRayOriginEXT", 1, &E_GL_EXT_ray_query);
8090 symbolTable.setFunctionExtensions("rayQueryGetWorldRayDirectionEXT", 1, &E_GL_EXT_ray_query);
8091 symbolTable.setVariableExtensions("gl_RayFlagsSkipAABBEXT", 1, &E_GL_EXT_ray_flags_primitive_culling);
8092 symbolTable.setVariableExtensions("gl_RayFlagsSkipTrianglesEXT", 1, &E_GL_EXT_ray_flags_primitive_culling);
8095 if ((profile != EEsProfile && version >= 130) ||
8096 (profile == EEsProfile && version >= 310)) {
8097 BuiltInVariable("gl_SampleID", EbvSampleId, symbolTable);
8098 BuiltInVariable("gl_SamplePosition", EbvSamplePosition, symbolTable);
8099 BuiltInVariable("gl_SampleMask", EbvSampleMask, symbolTable);
8101 if (profile != EEsProfile && version < 400) {
8102 BuiltInVariable("gl_NumSamples", EbvSampleMask, symbolTable);
8104 symbolTable.setVariableExtensions("gl_SampleMask", 1, &E_GL_ARB_sample_shading);
8105 symbolTable.setVariableExtensions("gl_SampleID", 1, &E_GL_ARB_sample_shading);
8106 symbolTable.setVariableExtensions("gl_SamplePosition", 1, &E_GL_ARB_sample_shading);
8107 symbolTable.setVariableExtensions("gl_NumSamples", 1, &E_GL_ARB_sample_shading);
8109 BuiltInVariable("gl_SampleMaskIn", EbvSampleMask, symbolTable);
8111 if (profile == EEsProfile && version < 320) {
8112 symbolTable.setVariableExtensions("gl_SampleID", 1, &E_GL_OES_sample_variables);
8113 symbolTable.setVariableExtensions("gl_SamplePosition", 1, &E_GL_OES_sample_variables);
8114 symbolTable.setVariableExtensions("gl_SampleMaskIn", 1, &E_GL_OES_sample_variables);
8115 symbolTable.setVariableExtensions("gl_SampleMask", 1, &E_GL_OES_sample_variables);
8116 symbolTable.setVariableExtensions("gl_NumSamples", 1, &E_GL_OES_sample_variables);
8121 BuiltInVariable("gl_Layer", EbvLayer, symbolTable);
8122 BuiltInVariable("gl_ViewportIndex", EbvViewportIndex, symbolTable);
8124 // Compatibility variables
8126 BuiltInVariable("gl_in", "gl_FogFragCoord", EbvFogFragCoord, symbolTable);
8127 BuiltInVariable("gl_in", "gl_TexCoord", EbvTexCoord, symbolTable);
8128 BuiltInVariable("gl_in", "gl_Color", EbvColor, symbolTable);
8129 BuiltInVariable("gl_in", "gl_SecondaryColor", EbvSecondaryColor, symbolTable);
8131 BuiltInVariable("gl_FogFragCoord", EbvFogFragCoord, symbolTable);
8132 BuiltInVariable("gl_TexCoord", EbvTexCoord, symbolTable);
8133 BuiltInVariable("gl_Color", EbvColor, symbolTable);
8134 BuiltInVariable("gl_SecondaryColor", EbvSecondaryColor, symbolTable);
8136 // built-in functions
8138 if (profile == EEsProfile) {
8139 if (spvVersion.spv == 0) {
8140 symbolTable.setFunctionExtensions("texture2DLodEXT", 1, &E_GL_EXT_shader_texture_lod);
8141 symbolTable.setFunctionExtensions("texture2DProjLodEXT", 1, &E_GL_EXT_shader_texture_lod);
8142 symbolTable.setFunctionExtensions("textureCubeLodEXT", 1, &E_GL_EXT_shader_texture_lod);
8143 symbolTable.setFunctionExtensions("texture2DGradEXT", 1, &E_GL_EXT_shader_texture_lod);
8144 symbolTable.setFunctionExtensions("texture2DProjGradEXT", 1, &E_GL_EXT_shader_texture_lod);
8145 symbolTable.setFunctionExtensions("textureCubeGradEXT", 1, &E_GL_EXT_shader_texture_lod);
8147 symbolTable.setFunctionExtensions("textureGatherOffsets", Num_AEP_gpu_shader5, AEP_gpu_shader5);
8149 if (version == 100) {
8150 symbolTable.setFunctionExtensions("dFdx", 1, &E_GL_OES_standard_derivatives);
8151 symbolTable.setFunctionExtensions("dFdy", 1, &E_GL_OES_standard_derivatives);
8152 symbolTable.setFunctionExtensions("fwidth", 1, &E_GL_OES_standard_derivatives);
8154 if (version == 310) {
8155 symbolTable.setFunctionExtensions("fma", Num_AEP_gpu_shader5, AEP_gpu_shader5);
8156 symbolTable.setFunctionExtensions("interpolateAtCentroid", 1, &E_GL_OES_shader_multisample_interpolation);
8157 symbolTable.setFunctionExtensions("interpolateAtSample", 1, &E_GL_OES_shader_multisample_interpolation);
8158 symbolTable.setFunctionExtensions("interpolateAtOffset", 1, &E_GL_OES_shader_multisample_interpolation);
8160 } else if (version < 130) {
8161 if (spvVersion.spv == 0) {
8162 symbolTable.setFunctionExtensions("texture1DLod", 1, &E_GL_ARB_shader_texture_lod);
8163 symbolTable.setFunctionExtensions("texture2DLod", 1, &E_GL_ARB_shader_texture_lod);
8164 symbolTable.setFunctionExtensions("texture3DLod", 1, &E_GL_ARB_shader_texture_lod);
8165 symbolTable.setFunctionExtensions("textureCubeLod", 1, &E_GL_ARB_shader_texture_lod);
8166 symbolTable.setFunctionExtensions("texture1DProjLod", 1, &E_GL_ARB_shader_texture_lod);
8167 symbolTable.setFunctionExtensions("texture2DProjLod", 1, &E_GL_ARB_shader_texture_lod);
8168 symbolTable.setFunctionExtensions("texture3DProjLod", 1, &E_GL_ARB_shader_texture_lod);
8169 symbolTable.setFunctionExtensions("shadow1DLod", 1, &E_GL_ARB_shader_texture_lod);
8170 symbolTable.setFunctionExtensions("shadow2DLod", 1, &E_GL_ARB_shader_texture_lod);
8171 symbolTable.setFunctionExtensions("shadow1DProjLod", 1, &E_GL_ARB_shader_texture_lod);
8172 symbolTable.setFunctionExtensions("shadow2DProjLod", 1, &E_GL_ARB_shader_texture_lod);
8176 // E_GL_ARB_shader_texture_lod functions usable only with the extension enabled
8177 if (profile != EEsProfile && spvVersion.spv == 0) {
8178 symbolTable.setFunctionExtensions("texture1DGradARB", 1, &E_GL_ARB_shader_texture_lod);
8179 symbolTable.setFunctionExtensions("texture1DProjGradARB", 1, &E_GL_ARB_shader_texture_lod);
8180 symbolTable.setFunctionExtensions("texture2DGradARB", 1, &E_GL_ARB_shader_texture_lod);
8181 symbolTable.setFunctionExtensions("texture2DProjGradARB", 1, &E_GL_ARB_shader_texture_lod);
8182 symbolTable.setFunctionExtensions("texture3DGradARB", 1, &E_GL_ARB_shader_texture_lod);
8183 symbolTable.setFunctionExtensions("texture3DProjGradARB", 1, &E_GL_ARB_shader_texture_lod);
8184 symbolTable.setFunctionExtensions("textureCubeGradARB", 1, &E_GL_ARB_shader_texture_lod);
8185 symbolTable.setFunctionExtensions("shadow1DGradARB", 1, &E_GL_ARB_shader_texture_lod);
8186 symbolTable.setFunctionExtensions("shadow1DProjGradARB", 1, &E_GL_ARB_shader_texture_lod);
8187 symbolTable.setFunctionExtensions("shadow2DGradARB", 1, &E_GL_ARB_shader_texture_lod);
8188 symbolTable.setFunctionExtensions("shadow2DProjGradARB", 1, &E_GL_ARB_shader_texture_lod);
8189 symbolTable.setFunctionExtensions("texture2DRectGradARB", 1, &E_GL_ARB_shader_texture_lod);
8190 symbolTable.setFunctionExtensions("texture2DRectProjGradARB", 1, &E_GL_ARB_shader_texture_lod);
8191 symbolTable.setFunctionExtensions("shadow2DRectGradARB", 1, &E_GL_ARB_shader_texture_lod);
8192 symbolTable.setFunctionExtensions("shadow2DRectProjGradARB", 1, &E_GL_ARB_shader_texture_lod);
8195 // E_GL_ARB_shader_image_load_store
8196 if (profile != EEsProfile && version < 420)
8197 symbolTable.setFunctionExtensions("memoryBarrier", 1, &E_GL_ARB_shader_image_load_store);
8198 // All the image access functions are protected by checks on the type of the first argument.
8200 // E_GL_ARB_shader_atomic_counters
8201 if (profile != EEsProfile && version < 420) {
8202 symbolTable.setFunctionExtensions("atomicCounterIncrement", 1, &E_GL_ARB_shader_atomic_counters);
8203 symbolTable.setFunctionExtensions("atomicCounterDecrement", 1, &E_GL_ARB_shader_atomic_counters);
8204 symbolTable.setFunctionExtensions("atomicCounter" , 1, &E_GL_ARB_shader_atomic_counters);
8207 // E_GL_ARB_shader_atomic_counter_ops
8208 if (profile != EEsProfile && version == 450) {
8209 symbolTable.setFunctionExtensions("atomicCounterAddARB" , 1, &E_GL_ARB_shader_atomic_counter_ops);
8210 symbolTable.setFunctionExtensions("atomicCounterSubtractARB", 1, &E_GL_ARB_shader_atomic_counter_ops);
8211 symbolTable.setFunctionExtensions("atomicCounterMinARB" , 1, &E_GL_ARB_shader_atomic_counter_ops);
8212 symbolTable.setFunctionExtensions("atomicCounterMaxARB" , 1, &E_GL_ARB_shader_atomic_counter_ops);
8213 symbolTable.setFunctionExtensions("atomicCounterAndARB" , 1, &E_GL_ARB_shader_atomic_counter_ops);
8214 symbolTable.setFunctionExtensions("atomicCounterOrARB" , 1, &E_GL_ARB_shader_atomic_counter_ops);
8215 symbolTable.setFunctionExtensions("atomicCounterXorARB" , 1, &E_GL_ARB_shader_atomic_counter_ops);
8216 symbolTable.setFunctionExtensions("atomicCounterExchangeARB", 1, &E_GL_ARB_shader_atomic_counter_ops);
8217 symbolTable.setFunctionExtensions("atomicCounterCompSwapARB", 1, &E_GL_ARB_shader_atomic_counter_ops);
8220 // E_GL_ARB_derivative_control
8221 if (profile != EEsProfile && version < 450) {
8222 symbolTable.setFunctionExtensions("dFdxFine", 1, &E_GL_ARB_derivative_control);
8223 symbolTable.setFunctionExtensions("dFdyFine", 1, &E_GL_ARB_derivative_control);
8224 symbolTable.setFunctionExtensions("fwidthFine", 1, &E_GL_ARB_derivative_control);
8225 symbolTable.setFunctionExtensions("dFdxCoarse", 1, &E_GL_ARB_derivative_control);
8226 symbolTable.setFunctionExtensions("dFdyCoarse", 1, &E_GL_ARB_derivative_control);
8227 symbolTable.setFunctionExtensions("fwidthCoarse", 1, &E_GL_ARB_derivative_control);
8230 // E_GL_ARB_sparse_texture2
8231 if (profile != EEsProfile)
8233 symbolTable.setFunctionExtensions("sparseTextureARB", 1, &E_GL_ARB_sparse_texture2);
8234 symbolTable.setFunctionExtensions("sparseTextureLodARB", 1, &E_GL_ARB_sparse_texture2);
8235 symbolTable.setFunctionExtensions("sparseTextureOffsetARB", 1, &E_GL_ARB_sparse_texture2);
8236 symbolTable.setFunctionExtensions("sparseTexelFetchARB", 1, &E_GL_ARB_sparse_texture2);
8237 symbolTable.setFunctionExtensions("sparseTexelFetchOffsetARB", 1, &E_GL_ARB_sparse_texture2);
8238 symbolTable.setFunctionExtensions("sparseTextureLodOffsetARB", 1, &E_GL_ARB_sparse_texture2);
8239 symbolTable.setFunctionExtensions("sparseTextureGradARB", 1, &E_GL_ARB_sparse_texture2);
8240 symbolTable.setFunctionExtensions("sparseTextureGradOffsetARB", 1, &E_GL_ARB_sparse_texture2);
8241 symbolTable.setFunctionExtensions("sparseTextureGatherARB", 1, &E_GL_ARB_sparse_texture2);
8242 symbolTable.setFunctionExtensions("sparseTextureGatherOffsetARB", 1, &E_GL_ARB_sparse_texture2);
8243 symbolTable.setFunctionExtensions("sparseTextureGatherOffsetsARB", 1, &E_GL_ARB_sparse_texture2);
8244 symbolTable.setFunctionExtensions("sparseImageLoadARB", 1, &E_GL_ARB_sparse_texture2);
8245 symbolTable.setFunctionExtensions("sparseTexelsResident", 1, &E_GL_ARB_sparse_texture2);
8248 // E_GL_ARB_sparse_texture_clamp
8249 if (profile != EEsProfile)
8251 symbolTable.setFunctionExtensions("sparseTextureClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
8252 symbolTable.setFunctionExtensions("sparseTextureOffsetClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
8253 symbolTable.setFunctionExtensions("sparseTextureGradClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
8254 symbolTable.setFunctionExtensions("sparseTextureGradOffsetClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
8255 symbolTable.setFunctionExtensions("textureClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
8256 symbolTable.setFunctionExtensions("textureOffsetClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
8257 symbolTable.setFunctionExtensions("textureGradClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
8258 symbolTable.setFunctionExtensions("textureGradOffsetClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
8261 // E_GL_AMD_shader_explicit_vertex_parameter
8262 if (profile != EEsProfile) {
8263 symbolTable.setVariableExtensions("gl_BaryCoordNoPerspAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter);
8264 symbolTable.setVariableExtensions("gl_BaryCoordNoPerspCentroidAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter);
8265 symbolTable.setVariableExtensions("gl_BaryCoordNoPerspSampleAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter);
8266 symbolTable.setVariableExtensions("gl_BaryCoordSmoothAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter);
8267 symbolTable.setVariableExtensions("gl_BaryCoordSmoothCentroidAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter);
8268 symbolTable.setVariableExtensions("gl_BaryCoordSmoothSampleAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter);
8269 symbolTable.setVariableExtensions("gl_BaryCoordPullModelAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter);
8271 symbolTable.setFunctionExtensions("interpolateAtVertexAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter);
8273 BuiltInVariable("gl_BaryCoordNoPerspAMD", EbvBaryCoordNoPersp, symbolTable);
8274 BuiltInVariable("gl_BaryCoordNoPerspCentroidAMD", EbvBaryCoordNoPerspCentroid, symbolTable);
8275 BuiltInVariable("gl_BaryCoordNoPerspSampleAMD", EbvBaryCoordNoPerspSample, symbolTable);
8276 BuiltInVariable("gl_BaryCoordSmoothAMD", EbvBaryCoordSmooth, symbolTable);
8277 BuiltInVariable("gl_BaryCoordSmoothCentroidAMD", EbvBaryCoordSmoothCentroid, symbolTable);
8278 BuiltInVariable("gl_BaryCoordSmoothSampleAMD", EbvBaryCoordSmoothSample, symbolTable);
8279 BuiltInVariable("gl_BaryCoordPullModelAMD", EbvBaryCoordPullModel, symbolTable);
8282 // E_GL_AMD_texture_gather_bias_lod
8283 if (profile != EEsProfile) {
8284 symbolTable.setFunctionExtensions("textureGatherLodAMD", 1, &E_GL_AMD_texture_gather_bias_lod);
8285 symbolTable.setFunctionExtensions("textureGatherLodOffsetAMD", 1, &E_GL_AMD_texture_gather_bias_lod);
8286 symbolTable.setFunctionExtensions("textureGatherLodOffsetsAMD", 1, &E_GL_AMD_texture_gather_bias_lod);
8287 symbolTable.setFunctionExtensions("sparseTextureGatherLodAMD", 1, &E_GL_AMD_texture_gather_bias_lod);
8288 symbolTable.setFunctionExtensions("sparseTextureGatherLodOffsetAMD", 1, &E_GL_AMD_texture_gather_bias_lod);
8289 symbolTable.setFunctionExtensions("sparseTextureGatherLodOffsetsAMD", 1, &E_GL_AMD_texture_gather_bias_lod);
8292 // E_GL_AMD_shader_image_load_store_lod
8293 if (profile != EEsProfile) {
8294 symbolTable.setFunctionExtensions("imageLoadLodAMD", 1, &E_GL_AMD_shader_image_load_store_lod);
8295 symbolTable.setFunctionExtensions("imageStoreLodAMD", 1, &E_GL_AMD_shader_image_load_store_lod);
8296 symbolTable.setFunctionExtensions("sparseImageLoadLodAMD", 1, &E_GL_AMD_shader_image_load_store_lod);
8298 if (profile != EEsProfile && version >= 430) {
8299 symbolTable.setVariableExtensions("gl_FragFullyCoveredNV", 1, &E_GL_NV_conservative_raster_underestimation);
8300 BuiltInVariable("gl_FragFullyCoveredNV", EbvFragFullyCoveredNV, symbolTable);
8302 if ((profile != EEsProfile && version >= 450) ||
8303 (profile == EEsProfile && version >= 320)) {
8304 symbolTable.setVariableExtensions("gl_FragmentSizeNV", 1, &E_GL_NV_shading_rate_image);
8305 symbolTable.setVariableExtensions("gl_InvocationsPerPixelNV", 1, &E_GL_NV_shading_rate_image);
8306 BuiltInVariable("gl_FragmentSizeNV", EbvFragmentSizeNV, symbolTable);
8307 BuiltInVariable("gl_InvocationsPerPixelNV", EbvInvocationsPerPixelNV, symbolTable);
8308 symbolTable.setVariableExtensions("gl_BaryCoordNV", 1, &E_GL_NV_fragment_shader_barycentric);
8309 symbolTable.setVariableExtensions("gl_BaryCoordNoPerspNV", 1, &E_GL_NV_fragment_shader_barycentric);
8310 BuiltInVariable("gl_BaryCoordNV", EbvBaryCoordNV, symbolTable);
8311 BuiltInVariable("gl_BaryCoordNoPerspNV", EbvBaryCoordNoPerspNV, symbolTable);
8314 if ((profile != EEsProfile && version >= 450) ||
8315 (profile == EEsProfile && version >= 310)) {
8316 symbolTable.setVariableExtensions("gl_FragSizeEXT", 1, &E_GL_EXT_fragment_invocation_density);
8317 symbolTable.setVariableExtensions("gl_FragInvocationCountEXT", 1, &E_GL_EXT_fragment_invocation_density);
8318 BuiltInVariable("gl_FragSizeEXT", EbvFragSizeEXT, symbolTable);
8319 BuiltInVariable("gl_FragInvocationCountEXT", EbvFragInvocationCountEXT, symbolTable);
8322 symbolTable.setVariableExtensions("gl_FragDepthEXT", 1, &E_GL_EXT_frag_depth);
8324 symbolTable.setFunctionExtensions("clockARB", 1, &E_GL_ARB_shader_clock);
8325 symbolTable.setFunctionExtensions("clock2x32ARB", 1, &E_GL_ARB_shader_clock);
8327 if (profile == EEsProfile && version < 320) {
8328 symbolTable.setVariableExtensions("gl_PrimitiveID", Num_AEP_geometry_shader, AEP_geometry_shader);
8329 symbolTable.setVariableExtensions("gl_Layer", Num_AEP_geometry_shader, AEP_geometry_shader);
8332 if (profile == EEsProfile && version < 320) {
8333 symbolTable.setFunctionExtensions("imageAtomicAdd", 1, &E_GL_OES_shader_image_atomic);
8334 symbolTable.setFunctionExtensions("imageAtomicMin", 1, &E_GL_OES_shader_image_atomic);
8335 symbolTable.setFunctionExtensions("imageAtomicMax", 1, &E_GL_OES_shader_image_atomic);
8336 symbolTable.setFunctionExtensions("imageAtomicAnd", 1, &E_GL_OES_shader_image_atomic);
8337 symbolTable.setFunctionExtensions("imageAtomicOr", 1, &E_GL_OES_shader_image_atomic);
8338 symbolTable.setFunctionExtensions("imageAtomicXor", 1, &E_GL_OES_shader_image_atomic);
8339 symbolTable.setFunctionExtensions("imageAtomicExchange", 1, &E_GL_OES_shader_image_atomic);
8340 symbolTable.setFunctionExtensions("imageAtomicCompSwap", 1, &E_GL_OES_shader_image_atomic);
8343 if (profile != EEsProfile && version < 330 ) {
8344 symbolTable.setFunctionExtensions("floatBitsToInt", 1, &E_GL_ARB_shader_bit_encoding);
8345 symbolTable.setFunctionExtensions("floatBitsToUint", 1, &E_GL_ARB_shader_bit_encoding);
8346 symbolTable.setFunctionExtensions("intBitsToFloat", 1, &E_GL_ARB_shader_bit_encoding);
8347 symbolTable.setFunctionExtensions("uintBitsToFloat", 1, &E_GL_ARB_shader_bit_encoding);
8350 if (profile != EEsProfile && version < 430 ) {
8351 symbolTable.setFunctionExtensions("imageSize", 1, &E_GL_ARB_shader_image_size);
8354 // GL_ARB_shader_storage_buffer_object
8355 if (profile != EEsProfile && version < 430 ) {
8356 symbolTable.setFunctionExtensions("atomicAdd", 1, &E_GL_ARB_shader_storage_buffer_object);
8357 symbolTable.setFunctionExtensions("atomicMin", 1, &E_GL_ARB_shader_storage_buffer_object);
8358 symbolTable.setFunctionExtensions("atomicMax", 1, &E_GL_ARB_shader_storage_buffer_object);
8359 symbolTable.setFunctionExtensions("atomicAnd", 1, &E_GL_ARB_shader_storage_buffer_object);
8360 symbolTable.setFunctionExtensions("atomicOr", 1, &E_GL_ARB_shader_storage_buffer_object);
8361 symbolTable.setFunctionExtensions("atomicXor", 1, &E_GL_ARB_shader_storage_buffer_object);
8362 symbolTable.setFunctionExtensions("atomicExchange", 1, &E_GL_ARB_shader_storage_buffer_object);
8363 symbolTable.setFunctionExtensions("atomicCompSwap", 1, &E_GL_ARB_shader_storage_buffer_object);
8366 // GL_ARB_shading_language_packing
8367 if (profile != EEsProfile && version < 400 ) {
8368 symbolTable.setFunctionExtensions("packUnorm2x16", 1, &E_GL_ARB_shading_language_packing);
8369 symbolTable.setFunctionExtensions("unpackUnorm2x16", 1, &E_GL_ARB_shading_language_packing);
8370 symbolTable.setFunctionExtensions("packSnorm4x8", 1, &E_GL_ARB_shading_language_packing);
8371 symbolTable.setFunctionExtensions("packUnorm4x8", 1, &E_GL_ARB_shading_language_packing);
8372 symbolTable.setFunctionExtensions("unpackSnorm4x8", 1, &E_GL_ARB_shading_language_packing);
8373 symbolTable.setFunctionExtensions("unpackUnorm4x8", 1, &E_GL_ARB_shading_language_packing);
8375 if (profile != EEsProfile && version < 420 ) {
8376 symbolTable.setFunctionExtensions("packSnorm2x16", 1, &E_GL_ARB_shading_language_packing);
8377 symbolTable.setFunctionExtensions("unpackSnorm2x16", 1, &E_GL_ARB_shading_language_packing);
8378 symbolTable.setFunctionExtensions("unpackHalf2x16", 1, &E_GL_ARB_shading_language_packing);
8379 symbolTable.setFunctionExtensions("packHalf2x16", 1, &E_GL_ARB_shading_language_packing);
8382 symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
8383 BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
8384 symbolTable.setVariableExtensions("gl_ViewIndex", 1, &E_GL_EXT_multiview);
8385 BuiltInVariable("gl_ViewIndex", EbvViewIndex, symbolTable);
8386 if (version >= 300 /* both ES and non-ES */) {
8387 symbolTable.setVariableExtensions("gl_ViewID_OVR", Num_OVR_multiview_EXTs, OVR_multiview_EXTs);
8388 BuiltInVariable("gl_ViewID_OVR", EbvViewIndex, symbolTable);
8391 // GL_ARB_shader_ballot
8392 if (profile != EEsProfile) {
8393 symbolTable.setVariableExtensions("gl_SubGroupSizeARB", 1, &E_GL_ARB_shader_ballot);
8394 symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
8395 symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB", 1, &E_GL_ARB_shader_ballot);
8396 symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB", 1, &E_GL_ARB_shader_ballot);
8397 symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB", 1, &E_GL_ARB_shader_ballot);
8398 symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB", 1, &E_GL_ARB_shader_ballot);
8399 symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB", 1, &E_GL_ARB_shader_ballot);
8401 BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
8402 BuiltInVariable("gl_SubGroupEqMaskARB", EbvSubGroupEqMask, symbolTable);
8403 BuiltInVariable("gl_SubGroupGeMaskARB", EbvSubGroupGeMask, symbolTable);
8404 BuiltInVariable("gl_SubGroupGtMaskARB", EbvSubGroupGtMask, symbolTable);
8405 BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
8406 BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
8408 if (spvVersion.vulkan > 0)
8409 // Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
8410 SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
8412 BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
8415 // GL_KHR_shader_subgroup
8416 if ((profile == EEsProfile && version >= 310) ||
8417 (profile != EEsProfile && version >= 140)) {
8418 symbolTable.setVariableExtensions("gl_SubgroupSize", 1, &E_GL_KHR_shader_subgroup_basic);
8419 symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
8420 symbolTable.setVariableExtensions("gl_SubgroupEqMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8421 symbolTable.setVariableExtensions("gl_SubgroupGeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8422 symbolTable.setVariableExtensions("gl_SubgroupGtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8423 symbolTable.setVariableExtensions("gl_SubgroupLeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8424 symbolTable.setVariableExtensions("gl_SubgroupLtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8426 BuiltInVariable("gl_SubgroupSize", EbvSubgroupSize2, symbolTable);
8427 BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
8428 BuiltInVariable("gl_SubgroupEqMask", EbvSubgroupEqMask2, symbolTable);
8429 BuiltInVariable("gl_SubgroupGeMask", EbvSubgroupGeMask2, symbolTable);
8430 BuiltInVariable("gl_SubgroupGtMask", EbvSubgroupGtMask2, symbolTable);
8431 BuiltInVariable("gl_SubgroupLeMask", EbvSubgroupLeMask2, symbolTable);
8432 BuiltInVariable("gl_SubgroupLtMask", EbvSubgroupLtMask2, symbolTable);
8434 symbolTable.setFunctionExtensions("subgroupBarrier", 1, &E_GL_KHR_shader_subgroup_basic);
8435 symbolTable.setFunctionExtensions("subgroupMemoryBarrier", 1, &E_GL_KHR_shader_subgroup_basic);
8436 symbolTable.setFunctionExtensions("subgroupMemoryBarrierBuffer", 1, &E_GL_KHR_shader_subgroup_basic);
8437 symbolTable.setFunctionExtensions("subgroupMemoryBarrierImage", 1, &E_GL_KHR_shader_subgroup_basic);
8438 symbolTable.setFunctionExtensions("subgroupElect", 1, &E_GL_KHR_shader_subgroup_basic);
8439 symbolTable.setFunctionExtensions("subgroupAll", 1, &E_GL_KHR_shader_subgroup_vote);
8440 symbolTable.setFunctionExtensions("subgroupAny", 1, &E_GL_KHR_shader_subgroup_vote);
8441 symbolTable.setFunctionExtensions("subgroupAllEqual", 1, &E_GL_KHR_shader_subgroup_vote);
8442 symbolTable.setFunctionExtensions("subgroupBroadcast", 1, &E_GL_KHR_shader_subgroup_ballot);
8443 symbolTable.setFunctionExtensions("subgroupBroadcastFirst", 1, &E_GL_KHR_shader_subgroup_ballot);
8444 symbolTable.setFunctionExtensions("subgroupBallot", 1, &E_GL_KHR_shader_subgroup_ballot);
8445 symbolTable.setFunctionExtensions("subgroupInverseBallot", 1, &E_GL_KHR_shader_subgroup_ballot);
8446 symbolTable.setFunctionExtensions("subgroupBallotBitExtract", 1, &E_GL_KHR_shader_subgroup_ballot);
8447 symbolTable.setFunctionExtensions("subgroupBallotBitCount", 1, &E_GL_KHR_shader_subgroup_ballot);
8448 symbolTable.setFunctionExtensions("subgroupBallotInclusiveBitCount", 1, &E_GL_KHR_shader_subgroup_ballot);
8449 symbolTable.setFunctionExtensions("subgroupBallotExclusiveBitCount", 1, &E_GL_KHR_shader_subgroup_ballot);
8450 symbolTable.setFunctionExtensions("subgroupBallotFindLSB", 1, &E_GL_KHR_shader_subgroup_ballot);
8451 symbolTable.setFunctionExtensions("subgroupBallotFindMSB", 1, &E_GL_KHR_shader_subgroup_ballot);
8452 symbolTable.setFunctionExtensions("subgroupShuffle", 1, &E_GL_KHR_shader_subgroup_shuffle);
8453 symbolTable.setFunctionExtensions("subgroupShuffleXor", 1, &E_GL_KHR_shader_subgroup_shuffle);
8454 symbolTable.setFunctionExtensions("subgroupShuffleUp", 1, &E_GL_KHR_shader_subgroup_shuffle_relative);
8455 symbolTable.setFunctionExtensions("subgroupShuffleDown", 1, &E_GL_KHR_shader_subgroup_shuffle_relative);
8456 symbolTable.setFunctionExtensions("subgroupAdd", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8457 symbolTable.setFunctionExtensions("subgroupMul", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8458 symbolTable.setFunctionExtensions("subgroupMin", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8459 symbolTable.setFunctionExtensions("subgroupMax", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8460 symbolTable.setFunctionExtensions("subgroupAnd", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8461 symbolTable.setFunctionExtensions("subgroupOr", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8462 symbolTable.setFunctionExtensions("subgroupXor", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8463 symbolTable.setFunctionExtensions("subgroupInclusiveAdd", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8464 symbolTable.setFunctionExtensions("subgroupInclusiveMul", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8465 symbolTable.setFunctionExtensions("subgroupInclusiveMin", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8466 symbolTable.setFunctionExtensions("subgroupInclusiveMax", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8467 symbolTable.setFunctionExtensions("subgroupInclusiveAnd", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8468 symbolTable.setFunctionExtensions("subgroupInclusiveOr", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8469 symbolTable.setFunctionExtensions("subgroupInclusiveXor", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8470 symbolTable.setFunctionExtensions("subgroupExclusiveAdd", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8471 symbolTable.setFunctionExtensions("subgroupExclusiveMul", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8472 symbolTable.setFunctionExtensions("subgroupExclusiveMin", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8473 symbolTable.setFunctionExtensions("subgroupExclusiveMax", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8474 symbolTable.setFunctionExtensions("subgroupExclusiveAnd", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8475 symbolTable.setFunctionExtensions("subgroupExclusiveOr", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8476 symbolTable.setFunctionExtensions("subgroupExclusiveXor", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8477 symbolTable.setFunctionExtensions("subgroupClusteredAdd", 1, &E_GL_KHR_shader_subgroup_clustered);
8478 symbolTable.setFunctionExtensions("subgroupClusteredMul", 1, &E_GL_KHR_shader_subgroup_clustered);
8479 symbolTable.setFunctionExtensions("subgroupClusteredMin", 1, &E_GL_KHR_shader_subgroup_clustered);
8480 symbolTable.setFunctionExtensions("subgroupClusteredMax", 1, &E_GL_KHR_shader_subgroup_clustered);
8481 symbolTable.setFunctionExtensions("subgroupClusteredAnd", 1, &E_GL_KHR_shader_subgroup_clustered);
8482 symbolTable.setFunctionExtensions("subgroupClusteredOr", 1, &E_GL_KHR_shader_subgroup_clustered);
8483 symbolTable.setFunctionExtensions("subgroupClusteredXor", 1, &E_GL_KHR_shader_subgroup_clustered);
8484 symbolTable.setFunctionExtensions("subgroupQuadBroadcast", 1, &E_GL_KHR_shader_subgroup_quad);
8485 symbolTable.setFunctionExtensions("subgroupQuadSwapHorizontal", 1, &E_GL_KHR_shader_subgroup_quad);
8486 symbolTable.setFunctionExtensions("subgroupQuadSwapVertical", 1, &E_GL_KHR_shader_subgroup_quad);
8487 symbolTable.setFunctionExtensions("subgroupQuadSwapDiagonal", 1, &E_GL_KHR_shader_subgroup_quad);
8488 symbolTable.setFunctionExtensions("subgroupPartitionNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8489 symbolTable.setFunctionExtensions("subgroupPartitionedAddNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8490 symbolTable.setFunctionExtensions("subgroupPartitionedMulNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8491 symbolTable.setFunctionExtensions("subgroupPartitionedMinNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8492 symbolTable.setFunctionExtensions("subgroupPartitionedMaxNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8493 symbolTable.setFunctionExtensions("subgroupPartitionedAndNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8494 symbolTable.setFunctionExtensions("subgroupPartitionedOrNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8495 symbolTable.setFunctionExtensions("subgroupPartitionedXorNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8496 symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveAddNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8497 symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveMulNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8498 symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveMinNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8499 symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveMaxNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8500 symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveAndNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8501 symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveOrNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8502 symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveXorNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8503 symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveAddNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8504 symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveMulNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8505 symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveMinNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8506 symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveMaxNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8507 symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveAndNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8508 symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveOrNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8509 symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveXorNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8511 // GL_NV_shader_sm_builtins
8512 symbolTable.setVariableExtensions("gl_WarpsPerSMNV", 1, &E_GL_NV_shader_sm_builtins);
8513 symbolTable.setVariableExtensions("gl_SMCountNV", 1, &E_GL_NV_shader_sm_builtins);
8514 symbolTable.setVariableExtensions("gl_WarpIDNV", 1, &E_GL_NV_shader_sm_builtins);
8515 symbolTable.setVariableExtensions("gl_SMIDNV", 1, &E_GL_NV_shader_sm_builtins);
8516 BuiltInVariable("gl_WarpsPerSMNV", EbvWarpsPerSM, symbolTable);
8517 BuiltInVariable("gl_SMCountNV", EbvSMCount, symbolTable);
8518 BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable);
8519 BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable);
8522 if (profile == EEsProfile) {
8523 symbolTable.setFunctionExtensions("shadow2DEXT", 1, &E_GL_EXT_shadow_samplers);
8524 symbolTable.setFunctionExtensions("shadow2DProjEXT", 1, &E_GL_EXT_shadow_samplers);
8527 if (spvVersion.vulkan > 0) {
8528 symbolTable.setVariableExtensions("gl_ScopeDevice", 1, &E_GL_KHR_memory_scope_semantics);
8529 symbolTable.setVariableExtensions("gl_ScopeWorkgroup", 1, &E_GL_KHR_memory_scope_semantics);
8530 symbolTable.setVariableExtensions("gl_ScopeSubgroup", 1, &E_GL_KHR_memory_scope_semantics);
8531 symbolTable.setVariableExtensions("gl_ScopeInvocation", 1, &E_GL_KHR_memory_scope_semantics);
8533 symbolTable.setVariableExtensions("gl_SemanticsRelaxed", 1, &E_GL_KHR_memory_scope_semantics);
8534 symbolTable.setVariableExtensions("gl_SemanticsAcquire", 1, &E_GL_KHR_memory_scope_semantics);
8535 symbolTable.setVariableExtensions("gl_SemanticsRelease", 1, &E_GL_KHR_memory_scope_semantics);
8536 symbolTable.setVariableExtensions("gl_SemanticsAcquireRelease", 1, &E_GL_KHR_memory_scope_semantics);
8537 symbolTable.setVariableExtensions("gl_SemanticsMakeAvailable", 1, &E_GL_KHR_memory_scope_semantics);
8538 symbolTable.setVariableExtensions("gl_SemanticsMakeVisible", 1, &E_GL_KHR_memory_scope_semantics);
8539 symbolTable.setVariableExtensions("gl_SemanticsVolatile", 1, &E_GL_KHR_memory_scope_semantics);
8541 symbolTable.setVariableExtensions("gl_StorageSemanticsNone", 1, &E_GL_KHR_memory_scope_semantics);
8542 symbolTable.setVariableExtensions("gl_StorageSemanticsBuffer", 1, &E_GL_KHR_memory_scope_semantics);
8543 symbolTable.setVariableExtensions("gl_StorageSemanticsShared", 1, &E_GL_KHR_memory_scope_semantics);
8544 symbolTable.setVariableExtensions("gl_StorageSemanticsImage", 1, &E_GL_KHR_memory_scope_semantics);
8545 symbolTable.setVariableExtensions("gl_StorageSemanticsOutput", 1, &E_GL_KHR_memory_scope_semantics);
8548 symbolTable.setFunctionExtensions("helperInvocationEXT", 1, &E_GL_EXT_demote_to_helper_invocation);
8550 if ((profile == EEsProfile && version >= 310) ||
8551 (profile != EEsProfile && version >= 450)) {
8552 symbolTable.setVariableExtensions("gl_ShadingRateEXT", 1, &E_GL_EXT_fragment_shading_rate);
8553 BuiltInVariable("gl_ShadingRateEXT", EbvShadingRateKHR, symbolTable);
8555 symbolTable.setVariableExtensions("gl_ShadingRateFlag2VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8556 symbolTable.setVariableExtensions("gl_ShadingRateFlag4VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8557 symbolTable.setVariableExtensions("gl_ShadingRateFlag2HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8558 symbolTable.setVariableExtensions("gl_ShadingRateFlag4HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8560 #endif // !GLSLANG_WEB
8563 case EShLangCompute:
8564 BuiltInVariable("gl_NumWorkGroups", EbvNumWorkGroups, symbolTable);
8565 BuiltInVariable("gl_WorkGroupSize", EbvWorkGroupSize, symbolTable);
8566 BuiltInVariable("gl_WorkGroupID", EbvWorkGroupId, symbolTable);
8567 BuiltInVariable("gl_LocalInvocationID", EbvLocalInvocationId, symbolTable);
8568 BuiltInVariable("gl_GlobalInvocationID", EbvGlobalInvocationId, symbolTable);
8569 BuiltInVariable("gl_LocalInvocationIndex", EbvLocalInvocationIndex, symbolTable);
8570 BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
8571 BuiltInVariable("gl_ViewIndex", EbvViewIndex, symbolTable);
8574 if ((profile != EEsProfile && version >= 140) ||
8575 (profile == EEsProfile && version >= 310)) {
8576 symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
8577 symbolTable.setVariableExtensions("gl_ViewIndex", 1, &E_GL_EXT_multiview);
8580 if (profile != EEsProfile && version < 430) {
8581 symbolTable.setVariableExtensions("gl_NumWorkGroups", 1, &E_GL_ARB_compute_shader);
8582 symbolTable.setVariableExtensions("gl_WorkGroupSize", 1, &E_GL_ARB_compute_shader);
8583 symbolTable.setVariableExtensions("gl_WorkGroupID", 1, &E_GL_ARB_compute_shader);
8584 symbolTable.setVariableExtensions("gl_LocalInvocationID", 1, &E_GL_ARB_compute_shader);
8585 symbolTable.setVariableExtensions("gl_GlobalInvocationID", 1, &E_GL_ARB_compute_shader);
8586 symbolTable.setVariableExtensions("gl_LocalInvocationIndex", 1, &E_GL_ARB_compute_shader);
8588 symbolTable.setVariableExtensions("gl_MaxComputeWorkGroupCount", 1, &E_GL_ARB_compute_shader);
8589 symbolTable.setVariableExtensions("gl_MaxComputeWorkGroupSize", 1, &E_GL_ARB_compute_shader);
8590 symbolTable.setVariableExtensions("gl_MaxComputeUniformComponents", 1, &E_GL_ARB_compute_shader);
8591 symbolTable.setVariableExtensions("gl_MaxComputeTextureImageUnits", 1, &E_GL_ARB_compute_shader);
8592 symbolTable.setVariableExtensions("gl_MaxComputeImageUniforms", 1, &E_GL_ARB_compute_shader);
8593 symbolTable.setVariableExtensions("gl_MaxComputeAtomicCounters", 1, &E_GL_ARB_compute_shader);
8594 symbolTable.setVariableExtensions("gl_MaxComputeAtomicCounterBuffers", 1, &E_GL_ARB_compute_shader);
8596 symbolTable.setFunctionExtensions("barrier", 1, &E_GL_ARB_compute_shader);
8597 symbolTable.setFunctionExtensions("memoryBarrierAtomicCounter", 1, &E_GL_ARB_compute_shader);
8598 symbolTable.setFunctionExtensions("memoryBarrierBuffer", 1, &E_GL_ARB_compute_shader);
8599 symbolTable.setFunctionExtensions("memoryBarrierImage", 1, &E_GL_ARB_compute_shader);
8600 symbolTable.setFunctionExtensions("memoryBarrierShared", 1, &E_GL_ARB_compute_shader);
8601 symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_ARB_compute_shader);
8605 symbolTable.setFunctionExtensions("controlBarrier", 1, &E_GL_KHR_memory_scope_semantics);
8606 symbolTable.setFunctionExtensions("debugPrintfEXT", 1, &E_GL_EXT_debug_printf);
8608 // GL_ARB_shader_ballot
8609 if (profile != EEsProfile) {
8610 symbolTable.setVariableExtensions("gl_SubGroupSizeARB", 1, &E_GL_ARB_shader_ballot);
8611 symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
8612 symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB", 1, &E_GL_ARB_shader_ballot);
8613 symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB", 1, &E_GL_ARB_shader_ballot);
8614 symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB", 1, &E_GL_ARB_shader_ballot);
8615 symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB", 1, &E_GL_ARB_shader_ballot);
8616 symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB", 1, &E_GL_ARB_shader_ballot);
8618 BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
8619 BuiltInVariable("gl_SubGroupEqMaskARB", EbvSubGroupEqMask, symbolTable);
8620 BuiltInVariable("gl_SubGroupGeMaskARB", EbvSubGroupGeMask, symbolTable);
8621 BuiltInVariable("gl_SubGroupGtMaskARB", EbvSubGroupGtMask, symbolTable);
8622 BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
8623 BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
8625 if (spvVersion.vulkan > 0)
8626 // Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
8627 SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
8629 BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
8632 // GL_KHR_shader_subgroup
8633 if ((profile == EEsProfile && version >= 310) ||
8634 (profile != EEsProfile && version >= 140)) {
8635 symbolTable.setVariableExtensions("gl_SubgroupSize", 1, &E_GL_KHR_shader_subgroup_basic);
8636 symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
8637 symbolTable.setVariableExtensions("gl_SubgroupEqMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8638 symbolTable.setVariableExtensions("gl_SubgroupGeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8639 symbolTable.setVariableExtensions("gl_SubgroupGtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8640 symbolTable.setVariableExtensions("gl_SubgroupLeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8641 symbolTable.setVariableExtensions("gl_SubgroupLtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8643 BuiltInVariable("gl_SubgroupSize", EbvSubgroupSize2, symbolTable);
8644 BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
8645 BuiltInVariable("gl_SubgroupEqMask", EbvSubgroupEqMask2, symbolTable);
8646 BuiltInVariable("gl_SubgroupGeMask", EbvSubgroupGeMask2, symbolTable);
8647 BuiltInVariable("gl_SubgroupGtMask", EbvSubgroupGtMask2, symbolTable);
8648 BuiltInVariable("gl_SubgroupLeMask", EbvSubgroupLeMask2, symbolTable);
8649 BuiltInVariable("gl_SubgroupLtMask", EbvSubgroupLtMask2, symbolTable);
8651 // GL_NV_shader_sm_builtins
8652 symbolTable.setVariableExtensions("gl_WarpsPerSMNV", 1, &E_GL_NV_shader_sm_builtins);
8653 symbolTable.setVariableExtensions("gl_SMCountNV", 1, &E_GL_NV_shader_sm_builtins);
8654 symbolTable.setVariableExtensions("gl_WarpIDNV", 1, &E_GL_NV_shader_sm_builtins);
8655 symbolTable.setVariableExtensions("gl_SMIDNV", 1, &E_GL_NV_shader_sm_builtins);
8656 BuiltInVariable("gl_WarpsPerSMNV", EbvWarpsPerSM, symbolTable);
8657 BuiltInVariable("gl_SMCountNV", EbvSMCount, symbolTable);
8658 BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable);
8659 BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable);
8662 // GL_KHR_shader_subgroup
8663 if ((profile == EEsProfile && version >= 310) ||
8664 (profile != EEsProfile && version >= 140)) {
8665 symbolTable.setVariableExtensions("gl_NumSubgroups", 1, &E_GL_KHR_shader_subgroup_basic);
8666 symbolTable.setVariableExtensions("gl_SubgroupID", 1, &E_GL_KHR_shader_subgroup_basic);
8668 BuiltInVariable("gl_NumSubgroups", EbvNumSubgroups, symbolTable);
8669 BuiltInVariable("gl_SubgroupID", EbvSubgroupID, symbolTable);
8671 symbolTable.setFunctionExtensions("subgroupMemoryBarrierShared", 1, &E_GL_KHR_shader_subgroup_basic);
8675 const char *coopExt[2] = { E_GL_NV_cooperative_matrix, E_GL_NV_integer_cooperative_matrix };
8676 symbolTable.setFunctionExtensions("coopMatLoadNV", 2, coopExt);
8677 symbolTable.setFunctionExtensions("coopMatStoreNV", 2, coopExt);
8678 symbolTable.setFunctionExtensions("coopMatMulAddNV", 2, coopExt);
8681 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
8682 symbolTable.setFunctionExtensions("dFdx", 1, &E_GL_NV_compute_shader_derivatives);
8683 symbolTable.setFunctionExtensions("dFdy", 1, &E_GL_NV_compute_shader_derivatives);
8684 symbolTable.setFunctionExtensions("fwidth", 1, &E_GL_NV_compute_shader_derivatives);
8685 symbolTable.setFunctionExtensions("dFdxFine", 1, &E_GL_NV_compute_shader_derivatives);
8686 symbolTable.setFunctionExtensions("dFdyFine", 1, &E_GL_NV_compute_shader_derivatives);
8687 symbolTable.setFunctionExtensions("fwidthFine", 1, &E_GL_NV_compute_shader_derivatives);
8688 symbolTable.setFunctionExtensions("dFdxCoarse", 1, &E_GL_NV_compute_shader_derivatives);
8689 symbolTable.setFunctionExtensions("dFdyCoarse", 1, &E_GL_NV_compute_shader_derivatives);
8690 symbolTable.setFunctionExtensions("fwidthCoarse", 1, &E_GL_NV_compute_shader_derivatives);
8693 if ((profile == EEsProfile && version >= 310) ||
8694 (profile != EEsProfile && version >= 450)) {
8695 symbolTable.setVariableExtensions("gl_ShadingRateFlag2VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8696 symbolTable.setVariableExtensions("gl_ShadingRateFlag4VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8697 symbolTable.setVariableExtensions("gl_ShadingRateFlag2HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8698 symbolTable.setVariableExtensions("gl_ShadingRateFlag4HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8700 #endif // !GLSLANG_WEB
8703 #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
8705 case EShLangIntersect:
8707 case EShLangClosestHit:
8709 case EShLangCallable:
8710 if (profile != EEsProfile && version >= 460) {
8711 const char *rtexts[] = { E_GL_NV_ray_tracing, E_GL_EXT_ray_tracing };
8712 symbolTable.setVariableExtensions("gl_LaunchIDNV", 1, &E_GL_NV_ray_tracing);
8713 symbolTable.setVariableExtensions("gl_LaunchIDEXT", 1, &E_GL_EXT_ray_tracing);
8714 symbolTable.setVariableExtensions("gl_LaunchSizeNV", 1, &E_GL_NV_ray_tracing);
8715 symbolTable.setVariableExtensions("gl_LaunchSizeEXT", 1, &E_GL_EXT_ray_tracing);
8716 symbolTable.setVariableExtensions("gl_PrimitiveID", 2, rtexts);
8717 symbolTable.setVariableExtensions("gl_InstanceID", 2, rtexts);
8718 symbolTable.setVariableExtensions("gl_InstanceCustomIndexNV", 1, &E_GL_NV_ray_tracing);
8719 symbolTable.setVariableExtensions("gl_InstanceCustomIndexEXT", 1, &E_GL_EXT_ray_tracing);
8720 symbolTable.setVariableExtensions("gl_GeometryIndexEXT", 1, &E_GL_EXT_ray_tracing);
8721 symbolTable.setVariableExtensions("gl_WorldRayOriginNV", 1, &E_GL_NV_ray_tracing);
8722 symbolTable.setVariableExtensions("gl_WorldRayOriginEXT", 1, &E_GL_EXT_ray_tracing);
8723 symbolTable.setVariableExtensions("gl_WorldRayDirectionNV", 1, &E_GL_NV_ray_tracing);
8724 symbolTable.setVariableExtensions("gl_WorldRayDirectionEXT", 1, &E_GL_EXT_ray_tracing);
8725 symbolTable.setVariableExtensions("gl_ObjectRayOriginNV", 1, &E_GL_NV_ray_tracing);
8726 symbolTable.setVariableExtensions("gl_ObjectRayOriginEXT", 1, &E_GL_EXT_ray_tracing);
8727 symbolTable.setVariableExtensions("gl_ObjectRayDirectionNV", 1, &E_GL_NV_ray_tracing);
8728 symbolTable.setVariableExtensions("gl_ObjectRayDirectionEXT", 1, &E_GL_EXT_ray_tracing);
8729 symbolTable.setVariableExtensions("gl_RayTminNV", 1, &E_GL_NV_ray_tracing);
8730 symbolTable.setVariableExtensions("gl_RayTminEXT", 1, &E_GL_EXT_ray_tracing);
8731 symbolTable.setVariableExtensions("gl_RayTmaxNV", 1, &E_GL_NV_ray_tracing);
8732 symbolTable.setVariableExtensions("gl_RayTmaxEXT", 1, &E_GL_EXT_ray_tracing);
8733 symbolTable.setVariableExtensions("gl_HitTNV", 1, &E_GL_NV_ray_tracing);
8734 symbolTable.setVariableExtensions("gl_HitTEXT", 1, &E_GL_EXT_ray_tracing);
8735 symbolTable.setVariableExtensions("gl_HitKindNV", 1, &E_GL_NV_ray_tracing);
8736 symbolTable.setVariableExtensions("gl_HitKindEXT", 1, &E_GL_EXT_ray_tracing);
8737 symbolTable.setVariableExtensions("gl_ObjectToWorldNV", 1, &E_GL_NV_ray_tracing);
8738 symbolTable.setVariableExtensions("gl_ObjectToWorldEXT", 1, &E_GL_EXT_ray_tracing);
8739 symbolTable.setVariableExtensions("gl_ObjectToWorld3x4EXT", 1, &E_GL_EXT_ray_tracing);
8740 symbolTable.setVariableExtensions("gl_WorldToObjectNV", 1, &E_GL_NV_ray_tracing);
8741 symbolTable.setVariableExtensions("gl_WorldToObjectEXT", 1, &E_GL_EXT_ray_tracing);
8742 symbolTable.setVariableExtensions("gl_WorldToObject3x4EXT", 1, &E_GL_EXT_ray_tracing);
8743 symbolTable.setVariableExtensions("gl_IncomingRayFlagsNV", 1, &E_GL_NV_ray_tracing);
8744 symbolTable.setVariableExtensions("gl_IncomingRayFlagsEXT", 1, &E_GL_EXT_ray_tracing);
8745 symbolTable.setVariableExtensions("gl_CurrentRayTimeNV", 1, &E_GL_NV_ray_tracing_motion_blur);
8747 symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
8750 symbolTable.setFunctionExtensions("traceNV", 1, &E_GL_NV_ray_tracing);
8751 symbolTable.setFunctionExtensions("traceRayMotionNV", 1, &E_GL_NV_ray_tracing_motion_blur);
8752 symbolTable.setFunctionExtensions("traceRayEXT", 1, &E_GL_EXT_ray_tracing);
8753 symbolTable.setFunctionExtensions("reportIntersectionNV", 1, &E_GL_NV_ray_tracing);
8754 symbolTable.setFunctionExtensions("reportIntersectionEXT", 1, &E_GL_EXT_ray_tracing);
8755 symbolTable.setFunctionExtensions("ignoreIntersectionNV", 1, &E_GL_NV_ray_tracing);
8756 symbolTable.setFunctionExtensions("terminateRayNV", 1, &E_GL_NV_ray_tracing);
8757 symbolTable.setFunctionExtensions("executeCallableNV", 1, &E_GL_NV_ray_tracing);
8758 symbolTable.setFunctionExtensions("executeCallableEXT", 1, &E_GL_EXT_ray_tracing);
8761 BuiltInVariable("gl_LaunchIDNV", EbvLaunchId, symbolTable);
8762 BuiltInVariable("gl_LaunchIDEXT", EbvLaunchId, symbolTable);
8763 BuiltInVariable("gl_LaunchSizeNV", EbvLaunchSize, symbolTable);
8764 BuiltInVariable("gl_LaunchSizeEXT", EbvLaunchSize, symbolTable);
8765 BuiltInVariable("gl_PrimitiveID", EbvPrimitiveId, symbolTable);
8766 BuiltInVariable("gl_InstanceID", EbvInstanceId, symbolTable);
8767 BuiltInVariable("gl_InstanceCustomIndexNV", EbvInstanceCustomIndex,symbolTable);
8768 BuiltInVariable("gl_InstanceCustomIndexEXT", EbvInstanceCustomIndex,symbolTable);
8769 BuiltInVariable("gl_GeometryIndexEXT", EbvGeometryIndex, symbolTable);
8770 BuiltInVariable("gl_WorldRayOriginNV", EbvWorldRayOrigin, symbolTable);
8771 BuiltInVariable("gl_WorldRayOriginEXT", EbvWorldRayOrigin, symbolTable);
8772 BuiltInVariable("gl_WorldRayDirectionNV", EbvWorldRayDirection, symbolTable);
8773 BuiltInVariable("gl_WorldRayDirectionEXT", EbvWorldRayDirection, symbolTable);
8774 BuiltInVariable("gl_ObjectRayOriginNV", EbvObjectRayOrigin, symbolTable);
8775 BuiltInVariable("gl_ObjectRayOriginEXT", EbvObjectRayOrigin, symbolTable);
8776 BuiltInVariable("gl_ObjectRayDirectionNV", EbvObjectRayDirection, symbolTable);
8777 BuiltInVariable("gl_ObjectRayDirectionEXT", EbvObjectRayDirection, symbolTable);
8778 BuiltInVariable("gl_RayTminNV", EbvRayTmin, symbolTable);
8779 BuiltInVariable("gl_RayTminEXT", EbvRayTmin, symbolTable);
8780 BuiltInVariable("gl_RayTmaxNV", EbvRayTmax, symbolTable);
8781 BuiltInVariable("gl_RayTmaxEXT", EbvRayTmax, symbolTable);
8782 BuiltInVariable("gl_HitTNV", EbvHitT, symbolTable);
8783 BuiltInVariable("gl_HitTEXT", EbvHitT, symbolTable);
8784 BuiltInVariable("gl_HitKindNV", EbvHitKind, symbolTable);
8785 BuiltInVariable("gl_HitKindEXT", EbvHitKind, symbolTable);
8786 BuiltInVariable("gl_ObjectToWorldNV", EbvObjectToWorld, symbolTable);
8787 BuiltInVariable("gl_ObjectToWorldEXT", EbvObjectToWorld, symbolTable);
8788 BuiltInVariable("gl_ObjectToWorld3x4EXT", EbvObjectToWorld3x4, symbolTable);
8789 BuiltInVariable("gl_WorldToObjectNV", EbvWorldToObject, symbolTable);
8790 BuiltInVariable("gl_WorldToObjectEXT", EbvWorldToObject, symbolTable);
8791 BuiltInVariable("gl_WorldToObject3x4EXT", EbvWorldToObject3x4, symbolTable);
8792 BuiltInVariable("gl_IncomingRayFlagsNV", EbvIncomingRayFlags, symbolTable);
8793 BuiltInVariable("gl_IncomingRayFlagsEXT", EbvIncomingRayFlags, symbolTable);
8794 BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
8795 BuiltInVariable("gl_CurrentRayTimeNV", EbvCurrentRayTimeNV, symbolTable);
8797 // GL_ARB_shader_ballot
8798 symbolTable.setVariableExtensions("gl_SubGroupSizeARB", 1, &E_GL_ARB_shader_ballot);
8799 symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
8800 symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB", 1, &E_GL_ARB_shader_ballot);
8801 symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB", 1, &E_GL_ARB_shader_ballot);
8802 symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB", 1, &E_GL_ARB_shader_ballot);
8803 symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB", 1, &E_GL_ARB_shader_ballot);
8804 symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB", 1, &E_GL_ARB_shader_ballot);
8806 BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
8807 BuiltInVariable("gl_SubGroupEqMaskARB", EbvSubGroupEqMask, symbolTable);
8808 BuiltInVariable("gl_SubGroupGeMaskARB", EbvSubGroupGeMask, symbolTable);
8809 BuiltInVariable("gl_SubGroupGtMaskARB", EbvSubGroupGtMask, symbolTable);
8810 BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
8811 BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
8813 if (spvVersion.vulkan > 0)
8814 // Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
8815 SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
8817 BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
8819 // GL_KHR_shader_subgroup
8820 symbolTable.setVariableExtensions("gl_NumSubgroups", 1, &E_GL_KHR_shader_subgroup_basic);
8821 symbolTable.setVariableExtensions("gl_SubgroupID", 1, &E_GL_KHR_shader_subgroup_basic);
8822 symbolTable.setVariableExtensions("gl_SubgroupSize", 1, &E_GL_KHR_shader_subgroup_basic);
8823 symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
8824 symbolTable.setVariableExtensions("gl_SubgroupEqMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8825 symbolTable.setVariableExtensions("gl_SubgroupGeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8826 symbolTable.setVariableExtensions("gl_SubgroupGtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8827 symbolTable.setVariableExtensions("gl_SubgroupLeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8828 symbolTable.setVariableExtensions("gl_SubgroupLtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8830 BuiltInVariable("gl_NumSubgroups", EbvNumSubgroups, symbolTable);
8831 BuiltInVariable("gl_SubgroupID", EbvSubgroupID, symbolTable);
8832 BuiltInVariable("gl_SubgroupSize", EbvSubgroupSize2, symbolTable);
8833 BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
8834 BuiltInVariable("gl_SubgroupEqMask", EbvSubgroupEqMask2, symbolTable);
8835 BuiltInVariable("gl_SubgroupGeMask", EbvSubgroupGeMask2, symbolTable);
8836 BuiltInVariable("gl_SubgroupGtMask", EbvSubgroupGtMask2, symbolTable);
8837 BuiltInVariable("gl_SubgroupLeMask", EbvSubgroupLeMask2, symbolTable);
8838 BuiltInVariable("gl_SubgroupLtMask", EbvSubgroupLtMask2, symbolTable);
8840 // GL_NV_shader_sm_builtins
8841 symbolTable.setVariableExtensions("gl_WarpsPerSMNV", 1, &E_GL_NV_shader_sm_builtins);
8842 symbolTable.setVariableExtensions("gl_SMCountNV", 1, &E_GL_NV_shader_sm_builtins);
8843 symbolTable.setVariableExtensions("gl_WarpIDNV", 1, &E_GL_NV_shader_sm_builtins);
8844 symbolTable.setVariableExtensions("gl_SMIDNV", 1, &E_GL_NV_shader_sm_builtins);
8845 BuiltInVariable("gl_WarpsPerSMNV", EbvWarpsPerSM, symbolTable);
8846 BuiltInVariable("gl_SMCountNV", EbvSMCount, symbolTable);
8847 BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable);
8848 BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable);
8850 if ((profile == EEsProfile && version >= 310) ||
8851 (profile != EEsProfile && version >= 450)) {
8852 symbolTable.setVariableExtensions("gl_ShadingRateFlag2VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8853 symbolTable.setVariableExtensions("gl_ShadingRateFlag4VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8854 symbolTable.setVariableExtensions("gl_ShadingRateFlag2HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8855 symbolTable.setVariableExtensions("gl_ShadingRateFlag4HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8860 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
8861 // per-vertex builtins
8862 symbolTable.setVariableExtensions("gl_MeshVerticesNV", "gl_Position", 1, &E_GL_NV_mesh_shader);
8863 symbolTable.setVariableExtensions("gl_MeshVerticesNV", "gl_PointSize", 1, &E_GL_NV_mesh_shader);
8864 symbolTable.setVariableExtensions("gl_MeshVerticesNV", "gl_ClipDistance", 1, &E_GL_NV_mesh_shader);
8865 symbolTable.setVariableExtensions("gl_MeshVerticesNV", "gl_CullDistance", 1, &E_GL_NV_mesh_shader);
8867 BuiltInVariable("gl_MeshVerticesNV", "gl_Position", EbvPosition, symbolTable);
8868 BuiltInVariable("gl_MeshVerticesNV", "gl_PointSize", EbvPointSize, symbolTable);
8869 BuiltInVariable("gl_MeshVerticesNV", "gl_ClipDistance", EbvClipDistance, symbolTable);
8870 BuiltInVariable("gl_MeshVerticesNV", "gl_CullDistance", EbvCullDistance, symbolTable);
8872 symbolTable.setVariableExtensions("gl_MeshVerticesNV", "gl_PositionPerViewNV", 1, &E_GL_NV_mesh_shader);
8873 symbolTable.setVariableExtensions("gl_MeshVerticesNV", "gl_ClipDistancePerViewNV", 1, &E_GL_NV_mesh_shader);
8874 symbolTable.setVariableExtensions("gl_MeshVerticesNV", "gl_CullDistancePerViewNV", 1, &E_GL_NV_mesh_shader);
8876 BuiltInVariable("gl_MeshVerticesNV", "gl_PositionPerViewNV", EbvPositionPerViewNV, symbolTable);
8877 BuiltInVariable("gl_MeshVerticesNV", "gl_ClipDistancePerViewNV", EbvClipDistancePerViewNV, symbolTable);
8878 BuiltInVariable("gl_MeshVerticesNV", "gl_CullDistancePerViewNV", EbvCullDistancePerViewNV, symbolTable);
8880 // per-primitive builtins
8881 symbolTable.setVariableExtensions("gl_MeshPrimitivesNV", "gl_PrimitiveID", 1, &E_GL_NV_mesh_shader);
8882 symbolTable.setVariableExtensions("gl_MeshPrimitivesNV", "gl_Layer", 1, &E_GL_NV_mesh_shader);
8883 symbolTable.setVariableExtensions("gl_MeshPrimitivesNV", "gl_ViewportIndex", 1, &E_GL_NV_mesh_shader);
8884 symbolTable.setVariableExtensions("gl_MeshPrimitivesNV", "gl_ViewportMask", 1, &E_GL_NV_mesh_shader);
8886 BuiltInVariable("gl_MeshPrimitivesNV", "gl_PrimitiveID", EbvPrimitiveId, symbolTable);
8887 BuiltInVariable("gl_MeshPrimitivesNV", "gl_Layer", EbvLayer, symbolTable);
8888 BuiltInVariable("gl_MeshPrimitivesNV", "gl_ViewportIndex", EbvViewportIndex, symbolTable);
8889 BuiltInVariable("gl_MeshPrimitivesNV", "gl_ViewportMask", EbvViewportMaskNV, symbolTable);
8891 // per-view per-primitive builtins
8892 symbolTable.setVariableExtensions("gl_MeshPrimitivesNV", "gl_LayerPerViewNV", 1, &E_GL_NV_mesh_shader);
8893 symbolTable.setVariableExtensions("gl_MeshPrimitivesNV", "gl_ViewportMaskPerViewNV", 1, &E_GL_NV_mesh_shader);
8895 BuiltInVariable("gl_MeshPrimitivesNV", "gl_LayerPerViewNV", EbvLayerPerViewNV, symbolTable);
8896 BuiltInVariable("gl_MeshPrimitivesNV", "gl_ViewportMaskPerViewNV", EbvViewportMaskPerViewNV, symbolTable);
8899 symbolTable.setVariableExtensions("gl_PrimitiveCountNV", 1, &E_GL_NV_mesh_shader);
8900 symbolTable.setVariableExtensions("gl_PrimitiveIndicesNV", 1, &E_GL_NV_mesh_shader);
8901 symbolTable.setVariableExtensions("gl_MeshViewCountNV", 1, &E_GL_NV_mesh_shader);
8902 symbolTable.setVariableExtensions("gl_MeshViewIndicesNV", 1, &E_GL_NV_mesh_shader);
8903 symbolTable.setVariableExtensions("gl_WorkGroupSize", 1, &E_GL_NV_mesh_shader);
8904 symbolTable.setVariableExtensions("gl_WorkGroupID", 1, &E_GL_NV_mesh_shader);
8905 symbolTable.setVariableExtensions("gl_LocalInvocationID", 1, &E_GL_NV_mesh_shader);
8906 symbolTable.setVariableExtensions("gl_GlobalInvocationID", 1, &E_GL_NV_mesh_shader);
8907 symbolTable.setVariableExtensions("gl_LocalInvocationIndex", 1, &E_GL_NV_mesh_shader);
8909 BuiltInVariable("gl_PrimitiveCountNV", EbvPrimitiveCountNV, symbolTable);
8910 BuiltInVariable("gl_PrimitiveIndicesNV", EbvPrimitiveIndicesNV, symbolTable);
8911 BuiltInVariable("gl_MeshViewCountNV", EbvMeshViewCountNV, symbolTable);
8912 BuiltInVariable("gl_MeshViewIndicesNV", EbvMeshViewIndicesNV, symbolTable);
8913 BuiltInVariable("gl_WorkGroupSize", EbvWorkGroupSize, symbolTable);
8914 BuiltInVariable("gl_WorkGroupID", EbvWorkGroupId, symbolTable);
8915 BuiltInVariable("gl_LocalInvocationID", EbvLocalInvocationId, symbolTable);
8916 BuiltInVariable("gl_GlobalInvocationID", EbvGlobalInvocationId, symbolTable);
8917 BuiltInVariable("gl_LocalInvocationIndex", EbvLocalInvocationIndex, symbolTable);
8919 // builtin constants
8920 symbolTable.setVariableExtensions("gl_MaxMeshOutputVerticesNV", 1, &E_GL_NV_mesh_shader);
8921 symbolTable.setVariableExtensions("gl_MaxMeshOutputPrimitivesNV", 1, &E_GL_NV_mesh_shader);
8922 symbolTable.setVariableExtensions("gl_MaxMeshWorkGroupSizeNV", 1, &E_GL_NV_mesh_shader);
8923 symbolTable.setVariableExtensions("gl_MaxMeshViewCountNV", 1, &E_GL_NV_mesh_shader);
8925 // builtin functions
8926 symbolTable.setFunctionExtensions("barrier", 1, &E_GL_NV_mesh_shader);
8927 symbolTable.setFunctionExtensions("memoryBarrierShared", 1, &E_GL_NV_mesh_shader);
8928 symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_NV_mesh_shader);
8931 if (profile != EEsProfile && version >= 450) {
8932 // GL_EXT_device_group
8933 symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
8934 BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
8936 // GL_ARB_shader_draw_parameters
8937 symbolTable.setVariableExtensions("gl_DrawIDARB", 1, &E_GL_ARB_shader_draw_parameters);
8938 BuiltInVariable("gl_DrawIDARB", EbvDrawId, symbolTable);
8939 if (version >= 460) {
8940 BuiltInVariable("gl_DrawID", EbvDrawId, symbolTable);
8943 // GL_ARB_shader_ballot
8944 symbolTable.setVariableExtensions("gl_SubGroupSizeARB", 1, &E_GL_ARB_shader_ballot);
8945 symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
8946 symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB", 1, &E_GL_ARB_shader_ballot);
8947 symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB", 1, &E_GL_ARB_shader_ballot);
8948 symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB", 1, &E_GL_ARB_shader_ballot);
8949 symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB", 1, &E_GL_ARB_shader_ballot);
8950 symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB", 1, &E_GL_ARB_shader_ballot);
8952 BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
8953 BuiltInVariable("gl_SubGroupEqMaskARB", EbvSubGroupEqMask, symbolTable);
8954 BuiltInVariable("gl_SubGroupGeMaskARB", EbvSubGroupGeMask, symbolTable);
8955 BuiltInVariable("gl_SubGroupGtMaskARB", EbvSubGroupGtMask, symbolTable);
8956 BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
8957 BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
8959 if (spvVersion.vulkan > 0)
8960 // Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
8961 SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
8963 BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
8966 // GL_KHR_shader_subgroup
8967 if ((profile == EEsProfile && version >= 310) ||
8968 (profile != EEsProfile && version >= 140)) {
8969 symbolTable.setVariableExtensions("gl_NumSubgroups", 1, &E_GL_KHR_shader_subgroup_basic);
8970 symbolTable.setVariableExtensions("gl_SubgroupID", 1, &E_GL_KHR_shader_subgroup_basic);
8971 symbolTable.setVariableExtensions("gl_SubgroupSize", 1, &E_GL_KHR_shader_subgroup_basic);
8972 symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
8973 symbolTable.setVariableExtensions("gl_SubgroupEqMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8974 symbolTable.setVariableExtensions("gl_SubgroupGeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8975 symbolTable.setVariableExtensions("gl_SubgroupGtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8976 symbolTable.setVariableExtensions("gl_SubgroupLeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8977 symbolTable.setVariableExtensions("gl_SubgroupLtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8979 BuiltInVariable("gl_NumSubgroups", EbvNumSubgroups, symbolTable);
8980 BuiltInVariable("gl_SubgroupID", EbvSubgroupID, symbolTable);
8981 BuiltInVariable("gl_SubgroupSize", EbvSubgroupSize2, symbolTable);
8982 BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
8983 BuiltInVariable("gl_SubgroupEqMask", EbvSubgroupEqMask2, symbolTable);
8984 BuiltInVariable("gl_SubgroupGeMask", EbvSubgroupGeMask2, symbolTable);
8985 BuiltInVariable("gl_SubgroupGtMask", EbvSubgroupGtMask2, symbolTable);
8986 BuiltInVariable("gl_SubgroupLeMask", EbvSubgroupLeMask2, symbolTable);
8987 BuiltInVariable("gl_SubgroupLtMask", EbvSubgroupLtMask2, symbolTable);
8989 symbolTable.setFunctionExtensions("subgroupMemoryBarrierShared", 1, &E_GL_KHR_shader_subgroup_basic);
8991 // GL_NV_shader_sm_builtins
8992 symbolTable.setVariableExtensions("gl_WarpsPerSMNV", 1, &E_GL_NV_shader_sm_builtins);
8993 symbolTable.setVariableExtensions("gl_SMCountNV", 1, &E_GL_NV_shader_sm_builtins);
8994 symbolTable.setVariableExtensions("gl_WarpIDNV", 1, &E_GL_NV_shader_sm_builtins);
8995 symbolTable.setVariableExtensions("gl_SMIDNV", 1, &E_GL_NV_shader_sm_builtins);
8996 BuiltInVariable("gl_WarpsPerSMNV", EbvWarpsPerSM, symbolTable);
8997 BuiltInVariable("gl_SMCountNV", EbvSMCount, symbolTable);
8998 BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable);
8999 BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable);
9002 if ((profile == EEsProfile && version >= 310) ||
9003 (profile != EEsProfile && version >= 450)) {
9004 symbolTable.setVariableExtensions("gl_ShadingRateFlag2VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9005 symbolTable.setVariableExtensions("gl_ShadingRateFlag4VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9006 symbolTable.setVariableExtensions("gl_ShadingRateFlag2HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9007 symbolTable.setVariableExtensions("gl_ShadingRateFlag4HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9012 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
9013 symbolTable.setVariableExtensions("gl_TaskCountNV", 1, &E_GL_NV_mesh_shader);
9014 symbolTable.setVariableExtensions("gl_WorkGroupSize", 1, &E_GL_NV_mesh_shader);
9015 symbolTable.setVariableExtensions("gl_WorkGroupID", 1, &E_GL_NV_mesh_shader);
9016 symbolTable.setVariableExtensions("gl_LocalInvocationID", 1, &E_GL_NV_mesh_shader);
9017 symbolTable.setVariableExtensions("gl_GlobalInvocationID", 1, &E_GL_NV_mesh_shader);
9018 symbolTable.setVariableExtensions("gl_LocalInvocationIndex", 1, &E_GL_NV_mesh_shader);
9019 symbolTable.setVariableExtensions("gl_MeshViewCountNV", 1, &E_GL_NV_mesh_shader);
9020 symbolTable.setVariableExtensions("gl_MeshViewIndicesNV", 1, &E_GL_NV_mesh_shader);
9022 BuiltInVariable("gl_TaskCountNV", EbvTaskCountNV, symbolTable);
9023 BuiltInVariable("gl_WorkGroupSize", EbvWorkGroupSize, symbolTable);
9024 BuiltInVariable("gl_WorkGroupID", EbvWorkGroupId, symbolTable);
9025 BuiltInVariable("gl_LocalInvocationID", EbvLocalInvocationId, symbolTable);
9026 BuiltInVariable("gl_GlobalInvocationID", EbvGlobalInvocationId, symbolTable);
9027 BuiltInVariable("gl_LocalInvocationIndex", EbvLocalInvocationIndex, symbolTable);
9028 BuiltInVariable("gl_MeshViewCountNV", EbvMeshViewCountNV, symbolTable);
9029 BuiltInVariable("gl_MeshViewIndicesNV", EbvMeshViewIndicesNV, symbolTable);
9031 symbolTable.setVariableExtensions("gl_MaxTaskWorkGroupSizeNV", 1, &E_GL_NV_mesh_shader);
9032 symbolTable.setVariableExtensions("gl_MaxMeshViewCountNV", 1, &E_GL_NV_mesh_shader);
9034 symbolTable.setFunctionExtensions("barrier", 1, &E_GL_NV_mesh_shader);
9035 symbolTable.setFunctionExtensions("memoryBarrierShared", 1, &E_GL_NV_mesh_shader);
9036 symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_NV_mesh_shader);
9039 if (profile != EEsProfile && version >= 450) {
9040 // GL_EXT_device_group
9041 symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
9042 BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
9044 // GL_ARB_shader_draw_parameters
9045 symbolTable.setVariableExtensions("gl_DrawIDARB", 1, &E_GL_ARB_shader_draw_parameters);
9046 BuiltInVariable("gl_DrawIDARB", EbvDrawId, symbolTable);
9047 if (version >= 460) {
9048 BuiltInVariable("gl_DrawID", EbvDrawId, symbolTable);
9051 // GL_ARB_shader_ballot
9052 symbolTable.setVariableExtensions("gl_SubGroupSizeARB", 1, &E_GL_ARB_shader_ballot);
9053 symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
9054 symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB", 1, &E_GL_ARB_shader_ballot);
9055 symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB", 1, &E_GL_ARB_shader_ballot);
9056 symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB", 1, &E_GL_ARB_shader_ballot);
9057 symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB", 1, &E_GL_ARB_shader_ballot);
9058 symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB", 1, &E_GL_ARB_shader_ballot);
9060 BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
9061 BuiltInVariable("gl_SubGroupEqMaskARB", EbvSubGroupEqMask, symbolTable);
9062 BuiltInVariable("gl_SubGroupGeMaskARB", EbvSubGroupGeMask, symbolTable);
9063 BuiltInVariable("gl_SubGroupGtMaskARB", EbvSubGroupGtMask, symbolTable);
9064 BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
9065 BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
9067 if (spvVersion.vulkan > 0)
9068 // Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
9069 SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
9071 BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
9074 // GL_KHR_shader_subgroup
9075 if ((profile == EEsProfile && version >= 310) ||
9076 (profile != EEsProfile && version >= 140)) {
9077 symbolTable.setVariableExtensions("gl_NumSubgroups", 1, &E_GL_KHR_shader_subgroup_basic);
9078 symbolTable.setVariableExtensions("gl_SubgroupID", 1, &E_GL_KHR_shader_subgroup_basic);
9079 symbolTable.setVariableExtensions("gl_SubgroupSize", 1, &E_GL_KHR_shader_subgroup_basic);
9080 symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
9081 symbolTable.setVariableExtensions("gl_SubgroupEqMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9082 symbolTable.setVariableExtensions("gl_SubgroupGeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9083 symbolTable.setVariableExtensions("gl_SubgroupGtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9084 symbolTable.setVariableExtensions("gl_SubgroupLeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9085 symbolTable.setVariableExtensions("gl_SubgroupLtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9087 BuiltInVariable("gl_NumSubgroups", EbvNumSubgroups, symbolTable);
9088 BuiltInVariable("gl_SubgroupID", EbvSubgroupID, symbolTable);
9089 BuiltInVariable("gl_SubgroupSize", EbvSubgroupSize2, symbolTable);
9090 BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
9091 BuiltInVariable("gl_SubgroupEqMask", EbvSubgroupEqMask2, symbolTable);
9092 BuiltInVariable("gl_SubgroupGeMask", EbvSubgroupGeMask2, symbolTable);
9093 BuiltInVariable("gl_SubgroupGtMask", EbvSubgroupGtMask2, symbolTable);
9094 BuiltInVariable("gl_SubgroupLeMask", EbvSubgroupLeMask2, symbolTable);
9095 BuiltInVariable("gl_SubgroupLtMask", EbvSubgroupLtMask2, symbolTable);
9097 symbolTable.setFunctionExtensions("subgroupMemoryBarrierShared", 1, &E_GL_KHR_shader_subgroup_basic);
9099 // GL_NV_shader_sm_builtins
9100 symbolTable.setVariableExtensions("gl_WarpsPerSMNV", 1, &E_GL_NV_shader_sm_builtins);
9101 symbolTable.setVariableExtensions("gl_SMCountNV", 1, &E_GL_NV_shader_sm_builtins);
9102 symbolTable.setVariableExtensions("gl_WarpIDNV", 1, &E_GL_NV_shader_sm_builtins);
9103 symbolTable.setVariableExtensions("gl_SMIDNV", 1, &E_GL_NV_shader_sm_builtins);
9104 BuiltInVariable("gl_WarpsPerSMNV", EbvWarpsPerSM, symbolTable);
9105 BuiltInVariable("gl_SMCountNV", EbvSMCount, symbolTable);
9106 BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable);
9107 BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable);
9109 if ((profile == EEsProfile && version >= 310) ||
9110 (profile != EEsProfile && version >= 450)) {
9111 symbolTable.setVariableExtensions("gl_ShadingRateFlag2VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9112 symbolTable.setVariableExtensions("gl_ShadingRateFlag4VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9113 symbolTable.setVariableExtensions("gl_ShadingRateFlag2HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9114 symbolTable.setVariableExtensions("gl_ShadingRateFlag4HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9120 assert(false && "Language not supported");
9125 // Next, identify which built-ins have a mapping to an operator.
9126 // If PureOperatorBuiltins is false, those that are not identified as such are
9127 // expected to be resolved through a library of functions, versus as
9131 relateTabledBuiltins(version, profile, spvVersion, language, symbolTable);
9134 symbolTable.relateToOperator("doubleBitsToInt64", EOpDoubleBitsToInt64);
9135 symbolTable.relateToOperator("doubleBitsToUint64", EOpDoubleBitsToUint64);
9136 symbolTable.relateToOperator("int64BitsToDouble", EOpInt64BitsToDouble);
9137 symbolTable.relateToOperator("uint64BitsToDouble", EOpUint64BitsToDouble);
9138 symbolTable.relateToOperator("halfBitsToInt16", EOpFloat16BitsToInt16);
9139 symbolTable.relateToOperator("halfBitsToUint16", EOpFloat16BitsToUint16);
9140 symbolTable.relateToOperator("float16BitsToInt16", EOpFloat16BitsToInt16);
9141 symbolTable.relateToOperator("float16BitsToUint16", EOpFloat16BitsToUint16);
9142 symbolTable.relateToOperator("int16BitsToFloat16", EOpInt16BitsToFloat16);
9143 symbolTable.relateToOperator("uint16BitsToFloat16", EOpUint16BitsToFloat16);
9145 symbolTable.relateToOperator("int16BitsToHalf", EOpInt16BitsToFloat16);
9146 symbolTable.relateToOperator("uint16BitsToHalf", EOpUint16BitsToFloat16);
9148 symbolTable.relateToOperator("packSnorm4x8", EOpPackSnorm4x8);
9149 symbolTable.relateToOperator("unpackSnorm4x8", EOpUnpackSnorm4x8);
9150 symbolTable.relateToOperator("packUnorm4x8", EOpPackUnorm4x8);
9151 symbolTable.relateToOperator("unpackUnorm4x8", EOpUnpackUnorm4x8);
9153 symbolTable.relateToOperator("packDouble2x32", EOpPackDouble2x32);
9154 symbolTable.relateToOperator("unpackDouble2x32", EOpUnpackDouble2x32);
9156 symbolTable.relateToOperator("packInt2x32", EOpPackInt2x32);
9157 symbolTable.relateToOperator("unpackInt2x32", EOpUnpackInt2x32);
9158 symbolTable.relateToOperator("packUint2x32", EOpPackUint2x32);
9159 symbolTable.relateToOperator("unpackUint2x32", EOpUnpackUint2x32);
9161 symbolTable.relateToOperator("packInt2x16", EOpPackInt2x16);
9162 symbolTable.relateToOperator("unpackInt2x16", EOpUnpackInt2x16);
9163 symbolTable.relateToOperator("packUint2x16", EOpPackUint2x16);
9164 symbolTable.relateToOperator("unpackUint2x16", EOpUnpackUint2x16);
9166 symbolTable.relateToOperator("packInt4x16", EOpPackInt4x16);
9167 symbolTable.relateToOperator("unpackInt4x16", EOpUnpackInt4x16);
9168 symbolTable.relateToOperator("packUint4x16", EOpPackUint4x16);
9169 symbolTable.relateToOperator("unpackUint4x16", EOpUnpackUint4x16);
9170 symbolTable.relateToOperator("packFloat2x16", EOpPackFloat2x16);
9171 symbolTable.relateToOperator("unpackFloat2x16", EOpUnpackFloat2x16);
9173 symbolTable.relateToOperator("pack16", EOpPack16);
9174 symbolTable.relateToOperator("pack32", EOpPack32);
9175 symbolTable.relateToOperator("pack64", EOpPack64);
9177 symbolTable.relateToOperator("unpack32", EOpUnpack32);
9178 symbolTable.relateToOperator("unpack16", EOpUnpack16);
9179 symbolTable.relateToOperator("unpack8", EOpUnpack8);
9181 symbolTable.relateToOperator("controlBarrier", EOpBarrier);
9182 symbolTable.relateToOperator("memoryBarrierAtomicCounter", EOpMemoryBarrierAtomicCounter);
9183 symbolTable.relateToOperator("memoryBarrierImage", EOpMemoryBarrierImage);
9185 if (spvVersion.vulkanRelaxed) {
9187 // functions signature have been replaced to take uint operations on buffer variables
9188 // remap atomic counter functions to atomic operations
9190 symbolTable.relateToOperator("memoryBarrierAtomicCounter", EOpMemoryBarrierBuffer);
9193 symbolTable.relateToOperator("atomicLoad", EOpAtomicLoad);
9194 symbolTable.relateToOperator("atomicStore", EOpAtomicStore);
9196 symbolTable.relateToOperator("atomicCounterIncrement", EOpAtomicCounterIncrement);
9197 symbolTable.relateToOperator("atomicCounterDecrement", EOpAtomicCounterDecrement);
9198 symbolTable.relateToOperator("atomicCounter", EOpAtomicCounter);
9200 if (spvVersion.vulkanRelaxed) {
9202 // functions signature have been replaced to take uint operations
9203 // remap atomic counter functions to atomic operations
9205 // these atomic counter functions do not match signatures of glsl
9206 // atomic functions, so they will be remapped to semantically
9207 // equivalent functions in the parser
9209 symbolTable.relateToOperator("atomicCounterIncrement", EOpNull);
9210 symbolTable.relateToOperator("atomicCounterDecrement", EOpNull);
9211 symbolTable.relateToOperator("atomicCounter", EOpNull);
9214 symbolTable.relateToOperator("clockARB", EOpReadClockSubgroupKHR);
9215 symbolTable.relateToOperator("clock2x32ARB", EOpReadClockSubgroupKHR);
9217 symbolTable.relateToOperator("clockRealtimeEXT", EOpReadClockDeviceKHR);
9218 symbolTable.relateToOperator("clockRealtime2x32EXT", EOpReadClockDeviceKHR);
9220 if (profile != EEsProfile && version == 450) {
9221 symbolTable.relateToOperator("atomicCounterAddARB", EOpAtomicCounterAdd);
9222 symbolTable.relateToOperator("atomicCounterSubtractARB", EOpAtomicCounterSubtract);
9223 symbolTable.relateToOperator("atomicCounterMinARB", EOpAtomicCounterMin);
9224 symbolTable.relateToOperator("atomicCounterMaxARB", EOpAtomicCounterMax);
9225 symbolTable.relateToOperator("atomicCounterAndARB", EOpAtomicCounterAnd);
9226 symbolTable.relateToOperator("atomicCounterOrARB", EOpAtomicCounterOr);
9227 symbolTable.relateToOperator("atomicCounterXorARB", EOpAtomicCounterXor);
9228 symbolTable.relateToOperator("atomicCounterExchangeARB", EOpAtomicCounterExchange);
9229 symbolTable.relateToOperator("atomicCounterCompSwapARB", EOpAtomicCounterCompSwap);
9232 if (profile != EEsProfile && version >= 460) {
9233 symbolTable.relateToOperator("atomicCounterAdd", EOpAtomicCounterAdd);
9234 symbolTable.relateToOperator("atomicCounterSubtract", EOpAtomicCounterSubtract);
9235 symbolTable.relateToOperator("atomicCounterMin", EOpAtomicCounterMin);
9236 symbolTable.relateToOperator("atomicCounterMax", EOpAtomicCounterMax);
9237 symbolTable.relateToOperator("atomicCounterAnd", EOpAtomicCounterAnd);
9238 symbolTable.relateToOperator("atomicCounterOr", EOpAtomicCounterOr);
9239 symbolTable.relateToOperator("atomicCounterXor", EOpAtomicCounterXor);
9240 symbolTable.relateToOperator("atomicCounterExchange", EOpAtomicCounterExchange);
9241 symbolTable.relateToOperator("atomicCounterCompSwap", EOpAtomicCounterCompSwap);
9244 if (spvVersion.vulkanRelaxed) {
9246 // functions signature have been replaced to take 'uint' instead of 'atomic_uint'
9247 // remap atomic counter functions to non-counter atomic ops so
9248 // functions act as aliases to non-counter atomic ops
9250 symbolTable.relateToOperator("atomicCounterAdd", EOpAtomicAdd);
9251 symbolTable.relateToOperator("atomicCounterSubtract", EOpAtomicSubtract);
9252 symbolTable.relateToOperator("atomicCounterMin", EOpAtomicMin);
9253 symbolTable.relateToOperator("atomicCounterMax", EOpAtomicMax);
9254 symbolTable.relateToOperator("atomicCounterAnd", EOpAtomicAnd);
9255 symbolTable.relateToOperator("atomicCounterOr", EOpAtomicOr);
9256 symbolTable.relateToOperator("atomicCounterXor", EOpAtomicXor);
9257 symbolTable.relateToOperator("atomicCounterExchange", EOpAtomicExchange);
9258 symbolTable.relateToOperator("atomicCounterCompSwap", EOpAtomicCompSwap);
9261 symbolTable.relateToOperator("fma", EOpFma);
9262 symbolTable.relateToOperator("frexp", EOpFrexp);
9263 symbolTable.relateToOperator("ldexp", EOpLdexp);
9264 symbolTable.relateToOperator("uaddCarry", EOpAddCarry);
9265 symbolTable.relateToOperator("usubBorrow", EOpSubBorrow);
9266 symbolTable.relateToOperator("umulExtended", EOpUMulExtended);
9267 symbolTable.relateToOperator("imulExtended", EOpIMulExtended);
9268 symbolTable.relateToOperator("bitfieldExtract", EOpBitfieldExtract);
9269 symbolTable.relateToOperator("bitfieldInsert", EOpBitfieldInsert);
9270 symbolTable.relateToOperator("bitfieldReverse", EOpBitFieldReverse);
9271 symbolTable.relateToOperator("bitCount", EOpBitCount);
9272 symbolTable.relateToOperator("findLSB", EOpFindLSB);
9273 symbolTable.relateToOperator("findMSB", EOpFindMSB);
9275 symbolTable.relateToOperator("helperInvocationEXT", EOpIsHelperInvocation);
9277 symbolTable.relateToOperator("countLeadingZeros", EOpCountLeadingZeros);
9278 symbolTable.relateToOperator("countTrailingZeros", EOpCountTrailingZeros);
9279 symbolTable.relateToOperator("absoluteDifference", EOpAbsDifference);
9280 symbolTable.relateToOperator("addSaturate", EOpAddSaturate);
9281 symbolTable.relateToOperator("subtractSaturate", EOpSubSaturate);
9282 symbolTable.relateToOperator("average", EOpAverage);
9283 symbolTable.relateToOperator("averageRounded", EOpAverageRounded);
9284 symbolTable.relateToOperator("multiply32x16", EOpMul32x16);
9285 symbolTable.relateToOperator("debugPrintfEXT", EOpDebugPrintf);
9288 if (PureOperatorBuiltins) {
9289 symbolTable.relateToOperator("imageSize", EOpImageQuerySize);
9290 symbolTable.relateToOperator("imageSamples", EOpImageQuerySamples);
9291 symbolTable.relateToOperator("imageLoad", EOpImageLoad);
9292 symbolTable.relateToOperator("imageStore", EOpImageStore);
9293 symbolTable.relateToOperator("imageAtomicAdd", EOpImageAtomicAdd);
9294 symbolTable.relateToOperator("imageAtomicMin", EOpImageAtomicMin);
9295 symbolTable.relateToOperator("imageAtomicMax", EOpImageAtomicMax);
9296 symbolTable.relateToOperator("imageAtomicAnd", EOpImageAtomicAnd);
9297 symbolTable.relateToOperator("imageAtomicOr", EOpImageAtomicOr);
9298 symbolTable.relateToOperator("imageAtomicXor", EOpImageAtomicXor);
9299 symbolTable.relateToOperator("imageAtomicExchange", EOpImageAtomicExchange);
9300 symbolTable.relateToOperator("imageAtomicCompSwap", EOpImageAtomicCompSwap);
9301 symbolTable.relateToOperator("imageAtomicLoad", EOpImageAtomicLoad);
9302 symbolTable.relateToOperator("imageAtomicStore", EOpImageAtomicStore);
9304 symbolTable.relateToOperator("subpassLoad", EOpSubpassLoad);
9305 symbolTable.relateToOperator("subpassLoadMS", EOpSubpassLoadMS);
9307 symbolTable.relateToOperator("textureGather", EOpTextureGather);
9308 symbolTable.relateToOperator("textureGatherOffset", EOpTextureGatherOffset);
9309 symbolTable.relateToOperator("textureGatherOffsets", EOpTextureGatherOffsets);
9311 symbolTable.relateToOperator("noise1", EOpNoise);
9312 symbolTable.relateToOperator("noise2", EOpNoise);
9313 symbolTable.relateToOperator("noise3", EOpNoise);
9314 symbolTable.relateToOperator("noise4", EOpNoise);
9316 symbolTable.relateToOperator("textureFootprintNV", EOpImageSampleFootprintNV);
9317 symbolTable.relateToOperator("textureFootprintClampNV", EOpImageSampleFootprintClampNV);
9318 symbolTable.relateToOperator("textureFootprintLodNV", EOpImageSampleFootprintLodNV);
9319 symbolTable.relateToOperator("textureFootprintGradNV", EOpImageSampleFootprintGradNV);
9320 symbolTable.relateToOperator("textureFootprintGradClampNV", EOpImageSampleFootprintGradClampNV);
9322 if (spvVersion.spv == 0 && IncludeLegacy(version, profile, spvVersion))
9323 symbolTable.relateToOperator("ftransform", EOpFtransform);
9325 if (spvVersion.spv == 0 && (IncludeLegacy(version, profile, spvVersion) ||
9326 (profile == EEsProfile && version == 100))) {
9328 symbolTable.relateToOperator("texture1D", EOpTexture);
9329 symbolTable.relateToOperator("texture1DGradARB", EOpTextureGrad);
9330 symbolTable.relateToOperator("texture1DProj", EOpTextureProj);
9331 symbolTable.relateToOperator("texture1DProjGradARB", EOpTextureProjGrad);
9332 symbolTable.relateToOperator("texture1DLod", EOpTextureLod);
9333 symbolTable.relateToOperator("texture1DProjLod", EOpTextureProjLod);
9335 symbolTable.relateToOperator("texture2DRect", EOpTexture);
9336 symbolTable.relateToOperator("texture2DRectProj", EOpTextureProj);
9337 symbolTable.relateToOperator("texture2DRectGradARB", EOpTextureGrad);
9338 symbolTable.relateToOperator("texture2DRectProjGradARB", EOpTextureProjGrad);
9339 symbolTable.relateToOperator("shadow2DRect", EOpTexture);
9340 symbolTable.relateToOperator("shadow2DRectProj", EOpTextureProj);
9341 symbolTable.relateToOperator("shadow2DRectGradARB", EOpTextureGrad);
9342 symbolTable.relateToOperator("shadow2DRectProjGradARB", EOpTextureProjGrad);
9344 symbolTable.relateToOperator("texture2D", EOpTexture);
9345 symbolTable.relateToOperator("texture2DProj", EOpTextureProj);
9346 symbolTable.relateToOperator("texture2DGradEXT", EOpTextureGrad);
9347 symbolTable.relateToOperator("texture2DGradARB", EOpTextureGrad);
9348 symbolTable.relateToOperator("texture2DProjGradEXT", EOpTextureProjGrad);
9349 symbolTable.relateToOperator("texture2DProjGradARB", EOpTextureProjGrad);
9350 symbolTable.relateToOperator("texture2DLod", EOpTextureLod);
9351 symbolTable.relateToOperator("texture2DLodEXT", EOpTextureLod);
9352 symbolTable.relateToOperator("texture2DProjLod", EOpTextureProjLod);
9353 symbolTable.relateToOperator("texture2DProjLodEXT", EOpTextureProjLod);
9355 symbolTable.relateToOperator("texture3D", EOpTexture);
9356 symbolTable.relateToOperator("texture3DGradARB", EOpTextureGrad);
9357 symbolTable.relateToOperator("texture3DProj", EOpTextureProj);
9358 symbolTable.relateToOperator("texture3DProjGradARB", EOpTextureProjGrad);
9359 symbolTable.relateToOperator("texture3DLod", EOpTextureLod);
9360 symbolTable.relateToOperator("texture3DProjLod", EOpTextureProjLod);
9361 symbolTable.relateToOperator("textureCube", EOpTexture);
9362 symbolTable.relateToOperator("textureCubeGradEXT", EOpTextureGrad);
9363 symbolTable.relateToOperator("textureCubeGradARB", EOpTextureGrad);
9364 symbolTable.relateToOperator("textureCubeLod", EOpTextureLod);
9365 symbolTable.relateToOperator("textureCubeLodEXT", EOpTextureLod);
9366 symbolTable.relateToOperator("shadow1D", EOpTexture);
9367 symbolTable.relateToOperator("shadow1DGradARB", EOpTextureGrad);
9368 symbolTable.relateToOperator("shadow2D", EOpTexture);
9369 symbolTable.relateToOperator("shadow2DGradARB", EOpTextureGrad);
9370 symbolTable.relateToOperator("shadow1DProj", EOpTextureProj);
9371 symbolTable.relateToOperator("shadow2DProj", EOpTextureProj);
9372 symbolTable.relateToOperator("shadow1DProjGradARB", EOpTextureProjGrad);
9373 symbolTable.relateToOperator("shadow2DProjGradARB", EOpTextureProjGrad);
9374 symbolTable.relateToOperator("shadow1DLod", EOpTextureLod);
9375 symbolTable.relateToOperator("shadow2DLod", EOpTextureLod);
9376 symbolTable.relateToOperator("shadow1DProjLod", EOpTextureProjLod);
9377 symbolTable.relateToOperator("shadow2DProjLod", EOpTextureProjLod);
9380 if (profile != EEsProfile) {
9381 symbolTable.relateToOperator("sparseTextureARB", EOpSparseTexture);
9382 symbolTable.relateToOperator("sparseTextureLodARB", EOpSparseTextureLod);
9383 symbolTable.relateToOperator("sparseTextureOffsetARB", EOpSparseTextureOffset);
9384 symbolTable.relateToOperator("sparseTexelFetchARB", EOpSparseTextureFetch);
9385 symbolTable.relateToOperator("sparseTexelFetchOffsetARB", EOpSparseTextureFetchOffset);
9386 symbolTable.relateToOperator("sparseTextureLodOffsetARB", EOpSparseTextureLodOffset);
9387 symbolTable.relateToOperator("sparseTextureGradARB", EOpSparseTextureGrad);
9388 symbolTable.relateToOperator("sparseTextureGradOffsetARB", EOpSparseTextureGradOffset);
9389 symbolTable.relateToOperator("sparseTextureGatherARB", EOpSparseTextureGather);
9390 symbolTable.relateToOperator("sparseTextureGatherOffsetARB", EOpSparseTextureGatherOffset);
9391 symbolTable.relateToOperator("sparseTextureGatherOffsetsARB", EOpSparseTextureGatherOffsets);
9392 symbolTable.relateToOperator("sparseImageLoadARB", EOpSparseImageLoad);
9393 symbolTable.relateToOperator("sparseTexelsResidentARB", EOpSparseTexelsResident);
9395 symbolTable.relateToOperator("sparseTextureClampARB", EOpSparseTextureClamp);
9396 symbolTable.relateToOperator("sparseTextureOffsetClampARB", EOpSparseTextureOffsetClamp);
9397 symbolTable.relateToOperator("sparseTextureGradClampARB", EOpSparseTextureGradClamp);
9398 symbolTable.relateToOperator("sparseTextureGradOffsetClampARB", EOpSparseTextureGradOffsetClamp);
9399 symbolTable.relateToOperator("textureClampARB", EOpTextureClamp);
9400 symbolTable.relateToOperator("textureOffsetClampARB", EOpTextureOffsetClamp);
9401 symbolTable.relateToOperator("textureGradClampARB", EOpTextureGradClamp);
9402 symbolTable.relateToOperator("textureGradOffsetClampARB", EOpTextureGradOffsetClamp);
9404 symbolTable.relateToOperator("ballotARB", EOpBallot);
9405 symbolTable.relateToOperator("readInvocationARB", EOpReadInvocation);
9406 symbolTable.relateToOperator("readFirstInvocationARB", EOpReadFirstInvocation);
9408 if (version >= 430) {
9409 symbolTable.relateToOperator("anyInvocationARB", EOpAnyInvocation);
9410 symbolTable.relateToOperator("allInvocationsARB", EOpAllInvocations);
9411 symbolTable.relateToOperator("allInvocationsEqualARB", EOpAllInvocationsEqual);
9413 if (version >= 460) {
9414 symbolTable.relateToOperator("anyInvocation", EOpAnyInvocation);
9415 symbolTable.relateToOperator("allInvocations", EOpAllInvocations);
9416 symbolTable.relateToOperator("allInvocationsEqual", EOpAllInvocationsEqual);
9418 symbolTable.relateToOperator("minInvocationsAMD", EOpMinInvocations);
9419 symbolTable.relateToOperator("maxInvocationsAMD", EOpMaxInvocations);
9420 symbolTable.relateToOperator("addInvocationsAMD", EOpAddInvocations);
9421 symbolTable.relateToOperator("minInvocationsNonUniformAMD", EOpMinInvocationsNonUniform);
9422 symbolTable.relateToOperator("maxInvocationsNonUniformAMD", EOpMaxInvocationsNonUniform);
9423 symbolTable.relateToOperator("addInvocationsNonUniformAMD", EOpAddInvocationsNonUniform);
9424 symbolTable.relateToOperator("minInvocationsInclusiveScanAMD", EOpMinInvocationsInclusiveScan);
9425 symbolTable.relateToOperator("maxInvocationsInclusiveScanAMD", EOpMaxInvocationsInclusiveScan);
9426 symbolTable.relateToOperator("addInvocationsInclusiveScanAMD", EOpAddInvocationsInclusiveScan);
9427 symbolTable.relateToOperator("minInvocationsInclusiveScanNonUniformAMD", EOpMinInvocationsInclusiveScanNonUniform);
9428 symbolTable.relateToOperator("maxInvocationsInclusiveScanNonUniformAMD", EOpMaxInvocationsInclusiveScanNonUniform);
9429 symbolTable.relateToOperator("addInvocationsInclusiveScanNonUniformAMD", EOpAddInvocationsInclusiveScanNonUniform);
9430 symbolTable.relateToOperator("minInvocationsExclusiveScanAMD", EOpMinInvocationsExclusiveScan);
9431 symbolTable.relateToOperator("maxInvocationsExclusiveScanAMD", EOpMaxInvocationsExclusiveScan);
9432 symbolTable.relateToOperator("addInvocationsExclusiveScanAMD", EOpAddInvocationsExclusiveScan);
9433 symbolTable.relateToOperator("minInvocationsExclusiveScanNonUniformAMD", EOpMinInvocationsExclusiveScanNonUniform);
9434 symbolTable.relateToOperator("maxInvocationsExclusiveScanNonUniformAMD", EOpMaxInvocationsExclusiveScanNonUniform);
9435 symbolTable.relateToOperator("addInvocationsExclusiveScanNonUniformAMD", EOpAddInvocationsExclusiveScanNonUniform);
9436 symbolTable.relateToOperator("swizzleInvocationsAMD", EOpSwizzleInvocations);
9437 symbolTable.relateToOperator("swizzleInvocationsMaskedAMD", EOpSwizzleInvocationsMasked);
9438 symbolTable.relateToOperator("writeInvocationAMD", EOpWriteInvocation);
9439 symbolTable.relateToOperator("mbcntAMD", EOpMbcnt);
9441 symbolTable.relateToOperator("min3", EOpMin3);
9442 symbolTable.relateToOperator("max3", EOpMax3);
9443 symbolTable.relateToOperator("mid3", EOpMid3);
9445 symbolTable.relateToOperator("cubeFaceIndexAMD", EOpCubeFaceIndex);
9446 symbolTable.relateToOperator("cubeFaceCoordAMD", EOpCubeFaceCoord);
9447 symbolTable.relateToOperator("timeAMD", EOpTime);
9449 symbolTable.relateToOperator("textureGatherLodAMD", EOpTextureGatherLod);
9450 symbolTable.relateToOperator("textureGatherLodOffsetAMD", EOpTextureGatherLodOffset);
9451 symbolTable.relateToOperator("textureGatherLodOffsetsAMD", EOpTextureGatherLodOffsets);
9452 symbolTable.relateToOperator("sparseTextureGatherLodAMD", EOpSparseTextureGatherLod);
9453 symbolTable.relateToOperator("sparseTextureGatherLodOffsetAMD", EOpSparseTextureGatherLodOffset);
9454 symbolTable.relateToOperator("sparseTextureGatherLodOffsetsAMD", EOpSparseTextureGatherLodOffsets);
9456 symbolTable.relateToOperator("imageLoadLodAMD", EOpImageLoadLod);
9457 symbolTable.relateToOperator("imageStoreLodAMD", EOpImageStoreLod);
9458 symbolTable.relateToOperator("sparseImageLoadLodAMD", EOpSparseImageLoadLod);
9460 symbolTable.relateToOperator("fragmentMaskFetchAMD", EOpFragmentMaskFetch);
9461 symbolTable.relateToOperator("fragmentFetchAMD", EOpFragmentFetch);
9464 // GL_KHR_shader_subgroup
9465 if ((profile == EEsProfile && version >= 310) ||
9466 (profile != EEsProfile && version >= 140)) {
9467 symbolTable.relateToOperator("subgroupBarrier", EOpSubgroupBarrier);
9468 symbolTable.relateToOperator("subgroupMemoryBarrier", EOpSubgroupMemoryBarrier);
9469 symbolTable.relateToOperator("subgroupMemoryBarrierBuffer", EOpSubgroupMemoryBarrierBuffer);
9470 symbolTable.relateToOperator("subgroupMemoryBarrierImage", EOpSubgroupMemoryBarrierImage);
9471 symbolTable.relateToOperator("subgroupElect", EOpSubgroupElect);
9472 symbolTable.relateToOperator("subgroupAll", EOpSubgroupAll);
9473 symbolTable.relateToOperator("subgroupAny", EOpSubgroupAny);
9474 symbolTable.relateToOperator("subgroupAllEqual", EOpSubgroupAllEqual);
9475 symbolTable.relateToOperator("subgroupBroadcast", EOpSubgroupBroadcast);
9476 symbolTable.relateToOperator("subgroupBroadcastFirst", EOpSubgroupBroadcastFirst);
9477 symbolTable.relateToOperator("subgroupBallot", EOpSubgroupBallot);
9478 symbolTable.relateToOperator("subgroupInverseBallot", EOpSubgroupInverseBallot);
9479 symbolTable.relateToOperator("subgroupBallotBitExtract", EOpSubgroupBallotBitExtract);
9480 symbolTable.relateToOperator("subgroupBallotBitCount", EOpSubgroupBallotBitCount);
9481 symbolTable.relateToOperator("subgroupBallotInclusiveBitCount", EOpSubgroupBallotInclusiveBitCount);
9482 symbolTable.relateToOperator("subgroupBallotExclusiveBitCount", EOpSubgroupBallotExclusiveBitCount);
9483 symbolTable.relateToOperator("subgroupBallotFindLSB", EOpSubgroupBallotFindLSB);
9484 symbolTable.relateToOperator("subgroupBallotFindMSB", EOpSubgroupBallotFindMSB);
9485 symbolTable.relateToOperator("subgroupShuffle", EOpSubgroupShuffle);
9486 symbolTable.relateToOperator("subgroupShuffleXor", EOpSubgroupShuffleXor);
9487 symbolTable.relateToOperator("subgroupShuffleUp", EOpSubgroupShuffleUp);
9488 symbolTable.relateToOperator("subgroupShuffleDown", EOpSubgroupShuffleDown);
9489 symbolTable.relateToOperator("subgroupAdd", EOpSubgroupAdd);
9490 symbolTable.relateToOperator("subgroupMul", EOpSubgroupMul);
9491 symbolTable.relateToOperator("subgroupMin", EOpSubgroupMin);
9492 symbolTable.relateToOperator("subgroupMax", EOpSubgroupMax);
9493 symbolTable.relateToOperator("subgroupAnd", EOpSubgroupAnd);
9494 symbolTable.relateToOperator("subgroupOr", EOpSubgroupOr);
9495 symbolTable.relateToOperator("subgroupXor", EOpSubgroupXor);
9496 symbolTable.relateToOperator("subgroupInclusiveAdd", EOpSubgroupInclusiveAdd);
9497 symbolTable.relateToOperator("subgroupInclusiveMul", EOpSubgroupInclusiveMul);
9498 symbolTable.relateToOperator("subgroupInclusiveMin", EOpSubgroupInclusiveMin);
9499 symbolTable.relateToOperator("subgroupInclusiveMax", EOpSubgroupInclusiveMax);
9500 symbolTable.relateToOperator("subgroupInclusiveAnd", EOpSubgroupInclusiveAnd);
9501 symbolTable.relateToOperator("subgroupInclusiveOr", EOpSubgroupInclusiveOr);
9502 symbolTable.relateToOperator("subgroupInclusiveXor", EOpSubgroupInclusiveXor);
9503 symbolTable.relateToOperator("subgroupExclusiveAdd", EOpSubgroupExclusiveAdd);
9504 symbolTable.relateToOperator("subgroupExclusiveMul", EOpSubgroupExclusiveMul);
9505 symbolTable.relateToOperator("subgroupExclusiveMin", EOpSubgroupExclusiveMin);
9506 symbolTable.relateToOperator("subgroupExclusiveMax", EOpSubgroupExclusiveMax);
9507 symbolTable.relateToOperator("subgroupExclusiveAnd", EOpSubgroupExclusiveAnd);
9508 symbolTable.relateToOperator("subgroupExclusiveOr", EOpSubgroupExclusiveOr);
9509 symbolTable.relateToOperator("subgroupExclusiveXor", EOpSubgroupExclusiveXor);
9510 symbolTable.relateToOperator("subgroupClusteredAdd", EOpSubgroupClusteredAdd);
9511 symbolTable.relateToOperator("subgroupClusteredMul", EOpSubgroupClusteredMul);
9512 symbolTable.relateToOperator("subgroupClusteredMin", EOpSubgroupClusteredMin);
9513 symbolTable.relateToOperator("subgroupClusteredMax", EOpSubgroupClusteredMax);
9514 symbolTable.relateToOperator("subgroupClusteredAnd", EOpSubgroupClusteredAnd);
9515 symbolTable.relateToOperator("subgroupClusteredOr", EOpSubgroupClusteredOr);
9516 symbolTable.relateToOperator("subgroupClusteredXor", EOpSubgroupClusteredXor);
9517 symbolTable.relateToOperator("subgroupQuadBroadcast", EOpSubgroupQuadBroadcast);
9518 symbolTable.relateToOperator("subgroupQuadSwapHorizontal", EOpSubgroupQuadSwapHorizontal);
9519 symbolTable.relateToOperator("subgroupQuadSwapVertical", EOpSubgroupQuadSwapVertical);
9520 symbolTable.relateToOperator("subgroupQuadSwapDiagonal", EOpSubgroupQuadSwapDiagonal);
9522 symbolTable.relateToOperator("subgroupPartitionNV", EOpSubgroupPartition);
9523 symbolTable.relateToOperator("subgroupPartitionedAddNV", EOpSubgroupPartitionedAdd);
9524 symbolTable.relateToOperator("subgroupPartitionedMulNV", EOpSubgroupPartitionedMul);
9525 symbolTable.relateToOperator("subgroupPartitionedMinNV", EOpSubgroupPartitionedMin);
9526 symbolTable.relateToOperator("subgroupPartitionedMaxNV", EOpSubgroupPartitionedMax);
9527 symbolTable.relateToOperator("subgroupPartitionedAndNV", EOpSubgroupPartitionedAnd);
9528 symbolTable.relateToOperator("subgroupPartitionedOrNV", EOpSubgroupPartitionedOr);
9529 symbolTable.relateToOperator("subgroupPartitionedXorNV", EOpSubgroupPartitionedXor);
9530 symbolTable.relateToOperator("subgroupPartitionedInclusiveAddNV", EOpSubgroupPartitionedInclusiveAdd);
9531 symbolTable.relateToOperator("subgroupPartitionedInclusiveMulNV", EOpSubgroupPartitionedInclusiveMul);
9532 symbolTable.relateToOperator("subgroupPartitionedInclusiveMinNV", EOpSubgroupPartitionedInclusiveMin);
9533 symbolTable.relateToOperator("subgroupPartitionedInclusiveMaxNV", EOpSubgroupPartitionedInclusiveMax);
9534 symbolTable.relateToOperator("subgroupPartitionedInclusiveAndNV", EOpSubgroupPartitionedInclusiveAnd);
9535 symbolTable.relateToOperator("subgroupPartitionedInclusiveOrNV", EOpSubgroupPartitionedInclusiveOr);
9536 symbolTable.relateToOperator("subgroupPartitionedInclusiveXorNV", EOpSubgroupPartitionedInclusiveXor);
9537 symbolTable.relateToOperator("subgroupPartitionedExclusiveAddNV", EOpSubgroupPartitionedExclusiveAdd);
9538 symbolTable.relateToOperator("subgroupPartitionedExclusiveMulNV", EOpSubgroupPartitionedExclusiveMul);
9539 symbolTable.relateToOperator("subgroupPartitionedExclusiveMinNV", EOpSubgroupPartitionedExclusiveMin);
9540 symbolTable.relateToOperator("subgroupPartitionedExclusiveMaxNV", EOpSubgroupPartitionedExclusiveMax);
9541 symbolTable.relateToOperator("subgroupPartitionedExclusiveAndNV", EOpSubgroupPartitionedExclusiveAnd);
9542 symbolTable.relateToOperator("subgroupPartitionedExclusiveOrNV", EOpSubgroupPartitionedExclusiveOr);
9543 symbolTable.relateToOperator("subgroupPartitionedExclusiveXorNV", EOpSubgroupPartitionedExclusiveXor);
9546 if (profile == EEsProfile) {
9547 symbolTable.relateToOperator("shadow2DEXT", EOpTexture);
9548 symbolTable.relateToOperator("shadow2DProjEXT", EOpTextureProj);
9556 case EShLangTessControl:
9557 case EShLangTessEvaluation:
9560 case EShLangGeometry:
9561 symbolTable.relateToOperator("EmitStreamVertex", EOpEmitStreamVertex);
9562 symbolTable.relateToOperator("EndStreamPrimitive", EOpEndStreamPrimitive);
9563 symbolTable.relateToOperator("EmitVertex", EOpEmitVertex);
9564 symbolTable.relateToOperator("EndPrimitive", EOpEndPrimitive);
9567 case EShLangFragment:
9568 if (profile != EEsProfile && version >= 400) {
9569 symbolTable.relateToOperator("dFdxFine", EOpDPdxFine);
9570 symbolTable.relateToOperator("dFdyFine", EOpDPdyFine);
9571 symbolTable.relateToOperator("fwidthFine", EOpFwidthFine);
9572 symbolTable.relateToOperator("dFdxCoarse", EOpDPdxCoarse);
9573 symbolTable.relateToOperator("dFdyCoarse", EOpDPdyCoarse);
9574 symbolTable.relateToOperator("fwidthCoarse", EOpFwidthCoarse);
9577 if (profile != EEsProfile && version >= 460) {
9578 symbolTable.relateToOperator("rayQueryInitializeEXT", EOpRayQueryInitialize);
9579 symbolTable.relateToOperator("rayQueryTerminateEXT", EOpRayQueryTerminate);
9580 symbolTable.relateToOperator("rayQueryGenerateIntersectionEXT", EOpRayQueryGenerateIntersection);
9581 symbolTable.relateToOperator("rayQueryConfirmIntersectionEXT", EOpRayQueryConfirmIntersection);
9582 symbolTable.relateToOperator("rayQueryProceedEXT", EOpRayQueryProceed);
9583 symbolTable.relateToOperator("rayQueryGetIntersectionTypeEXT", EOpRayQueryGetIntersectionType);
9584 symbolTable.relateToOperator("rayQueryGetRayTMinEXT", EOpRayQueryGetRayTMin);
9585 symbolTable.relateToOperator("rayQueryGetRayFlagsEXT", EOpRayQueryGetRayFlags);
9586 symbolTable.relateToOperator("rayQueryGetIntersectionTEXT", EOpRayQueryGetIntersectionT);
9587 symbolTable.relateToOperator("rayQueryGetIntersectionInstanceCustomIndexEXT", EOpRayQueryGetIntersectionInstanceCustomIndex);
9588 symbolTable.relateToOperator("rayQueryGetIntersectionInstanceIdEXT", EOpRayQueryGetIntersectionInstanceId);
9589 symbolTable.relateToOperator("rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT", EOpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffset);
9590 symbolTable.relateToOperator("rayQueryGetIntersectionGeometryIndexEXT", EOpRayQueryGetIntersectionGeometryIndex);
9591 symbolTable.relateToOperator("rayQueryGetIntersectionPrimitiveIndexEXT", EOpRayQueryGetIntersectionPrimitiveIndex);
9592 symbolTable.relateToOperator("rayQueryGetIntersectionBarycentricsEXT", EOpRayQueryGetIntersectionBarycentrics);
9593 symbolTable.relateToOperator("rayQueryGetIntersectionFrontFaceEXT", EOpRayQueryGetIntersectionFrontFace);
9594 symbolTable.relateToOperator("rayQueryGetIntersectionCandidateAABBOpaqueEXT", EOpRayQueryGetIntersectionCandidateAABBOpaque);
9595 symbolTable.relateToOperator("rayQueryGetIntersectionObjectRayDirectionEXT", EOpRayQueryGetIntersectionObjectRayDirection);
9596 symbolTable.relateToOperator("rayQueryGetIntersectionObjectRayOriginEXT", EOpRayQueryGetIntersectionObjectRayOrigin);
9597 symbolTable.relateToOperator("rayQueryGetWorldRayDirectionEXT", EOpRayQueryGetWorldRayDirection);
9598 symbolTable.relateToOperator("rayQueryGetWorldRayOriginEXT", EOpRayQueryGetWorldRayOrigin);
9599 symbolTable.relateToOperator("rayQueryGetIntersectionObjectToWorldEXT", EOpRayQueryGetIntersectionObjectToWorld);
9600 symbolTable.relateToOperator("rayQueryGetIntersectionWorldToObjectEXT", EOpRayQueryGetIntersectionWorldToObject);
9603 symbolTable.relateToOperator("interpolateAtCentroid", EOpInterpolateAtCentroid);
9604 symbolTable.relateToOperator("interpolateAtSample", EOpInterpolateAtSample);
9605 symbolTable.relateToOperator("interpolateAtOffset", EOpInterpolateAtOffset);
9607 if (profile != EEsProfile)
9608 symbolTable.relateToOperator("interpolateAtVertexAMD", EOpInterpolateAtVertex);
9610 symbolTable.relateToOperator("beginInvocationInterlockARB", EOpBeginInvocationInterlock);
9611 symbolTable.relateToOperator("endInvocationInterlockARB", EOpEndInvocationInterlock);
9615 case EShLangCompute:
9616 symbolTable.relateToOperator("subgroupMemoryBarrierShared", EOpSubgroupMemoryBarrierShared);
9617 if ((profile != EEsProfile && version >= 450) ||
9618 (profile == EEsProfile && version >= 320)) {
9619 symbolTable.relateToOperator("dFdx", EOpDPdx);
9620 symbolTable.relateToOperator("dFdy", EOpDPdy);
9621 symbolTable.relateToOperator("fwidth", EOpFwidth);
9622 symbolTable.relateToOperator("dFdxFine", EOpDPdxFine);
9623 symbolTable.relateToOperator("dFdyFine", EOpDPdyFine);
9624 symbolTable.relateToOperator("fwidthFine", EOpFwidthFine);
9625 symbolTable.relateToOperator("dFdxCoarse", EOpDPdxCoarse);
9626 symbolTable.relateToOperator("dFdyCoarse", EOpDPdyCoarse);
9627 symbolTable.relateToOperator("fwidthCoarse",EOpFwidthCoarse);
9629 symbolTable.relateToOperator("coopMatLoadNV", EOpCooperativeMatrixLoad);
9630 symbolTable.relateToOperator("coopMatStoreNV", EOpCooperativeMatrixStore);
9631 symbolTable.relateToOperator("coopMatMulAddNV", EOpCooperativeMatrixMulAdd);
9635 case EShLangClosestHit:
9637 if (profile != EEsProfile && version >= 460) {
9638 symbolTable.relateToOperator("traceNV", EOpTraceNV);
9639 symbolTable.relateToOperator("traceRayMotionNV", EOpTraceRayMotionNV);
9640 symbolTable.relateToOperator("traceRayEXT", EOpTraceKHR);
9641 symbolTable.relateToOperator("executeCallableNV", EOpExecuteCallableNV);
9642 symbolTable.relateToOperator("executeCallableEXT", EOpExecuteCallableKHR);
9645 case EShLangIntersect:
9646 if (profile != EEsProfile && version >= 460) {
9647 symbolTable.relateToOperator("reportIntersectionNV", EOpReportIntersection);
9648 symbolTable.relateToOperator("reportIntersectionEXT", EOpReportIntersection);
9652 if (profile != EEsProfile && version >= 460) {
9653 symbolTable.relateToOperator("ignoreIntersectionNV", EOpIgnoreIntersectionNV);
9654 symbolTable.relateToOperator("terminateRayNV", EOpTerminateRayNV);
9657 case EShLangCallable:
9658 if (profile != EEsProfile && version >= 460) {
9659 symbolTable.relateToOperator("executeCallableNV", EOpExecuteCallableNV);
9660 symbolTable.relateToOperator("executeCallableEXT", EOpExecuteCallableKHR);
9664 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
9665 symbolTable.relateToOperator("writePackedPrimitiveIndices4x8NV", EOpWritePackedPrimitiveIndices4x8NV);
9669 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
9670 symbolTable.relateToOperator("memoryBarrierShared", EOpMemoryBarrierShared);
9671 symbolTable.relateToOperator("groupMemoryBarrier", EOpGroupMemoryBarrier);
9672 symbolTable.relateToOperator("subgroupMemoryBarrierShared", EOpSubgroupMemoryBarrierShared);
9677 assert(false && "Language not supported");
9679 #endif // !GLSLANG_WEB
9683 // Add context-dependent (resource-specific) built-ins not handled by the above. These
9684 // would be ones that need to be programmatically added because they cannot
9685 // be added by simple text strings. For these, also
9686 // 1) Map built-in functions to operators, for those that will turn into an operation node
9687 // instead of remaining a function call.
9688 // 2) Tag extension-related symbols added to their base version with their extensions, so
9689 // that if an early version has the extension turned off, there is an error reported on use.
9691 void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources)
9694 #if defined(GLSLANG_ANGLE)
9695 profile = ECoreProfile;
9698 if (profile != EEsProfile && version >= 430 && version < 440) {
9699 symbolTable.setVariableExtensions("gl_MaxTransformFeedbackBuffers", 1, &E_GL_ARB_enhanced_layouts);
9700 symbolTable.setVariableExtensions("gl_MaxTransformFeedbackInterleavedComponents", 1, &E_GL_ARB_enhanced_layouts);
9702 if (profile != EEsProfile && version >= 130 && version < 420) {
9703 symbolTable.setVariableExtensions("gl_MinProgramTexelOffset", 1, &E_GL_ARB_shading_language_420pack);
9704 symbolTable.setVariableExtensions("gl_MaxProgramTexelOffset", 1, &E_GL_ARB_shading_language_420pack);
9706 if (profile != EEsProfile && version >= 150 && version < 410)
9707 symbolTable.setVariableExtensions("gl_MaxViewports", 1, &E_GL_ARB_viewport_array);
9710 case EShLangFragment:
9711 // Set up gl_FragData based on current array size.
9712 if (version == 100 || IncludeLegacy(version, profile, spvVersion) || (! ForwardCompatibility && profile != EEsProfile && version < 420)) {
9713 TPrecisionQualifier pq = profile == EEsProfile ? EpqMedium : EpqNone;
9714 TType fragData(EbtFloat, EvqFragColor, pq, 4);
9715 TArraySizes* arraySizes = new TArraySizes;
9716 arraySizes->addInnerSize(resources.maxDrawBuffers);
9717 fragData.transferArraySizes(arraySizes);
9718 symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));
9719 SpecialQualifier("gl_FragData", EvqFragColor, EbvFragData, symbolTable);
9722 // GL_EXT_blend_func_extended
9723 if (profile == EEsProfile && version >= 100) {
9724 symbolTable.setVariableExtensions("gl_MaxDualSourceDrawBuffersEXT", 1, &E_GL_EXT_blend_func_extended);
9725 symbolTable.setVariableExtensions("gl_SecondaryFragColorEXT", 1, &E_GL_EXT_blend_func_extended);
9726 symbolTable.setVariableExtensions("gl_SecondaryFragDataEXT", 1, &E_GL_EXT_blend_func_extended);
9727 SpecialQualifier("gl_SecondaryFragColorEXT", EvqVaryingOut, EbvSecondaryFragColorEXT, symbolTable);
9728 SpecialQualifier("gl_SecondaryFragDataEXT", EvqVaryingOut, EbvSecondaryFragDataEXT, symbolTable);
9733 case EShLangTessControl:
9734 case EShLangTessEvaluation:
9735 // Because of the context-dependent array size (gl_MaxPatchVertices),
9736 // these variables were added later than the others and need to be mapped now.
9739 BuiltInVariable("gl_in", "gl_Position", EbvPosition, symbolTable);
9740 BuiltInVariable("gl_in", "gl_PointSize", EbvPointSize, symbolTable);
9741 BuiltInVariable("gl_in", "gl_ClipDistance", EbvClipDistance, symbolTable);
9742 BuiltInVariable("gl_in", "gl_CullDistance", EbvCullDistance, symbolTable);
9744 // compatibility members
9745 BuiltInVariable("gl_in", "gl_ClipVertex", EbvClipVertex, symbolTable);
9746 BuiltInVariable("gl_in", "gl_FrontColor", EbvFrontColor, symbolTable);
9747 BuiltInVariable("gl_in", "gl_BackColor", EbvBackColor, symbolTable);
9748 BuiltInVariable("gl_in", "gl_FrontSecondaryColor", EbvFrontSecondaryColor, symbolTable);
9749 BuiltInVariable("gl_in", "gl_BackSecondaryColor", EbvBackSecondaryColor, symbolTable);
9750 BuiltInVariable("gl_in", "gl_TexCoord", EbvTexCoord, symbolTable);
9751 BuiltInVariable("gl_in", "gl_FogFragCoord", EbvFogFragCoord, symbolTable);
9753 symbolTable.setVariableExtensions("gl_in", "gl_SecondaryPositionNV", 1, &E_GL_NV_stereo_view_rendering);
9754 symbolTable.setVariableExtensions("gl_in", "gl_PositionPerViewNV", 1, &E_GL_NVX_multiview_per_view_attributes);
9756 BuiltInVariable("gl_in", "gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable);
9757 BuiltInVariable("gl_in", "gl_PositionPerViewNV", EbvPositionPerViewNV, symbolTable);
9759 // extension requirements
9760 if (profile == EEsProfile) {
9761 symbolTable.setVariableExtensions("gl_in", "gl_PointSize", Num_AEP_tessellation_point_size, AEP_tessellation_point_size);
9772 } // end namespace glslang