1 //
2 // Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
3 // Copyright (C) 2012-2016 LunarG, Inc.
4 // Copyright (C) 2015-2020 Google, Inc.
5 // Copyright (C) 2017 ARM Limited.
6 // Modifications Copyright (C) 2020-2021 Advanced Micro Devices, Inc. All rights reserved.
7 //
8 // All rights reserved.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions
12 // are met:
13 //
14 // Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // Redistributions in binary form must reproduce the above
18 // copyright notice, this list of conditions and the following
19 // disclaimer in the documentation and/or other materials provided
20 // with the distribution.
21 //
22 // Neither the name of 3Dlabs Inc. Ltd. nor the names of its
23 // contributors may be used to endorse or promote products derived
24 // from this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
29 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
30 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
31 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
32 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
36 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 // POSSIBILITY OF SUCH DAMAGE.
38 //
39
40 //
41 // Create strings that declare built-in definitions, add built-ins programmatically
42 // that cannot be expressed in the strings, and establish mappings between
43 // built-in functions and operators.
44 //
45 // Where to put a built-in:
46 // TBuiltIns::initialize(version,profile) context-independent textual built-ins; add them to the right string
47 // TBuiltIns::initialize(resources,...) context-dependent textual built-ins; add them to the right string
48 // TBuiltIns::identifyBuiltIns(...,symbolTable) context-independent programmatic additions/mappings to the symbol table,
49 // including identifying what extensions are needed if a version does not allow a symbol
50 // TBuiltIns::identifyBuiltIns(...,symbolTable, resources) context-dependent programmatic additions/mappings to the symbol table,
51 // including identifying what extensions are needed if a version does not allow a symbol
52 //
53
54 #include "Initialize.h"
55
56 namespace glslang {
57
58 // TODO: ARB_Compatability: do full extension support
59 const bool ARBCompatibility = true;
60
61 const bool ForwardCompatibility = false;
62
63 namespace {
64
65 //
66 // A set of definitions for tabling of the built-in functions.
67 //
68
69 // Order matters here, as does correlation with the subsequent
70 // "const int ..." declarations and the ArgType enumerants.
71 const char* TypeString[] = {
72 "bool", "bvec2", "bvec3", "bvec4",
73 "float", "vec2", "vec3", "vec4",
74 "int", "ivec2", "ivec3", "ivec4",
75 "uint", "uvec2", "uvec3", "uvec4",
76 };
77 const int TypeStringCount = sizeof(TypeString) / sizeof(char*); // number of entries in 'TypeString'
78 const int TypeStringRowShift = 2; // shift amount to go downe one row in 'TypeString'
79 const int TypeStringColumnMask = (1 << TypeStringRowShift) - 1; // reduce type to its column number in 'TypeString'
80 const int TypeStringScalarMask = ~TypeStringColumnMask; // take type to its scalar column in 'TypeString'
81
82 enum ArgType {
83 // numbers hardcoded to correspond to 'TypeString'; order and value matter
84 TypeB = 1 << 0, // Boolean
85 TypeF = 1 << 1, // float 32
86 TypeI = 1 << 2, // int 32
87 TypeU = 1 << 3, // uint 32
88 TypeF16 = 1 << 4, // float 16
89 TypeF64 = 1 << 5, // float 64
90 TypeI8 = 1 << 6, // int 8
91 TypeI16 = 1 << 7, // int 16
92 TypeI64 = 1 << 8, // int 64
93 TypeU8 = 1 << 9, // uint 8
94 TypeU16 = 1 << 10, // uint 16
95 TypeU64 = 1 << 11, // uint 64
96 };
97 // Mixtures of the above, to help the function tables
98 const ArgType TypeFI = static_cast<ArgType>(TypeF | TypeI);
99 const ArgType TypeFIB = static_cast<ArgType>(TypeF | TypeI | TypeB);
100 const ArgType TypeIU = static_cast<ArgType>(TypeI | TypeU);
101
102 // The relationships between arguments and return type, whether anything is
103 // output, or other unusual situations.
104 enum ArgClass {
105 ClassRegular = 0, // nothing special, just all vector widths with matching return type; traditional arithmetic
106 ClassLS = 1 << 0, // the last argument is also held fixed as a (type-matched) scalar while the others cycle
107 ClassXLS = 1 << 1, // the last argument is exclusively a (type-matched) scalar while the others cycle
108 ClassLS2 = 1 << 2, // the last two arguments are held fixed as a (type-matched) scalar while the others cycle
109 ClassFS = 1 << 3, // the first argument is held fixed as a (type-matched) scalar while the others cycle
110 ClassFS2 = 1 << 4, // the first two arguments are held fixed as a (type-matched) scalar while the others cycle
111 ClassLO = 1 << 5, // the last argument is an output
112 ClassB = 1 << 6, // return type cycles through only bool/bvec, matching vector width of args
113 ClassLB = 1 << 7, // last argument cycles through only bool/bvec, matching vector width of args
114 ClassV1 = 1 << 8, // scalar only
115 ClassFIO = 1 << 9, // first argument is inout
116 ClassRS = 1 << 10, // the return is held scalar as the arguments cycle
117 ClassNS = 1 << 11, // no scalar prototype
118 ClassCV = 1 << 12, // first argument is 'coherent volatile'
119 ClassFO = 1 << 13, // first argument is output
120 ClassV3 = 1 << 14, // vec3 only
121 };
122 // Mixtures of the above, to help the function tables
123 const ArgClass ClassV1FIOCV = (ArgClass)(ClassV1 | ClassFIO | ClassCV);
124 const ArgClass ClassBNS = (ArgClass)(ClassB | ClassNS);
125 const ArgClass ClassRSNS = (ArgClass)(ClassRS | ClassNS);
126
127 // A descriptor, for a single profile, of when something is available.
128 // If the current profile does not match 'profile' mask below, the other fields
129 // do not apply (nor validate).
130 // profiles == EBadProfile is the end of an array of these
131 struct Versioning {
132 EProfile profiles; // the profile(s) (mask) that the following fields are valid for
133 int minExtendedVersion; // earliest version when extensions are enabled; ignored if numExtensions is 0
134 int minCoreVersion; // earliest version function is in core; 0 means never
135 int numExtensions; // how many extensions are in the 'extensions' list
136 const char** extensions; // list of extension names enabling the function
137 };
138
139 EProfile EDesktopProfile = static_cast<EProfile>(ENoProfile | ECoreProfile | ECompatibilityProfile);
140
141 // Declare pointers to put into the table for versioning.
142 const Versioning Es300Desktop130Version[] = { { EEsProfile, 0, 300, 0, nullptr },
143 { EDesktopProfile, 0, 130, 0, nullptr },
144 { EBadProfile } };
145 const Versioning* Es300Desktop130 = &Es300Desktop130Version[0];
146
147 const Versioning Es310Desktop400Version[] = { { EEsProfile, 0, 310, 0, nullptr },
148 { EDesktopProfile, 0, 400, 0, nullptr },
149 { EBadProfile } };
150 const Versioning* Es310Desktop400 = &Es310Desktop400Version[0];
151
152 const Versioning Es310Desktop450Version[] = { { EEsProfile, 0, 310, 0, nullptr },
153 { EDesktopProfile, 0, 450, 0, nullptr },
154 { EBadProfile } };
155 const Versioning* Es310Desktop450 = &Es310Desktop450Version[0];
156
157 // The main descriptor of what a set of function prototypes can look like, and
158 // a pointer to extra versioning information, when needed.
159 struct BuiltInFunction {
160 TOperator op; // operator to map the name to
161 const char* name; // function name
162 int numArguments; // number of arguments (overloads with varying arguments need different entries)
163 ArgType types; // ArgType mask
164 ArgClass classes; // the ways this particular function entry manifests
165 const Versioning* versioning; // nullptr means always a valid version
166 };
167
168 // The tables can have the same built-in function name more than one time,
169 // but the exact same prototype must be indicated at most once.
170 // The prototypes that get declared are the union of all those indicated.
171 // This is important when different releases add new prototypes for the same name.
172 // It also also congnitively simpler tiling of the prototype space.
173 // In practice, most names can be fully represented with one entry.
174 //
175 // Table is terminated by an OpNull TOperator.
176
177 const BuiltInFunction BaseFunctions[] = {
178 // TOperator, name, arg-count, ArgType, ArgClass, versioning
179 // --------- ---- --------- ------- -------- ----------
180 { EOpRadians, "radians", 1, TypeF, ClassRegular, nullptr },
181 { EOpDegrees, "degrees", 1, TypeF, ClassRegular, nullptr },
182 { EOpSin, "sin", 1, TypeF, ClassRegular, nullptr },
183 { EOpCos, "cos", 1, TypeF, ClassRegular, nullptr },
184 { EOpTan, "tan", 1, TypeF, ClassRegular, nullptr },
185 { EOpAsin, "asin", 1, TypeF, ClassRegular, nullptr },
186 { EOpAcos, "acos", 1, TypeF, ClassRegular, nullptr },
187 { EOpAtan, "atan", 2, TypeF, ClassRegular, nullptr },
188 { EOpAtan, "atan", 1, TypeF, ClassRegular, nullptr },
189 { EOpPow, "pow", 2, TypeF, ClassRegular, nullptr },
190 { EOpExp, "exp", 1, TypeF, ClassRegular, nullptr },
191 { EOpLog, "log", 1, TypeF, ClassRegular, nullptr },
192 { EOpExp2, "exp2", 1, TypeF, ClassRegular, nullptr },
193 { EOpLog2, "log2", 1, TypeF, ClassRegular, nullptr },
194 { EOpSqrt, "sqrt", 1, TypeF, ClassRegular, nullptr },
195 { EOpInverseSqrt, "inversesqrt", 1, TypeF, ClassRegular, nullptr },
196 { EOpAbs, "abs", 1, TypeF, ClassRegular, nullptr },
197 { EOpSign, "sign", 1, TypeF, ClassRegular, nullptr },
198 { EOpFloor, "floor", 1, TypeF, ClassRegular, nullptr },
199 { EOpCeil, "ceil", 1, TypeF, ClassRegular, nullptr },
200 { EOpFract, "fract", 1, TypeF, ClassRegular, nullptr },
201 { EOpMod, "mod", 2, TypeF, ClassLS, nullptr },
202 { EOpMin, "min", 2, TypeF, ClassLS, nullptr },
203 { EOpMax, "max", 2, TypeF, ClassLS, nullptr },
204 { EOpClamp, "clamp", 3, TypeF, ClassLS2, nullptr },
205 { EOpMix, "mix", 3, TypeF, ClassLS, nullptr },
206 { EOpStep, "step", 2, TypeF, ClassFS, nullptr },
207 { EOpSmoothStep, "smoothstep", 3, TypeF, ClassFS2, nullptr },
208 { EOpNormalize, "normalize", 1, TypeF, ClassRegular, nullptr },
209 { EOpFaceForward, "faceforward", 3, TypeF, ClassRegular, nullptr },
210 { EOpReflect, "reflect", 2, TypeF, ClassRegular, nullptr },
211 { EOpRefract, "refract", 3, TypeF, ClassXLS, nullptr },
212 { EOpLength, "length", 1, TypeF, ClassRS, nullptr },
213 { EOpDistance, "distance", 2, TypeF, ClassRS, nullptr },
214 { EOpDot, "dot", 2, TypeF, ClassRS, nullptr },
215 { EOpCross, "cross", 2, TypeF, ClassV3, nullptr },
216 { EOpLessThan, "lessThan", 2, TypeFI, ClassBNS, nullptr },
217 { EOpLessThanEqual, "lessThanEqual", 2, TypeFI, ClassBNS, nullptr },
218 { EOpGreaterThan, "greaterThan", 2, TypeFI, ClassBNS, nullptr },
219 { EOpGreaterThanEqual, "greaterThanEqual", 2, TypeFI, ClassBNS, nullptr },
220 { EOpVectorEqual, "equal", 2, TypeFIB, ClassBNS, nullptr },
221 { EOpVectorNotEqual, "notEqual", 2, TypeFIB, ClassBNS, nullptr },
222 { EOpAny, "any", 1, TypeB, ClassRSNS, nullptr },
223 { EOpAll, "all", 1, TypeB, ClassRSNS, nullptr },
224 { EOpVectorLogicalNot, "not", 1, TypeB, ClassNS, nullptr },
225 { EOpSinh, "sinh", 1, TypeF, ClassRegular, Es300Desktop130 },
226 { EOpCosh, "cosh", 1, TypeF, ClassRegular, Es300Desktop130 },
227 { EOpTanh, "tanh", 1, TypeF, ClassRegular, Es300Desktop130 },
228 { EOpAsinh, "asinh", 1, TypeF, ClassRegular, Es300Desktop130 },
229 { EOpAcosh, "acosh", 1, TypeF, ClassRegular, Es300Desktop130 },
230 { EOpAtanh, "atanh", 1, TypeF, ClassRegular, Es300Desktop130 },
231 { EOpAbs, "abs", 1, TypeI, ClassRegular, Es300Desktop130 },
232 { EOpSign, "sign", 1, TypeI, ClassRegular, Es300Desktop130 },
233 { EOpTrunc, "trunc", 1, TypeF, ClassRegular, Es300Desktop130 },
234 { EOpRound, "round", 1, TypeF, ClassRegular, Es300Desktop130 },
235 { EOpRoundEven, "roundEven", 1, TypeF, ClassRegular, Es300Desktop130 },
236 { EOpModf, "modf", 2, TypeF, ClassLO, Es300Desktop130 },
237 { EOpMin, "min", 2, TypeIU, ClassLS, Es300Desktop130 },
238 { EOpMax, "max", 2, TypeIU, ClassLS, Es300Desktop130 },
239 { EOpClamp, "clamp", 3, TypeIU, ClassLS2, Es300Desktop130 },
240 { EOpMix, "mix", 3, TypeF, ClassLB, Es300Desktop130 },
241 { EOpIsInf, "isinf", 1, TypeF, ClassB, Es300Desktop130 },
242 { EOpIsNan, "isnan", 1, TypeF, ClassB, Es300Desktop130 },
243 { EOpLessThan, "lessThan", 2, TypeU, ClassBNS, Es300Desktop130 },
244 { EOpLessThanEqual, "lessThanEqual", 2, TypeU, ClassBNS, Es300Desktop130 },
245 { EOpGreaterThan, "greaterThan", 2, TypeU, ClassBNS, Es300Desktop130 },
246 { EOpGreaterThanEqual, "greaterThanEqual", 2, TypeU, ClassBNS, Es300Desktop130 },
247 { EOpVectorEqual, "equal", 2, TypeU, ClassBNS, Es300Desktop130 },
248 { EOpVectorNotEqual, "notEqual", 2, TypeU, ClassBNS, Es300Desktop130 },
249 { EOpAtomicAdd, "atomicAdd", 2, TypeIU, ClassV1FIOCV, Es310Desktop400 },
250 { EOpAtomicMin, "atomicMin", 2, TypeIU, ClassV1FIOCV, Es310Desktop400 },
251 { EOpAtomicMax, "atomicMax", 2, TypeIU, ClassV1FIOCV, Es310Desktop400 },
252 { EOpAtomicAnd, "atomicAnd", 2, TypeIU, ClassV1FIOCV, Es310Desktop400 },
253 { EOpAtomicOr, "atomicOr", 2, TypeIU, ClassV1FIOCV, Es310Desktop400 },
254 { EOpAtomicXor, "atomicXor", 2, TypeIU, ClassV1FIOCV, Es310Desktop400 },
255 { EOpAtomicExchange, "atomicExchange", 2, TypeIU, ClassV1FIOCV, Es310Desktop400 },
256 { EOpAtomicCompSwap, "atomicCompSwap", 3, TypeIU, ClassV1FIOCV, Es310Desktop400 },
257 { EOpMix, "mix", 3, TypeB, ClassRegular, Es310Desktop450 },
258 { EOpMix, "mix", 3, TypeIU, ClassLB, Es310Desktop450 },
259
260 { EOpNull }
261 };
262
263 const BuiltInFunction DerivativeFunctions[] = {
264 { EOpDPdx, "dFdx", 1, TypeF, ClassRegular, nullptr },
265 { EOpDPdy, "dFdy", 1, TypeF, ClassRegular, nullptr },
266 { EOpFwidth, "fwidth", 1, TypeF, ClassRegular, nullptr },
267 { EOpNull }
268 };
269
270 // For functions declared some other way, but still use the table to relate to operator.
271 struct CustomFunction {
272 TOperator op; // operator to map the name to
273 const char* name; // function name
274 const Versioning* versioning; // nullptr means always a valid version
275 };
276
277 const CustomFunction CustomFunctions[] = {
278 { EOpBarrier, "barrier", nullptr },
279 { EOpMemoryBarrierShared, "memoryBarrierShared", nullptr },
280 { EOpGroupMemoryBarrier, "groupMemoryBarrier", nullptr },
281 { EOpMemoryBarrier, "memoryBarrier", nullptr },
282 { EOpMemoryBarrierBuffer, "memoryBarrierBuffer", nullptr },
283
284 { EOpPackSnorm2x16, "packSnorm2x16", nullptr },
285 { EOpUnpackSnorm2x16, "unpackSnorm2x16", nullptr },
286 { EOpPackUnorm2x16, "packUnorm2x16", nullptr },
287 { EOpUnpackUnorm2x16, "unpackUnorm2x16", nullptr },
288 { EOpPackHalf2x16, "packHalf2x16", nullptr },
289 { EOpUnpackHalf2x16, "unpackHalf2x16", nullptr },
290
291 { EOpMul, "matrixCompMult", nullptr },
292 { EOpOuterProduct, "outerProduct", nullptr },
293 { EOpTranspose, "transpose", nullptr },
294 { EOpDeterminant, "determinant", nullptr },
295 { EOpMatrixInverse, "inverse", nullptr },
296 { EOpFloatBitsToInt, "floatBitsToInt", nullptr },
297 { EOpFloatBitsToUint, "floatBitsToUint", nullptr },
298 { EOpIntBitsToFloat, "intBitsToFloat", nullptr },
299 { EOpUintBitsToFloat, "uintBitsToFloat", nullptr },
300
301 { EOpTextureQuerySize, "textureSize", nullptr },
302 { EOpTextureQueryLod, "textureQueryLod", nullptr },
303 { EOpTextureQueryLod, "textureQueryLOD", nullptr }, // extension GL_ARB_texture_query_lod
304 { EOpTextureQueryLevels, "textureQueryLevels", nullptr },
305 { EOpTextureQuerySamples, "textureSamples", nullptr },
306 { EOpTexture, "texture", nullptr },
307 { EOpTextureProj, "textureProj", nullptr },
308 { EOpTextureLod, "textureLod", nullptr },
309 { EOpTextureOffset, "textureOffset", nullptr },
310 { EOpTextureFetch, "texelFetch", nullptr },
311 { EOpTextureFetchOffset, "texelFetchOffset", nullptr },
312 { EOpTextureProjOffset, "textureProjOffset", nullptr },
313 { EOpTextureLodOffset, "textureLodOffset", nullptr },
314 { EOpTextureProjLod, "textureProjLod", nullptr },
315 { EOpTextureProjLodOffset, "textureProjLodOffset", nullptr },
316 { EOpTextureGrad, "textureGrad", nullptr },
317 { EOpTextureGradOffset, "textureGradOffset", nullptr },
318 { EOpTextureProjGrad, "textureProjGrad", nullptr },
319 { EOpTextureProjGradOffset, "textureProjGradOffset", nullptr },
320
321 { EOpNull }
322 };
323
324 // For the given table of functions, add all the indicated prototypes for each
325 // one, to be returned in the passed in decls.
AddTabledBuiltin(TString & decls,const BuiltInFunction & function)326 void AddTabledBuiltin(TString& decls, const BuiltInFunction& function)
327 {
328 const auto isScalarType = [](int type) { return (type & TypeStringColumnMask) == 0; };
329
330 // loop across these two:
331 // 0: the varying arg set, and
332 // 1: the fixed scalar args
333 const ArgClass ClassFixed = (ArgClass)(ClassLS | ClassXLS | ClassLS2 | ClassFS | ClassFS2);
334 for (int fixed = 0; fixed < ((function.classes & ClassFixed) > 0 ? 2 : 1); ++fixed) {
335
336 if (fixed == 0 && (function.classes & ClassXLS))
337 continue;
338
339 // walk the type strings in TypeString[]
340 for (int type = 0; type < TypeStringCount; ++type) {
341 // skip types not selected: go from type to row number to type bit
342 if ((function.types & (1 << (type >> TypeStringRowShift))) == 0)
343 continue;
344
345 // if we aren't on a scalar, and should be, skip
346 if ((function.classes & ClassV1) && !isScalarType(type))
347 continue;
348
349 // if we aren't on a 3-vector, and should be, skip
350 if ((function.classes & ClassV3) && (type & TypeStringColumnMask) != 2)
351 continue;
352
353 // skip replication of all arg scalars between the varying arg set and the fixed args
354 if (fixed == 1 && type == (type & TypeStringScalarMask) && (function.classes & ClassXLS) == 0)
355 continue;
356
357 // skip scalars when we are told to
358 if ((function.classes & ClassNS) && isScalarType(type))
359 continue;
360
361 // return type
362 if (function.classes & ClassB)
363 decls.append(TypeString[type & TypeStringColumnMask]);
364 else if (function.classes & ClassRS)
365 decls.append(TypeString[type & TypeStringScalarMask]);
366 else
367 decls.append(TypeString[type]);
368 decls.append(" ");
369 decls.append(function.name);
370 decls.append("(");
371
372 // arguments
373 for (int arg = 0; arg < function.numArguments; ++arg) {
374 if (arg == function.numArguments - 1 && (function.classes & ClassLO))
375 decls.append("out ");
376 if (arg == 0) {
377 if (function.classes & ClassCV)
378 decls.append("coherent volatile ");
379 if (function.classes & ClassFIO)
380 decls.append("inout ");
381 if (function.classes & ClassFO)
382 decls.append("out ");
383 }
384 if ((function.classes & ClassLB) && arg == function.numArguments - 1)
385 decls.append(TypeString[type & TypeStringColumnMask]);
386 else if (fixed && ((arg == function.numArguments - 1 && (function.classes & (ClassLS | ClassXLS |
387 ClassLS2))) ||
388 (arg == function.numArguments - 2 && (function.classes & ClassLS2)) ||
389 (arg == 0 && (function.classes & (ClassFS | ClassFS2))) ||
390 (arg == 1 && (function.classes & ClassFS2))))
391 decls.append(TypeString[type & TypeStringScalarMask]);
392 else
393 decls.append(TypeString[type]);
394 if (arg < function.numArguments - 1)
395 decls.append(",");
396 }
397 decls.append(");\n");
398 }
399 }
400 }
401
402 // See if the tabled versioning information allows the current version.
ValidVersion(const BuiltInFunction & function,int version,EProfile profile,const SpvVersion &)403 bool ValidVersion(const BuiltInFunction& function, int version, EProfile profile, const SpvVersion& /* spVersion */)
404 {
405 // nullptr means always valid
406 if (function.versioning == nullptr)
407 return true;
408
409 // check for what is said about our current profile
410 for (const Versioning* v = function.versioning; v->profiles != EBadProfile; ++v) {
411 if ((v->profiles & profile) != 0) {
412 if (v->minCoreVersion <= version || (v->numExtensions > 0 && v->minExtendedVersion <= version))
413 return true;
414 }
415 }
416
417 return false;
418 }
419
420 // Relate a single table of built-ins to their AST operator.
421 // This can get called redundantly (especially for the common built-ins, when
422 // called once per stage). This is a performance issue only, not a correctness
423 // concern. It is done for quality arising from simplicity, as there are subtleties
424 // to get correct if instead trying to do it surgically.
425 template<class FunctionT>
RelateTabledBuiltins(const FunctionT * functions,TSymbolTable & symbolTable)426 void RelateTabledBuiltins(const FunctionT* functions, TSymbolTable& symbolTable)
427 {
428 while (functions->op != EOpNull) {
429 symbolTable.relateToOperator(functions->name, functions->op);
430 ++functions;
431 }
432 }
433
434 } // end anonymous namespace
435
436 // Add declarations for all tables of built-in functions.
addTabledBuiltins(int version,EProfile profile,const SpvVersion & spvVersion)437 void TBuiltIns::addTabledBuiltins(int version, EProfile profile, const SpvVersion& spvVersion)
438 {
439 const auto forEachFunction = [&](TString& decls, const BuiltInFunction* function) {
440 while (function->op != EOpNull) {
441 if (ValidVersion(*function, version, profile, spvVersion))
442 AddTabledBuiltin(decls, *function);
443 ++function;
444 }
445 };
446
447 forEachFunction(commonBuiltins, BaseFunctions);
448 forEachFunction(stageBuiltins[EShLangFragment], DerivativeFunctions);
449
450 if ((profile == EEsProfile && version >= 320) || (profile != EEsProfile && version >= 450))
451 forEachFunction(stageBuiltins[EShLangCompute], DerivativeFunctions);
452 }
453
454 // Relate all tables of built-ins to the AST operators.
relateTabledBuiltins(int,EProfile,const SpvVersion &,EShLanguage,TSymbolTable & symbolTable)455 void TBuiltIns::relateTabledBuiltins(int /* version */, EProfile /* profile */, const SpvVersion& /* spvVersion */, EShLanguage /* stage */, TSymbolTable& symbolTable)
456 {
457 RelateTabledBuiltins(BaseFunctions, symbolTable);
458 RelateTabledBuiltins(DerivativeFunctions, symbolTable);
459 RelateTabledBuiltins(CustomFunctions, symbolTable);
460 }
461
IncludeLegacy(int version,EProfile profile,const SpvVersion & spvVersion)462 inline bool IncludeLegacy(int version, EProfile profile, const SpvVersion& spvVersion)
463 {
464 return profile != EEsProfile && (version <= 130 || (spvVersion.spv == 0 && version == 140 && ARBCompatibility) ||
465 profile == ECompatibilityProfile);
466 }
467
468 // Construct TBuiltInParseables base class. This can be used for language-common constructs.
TBuiltInParseables()469 TBuiltInParseables::TBuiltInParseables()
470 {
471 }
472
473 // Destroy TBuiltInParseables.
~TBuiltInParseables()474 TBuiltInParseables::~TBuiltInParseables()
475 {
476 }
477
TBuiltIns()478 TBuiltIns::TBuiltIns()
479 {
480 // Set up textual representations for making all the permutations
481 // of texturing/imaging functions.
482 prefixes[EbtFloat] = "";
483 prefixes[EbtInt] = "i";
484 prefixes[EbtUint] = "u";
485 prefixes[EbtFloat16] = "f16";
486 prefixes[EbtInt8] = "i8";
487 prefixes[EbtUint8] = "u8";
488 prefixes[EbtInt16] = "i16";
489 prefixes[EbtUint16] = "u16";
490 prefixes[EbtInt64] = "i64";
491 prefixes[EbtUint64] = "u64";
492
493 postfixes[2] = "2";
494 postfixes[3] = "3";
495 postfixes[4] = "4";
496
497 // Map from symbolic class of texturing dimension to numeric dimensions.
498 dimMap[Esd2D] = 2;
499 dimMap[Esd3D] = 3;
500 dimMap[EsdCube] = 3;
501 dimMap[Esd1D] = 1;
502 dimMap[EsdRect] = 2;
503 dimMap[EsdBuffer] = 1;
504 dimMap[EsdSubpass] = 2; // potentially unused for now
505 dimMap[EsdAttachmentEXT] = 2; // potentially unused for now
506 }
507
~TBuiltIns()508 TBuiltIns::~TBuiltIns()
509 {
510 }
511
512
513 //
514 // Add all context-independent built-in functions and variables that are present
515 // for the given version and profile. Share common ones across stages, otherwise
516 // make stage-specific entries.
517 //
518 // Most built-ins variables can be added as simple text strings. Some need to
519 // be added programmatically, which is done later in IdentifyBuiltIns() below.
520 //
initialize(int version,EProfile profile,const SpvVersion & spvVersion)521 void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvVersion)
522 {
523 addTabledBuiltins(version, profile, spvVersion);
524
525 //============================================================================
526 //
527 // Prototypes for built-in functions used repeatly by different shaders
528 //
529 //============================================================================
530
531 //
532 // Derivatives Functions.
533 //
534 TString derivativeControls (
535 "float dFdxFine(float p);"
536 "vec2 dFdxFine(vec2 p);"
537 "vec3 dFdxFine(vec3 p);"
538 "vec4 dFdxFine(vec4 p);"
539
540 "float dFdyFine(float p);"
541 "vec2 dFdyFine(vec2 p);"
542 "vec3 dFdyFine(vec3 p);"
543 "vec4 dFdyFine(vec4 p);"
544
545 "float fwidthFine(float p);"
546 "vec2 fwidthFine(vec2 p);"
547 "vec3 fwidthFine(vec3 p);"
548 "vec4 fwidthFine(vec4 p);"
549
550 "float dFdxCoarse(float p);"
551 "vec2 dFdxCoarse(vec2 p);"
552 "vec3 dFdxCoarse(vec3 p);"
553 "vec4 dFdxCoarse(vec4 p);"
554
555 "float dFdyCoarse(float p);"
556 "vec2 dFdyCoarse(vec2 p);"
557 "vec3 dFdyCoarse(vec3 p);"
558 "vec4 dFdyCoarse(vec4 p);"
559
560 "float fwidthCoarse(float p);"
561 "vec2 fwidthCoarse(vec2 p);"
562 "vec3 fwidthCoarse(vec3 p);"
563 "vec4 fwidthCoarse(vec4 p);"
564 );
565
566 TString derivativesAndControl16bits (
567 "float16_t dFdx(float16_t);"
568 "f16vec2 dFdx(f16vec2);"
569 "f16vec3 dFdx(f16vec3);"
570 "f16vec4 dFdx(f16vec4);"
571
572 "float16_t dFdy(float16_t);"
573 "f16vec2 dFdy(f16vec2);"
574 "f16vec3 dFdy(f16vec3);"
575 "f16vec4 dFdy(f16vec4);"
576
577 "float16_t dFdxFine(float16_t);"
578 "f16vec2 dFdxFine(f16vec2);"
579 "f16vec3 dFdxFine(f16vec3);"
580 "f16vec4 dFdxFine(f16vec4);"
581
582 "float16_t dFdyFine(float16_t);"
583 "f16vec2 dFdyFine(f16vec2);"
584 "f16vec3 dFdyFine(f16vec3);"
585 "f16vec4 dFdyFine(f16vec4);"
586
587 "float16_t dFdxCoarse(float16_t);"
588 "f16vec2 dFdxCoarse(f16vec2);"
589 "f16vec3 dFdxCoarse(f16vec3);"
590 "f16vec4 dFdxCoarse(f16vec4);"
591
592 "float16_t dFdyCoarse(float16_t);"
593 "f16vec2 dFdyCoarse(f16vec2);"
594 "f16vec3 dFdyCoarse(f16vec3);"
595 "f16vec4 dFdyCoarse(f16vec4);"
596
597 "float16_t fwidth(float16_t);"
598 "f16vec2 fwidth(f16vec2);"
599 "f16vec3 fwidth(f16vec3);"
600 "f16vec4 fwidth(f16vec4);"
601
602 "float16_t fwidthFine(float16_t);"
603 "f16vec2 fwidthFine(f16vec2);"
604 "f16vec3 fwidthFine(f16vec3);"
605 "f16vec4 fwidthFine(f16vec4);"
606
607 "float16_t fwidthCoarse(float16_t);"
608 "f16vec2 fwidthCoarse(f16vec2);"
609 "f16vec3 fwidthCoarse(f16vec3);"
610 "f16vec4 fwidthCoarse(f16vec4);"
611 );
612
613 TString derivativesAndControl64bits (
614 "float64_t dFdx(float64_t);"
615 "f64vec2 dFdx(f64vec2);"
616 "f64vec3 dFdx(f64vec3);"
617 "f64vec4 dFdx(f64vec4);"
618
619 "float64_t dFdy(float64_t);"
620 "f64vec2 dFdy(f64vec2);"
621 "f64vec3 dFdy(f64vec3);"
622 "f64vec4 dFdy(f64vec4);"
623
624 "float64_t dFdxFine(float64_t);"
625 "f64vec2 dFdxFine(f64vec2);"
626 "f64vec3 dFdxFine(f64vec3);"
627 "f64vec4 dFdxFine(f64vec4);"
628
629 "float64_t dFdyFine(float64_t);"
630 "f64vec2 dFdyFine(f64vec2);"
631 "f64vec3 dFdyFine(f64vec3);"
632 "f64vec4 dFdyFine(f64vec4);"
633
634 "float64_t dFdxCoarse(float64_t);"
635 "f64vec2 dFdxCoarse(f64vec2);"
636 "f64vec3 dFdxCoarse(f64vec3);"
637 "f64vec4 dFdxCoarse(f64vec4);"
638
639 "float64_t dFdyCoarse(float64_t);"
640 "f64vec2 dFdyCoarse(f64vec2);"
641 "f64vec3 dFdyCoarse(f64vec3);"
642 "f64vec4 dFdyCoarse(f64vec4);"
643
644 "float64_t fwidth(float64_t);"
645 "f64vec2 fwidth(f64vec2);"
646 "f64vec3 fwidth(f64vec3);"
647 "f64vec4 fwidth(f64vec4);"
648
649 "float64_t fwidthFine(float64_t);"
650 "f64vec2 fwidthFine(f64vec2);"
651 "f64vec3 fwidthFine(f64vec3);"
652 "f64vec4 fwidthFine(f64vec4);"
653
654 "float64_t fwidthCoarse(float64_t);"
655 "f64vec2 fwidthCoarse(f64vec2);"
656 "f64vec3 fwidthCoarse(f64vec3);"
657 "f64vec4 fwidthCoarse(f64vec4);"
658 );
659
660 //============================================================================
661 //
662 // Prototypes for built-in functions seen by both vertex and fragment shaders.
663 //
664 //============================================================================
665
666 //
667 // double functions added to desktop 4.00, but not fma, frexp, ldexp, or pack/unpack
668 //
669 if (profile != EEsProfile && version >= 150) { // ARB_gpu_shader_fp64
670 commonBuiltins.append(
671
672 "double sqrt(double);"
673 "dvec2 sqrt(dvec2);"
674 "dvec3 sqrt(dvec3);"
675 "dvec4 sqrt(dvec4);"
676
677 "double inversesqrt(double);"
678 "dvec2 inversesqrt(dvec2);"
679 "dvec3 inversesqrt(dvec3);"
680 "dvec4 inversesqrt(dvec4);"
681
682 "double abs(double);"
683 "dvec2 abs(dvec2);"
684 "dvec3 abs(dvec3);"
685 "dvec4 abs(dvec4);"
686
687 "double sign(double);"
688 "dvec2 sign(dvec2);"
689 "dvec3 sign(dvec3);"
690 "dvec4 sign(dvec4);"
691
692 "double floor(double);"
693 "dvec2 floor(dvec2);"
694 "dvec3 floor(dvec3);"
695 "dvec4 floor(dvec4);"
696
697 "double trunc(double);"
698 "dvec2 trunc(dvec2);"
699 "dvec3 trunc(dvec3);"
700 "dvec4 trunc(dvec4);"
701
702 "double round(double);"
703 "dvec2 round(dvec2);"
704 "dvec3 round(dvec3);"
705 "dvec4 round(dvec4);"
706
707 "double roundEven(double);"
708 "dvec2 roundEven(dvec2);"
709 "dvec3 roundEven(dvec3);"
710 "dvec4 roundEven(dvec4);"
711
712 "double ceil(double);"
713 "dvec2 ceil(dvec2);"
714 "dvec3 ceil(dvec3);"
715 "dvec4 ceil(dvec4);"
716
717 "double fract(double);"
718 "dvec2 fract(dvec2);"
719 "dvec3 fract(dvec3);"
720 "dvec4 fract(dvec4);"
721
722 "double mod(double, double);"
723 "dvec2 mod(dvec2 , double);"
724 "dvec3 mod(dvec3 , double);"
725 "dvec4 mod(dvec4 , double);"
726 "dvec2 mod(dvec2 , dvec2);"
727 "dvec3 mod(dvec3 , dvec3);"
728 "dvec4 mod(dvec4 , dvec4);"
729
730 "double modf(double, out double);"
731 "dvec2 modf(dvec2, out dvec2);"
732 "dvec3 modf(dvec3, out dvec3);"
733 "dvec4 modf(dvec4, out dvec4);"
734
735 "double min(double, double);"
736 "dvec2 min(dvec2, double);"
737 "dvec3 min(dvec3, double);"
738 "dvec4 min(dvec4, double);"
739 "dvec2 min(dvec2, dvec2);"
740 "dvec3 min(dvec3, dvec3);"
741 "dvec4 min(dvec4, dvec4);"
742
743 "double max(double, double);"
744 "dvec2 max(dvec2 , double);"
745 "dvec3 max(dvec3 , double);"
746 "dvec4 max(dvec4 , double);"
747 "dvec2 max(dvec2 , dvec2);"
748 "dvec3 max(dvec3 , dvec3);"
749 "dvec4 max(dvec4 , dvec4);"
750
751 "double clamp(double, double, double);"
752 "dvec2 clamp(dvec2 , double, double);"
753 "dvec3 clamp(dvec3 , double, double);"
754 "dvec4 clamp(dvec4 , double, double);"
755 "dvec2 clamp(dvec2 , dvec2 , dvec2);"
756 "dvec3 clamp(dvec3 , dvec3 , dvec3);"
757 "dvec4 clamp(dvec4 , dvec4 , dvec4);"
758
759 "double mix(double, double, double);"
760 "dvec2 mix(dvec2, dvec2, double);"
761 "dvec3 mix(dvec3, dvec3, double);"
762 "dvec4 mix(dvec4, dvec4, double);"
763 "dvec2 mix(dvec2, dvec2, dvec2);"
764 "dvec3 mix(dvec3, dvec3, dvec3);"
765 "dvec4 mix(dvec4, dvec4, dvec4);"
766 "double mix(double, double, bool);"
767 "dvec2 mix(dvec2, dvec2, bvec2);"
768 "dvec3 mix(dvec3, dvec3, bvec3);"
769 "dvec4 mix(dvec4, dvec4, bvec4);"
770
771 "double step(double, double);"
772 "dvec2 step(dvec2 , dvec2);"
773 "dvec3 step(dvec3 , dvec3);"
774 "dvec4 step(dvec4 , dvec4);"
775 "dvec2 step(double, dvec2);"
776 "dvec3 step(double, dvec3);"
777 "dvec4 step(double, dvec4);"
778
779 "double smoothstep(double, double, double);"
780 "dvec2 smoothstep(dvec2 , dvec2 , dvec2);"
781 "dvec3 smoothstep(dvec3 , dvec3 , dvec3);"
782 "dvec4 smoothstep(dvec4 , dvec4 , dvec4);"
783 "dvec2 smoothstep(double, double, dvec2);"
784 "dvec3 smoothstep(double, double, dvec3);"
785 "dvec4 smoothstep(double, double, dvec4);"
786
787 "bool isnan(double);"
788 "bvec2 isnan(dvec2);"
789 "bvec3 isnan(dvec3);"
790 "bvec4 isnan(dvec4);"
791
792 "bool isinf(double);"
793 "bvec2 isinf(dvec2);"
794 "bvec3 isinf(dvec3);"
795 "bvec4 isinf(dvec4);"
796
797 "double length(double);"
798 "double length(dvec2);"
799 "double length(dvec3);"
800 "double length(dvec4);"
801
802 "double distance(double, double);"
803 "double distance(dvec2 , dvec2);"
804 "double distance(dvec3 , dvec3);"
805 "double distance(dvec4 , dvec4);"
806
807 "double dot(double, double);"
808 "double dot(dvec2 , dvec2);"
809 "double dot(dvec3 , dvec3);"
810 "double dot(dvec4 , dvec4);"
811
812 "dvec3 cross(dvec3, dvec3);"
813
814 "double normalize(double);"
815 "dvec2 normalize(dvec2);"
816 "dvec3 normalize(dvec3);"
817 "dvec4 normalize(dvec4);"
818
819 "double faceforward(double, double, double);"
820 "dvec2 faceforward(dvec2, dvec2, dvec2);"
821 "dvec3 faceforward(dvec3, dvec3, dvec3);"
822 "dvec4 faceforward(dvec4, dvec4, dvec4);"
823
824 "double reflect(double, double);"
825 "dvec2 reflect(dvec2 , dvec2 );"
826 "dvec3 reflect(dvec3 , dvec3 );"
827 "dvec4 reflect(dvec4 , dvec4 );"
828
829 "double refract(double, double, double);"
830 "dvec2 refract(dvec2 , dvec2 , double);"
831 "dvec3 refract(dvec3 , dvec3 , double);"
832 "dvec4 refract(dvec4 , dvec4 , double);"
833
834 "dmat2 matrixCompMult(dmat2, dmat2);"
835 "dmat3 matrixCompMult(dmat3, dmat3);"
836 "dmat4 matrixCompMult(dmat4, dmat4);"
837 "dmat2x3 matrixCompMult(dmat2x3, dmat2x3);"
838 "dmat2x4 matrixCompMult(dmat2x4, dmat2x4);"
839 "dmat3x2 matrixCompMult(dmat3x2, dmat3x2);"
840 "dmat3x4 matrixCompMult(dmat3x4, dmat3x4);"
841 "dmat4x2 matrixCompMult(dmat4x2, dmat4x2);"
842 "dmat4x3 matrixCompMult(dmat4x3, dmat4x3);"
843
844 "dmat2 outerProduct(dvec2, dvec2);"
845 "dmat3 outerProduct(dvec3, dvec3);"
846 "dmat4 outerProduct(dvec4, dvec4);"
847 "dmat2x3 outerProduct(dvec3, dvec2);"
848 "dmat3x2 outerProduct(dvec2, dvec3);"
849 "dmat2x4 outerProduct(dvec4, dvec2);"
850 "dmat4x2 outerProduct(dvec2, dvec4);"
851 "dmat3x4 outerProduct(dvec4, dvec3);"
852 "dmat4x3 outerProduct(dvec3, dvec4);"
853
854 "dmat2 transpose(dmat2);"
855 "dmat3 transpose(dmat3);"
856 "dmat4 transpose(dmat4);"
857 "dmat2x3 transpose(dmat3x2);"
858 "dmat3x2 transpose(dmat2x3);"
859 "dmat2x4 transpose(dmat4x2);"
860 "dmat4x2 transpose(dmat2x4);"
861 "dmat3x4 transpose(dmat4x3);"
862 "dmat4x3 transpose(dmat3x4);"
863
864 "double determinant(dmat2);"
865 "double determinant(dmat3);"
866 "double determinant(dmat4);"
867
868 "dmat2 inverse(dmat2);"
869 "dmat3 inverse(dmat3);"
870 "dmat4 inverse(dmat4);"
871
872 "bvec2 lessThan(dvec2, dvec2);"
873 "bvec3 lessThan(dvec3, dvec3);"
874 "bvec4 lessThan(dvec4, dvec4);"
875
876 "bvec2 lessThanEqual(dvec2, dvec2);"
877 "bvec3 lessThanEqual(dvec3, dvec3);"
878 "bvec4 lessThanEqual(dvec4, dvec4);"
879
880 "bvec2 greaterThan(dvec2, dvec2);"
881 "bvec3 greaterThan(dvec3, dvec3);"
882 "bvec4 greaterThan(dvec4, dvec4);"
883
884 "bvec2 greaterThanEqual(dvec2, dvec2);"
885 "bvec3 greaterThanEqual(dvec3, dvec3);"
886 "bvec4 greaterThanEqual(dvec4, dvec4);"
887
888 "bvec2 equal(dvec2, dvec2);"
889 "bvec3 equal(dvec3, dvec3);"
890 "bvec4 equal(dvec4, dvec4);"
891
892 "bvec2 notEqual(dvec2, dvec2);"
893 "bvec3 notEqual(dvec3, dvec3);"
894 "bvec4 notEqual(dvec4, dvec4);"
895
896 "\n");
897 }
898
899 if (profile == EEsProfile && version >= 310) { // Explicit Types
900 commonBuiltins.append(
901
902 "float64_t sqrt(float64_t);"
903 "f64vec2 sqrt(f64vec2);"
904 "f64vec3 sqrt(f64vec3);"
905 "f64vec4 sqrt(f64vec4);"
906
907 "float64_t inversesqrt(float64_t);"
908 "f64vec2 inversesqrt(f64vec2);"
909 "f64vec3 inversesqrt(f64vec3);"
910 "f64vec4 inversesqrt(f64vec4);"
911
912 "float64_t abs(float64_t);"
913 "f64vec2 abs(f64vec2);"
914 "f64vec3 abs(f64vec3);"
915 "f64vec4 abs(f64vec4);"
916
917 "float64_t sign(float64_t);"
918 "f64vec2 sign(f64vec2);"
919 "f64vec3 sign(f64vec3);"
920 "f64vec4 sign(f64vec4);"
921
922 "float64_t floor(float64_t);"
923 "f64vec2 floor(f64vec2);"
924 "f64vec3 floor(f64vec3);"
925 "f64vec4 floor(f64vec4);"
926
927 "float64_t trunc(float64_t);"
928 "f64vec2 trunc(f64vec2);"
929 "f64vec3 trunc(f64vec3);"
930 "f64vec4 trunc(f64vec4);"
931
932 "float64_t round(float64_t);"
933 "f64vec2 round(f64vec2);"
934 "f64vec3 round(f64vec3);"
935 "f64vec4 round(f64vec4);"
936
937 "float64_t roundEven(float64_t);"
938 "f64vec2 roundEven(f64vec2);"
939 "f64vec3 roundEven(f64vec3);"
940 "f64vec4 roundEven(f64vec4);"
941
942 "float64_t ceil(float64_t);"
943 "f64vec2 ceil(f64vec2);"
944 "f64vec3 ceil(f64vec3);"
945 "f64vec4 ceil(f64vec4);"
946
947 "float64_t fract(float64_t);"
948 "f64vec2 fract(f64vec2);"
949 "f64vec3 fract(f64vec3);"
950 "f64vec4 fract(f64vec4);"
951
952 "float64_t mod(float64_t, float64_t);"
953 "f64vec2 mod(f64vec2 , float64_t);"
954 "f64vec3 mod(f64vec3 , float64_t);"
955 "f64vec4 mod(f64vec4 , float64_t);"
956 "f64vec2 mod(f64vec2 , f64vec2);"
957 "f64vec3 mod(f64vec3 , f64vec3);"
958 "f64vec4 mod(f64vec4 , f64vec4);"
959
960 "float64_t modf(float64_t, out float64_t);"
961 "f64vec2 modf(f64vec2, out f64vec2);"
962 "f64vec3 modf(f64vec3, out f64vec3);"
963 "f64vec4 modf(f64vec4, out f64vec4);"
964
965 "float64_t min(float64_t, float64_t);"
966 "f64vec2 min(f64vec2, float64_t);"
967 "f64vec3 min(f64vec3, float64_t);"
968 "f64vec4 min(f64vec4, float64_t);"
969 "f64vec2 min(f64vec2, f64vec2);"
970 "f64vec3 min(f64vec3, f64vec3);"
971 "f64vec4 min(f64vec4, f64vec4);"
972
973 "float64_t max(float64_t, float64_t);"
974 "f64vec2 max(f64vec2 , float64_t);"
975 "f64vec3 max(f64vec3 , float64_t);"
976 "f64vec4 max(f64vec4 , float64_t);"
977 "f64vec2 max(f64vec2 , f64vec2);"
978 "f64vec3 max(f64vec3 , f64vec3);"
979 "f64vec4 max(f64vec4 , f64vec4);"
980
981 "float64_t clamp(float64_t, float64_t, float64_t);"
982 "f64vec2 clamp(f64vec2 , float64_t, float64_t);"
983 "f64vec3 clamp(f64vec3 , float64_t, float64_t);"
984 "f64vec4 clamp(f64vec4 , float64_t, float64_t);"
985 "f64vec2 clamp(f64vec2 , f64vec2 , f64vec2);"
986 "f64vec3 clamp(f64vec3 , f64vec3 , f64vec3);"
987 "f64vec4 clamp(f64vec4 , f64vec4 , f64vec4);"
988
989 "float64_t mix(float64_t, float64_t, float64_t);"
990 "f64vec2 mix(f64vec2, f64vec2, float64_t);"
991 "f64vec3 mix(f64vec3, f64vec3, float64_t);"
992 "f64vec4 mix(f64vec4, f64vec4, float64_t);"
993 "f64vec2 mix(f64vec2, f64vec2, f64vec2);"
994 "f64vec3 mix(f64vec3, f64vec3, f64vec3);"
995 "f64vec4 mix(f64vec4, f64vec4, f64vec4);"
996 "float64_t mix(float64_t, float64_t, bool);"
997 "f64vec2 mix(f64vec2, f64vec2, bvec2);"
998 "f64vec3 mix(f64vec3, f64vec3, bvec3);"
999 "f64vec4 mix(f64vec4, f64vec4, bvec4);"
1000
1001 "float64_t step(float64_t, float64_t);"
1002 "f64vec2 step(f64vec2 , f64vec2);"
1003 "f64vec3 step(f64vec3 , f64vec3);"
1004 "f64vec4 step(f64vec4 , f64vec4);"
1005 "f64vec2 step(float64_t, f64vec2);"
1006 "f64vec3 step(float64_t, f64vec3);"
1007 "f64vec4 step(float64_t, f64vec4);"
1008
1009 "float64_t smoothstep(float64_t, float64_t, float64_t);"
1010 "f64vec2 smoothstep(f64vec2 , f64vec2 , f64vec2);"
1011 "f64vec3 smoothstep(f64vec3 , f64vec3 , f64vec3);"
1012 "f64vec4 smoothstep(f64vec4 , f64vec4 , f64vec4);"
1013 "f64vec2 smoothstep(float64_t, float64_t, f64vec2);"
1014 "f64vec3 smoothstep(float64_t, float64_t, f64vec3);"
1015 "f64vec4 smoothstep(float64_t, float64_t, f64vec4);"
1016
1017 "float64_t length(float64_t);"
1018 "float64_t length(f64vec2);"
1019 "float64_t length(f64vec3);"
1020 "float64_t length(f64vec4);"
1021
1022 "float64_t distance(float64_t, float64_t);"
1023 "float64_t distance(f64vec2 , f64vec2);"
1024 "float64_t distance(f64vec3 , f64vec3);"
1025 "float64_t distance(f64vec4 , f64vec4);"
1026
1027 "float64_t dot(float64_t, float64_t);"
1028 "float64_t dot(f64vec2 , f64vec2);"
1029 "float64_t dot(f64vec3 , f64vec3);"
1030 "float64_t dot(f64vec4 , f64vec4);"
1031
1032 "f64vec3 cross(f64vec3, f64vec3);"
1033
1034 "float64_t normalize(float64_t);"
1035 "f64vec2 normalize(f64vec2);"
1036 "f64vec3 normalize(f64vec3);"
1037 "f64vec4 normalize(f64vec4);"
1038
1039 "float64_t faceforward(float64_t, float64_t, float64_t);"
1040 "f64vec2 faceforward(f64vec2, f64vec2, f64vec2);"
1041 "f64vec3 faceforward(f64vec3, f64vec3, f64vec3);"
1042 "f64vec4 faceforward(f64vec4, f64vec4, f64vec4);"
1043
1044 "float64_t reflect(float64_t, float64_t);"
1045 "f64vec2 reflect(f64vec2 , f64vec2 );"
1046 "f64vec3 reflect(f64vec3 , f64vec3 );"
1047 "f64vec4 reflect(f64vec4 , f64vec4 );"
1048
1049 "float64_t refract(float64_t, float64_t, float64_t);"
1050 "f64vec2 refract(f64vec2 , f64vec2 , float64_t);"
1051 "f64vec3 refract(f64vec3 , f64vec3 , float64_t);"
1052 "f64vec4 refract(f64vec4 , f64vec4 , float64_t);"
1053
1054 "f64mat2 matrixCompMult(f64mat2, f64mat2);"
1055 "f64mat3 matrixCompMult(f64mat3, f64mat3);"
1056 "f64mat4 matrixCompMult(f64mat4, f64mat4);"
1057 "f64mat2x3 matrixCompMult(f64mat2x3, f64mat2x3);"
1058 "f64mat2x4 matrixCompMult(f64mat2x4, f64mat2x4);"
1059 "f64mat3x2 matrixCompMult(f64mat3x2, f64mat3x2);"
1060 "f64mat3x4 matrixCompMult(f64mat3x4, f64mat3x4);"
1061 "f64mat4x2 matrixCompMult(f64mat4x2, f64mat4x2);"
1062 "f64mat4x3 matrixCompMult(f64mat4x3, f64mat4x3);"
1063
1064 "f64mat2 outerProduct(f64vec2, f64vec2);"
1065 "f64mat3 outerProduct(f64vec3, f64vec3);"
1066 "f64mat4 outerProduct(f64vec4, f64vec4);"
1067 "f64mat2x3 outerProduct(f64vec3, f64vec2);"
1068 "f64mat3x2 outerProduct(f64vec2, f64vec3);"
1069 "f64mat2x4 outerProduct(f64vec4, f64vec2);"
1070 "f64mat4x2 outerProduct(f64vec2, f64vec4);"
1071 "f64mat3x4 outerProduct(f64vec4, f64vec3);"
1072 "f64mat4x3 outerProduct(f64vec3, f64vec4);"
1073
1074 "f64mat2 transpose(f64mat2);"
1075 "f64mat3 transpose(f64mat3);"
1076 "f64mat4 transpose(f64mat4);"
1077 "f64mat2x3 transpose(f64mat3x2);"
1078 "f64mat3x2 transpose(f64mat2x3);"
1079 "f64mat2x4 transpose(f64mat4x2);"
1080 "f64mat4x2 transpose(f64mat2x4);"
1081 "f64mat3x4 transpose(f64mat4x3);"
1082 "f64mat4x3 transpose(f64mat3x4);"
1083
1084 "float64_t determinant(f64mat2);"
1085 "float64_t determinant(f64mat3);"
1086 "float64_t determinant(f64mat4);"
1087
1088 "f64mat2 inverse(f64mat2);"
1089 "f64mat3 inverse(f64mat3);"
1090 "f64mat4 inverse(f64mat4);"
1091
1092 "\n");
1093 }
1094
1095 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 310)) {
1096 commonBuiltins.append(
1097
1098 "int64_t abs(int64_t);"
1099 "i64vec2 abs(i64vec2);"
1100 "i64vec3 abs(i64vec3);"
1101 "i64vec4 abs(i64vec4);"
1102
1103 "int64_t sign(int64_t);"
1104 "i64vec2 sign(i64vec2);"
1105 "i64vec3 sign(i64vec3);"
1106 "i64vec4 sign(i64vec4);"
1107
1108 "int64_t min(int64_t, int64_t);"
1109 "i64vec2 min(i64vec2, int64_t);"
1110 "i64vec3 min(i64vec3, int64_t);"
1111 "i64vec4 min(i64vec4, int64_t);"
1112 "i64vec2 min(i64vec2, i64vec2);"
1113 "i64vec3 min(i64vec3, i64vec3);"
1114 "i64vec4 min(i64vec4, i64vec4);"
1115 "uint64_t min(uint64_t, uint64_t);"
1116 "u64vec2 min(u64vec2, uint64_t);"
1117 "u64vec3 min(u64vec3, uint64_t);"
1118 "u64vec4 min(u64vec4, uint64_t);"
1119 "u64vec2 min(u64vec2, u64vec2);"
1120 "u64vec3 min(u64vec3, u64vec3);"
1121 "u64vec4 min(u64vec4, u64vec4);"
1122
1123 "int64_t max(int64_t, int64_t);"
1124 "i64vec2 max(i64vec2, int64_t);"
1125 "i64vec3 max(i64vec3, int64_t);"
1126 "i64vec4 max(i64vec4, int64_t);"
1127 "i64vec2 max(i64vec2, i64vec2);"
1128 "i64vec3 max(i64vec3, i64vec3);"
1129 "i64vec4 max(i64vec4, i64vec4);"
1130 "uint64_t max(uint64_t, uint64_t);"
1131 "u64vec2 max(u64vec2, uint64_t);"
1132 "u64vec3 max(u64vec3, uint64_t);"
1133 "u64vec4 max(u64vec4, uint64_t);"
1134 "u64vec2 max(u64vec2, u64vec2);"
1135 "u64vec3 max(u64vec3, u64vec3);"
1136 "u64vec4 max(u64vec4, u64vec4);"
1137
1138 "int64_t clamp(int64_t, int64_t, int64_t);"
1139 "i64vec2 clamp(i64vec2, int64_t, int64_t);"
1140 "i64vec3 clamp(i64vec3, int64_t, int64_t);"
1141 "i64vec4 clamp(i64vec4, int64_t, int64_t);"
1142 "i64vec2 clamp(i64vec2, i64vec2, i64vec2);"
1143 "i64vec3 clamp(i64vec3, i64vec3, i64vec3);"
1144 "i64vec4 clamp(i64vec4, i64vec4, i64vec4);"
1145 "uint64_t clamp(uint64_t, uint64_t, uint64_t);"
1146 "u64vec2 clamp(u64vec2, uint64_t, uint64_t);"
1147 "u64vec3 clamp(u64vec3, uint64_t, uint64_t);"
1148 "u64vec4 clamp(u64vec4, uint64_t, uint64_t);"
1149 "u64vec2 clamp(u64vec2, u64vec2, u64vec2);"
1150 "u64vec3 clamp(u64vec3, u64vec3, u64vec3);"
1151 "u64vec4 clamp(u64vec4, u64vec4, u64vec4);"
1152
1153 "int64_t mix(int64_t, int64_t, bool);"
1154 "i64vec2 mix(i64vec2, i64vec2, bvec2);"
1155 "i64vec3 mix(i64vec3, i64vec3, bvec3);"
1156 "i64vec4 mix(i64vec4, i64vec4, bvec4);"
1157 "uint64_t mix(uint64_t, uint64_t, bool);"
1158 "u64vec2 mix(u64vec2, u64vec2, bvec2);"
1159 "u64vec3 mix(u64vec3, u64vec3, bvec3);"
1160 "u64vec4 mix(u64vec4, u64vec4, bvec4);"
1161
1162 "int64_t doubleBitsToInt64(float64_t);"
1163 "i64vec2 doubleBitsToInt64(f64vec2);"
1164 "i64vec3 doubleBitsToInt64(f64vec3);"
1165 "i64vec4 doubleBitsToInt64(f64vec4);"
1166
1167 "uint64_t doubleBitsToUint64(float64_t);"
1168 "u64vec2 doubleBitsToUint64(f64vec2);"
1169 "u64vec3 doubleBitsToUint64(f64vec3);"
1170 "u64vec4 doubleBitsToUint64(f64vec4);"
1171
1172 "float64_t int64BitsToDouble(int64_t);"
1173 "f64vec2 int64BitsToDouble(i64vec2);"
1174 "f64vec3 int64BitsToDouble(i64vec3);"
1175 "f64vec4 int64BitsToDouble(i64vec4);"
1176
1177 "float64_t uint64BitsToDouble(uint64_t);"
1178 "f64vec2 uint64BitsToDouble(u64vec2);"
1179 "f64vec3 uint64BitsToDouble(u64vec3);"
1180 "f64vec4 uint64BitsToDouble(u64vec4);"
1181
1182 "int64_t packInt2x32(ivec2);"
1183 "uint64_t packUint2x32(uvec2);"
1184 "ivec2 unpackInt2x32(int64_t);"
1185 "uvec2 unpackUint2x32(uint64_t);"
1186
1187 "bvec2 lessThan(i64vec2, i64vec2);"
1188 "bvec3 lessThan(i64vec3, i64vec3);"
1189 "bvec4 lessThan(i64vec4, i64vec4);"
1190 "bvec2 lessThan(u64vec2, u64vec2);"
1191 "bvec3 lessThan(u64vec3, u64vec3);"
1192 "bvec4 lessThan(u64vec4, u64vec4);"
1193
1194 "bvec2 lessThanEqual(i64vec2, i64vec2);"
1195 "bvec3 lessThanEqual(i64vec3, i64vec3);"
1196 "bvec4 lessThanEqual(i64vec4, i64vec4);"
1197 "bvec2 lessThanEqual(u64vec2, u64vec2);"
1198 "bvec3 lessThanEqual(u64vec3, u64vec3);"
1199 "bvec4 lessThanEqual(u64vec4, u64vec4);"
1200
1201 "bvec2 greaterThan(i64vec2, i64vec2);"
1202 "bvec3 greaterThan(i64vec3, i64vec3);"
1203 "bvec4 greaterThan(i64vec4, i64vec4);"
1204 "bvec2 greaterThan(u64vec2, u64vec2);"
1205 "bvec3 greaterThan(u64vec3, u64vec3);"
1206 "bvec4 greaterThan(u64vec4, u64vec4);"
1207
1208 "bvec2 greaterThanEqual(i64vec2, i64vec2);"
1209 "bvec3 greaterThanEqual(i64vec3, i64vec3);"
1210 "bvec4 greaterThanEqual(i64vec4, i64vec4);"
1211 "bvec2 greaterThanEqual(u64vec2, u64vec2);"
1212 "bvec3 greaterThanEqual(u64vec3, u64vec3);"
1213 "bvec4 greaterThanEqual(u64vec4, u64vec4);"
1214
1215 "bvec2 equal(i64vec2, i64vec2);"
1216 "bvec3 equal(i64vec3, i64vec3);"
1217 "bvec4 equal(i64vec4, i64vec4);"
1218 "bvec2 equal(u64vec2, u64vec2);"
1219 "bvec3 equal(u64vec3, u64vec3);"
1220 "bvec4 equal(u64vec4, u64vec4);"
1221
1222 "bvec2 notEqual(i64vec2, i64vec2);"
1223 "bvec3 notEqual(i64vec3, i64vec3);"
1224 "bvec4 notEqual(i64vec4, i64vec4);"
1225 "bvec2 notEqual(u64vec2, u64vec2);"
1226 "bvec3 notEqual(u64vec3, u64vec3);"
1227 "bvec4 notEqual(u64vec4, u64vec4);"
1228
1229 "int64_t bitCount(int64_t);"
1230 "i64vec2 bitCount(i64vec2);"
1231 "i64vec3 bitCount(i64vec3);"
1232 "i64vec4 bitCount(i64vec4);"
1233
1234 "int64_t bitCount(uint64_t);"
1235 "i64vec2 bitCount(u64vec2);"
1236 "i64vec3 bitCount(u64vec3);"
1237 "i64vec4 bitCount(u64vec4);"
1238
1239 "int64_t findLSB(int64_t);"
1240 "i64vec2 findLSB(i64vec2);"
1241 "i64vec3 findLSB(i64vec3);"
1242 "i64vec4 findLSB(i64vec4);"
1243
1244 "int64_t findLSB(uint64_t);"
1245 "i64vec2 findLSB(u64vec2);"
1246 "i64vec3 findLSB(u64vec3);"
1247 "i64vec4 findLSB(u64vec4);"
1248
1249 "int64_t findMSB(int64_t);"
1250 "i64vec2 findMSB(i64vec2);"
1251 "i64vec3 findMSB(i64vec3);"
1252 "i64vec4 findMSB(i64vec4);"
1253
1254 "int64_t findMSB(uint64_t);"
1255 "i64vec2 findMSB(u64vec2);"
1256 "i64vec3 findMSB(u64vec3);"
1257 "i64vec4 findMSB(u64vec4);"
1258
1259 "\n"
1260 );
1261 }
1262
1263 // GL_AMD_shader_trinary_minmax
1264 if (profile != EEsProfile && version >= 430) {
1265 commonBuiltins.append(
1266 "float min3(float, float, float);"
1267 "vec2 min3(vec2, vec2, vec2);"
1268 "vec3 min3(vec3, vec3, vec3);"
1269 "vec4 min3(vec4, vec4, vec4);"
1270
1271 "int min3(int, int, int);"
1272 "ivec2 min3(ivec2, ivec2, ivec2);"
1273 "ivec3 min3(ivec3, ivec3, ivec3);"
1274 "ivec4 min3(ivec4, ivec4, ivec4);"
1275
1276 "uint min3(uint, uint, uint);"
1277 "uvec2 min3(uvec2, uvec2, uvec2);"
1278 "uvec3 min3(uvec3, uvec3, uvec3);"
1279 "uvec4 min3(uvec4, uvec4, uvec4);"
1280
1281 "float max3(float, float, float);"
1282 "vec2 max3(vec2, vec2, vec2);"
1283 "vec3 max3(vec3, vec3, vec3);"
1284 "vec4 max3(vec4, vec4, vec4);"
1285
1286 "int max3(int, int, int);"
1287 "ivec2 max3(ivec2, ivec2, ivec2);"
1288 "ivec3 max3(ivec3, ivec3, ivec3);"
1289 "ivec4 max3(ivec4, ivec4, ivec4);"
1290
1291 "uint max3(uint, uint, uint);"
1292 "uvec2 max3(uvec2, uvec2, uvec2);"
1293 "uvec3 max3(uvec3, uvec3, uvec3);"
1294 "uvec4 max3(uvec4, uvec4, uvec4);"
1295
1296 "float mid3(float, float, float);"
1297 "vec2 mid3(vec2, vec2, vec2);"
1298 "vec3 mid3(vec3, vec3, vec3);"
1299 "vec4 mid3(vec4, vec4, vec4);"
1300
1301 "int mid3(int, int, int);"
1302 "ivec2 mid3(ivec2, ivec2, ivec2);"
1303 "ivec3 mid3(ivec3, ivec3, ivec3);"
1304 "ivec4 mid3(ivec4, ivec4, ivec4);"
1305
1306 "uint mid3(uint, uint, uint);"
1307 "uvec2 mid3(uvec2, uvec2, uvec2);"
1308 "uvec3 mid3(uvec3, uvec3, uvec3);"
1309 "uvec4 mid3(uvec4, uvec4, uvec4);"
1310
1311 "float16_t min3(float16_t, float16_t, float16_t);"
1312 "f16vec2 min3(f16vec2, f16vec2, f16vec2);"
1313 "f16vec3 min3(f16vec3, f16vec3, f16vec3);"
1314 "f16vec4 min3(f16vec4, f16vec4, f16vec4);"
1315
1316 "float16_t max3(float16_t, float16_t, float16_t);"
1317 "f16vec2 max3(f16vec2, f16vec2, f16vec2);"
1318 "f16vec3 max3(f16vec3, f16vec3, f16vec3);"
1319 "f16vec4 max3(f16vec4, f16vec4, f16vec4);"
1320
1321 "float16_t mid3(float16_t, float16_t, float16_t);"
1322 "f16vec2 mid3(f16vec2, f16vec2, f16vec2);"
1323 "f16vec3 mid3(f16vec3, f16vec3, f16vec3);"
1324 "f16vec4 mid3(f16vec4, f16vec4, f16vec4);"
1325
1326 "int16_t min3(int16_t, int16_t, int16_t);"
1327 "i16vec2 min3(i16vec2, i16vec2, i16vec2);"
1328 "i16vec3 min3(i16vec3, i16vec3, i16vec3);"
1329 "i16vec4 min3(i16vec4, i16vec4, i16vec4);"
1330
1331 "int16_t max3(int16_t, int16_t, int16_t);"
1332 "i16vec2 max3(i16vec2, i16vec2, i16vec2);"
1333 "i16vec3 max3(i16vec3, i16vec3, i16vec3);"
1334 "i16vec4 max3(i16vec4, i16vec4, i16vec4);"
1335
1336 "int16_t mid3(int16_t, int16_t, int16_t);"
1337 "i16vec2 mid3(i16vec2, i16vec2, i16vec2);"
1338 "i16vec3 mid3(i16vec3, i16vec3, i16vec3);"
1339 "i16vec4 mid3(i16vec4, i16vec4, i16vec4);"
1340
1341 "uint16_t min3(uint16_t, uint16_t, uint16_t);"
1342 "u16vec2 min3(u16vec2, u16vec2, u16vec2);"
1343 "u16vec3 min3(u16vec3, u16vec3, u16vec3);"
1344 "u16vec4 min3(u16vec4, u16vec4, u16vec4);"
1345
1346 "uint16_t max3(uint16_t, uint16_t, uint16_t);"
1347 "u16vec2 max3(u16vec2, u16vec2, u16vec2);"
1348 "u16vec3 max3(u16vec3, u16vec3, u16vec3);"
1349 "u16vec4 max3(u16vec4, u16vec4, u16vec4);"
1350
1351 "uint16_t mid3(uint16_t, uint16_t, uint16_t);"
1352 "u16vec2 mid3(u16vec2, u16vec2, u16vec2);"
1353 "u16vec3 mid3(u16vec3, u16vec3, u16vec3);"
1354 "u16vec4 mid3(u16vec4, u16vec4, u16vec4);"
1355
1356 "\n"
1357 );
1358 }
1359
1360 if ((profile == EEsProfile && version >= 310) ||
1361 (profile != EEsProfile && version >= 430)) {
1362 commonBuiltins.append(
1363 "uint atomicAdd(coherent volatile inout uint, uint, int, int, int);"
1364 " int atomicAdd(coherent volatile inout int, int, int, int, int);"
1365
1366 "uint atomicMin(coherent volatile inout uint, uint, int, int, int);"
1367 " int atomicMin(coherent volatile inout int, int, int, int, int);"
1368
1369 "uint atomicMax(coherent volatile inout uint, uint, int, int, int);"
1370 " int atomicMax(coherent volatile inout int, int, int, int, int);"
1371
1372 "uint atomicAnd(coherent volatile inout uint, uint, int, int, int);"
1373 " int atomicAnd(coherent volatile inout int, int, int, int, int);"
1374
1375 "uint atomicOr (coherent volatile inout uint, uint, int, int, int);"
1376 " int atomicOr (coherent volatile inout int, int, int, int, int);"
1377
1378 "uint atomicXor(coherent volatile inout uint, uint, int, int, int);"
1379 " int atomicXor(coherent volatile inout int, int, int, int, int);"
1380
1381 "uint atomicExchange(coherent volatile inout uint, uint, int, int, int);"
1382 " int atomicExchange(coherent volatile inout int, int, int, int, int);"
1383
1384 "uint atomicCompSwap(coherent volatile inout uint, uint, uint, int, int, int, int, int);"
1385 " int atomicCompSwap(coherent volatile inout int, int, int, int, int, int, int, int);"
1386
1387 "uint atomicLoad(coherent volatile in uint, int, int, int);"
1388 " int atomicLoad(coherent volatile in int, int, int, int);"
1389
1390 "void atomicStore(coherent volatile out uint, uint, int, int, int);"
1391 "void atomicStore(coherent volatile out int, int, int, int, int);"
1392
1393 "\n");
1394 }
1395
1396 if (profile != EEsProfile && version >= 440) {
1397 commonBuiltins.append(
1398 "uint64_t atomicMin(coherent volatile inout uint64_t, uint64_t);"
1399 " int64_t atomicMin(coherent volatile inout int64_t, int64_t);"
1400 "uint64_t atomicMin(coherent volatile inout uint64_t, uint64_t, int, int, int);"
1401 " int64_t atomicMin(coherent volatile inout int64_t, int64_t, int, int, int);"
1402 "float16_t atomicMin(coherent volatile inout float16_t, float16_t);"
1403 "float16_t atomicMin(coherent volatile inout float16_t, float16_t, int, int, int);"
1404 " float atomicMin(coherent volatile inout float, float);"
1405 " float atomicMin(coherent volatile inout float, float, int, int, int);"
1406 " double atomicMin(coherent volatile inout double, double);"
1407 " double atomicMin(coherent volatile inout double, double, int, int, int);"
1408
1409 "uint64_t atomicMax(coherent volatile inout uint64_t, uint64_t);"
1410 " int64_t atomicMax(coherent volatile inout int64_t, int64_t);"
1411 "uint64_t atomicMax(coherent volatile inout uint64_t, uint64_t, int, int, int);"
1412 " int64_t atomicMax(coherent volatile inout int64_t, int64_t, int, int, int);"
1413 "float16_t atomicMax(coherent volatile inout float16_t, float16_t);"
1414 "float16_t atomicMax(coherent volatile inout float16_t, float16_t, int, int, int);"
1415 " float atomicMax(coherent volatile inout float, float);"
1416 " float atomicMax(coherent volatile inout float, float, int, int, int);"
1417 " double atomicMax(coherent volatile inout double, double);"
1418 " double atomicMax(coherent volatile inout double, double, int, int, int);"
1419
1420 "uint64_t atomicAnd(coherent volatile inout uint64_t, uint64_t);"
1421 " int64_t atomicAnd(coherent volatile inout int64_t, int64_t);"
1422 "uint64_t atomicAnd(coherent volatile inout uint64_t, uint64_t, int, int, int);"
1423 " int64_t atomicAnd(coherent volatile inout int64_t, int64_t, int, int, int);"
1424
1425 "uint64_t atomicOr (coherent volatile inout uint64_t, uint64_t);"
1426 " int64_t atomicOr (coherent volatile inout int64_t, int64_t);"
1427 "uint64_t atomicOr (coherent volatile inout uint64_t, uint64_t, int, int, int);"
1428 " int64_t atomicOr (coherent volatile inout int64_t, int64_t, int, int, int);"
1429
1430 "uint64_t atomicXor(coherent volatile inout uint64_t, uint64_t);"
1431 " int64_t atomicXor(coherent volatile inout int64_t, int64_t);"
1432 "uint64_t atomicXor(coherent volatile inout uint64_t, uint64_t, int, int, int);"
1433 " int64_t atomicXor(coherent volatile inout int64_t, int64_t, int, int, int);"
1434
1435 "uint64_t atomicAdd(coherent volatile inout uint64_t, uint64_t);"
1436 " int64_t atomicAdd(coherent volatile inout int64_t, int64_t);"
1437 "uint64_t atomicAdd(coherent volatile inout uint64_t, uint64_t, int, int, int);"
1438 " int64_t atomicAdd(coherent volatile inout int64_t, int64_t, int, int, int);"
1439 "float16_t atomicAdd(coherent volatile inout float16_t, float16_t);"
1440 "float16_t atomicAdd(coherent volatile inout float16_t, float16_t, int, int, int);"
1441 " float atomicAdd(coherent volatile inout float, float);"
1442 " float atomicAdd(coherent volatile inout float, float, int, int, int);"
1443 " double atomicAdd(coherent volatile inout double, double);"
1444 " double atomicAdd(coherent volatile inout double, double, int, int, int);"
1445
1446 "uint64_t atomicExchange(coherent volatile inout uint64_t, uint64_t);"
1447 " int64_t atomicExchange(coherent volatile inout int64_t, int64_t);"
1448 "uint64_t atomicExchange(coherent volatile inout uint64_t, uint64_t, int, int, int);"
1449 " int64_t atomicExchange(coherent volatile inout int64_t, int64_t, int, int, int);"
1450 "float16_t atomicExchange(coherent volatile inout float16_t, float16_t);"
1451 "float16_t atomicExchange(coherent volatile inout float16_t, float16_t, int, int, int);"
1452 " float atomicExchange(coherent volatile inout float, float);"
1453 " float atomicExchange(coherent volatile inout float, float, int, int, int);"
1454 " double atomicExchange(coherent volatile inout double, double);"
1455 " double atomicExchange(coherent volatile inout double, double, int, int, int);"
1456
1457 "uint64_t atomicCompSwap(coherent volatile inout uint64_t, uint64_t, uint64_t);"
1458 " int64_t atomicCompSwap(coherent volatile inout int64_t, int64_t, int64_t);"
1459 "uint64_t atomicCompSwap(coherent volatile inout uint64_t, uint64_t, uint64_t, int, int, int, int, int);"
1460 " int64_t atomicCompSwap(coherent volatile inout int64_t, int64_t, int64_t, int, int, int, int, int);"
1461
1462 "uint64_t atomicLoad(coherent volatile in uint64_t, int, int, int);"
1463 " int64_t atomicLoad(coherent volatile in int64_t, int, int, int);"
1464 "float16_t atomicLoad(coherent volatile in float16_t, int, int, int);"
1465 " float atomicLoad(coherent volatile in float, int, int, int);"
1466 " double atomicLoad(coherent volatile in double, int, int, int);"
1467
1468 "void atomicStore(coherent volatile out uint64_t, uint64_t, int, int, int);"
1469 "void atomicStore(coherent volatile out int64_t, int64_t, int, int, int);"
1470 "void atomicStore(coherent volatile out float16_t, float16_t, int, int, int);"
1471 "void atomicStore(coherent volatile out float, float, int, int, int);"
1472 "void atomicStore(coherent volatile out double, double, int, int, int);"
1473 "\n");
1474 }
1475
1476 if ((profile == EEsProfile && version >= 300) ||
1477 (profile != EEsProfile && version >= 150)) { // GL_ARB_shader_bit_encoding
1478 commonBuiltins.append(
1479 "int floatBitsToInt(highp float value);"
1480 "ivec2 floatBitsToInt(highp vec2 value);"
1481 "ivec3 floatBitsToInt(highp vec3 value);"
1482 "ivec4 floatBitsToInt(highp vec4 value);"
1483
1484 "uint floatBitsToUint(highp float value);"
1485 "uvec2 floatBitsToUint(highp vec2 value);"
1486 "uvec3 floatBitsToUint(highp vec3 value);"
1487 "uvec4 floatBitsToUint(highp vec4 value);"
1488
1489 "float intBitsToFloat(highp int value);"
1490 "vec2 intBitsToFloat(highp ivec2 value);"
1491 "vec3 intBitsToFloat(highp ivec3 value);"
1492 "vec4 intBitsToFloat(highp ivec4 value);"
1493
1494 "float uintBitsToFloat(highp uint value);"
1495 "vec2 uintBitsToFloat(highp uvec2 value);"
1496 "vec3 uintBitsToFloat(highp uvec3 value);"
1497 "vec4 uintBitsToFloat(highp uvec4 value);"
1498
1499 "\n");
1500 }
1501
1502 if ((profile != EEsProfile && version >= 400) ||
1503 (profile == EEsProfile && version >= 310)) { // GL_OES_gpu_shader5
1504
1505 commonBuiltins.append(
1506 "float fma(float, float, float );"
1507 "vec2 fma(vec2, vec2, vec2 );"
1508 "vec3 fma(vec3, vec3, vec3 );"
1509 "vec4 fma(vec4, vec4, vec4 );"
1510 "\n");
1511 }
1512
1513 if (profile != EEsProfile && version >= 150) { // ARB_gpu_shader_fp64
1514 commonBuiltins.append(
1515 "double fma(double, double, double);"
1516 "dvec2 fma(dvec2, dvec2, dvec2 );"
1517 "dvec3 fma(dvec3, dvec3, dvec3 );"
1518 "dvec4 fma(dvec4, dvec4, dvec4 );"
1519 "\n");
1520 }
1521
1522 if (profile == EEsProfile && version >= 310) { // ARB_gpu_shader_fp64
1523 commonBuiltins.append(
1524 "float64_t fma(float64_t, float64_t, float64_t);"
1525 "f64vec2 fma(f64vec2, f64vec2, f64vec2 );"
1526 "f64vec3 fma(f64vec3, f64vec3, f64vec3 );"
1527 "f64vec4 fma(f64vec4, f64vec4, f64vec4 );"
1528 "\n");
1529 }
1530
1531 if ((profile == EEsProfile && version >= 310) ||
1532 (profile != EEsProfile && version >= 400)) {
1533 commonBuiltins.append(
1534 "float frexp(highp float, out highp int);"
1535 "vec2 frexp(highp vec2, out highp ivec2);"
1536 "vec3 frexp(highp vec3, out highp ivec3);"
1537 "vec4 frexp(highp vec4, out highp ivec4);"
1538
1539 "float ldexp(highp float, highp int);"
1540 "vec2 ldexp(highp vec2, highp ivec2);"
1541 "vec3 ldexp(highp vec3, highp ivec3);"
1542 "vec4 ldexp(highp vec4, highp ivec4);"
1543
1544 "\n");
1545 }
1546
1547 if (profile != EEsProfile && version >= 150) { // ARB_gpu_shader_fp64
1548 commonBuiltins.append(
1549 "double frexp(double, out int);"
1550 "dvec2 frexp( dvec2, out ivec2);"
1551 "dvec3 frexp( dvec3, out ivec3);"
1552 "dvec4 frexp( dvec4, out ivec4);"
1553
1554 "double ldexp(double, int);"
1555 "dvec2 ldexp( dvec2, ivec2);"
1556 "dvec3 ldexp( dvec3, ivec3);"
1557 "dvec4 ldexp( dvec4, ivec4);"
1558
1559 "double packDouble2x32(uvec2);"
1560 "uvec2 unpackDouble2x32(double);"
1561
1562 "\n");
1563 }
1564
1565 if (profile == EEsProfile && version >= 310) { // ARB_gpu_shader_fp64
1566 commonBuiltins.append(
1567 "float64_t frexp(float64_t, out int);"
1568 "f64vec2 frexp( f64vec2, out ivec2);"
1569 "f64vec3 frexp( f64vec3, out ivec3);"
1570 "f64vec4 frexp( f64vec4, out ivec4);"
1571
1572 "float64_t ldexp(float64_t, int);"
1573 "f64vec2 ldexp( f64vec2, ivec2);"
1574 "f64vec3 ldexp( f64vec3, ivec3);"
1575 "f64vec4 ldexp( f64vec4, ivec4);"
1576
1577 "\n");
1578 }
1579
1580 if ((profile == EEsProfile && version >= 300) ||
1581 (profile != EEsProfile && version >= 150)) {
1582 commonBuiltins.append(
1583 "highp uint packUnorm2x16(vec2);"
1584 "vec2 unpackUnorm2x16(highp uint);"
1585 "\n");
1586 }
1587
1588 if ((profile == EEsProfile && version >= 300) ||
1589 (profile != EEsProfile && version >= 150)) {
1590 commonBuiltins.append(
1591 "highp uint packSnorm2x16(vec2);"
1592 " vec2 unpackSnorm2x16(highp uint);"
1593 "highp uint packHalf2x16(vec2);"
1594 "\n");
1595 }
1596
1597 if (profile == EEsProfile && version >= 300) {
1598 commonBuiltins.append(
1599 "mediump vec2 unpackHalf2x16(highp uint);"
1600 "\n");
1601 } else if (profile != EEsProfile && version >= 150) {
1602 commonBuiltins.append(
1603 " vec2 unpackHalf2x16(highp uint);"
1604 "\n");
1605 }
1606
1607 if ((profile == EEsProfile && version >= 310) ||
1608 (profile != EEsProfile && version >= 150)) {
1609 commonBuiltins.append(
1610 "highp uint packSnorm4x8(vec4);"
1611 "highp uint packUnorm4x8(vec4);"
1612 "\n");
1613 }
1614
1615 if (profile == EEsProfile && version >= 310) {
1616 commonBuiltins.append(
1617 "mediump vec4 unpackSnorm4x8(highp uint);"
1618 "mediump vec4 unpackUnorm4x8(highp uint);"
1619 "\n");
1620 } else if (profile != EEsProfile && version >= 150) {
1621 commonBuiltins.append(
1622 "vec4 unpackSnorm4x8(highp uint);"
1623 "vec4 unpackUnorm4x8(highp uint);"
1624 "\n");
1625 }
1626
1627 //
1628 // Matrix Functions.
1629 //
1630 commonBuiltins.append(
1631 "mat2 matrixCompMult(mat2 x, mat2 y);"
1632 "mat3 matrixCompMult(mat3 x, mat3 y);"
1633 "mat4 matrixCompMult(mat4 x, mat4 y);"
1634
1635 "\n");
1636
1637 // 120 is correct for both ES and desktop
1638 if (version >= 120) {
1639 commonBuiltins.append(
1640 "mat2 outerProduct(vec2 c, vec2 r);"
1641 "mat3 outerProduct(vec3 c, vec3 r);"
1642 "mat4 outerProduct(vec4 c, vec4 r);"
1643 "mat2x3 outerProduct(vec3 c, vec2 r);"
1644 "mat3x2 outerProduct(vec2 c, vec3 r);"
1645 "mat2x4 outerProduct(vec4 c, vec2 r);"
1646 "mat4x2 outerProduct(vec2 c, vec4 r);"
1647 "mat3x4 outerProduct(vec4 c, vec3 r);"
1648 "mat4x3 outerProduct(vec3 c, vec4 r);"
1649
1650 "mat2 transpose(mat2 m);"
1651 "mat3 transpose(mat3 m);"
1652 "mat4 transpose(mat4 m);"
1653 "mat2x3 transpose(mat3x2 m);"
1654 "mat3x2 transpose(mat2x3 m);"
1655 "mat2x4 transpose(mat4x2 m);"
1656 "mat4x2 transpose(mat2x4 m);"
1657 "mat3x4 transpose(mat4x3 m);"
1658 "mat4x3 transpose(mat3x4 m);"
1659
1660 "mat2x3 matrixCompMult(mat2x3, mat2x3);"
1661 "mat2x4 matrixCompMult(mat2x4, mat2x4);"
1662 "mat3x2 matrixCompMult(mat3x2, mat3x2);"
1663 "mat3x4 matrixCompMult(mat3x4, mat3x4);"
1664 "mat4x2 matrixCompMult(mat4x2, mat4x2);"
1665 "mat4x3 matrixCompMult(mat4x3, mat4x3);"
1666
1667 "\n");
1668
1669 // 150 is correct for both ES and desktop
1670 if (version >= 150) {
1671 commonBuiltins.append(
1672 "float determinant(mat2 m);"
1673 "float determinant(mat3 m);"
1674 "float determinant(mat4 m);"
1675
1676 "mat2 inverse(mat2 m);"
1677 "mat3 inverse(mat3 m);"
1678 "mat4 inverse(mat4 m);"
1679
1680 "\n");
1681 }
1682 }
1683
1684 //
1685 // Original-style texture functions existing in all stages.
1686 // (Per-stage functions below.)
1687 //
1688 if ((profile == EEsProfile && version == 100) ||
1689 profile == ECompatibilityProfile ||
1690 (profile == ECoreProfile && version < 420) ||
1691 profile == ENoProfile) {
1692 if (spvVersion.spv == 0) {
1693 commonBuiltins.append(
1694 "vec4 texture2D(sampler2D, vec2);"
1695
1696 "vec4 texture2DProj(sampler2D, vec3);"
1697 "vec4 texture2DProj(sampler2D, vec4);"
1698
1699 "vec4 texture3D(sampler3D, vec3);" // OES_texture_3D, but caught by keyword check
1700 "vec4 texture3DProj(sampler3D, vec4);" // OES_texture_3D, but caught by keyword check
1701
1702 "vec4 textureCube(samplerCube, vec3);"
1703
1704 "\n");
1705 }
1706 }
1707
1708 if ( profile == ECompatibilityProfile ||
1709 (profile == ECoreProfile && version < 420) ||
1710 profile == ENoProfile) {
1711 if (spvVersion.spv == 0) {
1712 commonBuiltins.append(
1713 "vec4 texture1D(sampler1D, float);"
1714
1715 "vec4 texture1DProj(sampler1D, vec2);"
1716 "vec4 texture1DProj(sampler1D, vec4);"
1717
1718 "vec4 shadow1D(sampler1DShadow, vec3);"
1719 "vec4 shadow2D(sampler2DShadow, vec3);"
1720 "vec4 shadow1DProj(sampler1DShadow, vec4);"
1721 "vec4 shadow2DProj(sampler2DShadow, vec4);"
1722
1723 "vec4 texture2DRect(sampler2DRect, vec2);" // GL_ARB_texture_rectangle, caught by keyword check
1724 "vec4 texture2DRectProj(sampler2DRect, vec3);" // GL_ARB_texture_rectangle, caught by keyword check
1725 "vec4 texture2DRectProj(sampler2DRect, vec4);" // GL_ARB_texture_rectangle, caught by keyword check
1726 "vec4 shadow2DRect(sampler2DRectShadow, vec3);" // GL_ARB_texture_rectangle, caught by keyword check
1727 "vec4 shadow2DRectProj(sampler2DRectShadow, vec4);" // GL_ARB_texture_rectangle, caught by keyword check
1728
1729 "vec4 texture1DArray(sampler1DArray, vec2);" // GL_EXT_texture_array
1730 "vec4 texture2DArray(sampler2DArray, vec3);" // GL_EXT_texture_array
1731 "vec4 shadow1DArray(sampler1DArrayShadow, vec3);" // GL_EXT_texture_array
1732 "vec4 shadow2DArray(sampler2DArrayShadow, vec4);" // GL_EXT_texture_array
1733 "vec4 texture1DArray(sampler1DArray, vec2, float);" // GL_EXT_texture_array
1734 "vec4 texture2DArray(sampler2DArray, vec3, float);" // GL_EXT_texture_array
1735 "vec4 shadow1DArray(sampler1DArrayShadow, vec3, float);" // GL_EXT_texture_array
1736 "vec4 texture1DArrayLod(sampler1DArray, vec2, float);" // GL_EXT_texture_array
1737 "vec4 texture2DArrayLod(sampler2DArray, vec3, float);" // GL_EXT_texture_array
1738 "vec4 shadow1DArrayLod(sampler1DArrayShadow, vec3, float);" // GL_EXT_texture_array
1739 "\n");
1740 }
1741 }
1742
1743 if (profile == EEsProfile) {
1744 if (spvVersion.spv == 0) {
1745 if (version < 300) {
1746 commonBuiltins.append(
1747 "vec4 texture2D(samplerExternalOES, vec2 coord);" // GL_OES_EGL_image_external
1748 "vec4 texture2DProj(samplerExternalOES, vec3);" // GL_OES_EGL_image_external
1749 "vec4 texture2DProj(samplerExternalOES, vec4);" // GL_OES_EGL_image_external
1750 "\n");
1751 } else {
1752 commonBuiltins.append(
1753 "highp ivec2 textureSize(samplerExternalOES, int lod);" // GL_OES_EGL_image_external_essl3
1754 "vec4 texture(samplerExternalOES, vec2);" // GL_OES_EGL_image_external_essl3
1755 "vec4 texture(samplerExternalOES, vec2, float bias);" // GL_OES_EGL_image_external_essl3
1756 "vec4 textureProj(samplerExternalOES, vec3);" // GL_OES_EGL_image_external_essl3
1757 "vec4 textureProj(samplerExternalOES, vec3, float bias);" // GL_OES_EGL_image_external_essl3
1758 "vec4 textureProj(samplerExternalOES, vec4);" // GL_OES_EGL_image_external_essl3
1759 "vec4 textureProj(samplerExternalOES, vec4, float bias);" // GL_OES_EGL_image_external_essl3
1760 "vec4 texelFetch(samplerExternalOES, ivec2, int lod);" // GL_OES_EGL_image_external_essl3
1761 "\n");
1762 }
1763 commonBuiltins.append(
1764 "highp ivec2 textureSize(__samplerExternal2DY2YEXT, int lod);" // GL_EXT_YUV_target
1765 "vec4 texture(__samplerExternal2DY2YEXT, vec2);" // GL_EXT_YUV_target
1766 "vec4 texture(__samplerExternal2DY2YEXT, vec2, float bias);" // GL_EXT_YUV_target
1767 "vec4 textureProj(__samplerExternal2DY2YEXT, vec3);" // GL_EXT_YUV_target
1768 "vec4 textureProj(__samplerExternal2DY2YEXT, vec3, float bias);" // GL_EXT_YUV_target
1769 "vec4 textureProj(__samplerExternal2DY2YEXT, vec4);" // GL_EXT_YUV_target
1770 "vec4 textureProj(__samplerExternal2DY2YEXT, vec4, float bias);" // GL_EXT_YUV_target
1771 "vec4 texelFetch(__samplerExternal2DY2YEXT sampler, ivec2, int lod);" // GL_EXT_YUV_target
1772 "\n");
1773 commonBuiltins.append(
1774 "vec4 texture2DGradEXT(sampler2D, vec2, vec2, vec2);" // GL_EXT_shader_texture_lod
1775 "vec4 texture2DProjGradEXT(sampler2D, vec3, vec2, vec2);" // GL_EXT_shader_texture_lod
1776 "vec4 texture2DProjGradEXT(sampler2D, vec4, vec2, vec2);" // GL_EXT_shader_texture_lod
1777 "vec4 textureCubeGradEXT(samplerCube, vec3, vec3, vec3);" // GL_EXT_shader_texture_lod
1778
1779 "float shadow2DEXT(sampler2DShadow, vec3);" // GL_EXT_shadow_samplers
1780 "float shadow2DProjEXT(sampler2DShadow, vec4);" // GL_EXT_shadow_samplers
1781
1782 "\n");
1783 }
1784 }
1785
1786 //
1787 // Noise functions.
1788 //
1789 if (spvVersion.spv == 0 && profile != EEsProfile) {
1790 commonBuiltins.append(
1791 "float noise1(float x);"
1792 "float noise1(vec2 x);"
1793 "float noise1(vec3 x);"
1794 "float noise1(vec4 x);"
1795
1796 "vec2 noise2(float x);"
1797 "vec2 noise2(vec2 x);"
1798 "vec2 noise2(vec3 x);"
1799 "vec2 noise2(vec4 x);"
1800
1801 "vec3 noise3(float x);"
1802 "vec3 noise3(vec2 x);"
1803 "vec3 noise3(vec3 x);"
1804 "vec3 noise3(vec4 x);"
1805
1806 "vec4 noise4(float x);"
1807 "vec4 noise4(vec2 x);"
1808 "vec4 noise4(vec3 x);"
1809 "vec4 noise4(vec4 x);"
1810
1811 "\n");
1812 }
1813
1814 if (spvVersion.vulkan == 0) {
1815 //
1816 // Atomic counter functions.
1817 //
1818 if ((profile != EEsProfile && version >= 300) ||
1819 (profile == EEsProfile && version >= 310)) {
1820 commonBuiltins.append(
1821 "uint atomicCounterIncrement(atomic_uint);"
1822 "uint atomicCounterDecrement(atomic_uint);"
1823 "uint atomicCounter(atomic_uint);"
1824
1825 "\n");
1826 }
1827 if (profile != EEsProfile && version == 450) {
1828 commonBuiltins.append(
1829 "uint atomicCounterAddARB(atomic_uint, uint);"
1830 "uint atomicCounterSubtractARB(atomic_uint, uint);"
1831 "uint atomicCounterMinARB(atomic_uint, uint);"
1832 "uint atomicCounterMaxARB(atomic_uint, uint);"
1833 "uint atomicCounterAndARB(atomic_uint, uint);"
1834 "uint atomicCounterOrARB(atomic_uint, uint);"
1835 "uint atomicCounterXorARB(atomic_uint, uint);"
1836 "uint atomicCounterExchangeARB(atomic_uint, uint);"
1837 "uint atomicCounterCompSwapARB(atomic_uint, uint, uint);"
1838
1839 "\n");
1840 }
1841
1842
1843 if (profile != EEsProfile && version >= 460) {
1844 commonBuiltins.append(
1845 "uint atomicCounterAdd(atomic_uint, uint);"
1846 "uint atomicCounterSubtract(atomic_uint, uint);"
1847 "uint atomicCounterMin(atomic_uint, uint);"
1848 "uint atomicCounterMax(atomic_uint, uint);"
1849 "uint atomicCounterAnd(atomic_uint, uint);"
1850 "uint atomicCounterOr(atomic_uint, uint);"
1851 "uint atomicCounterXor(atomic_uint, uint);"
1852 "uint atomicCounterExchange(atomic_uint, uint);"
1853 "uint atomicCounterCompSwap(atomic_uint, uint, uint);"
1854
1855 "\n");
1856 }
1857 }
1858 else if (spvVersion.vulkanRelaxed) {
1859 //
1860 // Atomic counter functions act as aliases to normal atomic functions.
1861 // replace definitions to take 'volatile coherent uint' instead of 'atomic_uint'
1862 // and map to equivalent non-counter atomic op
1863 //
1864 if ((profile != EEsProfile && version >= 300) ||
1865 (profile == EEsProfile && version >= 310)) {
1866 commonBuiltins.append(
1867 "uint atomicCounterIncrement(volatile coherent uint);"
1868 "uint atomicCounterDecrement(volatile coherent uint);"
1869 "uint atomicCounter(volatile coherent uint);"
1870
1871 "\n");
1872 }
1873 if (profile != EEsProfile && version >= 460) {
1874 commonBuiltins.append(
1875 "uint atomicCounterAdd(volatile coherent uint, uint);"
1876 "uint atomicCounterSubtract(volatile coherent uint, uint);"
1877 "uint atomicCounterMin(volatile coherent uint, uint);"
1878 "uint atomicCounterMax(volatile coherent uint, uint);"
1879 "uint atomicCounterAnd(volatile coherent uint, uint);"
1880 "uint atomicCounterOr(volatile coherent uint, uint);"
1881 "uint atomicCounterXor(volatile coherent uint, uint);"
1882 "uint atomicCounterExchange(volatile coherent uint, uint);"
1883 "uint atomicCounterCompSwap(volatile coherent uint, uint, uint);"
1884
1885 "\n");
1886 }
1887 }
1888
1889 // Bitfield
1890 if ((profile == EEsProfile && version >= 310) ||
1891 (profile != EEsProfile && version >= 400)) {
1892 commonBuiltins.append(
1893 " int bitfieldExtract( int, int, int);"
1894 "ivec2 bitfieldExtract(ivec2, int, int);"
1895 "ivec3 bitfieldExtract(ivec3, int, int);"
1896 "ivec4 bitfieldExtract(ivec4, int, int);"
1897
1898 " uint bitfieldExtract( uint, int, int);"
1899 "uvec2 bitfieldExtract(uvec2, int, int);"
1900 "uvec3 bitfieldExtract(uvec3, int, int);"
1901 "uvec4 bitfieldExtract(uvec4, int, int);"
1902
1903 " int bitfieldInsert( int base, int, int, int);"
1904 "ivec2 bitfieldInsert(ivec2 base, ivec2, int, int);"
1905 "ivec3 bitfieldInsert(ivec3 base, ivec3, int, int);"
1906 "ivec4 bitfieldInsert(ivec4 base, ivec4, int, int);"
1907
1908 " uint bitfieldInsert( uint base, uint, int, int);"
1909 "uvec2 bitfieldInsert(uvec2 base, uvec2, int, int);"
1910 "uvec3 bitfieldInsert(uvec3 base, uvec3, int, int);"
1911 "uvec4 bitfieldInsert(uvec4 base, uvec4, int, int);"
1912
1913 "\n");
1914 }
1915
1916 if (profile != EEsProfile && version >= 400) {
1917 commonBuiltins.append(
1918 " int findLSB( int);"
1919 "ivec2 findLSB(ivec2);"
1920 "ivec3 findLSB(ivec3);"
1921 "ivec4 findLSB(ivec4);"
1922
1923 " int findLSB( uint);"
1924 "ivec2 findLSB(uvec2);"
1925 "ivec3 findLSB(uvec3);"
1926 "ivec4 findLSB(uvec4);"
1927
1928 "\n");
1929 } else if (profile == EEsProfile && version >= 310) {
1930 commonBuiltins.append(
1931 "lowp int findLSB( int);"
1932 "lowp ivec2 findLSB(ivec2);"
1933 "lowp ivec3 findLSB(ivec3);"
1934 "lowp ivec4 findLSB(ivec4);"
1935
1936 "lowp int findLSB( uint);"
1937 "lowp ivec2 findLSB(uvec2);"
1938 "lowp ivec3 findLSB(uvec3);"
1939 "lowp ivec4 findLSB(uvec4);"
1940
1941 "\n");
1942 }
1943
1944 if (profile != EEsProfile && version >= 400) {
1945 commonBuiltins.append(
1946 " int bitCount( int);"
1947 "ivec2 bitCount(ivec2);"
1948 "ivec3 bitCount(ivec3);"
1949 "ivec4 bitCount(ivec4);"
1950
1951 " int bitCount( uint);"
1952 "ivec2 bitCount(uvec2);"
1953 "ivec3 bitCount(uvec3);"
1954 "ivec4 bitCount(uvec4);"
1955
1956 " int findMSB(highp int);"
1957 "ivec2 findMSB(highp ivec2);"
1958 "ivec3 findMSB(highp ivec3);"
1959 "ivec4 findMSB(highp ivec4);"
1960
1961 " int findMSB(highp uint);"
1962 "ivec2 findMSB(highp uvec2);"
1963 "ivec3 findMSB(highp uvec3);"
1964 "ivec4 findMSB(highp uvec4);"
1965
1966 "\n");
1967 }
1968
1969 if ((profile == EEsProfile && version >= 310) ||
1970 (profile != EEsProfile && version >= 400)) {
1971 commonBuiltins.append(
1972 " uint uaddCarry(highp uint, highp uint, out lowp uint carry);"
1973 "uvec2 uaddCarry(highp uvec2, highp uvec2, out lowp uvec2 carry);"
1974 "uvec3 uaddCarry(highp uvec3, highp uvec3, out lowp uvec3 carry);"
1975 "uvec4 uaddCarry(highp uvec4, highp uvec4, out lowp uvec4 carry);"
1976
1977 " uint usubBorrow(highp uint, highp uint, out lowp uint borrow);"
1978 "uvec2 usubBorrow(highp uvec2, highp uvec2, out lowp uvec2 borrow);"
1979 "uvec3 usubBorrow(highp uvec3, highp uvec3, out lowp uvec3 borrow);"
1980 "uvec4 usubBorrow(highp uvec4, highp uvec4, out lowp uvec4 borrow);"
1981
1982 "void umulExtended(highp uint, highp uint, out highp uint, out highp uint lsb);"
1983 "void umulExtended(highp uvec2, highp uvec2, out highp uvec2, out highp uvec2 lsb);"
1984 "void umulExtended(highp uvec3, highp uvec3, out highp uvec3, out highp uvec3 lsb);"
1985 "void umulExtended(highp uvec4, highp uvec4, out highp uvec4, out highp uvec4 lsb);"
1986
1987 "void imulExtended(highp int, highp int, out highp int, out highp int lsb);"
1988 "void imulExtended(highp ivec2, highp ivec2, out highp ivec2, out highp ivec2 lsb);"
1989 "void imulExtended(highp ivec3, highp ivec3, out highp ivec3, out highp ivec3 lsb);"
1990 "void imulExtended(highp ivec4, highp ivec4, out highp ivec4, out highp ivec4 lsb);"
1991
1992 " int bitfieldReverse(highp int);"
1993 "ivec2 bitfieldReverse(highp ivec2);"
1994 "ivec3 bitfieldReverse(highp ivec3);"
1995 "ivec4 bitfieldReverse(highp ivec4);"
1996
1997 " uint bitfieldReverse(highp uint);"
1998 "uvec2 bitfieldReverse(highp uvec2);"
1999 "uvec3 bitfieldReverse(highp uvec3);"
2000 "uvec4 bitfieldReverse(highp uvec4);"
2001
2002 "\n");
2003 }
2004
2005 if (profile == EEsProfile && version >= 310) {
2006 commonBuiltins.append(
2007 "lowp int bitCount( int);"
2008 "lowp ivec2 bitCount(ivec2);"
2009 "lowp ivec3 bitCount(ivec3);"
2010 "lowp ivec4 bitCount(ivec4);"
2011
2012 "lowp int bitCount( uint);"
2013 "lowp ivec2 bitCount(uvec2);"
2014 "lowp ivec3 bitCount(uvec3);"
2015 "lowp ivec4 bitCount(uvec4);"
2016
2017 "lowp int findMSB(highp int);"
2018 "lowp ivec2 findMSB(highp ivec2);"
2019 "lowp ivec3 findMSB(highp ivec3);"
2020 "lowp ivec4 findMSB(highp ivec4);"
2021
2022 "lowp int findMSB(highp uint);"
2023 "lowp ivec2 findMSB(highp uvec2);"
2024 "lowp ivec3 findMSB(highp uvec3);"
2025 "lowp ivec4 findMSB(highp uvec4);"
2026
2027 "\n");
2028 }
2029
2030 // GL_ARB_shader_ballot
2031 if (profile != EEsProfile && version >= 450) {
2032 commonBuiltins.append(
2033 "uint64_t ballotARB(bool);"
2034
2035 "float readInvocationARB(float, uint);"
2036 "vec2 readInvocationARB(vec2, uint);"
2037 "vec3 readInvocationARB(vec3, uint);"
2038 "vec4 readInvocationARB(vec4, uint);"
2039
2040 "int readInvocationARB(int, uint);"
2041 "ivec2 readInvocationARB(ivec2, uint);"
2042 "ivec3 readInvocationARB(ivec3, uint);"
2043 "ivec4 readInvocationARB(ivec4, uint);"
2044
2045 "uint readInvocationARB(uint, uint);"
2046 "uvec2 readInvocationARB(uvec2, uint);"
2047 "uvec3 readInvocationARB(uvec3, uint);"
2048 "uvec4 readInvocationARB(uvec4, uint);"
2049
2050 "float readFirstInvocationARB(float);"
2051 "vec2 readFirstInvocationARB(vec2);"
2052 "vec3 readFirstInvocationARB(vec3);"
2053 "vec4 readFirstInvocationARB(vec4);"
2054
2055 "int readFirstInvocationARB(int);"
2056 "ivec2 readFirstInvocationARB(ivec2);"
2057 "ivec3 readFirstInvocationARB(ivec3);"
2058 "ivec4 readFirstInvocationARB(ivec4);"
2059
2060 "uint readFirstInvocationARB(uint);"
2061 "uvec2 readFirstInvocationARB(uvec2);"
2062 "uvec3 readFirstInvocationARB(uvec3);"
2063 "uvec4 readFirstInvocationARB(uvec4);"
2064
2065 "\n");
2066 }
2067
2068 // GL_ARB_shader_group_vote
2069 if (profile != EEsProfile && version >= 430) {
2070 commonBuiltins.append(
2071 "bool anyInvocationARB(bool);"
2072 "bool allInvocationsARB(bool);"
2073 "bool allInvocationsEqualARB(bool);"
2074
2075 "\n");
2076 }
2077
2078 // GL_KHR_shader_subgroup
2079 if ((profile == EEsProfile && version >= 310) ||
2080 (profile != EEsProfile && version >= 140)) {
2081 commonBuiltins.append(
2082 "void subgroupBarrier();"
2083 "void subgroupMemoryBarrier();"
2084 "void subgroupMemoryBarrierBuffer();"
2085 "void subgroupMemoryBarrierImage();"
2086 "bool subgroupElect();"
2087
2088 "bool subgroupAll(bool);\n"
2089 "bool subgroupAny(bool);\n"
2090 "uvec4 subgroupBallot(bool);\n"
2091 "bool subgroupInverseBallot(uvec4);\n"
2092 "bool subgroupBallotBitExtract(uvec4, uint);\n"
2093 "uint subgroupBallotBitCount(uvec4);\n"
2094 "uint subgroupBallotInclusiveBitCount(uvec4);\n"
2095 "uint subgroupBallotExclusiveBitCount(uvec4);\n"
2096 "uint subgroupBallotFindLSB(uvec4);\n"
2097 "uint subgroupBallotFindMSB(uvec4);\n"
2098 );
2099
2100 // Generate all flavors of subgroup ops.
2101 static const char *subgroupOps[] =
2102 {
2103 "bool subgroupAllEqual(%s);\n",
2104 "%s subgroupBroadcast(%s, uint);\n",
2105 "%s subgroupBroadcastFirst(%s);\n",
2106 "%s subgroupShuffle(%s, uint);\n",
2107 "%s subgroupShuffleXor(%s, uint);\n",
2108 "%s subgroupShuffleUp(%s, uint delta);\n",
2109 "%s subgroupShuffleDown(%s, uint delta);\n",
2110 "%s subgroupAdd(%s);\n",
2111 "%s subgroupMul(%s);\n",
2112 "%s subgroupMin(%s);\n",
2113 "%s subgroupMax(%s);\n",
2114 "%s subgroupAnd(%s);\n",
2115 "%s subgroupOr(%s);\n",
2116 "%s subgroupXor(%s);\n",
2117 "%s subgroupInclusiveAdd(%s);\n",
2118 "%s subgroupInclusiveMul(%s);\n",
2119 "%s subgroupInclusiveMin(%s);\n",
2120 "%s subgroupInclusiveMax(%s);\n",
2121 "%s subgroupInclusiveAnd(%s);\n",
2122 "%s subgroupInclusiveOr(%s);\n",
2123 "%s subgroupInclusiveXor(%s);\n",
2124 "%s subgroupExclusiveAdd(%s);\n",
2125 "%s subgroupExclusiveMul(%s);\n",
2126 "%s subgroupExclusiveMin(%s);\n",
2127 "%s subgroupExclusiveMax(%s);\n",
2128 "%s subgroupExclusiveAnd(%s);\n",
2129 "%s subgroupExclusiveOr(%s);\n",
2130 "%s subgroupExclusiveXor(%s);\n",
2131 "%s subgroupClusteredAdd(%s, uint);\n",
2132 "%s subgroupClusteredMul(%s, uint);\n",
2133 "%s subgroupClusteredMin(%s, uint);\n",
2134 "%s subgroupClusteredMax(%s, uint);\n",
2135 "%s subgroupClusteredAnd(%s, uint);\n",
2136 "%s subgroupClusteredOr(%s, uint);\n",
2137 "%s subgroupClusteredXor(%s, uint);\n",
2138 "%s subgroupQuadBroadcast(%s, uint);\n",
2139 "%s subgroupQuadSwapHorizontal(%s);\n",
2140 "%s subgroupQuadSwapVertical(%s);\n",
2141 "%s subgroupQuadSwapDiagonal(%s);\n",
2142 "uvec4 subgroupPartitionNV(%s);\n",
2143 "%s subgroupPartitionedAddNV(%s, uvec4 ballot);\n",
2144 "%s subgroupPartitionedMulNV(%s, uvec4 ballot);\n",
2145 "%s subgroupPartitionedMinNV(%s, uvec4 ballot);\n",
2146 "%s subgroupPartitionedMaxNV(%s, uvec4 ballot);\n",
2147 "%s subgroupPartitionedAndNV(%s, uvec4 ballot);\n",
2148 "%s subgroupPartitionedOrNV(%s, uvec4 ballot);\n",
2149 "%s subgroupPartitionedXorNV(%s, uvec4 ballot);\n",
2150 "%s subgroupPartitionedInclusiveAddNV(%s, uvec4 ballot);\n",
2151 "%s subgroupPartitionedInclusiveMulNV(%s, uvec4 ballot);\n",
2152 "%s subgroupPartitionedInclusiveMinNV(%s, uvec4 ballot);\n",
2153 "%s subgroupPartitionedInclusiveMaxNV(%s, uvec4 ballot);\n",
2154 "%s subgroupPartitionedInclusiveAndNV(%s, uvec4 ballot);\n",
2155 "%s subgroupPartitionedInclusiveOrNV(%s, uvec4 ballot);\n",
2156 "%s subgroupPartitionedInclusiveXorNV(%s, uvec4 ballot);\n",
2157 "%s subgroupPartitionedExclusiveAddNV(%s, uvec4 ballot);\n",
2158 "%s subgroupPartitionedExclusiveMulNV(%s, uvec4 ballot);\n",
2159 "%s subgroupPartitionedExclusiveMinNV(%s, uvec4 ballot);\n",
2160 "%s subgroupPartitionedExclusiveMaxNV(%s, uvec4 ballot);\n",
2161 "%s subgroupPartitionedExclusiveAndNV(%s, uvec4 ballot);\n",
2162 "%s subgroupPartitionedExclusiveOrNV(%s, uvec4 ballot);\n",
2163 "%s subgroupPartitionedExclusiveXorNV(%s, uvec4 ballot);\n",
2164 };
2165
2166 static const char *floatTypes[] = {
2167 "float", "vec2", "vec3", "vec4",
2168 "float16_t", "f16vec2", "f16vec3", "f16vec4",
2169 };
2170 static const char *doubleTypes[] = {
2171 "double", "dvec2", "dvec3", "dvec4",
2172 };
2173 static const char *intTypes[] = {
2174 "int8_t", "i8vec2", "i8vec3", "i8vec4",
2175 "int16_t", "i16vec2", "i16vec3", "i16vec4",
2176 "int", "ivec2", "ivec3", "ivec4",
2177 "int64_t", "i64vec2", "i64vec3", "i64vec4",
2178 "uint8_t", "u8vec2", "u8vec3", "u8vec4",
2179 "uint16_t", "u16vec2", "u16vec3", "u16vec4",
2180 "uint", "uvec2", "uvec3", "uvec4",
2181 "uint64_t", "u64vec2", "u64vec3", "u64vec4",
2182 };
2183 static const char *boolTypes[] = {
2184 "bool", "bvec2", "bvec3", "bvec4",
2185 };
2186
2187 for (size_t i = 0; i < sizeof(subgroupOps)/sizeof(subgroupOps[0]); ++i) {
2188 const char *op = subgroupOps[i];
2189
2190 // Logical operations don't support float
2191 bool logicalOp = strstr(op, "Or") || strstr(op, "And") ||
2192 (strstr(op, "Xor") && !strstr(op, "ShuffleXor"));
2193 // Math operations don't support bool
2194 bool mathOp = strstr(op, "Add") || strstr(op, "Mul") || strstr(op, "Min") || strstr(op, "Max");
2195
2196 const int bufSize = 256;
2197 char buf[bufSize];
2198
2199 if (!logicalOp) {
2200 for (size_t j = 0; j < sizeof(floatTypes)/sizeof(floatTypes[0]); ++j) {
2201 snprintf(buf, bufSize, op, floatTypes[j], floatTypes[j]);
2202 commonBuiltins.append(buf);
2203 }
2204 if (profile != EEsProfile && version >= 400) {
2205 for (size_t j = 0; j < sizeof(doubleTypes)/sizeof(doubleTypes[0]); ++j) {
2206 snprintf(buf, bufSize, op, doubleTypes[j], doubleTypes[j]);
2207 commonBuiltins.append(buf);
2208 }
2209 }
2210 }
2211 if (!mathOp) {
2212 for (size_t j = 0; j < sizeof(boolTypes)/sizeof(boolTypes[0]); ++j) {
2213 snprintf(buf, bufSize, op, boolTypes[j], boolTypes[j]);
2214 commonBuiltins.append(buf);
2215 }
2216 }
2217 for (size_t j = 0; j < sizeof(intTypes)/sizeof(intTypes[0]); ++j) {
2218 snprintf(buf, bufSize, op, intTypes[j], intTypes[j]);
2219 commonBuiltins.append(buf);
2220 }
2221 }
2222
2223 stageBuiltins[EShLangCompute].append(
2224 "void subgroupMemoryBarrierShared();"
2225
2226 "\n"
2227 );
2228 stageBuiltins[EShLangMesh].append(
2229 "void subgroupMemoryBarrierShared();"
2230 "\n"
2231 );
2232 stageBuiltins[EShLangTask].append(
2233 "void subgroupMemoryBarrierShared();"
2234 "\n"
2235 );
2236 }
2237
2238 if (profile != EEsProfile && version >= 460) {
2239 commonBuiltins.append(
2240 "bool anyInvocation(bool);"
2241 "bool allInvocations(bool);"
2242 "bool allInvocationsEqual(bool);"
2243
2244 "\n");
2245 }
2246
2247 // GL_AMD_shader_ballot
2248 if (profile != EEsProfile && version >= 450) {
2249 commonBuiltins.append(
2250 "float minInvocationsAMD(float);"
2251 "vec2 minInvocationsAMD(vec2);"
2252 "vec3 minInvocationsAMD(vec3);"
2253 "vec4 minInvocationsAMD(vec4);"
2254
2255 "int minInvocationsAMD(int);"
2256 "ivec2 minInvocationsAMD(ivec2);"
2257 "ivec3 minInvocationsAMD(ivec3);"
2258 "ivec4 minInvocationsAMD(ivec4);"
2259
2260 "uint minInvocationsAMD(uint);"
2261 "uvec2 minInvocationsAMD(uvec2);"
2262 "uvec3 minInvocationsAMD(uvec3);"
2263 "uvec4 minInvocationsAMD(uvec4);"
2264
2265 "double minInvocationsAMD(double);"
2266 "dvec2 minInvocationsAMD(dvec2);"
2267 "dvec3 minInvocationsAMD(dvec3);"
2268 "dvec4 minInvocationsAMD(dvec4);"
2269
2270 "int64_t minInvocationsAMD(int64_t);"
2271 "i64vec2 minInvocationsAMD(i64vec2);"
2272 "i64vec3 minInvocationsAMD(i64vec3);"
2273 "i64vec4 minInvocationsAMD(i64vec4);"
2274
2275 "uint64_t minInvocationsAMD(uint64_t);"
2276 "u64vec2 minInvocationsAMD(u64vec2);"
2277 "u64vec3 minInvocationsAMD(u64vec3);"
2278 "u64vec4 minInvocationsAMD(u64vec4);"
2279
2280 "float16_t minInvocationsAMD(float16_t);"
2281 "f16vec2 minInvocationsAMD(f16vec2);"
2282 "f16vec3 minInvocationsAMD(f16vec3);"
2283 "f16vec4 minInvocationsAMD(f16vec4);"
2284
2285 "int16_t minInvocationsAMD(int16_t);"
2286 "i16vec2 minInvocationsAMD(i16vec2);"
2287 "i16vec3 minInvocationsAMD(i16vec3);"
2288 "i16vec4 minInvocationsAMD(i16vec4);"
2289
2290 "uint16_t minInvocationsAMD(uint16_t);"
2291 "u16vec2 minInvocationsAMD(u16vec2);"
2292 "u16vec3 minInvocationsAMD(u16vec3);"
2293 "u16vec4 minInvocationsAMD(u16vec4);"
2294
2295 "float minInvocationsInclusiveScanAMD(float);"
2296 "vec2 minInvocationsInclusiveScanAMD(vec2);"
2297 "vec3 minInvocationsInclusiveScanAMD(vec3);"
2298 "vec4 minInvocationsInclusiveScanAMD(vec4);"
2299
2300 "int minInvocationsInclusiveScanAMD(int);"
2301 "ivec2 minInvocationsInclusiveScanAMD(ivec2);"
2302 "ivec3 minInvocationsInclusiveScanAMD(ivec3);"
2303 "ivec4 minInvocationsInclusiveScanAMD(ivec4);"
2304
2305 "uint minInvocationsInclusiveScanAMD(uint);"
2306 "uvec2 minInvocationsInclusiveScanAMD(uvec2);"
2307 "uvec3 minInvocationsInclusiveScanAMD(uvec3);"
2308 "uvec4 minInvocationsInclusiveScanAMD(uvec4);"
2309
2310 "double minInvocationsInclusiveScanAMD(double);"
2311 "dvec2 minInvocationsInclusiveScanAMD(dvec2);"
2312 "dvec3 minInvocationsInclusiveScanAMD(dvec3);"
2313 "dvec4 minInvocationsInclusiveScanAMD(dvec4);"
2314
2315 "int64_t minInvocationsInclusiveScanAMD(int64_t);"
2316 "i64vec2 minInvocationsInclusiveScanAMD(i64vec2);"
2317 "i64vec3 minInvocationsInclusiveScanAMD(i64vec3);"
2318 "i64vec4 minInvocationsInclusiveScanAMD(i64vec4);"
2319
2320 "uint64_t minInvocationsInclusiveScanAMD(uint64_t);"
2321 "u64vec2 minInvocationsInclusiveScanAMD(u64vec2);"
2322 "u64vec3 minInvocationsInclusiveScanAMD(u64vec3);"
2323 "u64vec4 minInvocationsInclusiveScanAMD(u64vec4);"
2324
2325 "float16_t minInvocationsInclusiveScanAMD(float16_t);"
2326 "f16vec2 minInvocationsInclusiveScanAMD(f16vec2);"
2327 "f16vec3 minInvocationsInclusiveScanAMD(f16vec3);"
2328 "f16vec4 minInvocationsInclusiveScanAMD(f16vec4);"
2329
2330 "int16_t minInvocationsInclusiveScanAMD(int16_t);"
2331 "i16vec2 minInvocationsInclusiveScanAMD(i16vec2);"
2332 "i16vec3 minInvocationsInclusiveScanAMD(i16vec3);"
2333 "i16vec4 minInvocationsInclusiveScanAMD(i16vec4);"
2334
2335 "uint16_t minInvocationsInclusiveScanAMD(uint16_t);"
2336 "u16vec2 minInvocationsInclusiveScanAMD(u16vec2);"
2337 "u16vec3 minInvocationsInclusiveScanAMD(u16vec3);"
2338 "u16vec4 minInvocationsInclusiveScanAMD(u16vec4);"
2339
2340 "float minInvocationsExclusiveScanAMD(float);"
2341 "vec2 minInvocationsExclusiveScanAMD(vec2);"
2342 "vec3 minInvocationsExclusiveScanAMD(vec3);"
2343 "vec4 minInvocationsExclusiveScanAMD(vec4);"
2344
2345 "int minInvocationsExclusiveScanAMD(int);"
2346 "ivec2 minInvocationsExclusiveScanAMD(ivec2);"
2347 "ivec3 minInvocationsExclusiveScanAMD(ivec3);"
2348 "ivec4 minInvocationsExclusiveScanAMD(ivec4);"
2349
2350 "uint minInvocationsExclusiveScanAMD(uint);"
2351 "uvec2 minInvocationsExclusiveScanAMD(uvec2);"
2352 "uvec3 minInvocationsExclusiveScanAMD(uvec3);"
2353 "uvec4 minInvocationsExclusiveScanAMD(uvec4);"
2354
2355 "double minInvocationsExclusiveScanAMD(double);"
2356 "dvec2 minInvocationsExclusiveScanAMD(dvec2);"
2357 "dvec3 minInvocationsExclusiveScanAMD(dvec3);"
2358 "dvec4 minInvocationsExclusiveScanAMD(dvec4);"
2359
2360 "int64_t minInvocationsExclusiveScanAMD(int64_t);"
2361 "i64vec2 minInvocationsExclusiveScanAMD(i64vec2);"
2362 "i64vec3 minInvocationsExclusiveScanAMD(i64vec3);"
2363 "i64vec4 minInvocationsExclusiveScanAMD(i64vec4);"
2364
2365 "uint64_t minInvocationsExclusiveScanAMD(uint64_t);"
2366 "u64vec2 minInvocationsExclusiveScanAMD(u64vec2);"
2367 "u64vec3 minInvocationsExclusiveScanAMD(u64vec3);"
2368 "u64vec4 minInvocationsExclusiveScanAMD(u64vec4);"
2369
2370 "float16_t minInvocationsExclusiveScanAMD(float16_t);"
2371 "f16vec2 minInvocationsExclusiveScanAMD(f16vec2);"
2372 "f16vec3 minInvocationsExclusiveScanAMD(f16vec3);"
2373 "f16vec4 minInvocationsExclusiveScanAMD(f16vec4);"
2374
2375 "int16_t minInvocationsExclusiveScanAMD(int16_t);"
2376 "i16vec2 minInvocationsExclusiveScanAMD(i16vec2);"
2377 "i16vec3 minInvocationsExclusiveScanAMD(i16vec3);"
2378 "i16vec4 minInvocationsExclusiveScanAMD(i16vec4);"
2379
2380 "uint16_t minInvocationsExclusiveScanAMD(uint16_t);"
2381 "u16vec2 minInvocationsExclusiveScanAMD(u16vec2);"
2382 "u16vec3 minInvocationsExclusiveScanAMD(u16vec3);"
2383 "u16vec4 minInvocationsExclusiveScanAMD(u16vec4);"
2384
2385 "float maxInvocationsAMD(float);"
2386 "vec2 maxInvocationsAMD(vec2);"
2387 "vec3 maxInvocationsAMD(vec3);"
2388 "vec4 maxInvocationsAMD(vec4);"
2389
2390 "int maxInvocationsAMD(int);"
2391 "ivec2 maxInvocationsAMD(ivec2);"
2392 "ivec3 maxInvocationsAMD(ivec3);"
2393 "ivec4 maxInvocationsAMD(ivec4);"
2394
2395 "uint maxInvocationsAMD(uint);"
2396 "uvec2 maxInvocationsAMD(uvec2);"
2397 "uvec3 maxInvocationsAMD(uvec3);"
2398 "uvec4 maxInvocationsAMD(uvec4);"
2399
2400 "double maxInvocationsAMD(double);"
2401 "dvec2 maxInvocationsAMD(dvec2);"
2402 "dvec3 maxInvocationsAMD(dvec3);"
2403 "dvec4 maxInvocationsAMD(dvec4);"
2404
2405 "int64_t maxInvocationsAMD(int64_t);"
2406 "i64vec2 maxInvocationsAMD(i64vec2);"
2407 "i64vec3 maxInvocationsAMD(i64vec3);"
2408 "i64vec4 maxInvocationsAMD(i64vec4);"
2409
2410 "uint64_t maxInvocationsAMD(uint64_t);"
2411 "u64vec2 maxInvocationsAMD(u64vec2);"
2412 "u64vec3 maxInvocationsAMD(u64vec3);"
2413 "u64vec4 maxInvocationsAMD(u64vec4);"
2414
2415 "float16_t maxInvocationsAMD(float16_t);"
2416 "f16vec2 maxInvocationsAMD(f16vec2);"
2417 "f16vec3 maxInvocationsAMD(f16vec3);"
2418 "f16vec4 maxInvocationsAMD(f16vec4);"
2419
2420 "int16_t maxInvocationsAMD(int16_t);"
2421 "i16vec2 maxInvocationsAMD(i16vec2);"
2422 "i16vec3 maxInvocationsAMD(i16vec3);"
2423 "i16vec4 maxInvocationsAMD(i16vec4);"
2424
2425 "uint16_t maxInvocationsAMD(uint16_t);"
2426 "u16vec2 maxInvocationsAMD(u16vec2);"
2427 "u16vec3 maxInvocationsAMD(u16vec3);"
2428 "u16vec4 maxInvocationsAMD(u16vec4);"
2429
2430 "float maxInvocationsInclusiveScanAMD(float);"
2431 "vec2 maxInvocationsInclusiveScanAMD(vec2);"
2432 "vec3 maxInvocationsInclusiveScanAMD(vec3);"
2433 "vec4 maxInvocationsInclusiveScanAMD(vec4);"
2434
2435 "int maxInvocationsInclusiveScanAMD(int);"
2436 "ivec2 maxInvocationsInclusiveScanAMD(ivec2);"
2437 "ivec3 maxInvocationsInclusiveScanAMD(ivec3);"
2438 "ivec4 maxInvocationsInclusiveScanAMD(ivec4);"
2439
2440 "uint maxInvocationsInclusiveScanAMD(uint);"
2441 "uvec2 maxInvocationsInclusiveScanAMD(uvec2);"
2442 "uvec3 maxInvocationsInclusiveScanAMD(uvec3);"
2443 "uvec4 maxInvocationsInclusiveScanAMD(uvec4);"
2444
2445 "double maxInvocationsInclusiveScanAMD(double);"
2446 "dvec2 maxInvocationsInclusiveScanAMD(dvec2);"
2447 "dvec3 maxInvocationsInclusiveScanAMD(dvec3);"
2448 "dvec4 maxInvocationsInclusiveScanAMD(dvec4);"
2449
2450 "int64_t maxInvocationsInclusiveScanAMD(int64_t);"
2451 "i64vec2 maxInvocationsInclusiveScanAMD(i64vec2);"
2452 "i64vec3 maxInvocationsInclusiveScanAMD(i64vec3);"
2453 "i64vec4 maxInvocationsInclusiveScanAMD(i64vec4);"
2454
2455 "uint64_t maxInvocationsInclusiveScanAMD(uint64_t);"
2456 "u64vec2 maxInvocationsInclusiveScanAMD(u64vec2);"
2457 "u64vec3 maxInvocationsInclusiveScanAMD(u64vec3);"
2458 "u64vec4 maxInvocationsInclusiveScanAMD(u64vec4);"
2459
2460 "float16_t maxInvocationsInclusiveScanAMD(float16_t);"
2461 "f16vec2 maxInvocationsInclusiveScanAMD(f16vec2);"
2462 "f16vec3 maxInvocationsInclusiveScanAMD(f16vec3);"
2463 "f16vec4 maxInvocationsInclusiveScanAMD(f16vec4);"
2464
2465 "int16_t maxInvocationsInclusiveScanAMD(int16_t);"
2466 "i16vec2 maxInvocationsInclusiveScanAMD(i16vec2);"
2467 "i16vec3 maxInvocationsInclusiveScanAMD(i16vec3);"
2468 "i16vec4 maxInvocationsInclusiveScanAMD(i16vec4);"
2469
2470 "uint16_t maxInvocationsInclusiveScanAMD(uint16_t);"
2471 "u16vec2 maxInvocationsInclusiveScanAMD(u16vec2);"
2472 "u16vec3 maxInvocationsInclusiveScanAMD(u16vec3);"
2473 "u16vec4 maxInvocationsInclusiveScanAMD(u16vec4);"
2474
2475 "float maxInvocationsExclusiveScanAMD(float);"
2476 "vec2 maxInvocationsExclusiveScanAMD(vec2);"
2477 "vec3 maxInvocationsExclusiveScanAMD(vec3);"
2478 "vec4 maxInvocationsExclusiveScanAMD(vec4);"
2479
2480 "int maxInvocationsExclusiveScanAMD(int);"
2481 "ivec2 maxInvocationsExclusiveScanAMD(ivec2);"
2482 "ivec3 maxInvocationsExclusiveScanAMD(ivec3);"
2483 "ivec4 maxInvocationsExclusiveScanAMD(ivec4);"
2484
2485 "uint maxInvocationsExclusiveScanAMD(uint);"
2486 "uvec2 maxInvocationsExclusiveScanAMD(uvec2);"
2487 "uvec3 maxInvocationsExclusiveScanAMD(uvec3);"
2488 "uvec4 maxInvocationsExclusiveScanAMD(uvec4);"
2489
2490 "double maxInvocationsExclusiveScanAMD(double);"
2491 "dvec2 maxInvocationsExclusiveScanAMD(dvec2);"
2492 "dvec3 maxInvocationsExclusiveScanAMD(dvec3);"
2493 "dvec4 maxInvocationsExclusiveScanAMD(dvec4);"
2494
2495 "int64_t maxInvocationsExclusiveScanAMD(int64_t);"
2496 "i64vec2 maxInvocationsExclusiveScanAMD(i64vec2);"
2497 "i64vec3 maxInvocationsExclusiveScanAMD(i64vec3);"
2498 "i64vec4 maxInvocationsExclusiveScanAMD(i64vec4);"
2499
2500 "uint64_t maxInvocationsExclusiveScanAMD(uint64_t);"
2501 "u64vec2 maxInvocationsExclusiveScanAMD(u64vec2);"
2502 "u64vec3 maxInvocationsExclusiveScanAMD(u64vec3);"
2503 "u64vec4 maxInvocationsExclusiveScanAMD(u64vec4);"
2504
2505 "float16_t maxInvocationsExclusiveScanAMD(float16_t);"
2506 "f16vec2 maxInvocationsExclusiveScanAMD(f16vec2);"
2507 "f16vec3 maxInvocationsExclusiveScanAMD(f16vec3);"
2508 "f16vec4 maxInvocationsExclusiveScanAMD(f16vec4);"
2509
2510 "int16_t maxInvocationsExclusiveScanAMD(int16_t);"
2511 "i16vec2 maxInvocationsExclusiveScanAMD(i16vec2);"
2512 "i16vec3 maxInvocationsExclusiveScanAMD(i16vec3);"
2513 "i16vec4 maxInvocationsExclusiveScanAMD(i16vec4);"
2514
2515 "uint16_t maxInvocationsExclusiveScanAMD(uint16_t);"
2516 "u16vec2 maxInvocationsExclusiveScanAMD(u16vec2);"
2517 "u16vec3 maxInvocationsExclusiveScanAMD(u16vec3);"
2518 "u16vec4 maxInvocationsExclusiveScanAMD(u16vec4);"
2519
2520 "float addInvocationsAMD(float);"
2521 "vec2 addInvocationsAMD(vec2);"
2522 "vec3 addInvocationsAMD(vec3);"
2523 "vec4 addInvocationsAMD(vec4);"
2524
2525 "int addInvocationsAMD(int);"
2526 "ivec2 addInvocationsAMD(ivec2);"
2527 "ivec3 addInvocationsAMD(ivec3);"
2528 "ivec4 addInvocationsAMD(ivec4);"
2529
2530 "uint addInvocationsAMD(uint);"
2531 "uvec2 addInvocationsAMD(uvec2);"
2532 "uvec3 addInvocationsAMD(uvec3);"
2533 "uvec4 addInvocationsAMD(uvec4);"
2534
2535 "double addInvocationsAMD(double);"
2536 "dvec2 addInvocationsAMD(dvec2);"
2537 "dvec3 addInvocationsAMD(dvec3);"
2538 "dvec4 addInvocationsAMD(dvec4);"
2539
2540 "int64_t addInvocationsAMD(int64_t);"
2541 "i64vec2 addInvocationsAMD(i64vec2);"
2542 "i64vec3 addInvocationsAMD(i64vec3);"
2543 "i64vec4 addInvocationsAMD(i64vec4);"
2544
2545 "uint64_t addInvocationsAMD(uint64_t);"
2546 "u64vec2 addInvocationsAMD(u64vec2);"
2547 "u64vec3 addInvocationsAMD(u64vec3);"
2548 "u64vec4 addInvocationsAMD(u64vec4);"
2549
2550 "float16_t addInvocationsAMD(float16_t);"
2551 "f16vec2 addInvocationsAMD(f16vec2);"
2552 "f16vec3 addInvocationsAMD(f16vec3);"
2553 "f16vec4 addInvocationsAMD(f16vec4);"
2554
2555 "int16_t addInvocationsAMD(int16_t);"
2556 "i16vec2 addInvocationsAMD(i16vec2);"
2557 "i16vec3 addInvocationsAMD(i16vec3);"
2558 "i16vec4 addInvocationsAMD(i16vec4);"
2559
2560 "uint16_t addInvocationsAMD(uint16_t);"
2561 "u16vec2 addInvocationsAMD(u16vec2);"
2562 "u16vec3 addInvocationsAMD(u16vec3);"
2563 "u16vec4 addInvocationsAMD(u16vec4);"
2564
2565 "float addInvocationsInclusiveScanAMD(float);"
2566 "vec2 addInvocationsInclusiveScanAMD(vec2);"
2567 "vec3 addInvocationsInclusiveScanAMD(vec3);"
2568 "vec4 addInvocationsInclusiveScanAMD(vec4);"
2569
2570 "int addInvocationsInclusiveScanAMD(int);"
2571 "ivec2 addInvocationsInclusiveScanAMD(ivec2);"
2572 "ivec3 addInvocationsInclusiveScanAMD(ivec3);"
2573 "ivec4 addInvocationsInclusiveScanAMD(ivec4);"
2574
2575 "uint addInvocationsInclusiveScanAMD(uint);"
2576 "uvec2 addInvocationsInclusiveScanAMD(uvec2);"
2577 "uvec3 addInvocationsInclusiveScanAMD(uvec3);"
2578 "uvec4 addInvocationsInclusiveScanAMD(uvec4);"
2579
2580 "double addInvocationsInclusiveScanAMD(double);"
2581 "dvec2 addInvocationsInclusiveScanAMD(dvec2);"
2582 "dvec3 addInvocationsInclusiveScanAMD(dvec3);"
2583 "dvec4 addInvocationsInclusiveScanAMD(dvec4);"
2584
2585 "int64_t addInvocationsInclusiveScanAMD(int64_t);"
2586 "i64vec2 addInvocationsInclusiveScanAMD(i64vec2);"
2587 "i64vec3 addInvocationsInclusiveScanAMD(i64vec3);"
2588 "i64vec4 addInvocationsInclusiveScanAMD(i64vec4);"
2589
2590 "uint64_t addInvocationsInclusiveScanAMD(uint64_t);"
2591 "u64vec2 addInvocationsInclusiveScanAMD(u64vec2);"
2592 "u64vec3 addInvocationsInclusiveScanAMD(u64vec3);"
2593 "u64vec4 addInvocationsInclusiveScanAMD(u64vec4);"
2594
2595 "float16_t addInvocationsInclusiveScanAMD(float16_t);"
2596 "f16vec2 addInvocationsInclusiveScanAMD(f16vec2);"
2597 "f16vec3 addInvocationsInclusiveScanAMD(f16vec3);"
2598 "f16vec4 addInvocationsInclusiveScanAMD(f16vec4);"
2599
2600 "int16_t addInvocationsInclusiveScanAMD(int16_t);"
2601 "i16vec2 addInvocationsInclusiveScanAMD(i16vec2);"
2602 "i16vec3 addInvocationsInclusiveScanAMD(i16vec3);"
2603 "i16vec4 addInvocationsInclusiveScanAMD(i16vec4);"
2604
2605 "uint16_t addInvocationsInclusiveScanAMD(uint16_t);"
2606 "u16vec2 addInvocationsInclusiveScanAMD(u16vec2);"
2607 "u16vec3 addInvocationsInclusiveScanAMD(u16vec3);"
2608 "u16vec4 addInvocationsInclusiveScanAMD(u16vec4);"
2609
2610 "float addInvocationsExclusiveScanAMD(float);"
2611 "vec2 addInvocationsExclusiveScanAMD(vec2);"
2612 "vec3 addInvocationsExclusiveScanAMD(vec3);"
2613 "vec4 addInvocationsExclusiveScanAMD(vec4);"
2614
2615 "int addInvocationsExclusiveScanAMD(int);"
2616 "ivec2 addInvocationsExclusiveScanAMD(ivec2);"
2617 "ivec3 addInvocationsExclusiveScanAMD(ivec3);"
2618 "ivec4 addInvocationsExclusiveScanAMD(ivec4);"
2619
2620 "uint addInvocationsExclusiveScanAMD(uint);"
2621 "uvec2 addInvocationsExclusiveScanAMD(uvec2);"
2622 "uvec3 addInvocationsExclusiveScanAMD(uvec3);"
2623 "uvec4 addInvocationsExclusiveScanAMD(uvec4);"
2624
2625 "double addInvocationsExclusiveScanAMD(double);"
2626 "dvec2 addInvocationsExclusiveScanAMD(dvec2);"
2627 "dvec3 addInvocationsExclusiveScanAMD(dvec3);"
2628 "dvec4 addInvocationsExclusiveScanAMD(dvec4);"
2629
2630 "int64_t addInvocationsExclusiveScanAMD(int64_t);"
2631 "i64vec2 addInvocationsExclusiveScanAMD(i64vec2);"
2632 "i64vec3 addInvocationsExclusiveScanAMD(i64vec3);"
2633 "i64vec4 addInvocationsExclusiveScanAMD(i64vec4);"
2634
2635 "uint64_t addInvocationsExclusiveScanAMD(uint64_t);"
2636 "u64vec2 addInvocationsExclusiveScanAMD(u64vec2);"
2637 "u64vec3 addInvocationsExclusiveScanAMD(u64vec3);"
2638 "u64vec4 addInvocationsExclusiveScanAMD(u64vec4);"
2639
2640 "float16_t addInvocationsExclusiveScanAMD(float16_t);"
2641 "f16vec2 addInvocationsExclusiveScanAMD(f16vec2);"
2642 "f16vec3 addInvocationsExclusiveScanAMD(f16vec3);"
2643 "f16vec4 addInvocationsExclusiveScanAMD(f16vec4);"
2644
2645 "int16_t addInvocationsExclusiveScanAMD(int16_t);"
2646 "i16vec2 addInvocationsExclusiveScanAMD(i16vec2);"
2647 "i16vec3 addInvocationsExclusiveScanAMD(i16vec3);"
2648 "i16vec4 addInvocationsExclusiveScanAMD(i16vec4);"
2649
2650 "uint16_t addInvocationsExclusiveScanAMD(uint16_t);"
2651 "u16vec2 addInvocationsExclusiveScanAMD(u16vec2);"
2652 "u16vec3 addInvocationsExclusiveScanAMD(u16vec3);"
2653 "u16vec4 addInvocationsExclusiveScanAMD(u16vec4);"
2654
2655 "float minInvocationsNonUniformAMD(float);"
2656 "vec2 minInvocationsNonUniformAMD(vec2);"
2657 "vec3 minInvocationsNonUniformAMD(vec3);"
2658 "vec4 minInvocationsNonUniformAMD(vec4);"
2659
2660 "int minInvocationsNonUniformAMD(int);"
2661 "ivec2 minInvocationsNonUniformAMD(ivec2);"
2662 "ivec3 minInvocationsNonUniformAMD(ivec3);"
2663 "ivec4 minInvocationsNonUniformAMD(ivec4);"
2664
2665 "uint minInvocationsNonUniformAMD(uint);"
2666 "uvec2 minInvocationsNonUniformAMD(uvec2);"
2667 "uvec3 minInvocationsNonUniformAMD(uvec3);"
2668 "uvec4 minInvocationsNonUniformAMD(uvec4);"
2669
2670 "double minInvocationsNonUniformAMD(double);"
2671 "dvec2 minInvocationsNonUniformAMD(dvec2);"
2672 "dvec3 minInvocationsNonUniformAMD(dvec3);"
2673 "dvec4 minInvocationsNonUniformAMD(dvec4);"
2674
2675 "int64_t minInvocationsNonUniformAMD(int64_t);"
2676 "i64vec2 minInvocationsNonUniformAMD(i64vec2);"
2677 "i64vec3 minInvocationsNonUniformAMD(i64vec3);"
2678 "i64vec4 minInvocationsNonUniformAMD(i64vec4);"
2679
2680 "uint64_t minInvocationsNonUniformAMD(uint64_t);"
2681 "u64vec2 minInvocationsNonUniformAMD(u64vec2);"
2682 "u64vec3 minInvocationsNonUniformAMD(u64vec3);"
2683 "u64vec4 minInvocationsNonUniformAMD(u64vec4);"
2684
2685 "float16_t minInvocationsNonUniformAMD(float16_t);"
2686 "f16vec2 minInvocationsNonUniformAMD(f16vec2);"
2687 "f16vec3 minInvocationsNonUniformAMD(f16vec3);"
2688 "f16vec4 minInvocationsNonUniformAMD(f16vec4);"
2689
2690 "int16_t minInvocationsNonUniformAMD(int16_t);"
2691 "i16vec2 minInvocationsNonUniformAMD(i16vec2);"
2692 "i16vec3 minInvocationsNonUniformAMD(i16vec3);"
2693 "i16vec4 minInvocationsNonUniformAMD(i16vec4);"
2694
2695 "uint16_t minInvocationsNonUniformAMD(uint16_t);"
2696 "u16vec2 minInvocationsNonUniformAMD(u16vec2);"
2697 "u16vec3 minInvocationsNonUniformAMD(u16vec3);"
2698 "u16vec4 minInvocationsNonUniformAMD(u16vec4);"
2699
2700 "float minInvocationsInclusiveScanNonUniformAMD(float);"
2701 "vec2 minInvocationsInclusiveScanNonUniformAMD(vec2);"
2702 "vec3 minInvocationsInclusiveScanNonUniformAMD(vec3);"
2703 "vec4 minInvocationsInclusiveScanNonUniformAMD(vec4);"
2704
2705 "int minInvocationsInclusiveScanNonUniformAMD(int);"
2706 "ivec2 minInvocationsInclusiveScanNonUniformAMD(ivec2);"
2707 "ivec3 minInvocationsInclusiveScanNonUniformAMD(ivec3);"
2708 "ivec4 minInvocationsInclusiveScanNonUniformAMD(ivec4);"
2709
2710 "uint minInvocationsInclusiveScanNonUniformAMD(uint);"
2711 "uvec2 minInvocationsInclusiveScanNonUniformAMD(uvec2);"
2712 "uvec3 minInvocationsInclusiveScanNonUniformAMD(uvec3);"
2713 "uvec4 minInvocationsInclusiveScanNonUniformAMD(uvec4);"
2714
2715 "double minInvocationsInclusiveScanNonUniformAMD(double);"
2716 "dvec2 minInvocationsInclusiveScanNonUniformAMD(dvec2);"
2717 "dvec3 minInvocationsInclusiveScanNonUniformAMD(dvec3);"
2718 "dvec4 minInvocationsInclusiveScanNonUniformAMD(dvec4);"
2719
2720 "int64_t minInvocationsInclusiveScanNonUniformAMD(int64_t);"
2721 "i64vec2 minInvocationsInclusiveScanNonUniformAMD(i64vec2);"
2722 "i64vec3 minInvocationsInclusiveScanNonUniformAMD(i64vec3);"
2723 "i64vec4 minInvocationsInclusiveScanNonUniformAMD(i64vec4);"
2724
2725 "uint64_t minInvocationsInclusiveScanNonUniformAMD(uint64_t);"
2726 "u64vec2 minInvocationsInclusiveScanNonUniformAMD(u64vec2);"
2727 "u64vec3 minInvocationsInclusiveScanNonUniformAMD(u64vec3);"
2728 "u64vec4 minInvocationsInclusiveScanNonUniformAMD(u64vec4);"
2729
2730 "float16_t minInvocationsInclusiveScanNonUniformAMD(float16_t);"
2731 "f16vec2 minInvocationsInclusiveScanNonUniformAMD(f16vec2);"
2732 "f16vec3 minInvocationsInclusiveScanNonUniformAMD(f16vec3);"
2733 "f16vec4 minInvocationsInclusiveScanNonUniformAMD(f16vec4);"
2734
2735 "int16_t minInvocationsInclusiveScanNonUniformAMD(int16_t);"
2736 "i16vec2 minInvocationsInclusiveScanNonUniformAMD(i16vec2);"
2737 "i16vec3 minInvocationsInclusiveScanNonUniformAMD(i16vec3);"
2738 "i16vec4 minInvocationsInclusiveScanNonUniformAMD(i16vec4);"
2739
2740 "uint16_t minInvocationsInclusiveScanNonUniformAMD(uint16_t);"
2741 "u16vec2 minInvocationsInclusiveScanNonUniformAMD(u16vec2);"
2742 "u16vec3 minInvocationsInclusiveScanNonUniformAMD(u16vec3);"
2743 "u16vec4 minInvocationsInclusiveScanNonUniformAMD(u16vec4);"
2744
2745 "float minInvocationsExclusiveScanNonUniformAMD(float);"
2746 "vec2 minInvocationsExclusiveScanNonUniformAMD(vec2);"
2747 "vec3 minInvocationsExclusiveScanNonUniformAMD(vec3);"
2748 "vec4 minInvocationsExclusiveScanNonUniformAMD(vec4);"
2749
2750 "int minInvocationsExclusiveScanNonUniformAMD(int);"
2751 "ivec2 minInvocationsExclusiveScanNonUniformAMD(ivec2);"
2752 "ivec3 minInvocationsExclusiveScanNonUniformAMD(ivec3);"
2753 "ivec4 minInvocationsExclusiveScanNonUniformAMD(ivec4);"
2754
2755 "uint minInvocationsExclusiveScanNonUniformAMD(uint);"
2756 "uvec2 minInvocationsExclusiveScanNonUniformAMD(uvec2);"
2757 "uvec3 minInvocationsExclusiveScanNonUniformAMD(uvec3);"
2758 "uvec4 minInvocationsExclusiveScanNonUniformAMD(uvec4);"
2759
2760 "double minInvocationsExclusiveScanNonUniformAMD(double);"
2761 "dvec2 minInvocationsExclusiveScanNonUniformAMD(dvec2);"
2762 "dvec3 minInvocationsExclusiveScanNonUniformAMD(dvec3);"
2763 "dvec4 minInvocationsExclusiveScanNonUniformAMD(dvec4);"
2764
2765 "int64_t minInvocationsExclusiveScanNonUniformAMD(int64_t);"
2766 "i64vec2 minInvocationsExclusiveScanNonUniformAMD(i64vec2);"
2767 "i64vec3 minInvocationsExclusiveScanNonUniformAMD(i64vec3);"
2768 "i64vec4 minInvocationsExclusiveScanNonUniformAMD(i64vec4);"
2769
2770 "uint64_t minInvocationsExclusiveScanNonUniformAMD(uint64_t);"
2771 "u64vec2 minInvocationsExclusiveScanNonUniformAMD(u64vec2);"
2772 "u64vec3 minInvocationsExclusiveScanNonUniformAMD(u64vec3);"
2773 "u64vec4 minInvocationsExclusiveScanNonUniformAMD(u64vec4);"
2774
2775 "float16_t minInvocationsExclusiveScanNonUniformAMD(float16_t);"
2776 "f16vec2 minInvocationsExclusiveScanNonUniformAMD(f16vec2);"
2777 "f16vec3 minInvocationsExclusiveScanNonUniformAMD(f16vec3);"
2778 "f16vec4 minInvocationsExclusiveScanNonUniformAMD(f16vec4);"
2779
2780 "int16_t minInvocationsExclusiveScanNonUniformAMD(int16_t);"
2781 "i16vec2 minInvocationsExclusiveScanNonUniformAMD(i16vec2);"
2782 "i16vec3 minInvocationsExclusiveScanNonUniformAMD(i16vec3);"
2783 "i16vec4 minInvocationsExclusiveScanNonUniformAMD(i16vec4);"
2784
2785 "uint16_t minInvocationsExclusiveScanNonUniformAMD(uint16_t);"
2786 "u16vec2 minInvocationsExclusiveScanNonUniformAMD(u16vec2);"
2787 "u16vec3 minInvocationsExclusiveScanNonUniformAMD(u16vec3);"
2788 "u16vec4 minInvocationsExclusiveScanNonUniformAMD(u16vec4);"
2789
2790 "float maxInvocationsNonUniformAMD(float);"
2791 "vec2 maxInvocationsNonUniformAMD(vec2);"
2792 "vec3 maxInvocationsNonUniformAMD(vec3);"
2793 "vec4 maxInvocationsNonUniformAMD(vec4);"
2794
2795 "int maxInvocationsNonUniformAMD(int);"
2796 "ivec2 maxInvocationsNonUniformAMD(ivec2);"
2797 "ivec3 maxInvocationsNonUniformAMD(ivec3);"
2798 "ivec4 maxInvocationsNonUniformAMD(ivec4);"
2799
2800 "uint maxInvocationsNonUniformAMD(uint);"
2801 "uvec2 maxInvocationsNonUniformAMD(uvec2);"
2802 "uvec3 maxInvocationsNonUniformAMD(uvec3);"
2803 "uvec4 maxInvocationsNonUniformAMD(uvec4);"
2804
2805 "double maxInvocationsNonUniformAMD(double);"
2806 "dvec2 maxInvocationsNonUniformAMD(dvec2);"
2807 "dvec3 maxInvocationsNonUniformAMD(dvec3);"
2808 "dvec4 maxInvocationsNonUniformAMD(dvec4);"
2809
2810 "int64_t maxInvocationsNonUniformAMD(int64_t);"
2811 "i64vec2 maxInvocationsNonUniformAMD(i64vec2);"
2812 "i64vec3 maxInvocationsNonUniformAMD(i64vec3);"
2813 "i64vec4 maxInvocationsNonUniformAMD(i64vec4);"
2814
2815 "uint64_t maxInvocationsNonUniformAMD(uint64_t);"
2816 "u64vec2 maxInvocationsNonUniformAMD(u64vec2);"
2817 "u64vec3 maxInvocationsNonUniformAMD(u64vec3);"
2818 "u64vec4 maxInvocationsNonUniformAMD(u64vec4);"
2819
2820 "float16_t maxInvocationsNonUniformAMD(float16_t);"
2821 "f16vec2 maxInvocationsNonUniformAMD(f16vec2);"
2822 "f16vec3 maxInvocationsNonUniformAMD(f16vec3);"
2823 "f16vec4 maxInvocationsNonUniformAMD(f16vec4);"
2824
2825 "int16_t maxInvocationsNonUniformAMD(int16_t);"
2826 "i16vec2 maxInvocationsNonUniformAMD(i16vec2);"
2827 "i16vec3 maxInvocationsNonUniformAMD(i16vec3);"
2828 "i16vec4 maxInvocationsNonUniformAMD(i16vec4);"
2829
2830 "uint16_t maxInvocationsNonUniformAMD(uint16_t);"
2831 "u16vec2 maxInvocationsNonUniformAMD(u16vec2);"
2832 "u16vec3 maxInvocationsNonUniformAMD(u16vec3);"
2833 "u16vec4 maxInvocationsNonUniformAMD(u16vec4);"
2834
2835 "float maxInvocationsInclusiveScanNonUniformAMD(float);"
2836 "vec2 maxInvocationsInclusiveScanNonUniformAMD(vec2);"
2837 "vec3 maxInvocationsInclusiveScanNonUniformAMD(vec3);"
2838 "vec4 maxInvocationsInclusiveScanNonUniformAMD(vec4);"
2839
2840 "int maxInvocationsInclusiveScanNonUniformAMD(int);"
2841 "ivec2 maxInvocationsInclusiveScanNonUniformAMD(ivec2);"
2842 "ivec3 maxInvocationsInclusiveScanNonUniformAMD(ivec3);"
2843 "ivec4 maxInvocationsInclusiveScanNonUniformAMD(ivec4);"
2844
2845 "uint maxInvocationsInclusiveScanNonUniformAMD(uint);"
2846 "uvec2 maxInvocationsInclusiveScanNonUniformAMD(uvec2);"
2847 "uvec3 maxInvocationsInclusiveScanNonUniformAMD(uvec3);"
2848 "uvec4 maxInvocationsInclusiveScanNonUniformAMD(uvec4);"
2849
2850 "double maxInvocationsInclusiveScanNonUniformAMD(double);"
2851 "dvec2 maxInvocationsInclusiveScanNonUniformAMD(dvec2);"
2852 "dvec3 maxInvocationsInclusiveScanNonUniformAMD(dvec3);"
2853 "dvec4 maxInvocationsInclusiveScanNonUniformAMD(dvec4);"
2854
2855 "int64_t maxInvocationsInclusiveScanNonUniformAMD(int64_t);"
2856 "i64vec2 maxInvocationsInclusiveScanNonUniformAMD(i64vec2);"
2857 "i64vec3 maxInvocationsInclusiveScanNonUniformAMD(i64vec3);"
2858 "i64vec4 maxInvocationsInclusiveScanNonUniformAMD(i64vec4);"
2859
2860 "uint64_t maxInvocationsInclusiveScanNonUniformAMD(uint64_t);"
2861 "u64vec2 maxInvocationsInclusiveScanNonUniformAMD(u64vec2);"
2862 "u64vec3 maxInvocationsInclusiveScanNonUniformAMD(u64vec3);"
2863 "u64vec4 maxInvocationsInclusiveScanNonUniformAMD(u64vec4);"
2864
2865 "float16_t maxInvocationsInclusiveScanNonUniformAMD(float16_t);"
2866 "f16vec2 maxInvocationsInclusiveScanNonUniformAMD(f16vec2);"
2867 "f16vec3 maxInvocationsInclusiveScanNonUniformAMD(f16vec3);"
2868 "f16vec4 maxInvocationsInclusiveScanNonUniformAMD(f16vec4);"
2869
2870 "int16_t maxInvocationsInclusiveScanNonUniformAMD(int16_t);"
2871 "i16vec2 maxInvocationsInclusiveScanNonUniformAMD(i16vec2);"
2872 "i16vec3 maxInvocationsInclusiveScanNonUniformAMD(i16vec3);"
2873 "i16vec4 maxInvocationsInclusiveScanNonUniformAMD(i16vec4);"
2874
2875 "uint16_t maxInvocationsInclusiveScanNonUniformAMD(uint16_t);"
2876 "u16vec2 maxInvocationsInclusiveScanNonUniformAMD(u16vec2);"
2877 "u16vec3 maxInvocationsInclusiveScanNonUniformAMD(u16vec3);"
2878 "u16vec4 maxInvocationsInclusiveScanNonUniformAMD(u16vec4);"
2879
2880 "float maxInvocationsExclusiveScanNonUniformAMD(float);"
2881 "vec2 maxInvocationsExclusiveScanNonUniformAMD(vec2);"
2882 "vec3 maxInvocationsExclusiveScanNonUniformAMD(vec3);"
2883 "vec4 maxInvocationsExclusiveScanNonUniformAMD(vec4);"
2884
2885 "int maxInvocationsExclusiveScanNonUniformAMD(int);"
2886 "ivec2 maxInvocationsExclusiveScanNonUniformAMD(ivec2);"
2887 "ivec3 maxInvocationsExclusiveScanNonUniformAMD(ivec3);"
2888 "ivec4 maxInvocationsExclusiveScanNonUniformAMD(ivec4);"
2889
2890 "uint maxInvocationsExclusiveScanNonUniformAMD(uint);"
2891 "uvec2 maxInvocationsExclusiveScanNonUniformAMD(uvec2);"
2892 "uvec3 maxInvocationsExclusiveScanNonUniformAMD(uvec3);"
2893 "uvec4 maxInvocationsExclusiveScanNonUniformAMD(uvec4);"
2894
2895 "double maxInvocationsExclusiveScanNonUniformAMD(double);"
2896 "dvec2 maxInvocationsExclusiveScanNonUniformAMD(dvec2);"
2897 "dvec3 maxInvocationsExclusiveScanNonUniformAMD(dvec3);"
2898 "dvec4 maxInvocationsExclusiveScanNonUniformAMD(dvec4);"
2899
2900 "int64_t maxInvocationsExclusiveScanNonUniformAMD(int64_t);"
2901 "i64vec2 maxInvocationsExclusiveScanNonUniformAMD(i64vec2);"
2902 "i64vec3 maxInvocationsExclusiveScanNonUniformAMD(i64vec3);"
2903 "i64vec4 maxInvocationsExclusiveScanNonUniformAMD(i64vec4);"
2904
2905 "uint64_t maxInvocationsExclusiveScanNonUniformAMD(uint64_t);"
2906 "u64vec2 maxInvocationsExclusiveScanNonUniformAMD(u64vec2);"
2907 "u64vec3 maxInvocationsExclusiveScanNonUniformAMD(u64vec3);"
2908 "u64vec4 maxInvocationsExclusiveScanNonUniformAMD(u64vec4);"
2909
2910 "float16_t maxInvocationsExclusiveScanNonUniformAMD(float16_t);"
2911 "f16vec2 maxInvocationsExclusiveScanNonUniformAMD(f16vec2);"
2912 "f16vec3 maxInvocationsExclusiveScanNonUniformAMD(f16vec3);"
2913 "f16vec4 maxInvocationsExclusiveScanNonUniformAMD(f16vec4);"
2914
2915 "int16_t maxInvocationsExclusiveScanNonUniformAMD(int16_t);"
2916 "i16vec2 maxInvocationsExclusiveScanNonUniformAMD(i16vec2);"
2917 "i16vec3 maxInvocationsExclusiveScanNonUniformAMD(i16vec3);"
2918 "i16vec4 maxInvocationsExclusiveScanNonUniformAMD(i16vec4);"
2919
2920 "uint16_t maxInvocationsExclusiveScanNonUniformAMD(uint16_t);"
2921 "u16vec2 maxInvocationsExclusiveScanNonUniformAMD(u16vec2);"
2922 "u16vec3 maxInvocationsExclusiveScanNonUniformAMD(u16vec3);"
2923 "u16vec4 maxInvocationsExclusiveScanNonUniformAMD(u16vec4);"
2924
2925 "float addInvocationsNonUniformAMD(float);"
2926 "vec2 addInvocationsNonUniformAMD(vec2);"
2927 "vec3 addInvocationsNonUniformAMD(vec3);"
2928 "vec4 addInvocationsNonUniformAMD(vec4);"
2929
2930 "int addInvocationsNonUniformAMD(int);"
2931 "ivec2 addInvocationsNonUniformAMD(ivec2);"
2932 "ivec3 addInvocationsNonUniformAMD(ivec3);"
2933 "ivec4 addInvocationsNonUniformAMD(ivec4);"
2934
2935 "uint addInvocationsNonUniformAMD(uint);"
2936 "uvec2 addInvocationsNonUniformAMD(uvec2);"
2937 "uvec3 addInvocationsNonUniformAMD(uvec3);"
2938 "uvec4 addInvocationsNonUniformAMD(uvec4);"
2939
2940 "double addInvocationsNonUniformAMD(double);"
2941 "dvec2 addInvocationsNonUniformAMD(dvec2);"
2942 "dvec3 addInvocationsNonUniformAMD(dvec3);"
2943 "dvec4 addInvocationsNonUniformAMD(dvec4);"
2944
2945 "int64_t addInvocationsNonUniformAMD(int64_t);"
2946 "i64vec2 addInvocationsNonUniformAMD(i64vec2);"
2947 "i64vec3 addInvocationsNonUniformAMD(i64vec3);"
2948 "i64vec4 addInvocationsNonUniformAMD(i64vec4);"
2949
2950 "uint64_t addInvocationsNonUniformAMD(uint64_t);"
2951 "u64vec2 addInvocationsNonUniformAMD(u64vec2);"
2952 "u64vec3 addInvocationsNonUniformAMD(u64vec3);"
2953 "u64vec4 addInvocationsNonUniformAMD(u64vec4);"
2954
2955 "float16_t addInvocationsNonUniformAMD(float16_t);"
2956 "f16vec2 addInvocationsNonUniformAMD(f16vec2);"
2957 "f16vec3 addInvocationsNonUniformAMD(f16vec3);"
2958 "f16vec4 addInvocationsNonUniformAMD(f16vec4);"
2959
2960 "int16_t addInvocationsNonUniformAMD(int16_t);"
2961 "i16vec2 addInvocationsNonUniformAMD(i16vec2);"
2962 "i16vec3 addInvocationsNonUniformAMD(i16vec3);"
2963 "i16vec4 addInvocationsNonUniformAMD(i16vec4);"
2964
2965 "uint16_t addInvocationsNonUniformAMD(uint16_t);"
2966 "u16vec2 addInvocationsNonUniformAMD(u16vec2);"
2967 "u16vec3 addInvocationsNonUniformAMD(u16vec3);"
2968 "u16vec4 addInvocationsNonUniformAMD(u16vec4);"
2969
2970 "float addInvocationsInclusiveScanNonUniformAMD(float);"
2971 "vec2 addInvocationsInclusiveScanNonUniformAMD(vec2);"
2972 "vec3 addInvocationsInclusiveScanNonUniformAMD(vec3);"
2973 "vec4 addInvocationsInclusiveScanNonUniformAMD(vec4);"
2974
2975 "int addInvocationsInclusiveScanNonUniformAMD(int);"
2976 "ivec2 addInvocationsInclusiveScanNonUniformAMD(ivec2);"
2977 "ivec3 addInvocationsInclusiveScanNonUniformAMD(ivec3);"
2978 "ivec4 addInvocationsInclusiveScanNonUniformAMD(ivec4);"
2979
2980 "uint addInvocationsInclusiveScanNonUniformAMD(uint);"
2981 "uvec2 addInvocationsInclusiveScanNonUniformAMD(uvec2);"
2982 "uvec3 addInvocationsInclusiveScanNonUniformAMD(uvec3);"
2983 "uvec4 addInvocationsInclusiveScanNonUniformAMD(uvec4);"
2984
2985 "double addInvocationsInclusiveScanNonUniformAMD(double);"
2986 "dvec2 addInvocationsInclusiveScanNonUniformAMD(dvec2);"
2987 "dvec3 addInvocationsInclusiveScanNonUniformAMD(dvec3);"
2988 "dvec4 addInvocationsInclusiveScanNonUniformAMD(dvec4);"
2989
2990 "int64_t addInvocationsInclusiveScanNonUniformAMD(int64_t);"
2991 "i64vec2 addInvocationsInclusiveScanNonUniformAMD(i64vec2);"
2992 "i64vec3 addInvocationsInclusiveScanNonUniformAMD(i64vec3);"
2993 "i64vec4 addInvocationsInclusiveScanNonUniformAMD(i64vec4);"
2994
2995 "uint64_t addInvocationsInclusiveScanNonUniformAMD(uint64_t);"
2996 "u64vec2 addInvocationsInclusiveScanNonUniformAMD(u64vec2);"
2997 "u64vec3 addInvocationsInclusiveScanNonUniformAMD(u64vec3);"
2998 "u64vec4 addInvocationsInclusiveScanNonUniformAMD(u64vec4);"
2999
3000 "float16_t addInvocationsInclusiveScanNonUniformAMD(float16_t);"
3001 "f16vec2 addInvocationsInclusiveScanNonUniformAMD(f16vec2);"
3002 "f16vec3 addInvocationsInclusiveScanNonUniformAMD(f16vec3);"
3003 "f16vec4 addInvocationsInclusiveScanNonUniformAMD(f16vec4);"
3004
3005 "int16_t addInvocationsInclusiveScanNonUniformAMD(int16_t);"
3006 "i16vec2 addInvocationsInclusiveScanNonUniformAMD(i16vec2);"
3007 "i16vec3 addInvocationsInclusiveScanNonUniformAMD(i16vec3);"
3008 "i16vec4 addInvocationsInclusiveScanNonUniformAMD(i16vec4);"
3009
3010 "uint16_t addInvocationsInclusiveScanNonUniformAMD(uint16_t);"
3011 "u16vec2 addInvocationsInclusiveScanNonUniformAMD(u16vec2);"
3012 "u16vec3 addInvocationsInclusiveScanNonUniformAMD(u16vec3);"
3013 "u16vec4 addInvocationsInclusiveScanNonUniformAMD(u16vec4);"
3014
3015 "float addInvocationsExclusiveScanNonUniformAMD(float);"
3016 "vec2 addInvocationsExclusiveScanNonUniformAMD(vec2);"
3017 "vec3 addInvocationsExclusiveScanNonUniformAMD(vec3);"
3018 "vec4 addInvocationsExclusiveScanNonUniformAMD(vec4);"
3019
3020 "int addInvocationsExclusiveScanNonUniformAMD(int);"
3021 "ivec2 addInvocationsExclusiveScanNonUniformAMD(ivec2);"
3022 "ivec3 addInvocationsExclusiveScanNonUniformAMD(ivec3);"
3023 "ivec4 addInvocationsExclusiveScanNonUniformAMD(ivec4);"
3024
3025 "uint addInvocationsExclusiveScanNonUniformAMD(uint);"
3026 "uvec2 addInvocationsExclusiveScanNonUniformAMD(uvec2);"
3027 "uvec3 addInvocationsExclusiveScanNonUniformAMD(uvec3);"
3028 "uvec4 addInvocationsExclusiveScanNonUniformAMD(uvec4);"
3029
3030 "double addInvocationsExclusiveScanNonUniformAMD(double);"
3031 "dvec2 addInvocationsExclusiveScanNonUniformAMD(dvec2);"
3032 "dvec3 addInvocationsExclusiveScanNonUniformAMD(dvec3);"
3033 "dvec4 addInvocationsExclusiveScanNonUniformAMD(dvec4);"
3034
3035 "int64_t addInvocationsExclusiveScanNonUniformAMD(int64_t);"
3036 "i64vec2 addInvocationsExclusiveScanNonUniformAMD(i64vec2);"
3037 "i64vec3 addInvocationsExclusiveScanNonUniformAMD(i64vec3);"
3038 "i64vec4 addInvocationsExclusiveScanNonUniformAMD(i64vec4);"
3039
3040 "uint64_t addInvocationsExclusiveScanNonUniformAMD(uint64_t);"
3041 "u64vec2 addInvocationsExclusiveScanNonUniformAMD(u64vec2);"
3042 "u64vec3 addInvocationsExclusiveScanNonUniformAMD(u64vec3);"
3043 "u64vec4 addInvocationsExclusiveScanNonUniformAMD(u64vec4);"
3044
3045 "float16_t addInvocationsExclusiveScanNonUniformAMD(float16_t);"
3046 "f16vec2 addInvocationsExclusiveScanNonUniformAMD(f16vec2);"
3047 "f16vec3 addInvocationsExclusiveScanNonUniformAMD(f16vec3);"
3048 "f16vec4 addInvocationsExclusiveScanNonUniformAMD(f16vec4);"
3049
3050 "int16_t addInvocationsExclusiveScanNonUniformAMD(int16_t);"
3051 "i16vec2 addInvocationsExclusiveScanNonUniformAMD(i16vec2);"
3052 "i16vec3 addInvocationsExclusiveScanNonUniformAMD(i16vec3);"
3053 "i16vec4 addInvocationsExclusiveScanNonUniformAMD(i16vec4);"
3054
3055 "uint16_t addInvocationsExclusiveScanNonUniformAMD(uint16_t);"
3056 "u16vec2 addInvocationsExclusiveScanNonUniformAMD(u16vec2);"
3057 "u16vec3 addInvocationsExclusiveScanNonUniformAMD(u16vec3);"
3058 "u16vec4 addInvocationsExclusiveScanNonUniformAMD(u16vec4);"
3059
3060 "float swizzleInvocationsAMD(float, uvec4);"
3061 "vec2 swizzleInvocationsAMD(vec2, uvec4);"
3062 "vec3 swizzleInvocationsAMD(vec3, uvec4);"
3063 "vec4 swizzleInvocationsAMD(vec4, uvec4);"
3064
3065 "int swizzleInvocationsAMD(int, uvec4);"
3066 "ivec2 swizzleInvocationsAMD(ivec2, uvec4);"
3067 "ivec3 swizzleInvocationsAMD(ivec3, uvec4);"
3068 "ivec4 swizzleInvocationsAMD(ivec4, uvec4);"
3069
3070 "uint swizzleInvocationsAMD(uint, uvec4);"
3071 "uvec2 swizzleInvocationsAMD(uvec2, uvec4);"
3072 "uvec3 swizzleInvocationsAMD(uvec3, uvec4);"
3073 "uvec4 swizzleInvocationsAMD(uvec4, uvec4);"
3074
3075 "float swizzleInvocationsMaskedAMD(float, uvec3);"
3076 "vec2 swizzleInvocationsMaskedAMD(vec2, uvec3);"
3077 "vec3 swizzleInvocationsMaskedAMD(vec3, uvec3);"
3078 "vec4 swizzleInvocationsMaskedAMD(vec4, uvec3);"
3079
3080 "int swizzleInvocationsMaskedAMD(int, uvec3);"
3081 "ivec2 swizzleInvocationsMaskedAMD(ivec2, uvec3);"
3082 "ivec3 swizzleInvocationsMaskedAMD(ivec3, uvec3);"
3083 "ivec4 swizzleInvocationsMaskedAMD(ivec4, uvec3);"
3084
3085 "uint swizzleInvocationsMaskedAMD(uint, uvec3);"
3086 "uvec2 swizzleInvocationsMaskedAMD(uvec2, uvec3);"
3087 "uvec3 swizzleInvocationsMaskedAMD(uvec3, uvec3);"
3088 "uvec4 swizzleInvocationsMaskedAMD(uvec4, uvec3);"
3089
3090 "float writeInvocationAMD(float, float, uint);"
3091 "vec2 writeInvocationAMD(vec2, vec2, uint);"
3092 "vec3 writeInvocationAMD(vec3, vec3, uint);"
3093 "vec4 writeInvocationAMD(vec4, vec4, uint);"
3094
3095 "int writeInvocationAMD(int, int, uint);"
3096 "ivec2 writeInvocationAMD(ivec2, ivec2, uint);"
3097 "ivec3 writeInvocationAMD(ivec3, ivec3, uint);"
3098 "ivec4 writeInvocationAMD(ivec4, ivec4, uint);"
3099
3100 "uint writeInvocationAMD(uint, uint, uint);"
3101 "uvec2 writeInvocationAMD(uvec2, uvec2, uint);"
3102 "uvec3 writeInvocationAMD(uvec3, uvec3, uint);"
3103 "uvec4 writeInvocationAMD(uvec4, uvec4, uint);"
3104
3105 "uint mbcntAMD(uint64_t);"
3106
3107 "\n");
3108 }
3109
3110 // GL_AMD_gcn_shader
3111 if (profile != EEsProfile && version >= 440) {
3112 commonBuiltins.append(
3113 "float cubeFaceIndexAMD(vec3);"
3114 "vec2 cubeFaceCoordAMD(vec3);"
3115 "uint64_t timeAMD();"
3116
3117 "in int gl_SIMDGroupSizeAMD;"
3118 "\n");
3119 }
3120
3121 // GL_AMD_shader_fragment_mask
3122 if (profile != EEsProfile && version >= 450) {
3123 commonBuiltins.append(
3124 "uint fragmentMaskFetchAMD(sampler2DMS, ivec2);"
3125 "uint fragmentMaskFetchAMD(isampler2DMS, ivec2);"
3126 "uint fragmentMaskFetchAMD(usampler2DMS, ivec2);"
3127
3128 "uint fragmentMaskFetchAMD(sampler2DMSArray, ivec3);"
3129 "uint fragmentMaskFetchAMD(isampler2DMSArray, ivec3);"
3130 "uint fragmentMaskFetchAMD(usampler2DMSArray, ivec3);"
3131
3132 "vec4 fragmentFetchAMD(sampler2DMS, ivec2, uint);"
3133 "ivec4 fragmentFetchAMD(isampler2DMS, ivec2, uint);"
3134 "uvec4 fragmentFetchAMD(usampler2DMS, ivec2, uint);"
3135
3136 "vec4 fragmentFetchAMD(sampler2DMSArray, ivec3, uint);"
3137 "ivec4 fragmentFetchAMD(isampler2DMSArray, ivec3, uint);"
3138 "uvec4 fragmentFetchAMD(usampler2DMSArray, ivec3, uint);"
3139
3140 "\n");
3141 }
3142
3143 if ((profile != EEsProfile && version >= 130) ||
3144 (profile == EEsProfile && version >= 300)) {
3145 commonBuiltins.append(
3146 "uint countLeadingZeros(uint);"
3147 "uvec2 countLeadingZeros(uvec2);"
3148 "uvec3 countLeadingZeros(uvec3);"
3149 "uvec4 countLeadingZeros(uvec4);"
3150
3151 "uint countTrailingZeros(uint);"
3152 "uvec2 countTrailingZeros(uvec2);"
3153 "uvec3 countTrailingZeros(uvec3);"
3154 "uvec4 countTrailingZeros(uvec4);"
3155
3156 "uint absoluteDifference(int, int);"
3157 "uvec2 absoluteDifference(ivec2, ivec2);"
3158 "uvec3 absoluteDifference(ivec3, ivec3);"
3159 "uvec4 absoluteDifference(ivec4, ivec4);"
3160
3161 "uint16_t absoluteDifference(int16_t, int16_t);"
3162 "u16vec2 absoluteDifference(i16vec2, i16vec2);"
3163 "u16vec3 absoluteDifference(i16vec3, i16vec3);"
3164 "u16vec4 absoluteDifference(i16vec4, i16vec4);"
3165
3166 "uint64_t absoluteDifference(int64_t, int64_t);"
3167 "u64vec2 absoluteDifference(i64vec2, i64vec2);"
3168 "u64vec3 absoluteDifference(i64vec3, i64vec3);"
3169 "u64vec4 absoluteDifference(i64vec4, i64vec4);"
3170
3171 "uint absoluteDifference(uint, uint);"
3172 "uvec2 absoluteDifference(uvec2, uvec2);"
3173 "uvec3 absoluteDifference(uvec3, uvec3);"
3174 "uvec4 absoluteDifference(uvec4, uvec4);"
3175
3176 "uint16_t absoluteDifference(uint16_t, uint16_t);"
3177 "u16vec2 absoluteDifference(u16vec2, u16vec2);"
3178 "u16vec3 absoluteDifference(u16vec3, u16vec3);"
3179 "u16vec4 absoluteDifference(u16vec4, u16vec4);"
3180
3181 "uint64_t absoluteDifference(uint64_t, uint64_t);"
3182 "u64vec2 absoluteDifference(u64vec2, u64vec2);"
3183 "u64vec3 absoluteDifference(u64vec3, u64vec3);"
3184 "u64vec4 absoluteDifference(u64vec4, u64vec4);"
3185
3186 "int addSaturate(int, int);"
3187 "ivec2 addSaturate(ivec2, ivec2);"
3188 "ivec3 addSaturate(ivec3, ivec3);"
3189 "ivec4 addSaturate(ivec4, ivec4);"
3190
3191 "int16_t addSaturate(int16_t, int16_t);"
3192 "i16vec2 addSaturate(i16vec2, i16vec2);"
3193 "i16vec3 addSaturate(i16vec3, i16vec3);"
3194 "i16vec4 addSaturate(i16vec4, i16vec4);"
3195
3196 "int64_t addSaturate(int64_t, int64_t);"
3197 "i64vec2 addSaturate(i64vec2, i64vec2);"
3198 "i64vec3 addSaturate(i64vec3, i64vec3);"
3199 "i64vec4 addSaturate(i64vec4, i64vec4);"
3200
3201 "uint addSaturate(uint, uint);"
3202 "uvec2 addSaturate(uvec2, uvec2);"
3203 "uvec3 addSaturate(uvec3, uvec3);"
3204 "uvec4 addSaturate(uvec4, uvec4);"
3205
3206 "uint16_t addSaturate(uint16_t, uint16_t);"
3207 "u16vec2 addSaturate(u16vec2, u16vec2);"
3208 "u16vec3 addSaturate(u16vec3, u16vec3);"
3209 "u16vec4 addSaturate(u16vec4, u16vec4);"
3210
3211 "uint64_t addSaturate(uint64_t, uint64_t);"
3212 "u64vec2 addSaturate(u64vec2, u64vec2);"
3213 "u64vec3 addSaturate(u64vec3, u64vec3);"
3214 "u64vec4 addSaturate(u64vec4, u64vec4);"
3215
3216 "int subtractSaturate(int, int);"
3217 "ivec2 subtractSaturate(ivec2, ivec2);"
3218 "ivec3 subtractSaturate(ivec3, ivec3);"
3219 "ivec4 subtractSaturate(ivec4, ivec4);"
3220
3221 "int16_t subtractSaturate(int16_t, int16_t);"
3222 "i16vec2 subtractSaturate(i16vec2, i16vec2);"
3223 "i16vec3 subtractSaturate(i16vec3, i16vec3);"
3224 "i16vec4 subtractSaturate(i16vec4, i16vec4);"
3225
3226 "int64_t subtractSaturate(int64_t, int64_t);"
3227 "i64vec2 subtractSaturate(i64vec2, i64vec2);"
3228 "i64vec3 subtractSaturate(i64vec3, i64vec3);"
3229 "i64vec4 subtractSaturate(i64vec4, i64vec4);"
3230
3231 "uint subtractSaturate(uint, uint);"
3232 "uvec2 subtractSaturate(uvec2, uvec2);"
3233 "uvec3 subtractSaturate(uvec3, uvec3);"
3234 "uvec4 subtractSaturate(uvec4, uvec4);"
3235
3236 "uint16_t subtractSaturate(uint16_t, uint16_t);"
3237 "u16vec2 subtractSaturate(u16vec2, u16vec2);"
3238 "u16vec3 subtractSaturate(u16vec3, u16vec3);"
3239 "u16vec4 subtractSaturate(u16vec4, u16vec4);"
3240
3241 "uint64_t subtractSaturate(uint64_t, uint64_t);"
3242 "u64vec2 subtractSaturate(u64vec2, u64vec2);"
3243 "u64vec3 subtractSaturate(u64vec3, u64vec3);"
3244 "u64vec4 subtractSaturate(u64vec4, u64vec4);"
3245
3246 "int average(int, int);"
3247 "ivec2 average(ivec2, ivec2);"
3248 "ivec3 average(ivec3, ivec3);"
3249 "ivec4 average(ivec4, ivec4);"
3250
3251 "int16_t average(int16_t, int16_t);"
3252 "i16vec2 average(i16vec2, i16vec2);"
3253 "i16vec3 average(i16vec3, i16vec3);"
3254 "i16vec4 average(i16vec4, i16vec4);"
3255
3256 "int64_t average(int64_t, int64_t);"
3257 "i64vec2 average(i64vec2, i64vec2);"
3258 "i64vec3 average(i64vec3, i64vec3);"
3259 "i64vec4 average(i64vec4, i64vec4);"
3260
3261 "uint average(uint, uint);"
3262 "uvec2 average(uvec2, uvec2);"
3263 "uvec3 average(uvec3, uvec3);"
3264 "uvec4 average(uvec4, uvec4);"
3265
3266 "uint16_t average(uint16_t, uint16_t);"
3267 "u16vec2 average(u16vec2, u16vec2);"
3268 "u16vec3 average(u16vec3, u16vec3);"
3269 "u16vec4 average(u16vec4, u16vec4);"
3270
3271 "uint64_t average(uint64_t, uint64_t);"
3272 "u64vec2 average(u64vec2, u64vec2);"
3273 "u64vec3 average(u64vec3, u64vec3);"
3274 "u64vec4 average(u64vec4, u64vec4);"
3275
3276 "int averageRounded(int, int);"
3277 "ivec2 averageRounded(ivec2, ivec2);"
3278 "ivec3 averageRounded(ivec3, ivec3);"
3279 "ivec4 averageRounded(ivec4, ivec4);"
3280
3281 "int16_t averageRounded(int16_t, int16_t);"
3282 "i16vec2 averageRounded(i16vec2, i16vec2);"
3283 "i16vec3 averageRounded(i16vec3, i16vec3);"
3284 "i16vec4 averageRounded(i16vec4, i16vec4);"
3285
3286 "int64_t averageRounded(int64_t, int64_t);"
3287 "i64vec2 averageRounded(i64vec2, i64vec2);"
3288 "i64vec3 averageRounded(i64vec3, i64vec3);"
3289 "i64vec4 averageRounded(i64vec4, i64vec4);"
3290
3291 "uint averageRounded(uint, uint);"
3292 "uvec2 averageRounded(uvec2, uvec2);"
3293 "uvec3 averageRounded(uvec3, uvec3);"
3294 "uvec4 averageRounded(uvec4, uvec4);"
3295
3296 "uint16_t averageRounded(uint16_t, uint16_t);"
3297 "u16vec2 averageRounded(u16vec2, u16vec2);"
3298 "u16vec3 averageRounded(u16vec3, u16vec3);"
3299 "u16vec4 averageRounded(u16vec4, u16vec4);"
3300
3301 "uint64_t averageRounded(uint64_t, uint64_t);"
3302 "u64vec2 averageRounded(u64vec2, u64vec2);"
3303 "u64vec3 averageRounded(u64vec3, u64vec3);"
3304 "u64vec4 averageRounded(u64vec4, u64vec4);"
3305
3306 "int multiply32x16(int, int);"
3307 "ivec2 multiply32x16(ivec2, ivec2);"
3308 "ivec3 multiply32x16(ivec3, ivec3);"
3309 "ivec4 multiply32x16(ivec4, ivec4);"
3310
3311 "uint multiply32x16(uint, uint);"
3312 "uvec2 multiply32x16(uvec2, uvec2);"
3313 "uvec3 multiply32x16(uvec3, uvec3);"
3314 "uvec4 multiply32x16(uvec4, uvec4);"
3315 "\n");
3316 }
3317
3318 if ((profile != EEsProfile && version >= 450) ||
3319 (profile == EEsProfile && version >= 320)) {
3320 commonBuiltins.append(
3321 "struct gl_TextureFootprint2DNV {"
3322 "uvec2 anchor;"
3323 "uvec2 offset;"
3324 "uvec2 mask;"
3325 "uint lod;"
3326 "uint granularity;"
3327 "};"
3328
3329 "struct gl_TextureFootprint3DNV {"
3330 "uvec3 anchor;"
3331 "uvec3 offset;"
3332 "uvec2 mask;"
3333 "uint lod;"
3334 "uint granularity;"
3335 "};"
3336 "bool textureFootprintNV(sampler2D, vec2, int, bool, out gl_TextureFootprint2DNV);"
3337 "bool textureFootprintNV(sampler3D, vec3, int, bool, out gl_TextureFootprint3DNV);"
3338 "bool textureFootprintNV(sampler2D, vec2, int, bool, out gl_TextureFootprint2DNV, float);"
3339 "bool textureFootprintNV(sampler3D, vec3, int, bool, out gl_TextureFootprint3DNV, float);"
3340 "bool textureFootprintClampNV(sampler2D, vec2, float, int, bool, out gl_TextureFootprint2DNV);"
3341 "bool textureFootprintClampNV(sampler3D, vec3, float, int, bool, out gl_TextureFootprint3DNV);"
3342 "bool textureFootprintClampNV(sampler2D, vec2, float, int, bool, out gl_TextureFootprint2DNV, float);"
3343 "bool textureFootprintClampNV(sampler3D, vec3, float, int, bool, out gl_TextureFootprint3DNV, float);"
3344 "bool textureFootprintLodNV(sampler2D, vec2, float, int, bool, out gl_TextureFootprint2DNV);"
3345 "bool textureFootprintLodNV(sampler3D, vec3, float, int, bool, out gl_TextureFootprint3DNV);"
3346 "bool textureFootprintGradNV(sampler2D, vec2, vec2, vec2, int, bool, out gl_TextureFootprint2DNV);"
3347 "bool textureFootprintGradClampNV(sampler2D, vec2, vec2, vec2, float, int, bool, out gl_TextureFootprint2DNV);"
3348 "\n");
3349 }
3350
3351 if ((profile == EEsProfile && version >= 300 && version < 310) ||
3352 (profile != EEsProfile && version >= 150 && version < 450)) { // GL_EXT_shader_integer_mix
3353 commonBuiltins.append("int mix(int, int, bool);"
3354 "ivec2 mix(ivec2, ivec2, bvec2);"
3355 "ivec3 mix(ivec3, ivec3, bvec3);"
3356 "ivec4 mix(ivec4, ivec4, bvec4);"
3357 "uint mix(uint, uint, bool );"
3358 "uvec2 mix(uvec2, uvec2, bvec2);"
3359 "uvec3 mix(uvec3, uvec3, bvec3);"
3360 "uvec4 mix(uvec4, uvec4, bvec4);"
3361 "bool mix(bool, bool, bool );"
3362 "bvec2 mix(bvec2, bvec2, bvec2);"
3363 "bvec3 mix(bvec3, bvec3, bvec3);"
3364 "bvec4 mix(bvec4, bvec4, bvec4);"
3365
3366 "\n");
3367 }
3368
3369 // GL_AMD_gpu_shader_half_float/Explicit types
3370 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 310)) {
3371 commonBuiltins.append(
3372 "float16_t radians(float16_t);"
3373 "f16vec2 radians(f16vec2);"
3374 "f16vec3 radians(f16vec3);"
3375 "f16vec4 radians(f16vec4);"
3376
3377 "float16_t degrees(float16_t);"
3378 "f16vec2 degrees(f16vec2);"
3379 "f16vec3 degrees(f16vec3);"
3380 "f16vec4 degrees(f16vec4);"
3381
3382 "float16_t sin(float16_t);"
3383 "f16vec2 sin(f16vec2);"
3384 "f16vec3 sin(f16vec3);"
3385 "f16vec4 sin(f16vec4);"
3386
3387 "float16_t cos(float16_t);"
3388 "f16vec2 cos(f16vec2);"
3389 "f16vec3 cos(f16vec3);"
3390 "f16vec4 cos(f16vec4);"
3391
3392 "float16_t tan(float16_t);"
3393 "f16vec2 tan(f16vec2);"
3394 "f16vec3 tan(f16vec3);"
3395 "f16vec4 tan(f16vec4);"
3396
3397 "float16_t asin(float16_t);"
3398 "f16vec2 asin(f16vec2);"
3399 "f16vec3 asin(f16vec3);"
3400 "f16vec4 asin(f16vec4);"
3401
3402 "float16_t acos(float16_t);"
3403 "f16vec2 acos(f16vec2);"
3404 "f16vec3 acos(f16vec3);"
3405 "f16vec4 acos(f16vec4);"
3406
3407 "float16_t atan(float16_t, float16_t);"
3408 "f16vec2 atan(f16vec2, f16vec2);"
3409 "f16vec3 atan(f16vec3, f16vec3);"
3410 "f16vec4 atan(f16vec4, f16vec4);"
3411
3412 "float16_t atan(float16_t);"
3413 "f16vec2 atan(f16vec2);"
3414 "f16vec3 atan(f16vec3);"
3415 "f16vec4 atan(f16vec4);"
3416
3417 "float16_t sinh(float16_t);"
3418 "f16vec2 sinh(f16vec2);"
3419 "f16vec3 sinh(f16vec3);"
3420 "f16vec4 sinh(f16vec4);"
3421
3422 "float16_t cosh(float16_t);"
3423 "f16vec2 cosh(f16vec2);"
3424 "f16vec3 cosh(f16vec3);"
3425 "f16vec4 cosh(f16vec4);"
3426
3427 "float16_t tanh(float16_t);"
3428 "f16vec2 tanh(f16vec2);"
3429 "f16vec3 tanh(f16vec3);"
3430 "f16vec4 tanh(f16vec4);"
3431
3432 "float16_t asinh(float16_t);"
3433 "f16vec2 asinh(f16vec2);"
3434 "f16vec3 asinh(f16vec3);"
3435 "f16vec4 asinh(f16vec4);"
3436
3437 "float16_t acosh(float16_t);"
3438 "f16vec2 acosh(f16vec2);"
3439 "f16vec3 acosh(f16vec3);"
3440 "f16vec4 acosh(f16vec4);"
3441
3442 "float16_t atanh(float16_t);"
3443 "f16vec2 atanh(f16vec2);"
3444 "f16vec3 atanh(f16vec3);"
3445 "f16vec4 atanh(f16vec4);"
3446
3447 "float16_t pow(float16_t, float16_t);"
3448 "f16vec2 pow(f16vec2, f16vec2);"
3449 "f16vec3 pow(f16vec3, f16vec3);"
3450 "f16vec4 pow(f16vec4, f16vec4);"
3451
3452 "float16_t exp(float16_t);"
3453 "f16vec2 exp(f16vec2);"
3454 "f16vec3 exp(f16vec3);"
3455 "f16vec4 exp(f16vec4);"
3456
3457 "float16_t log(float16_t);"
3458 "f16vec2 log(f16vec2);"
3459 "f16vec3 log(f16vec3);"
3460 "f16vec4 log(f16vec4);"
3461
3462 "float16_t exp2(float16_t);"
3463 "f16vec2 exp2(f16vec2);"
3464 "f16vec3 exp2(f16vec3);"
3465 "f16vec4 exp2(f16vec4);"
3466
3467 "float16_t log2(float16_t);"
3468 "f16vec2 log2(f16vec2);"
3469 "f16vec3 log2(f16vec3);"
3470 "f16vec4 log2(f16vec4);"
3471
3472 "float16_t sqrt(float16_t);"
3473 "f16vec2 sqrt(f16vec2);"
3474 "f16vec3 sqrt(f16vec3);"
3475 "f16vec4 sqrt(f16vec4);"
3476
3477 "float16_t inversesqrt(float16_t);"
3478 "f16vec2 inversesqrt(f16vec2);"
3479 "f16vec3 inversesqrt(f16vec3);"
3480 "f16vec4 inversesqrt(f16vec4);"
3481
3482 "float16_t abs(float16_t);"
3483 "f16vec2 abs(f16vec2);"
3484 "f16vec3 abs(f16vec3);"
3485 "f16vec4 abs(f16vec4);"
3486
3487 "float16_t sign(float16_t);"
3488 "f16vec2 sign(f16vec2);"
3489 "f16vec3 sign(f16vec3);"
3490 "f16vec4 sign(f16vec4);"
3491
3492 "float16_t floor(float16_t);"
3493 "f16vec2 floor(f16vec2);"
3494 "f16vec3 floor(f16vec3);"
3495 "f16vec4 floor(f16vec4);"
3496
3497 "float16_t trunc(float16_t);"
3498 "f16vec2 trunc(f16vec2);"
3499 "f16vec3 trunc(f16vec3);"
3500 "f16vec4 trunc(f16vec4);"
3501
3502 "float16_t round(float16_t);"
3503 "f16vec2 round(f16vec2);"
3504 "f16vec3 round(f16vec3);"
3505 "f16vec4 round(f16vec4);"
3506
3507 "float16_t roundEven(float16_t);"
3508 "f16vec2 roundEven(f16vec2);"
3509 "f16vec3 roundEven(f16vec3);"
3510 "f16vec4 roundEven(f16vec4);"
3511
3512 "float16_t ceil(float16_t);"
3513 "f16vec2 ceil(f16vec2);"
3514 "f16vec3 ceil(f16vec3);"
3515 "f16vec4 ceil(f16vec4);"
3516
3517 "float16_t fract(float16_t);"
3518 "f16vec2 fract(f16vec2);"
3519 "f16vec3 fract(f16vec3);"
3520 "f16vec4 fract(f16vec4);"
3521
3522 "float16_t mod(float16_t, float16_t);"
3523 "f16vec2 mod(f16vec2, float16_t);"
3524 "f16vec3 mod(f16vec3, float16_t);"
3525 "f16vec4 mod(f16vec4, float16_t);"
3526 "f16vec2 mod(f16vec2, f16vec2);"
3527 "f16vec3 mod(f16vec3, f16vec3);"
3528 "f16vec4 mod(f16vec4, f16vec4);"
3529
3530 "float16_t modf(float16_t, out float16_t);"
3531 "f16vec2 modf(f16vec2, out f16vec2);"
3532 "f16vec3 modf(f16vec3, out f16vec3);"
3533 "f16vec4 modf(f16vec4, out f16vec4);"
3534
3535 "float16_t min(float16_t, float16_t);"
3536 "f16vec2 min(f16vec2, float16_t);"
3537 "f16vec3 min(f16vec3, float16_t);"
3538 "f16vec4 min(f16vec4, float16_t);"
3539 "f16vec2 min(f16vec2, f16vec2);"
3540 "f16vec3 min(f16vec3, f16vec3);"
3541 "f16vec4 min(f16vec4, f16vec4);"
3542
3543 "float16_t max(float16_t, float16_t);"
3544 "f16vec2 max(f16vec2, float16_t);"
3545 "f16vec3 max(f16vec3, float16_t);"
3546 "f16vec4 max(f16vec4, float16_t);"
3547 "f16vec2 max(f16vec2, f16vec2);"
3548 "f16vec3 max(f16vec3, f16vec3);"
3549 "f16vec4 max(f16vec4, f16vec4);"
3550
3551 "float16_t clamp(float16_t, float16_t, float16_t);"
3552 "f16vec2 clamp(f16vec2, float16_t, float16_t);"
3553 "f16vec3 clamp(f16vec3, float16_t, float16_t);"
3554 "f16vec4 clamp(f16vec4, float16_t, float16_t);"
3555 "f16vec2 clamp(f16vec2, f16vec2, f16vec2);"
3556 "f16vec3 clamp(f16vec3, f16vec3, f16vec3);"
3557 "f16vec4 clamp(f16vec4, f16vec4, f16vec4);"
3558
3559 "float16_t mix(float16_t, float16_t, float16_t);"
3560 "f16vec2 mix(f16vec2, f16vec2, float16_t);"
3561 "f16vec3 mix(f16vec3, f16vec3, float16_t);"
3562 "f16vec4 mix(f16vec4, f16vec4, float16_t);"
3563 "f16vec2 mix(f16vec2, f16vec2, f16vec2);"
3564 "f16vec3 mix(f16vec3, f16vec3, f16vec3);"
3565 "f16vec4 mix(f16vec4, f16vec4, f16vec4);"
3566 "float16_t mix(float16_t, float16_t, bool);"
3567 "f16vec2 mix(f16vec2, f16vec2, bvec2);"
3568 "f16vec3 mix(f16vec3, f16vec3, bvec3);"
3569 "f16vec4 mix(f16vec4, f16vec4, bvec4);"
3570
3571 "float16_t step(float16_t, float16_t);"
3572 "f16vec2 step(f16vec2, f16vec2);"
3573 "f16vec3 step(f16vec3, f16vec3);"
3574 "f16vec4 step(f16vec4, f16vec4);"
3575 "f16vec2 step(float16_t, f16vec2);"
3576 "f16vec3 step(float16_t, f16vec3);"
3577 "f16vec4 step(float16_t, f16vec4);"
3578
3579 "float16_t smoothstep(float16_t, float16_t, float16_t);"
3580 "f16vec2 smoothstep(f16vec2, f16vec2, f16vec2);"
3581 "f16vec3 smoothstep(f16vec3, f16vec3, f16vec3);"
3582 "f16vec4 smoothstep(f16vec4, f16vec4, f16vec4);"
3583 "f16vec2 smoothstep(float16_t, float16_t, f16vec2);"
3584 "f16vec3 smoothstep(float16_t, float16_t, f16vec3);"
3585 "f16vec4 smoothstep(float16_t, float16_t, f16vec4);"
3586
3587 "bool isnan(float16_t);"
3588 "bvec2 isnan(f16vec2);"
3589 "bvec3 isnan(f16vec3);"
3590 "bvec4 isnan(f16vec4);"
3591
3592 "bool isinf(float16_t);"
3593 "bvec2 isinf(f16vec2);"
3594 "bvec3 isinf(f16vec3);"
3595 "bvec4 isinf(f16vec4);"
3596
3597 "float16_t fma(float16_t, float16_t, float16_t);"
3598 "f16vec2 fma(f16vec2, f16vec2, f16vec2);"
3599 "f16vec3 fma(f16vec3, f16vec3, f16vec3);"
3600 "f16vec4 fma(f16vec4, f16vec4, f16vec4);"
3601
3602 "float16_t frexp(float16_t, out int);"
3603 "f16vec2 frexp(f16vec2, out ivec2);"
3604 "f16vec3 frexp(f16vec3, out ivec3);"
3605 "f16vec4 frexp(f16vec4, out ivec4);"
3606
3607 "float16_t ldexp(float16_t, in int);"
3608 "f16vec2 ldexp(f16vec2, in ivec2);"
3609 "f16vec3 ldexp(f16vec3, in ivec3);"
3610 "f16vec4 ldexp(f16vec4, in ivec4);"
3611
3612 "uint packFloat2x16(f16vec2);"
3613 "f16vec2 unpackFloat2x16(uint);"
3614
3615 "float16_t length(float16_t);"
3616 "float16_t length(f16vec2);"
3617 "float16_t length(f16vec3);"
3618 "float16_t length(f16vec4);"
3619
3620 "float16_t distance(float16_t, float16_t);"
3621 "float16_t distance(f16vec2, f16vec2);"
3622 "float16_t distance(f16vec3, f16vec3);"
3623 "float16_t distance(f16vec4, f16vec4);"
3624
3625 "float16_t dot(float16_t, float16_t);"
3626 "float16_t dot(f16vec2, f16vec2);"
3627 "float16_t dot(f16vec3, f16vec3);"
3628 "float16_t dot(f16vec4, f16vec4);"
3629
3630 "f16vec3 cross(f16vec3, f16vec3);"
3631
3632 "float16_t normalize(float16_t);"
3633 "f16vec2 normalize(f16vec2);"
3634 "f16vec3 normalize(f16vec3);"
3635 "f16vec4 normalize(f16vec4);"
3636
3637 "float16_t faceforward(float16_t, float16_t, float16_t);"
3638 "f16vec2 faceforward(f16vec2, f16vec2, f16vec2);"
3639 "f16vec3 faceforward(f16vec3, f16vec3, f16vec3);"
3640 "f16vec4 faceforward(f16vec4, f16vec4, f16vec4);"
3641
3642 "float16_t reflect(float16_t, float16_t);"
3643 "f16vec2 reflect(f16vec2, f16vec2);"
3644 "f16vec3 reflect(f16vec3, f16vec3);"
3645 "f16vec4 reflect(f16vec4, f16vec4);"
3646
3647 "float16_t refract(float16_t, float16_t, float16_t);"
3648 "f16vec2 refract(f16vec2, f16vec2, float16_t);"
3649 "f16vec3 refract(f16vec3, f16vec3, float16_t);"
3650 "f16vec4 refract(f16vec4, f16vec4, float16_t);"
3651
3652 "f16mat2 matrixCompMult(f16mat2, f16mat2);"
3653 "f16mat3 matrixCompMult(f16mat3, f16mat3);"
3654 "f16mat4 matrixCompMult(f16mat4, f16mat4);"
3655 "f16mat2x3 matrixCompMult(f16mat2x3, f16mat2x3);"
3656 "f16mat2x4 matrixCompMult(f16mat2x4, f16mat2x4);"
3657 "f16mat3x2 matrixCompMult(f16mat3x2, f16mat3x2);"
3658 "f16mat3x4 matrixCompMult(f16mat3x4, f16mat3x4);"
3659 "f16mat4x2 matrixCompMult(f16mat4x2, f16mat4x2);"
3660 "f16mat4x3 matrixCompMult(f16mat4x3, f16mat4x3);"
3661
3662 "f16mat2 outerProduct(f16vec2, f16vec2);"
3663 "f16mat3 outerProduct(f16vec3, f16vec3);"
3664 "f16mat4 outerProduct(f16vec4, f16vec4);"
3665 "f16mat2x3 outerProduct(f16vec3, f16vec2);"
3666 "f16mat3x2 outerProduct(f16vec2, f16vec3);"
3667 "f16mat2x4 outerProduct(f16vec4, f16vec2);"
3668 "f16mat4x2 outerProduct(f16vec2, f16vec4);"
3669 "f16mat3x4 outerProduct(f16vec4, f16vec3);"
3670 "f16mat4x3 outerProduct(f16vec3, f16vec4);"
3671
3672 "f16mat2 transpose(f16mat2);"
3673 "f16mat3 transpose(f16mat3);"
3674 "f16mat4 transpose(f16mat4);"
3675 "f16mat2x3 transpose(f16mat3x2);"
3676 "f16mat3x2 transpose(f16mat2x3);"
3677 "f16mat2x4 transpose(f16mat4x2);"
3678 "f16mat4x2 transpose(f16mat2x4);"
3679 "f16mat3x4 transpose(f16mat4x3);"
3680 "f16mat4x3 transpose(f16mat3x4);"
3681
3682 "float16_t determinant(f16mat2);"
3683 "float16_t determinant(f16mat3);"
3684 "float16_t determinant(f16mat4);"
3685
3686 "f16mat2 inverse(f16mat2);"
3687 "f16mat3 inverse(f16mat3);"
3688 "f16mat4 inverse(f16mat4);"
3689
3690 "bvec2 lessThan(f16vec2, f16vec2);"
3691 "bvec3 lessThan(f16vec3, f16vec3);"
3692 "bvec4 lessThan(f16vec4, f16vec4);"
3693
3694 "bvec2 lessThanEqual(f16vec2, f16vec2);"
3695 "bvec3 lessThanEqual(f16vec3, f16vec3);"
3696 "bvec4 lessThanEqual(f16vec4, f16vec4);"
3697
3698 "bvec2 greaterThan(f16vec2, f16vec2);"
3699 "bvec3 greaterThan(f16vec3, f16vec3);"
3700 "bvec4 greaterThan(f16vec4, f16vec4);"
3701
3702 "bvec2 greaterThanEqual(f16vec2, f16vec2);"
3703 "bvec3 greaterThanEqual(f16vec3, f16vec3);"
3704 "bvec4 greaterThanEqual(f16vec4, f16vec4);"
3705
3706 "bvec2 equal(f16vec2, f16vec2);"
3707 "bvec3 equal(f16vec3, f16vec3);"
3708 "bvec4 equal(f16vec4, f16vec4);"
3709
3710 "bvec2 notEqual(f16vec2, f16vec2);"
3711 "bvec3 notEqual(f16vec3, f16vec3);"
3712 "bvec4 notEqual(f16vec4, f16vec4);"
3713
3714 "\n");
3715 }
3716
3717 // Explicit types
3718 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 310)) {
3719 commonBuiltins.append(
3720 "int8_t abs(int8_t);"
3721 "i8vec2 abs(i8vec2);"
3722 "i8vec3 abs(i8vec3);"
3723 "i8vec4 abs(i8vec4);"
3724
3725 "int8_t sign(int8_t);"
3726 "i8vec2 sign(i8vec2);"
3727 "i8vec3 sign(i8vec3);"
3728 "i8vec4 sign(i8vec4);"
3729
3730 "int8_t min(int8_t x, int8_t y);"
3731 "i8vec2 min(i8vec2 x, int8_t y);"
3732 "i8vec3 min(i8vec3 x, int8_t y);"
3733 "i8vec4 min(i8vec4 x, int8_t y);"
3734 "i8vec2 min(i8vec2 x, i8vec2 y);"
3735 "i8vec3 min(i8vec3 x, i8vec3 y);"
3736 "i8vec4 min(i8vec4 x, i8vec4 y);"
3737
3738 "uint8_t min(uint8_t x, uint8_t y);"
3739 "u8vec2 min(u8vec2 x, uint8_t y);"
3740 "u8vec3 min(u8vec3 x, uint8_t y);"
3741 "u8vec4 min(u8vec4 x, uint8_t y);"
3742 "u8vec2 min(u8vec2 x, u8vec2 y);"
3743 "u8vec3 min(u8vec3 x, u8vec3 y);"
3744 "u8vec4 min(u8vec4 x, u8vec4 y);"
3745
3746 "int8_t max(int8_t x, int8_t y);"
3747 "i8vec2 max(i8vec2 x, int8_t y);"
3748 "i8vec3 max(i8vec3 x, int8_t y);"
3749 "i8vec4 max(i8vec4 x, int8_t y);"
3750 "i8vec2 max(i8vec2 x, i8vec2 y);"
3751 "i8vec3 max(i8vec3 x, i8vec3 y);"
3752 "i8vec4 max(i8vec4 x, i8vec4 y);"
3753
3754 "uint8_t max(uint8_t x, uint8_t y);"
3755 "u8vec2 max(u8vec2 x, uint8_t y);"
3756 "u8vec3 max(u8vec3 x, uint8_t y);"
3757 "u8vec4 max(u8vec4 x, uint8_t y);"
3758 "u8vec2 max(u8vec2 x, u8vec2 y);"
3759 "u8vec3 max(u8vec3 x, u8vec3 y);"
3760 "u8vec4 max(u8vec4 x, u8vec4 y);"
3761
3762 "int8_t clamp(int8_t x, int8_t minVal, int8_t maxVal);"
3763 "i8vec2 clamp(i8vec2 x, int8_t minVal, int8_t maxVal);"
3764 "i8vec3 clamp(i8vec3 x, int8_t minVal, int8_t maxVal);"
3765 "i8vec4 clamp(i8vec4 x, int8_t minVal, int8_t maxVal);"
3766 "i8vec2 clamp(i8vec2 x, i8vec2 minVal, i8vec2 maxVal);"
3767 "i8vec3 clamp(i8vec3 x, i8vec3 minVal, i8vec3 maxVal);"
3768 "i8vec4 clamp(i8vec4 x, i8vec4 minVal, i8vec4 maxVal);"
3769
3770 "uint8_t clamp(uint8_t x, uint8_t minVal, uint8_t maxVal);"
3771 "u8vec2 clamp(u8vec2 x, uint8_t minVal, uint8_t maxVal);"
3772 "u8vec3 clamp(u8vec3 x, uint8_t minVal, uint8_t maxVal);"
3773 "u8vec4 clamp(u8vec4 x, uint8_t minVal, uint8_t maxVal);"
3774 "u8vec2 clamp(u8vec2 x, u8vec2 minVal, u8vec2 maxVal);"
3775 "u8vec3 clamp(u8vec3 x, u8vec3 minVal, u8vec3 maxVal);"
3776 "u8vec4 clamp(u8vec4 x, u8vec4 minVal, u8vec4 maxVal);"
3777
3778 "int8_t mix(int8_t, int8_t, bool);"
3779 "i8vec2 mix(i8vec2, i8vec2, bvec2);"
3780 "i8vec3 mix(i8vec3, i8vec3, bvec3);"
3781 "i8vec4 mix(i8vec4, i8vec4, bvec4);"
3782 "uint8_t mix(uint8_t, uint8_t, bool);"
3783 "u8vec2 mix(u8vec2, u8vec2, bvec2);"
3784 "u8vec3 mix(u8vec3, u8vec3, bvec3);"
3785 "u8vec4 mix(u8vec4, u8vec4, bvec4);"
3786
3787 "bvec2 lessThan(i8vec2, i8vec2);"
3788 "bvec3 lessThan(i8vec3, i8vec3);"
3789 "bvec4 lessThan(i8vec4, i8vec4);"
3790 "bvec2 lessThan(u8vec2, u8vec2);"
3791 "bvec3 lessThan(u8vec3, u8vec3);"
3792 "bvec4 lessThan(u8vec4, u8vec4);"
3793
3794 "bvec2 lessThanEqual(i8vec2, i8vec2);"
3795 "bvec3 lessThanEqual(i8vec3, i8vec3);"
3796 "bvec4 lessThanEqual(i8vec4, i8vec4);"
3797 "bvec2 lessThanEqual(u8vec2, u8vec2);"
3798 "bvec3 lessThanEqual(u8vec3, u8vec3);"
3799 "bvec4 lessThanEqual(u8vec4, u8vec4);"
3800
3801 "bvec2 greaterThan(i8vec2, i8vec2);"
3802 "bvec3 greaterThan(i8vec3, i8vec3);"
3803 "bvec4 greaterThan(i8vec4, i8vec4);"
3804 "bvec2 greaterThan(u8vec2, u8vec2);"
3805 "bvec3 greaterThan(u8vec3, u8vec3);"
3806 "bvec4 greaterThan(u8vec4, u8vec4);"
3807
3808 "bvec2 greaterThanEqual(i8vec2, i8vec2);"
3809 "bvec3 greaterThanEqual(i8vec3, i8vec3);"
3810 "bvec4 greaterThanEqual(i8vec4, i8vec4);"
3811 "bvec2 greaterThanEqual(u8vec2, u8vec2);"
3812 "bvec3 greaterThanEqual(u8vec3, u8vec3);"
3813 "bvec4 greaterThanEqual(u8vec4, u8vec4);"
3814
3815 "bvec2 equal(i8vec2, i8vec2);"
3816 "bvec3 equal(i8vec3, i8vec3);"
3817 "bvec4 equal(i8vec4, i8vec4);"
3818 "bvec2 equal(u8vec2, u8vec2);"
3819 "bvec3 equal(u8vec3, u8vec3);"
3820 "bvec4 equal(u8vec4, u8vec4);"
3821
3822 "bvec2 notEqual(i8vec2, i8vec2);"
3823 "bvec3 notEqual(i8vec3, i8vec3);"
3824 "bvec4 notEqual(i8vec4, i8vec4);"
3825 "bvec2 notEqual(u8vec2, u8vec2);"
3826 "bvec3 notEqual(u8vec3, u8vec3);"
3827 "bvec4 notEqual(u8vec4, u8vec4);"
3828
3829 " int8_t bitfieldExtract( int8_t, int8_t, int8_t);"
3830 "i8vec2 bitfieldExtract(i8vec2, int8_t, int8_t);"
3831 "i8vec3 bitfieldExtract(i8vec3, int8_t, int8_t);"
3832 "i8vec4 bitfieldExtract(i8vec4, int8_t, int8_t);"
3833
3834 " uint8_t bitfieldExtract( uint8_t, int8_t, int8_t);"
3835 "u8vec2 bitfieldExtract(u8vec2, int8_t, int8_t);"
3836 "u8vec3 bitfieldExtract(u8vec3, int8_t, int8_t);"
3837 "u8vec4 bitfieldExtract(u8vec4, int8_t, int8_t);"
3838
3839 " int8_t bitfieldInsert( int8_t base, int8_t, int8_t, int8_t);"
3840 "i8vec2 bitfieldInsert(i8vec2 base, i8vec2, int8_t, int8_t);"
3841 "i8vec3 bitfieldInsert(i8vec3 base, i8vec3, int8_t, int8_t);"
3842 "i8vec4 bitfieldInsert(i8vec4 base, i8vec4, int8_t, int8_t);"
3843
3844 " uint8_t bitfieldInsert( uint8_t base, uint8_t, int8_t, int8_t);"
3845 "u8vec2 bitfieldInsert(u8vec2 base, u8vec2, int8_t, int8_t);"
3846 "u8vec3 bitfieldInsert(u8vec3 base, u8vec3, int8_t, int8_t);"
3847 "u8vec4 bitfieldInsert(u8vec4 base, u8vec4, int8_t, int8_t);"
3848
3849 " int8_t bitCount( int8_t);"
3850 "i8vec2 bitCount(i8vec2);"
3851 "i8vec3 bitCount(i8vec3);"
3852 "i8vec4 bitCount(i8vec4);"
3853
3854 " int8_t bitCount( uint8_t);"
3855 "i8vec2 bitCount(u8vec2);"
3856 "i8vec3 bitCount(u8vec3);"
3857 "i8vec4 bitCount(u8vec4);"
3858
3859 " int8_t findLSB( int8_t);"
3860 "i8vec2 findLSB(i8vec2);"
3861 "i8vec3 findLSB(i8vec3);"
3862 "i8vec4 findLSB(i8vec4);"
3863
3864 " int8_t findLSB( uint8_t);"
3865 "i8vec2 findLSB(u8vec2);"
3866 "i8vec3 findLSB(u8vec3);"
3867 "i8vec4 findLSB(u8vec4);"
3868
3869 " int8_t findMSB( int8_t);"
3870 "i8vec2 findMSB(i8vec2);"
3871 "i8vec3 findMSB(i8vec3);"
3872 "i8vec4 findMSB(i8vec4);"
3873
3874 " int8_t findMSB( uint8_t);"
3875 "i8vec2 findMSB(u8vec2);"
3876 "i8vec3 findMSB(u8vec3);"
3877 "i8vec4 findMSB(u8vec4);"
3878
3879 "int16_t abs(int16_t);"
3880 "i16vec2 abs(i16vec2);"
3881 "i16vec3 abs(i16vec3);"
3882 "i16vec4 abs(i16vec4);"
3883
3884 "int16_t sign(int16_t);"
3885 "i16vec2 sign(i16vec2);"
3886 "i16vec3 sign(i16vec3);"
3887 "i16vec4 sign(i16vec4);"
3888
3889 "int16_t min(int16_t x, int16_t y);"
3890 "i16vec2 min(i16vec2 x, int16_t y);"
3891 "i16vec3 min(i16vec3 x, int16_t y);"
3892 "i16vec4 min(i16vec4 x, int16_t y);"
3893 "i16vec2 min(i16vec2 x, i16vec2 y);"
3894 "i16vec3 min(i16vec3 x, i16vec3 y);"
3895 "i16vec4 min(i16vec4 x, i16vec4 y);"
3896
3897 "uint16_t min(uint16_t x, uint16_t y);"
3898 "u16vec2 min(u16vec2 x, uint16_t y);"
3899 "u16vec3 min(u16vec3 x, uint16_t y);"
3900 "u16vec4 min(u16vec4 x, uint16_t y);"
3901 "u16vec2 min(u16vec2 x, u16vec2 y);"
3902 "u16vec3 min(u16vec3 x, u16vec3 y);"
3903 "u16vec4 min(u16vec4 x, u16vec4 y);"
3904
3905 "int16_t max(int16_t x, int16_t y);"
3906 "i16vec2 max(i16vec2 x, int16_t y);"
3907 "i16vec3 max(i16vec3 x, int16_t y);"
3908 "i16vec4 max(i16vec4 x, int16_t y);"
3909 "i16vec2 max(i16vec2 x, i16vec2 y);"
3910 "i16vec3 max(i16vec3 x, i16vec3 y);"
3911 "i16vec4 max(i16vec4 x, i16vec4 y);"
3912
3913 "uint16_t max(uint16_t x, uint16_t y);"
3914 "u16vec2 max(u16vec2 x, uint16_t y);"
3915 "u16vec3 max(u16vec3 x, uint16_t y);"
3916 "u16vec4 max(u16vec4 x, uint16_t y);"
3917 "u16vec2 max(u16vec2 x, u16vec2 y);"
3918 "u16vec3 max(u16vec3 x, u16vec3 y);"
3919 "u16vec4 max(u16vec4 x, u16vec4 y);"
3920
3921 "int16_t clamp(int16_t x, int16_t minVal, int16_t maxVal);"
3922 "i16vec2 clamp(i16vec2 x, int16_t minVal, int16_t maxVal);"
3923 "i16vec3 clamp(i16vec3 x, int16_t minVal, int16_t maxVal);"
3924 "i16vec4 clamp(i16vec4 x, int16_t minVal, int16_t maxVal);"
3925 "i16vec2 clamp(i16vec2 x, i16vec2 minVal, i16vec2 maxVal);"
3926 "i16vec3 clamp(i16vec3 x, i16vec3 minVal, i16vec3 maxVal);"
3927 "i16vec4 clamp(i16vec4 x, i16vec4 minVal, i16vec4 maxVal);"
3928
3929 "uint16_t clamp(uint16_t x, uint16_t minVal, uint16_t maxVal);"
3930 "u16vec2 clamp(u16vec2 x, uint16_t minVal, uint16_t maxVal);"
3931 "u16vec3 clamp(u16vec3 x, uint16_t minVal, uint16_t maxVal);"
3932 "u16vec4 clamp(u16vec4 x, uint16_t minVal, uint16_t maxVal);"
3933 "u16vec2 clamp(u16vec2 x, u16vec2 minVal, u16vec2 maxVal);"
3934 "u16vec3 clamp(u16vec3 x, u16vec3 minVal, u16vec3 maxVal);"
3935 "u16vec4 clamp(u16vec4 x, u16vec4 minVal, u16vec4 maxVal);"
3936
3937 "int16_t mix(int16_t, int16_t, bool);"
3938 "i16vec2 mix(i16vec2, i16vec2, bvec2);"
3939 "i16vec3 mix(i16vec3, i16vec3, bvec3);"
3940 "i16vec4 mix(i16vec4, i16vec4, bvec4);"
3941 "uint16_t mix(uint16_t, uint16_t, bool);"
3942 "u16vec2 mix(u16vec2, u16vec2, bvec2);"
3943 "u16vec3 mix(u16vec3, u16vec3, bvec3);"
3944 "u16vec4 mix(u16vec4, u16vec4, bvec4);"
3945
3946 "float16_t frexp(float16_t, out int16_t);"
3947 "f16vec2 frexp(f16vec2, out i16vec2);"
3948 "f16vec3 frexp(f16vec3, out i16vec3);"
3949 "f16vec4 frexp(f16vec4, out i16vec4);"
3950
3951 "float16_t ldexp(float16_t, int16_t);"
3952 "f16vec2 ldexp(f16vec2, i16vec2);"
3953 "f16vec3 ldexp(f16vec3, i16vec3);"
3954 "f16vec4 ldexp(f16vec4, i16vec4);"
3955
3956 "int16_t halfBitsToInt16(float16_t);"
3957 "i16vec2 halfBitsToInt16(f16vec2);"
3958 "i16vec3 halhBitsToInt16(f16vec3);"
3959 "i16vec4 halfBitsToInt16(f16vec4);"
3960
3961 "uint16_t halfBitsToUint16(float16_t);"
3962 "u16vec2 halfBitsToUint16(f16vec2);"
3963 "u16vec3 halfBitsToUint16(f16vec3);"
3964 "u16vec4 halfBitsToUint16(f16vec4);"
3965
3966 "int16_t float16BitsToInt16(float16_t);"
3967 "i16vec2 float16BitsToInt16(f16vec2);"
3968 "i16vec3 float16BitsToInt16(f16vec3);"
3969 "i16vec4 float16BitsToInt16(f16vec4);"
3970
3971 "uint16_t float16BitsToUint16(float16_t);"
3972 "u16vec2 float16BitsToUint16(f16vec2);"
3973 "u16vec3 float16BitsToUint16(f16vec3);"
3974 "u16vec4 float16BitsToUint16(f16vec4);"
3975
3976 "float16_t int16BitsToFloat16(int16_t);"
3977 "f16vec2 int16BitsToFloat16(i16vec2);"
3978 "f16vec3 int16BitsToFloat16(i16vec3);"
3979 "f16vec4 int16BitsToFloat16(i16vec4);"
3980
3981 "float16_t uint16BitsToFloat16(uint16_t);"
3982 "f16vec2 uint16BitsToFloat16(u16vec2);"
3983 "f16vec3 uint16BitsToFloat16(u16vec3);"
3984 "f16vec4 uint16BitsToFloat16(u16vec4);"
3985
3986 "float16_t int16BitsToHalf(int16_t);"
3987 "f16vec2 int16BitsToHalf(i16vec2);"
3988 "f16vec3 int16BitsToHalf(i16vec3);"
3989 "f16vec4 int16BitsToHalf(i16vec4);"
3990
3991 "float16_t uint16BitsToHalf(uint16_t);"
3992 "f16vec2 uint16BitsToHalf(u16vec2);"
3993 "f16vec3 uint16BitsToHalf(u16vec3);"
3994 "f16vec4 uint16BitsToHalf(u16vec4);"
3995
3996 "int packInt2x16(i16vec2);"
3997 "uint packUint2x16(u16vec2);"
3998 "int64_t packInt4x16(i16vec4);"
3999 "uint64_t packUint4x16(u16vec4);"
4000 "i16vec2 unpackInt2x16(int);"
4001 "u16vec2 unpackUint2x16(uint);"
4002 "i16vec4 unpackInt4x16(int64_t);"
4003 "u16vec4 unpackUint4x16(uint64_t);"
4004
4005 "bvec2 lessThan(i16vec2, i16vec2);"
4006 "bvec3 lessThan(i16vec3, i16vec3);"
4007 "bvec4 lessThan(i16vec4, i16vec4);"
4008 "bvec2 lessThan(u16vec2, u16vec2);"
4009 "bvec3 lessThan(u16vec3, u16vec3);"
4010 "bvec4 lessThan(u16vec4, u16vec4);"
4011
4012 "bvec2 lessThanEqual(i16vec2, i16vec2);"
4013 "bvec3 lessThanEqual(i16vec3, i16vec3);"
4014 "bvec4 lessThanEqual(i16vec4, i16vec4);"
4015 "bvec2 lessThanEqual(u16vec2, u16vec2);"
4016 "bvec3 lessThanEqual(u16vec3, u16vec3);"
4017 "bvec4 lessThanEqual(u16vec4, u16vec4);"
4018
4019 "bvec2 greaterThan(i16vec2, i16vec2);"
4020 "bvec3 greaterThan(i16vec3, i16vec3);"
4021 "bvec4 greaterThan(i16vec4, i16vec4);"
4022 "bvec2 greaterThan(u16vec2, u16vec2);"
4023 "bvec3 greaterThan(u16vec3, u16vec3);"
4024 "bvec4 greaterThan(u16vec4, u16vec4);"
4025
4026 "bvec2 greaterThanEqual(i16vec2, i16vec2);"
4027 "bvec3 greaterThanEqual(i16vec3, i16vec3);"
4028 "bvec4 greaterThanEqual(i16vec4, i16vec4);"
4029 "bvec2 greaterThanEqual(u16vec2, u16vec2);"
4030 "bvec3 greaterThanEqual(u16vec3, u16vec3);"
4031 "bvec4 greaterThanEqual(u16vec4, u16vec4);"
4032
4033 "bvec2 equal(i16vec2, i16vec2);"
4034 "bvec3 equal(i16vec3, i16vec3);"
4035 "bvec4 equal(i16vec4, i16vec4);"
4036 "bvec2 equal(u16vec2, u16vec2);"
4037 "bvec3 equal(u16vec3, u16vec3);"
4038 "bvec4 equal(u16vec4, u16vec4);"
4039
4040 "bvec2 notEqual(i16vec2, i16vec2);"
4041 "bvec3 notEqual(i16vec3, i16vec3);"
4042 "bvec4 notEqual(i16vec4, i16vec4);"
4043 "bvec2 notEqual(u16vec2, u16vec2);"
4044 "bvec3 notEqual(u16vec3, u16vec3);"
4045 "bvec4 notEqual(u16vec4, u16vec4);"
4046
4047 " int16_t bitfieldExtract( int16_t, int16_t, int16_t);"
4048 "i16vec2 bitfieldExtract(i16vec2, int16_t, int16_t);"
4049 "i16vec3 bitfieldExtract(i16vec3, int16_t, int16_t);"
4050 "i16vec4 bitfieldExtract(i16vec4, int16_t, int16_t);"
4051
4052 " uint16_t bitfieldExtract( uint16_t, int16_t, int16_t);"
4053 "u16vec2 bitfieldExtract(u16vec2, int16_t, int16_t);"
4054 "u16vec3 bitfieldExtract(u16vec3, int16_t, int16_t);"
4055 "u16vec4 bitfieldExtract(u16vec4, int16_t, int16_t);"
4056
4057 " int16_t bitfieldInsert( int16_t base, int16_t, int16_t, int16_t);"
4058 "i16vec2 bitfieldInsert(i16vec2 base, i16vec2, int16_t, int16_t);"
4059 "i16vec3 bitfieldInsert(i16vec3 base, i16vec3, int16_t, int16_t);"
4060 "i16vec4 bitfieldInsert(i16vec4 base, i16vec4, int16_t, int16_t);"
4061
4062 " uint16_t bitfieldInsert( uint16_t base, uint16_t, int16_t, int16_t);"
4063 "u16vec2 bitfieldInsert(u16vec2 base, u16vec2, int16_t, int16_t);"
4064 "u16vec3 bitfieldInsert(u16vec3 base, u16vec3, int16_t, int16_t);"
4065 "u16vec4 bitfieldInsert(u16vec4 base, u16vec4, int16_t, int16_t);"
4066
4067 " int16_t bitCount( int16_t);"
4068 "i16vec2 bitCount(i16vec2);"
4069 "i16vec3 bitCount(i16vec3);"
4070 "i16vec4 bitCount(i16vec4);"
4071
4072 " int16_t bitCount( uint16_t);"
4073 "i16vec2 bitCount(u16vec2);"
4074 "i16vec3 bitCount(u16vec3);"
4075 "i16vec4 bitCount(u16vec4);"
4076
4077 " int16_t findLSB( int16_t);"
4078 "i16vec2 findLSB(i16vec2);"
4079 "i16vec3 findLSB(i16vec3);"
4080 "i16vec4 findLSB(i16vec4);"
4081
4082 " int16_t findLSB( uint16_t);"
4083 "i16vec2 findLSB(u16vec2);"
4084 "i16vec3 findLSB(u16vec3);"
4085 "i16vec4 findLSB(u16vec4);"
4086
4087 " int16_t findMSB( int16_t);"
4088 "i16vec2 findMSB(i16vec2);"
4089 "i16vec3 findMSB(i16vec3);"
4090 "i16vec4 findMSB(i16vec4);"
4091
4092 " int16_t findMSB( uint16_t);"
4093 "i16vec2 findMSB(u16vec2);"
4094 "i16vec3 findMSB(u16vec3);"
4095 "i16vec4 findMSB(u16vec4);"
4096
4097 "int16_t pack16(i8vec2);"
4098 "uint16_t pack16(u8vec2);"
4099 "int32_t pack32(i8vec4);"
4100 "uint32_t pack32(u8vec4);"
4101 "int32_t pack32(i16vec2);"
4102 "uint32_t pack32(u16vec2);"
4103 "int64_t pack64(i16vec4);"
4104 "uint64_t pack64(u16vec4);"
4105 "int64_t pack64(i32vec2);"
4106 "uint64_t pack64(u32vec2);"
4107
4108 "i8vec2 unpack8(int16_t);"
4109 "u8vec2 unpack8(uint16_t);"
4110 "i8vec4 unpack8(int32_t);"
4111 "u8vec4 unpack8(uint32_t);"
4112 "i16vec2 unpack16(int32_t);"
4113 "u16vec2 unpack16(uint32_t);"
4114 "i16vec4 unpack16(int64_t);"
4115 "u16vec4 unpack16(uint64_t);"
4116 "i32vec2 unpack32(int64_t);"
4117 "u32vec2 unpack32(uint64_t);"
4118 "\n");
4119 }
4120
4121 // Builtins for GL_EXT_texture_shadow_lod
4122 if ((profile == EEsProfile && version >= 300) || ((profile != EEsProfile && version >= 130))) {
4123 commonBuiltins.append(
4124 "float texture(sampler2DArrayShadow, vec4, float);"
4125 "float texture(samplerCubeArrayShadow, vec4, float, float);"
4126 "float textureLod(sampler2DArrayShadow, vec4, float);"
4127 "float textureLod(samplerCubeShadow, vec4, float);"
4128 "float textureLod(samplerCubeArrayShadow, vec4, float, float);"
4129 "float textureLodOffset(sampler2DArrayShadow, vec4, float, ivec2);"
4130 "float textureOffset(sampler2DArrayShadow, vec4 , ivec2, float);"
4131 "\n");
4132 }
4133
4134 if (profile != EEsProfile && version >= 450) {
4135 stageBuiltins[EShLangFragment].append(derivativesAndControl64bits);
4136 stageBuiltins[EShLangFragment].append(
4137 "float64_t interpolateAtCentroid(float64_t);"
4138 "f64vec2 interpolateAtCentroid(f64vec2);"
4139 "f64vec3 interpolateAtCentroid(f64vec3);"
4140 "f64vec4 interpolateAtCentroid(f64vec4);"
4141
4142 "float64_t interpolateAtSample(float64_t, int);"
4143 "f64vec2 interpolateAtSample(f64vec2, int);"
4144 "f64vec3 interpolateAtSample(f64vec3, int);"
4145 "f64vec4 interpolateAtSample(f64vec4, int);"
4146
4147 "float64_t interpolateAtOffset(float64_t, f64vec2);"
4148 "f64vec2 interpolateAtOffset(f64vec2, f64vec2);"
4149 "f64vec3 interpolateAtOffset(f64vec3, f64vec2);"
4150 "f64vec4 interpolateAtOffset(f64vec4, f64vec2);"
4151
4152 "\n");
4153
4154 }
4155
4156 // QCOM_image_processing
4157 if ((profile == EEsProfile && version >= 310) ||
4158 (profile != EEsProfile && version >= 140)) {
4159 commonBuiltins.append(
4160 "vec4 textureWeightedQCOM(sampler2D, vec2, sampler2DArray);"
4161 "vec4 textureWeightedQCOM(sampler2D, vec2, sampler1DArray);"
4162 "vec4 textureBoxFilterQCOM(sampler2D, vec2, vec2);"
4163 "vec4 textureBlockMatchSADQCOM(sampler2D, uvec2, sampler2D, uvec2, uvec2);"
4164 "vec4 textureBlockMatchSSDQCOM(sampler2D, uvec2, sampler2D, uvec2, uvec2);"
4165 "\n");
4166 }
4167
4168 //============================================================================
4169 //
4170 // Prototypes for built-in functions seen by vertex shaders only.
4171 // (Except legacy lod functions, where it depends which release they are
4172 // vertex only.)
4173 //
4174 //============================================================================
4175
4176 //
4177 // Geometric Functions.
4178 //
4179 if (spvVersion.vulkan == 0 && IncludeLegacy(version, profile, spvVersion))
4180 stageBuiltins[EShLangVertex].append("vec4 ftransform();");
4181
4182 //
4183 // Original-style texture Functions with lod.
4184 //
4185 TString* s;
4186 if (version == 100)
4187 s = &stageBuiltins[EShLangVertex];
4188 else
4189 s = &commonBuiltins;
4190 if ((profile == EEsProfile && version == 100) ||
4191 profile == ECompatibilityProfile ||
4192 (profile == ECoreProfile && version < 420) ||
4193 profile == ENoProfile) {
4194 if (spvVersion.spv == 0) {
4195 s->append(
4196 "vec4 texture2DLod(sampler2D, vec2, float);" // GL_ARB_shader_texture_lod
4197 "vec4 texture2DProjLod(sampler2D, vec3, float);" // GL_ARB_shader_texture_lod
4198 "vec4 texture2DProjLod(sampler2D, vec4, float);" // GL_ARB_shader_texture_lod
4199 "vec4 texture3DLod(sampler3D, vec3, float);" // GL_ARB_shader_texture_lod // OES_texture_3D, but caught by keyword check
4200 "vec4 texture3DProjLod(sampler3D, vec4, float);" // GL_ARB_shader_texture_lod // OES_texture_3D, but caught by keyword check
4201 "vec4 textureCubeLod(samplerCube, vec3, float);" // GL_ARB_shader_texture_lod
4202
4203 "\n");
4204 }
4205 }
4206 if ( profile == ECompatibilityProfile ||
4207 (profile == ECoreProfile && version < 420) ||
4208 profile == ENoProfile) {
4209 if (spvVersion.spv == 0) {
4210 s->append(
4211 "vec4 texture1DLod(sampler1D, float, float);" // GL_ARB_shader_texture_lod
4212 "vec4 texture1DProjLod(sampler1D, vec2, float);" // GL_ARB_shader_texture_lod
4213 "vec4 texture1DProjLod(sampler1D, vec4, float);" // GL_ARB_shader_texture_lod
4214 "vec4 shadow1DLod(sampler1DShadow, vec3, float);" // GL_ARB_shader_texture_lod
4215 "vec4 shadow2DLod(sampler2DShadow, vec3, float);" // GL_ARB_shader_texture_lod
4216 "vec4 shadow1DProjLod(sampler1DShadow, vec4, float);" // GL_ARB_shader_texture_lod
4217 "vec4 shadow2DProjLod(sampler2DShadow, vec4, float);" // GL_ARB_shader_texture_lod
4218
4219 "vec4 texture1DGradARB(sampler1D, float, float, float);" // GL_ARB_shader_texture_lod
4220 "vec4 texture1DProjGradARB(sampler1D, vec2, float, float);" // GL_ARB_shader_texture_lod
4221 "vec4 texture1DProjGradARB(sampler1D, vec4, float, float);" // GL_ARB_shader_texture_lod
4222 "vec4 texture2DGradARB(sampler2D, vec2, vec2, vec2);" // GL_ARB_shader_texture_lod
4223 "vec4 texture2DProjGradARB(sampler2D, vec3, vec2, vec2);" // GL_ARB_shader_texture_lod
4224 "vec4 texture2DProjGradARB(sampler2D, vec4, vec2, vec2);" // GL_ARB_shader_texture_lod
4225 "vec4 texture3DGradARB(sampler3D, vec3, vec3, vec3);" // GL_ARB_shader_texture_lod
4226 "vec4 texture3DProjGradARB(sampler3D, vec4, vec3, vec3);" // GL_ARB_shader_texture_lod
4227 "vec4 textureCubeGradARB(samplerCube, vec3, vec3, vec3);" // GL_ARB_shader_texture_lod
4228 "vec4 shadow1DGradARB(sampler1DShadow, vec3, float, float);" // GL_ARB_shader_texture_lod
4229 "vec4 shadow1DProjGradARB( sampler1DShadow, vec4, float, float);" // GL_ARB_shader_texture_lod
4230 "vec4 shadow2DGradARB(sampler2DShadow, vec3, vec2, vec2);" // GL_ARB_shader_texture_lod
4231 "vec4 shadow2DProjGradARB( sampler2DShadow, vec4, vec2, vec2);" // GL_ARB_shader_texture_lod
4232 "vec4 texture2DRectGradARB(sampler2DRect, vec2, vec2, vec2);" // GL_ARB_shader_texture_lod
4233 "vec4 texture2DRectProjGradARB( sampler2DRect, vec3, vec2, vec2);" // GL_ARB_shader_texture_lod
4234 "vec4 texture2DRectProjGradARB( sampler2DRect, vec4, vec2, vec2);" // GL_ARB_shader_texture_lod
4235 "vec4 shadow2DRectGradARB( sampler2DRectShadow, vec3, vec2, vec2);" // GL_ARB_shader_texture_lod
4236 "vec4 shadow2DRectProjGradARB(sampler2DRectShadow, vec4, vec2, vec2);" // GL_ARB_shader_texture_lod
4237
4238 "\n");
4239 }
4240 }
4241
4242 if ((profile != EEsProfile && version >= 150) ||
4243 (profile == EEsProfile && version >= 310)) {
4244 //============================================================================
4245 //
4246 // Prototypes for built-in functions seen by geometry shaders only.
4247 //
4248 //============================================================================
4249
4250 if (profile != EEsProfile && (version >= 400 || version == 150)) {
4251 stageBuiltins[EShLangGeometry].append(
4252 "void EmitStreamVertex(int);"
4253 "void EndStreamPrimitive(int);"
4254 );
4255 }
4256 stageBuiltins[EShLangGeometry].append(
4257 "void EmitVertex();"
4258 "void EndPrimitive();"
4259 "\n");
4260 }
4261
4262 //============================================================================
4263 //
4264 // Prototypes for all control functions.
4265 //
4266 //============================================================================
4267 bool esBarrier = (profile == EEsProfile && version >= 310);
4268 if ((profile != EEsProfile && version >= 150) || esBarrier)
4269 stageBuiltins[EShLangTessControl].append(
4270 "void barrier();"
4271 );
4272 if ((profile != EEsProfile && version >= 420) || esBarrier)
4273 stageBuiltins[EShLangCompute].append(
4274 "void barrier();"
4275 );
4276 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
4277 stageBuiltins[EShLangMesh].append(
4278 "void barrier();"
4279 );
4280 stageBuiltins[EShLangTask].append(
4281 "void barrier();"
4282 );
4283 }
4284 if ((profile != EEsProfile && version >= 130) || esBarrier)
4285 commonBuiltins.append(
4286 "void memoryBarrier();"
4287 );
4288 if ((profile != EEsProfile && version >= 420) || esBarrier) {
4289 commonBuiltins.append(
4290 "void memoryBarrierBuffer();"
4291 );
4292 stageBuiltins[EShLangCompute].append(
4293 "void memoryBarrierShared();"
4294 "void groupMemoryBarrier();"
4295 );
4296 }
4297 if ((profile != EEsProfile && version >= 420) || esBarrier) {
4298 if (spvVersion.vulkan == 0 || spvVersion.vulkanRelaxed) {
4299 commonBuiltins.append("void memoryBarrierAtomicCounter();");
4300 }
4301 commonBuiltins.append("void memoryBarrierImage();");
4302 }
4303 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
4304 stageBuiltins[EShLangMesh].append(
4305 "void memoryBarrierShared();"
4306 "void groupMemoryBarrier();"
4307 );
4308 stageBuiltins[EShLangTask].append(
4309 "void memoryBarrierShared();"
4310 "void groupMemoryBarrier();"
4311 );
4312 }
4313
4314 commonBuiltins.append("void controlBarrier(int, int, int, int);\n"
4315 "void memoryBarrier(int, int, int);\n");
4316
4317 commonBuiltins.append("void debugPrintfEXT();\n");
4318
4319 if (profile != EEsProfile && version >= 450) {
4320 // coopMatStoreNV perhaps ought to have "out" on the buf parameter, but
4321 // adding it introduces undesirable tempArgs on the stack. What we want
4322 // is more like "buf" thought of as a pointer value being an in parameter.
4323 stageBuiltins[EShLangCompute].append(
4324 "void coopMatLoadNV(out fcoopmatNV m, volatile coherent float16_t[] buf, uint element, uint stride, bool colMajor);\n"
4325 "void coopMatLoadNV(out fcoopmatNV m, volatile coherent float[] buf, uint element, uint stride, bool colMajor);\n"
4326 "void coopMatLoadNV(out fcoopmatNV m, volatile coherent uint8_t[] buf, uint element, uint stride, bool colMajor);\n"
4327 "void coopMatLoadNV(out fcoopmatNV m, volatile coherent uint16_t[] buf, uint element, uint stride, bool colMajor);\n"
4328 "void coopMatLoadNV(out fcoopmatNV m, volatile coherent uint[] buf, uint element, uint stride, bool colMajor);\n"
4329 "void coopMatLoadNV(out fcoopmatNV m, volatile coherent uint64_t[] buf, uint element, uint stride, bool colMajor);\n"
4330 "void coopMatLoadNV(out fcoopmatNV m, volatile coherent uvec2[] buf, uint element, uint stride, bool colMajor);\n"
4331 "void coopMatLoadNV(out fcoopmatNV m, volatile coherent uvec4[] buf, uint element, uint stride, bool colMajor);\n"
4332
4333 "void coopMatStoreNV(fcoopmatNV m, volatile coherent float16_t[] buf, uint element, uint stride, bool colMajor);\n"
4334 "void coopMatStoreNV(fcoopmatNV m, volatile coherent float[] buf, uint element, uint stride, bool colMajor);\n"
4335 "void coopMatStoreNV(fcoopmatNV m, volatile coherent float64_t[] buf, uint element, uint stride, bool colMajor);\n"
4336 "void coopMatStoreNV(fcoopmatNV m, volatile coherent uint8_t[] buf, uint element, uint stride, bool colMajor);\n"
4337 "void coopMatStoreNV(fcoopmatNV m, volatile coherent uint16_t[] buf, uint element, uint stride, bool colMajor);\n"
4338 "void coopMatStoreNV(fcoopmatNV m, volatile coherent uint[] buf, uint element, uint stride, bool colMajor);\n"
4339 "void coopMatStoreNV(fcoopmatNV m, volatile coherent uint64_t[] buf, uint element, uint stride, bool colMajor);\n"
4340 "void coopMatStoreNV(fcoopmatNV m, volatile coherent uvec2[] buf, uint element, uint stride, bool colMajor);\n"
4341 "void coopMatStoreNV(fcoopmatNV m, volatile coherent uvec4[] buf, uint element, uint stride, bool colMajor);\n"
4342
4343 "fcoopmatNV coopMatMulAddNV(fcoopmatNV A, fcoopmatNV B, fcoopmatNV C);\n"
4344 "void coopMatLoadNV(out icoopmatNV m, volatile coherent int8_t[] buf, uint element, uint stride, bool colMajor);\n"
4345 "void coopMatLoadNV(out icoopmatNV m, volatile coherent int16_t[] buf, uint element, uint stride, bool colMajor);\n"
4346 "void coopMatLoadNV(out icoopmatNV m, volatile coherent int[] buf, uint element, uint stride, bool colMajor);\n"
4347 "void coopMatLoadNV(out icoopmatNV m, volatile coherent int64_t[] buf, uint element, uint stride, bool colMajor);\n"
4348 "void coopMatLoadNV(out icoopmatNV m, volatile coherent ivec2[] buf, uint element, uint stride, bool colMajor);\n"
4349 "void coopMatLoadNV(out icoopmatNV m, volatile coherent ivec4[] buf, uint element, uint stride, bool colMajor);\n"
4350 "void coopMatLoadNV(out icoopmatNV m, volatile coherent uint8_t[] buf, uint element, uint stride, bool colMajor);\n"
4351 "void coopMatLoadNV(out icoopmatNV m, volatile coherent uint16_t[] buf, uint element, uint stride, bool colMajor);\n"
4352 "void coopMatLoadNV(out icoopmatNV m, volatile coherent uint[] buf, uint element, uint stride, bool colMajor);\n"
4353 "void coopMatLoadNV(out icoopmatNV m, volatile coherent uint64_t[] buf, uint element, uint stride, bool colMajor);\n"
4354 "void coopMatLoadNV(out icoopmatNV m, volatile coherent uvec2[] buf, uint element, uint stride, bool colMajor);\n"
4355 "void coopMatLoadNV(out icoopmatNV m, volatile coherent uvec4[] buf, uint element, uint stride, bool colMajor);\n"
4356
4357 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent int8_t[] buf, uint element, uint stride, bool colMajor);\n"
4358 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent int16_t[] buf, uint element, uint stride, bool colMajor);\n"
4359 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent int[] buf, uint element, uint stride, bool colMajor);\n"
4360 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent int64_t[] buf, uint element, uint stride, bool colMajor);\n"
4361 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent ivec2[] buf, uint element, uint stride, bool colMajor);\n"
4362 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent ivec4[] buf, uint element, uint stride, bool colMajor);\n"
4363 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent uint8_t[] buf, uint element, uint stride, bool colMajor);\n"
4364 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent uint16_t[] buf, uint element, uint stride, bool colMajor);\n"
4365 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent uint[] buf, uint element, uint stride, bool colMajor);\n"
4366 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent uint64_t[] buf, uint element, uint stride, bool colMajor);\n"
4367 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent uvec2[] buf, uint element, uint stride, bool colMajor);\n"
4368 "void coopMatLoadNV(out ucoopmatNV m, volatile coherent uvec4[] buf, uint element, uint stride, bool colMajor);\n"
4369
4370 "void coopMatStoreNV(icoopmatNV m, volatile coherent int8_t[] buf, uint element, uint stride, bool colMajor);\n"
4371 "void coopMatStoreNV(icoopmatNV m, volatile coherent int16_t[] buf, uint element, uint stride, bool colMajor);\n"
4372 "void coopMatStoreNV(icoopmatNV m, volatile coherent int[] buf, uint element, uint stride, bool colMajor);\n"
4373 "void coopMatStoreNV(icoopmatNV m, volatile coherent int64_t[] buf, uint element, uint stride, bool colMajor);\n"
4374 "void coopMatStoreNV(icoopmatNV m, volatile coherent ivec2[] buf, uint element, uint stride, bool colMajor);\n"
4375 "void coopMatStoreNV(icoopmatNV m, volatile coherent ivec4[] buf, uint element, uint stride, bool colMajor);\n"
4376 "void coopMatStoreNV(icoopmatNV m, volatile coherent uint8_t[] buf, uint element, uint stride, bool colMajor);\n"
4377 "void coopMatStoreNV(icoopmatNV m, volatile coherent uint16_t[] buf, uint element, uint stride, bool colMajor);\n"
4378 "void coopMatStoreNV(icoopmatNV m, volatile coherent uint[] buf, uint element, uint stride, bool colMajor);\n"
4379 "void coopMatStoreNV(icoopmatNV m, volatile coherent uint64_t[] buf, uint element, uint stride, bool colMajor);\n"
4380 "void coopMatStoreNV(icoopmatNV m, volatile coherent uvec2[] buf, uint element, uint stride, bool colMajor);\n"
4381 "void coopMatStoreNV(icoopmatNV m, volatile coherent uvec4[] buf, uint element, uint stride, bool colMajor);\n"
4382
4383 "void coopMatStoreNV(ucoopmatNV m, volatile coherent int8_t[] buf, uint element, uint stride, bool colMajor);\n"
4384 "void coopMatStoreNV(ucoopmatNV m, volatile coherent int16_t[] buf, uint element, uint stride, bool colMajor);\n"
4385 "void coopMatStoreNV(ucoopmatNV m, volatile coherent int[] buf, uint element, uint stride, bool colMajor);\n"
4386 "void coopMatStoreNV(ucoopmatNV m, volatile coherent int64_t[] buf, uint element, uint stride, bool colMajor);\n"
4387 "void coopMatStoreNV(ucoopmatNV m, volatile coherent ivec2[] buf, uint element, uint stride, bool colMajor);\n"
4388 "void coopMatStoreNV(ucoopmatNV m, volatile coherent ivec4[] buf, uint element, uint stride, bool colMajor);\n"
4389 "void coopMatStoreNV(ucoopmatNV m, volatile coherent uint8_t[] buf, uint element, uint stride, bool colMajor);\n"
4390 "void coopMatStoreNV(ucoopmatNV m, volatile coherent uint16_t[] buf, uint element, uint stride, bool colMajor);\n"
4391 "void coopMatStoreNV(ucoopmatNV m, volatile coherent uint[] buf, uint element, uint stride, bool colMajor);\n"
4392 "void coopMatStoreNV(ucoopmatNV m, volatile coherent uint64_t[] buf, uint element, uint stride, bool colMajor);\n"
4393 "void coopMatStoreNV(ucoopmatNV m, volatile coherent uvec2[] buf, uint element, uint stride, bool colMajor);\n"
4394 "void coopMatStoreNV(ucoopmatNV m, volatile coherent uvec4[] buf, uint element, uint stride, bool colMajor);\n"
4395
4396 "icoopmatNV coopMatMulAddNV(icoopmatNV A, icoopmatNV B, icoopmatNV C);\n"
4397 "ucoopmatNV coopMatMulAddNV(ucoopmatNV A, ucoopmatNV B, ucoopmatNV C);\n"
4398 );
4399
4400 std::string cooperativeMatrixFuncs =
4401 "void coopMatLoad(out coopmat m, volatile coherent int8_t[] buf, uint element, uint stride, int matrixLayout);\n"
4402 "void coopMatLoad(out coopmat m, volatile coherent int16_t[] buf, uint element, uint stride, int matrixLayout);\n"
4403 "void coopMatLoad(out coopmat m, volatile coherent int32_t[] buf, uint element, uint stride, int matrixLayout);\n"
4404 "void coopMatLoad(out coopmat m, volatile coherent int64_t[] buf, uint element, uint stride, int matrixLayout);\n"
4405 "void coopMatLoad(out coopmat m, volatile coherent uint8_t[] buf, uint element, uint stride, int matrixLayout);\n"
4406 "void coopMatLoad(out coopmat m, volatile coherent uint16_t[] buf, uint element, uint stride, int matrixLayout);\n"
4407 "void coopMatLoad(out coopmat m, volatile coherent uint32_t[] buf, uint element, uint stride, int matrixLayout);\n"
4408 "void coopMatLoad(out coopmat m, volatile coherent uint64_t[] buf, uint element, uint stride, int matrixLayout);\n"
4409 "void coopMatLoad(out coopmat m, volatile coherent float16_t[] buf, uint element, uint stride, int matrixLayout);\n"
4410 "void coopMatLoad(out coopmat m, volatile coherent float[] buf, uint element, uint stride, int matrixLayout);\n"
4411 "void coopMatLoad(out coopmat m, volatile coherent float64_t[] buf, uint element, uint stride, int matrixLayout);\n"
4412
4413 "void coopMatLoad(out coopmat m, volatile coherent i8vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4414 "void coopMatLoad(out coopmat m, volatile coherent i16vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4415 "void coopMatLoad(out coopmat m, volatile coherent i32vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4416 "void coopMatLoad(out coopmat m, volatile coherent i64vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4417 "void coopMatLoad(out coopmat m, volatile coherent u8vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4418 "void coopMatLoad(out coopmat m, volatile coherent u16vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4419 "void coopMatLoad(out coopmat m, volatile coherent u32vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4420 "void coopMatLoad(out coopmat m, volatile coherent u64vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4421 "void coopMatLoad(out coopmat m, volatile coherent f16vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4422 "void coopMatLoad(out coopmat m, volatile coherent f32vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4423 "void coopMatLoad(out coopmat m, volatile coherent f64vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4424
4425 "void coopMatLoad(out coopmat m, volatile coherent i8vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4426 "void coopMatLoad(out coopmat m, volatile coherent i16vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4427 "void coopMatLoad(out coopmat m, volatile coherent i32vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4428 "void coopMatLoad(out coopmat m, volatile coherent i64vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4429 "void coopMatLoad(out coopmat m, volatile coherent u8vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4430 "void coopMatLoad(out coopmat m, volatile coherent u16vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4431 "void coopMatLoad(out coopmat m, volatile coherent u32vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4432 "void coopMatLoad(out coopmat m, volatile coherent u64vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4433 "void coopMatLoad(out coopmat m, volatile coherent f16vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4434 "void coopMatLoad(out coopmat m, volatile coherent f32vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4435 "void coopMatLoad(out coopmat m, volatile coherent f64vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4436
4437 "void coopMatStore(coopmat m, volatile coherent int8_t[] buf, uint element, uint stride, int matrixLayout);\n"
4438 "void coopMatStore(coopmat m, volatile coherent int16_t[] buf, uint element, uint stride, int matrixLayout);\n"
4439 "void coopMatStore(coopmat m, volatile coherent int32_t[] buf, uint element, uint stride, int matrixLayout);\n"
4440 "void coopMatStore(coopmat m, volatile coherent int64_t[] buf, uint element, uint stride, int matrixLayout);\n"
4441 "void coopMatStore(coopmat m, volatile coherent uint8_t[] buf, uint element, uint stride, int matrixLayout);\n"
4442 "void coopMatStore(coopmat m, volatile coherent uint16_t[] buf, uint element, uint stride, int matrixLayout);\n"
4443 "void coopMatStore(coopmat m, volatile coherent uint32_t[] buf, uint element, uint stride, int matrixLayout);\n"
4444 "void coopMatStore(coopmat m, volatile coherent uint64_t[] buf, uint element, uint stride, int matrixLayout);\n"
4445 "void coopMatStore(coopmat m, volatile coherent float16_t[] buf, uint element, uint stride, int matrixLayout);\n"
4446 "void coopMatStore(coopmat m, volatile coherent float[] buf, uint element, uint stride, int matrixLayout);\n"
4447 "void coopMatStore(coopmat m, volatile coherent float64_t[] buf, uint element, uint stride, int matrixLayout);\n"
4448
4449 "void coopMatStore(coopmat m, volatile coherent i8vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4450 "void coopMatStore(coopmat m, volatile coherent i16vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4451 "void coopMatStore(coopmat m, volatile coherent i32vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4452 "void coopMatStore(coopmat m, volatile coherent i64vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4453 "void coopMatStore(coopmat m, volatile coherent u8vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4454 "void coopMatStore(coopmat m, volatile coherent u16vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4455 "void coopMatStore(coopmat m, volatile coherent u32vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4456 "void coopMatStore(coopmat m, volatile coherent u64vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4457 "void coopMatStore(coopmat m, volatile coherent f16vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4458 "void coopMatStore(coopmat m, volatile coherent f32vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4459 "void coopMatStore(coopmat m, volatile coherent f64vec2[] buf, uint element, uint stride, int matrixLayout);\n"
4460
4461 "void coopMatStore(coopmat m, volatile coherent i8vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4462 "void coopMatStore(coopmat m, volatile coherent i16vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4463 "void coopMatStore(coopmat m, volatile coherent i32vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4464 "void coopMatStore(coopmat m, volatile coherent i64vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4465 "void coopMatStore(coopmat m, volatile coherent u8vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4466 "void coopMatStore(coopmat m, volatile coherent u16vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4467 "void coopMatStore(coopmat m, volatile coherent u32vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4468 "void coopMatStore(coopmat m, volatile coherent u64vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4469 "void coopMatStore(coopmat m, volatile coherent f16vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4470 "void coopMatStore(coopmat m, volatile coherent f32vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4471 "void coopMatStore(coopmat m, volatile coherent f64vec4[] buf, uint element, uint stride, int matrixLayout);\n"
4472
4473 "coopmat coopMatMulAdd(coopmat A, coopmat B, coopmat C);\n"
4474 "coopmat coopMatMulAdd(coopmat A, coopmat B, coopmat C, int matrixOperands);\n";
4475
4476 commonBuiltins.append(cooperativeMatrixFuncs.c_str());
4477
4478 commonBuiltins.append(
4479 "const int gl_MatrixUseA = 0;\n"
4480 "const int gl_MatrixUseB = 1;\n"
4481 "const int gl_MatrixUseAccumulator = 2;\n"
4482 "const int gl_MatrixOperandsSaturatingAccumulation = 0x10;\n"
4483 "const int gl_CooperativeMatrixLayoutRowMajor = 0;\n"
4484 "const int gl_CooperativeMatrixLayoutColumnMajor = 1;\n"
4485 "\n"
4486 );
4487 }
4488
4489 //============================================================================
4490 //
4491 // Prototypes for built-in functions seen by fragment shaders only.
4492 //
4493 //============================================================================
4494
4495 //
4496 // Original-style texture Functions with bias.
4497 //
4498 if (spvVersion.spv == 0 && (profile != EEsProfile || version == 100)) {
4499 stageBuiltins[EShLangFragment].append(
4500 "vec4 texture2D(sampler2D, vec2, float);"
4501 "vec4 texture2DProj(sampler2D, vec3, float);"
4502 "vec4 texture2DProj(sampler2D, vec4, float);"
4503 "vec4 texture3D(sampler3D, vec3, float);" // OES_texture_3D
4504 "vec4 texture3DProj(sampler3D, vec4, float);" // OES_texture_3D
4505 "vec4 textureCube(samplerCube, vec3, float);"
4506
4507 "\n");
4508 }
4509 if (spvVersion.spv == 0 && (profile != EEsProfile && version > 100)) {
4510 stageBuiltins[EShLangFragment].append(
4511 "vec4 texture1D(sampler1D, float, float);"
4512 "vec4 texture1DProj(sampler1D, vec2, float);"
4513 "vec4 texture1DProj(sampler1D, vec4, float);"
4514 "vec4 shadow1D(sampler1DShadow, vec3, float);"
4515 "vec4 shadow2D(sampler2DShadow, vec3, float);"
4516 "vec4 shadow1DProj(sampler1DShadow, vec4, float);"
4517 "vec4 shadow2DProj(sampler2DShadow, vec4, float);"
4518
4519 "\n");
4520 }
4521 if (spvVersion.spv == 0 && profile == EEsProfile) {
4522 stageBuiltins[EShLangFragment].append(
4523 "vec4 texture2DLodEXT(sampler2D, vec2, float);" // GL_EXT_shader_texture_lod
4524 "vec4 texture2DProjLodEXT(sampler2D, vec3, float);" // GL_EXT_shader_texture_lod
4525 "vec4 texture2DProjLodEXT(sampler2D, vec4, float);" // GL_EXT_shader_texture_lod
4526 "vec4 textureCubeLodEXT(samplerCube, vec3, float);" // GL_EXT_shader_texture_lod
4527
4528 "\n");
4529 }
4530
4531 // GL_EXT_shader_tile_image
4532 if (spvVersion.vulkan > 0) {
4533 stageBuiltins[EShLangFragment].append(
4534 "lowp uint stencilAttachmentReadEXT();"
4535 "lowp uint stencilAttachmentReadEXT(int);"
4536 "highp float depthAttachmentReadEXT();"
4537 "highp float depthAttachmentReadEXT(int);"
4538 "\n");
4539 stageBuiltins[EShLangFragment].append(
4540 "vec4 colorAttachmentReadEXT(attachmentEXT);"
4541 "vec4 colorAttachmentReadEXT(attachmentEXT, int);"
4542 "ivec4 colorAttachmentReadEXT(iattachmentEXT);"
4543 "ivec4 colorAttachmentReadEXT(iattachmentEXT, int);"
4544 "uvec4 colorAttachmentReadEXT(uattachmentEXT);"
4545 "uvec4 colorAttachmentReadEXT(uattachmentEXT, int);"
4546 "\n");
4547 }
4548
4549 // GL_ARB_derivative_control
4550 if (profile != EEsProfile && version >= 400) {
4551 stageBuiltins[EShLangFragment].append(derivativeControls);
4552 stageBuiltins[EShLangFragment].append("\n");
4553 }
4554
4555 // GL_OES_shader_multisample_interpolation
4556 if ((profile == EEsProfile && version >= 310) ||
4557 (profile != EEsProfile && version >= 400)) {
4558 stageBuiltins[EShLangFragment].append(
4559 "float interpolateAtCentroid(float);"
4560 "vec2 interpolateAtCentroid(vec2);"
4561 "vec3 interpolateAtCentroid(vec3);"
4562 "vec4 interpolateAtCentroid(vec4);"
4563
4564 "float interpolateAtSample(float, int);"
4565 "vec2 interpolateAtSample(vec2, int);"
4566 "vec3 interpolateAtSample(vec3, int);"
4567 "vec4 interpolateAtSample(vec4, int);"
4568
4569 "float interpolateAtOffset(float, vec2);"
4570 "vec2 interpolateAtOffset(vec2, vec2);"
4571 "vec3 interpolateAtOffset(vec3, vec2);"
4572 "vec4 interpolateAtOffset(vec4, vec2);"
4573
4574 "\n");
4575 }
4576
4577 stageBuiltins[EShLangFragment].append(
4578 "void beginInvocationInterlockARB(void);"
4579 "void endInvocationInterlockARB(void);");
4580
4581 stageBuiltins[EShLangFragment].append(
4582 "bool helperInvocationEXT();"
4583 "\n");
4584
4585 // GL_AMD_shader_explicit_vertex_parameter
4586 if (profile != EEsProfile && version >= 450) {
4587 stageBuiltins[EShLangFragment].append(
4588 "float interpolateAtVertexAMD(float, uint);"
4589 "vec2 interpolateAtVertexAMD(vec2, uint);"
4590 "vec3 interpolateAtVertexAMD(vec3, uint);"
4591 "vec4 interpolateAtVertexAMD(vec4, uint);"
4592
4593 "int interpolateAtVertexAMD(int, uint);"
4594 "ivec2 interpolateAtVertexAMD(ivec2, uint);"
4595 "ivec3 interpolateAtVertexAMD(ivec3, uint);"
4596 "ivec4 interpolateAtVertexAMD(ivec4, uint);"
4597
4598 "uint interpolateAtVertexAMD(uint, uint);"
4599 "uvec2 interpolateAtVertexAMD(uvec2, uint);"
4600 "uvec3 interpolateAtVertexAMD(uvec3, uint);"
4601 "uvec4 interpolateAtVertexAMD(uvec4, uint);"
4602
4603 "float16_t interpolateAtVertexAMD(float16_t, uint);"
4604 "f16vec2 interpolateAtVertexAMD(f16vec2, uint);"
4605 "f16vec3 interpolateAtVertexAMD(f16vec3, uint);"
4606 "f16vec4 interpolateAtVertexAMD(f16vec4, uint);"
4607
4608 "\n");
4609 }
4610
4611 // GL_AMD_gpu_shader_half_float
4612 if (profile != EEsProfile && version >= 450) {
4613 stageBuiltins[EShLangFragment].append(derivativesAndControl16bits);
4614 stageBuiltins[EShLangFragment].append("\n");
4615
4616 stageBuiltins[EShLangFragment].append(
4617 "float16_t interpolateAtCentroid(float16_t);"
4618 "f16vec2 interpolateAtCentroid(f16vec2);"
4619 "f16vec3 interpolateAtCentroid(f16vec3);"
4620 "f16vec4 interpolateAtCentroid(f16vec4);"
4621
4622 "float16_t interpolateAtSample(float16_t, int);"
4623 "f16vec2 interpolateAtSample(f16vec2, int);"
4624 "f16vec3 interpolateAtSample(f16vec3, int);"
4625 "f16vec4 interpolateAtSample(f16vec4, int);"
4626
4627 "float16_t interpolateAtOffset(float16_t, f16vec2);"
4628 "f16vec2 interpolateAtOffset(f16vec2, f16vec2);"
4629 "f16vec3 interpolateAtOffset(f16vec3, f16vec2);"
4630 "f16vec4 interpolateAtOffset(f16vec4, f16vec2);"
4631
4632 "\n");
4633 }
4634
4635 // GL_ARB_shader_clock& GL_EXT_shader_realtime_clock
4636 if (profile != EEsProfile && version >= 450) {
4637 commonBuiltins.append(
4638 "uvec2 clock2x32ARB();"
4639 "uint64_t clockARB();"
4640 "uvec2 clockRealtime2x32EXT();"
4641 "uint64_t clockRealtimeEXT();"
4642 "\n");
4643 }
4644
4645 // GL_AMD_shader_fragment_mask
4646 if (profile != EEsProfile && version >= 450 && spvVersion.vulkan > 0) {
4647 stageBuiltins[EShLangFragment].append(
4648 "uint fragmentMaskFetchAMD(subpassInputMS);"
4649 "uint fragmentMaskFetchAMD(isubpassInputMS);"
4650 "uint fragmentMaskFetchAMD(usubpassInputMS);"
4651
4652 "vec4 fragmentFetchAMD(subpassInputMS, uint);"
4653 "ivec4 fragmentFetchAMD(isubpassInputMS, uint);"
4654 "uvec4 fragmentFetchAMD(usubpassInputMS, uint);"
4655
4656 "\n");
4657 }
4658
4659 // Builtins for GL_NV_ray_tracing/GL_NV_ray_tracing_motion_blur/GL_EXT_ray_tracing/GL_EXT_ray_query/
4660 // GL_NV_shader_invocation_reorder/GL_KHR_ray_tracing_position_Fetch
4661 if (profile != EEsProfile && version >= 460) {
4662 commonBuiltins.append("void rayQueryInitializeEXT(rayQueryEXT, accelerationStructureEXT, uint, uint, vec3, float, vec3, float);"
4663 "void rayQueryTerminateEXT(rayQueryEXT);"
4664 "void rayQueryGenerateIntersectionEXT(rayQueryEXT, float);"
4665 "void rayQueryConfirmIntersectionEXT(rayQueryEXT);"
4666 "bool rayQueryProceedEXT(rayQueryEXT);"
4667 "uint rayQueryGetIntersectionTypeEXT(rayQueryEXT, bool);"
4668 "float rayQueryGetRayTMinEXT(rayQueryEXT);"
4669 "uint rayQueryGetRayFlagsEXT(rayQueryEXT);"
4670 "vec3 rayQueryGetWorldRayOriginEXT(rayQueryEXT);"
4671 "vec3 rayQueryGetWorldRayDirectionEXT(rayQueryEXT);"
4672 "float rayQueryGetIntersectionTEXT(rayQueryEXT, bool);"
4673 "int rayQueryGetIntersectionInstanceCustomIndexEXT(rayQueryEXT, bool);"
4674 "int rayQueryGetIntersectionInstanceIdEXT(rayQueryEXT, bool);"
4675 "uint rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT(rayQueryEXT, bool);"
4676 "int rayQueryGetIntersectionGeometryIndexEXT(rayQueryEXT, bool);"
4677 "int rayQueryGetIntersectionPrimitiveIndexEXT(rayQueryEXT, bool);"
4678 "vec2 rayQueryGetIntersectionBarycentricsEXT(rayQueryEXT, bool);"
4679 "bool rayQueryGetIntersectionFrontFaceEXT(rayQueryEXT, bool);"
4680 "bool rayQueryGetIntersectionCandidateAABBOpaqueEXT(rayQueryEXT);"
4681 "vec3 rayQueryGetIntersectionObjectRayDirectionEXT(rayQueryEXT, bool);"
4682 "vec3 rayQueryGetIntersectionObjectRayOriginEXT(rayQueryEXT, bool);"
4683 "mat4x3 rayQueryGetIntersectionObjectToWorldEXT(rayQueryEXT, bool);"
4684 "mat4x3 rayQueryGetIntersectionWorldToObjectEXT(rayQueryEXT, bool);"
4685 "void rayQueryGetIntersectionTriangleVertexPositionsEXT(rayQueryEXT, bool, out vec3[3]);"
4686 "\n");
4687
4688 stageBuiltins[EShLangRayGen].append(
4689 "void traceNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
4690 "void traceRayMotionNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,float,int);"
4691 "void traceRayEXT(accelerationStructureEXT,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
4692 "void executeCallableNV(uint, int);"
4693 "void executeCallableEXT(uint, int);"
4694 "void hitObjectTraceRayNV(hitObjectNV,accelerationStructureEXT,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
4695 "void hitObjectTraceRayMotionNV(hitObjectNV,accelerationStructureEXT,uint,uint,uint,uint,uint,vec3,float,vec3,float,float,int);"
4696 "void hitObjectRecordHitNV(hitObjectNV,accelerationStructureEXT,int,int,int,uint,uint,uint,vec3,float,vec3,float,int);"
4697 "void hitObjectRecordHitMotionNV(hitObjectNV,accelerationStructureEXT,int,int,int,uint,uint,uint,vec3,float,vec3,float,float,int);"
4698 "void hitObjectRecordHitWithIndexNV(hitObjectNV, accelerationStructureEXT,int,int,int,uint,uint,vec3,float,vec3,float,int);"
4699 "void hitObjectRecordHitWithIndexMotionNV(hitObjectNV, accelerationStructureEXT,int,int,int,uint,uint,vec3,float,vec3,float,float,int);"
4700 "void hitObjectRecordMissNV(hitObjectNV,uint,vec3,float,vec3,float);"
4701 "void hitObjectRecordMissMotionNV(hitObjectNV,uint,vec3,float,vec3,float,float);"
4702 "void hitObjectRecordEmptyNV(hitObjectNV);"
4703 "void hitObjectExecuteShaderNV(hitObjectNV,int);"
4704 "bool hitObjectIsEmptyNV(hitObjectNV);"
4705 "bool hitObjectIsMissNV(hitObjectNV);"
4706 "bool hitObjectIsHitNV(hitObjectNV);"
4707 "float hitObjectGetRayTMinNV(hitObjectNV);"
4708 "float hitObjectGetRayTMaxNV(hitObjectNV);"
4709 "vec3 hitObjectGetWorldRayOriginNV(hitObjectNV);"
4710 "vec3 hitObjectGetWorldRayDirectionNV(hitObjectNV);"
4711 "vec3 hitObjectGetObjectRayOriginNV(hitObjectNV);"
4712 "vec3 hitObjectGetObjectRayDirectionNV(hitObjectNV);"
4713 "mat4x3 hitObjectGetWorldToObjectNV(hitObjectNV);"
4714 "mat4x3 hitObjectGetObjectToWorldNV(hitObjectNV);"
4715 "int hitObjectGetInstanceCustomIndexNV(hitObjectNV);"
4716 "int hitObjectGetInstanceIdNV(hitObjectNV);"
4717 "int hitObjectGetGeometryIndexNV(hitObjectNV);"
4718 "int hitObjectGetPrimitiveIndexNV(hitObjectNV);"
4719 "uint hitObjectGetHitKindNV(hitObjectNV);"
4720 "void hitObjectGetAttributesNV(hitObjectNV,int);"
4721 "float hitObjectGetCurrentTimeNV(hitObjectNV);"
4722 "uint hitObjectGetShaderBindingTableRecordIndexNV(hitObjectNV);"
4723 "uvec2 hitObjectGetShaderRecordBufferHandleNV(hitObjectNV);"
4724 "void reorderThreadNV(uint, uint);"
4725 "void reorderThreadNV(hitObjectNV);"
4726 "void reorderThreadNV(hitObjectNV, uint, uint);"
4727 "vec3 fetchMicroTriangleVertexPositionNV(accelerationStructureEXT, int, int, int, ivec2);"
4728 "vec2 fetchMicroTriangleVertexBarycentricNV(accelerationStructureEXT, int, int, int, ivec2);"
4729 "\n");
4730 stageBuiltins[EShLangIntersect].append(
4731 "bool reportIntersectionNV(float, uint);"
4732 "bool reportIntersectionEXT(float, uint);"
4733 "\n");
4734 stageBuiltins[EShLangAnyHit].append(
4735 "void ignoreIntersectionNV();"
4736 "void terminateRayNV();"
4737 "\n");
4738 stageBuiltins[EShLangClosestHit].append(
4739 "void traceNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
4740 "void traceRayMotionNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,float,int);"
4741 "void traceRayEXT(accelerationStructureEXT,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
4742 "void executeCallableNV(uint, int);"
4743 "void executeCallableEXT(uint, int);"
4744 "void hitObjectTraceRayNV(hitObjectNV,accelerationStructureEXT,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
4745 "void hitObjectTraceRayMotionNV(hitObjectNV,accelerationStructureEXT,uint,uint,uint,uint,uint,vec3,float,vec3,float,float,int);"
4746 "void hitObjectRecordHitNV(hitObjectNV,accelerationStructureEXT,int,int,int,uint,uint,uint,vec3,float,vec3,float,int);"
4747 "void hitObjectRecordHitMotionNV(hitObjectNV,accelerationStructureEXT,int,int,int,uint,uint,uint,vec3,float,vec3,float,float,int);"
4748 "void hitObjectRecordHitWithIndexNV(hitObjectNV,accelerationStructureEXT,int,int,int,uint,uint,vec3,float,vec3,float,int);"
4749 "void hitObjectRecordHitWithIndexMotionNV(hitObjectNV, accelerationStructureEXT,int,int,int,uint,uint,vec3,float,vec3,float,float,int);"
4750 "void hitObjectRecordMissNV(hitObjectNV, uint, vec3, float, vec3, float);"
4751 "void hitObjectRecordMissMotionNV(hitObjectNV,uint,vec3,float,vec3,float,float);"
4752 "void hitObjectRecordEmptyNV(hitObjectNV);"
4753 "void hitObjectExecuteShaderNV(hitObjectNV, int);"
4754 "bool hitObjectIsEmptyNV(hitObjectNV);"
4755 "bool hitObjectIsMissNV(hitObjectNV);"
4756 "bool hitObjectIsHitNV(hitObjectNV);"
4757 "float hitObjectGetRayTMinNV(hitObjectNV);"
4758 "float hitObjectGetRayTMaxNV(hitObjectNV);"
4759 "vec3 hitObjectGetWorldRayOriginNV(hitObjectNV);"
4760 "vec3 hitObjectGetWorldRayDirectionNV(hitObjectNV);"
4761 "vec3 hitObjectGetObjectRayOriginNV(hitObjectNV);"
4762 "vec3 hitObjectGetObjectRayDirectionNV(hitObjectNV);"
4763 "mat4x3 hitObjectGetWorldToObjectNV(hitObjectNV);"
4764 "mat4x3 hitObjectGetObjectToWorldNV(hitObjectNV);"
4765 "int hitObjectGetInstanceCustomIndexNV(hitObjectNV);"
4766 "int hitObjectGetInstanceIdNV(hitObjectNV);"
4767 "int hitObjectGetGeometryIndexNV(hitObjectNV);"
4768 "int hitObjectGetPrimitiveIndexNV(hitObjectNV);"
4769 "uint hitObjectGetHitKindNV(hitObjectNV);"
4770 "void hitObjectGetAttributesNV(hitObjectNV,int);"
4771 "float hitObjectGetCurrentTimeNV(hitObjectNV);"
4772 "uint hitObjectGetShaderBindingTableRecordIndexNV(hitObjectNV);"
4773 "uvec2 hitObjectGetShaderRecordBufferHandleNV(hitObjectNV);"
4774 "\n");
4775 stageBuiltins[EShLangMiss].append(
4776 "void traceNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
4777 "void traceRayMotionNV(accelerationStructureNV,uint,uint,uint,uint,uint,vec3,float,vec3,float,float,int);"
4778 "void traceRayEXT(accelerationStructureEXT,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
4779 "void executeCallableNV(uint, int);"
4780 "void executeCallableEXT(uint, int);"
4781 "void hitObjectTraceRayNV(hitObjectNV,accelerationStructureEXT,uint,uint,uint,uint,uint,vec3,float,vec3,float,int);"
4782 "void hitObjectTraceRayMotionNV(hitObjectNV,accelerationStructureEXT,uint,uint,uint,uint,uint,vec3,float,vec3,float,float,int);"
4783 "void hitObjectRecordHitNV(hitObjectNV,accelerationStructureEXT,int,int,int,uint,uint,uint,vec3,float,vec3,float,int);"
4784 "void hitObjectRecordHitMotionNV(hitObjectNV,accelerationStructureEXT,int,int,int,uint,uint,uint,vec3,float,vec3,float,float,int);"
4785 "void hitObjectRecordHitWithIndexNV(hitObjectNV,accelerationStructureEXT,int,int,int,uint,uint,vec3,float,vec3,float,int);"
4786 "void hitObjectRecordHitWithIndexMotionNV(hitObjectNV, accelerationStructureEXT,int,int,int,uint,uint,vec3,float,vec3,float,float,int);"
4787 "void hitObjectRecordMissNV(hitObjectNV, uint, vec3, float, vec3, float);"
4788 "void hitObjectRecordMissMotionNV(hitObjectNV,uint,vec3,float,vec3,float,float);"
4789 "void hitObjectRecordEmptyNV(hitObjectNV);"
4790 "void hitObjectExecuteShaderNV(hitObjectNV, int);"
4791 "bool hitObjectIsEmptyNV(hitObjectNV);"
4792 "bool hitObjectIsMissNV(hitObjectNV);"
4793 "bool hitObjectIsHitNV(hitObjectNV);"
4794 "float hitObjectGetRayTMinNV(hitObjectNV);"
4795 "float hitObjectGetRayTMaxNV(hitObjectNV);"
4796 "vec3 hitObjectGetWorldRayOriginNV(hitObjectNV);"
4797 "vec3 hitObjectGetWorldRayDirectionNV(hitObjectNV);"
4798 "vec3 hitObjectGetObjectRayOriginNV(hitObjectNV);"
4799 "vec3 hitObjectGetObjectRayDirectionNV(hitObjectNV);"
4800 "mat4x3 hitObjectGetWorldToObjectNV(hitObjectNV);"
4801 "mat4x3 hitObjectGetObjectToWorldNV(hitObjectNV);"
4802 "int hitObjectGetInstanceCustomIndexNV(hitObjectNV);"
4803 "int hitObjectGetInstanceIdNV(hitObjectNV);"
4804 "int hitObjectGetGeometryIndexNV(hitObjectNV);"
4805 "int hitObjectGetPrimitiveIndexNV(hitObjectNV);"
4806 "uint hitObjectGetHitKindNV(hitObjectNV);"
4807 "void hitObjectGetAttributesNV(hitObjectNV,int);"
4808 "float hitObjectGetCurrentTimeNV(hitObjectNV);"
4809 "uint hitObjectGetShaderBindingTableRecordIndexNV(hitObjectNV);"
4810 "uvec2 hitObjectGetShaderRecordBufferHandleNV(hitObjectNV);"
4811 "\n");
4812 stageBuiltins[EShLangCallable].append(
4813 "void executeCallableNV(uint, int);"
4814 "void executeCallableEXT(uint, int);"
4815 "\n");
4816 }
4817
4818 //E_SPV_NV_compute_shader_derivatives
4819 if ((profile == EEsProfile && version >= 320) || (profile != EEsProfile && version >= 450)) {
4820 stageBuiltins[EShLangCompute].append(derivativeControls);
4821 stageBuiltins[EShLangCompute].append("\n");
4822 }
4823 if (profile != EEsProfile && version >= 450) {
4824 stageBuiltins[EShLangCompute].append(derivativesAndControl16bits);
4825 stageBuiltins[EShLangCompute].append(derivativesAndControl64bits);
4826 stageBuiltins[EShLangCompute].append("\n");
4827 }
4828
4829 // Builtins for GL_NV_mesh_shader
4830 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
4831 stageBuiltins[EShLangMesh].append(
4832 "void writePackedPrimitiveIndices4x8NV(uint, uint);"
4833 "\n");
4834 }
4835 // Builtins for GL_EXT_mesh_shader
4836 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
4837 // Builtins for GL_EXT_mesh_shader
4838 stageBuiltins[EShLangTask].append(
4839 "void EmitMeshTasksEXT(uint, uint, uint);"
4840 "\n");
4841
4842 stageBuiltins[EShLangMesh].append(
4843 "void SetMeshOutputsEXT(uint, uint);"
4844 "\n");
4845 }
4846 // Builtins for GL_NV_displacement_micromap
4847 if ((profile != EEsProfile && version >= 460) || (profile == EEsProfile && version >= 320)) {
4848 stageBuiltins[EShLangMesh].append(
4849 "vec3 fetchMicroTriangleVertexPositionNV(accelerationStructureEXT, int, int, int, ivec2);"
4850 "vec2 fetchMicroTriangleVertexBarycentricNV(accelerationStructureEXT, int, int, int, ivec2);"
4851 "\n");
4852
4853 stageBuiltins[EShLangCompute].append(
4854 "vec3 fetchMicroTriangleVertexPositionNV(accelerationStructureEXT, int, int, int, ivec2);"
4855 "vec2 fetchMicroTriangleVertexBarycentricNV(accelerationStructureEXT, int, int, int, ivec2);"
4856 "\n");
4857
4858 }
4859
4860
4861 //============================================================================
4862 //
4863 // Standard Uniforms
4864 //
4865 //============================================================================
4866
4867 //
4868 // Depth range in window coordinates, p. 33
4869 //
4870 if (spvVersion.spv == 0) {
4871 commonBuiltins.append(
4872 "struct gl_DepthRangeParameters {"
4873 );
4874 if (profile == EEsProfile) {
4875 commonBuiltins.append(
4876 "highp float near;" // n
4877 "highp float far;" // f
4878 "highp float diff;" // f - n
4879 );
4880 } else {
4881 commonBuiltins.append(
4882 "float near;" // n
4883 "float far;" // f
4884 "float diff;" // f - n
4885 );
4886 }
4887
4888 commonBuiltins.append(
4889 "};"
4890 "uniform gl_DepthRangeParameters gl_DepthRange;"
4891 "\n");
4892 }
4893
4894 if (spvVersion.spv == 0 && IncludeLegacy(version, profile, spvVersion)) {
4895 //
4896 // Matrix state. p. 31, 32, 37, 39, 40.
4897 //
4898 commonBuiltins.append(
4899 "uniform mat4 gl_ModelViewMatrix;"
4900 "uniform mat4 gl_ProjectionMatrix;"
4901 "uniform mat4 gl_ModelViewProjectionMatrix;"
4902
4903 //
4904 // Derived matrix state that provides inverse and transposed versions
4905 // of the matrices above.
4906 //
4907 "uniform mat3 gl_NormalMatrix;"
4908
4909 "uniform mat4 gl_ModelViewMatrixInverse;"
4910 "uniform mat4 gl_ProjectionMatrixInverse;"
4911 "uniform mat4 gl_ModelViewProjectionMatrixInverse;"
4912
4913 "uniform mat4 gl_ModelViewMatrixTranspose;"
4914 "uniform mat4 gl_ProjectionMatrixTranspose;"
4915 "uniform mat4 gl_ModelViewProjectionMatrixTranspose;"
4916
4917 "uniform mat4 gl_ModelViewMatrixInverseTranspose;"
4918 "uniform mat4 gl_ProjectionMatrixInverseTranspose;"
4919 "uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;"
4920
4921 //
4922 // Normal scaling p. 39.
4923 //
4924 "uniform float gl_NormalScale;"
4925
4926 //
4927 // Point Size, p. 66, 67.
4928 //
4929 "struct gl_PointParameters {"
4930 "float size;"
4931 "float sizeMin;"
4932 "float sizeMax;"
4933 "float fadeThresholdSize;"
4934 "float distanceConstantAttenuation;"
4935 "float distanceLinearAttenuation;"
4936 "float distanceQuadraticAttenuation;"
4937 "};"
4938
4939 "uniform gl_PointParameters gl_Point;"
4940
4941 //
4942 // Material State p. 50, 55.
4943 //
4944 "struct gl_MaterialParameters {"
4945 "vec4 emission;" // Ecm
4946 "vec4 ambient;" // Acm
4947 "vec4 diffuse;" // Dcm
4948 "vec4 specular;" // Scm
4949 "float shininess;" // Srm
4950 "};"
4951 "uniform gl_MaterialParameters gl_FrontMaterial;"
4952 "uniform gl_MaterialParameters gl_BackMaterial;"
4953
4954 //
4955 // Light State p 50, 53, 55.
4956 //
4957 "struct gl_LightSourceParameters {"
4958 "vec4 ambient;" // Acli
4959 "vec4 diffuse;" // Dcli
4960 "vec4 specular;" // Scli
4961 "vec4 position;" // Ppli
4962 "vec4 halfVector;" // Derived: Hi
4963 "vec3 spotDirection;" // Sdli
4964 "float spotExponent;" // Srli
4965 "float spotCutoff;" // Crli
4966 // (range: [0.0,90.0], 180.0)
4967 "float spotCosCutoff;" // Derived: cos(Crli)
4968 // (range: [1.0,0.0],-1.0)
4969 "float constantAttenuation;" // K0
4970 "float linearAttenuation;" // K1
4971 "float quadraticAttenuation;"// K2
4972 "};"
4973
4974 "struct gl_LightModelParameters {"
4975 "vec4 ambient;" // Acs
4976 "};"
4977
4978 "uniform gl_LightModelParameters gl_LightModel;"
4979
4980 //
4981 // Derived state from products of light and material.
4982 //
4983 "struct gl_LightModelProducts {"
4984 "vec4 sceneColor;" // Derived. Ecm + Acm * Acs
4985 "};"
4986
4987 "uniform gl_LightModelProducts gl_FrontLightModelProduct;"
4988 "uniform gl_LightModelProducts gl_BackLightModelProduct;"
4989
4990 "struct gl_LightProducts {"
4991 "vec4 ambient;" // Acm * Acli
4992 "vec4 diffuse;" // Dcm * Dcli
4993 "vec4 specular;" // Scm * Scli
4994 "};"
4995
4996 //
4997 // Fog p. 161
4998 //
4999 "struct gl_FogParameters {"
5000 "vec4 color;"
5001 "float density;"
5002 "float start;"
5003 "float end;"
5004 "float scale;" // 1 / (gl_FogEnd - gl_FogStart)
5005 "};"
5006
5007 "uniform gl_FogParameters gl_Fog;"
5008
5009 "\n");
5010 }
5011
5012 //============================================================================
5013 //
5014 // Define the interface to the compute shader.
5015 //
5016 //============================================================================
5017
5018 if ((profile != EEsProfile && version >= 420) ||
5019 (profile == EEsProfile && version >= 310)) {
5020 stageBuiltins[EShLangCompute].append(
5021 "in highp uvec3 gl_NumWorkGroups;"
5022 "const highp uvec3 gl_WorkGroupSize = uvec3(1,1,1);"
5023
5024 "in highp uvec3 gl_WorkGroupID;"
5025 "in highp uvec3 gl_LocalInvocationID;"
5026
5027 "in highp uvec3 gl_GlobalInvocationID;"
5028 "in highp uint gl_LocalInvocationIndex;"
5029
5030 "\n");
5031 }
5032
5033 if ((profile != EEsProfile && version >= 140) ||
5034 (profile == EEsProfile && version >= 310)) {
5035 stageBuiltins[EShLangCompute].append(
5036 "in highp int gl_DeviceIndex;" // GL_EXT_device_group
5037 "\n");
5038 }
5039
5040 //============================================================================
5041 //
5042 // Define the interface to the mesh/task shader.
5043 //
5044 //============================================================================
5045
5046 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
5047 // per-vertex attributes
5048 stageBuiltins[EShLangMesh].append(
5049 "out gl_MeshPerVertexNV {"
5050 "vec4 gl_Position;"
5051 "float gl_PointSize;"
5052 "float gl_ClipDistance[];"
5053 "float gl_CullDistance[];"
5054 "perviewNV vec4 gl_PositionPerViewNV[];"
5055 "perviewNV float gl_ClipDistancePerViewNV[][];"
5056 "perviewNV float gl_CullDistancePerViewNV[][];"
5057 "} gl_MeshVerticesNV[];"
5058 );
5059
5060 // per-primitive attributes
5061 stageBuiltins[EShLangMesh].append(
5062 "perprimitiveNV out gl_MeshPerPrimitiveNV {"
5063 "int gl_PrimitiveID;"
5064 "int gl_Layer;"
5065 "int gl_ViewportIndex;"
5066 "int gl_ViewportMask[];"
5067 "perviewNV int gl_LayerPerViewNV[];"
5068 "perviewNV int gl_ViewportMaskPerViewNV[][];"
5069 "} gl_MeshPrimitivesNV[];"
5070 );
5071
5072 stageBuiltins[EShLangMesh].append(
5073 "out uint gl_PrimitiveCountNV;"
5074 "out uint gl_PrimitiveIndicesNV[];"
5075
5076 "in uint gl_MeshViewCountNV;"
5077 "in uint gl_MeshViewIndicesNV[4];"
5078
5079 "const highp uvec3 gl_WorkGroupSize = uvec3(1,1,1);"
5080
5081 "in highp uvec3 gl_WorkGroupID;"
5082 "in highp uvec3 gl_LocalInvocationID;"
5083
5084 "in highp uvec3 gl_GlobalInvocationID;"
5085 "in highp uint gl_LocalInvocationIndex;"
5086 "\n");
5087
5088 // GL_EXT_mesh_shader
5089 stageBuiltins[EShLangMesh].append(
5090 "out uint gl_PrimitivePointIndicesEXT[];"
5091 "out uvec2 gl_PrimitiveLineIndicesEXT[];"
5092 "out uvec3 gl_PrimitiveTriangleIndicesEXT[];"
5093 "in highp uvec3 gl_NumWorkGroups;"
5094 "\n");
5095
5096 // per-vertex attributes
5097 stageBuiltins[EShLangMesh].append(
5098 "out gl_MeshPerVertexEXT {"
5099 "vec4 gl_Position;"
5100 "float gl_PointSize;"
5101 "float gl_ClipDistance[];"
5102 "float gl_CullDistance[];"
5103 "} gl_MeshVerticesEXT[];"
5104 );
5105
5106 // per-primitive attributes
5107 stageBuiltins[EShLangMesh].append(
5108 "perprimitiveEXT out gl_MeshPerPrimitiveEXT {"
5109 "int gl_PrimitiveID;"
5110 "int gl_Layer;"
5111 "int gl_ViewportIndex;"
5112 "bool gl_CullPrimitiveEXT;"
5113 "int gl_PrimitiveShadingRateEXT;"
5114 "} gl_MeshPrimitivesEXT[];"
5115 );
5116
5117 stageBuiltins[EShLangTask].append(
5118 "out uint gl_TaskCountNV;"
5119
5120 "const highp uvec3 gl_WorkGroupSize = uvec3(1,1,1);"
5121
5122 "in highp uvec3 gl_WorkGroupID;"
5123 "in highp uvec3 gl_LocalInvocationID;"
5124
5125 "in highp uvec3 gl_GlobalInvocationID;"
5126 "in highp uint gl_LocalInvocationIndex;"
5127
5128 "in uint gl_MeshViewCountNV;"
5129 "in uint gl_MeshViewIndicesNV[4];"
5130 "in highp uvec3 gl_NumWorkGroups;"
5131 "\n");
5132 }
5133
5134 if (profile != EEsProfile && version >= 450) {
5135 stageBuiltins[EShLangMesh].append(
5136 "in highp int gl_DeviceIndex;" // GL_EXT_device_group
5137 "in int gl_DrawIDARB;" // GL_ARB_shader_draw_parameters
5138 "in int gl_ViewIndex;" // GL_EXT_multiview
5139 "\n");
5140
5141 stageBuiltins[EShLangTask].append(
5142 "in highp int gl_DeviceIndex;" // GL_EXT_device_group
5143 "in int gl_DrawIDARB;" // GL_ARB_shader_draw_parameters
5144 "\n");
5145
5146 if (version >= 460) {
5147 stageBuiltins[EShLangMesh].append(
5148 "in int gl_DrawID;"
5149 "\n");
5150
5151 stageBuiltins[EShLangTask].append(
5152 "in int gl_DrawID;"
5153 "\n");
5154 }
5155 }
5156
5157 //============================================================================
5158 //
5159 // Define the interface to the vertex shader.
5160 //
5161 //============================================================================
5162
5163 if (profile != EEsProfile) {
5164 if (version < 130) {
5165 stageBuiltins[EShLangVertex].append(
5166 "attribute vec4 gl_Color;"
5167 "attribute vec4 gl_SecondaryColor;"
5168 "attribute vec3 gl_Normal;"
5169 "attribute vec4 gl_Vertex;"
5170 "attribute vec4 gl_MultiTexCoord0;"
5171 "attribute vec4 gl_MultiTexCoord1;"
5172 "attribute vec4 gl_MultiTexCoord2;"
5173 "attribute vec4 gl_MultiTexCoord3;"
5174 "attribute vec4 gl_MultiTexCoord4;"
5175 "attribute vec4 gl_MultiTexCoord5;"
5176 "attribute vec4 gl_MultiTexCoord6;"
5177 "attribute vec4 gl_MultiTexCoord7;"
5178 "attribute float gl_FogCoord;"
5179 "\n");
5180 } else if (IncludeLegacy(version, profile, spvVersion)) {
5181 stageBuiltins[EShLangVertex].append(
5182 "in vec4 gl_Color;"
5183 "in vec4 gl_SecondaryColor;"
5184 "in vec3 gl_Normal;"
5185 "in vec4 gl_Vertex;"
5186 "in vec4 gl_MultiTexCoord0;"
5187 "in vec4 gl_MultiTexCoord1;"
5188 "in vec4 gl_MultiTexCoord2;"
5189 "in vec4 gl_MultiTexCoord3;"
5190 "in vec4 gl_MultiTexCoord4;"
5191 "in vec4 gl_MultiTexCoord5;"
5192 "in vec4 gl_MultiTexCoord6;"
5193 "in vec4 gl_MultiTexCoord7;"
5194 "in float gl_FogCoord;"
5195 "\n");
5196 }
5197
5198 if (version < 150) {
5199 if (version < 130) {
5200 stageBuiltins[EShLangVertex].append(
5201 " vec4 gl_ClipVertex;" // needs qualifier fixed later
5202 "varying vec4 gl_FrontColor;"
5203 "varying vec4 gl_BackColor;"
5204 "varying vec4 gl_FrontSecondaryColor;"
5205 "varying vec4 gl_BackSecondaryColor;"
5206 "varying vec4 gl_TexCoord[];"
5207 "varying float gl_FogFragCoord;"
5208 "\n");
5209 } else if (IncludeLegacy(version, profile, spvVersion)) {
5210 stageBuiltins[EShLangVertex].append(
5211 " vec4 gl_ClipVertex;" // needs qualifier fixed later
5212 "out vec4 gl_FrontColor;"
5213 "out vec4 gl_BackColor;"
5214 "out vec4 gl_FrontSecondaryColor;"
5215 "out vec4 gl_BackSecondaryColor;"
5216 "out vec4 gl_TexCoord[];"
5217 "out float gl_FogFragCoord;"
5218 "\n");
5219 }
5220 stageBuiltins[EShLangVertex].append(
5221 "vec4 gl_Position;" // needs qualifier fixed later
5222 "float gl_PointSize;" // needs qualifier fixed later
5223 );
5224
5225 if (version == 130 || version == 140)
5226 stageBuiltins[EShLangVertex].append(
5227 "out float gl_ClipDistance[];"
5228 );
5229 } else {
5230 // version >= 150
5231 stageBuiltins[EShLangVertex].append(
5232 "out gl_PerVertex {"
5233 "vec4 gl_Position;" // needs qualifier fixed later
5234 "float gl_PointSize;" // needs qualifier fixed later
5235 "float gl_ClipDistance[];"
5236 );
5237 if (IncludeLegacy(version, profile, spvVersion))
5238 stageBuiltins[EShLangVertex].append(
5239 "vec4 gl_ClipVertex;" // needs qualifier fixed later
5240 "vec4 gl_FrontColor;"
5241 "vec4 gl_BackColor;"
5242 "vec4 gl_FrontSecondaryColor;"
5243 "vec4 gl_BackSecondaryColor;"
5244 "vec4 gl_TexCoord[];"
5245 "float gl_FogFragCoord;"
5246 );
5247 if (version >= 450)
5248 stageBuiltins[EShLangVertex].append(
5249 "float gl_CullDistance[];"
5250 );
5251 stageBuiltins[EShLangVertex].append(
5252 "};"
5253 "\n");
5254 }
5255 if (version >= 130 && spvVersion.vulkan == 0)
5256 stageBuiltins[EShLangVertex].append(
5257 "int gl_VertexID;" // needs qualifier fixed later
5258 );
5259 if (spvVersion.vulkan == 0)
5260 stageBuiltins[EShLangVertex].append(
5261 "int gl_InstanceID;" // needs qualifier fixed later
5262 );
5263 if (spvVersion.vulkan > 0 && version >= 140)
5264 stageBuiltins[EShLangVertex].append(
5265 "in int gl_VertexIndex;"
5266 "in int gl_InstanceIndex;"
5267 );
5268
5269 if (spvVersion.vulkan > 0 && version >= 140 && spvVersion.vulkanRelaxed)
5270 stageBuiltins[EShLangVertex].append(
5271 "in int gl_VertexID;" // declare with 'in' qualifier
5272 "in int gl_InstanceID;"
5273 );
5274
5275 if (version >= 440) {
5276 stageBuiltins[EShLangVertex].append(
5277 "in int gl_BaseVertexARB;"
5278 "in int gl_BaseInstanceARB;"
5279 "in int gl_DrawIDARB;"
5280 );
5281 }
5282 if (version >= 410) {
5283 stageBuiltins[EShLangVertex].append(
5284 "out int gl_ViewportIndex;"
5285 "out int gl_Layer;"
5286 );
5287 }
5288 if (version >= 460) {
5289 stageBuiltins[EShLangVertex].append(
5290 "in int gl_BaseVertex;"
5291 "in int gl_BaseInstance;"
5292 "in int gl_DrawID;"
5293 );
5294 }
5295
5296 if (version >= 430)
5297 stageBuiltins[EShLangVertex].append(
5298 "out int gl_ViewportMask[];" // GL_NV_viewport_array2
5299 );
5300
5301 if (version >= 450)
5302 stageBuiltins[EShLangVertex].append(
5303 "out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering
5304 "out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
5305 "out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
5306 "out int gl_ViewportMaskPerViewNV[];" // GL_NVX_multiview_per_view_attributes
5307 );
5308 } else {
5309 // ES profile
5310 if (version == 100) {
5311 stageBuiltins[EShLangVertex].append(
5312 "highp vec4 gl_Position;" // needs qualifier fixed later
5313 "mediump float gl_PointSize;" // needs qualifier fixed later
5314 "highp int gl_InstanceID;" // needs qualifier fixed later
5315 );
5316 } else {
5317 if (spvVersion.vulkan == 0 || spvVersion.vulkanRelaxed)
5318 stageBuiltins[EShLangVertex].append(
5319 "in highp int gl_VertexID;" // needs qualifier fixed later
5320 "in highp int gl_InstanceID;" // needs qualifier fixed later
5321 );
5322 if (spvVersion.vulkan > 0)
5323 stageBuiltins[EShLangVertex].append(
5324 "in highp int gl_VertexIndex;"
5325 "in highp int gl_InstanceIndex;"
5326 );
5327 if (version < 310)
5328 stageBuiltins[EShLangVertex].append(
5329 "highp vec4 gl_Position;" // needs qualifier fixed later
5330 "highp float gl_PointSize;" // needs qualifier fixed later
5331 );
5332 else
5333 stageBuiltins[EShLangVertex].append(
5334 "out gl_PerVertex {"
5335 "highp vec4 gl_Position;" // needs qualifier fixed later
5336 "highp float gl_PointSize;" // needs qualifier fixed later
5337 "};"
5338 );
5339 }
5340 }
5341
5342 if ((profile != EEsProfile && version >= 140) ||
5343 (profile == EEsProfile && version >= 310)) {
5344 stageBuiltins[EShLangVertex].append(
5345 "in highp int gl_DeviceIndex;" // GL_EXT_device_group
5346 "in highp int gl_ViewIndex;" // GL_EXT_multiview
5347 "\n");
5348 }
5349
5350 if (version >= 300 /* both ES and non-ES */) {
5351 stageBuiltins[EShLangVertex].append(
5352 "in highp uint gl_ViewID_OVR;" // GL_OVR_multiview, GL_OVR_multiview2
5353 "\n");
5354 }
5355
5356 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 310)) {
5357 stageBuiltins[EShLangVertex].append(
5358 "out highp int gl_PrimitiveShadingRateEXT;" // GL_EXT_fragment_shading_rate
5359 "\n");
5360 }
5361
5362 //============================================================================
5363 //
5364 // Define the interface to the geometry shader.
5365 //
5366 //============================================================================
5367
5368 if (profile == ECoreProfile || profile == ECompatibilityProfile) {
5369 stageBuiltins[EShLangGeometry].append(
5370 "in gl_PerVertex {"
5371 "vec4 gl_Position;"
5372 "float gl_PointSize;"
5373 "float gl_ClipDistance[];"
5374 );
5375 if (profile == ECompatibilityProfile)
5376 stageBuiltins[EShLangGeometry].append(
5377 "vec4 gl_ClipVertex;"
5378 "vec4 gl_FrontColor;"
5379 "vec4 gl_BackColor;"
5380 "vec4 gl_FrontSecondaryColor;"
5381 "vec4 gl_BackSecondaryColor;"
5382 "vec4 gl_TexCoord[];"
5383 "float gl_FogFragCoord;"
5384 );
5385 if (version >= 450)
5386 stageBuiltins[EShLangGeometry].append(
5387 "float gl_CullDistance[];"
5388 "vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
5389 "vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
5390 );
5391 stageBuiltins[EShLangGeometry].append(
5392 "} gl_in[];"
5393
5394 "in int gl_PrimitiveIDIn;"
5395 "out gl_PerVertex {"
5396 "vec4 gl_Position;"
5397 "float gl_PointSize;"
5398 "float gl_ClipDistance[];"
5399 "\n");
5400 if (profile == ECompatibilityProfile && version >= 400)
5401 stageBuiltins[EShLangGeometry].append(
5402 "vec4 gl_ClipVertex;"
5403 "vec4 gl_FrontColor;"
5404 "vec4 gl_BackColor;"
5405 "vec4 gl_FrontSecondaryColor;"
5406 "vec4 gl_BackSecondaryColor;"
5407 "vec4 gl_TexCoord[];"
5408 "float gl_FogFragCoord;"
5409 );
5410 if (version >= 450)
5411 stageBuiltins[EShLangGeometry].append(
5412 "float gl_CullDistance[];"
5413 );
5414 stageBuiltins[EShLangGeometry].append(
5415 "};"
5416
5417 "out int gl_PrimitiveID;"
5418 "out int gl_Layer;");
5419
5420 if (version >= 150)
5421 stageBuiltins[EShLangGeometry].append(
5422 "out int gl_ViewportIndex;"
5423 );
5424
5425 if (profile == ECompatibilityProfile && version < 400)
5426 stageBuiltins[EShLangGeometry].append(
5427 "out vec4 gl_ClipVertex;"
5428 );
5429
5430 if (version >= 400)
5431 stageBuiltins[EShLangGeometry].append(
5432 "in int gl_InvocationID;"
5433 );
5434
5435 if (version >= 430)
5436 stageBuiltins[EShLangGeometry].append(
5437 "out int gl_ViewportMask[];" // GL_NV_viewport_array2
5438 );
5439
5440 if (version >= 450)
5441 stageBuiltins[EShLangGeometry].append(
5442 "out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering
5443 "out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
5444 "out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
5445 "out int gl_ViewportMaskPerViewNV[];" // GL_NVX_multiview_per_view_attributes
5446 );
5447
5448 stageBuiltins[EShLangGeometry].append("\n");
5449 } else if (profile == EEsProfile && version >= 310) {
5450 stageBuiltins[EShLangGeometry].append(
5451 "in gl_PerVertex {"
5452 "highp vec4 gl_Position;"
5453 "highp float gl_PointSize;"
5454 "} gl_in[];"
5455 "\n"
5456 "in highp int gl_PrimitiveIDIn;"
5457 "in highp int gl_InvocationID;"
5458 "\n"
5459 "out gl_PerVertex {"
5460 "highp vec4 gl_Position;"
5461 "highp float gl_PointSize;"
5462 "};"
5463 "\n"
5464 "out highp int gl_PrimitiveID;"
5465 "out highp int gl_Layer;"
5466 "\n"
5467 );
5468 }
5469
5470 if ((profile != EEsProfile && version >= 140) ||
5471 (profile == EEsProfile && version >= 310)) {
5472 stageBuiltins[EShLangGeometry].append(
5473 "in highp int gl_DeviceIndex;" // GL_EXT_device_group
5474 "in highp int gl_ViewIndex;" // GL_EXT_multiview
5475 "\n");
5476 }
5477
5478 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 310)) {
5479 stageBuiltins[EShLangGeometry].append(
5480 "out highp int gl_PrimitiveShadingRateEXT;" // GL_EXT_fragment_shading_rate
5481 "\n");
5482 }
5483
5484 //============================================================================
5485 //
5486 // Define the interface to the tessellation control shader.
5487 //
5488 //============================================================================
5489
5490 if (profile != EEsProfile && version >= 150) {
5491 // Note: "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below,
5492 // as it depends on the resource sizing of gl_MaxPatchVertices.
5493
5494 stageBuiltins[EShLangTessControl].append(
5495 "in int gl_PatchVerticesIn;"
5496 "in int gl_PrimitiveID;"
5497 "in int gl_InvocationID;"
5498
5499 "out gl_PerVertex {"
5500 "vec4 gl_Position;"
5501 "float gl_PointSize;"
5502 "float gl_ClipDistance[];"
5503 );
5504 if (profile == ECompatibilityProfile)
5505 stageBuiltins[EShLangTessControl].append(
5506 "vec4 gl_ClipVertex;"
5507 "vec4 gl_FrontColor;"
5508 "vec4 gl_BackColor;"
5509 "vec4 gl_FrontSecondaryColor;"
5510 "vec4 gl_BackSecondaryColor;"
5511 "vec4 gl_TexCoord[];"
5512 "float gl_FogFragCoord;"
5513 );
5514 if (version >= 450)
5515 stageBuiltins[EShLangTessControl].append(
5516 "float gl_CullDistance[];"
5517 );
5518 if (version >= 430)
5519 stageBuiltins[EShLangTessControl].append(
5520 "int gl_ViewportMask[];" // GL_NV_viewport_array2
5521 );
5522 if (version >= 450)
5523 stageBuiltins[EShLangTessControl].append(
5524 "vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
5525 "int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering
5526 "vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
5527 "int gl_ViewportMaskPerViewNV[];" // GL_NVX_multiview_per_view_attributes
5528 );
5529 stageBuiltins[EShLangTessControl].append(
5530 "} gl_out[];"
5531
5532 "patch out float gl_TessLevelOuter[4];"
5533 "patch out float gl_TessLevelInner[2];"
5534 "\n");
5535
5536 if (version >= 410)
5537 stageBuiltins[EShLangTessControl].append(
5538 "out int gl_ViewportIndex;"
5539 "out int gl_Layer;"
5540 "\n");
5541
5542 } else {
5543 // Note: "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below,
5544 // as it depends on the resource sizing of gl_MaxPatchVertices.
5545
5546 stageBuiltins[EShLangTessControl].append(
5547 "in highp int gl_PatchVerticesIn;"
5548 "in highp int gl_PrimitiveID;"
5549 "in highp int gl_InvocationID;"
5550
5551 "out gl_PerVertex {"
5552 "highp vec4 gl_Position;"
5553 "highp float gl_PointSize;"
5554 );
5555 stageBuiltins[EShLangTessControl].append(
5556 "} gl_out[];"
5557
5558 "patch out highp float gl_TessLevelOuter[4];"
5559 "patch out highp float gl_TessLevelInner[2];"
5560 "patch out highp vec4 gl_BoundingBoxOES[2];"
5561 "patch out highp vec4 gl_BoundingBoxEXT[2];"
5562 "\n");
5563 if (profile == EEsProfile && version >= 320) {
5564 stageBuiltins[EShLangTessControl].append(
5565 "patch out highp vec4 gl_BoundingBox[2];"
5566 "\n"
5567 );
5568 }
5569 }
5570
5571 if ((profile != EEsProfile && version >= 140) ||
5572 (profile == EEsProfile && version >= 310)) {
5573 stageBuiltins[EShLangTessControl].append(
5574 "in highp int gl_DeviceIndex;" // GL_EXT_device_group
5575 "in highp int gl_ViewIndex;" // GL_EXT_multiview
5576 "\n");
5577 }
5578
5579 //============================================================================
5580 //
5581 // Define the interface to the tessellation evaluation shader.
5582 //
5583 //============================================================================
5584
5585 if (profile != EEsProfile && version >= 150) {
5586 // Note: "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below,
5587 // as it depends on the resource sizing of gl_MaxPatchVertices.
5588
5589 stageBuiltins[EShLangTessEvaluation].append(
5590 "in int gl_PatchVerticesIn;"
5591 "in int gl_PrimitiveID;"
5592 "in vec3 gl_TessCoord;"
5593
5594 "patch in float gl_TessLevelOuter[4];"
5595 "patch in float gl_TessLevelInner[2];"
5596
5597 "out gl_PerVertex {"
5598 "vec4 gl_Position;"
5599 "float gl_PointSize;"
5600 "float gl_ClipDistance[];"
5601 );
5602 if (version >= 400 && profile == ECompatibilityProfile)
5603 stageBuiltins[EShLangTessEvaluation].append(
5604 "vec4 gl_ClipVertex;"
5605 "vec4 gl_FrontColor;"
5606 "vec4 gl_BackColor;"
5607 "vec4 gl_FrontSecondaryColor;"
5608 "vec4 gl_BackSecondaryColor;"
5609 "vec4 gl_TexCoord[];"
5610 "float gl_FogFragCoord;"
5611 );
5612 if (version >= 450)
5613 stageBuiltins[EShLangTessEvaluation].append(
5614 "float gl_CullDistance[];"
5615 );
5616 stageBuiltins[EShLangTessEvaluation].append(
5617 "};"
5618 "\n");
5619
5620 if (version >= 410)
5621 stageBuiltins[EShLangTessEvaluation].append(
5622 "out int gl_ViewportIndex;"
5623 "out int gl_Layer;"
5624 "\n");
5625
5626 if (version >= 430)
5627 stageBuiltins[EShLangTessEvaluation].append(
5628 "out int gl_ViewportMask[];" // GL_NV_viewport_array2
5629 );
5630
5631 if (version >= 450)
5632 stageBuiltins[EShLangTessEvaluation].append(
5633 "out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
5634 "out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering
5635 "out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
5636 "out int gl_ViewportMaskPerViewNV[];" // GL_NVX_multiview_per_view_attributes
5637 );
5638
5639 } else if (profile == EEsProfile && version >= 310) {
5640 // Note: "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below,
5641 // as it depends on the resource sizing of gl_MaxPatchVertices.
5642
5643 stageBuiltins[EShLangTessEvaluation].append(
5644 "in highp int gl_PatchVerticesIn;"
5645 "in highp int gl_PrimitiveID;"
5646 "in highp vec3 gl_TessCoord;"
5647
5648 "patch in highp float gl_TessLevelOuter[4];"
5649 "patch in highp float gl_TessLevelInner[2];"
5650
5651 "out gl_PerVertex {"
5652 "highp vec4 gl_Position;"
5653 "highp float gl_PointSize;"
5654 );
5655 stageBuiltins[EShLangTessEvaluation].append(
5656 "};"
5657 "\n");
5658 }
5659
5660 if ((profile != EEsProfile && version >= 140) ||
5661 (profile == EEsProfile && version >= 310)) {
5662 stageBuiltins[EShLangTessEvaluation].append(
5663 "in highp int gl_DeviceIndex;" // GL_EXT_device_group
5664 "in highp int gl_ViewIndex;" // GL_EXT_multiview
5665 "\n");
5666 }
5667
5668 //============================================================================
5669 //
5670 // Define the interface to the fragment shader.
5671 //
5672 //============================================================================
5673
5674 if (profile != EEsProfile) {
5675
5676 stageBuiltins[EShLangFragment].append(
5677 "vec4 gl_FragCoord;" // needs qualifier fixed later
5678 "bool gl_FrontFacing;" // needs qualifier fixed later
5679 "float gl_FragDepth;" // needs qualifier fixed later
5680 );
5681 if (version >= 120)
5682 stageBuiltins[EShLangFragment].append(
5683 "vec2 gl_PointCoord;" // needs qualifier fixed later
5684 );
5685 if (version >= 140)
5686 stageBuiltins[EShLangFragment].append(
5687 "out int gl_FragStencilRefARB;"
5688 );
5689 if (IncludeLegacy(version, profile, spvVersion) || (! ForwardCompatibility && version < 420))
5690 stageBuiltins[EShLangFragment].append(
5691 "vec4 gl_FragColor;" // needs qualifier fixed later
5692 );
5693
5694 if (version < 130) {
5695 stageBuiltins[EShLangFragment].append(
5696 "varying vec4 gl_Color;"
5697 "varying vec4 gl_SecondaryColor;"
5698 "varying vec4 gl_TexCoord[];"
5699 "varying float gl_FogFragCoord;"
5700 );
5701 } else {
5702 stageBuiltins[EShLangFragment].append(
5703 "in float gl_ClipDistance[];"
5704 );
5705
5706 if (IncludeLegacy(version, profile, spvVersion)) {
5707 if (version < 150)
5708 stageBuiltins[EShLangFragment].append(
5709 "in float gl_FogFragCoord;"
5710 "in vec4 gl_TexCoord[];"
5711 "in vec4 gl_Color;"
5712 "in vec4 gl_SecondaryColor;"
5713 );
5714 else
5715 stageBuiltins[EShLangFragment].append(
5716 "in gl_PerFragment {"
5717 "in float gl_FogFragCoord;"
5718 "in vec4 gl_TexCoord[];"
5719 "in vec4 gl_Color;"
5720 "in vec4 gl_SecondaryColor;"
5721 "};"
5722 );
5723 }
5724 }
5725
5726 if (version >= 150)
5727 stageBuiltins[EShLangFragment].append(
5728 "flat in int gl_PrimitiveID;"
5729 );
5730
5731 if (version >= 130) { // ARB_sample_shading
5732 stageBuiltins[EShLangFragment].append(
5733 "flat in int gl_SampleID;"
5734 " in vec2 gl_SamplePosition;"
5735 " out int gl_SampleMask[];"
5736 );
5737
5738 if (spvVersion.spv == 0) {
5739 stageBuiltins[EShLangFragment].append(
5740 "uniform int gl_NumSamples;"
5741 );
5742 }
5743 }
5744
5745 if (version >= 400)
5746 stageBuiltins[EShLangFragment].append(
5747 "flat in int gl_SampleMaskIn[];"
5748 );
5749
5750 if (version >= 430)
5751 stageBuiltins[EShLangFragment].append(
5752 "flat in int gl_Layer;"
5753 "flat in int gl_ViewportIndex;"
5754 );
5755
5756 if (version >= 450)
5757 stageBuiltins[EShLangFragment].append(
5758 "in float gl_CullDistance[];"
5759 "bool gl_HelperInvocation;" // needs qualifier fixed later
5760 );
5761
5762 if (version >= 450)
5763 stageBuiltins[EShLangFragment].append( // GL_EXT_fragment_invocation_density
5764 "flat in ivec2 gl_FragSizeEXT;"
5765 "flat in int gl_FragInvocationCountEXT;"
5766 );
5767
5768 if (version >= 450)
5769 stageBuiltins[EShLangFragment].append(
5770 "in vec2 gl_BaryCoordNoPerspAMD;"
5771 "in vec2 gl_BaryCoordNoPerspCentroidAMD;"
5772 "in vec2 gl_BaryCoordNoPerspSampleAMD;"
5773 "in vec2 gl_BaryCoordSmoothAMD;"
5774 "in vec2 gl_BaryCoordSmoothCentroidAMD;"
5775 "in vec2 gl_BaryCoordSmoothSampleAMD;"
5776 "in vec3 gl_BaryCoordPullModelAMD;"
5777 );
5778
5779 if (version >= 430)
5780 stageBuiltins[EShLangFragment].append(
5781 "in bool gl_FragFullyCoveredNV;"
5782 );
5783 if (version >= 450)
5784 stageBuiltins[EShLangFragment].append(
5785 "flat in ivec2 gl_FragmentSizeNV;" // GL_NV_shading_rate_image
5786 "flat in int gl_InvocationsPerPixelNV;"
5787 "in vec3 gl_BaryCoordNV;" // GL_NV_fragment_shader_barycentric
5788 "in vec3 gl_BaryCoordNoPerspNV;"
5789 "in vec3 gl_BaryCoordEXT;" // GL_EXT_fragment_shader_barycentric
5790 "in vec3 gl_BaryCoordNoPerspEXT;"
5791 );
5792
5793 if (version >= 450)
5794 stageBuiltins[EShLangFragment].append(
5795 "flat in int gl_ShadingRateEXT;" // GL_EXT_fragment_shading_rate
5796 );
5797
5798 } else {
5799 // ES profile
5800
5801 if (version == 100) {
5802 stageBuiltins[EShLangFragment].append(
5803 "mediump vec4 gl_FragCoord;" // needs qualifier fixed later
5804 " bool gl_FrontFacing;" // needs qualifier fixed later
5805 "mediump vec4 gl_FragColor;" // needs qualifier fixed later
5806 "mediump vec2 gl_PointCoord;" // needs qualifier fixed later
5807 );
5808 }
5809 if (version >= 300) {
5810 stageBuiltins[EShLangFragment].append(
5811 "highp vec4 gl_FragCoord;" // needs qualifier fixed later
5812 " bool gl_FrontFacing;" // needs qualifier fixed later
5813 "mediump vec2 gl_PointCoord;" // needs qualifier fixed later
5814 "highp float gl_FragDepth;" // needs qualifier fixed later
5815 );
5816 }
5817 if (version >= 310) {
5818 stageBuiltins[EShLangFragment].append(
5819 "bool gl_HelperInvocation;" // needs qualifier fixed later
5820 "flat in highp int gl_PrimitiveID;" // needs qualifier fixed later
5821 "flat in highp int gl_Layer;" // needs qualifier fixed later
5822 );
5823
5824 stageBuiltins[EShLangFragment].append( // GL_OES_sample_variables
5825 "flat in lowp int gl_SampleID;"
5826 " in mediump vec2 gl_SamplePosition;"
5827 "flat in highp int gl_SampleMaskIn[];"
5828 " out highp int gl_SampleMask[];"
5829 );
5830 if (spvVersion.spv == 0)
5831 stageBuiltins[EShLangFragment].append( // GL_OES_sample_variables
5832 "uniform lowp int gl_NumSamples;"
5833 );
5834 }
5835 stageBuiltins[EShLangFragment].append(
5836 "highp float gl_FragDepthEXT;" // GL_EXT_frag_depth
5837 );
5838
5839 if (version >= 310)
5840 stageBuiltins[EShLangFragment].append( // GL_EXT_fragment_invocation_density
5841 "flat in ivec2 gl_FragSizeEXT;"
5842 "flat in int gl_FragInvocationCountEXT;"
5843 );
5844 if (version >= 320)
5845 stageBuiltins[EShLangFragment].append( // GL_NV_shading_rate_image
5846 "flat in ivec2 gl_FragmentSizeNV;"
5847 "flat in int gl_InvocationsPerPixelNV;"
5848 );
5849 if (version >= 320)
5850 stageBuiltins[EShLangFragment].append(
5851 "in vec3 gl_BaryCoordNV;"
5852 "in vec3 gl_BaryCoordNoPerspNV;"
5853 "in vec3 gl_BaryCoordEXT;"
5854 "in vec3 gl_BaryCoordNoPerspEXT;"
5855 );
5856 if (version >= 310)
5857 stageBuiltins[EShLangFragment].append(
5858 "flat in highp int gl_ShadingRateEXT;" // GL_EXT_fragment_shading_rate
5859 );
5860 }
5861
5862 stageBuiltins[EShLangFragment].append("\n");
5863
5864 if (version >= 130)
5865 add2ndGenerationSamplingImaging(version, profile, spvVersion);
5866
5867 if ((profile != EEsProfile && version >= 140) ||
5868 (profile == EEsProfile && version >= 310)) {
5869 stageBuiltins[EShLangFragment].append(
5870 "flat in highp int gl_DeviceIndex;" // GL_EXT_device_group
5871 "flat in highp int gl_ViewIndex;" // GL_EXT_multiview
5872 "\n");
5873 }
5874
5875 if (version >= 300 /* both ES and non-ES */) {
5876 stageBuiltins[EShLangFragment].append(
5877 "flat in highp uint gl_ViewID_OVR;" // GL_OVR_multiview, GL_OVR_multiview2
5878 "\n");
5879 }
5880
5881 // GL_ARB_shader_ballot
5882 if (profile != EEsProfile && version >= 450) {
5883 const char* ballotDecls =
5884 "uniform uint gl_SubGroupSizeARB;"
5885 "in uint gl_SubGroupInvocationARB;"
5886 "in uint64_t gl_SubGroupEqMaskARB;"
5887 "in uint64_t gl_SubGroupGeMaskARB;"
5888 "in uint64_t gl_SubGroupGtMaskARB;"
5889 "in uint64_t gl_SubGroupLeMaskARB;"
5890 "in uint64_t gl_SubGroupLtMaskARB;"
5891 "\n";
5892 const char* rtBallotDecls =
5893 "uniform volatile uint gl_SubGroupSizeARB;"
5894 "in volatile uint gl_SubGroupInvocationARB;"
5895 "in volatile uint64_t gl_SubGroupEqMaskARB;"
5896 "in volatile uint64_t gl_SubGroupGeMaskARB;"
5897 "in volatile uint64_t gl_SubGroupGtMaskARB;"
5898 "in volatile uint64_t gl_SubGroupLeMaskARB;"
5899 "in volatile uint64_t gl_SubGroupLtMaskARB;"
5900 "\n";
5901 const char* fragmentBallotDecls =
5902 "uniform uint gl_SubGroupSizeARB;"
5903 "flat in uint gl_SubGroupInvocationARB;"
5904 "flat in uint64_t gl_SubGroupEqMaskARB;"
5905 "flat in uint64_t gl_SubGroupGeMaskARB;"
5906 "flat in uint64_t gl_SubGroupGtMaskARB;"
5907 "flat in uint64_t gl_SubGroupLeMaskARB;"
5908 "flat in uint64_t gl_SubGroupLtMaskARB;"
5909 "\n";
5910 stageBuiltins[EShLangVertex] .append(ballotDecls);
5911 stageBuiltins[EShLangTessControl] .append(ballotDecls);
5912 stageBuiltins[EShLangTessEvaluation].append(ballotDecls);
5913 stageBuiltins[EShLangGeometry] .append(ballotDecls);
5914 stageBuiltins[EShLangCompute] .append(ballotDecls);
5915 stageBuiltins[EShLangFragment] .append(fragmentBallotDecls);
5916 stageBuiltins[EShLangMesh] .append(ballotDecls);
5917 stageBuiltins[EShLangTask] .append(ballotDecls);
5918 stageBuiltins[EShLangRayGen] .append(rtBallotDecls);
5919 stageBuiltins[EShLangIntersect] .append(rtBallotDecls);
5920 // No volatile qualifier on these builtins in any-hit
5921 stageBuiltins[EShLangAnyHit] .append(ballotDecls);
5922 stageBuiltins[EShLangClosestHit] .append(rtBallotDecls);
5923 stageBuiltins[EShLangMiss] .append(rtBallotDecls);
5924 stageBuiltins[EShLangCallable] .append(rtBallotDecls);
5925 }
5926
5927 // GL_KHR_shader_subgroup
5928 if ((profile == EEsProfile && version >= 310) ||
5929 (profile != EEsProfile && version >= 140)) {
5930 const char* subgroupDecls =
5931 "in mediump uint gl_SubgroupSize;"
5932 "in mediump uint gl_SubgroupInvocationID;"
5933 "in highp uvec4 gl_SubgroupEqMask;"
5934 "in highp uvec4 gl_SubgroupGeMask;"
5935 "in highp uvec4 gl_SubgroupGtMask;"
5936 "in highp uvec4 gl_SubgroupLeMask;"
5937 "in highp uvec4 gl_SubgroupLtMask;"
5938 // GL_NV_shader_sm_builtins
5939 "in highp uint gl_WarpsPerSMNV;"
5940 "in highp uint gl_SMCountNV;"
5941 "in highp uint gl_WarpIDNV;"
5942 "in highp uint gl_SMIDNV;"
5943 // GL_ARM_shader_core_builtins
5944 "in highp uint gl_CoreIDARM;"
5945 "in highp uint gl_CoreCountARM;"
5946 "in highp uint gl_CoreMaxIDARM;"
5947 "in highp uint gl_WarpIDARM;"
5948 "in highp uint gl_WarpMaxIDARM;"
5949 "\n";
5950 const char* fragmentSubgroupDecls =
5951 "flat in mediump uint gl_SubgroupSize;"
5952 "flat in mediump uint gl_SubgroupInvocationID;"
5953 "flat in highp uvec4 gl_SubgroupEqMask;"
5954 "flat in highp uvec4 gl_SubgroupGeMask;"
5955 "flat in highp uvec4 gl_SubgroupGtMask;"
5956 "flat in highp uvec4 gl_SubgroupLeMask;"
5957 "flat in highp uvec4 gl_SubgroupLtMask;"
5958 // GL_NV_shader_sm_builtins
5959 "flat in highp uint gl_WarpsPerSMNV;"
5960 "flat in highp uint gl_SMCountNV;"
5961 "flat in highp uint gl_WarpIDNV;"
5962 "flat in highp uint gl_SMIDNV;"
5963 // GL_ARM_shader_core_builtins
5964 "flat in highp uint gl_CoreIDARM;"
5965 "flat in highp uint gl_CoreCountARM;"
5966 "flat in highp uint gl_CoreMaxIDARM;"
5967 "flat in highp uint gl_WarpIDARM;"
5968 "flat in highp uint gl_WarpMaxIDARM;"
5969 "\n";
5970 const char* computeSubgroupDecls =
5971 "in highp uint gl_NumSubgroups;"
5972 "in highp uint gl_SubgroupID;"
5973 "\n";
5974 // These builtins are volatile for RT stages
5975 const char* rtSubgroupDecls =
5976 "in mediump volatile uint gl_SubgroupSize;"
5977 "in mediump volatile uint gl_SubgroupInvocationID;"
5978 "in highp volatile uvec4 gl_SubgroupEqMask;"
5979 "in highp volatile uvec4 gl_SubgroupGeMask;"
5980 "in highp volatile uvec4 gl_SubgroupGtMask;"
5981 "in highp volatile uvec4 gl_SubgroupLeMask;"
5982 "in highp volatile uvec4 gl_SubgroupLtMask;"
5983 // GL_NV_shader_sm_builtins
5984 "in highp uint gl_WarpsPerSMNV;"
5985 "in highp uint gl_SMCountNV;"
5986 "in highp volatile uint gl_WarpIDNV;"
5987 "in highp volatile uint gl_SMIDNV;"
5988 // GL_ARM_shader_core_builtins
5989 "in highp uint gl_CoreIDARM;"
5990 "in highp uint gl_CoreCountARM;"
5991 "in highp uint gl_CoreMaxIDARM;"
5992 "in highp uint gl_WarpIDARM;"
5993 "in highp uint gl_WarpMaxIDARM;"
5994 "\n";
5995
5996 stageBuiltins[EShLangVertex] .append(subgroupDecls);
5997 stageBuiltins[EShLangTessControl] .append(subgroupDecls);
5998 stageBuiltins[EShLangTessEvaluation].append(subgroupDecls);
5999 stageBuiltins[EShLangGeometry] .append(subgroupDecls);
6000 stageBuiltins[EShLangCompute] .append(subgroupDecls);
6001 stageBuiltins[EShLangCompute] .append(computeSubgroupDecls);
6002 stageBuiltins[EShLangFragment] .append(fragmentSubgroupDecls);
6003 stageBuiltins[EShLangMesh] .append(subgroupDecls);
6004 stageBuiltins[EShLangMesh] .append(computeSubgroupDecls);
6005 stageBuiltins[EShLangTask] .append(subgroupDecls);
6006 stageBuiltins[EShLangTask] .append(computeSubgroupDecls);
6007 stageBuiltins[EShLangRayGen] .append(rtSubgroupDecls);
6008 stageBuiltins[EShLangIntersect] .append(rtSubgroupDecls);
6009 // No volatile qualifier on these builtins in any-hit
6010 stageBuiltins[EShLangAnyHit] .append(subgroupDecls);
6011 stageBuiltins[EShLangClosestHit] .append(rtSubgroupDecls);
6012 stageBuiltins[EShLangMiss] .append(rtSubgroupDecls);
6013 stageBuiltins[EShLangCallable] .append(rtSubgroupDecls);
6014 }
6015
6016 // GL_NV_ray_tracing/GL_EXT_ray_tracing
6017 if (profile != EEsProfile && version >= 460) {
6018
6019 const char *constRayFlags =
6020 "const uint gl_RayFlagsNoneNV = 0U;"
6021 "const uint gl_RayFlagsNoneEXT = 0U;"
6022 "const uint gl_RayFlagsOpaqueNV = 1U;"
6023 "const uint gl_RayFlagsOpaqueEXT = 1U;"
6024 "const uint gl_RayFlagsNoOpaqueNV = 2U;"
6025 "const uint gl_RayFlagsNoOpaqueEXT = 2U;"
6026 "const uint gl_RayFlagsTerminateOnFirstHitNV = 4U;"
6027 "const uint gl_RayFlagsTerminateOnFirstHitEXT = 4U;"
6028 "const uint gl_RayFlagsSkipClosestHitShaderNV = 8U;"
6029 "const uint gl_RayFlagsSkipClosestHitShaderEXT = 8U;"
6030 "const uint gl_RayFlagsCullBackFacingTrianglesNV = 16U;"
6031 "const uint gl_RayFlagsCullBackFacingTrianglesEXT = 16U;"
6032 "const uint gl_RayFlagsCullFrontFacingTrianglesNV = 32U;"
6033 "const uint gl_RayFlagsCullFrontFacingTrianglesEXT = 32U;"
6034 "const uint gl_RayFlagsCullOpaqueNV = 64U;"
6035 "const uint gl_RayFlagsCullOpaqueEXT = 64U;"
6036 "const uint gl_RayFlagsCullNoOpaqueNV = 128U;"
6037 "const uint gl_RayFlagsCullNoOpaqueEXT = 128U;"
6038 "const uint gl_RayFlagsSkipTrianglesEXT = 256U;"
6039 "const uint gl_RayFlagsSkipAABBEXT = 512U;"
6040 "const uint gl_RayFlagsForceOpacityMicromap2StateEXT = 1024U;"
6041 "const uint gl_HitKindFrontFacingTriangleEXT = 254U;"
6042 "const uint gl_HitKindBackFacingTriangleEXT = 255U;"
6043 "in uint gl_HitKindFrontFacingMicroTriangleNV;"
6044 "in uint gl_HitKindBackFacingMicroTriangleNV;"
6045 "\n";
6046
6047 const char *constRayQueryIntersection =
6048 "const uint gl_RayQueryCandidateIntersectionEXT = 0U;"
6049 "const uint gl_RayQueryCommittedIntersectionEXT = 1U;"
6050 "const uint gl_RayQueryCommittedIntersectionNoneEXT = 0U;"
6051 "const uint gl_RayQueryCommittedIntersectionTriangleEXT = 1U;"
6052 "const uint gl_RayQueryCommittedIntersectionGeneratedEXT = 2U;"
6053 "const uint gl_RayQueryCandidateIntersectionTriangleEXT = 0U;"
6054 "const uint gl_RayQueryCandidateIntersectionAABBEXT = 1U;"
6055 "\n";
6056
6057 const char *rayGenDecls =
6058 "in uvec3 gl_LaunchIDNV;"
6059 "in uvec3 gl_LaunchIDEXT;"
6060 "in uvec3 gl_LaunchSizeNV;"
6061 "in uvec3 gl_LaunchSizeEXT;"
6062 "\n";
6063 const char *intersectDecls =
6064 "in uvec3 gl_LaunchIDNV;"
6065 "in uvec3 gl_LaunchIDEXT;"
6066 "in uvec3 gl_LaunchSizeNV;"
6067 "in uvec3 gl_LaunchSizeEXT;"
6068 "in int gl_PrimitiveID;"
6069 "in int gl_InstanceID;"
6070 "in int gl_InstanceCustomIndexNV;"
6071 "in int gl_InstanceCustomIndexEXT;"
6072 "in int gl_GeometryIndexEXT;"
6073 "in vec3 gl_WorldRayOriginNV;"
6074 "in vec3 gl_WorldRayOriginEXT;"
6075 "in vec3 gl_WorldRayDirectionNV;"
6076 "in vec3 gl_WorldRayDirectionEXT;"
6077 "in vec3 gl_ObjectRayOriginNV;"
6078 "in vec3 gl_ObjectRayOriginEXT;"
6079 "in vec3 gl_ObjectRayDirectionNV;"
6080 "in vec3 gl_ObjectRayDirectionEXT;"
6081 "in float gl_RayTminNV;"
6082 "in float gl_RayTminEXT;"
6083 "in float gl_RayTmaxNV;"
6084 "in volatile float gl_RayTmaxEXT;"
6085 "in mat4x3 gl_ObjectToWorldNV;"
6086 "in mat4x3 gl_ObjectToWorldEXT;"
6087 "in mat3x4 gl_ObjectToWorld3x4EXT;"
6088 "in mat4x3 gl_WorldToObjectNV;"
6089 "in mat4x3 gl_WorldToObjectEXT;"
6090 "in mat3x4 gl_WorldToObject3x4EXT;"
6091 "in uint gl_IncomingRayFlagsNV;"
6092 "in uint gl_IncomingRayFlagsEXT;"
6093 "in float gl_CurrentRayTimeNV;"
6094 "in uint gl_CullMaskEXT;"
6095 "\n";
6096 const char *hitDecls =
6097 "in uvec3 gl_LaunchIDNV;"
6098 "in uvec3 gl_LaunchIDEXT;"
6099 "in uvec3 gl_LaunchSizeNV;"
6100 "in uvec3 gl_LaunchSizeEXT;"
6101 "in int gl_PrimitiveID;"
6102 "in int gl_InstanceID;"
6103 "in int gl_InstanceCustomIndexNV;"
6104 "in int gl_InstanceCustomIndexEXT;"
6105 "in int gl_GeometryIndexEXT;"
6106 "in vec3 gl_WorldRayOriginNV;"
6107 "in vec3 gl_WorldRayOriginEXT;"
6108 "in vec3 gl_WorldRayDirectionNV;"
6109 "in vec3 gl_WorldRayDirectionEXT;"
6110 "in vec3 gl_ObjectRayOriginNV;"
6111 "in vec3 gl_ObjectRayOriginEXT;"
6112 "in vec3 gl_ObjectRayDirectionNV;"
6113 "in vec3 gl_ObjectRayDirectionEXT;"
6114 "in float gl_RayTminNV;"
6115 "in float gl_RayTminEXT;"
6116 "in float gl_RayTmaxNV;"
6117 "in float gl_RayTmaxEXT;"
6118 "in float gl_HitTNV;"
6119 "in float gl_HitTEXT;"
6120 "in uint gl_HitKindNV;"
6121 "in uint gl_HitKindEXT;"
6122 "in mat4x3 gl_ObjectToWorldNV;"
6123 "in mat4x3 gl_ObjectToWorldEXT;"
6124 "in mat3x4 gl_ObjectToWorld3x4EXT;"
6125 "in mat4x3 gl_WorldToObjectNV;"
6126 "in mat4x3 gl_WorldToObjectEXT;"
6127 "in mat3x4 gl_WorldToObject3x4EXT;"
6128 "in uint gl_IncomingRayFlagsNV;"
6129 "in uint gl_IncomingRayFlagsEXT;"
6130 "in float gl_CurrentRayTimeNV;"
6131 "in uint gl_CullMaskEXT;"
6132 "in vec3 gl_HitTriangleVertexPositionsEXT[3];"
6133 "in vec3 gl_HitMicroTriangleVertexPositionsNV[3];"
6134 "in vec2 gl_HitMicroTriangleVertexBarycentricsNV[3];"
6135 "\n";
6136
6137 const char *missDecls =
6138 "in uvec3 gl_LaunchIDNV;"
6139 "in uvec3 gl_LaunchIDEXT;"
6140 "in uvec3 gl_LaunchSizeNV;"
6141 "in uvec3 gl_LaunchSizeEXT;"
6142 "in vec3 gl_WorldRayOriginNV;"
6143 "in vec3 gl_WorldRayOriginEXT;"
6144 "in vec3 gl_WorldRayDirectionNV;"
6145 "in vec3 gl_WorldRayDirectionEXT;"
6146 "in vec3 gl_ObjectRayOriginNV;"
6147 "in vec3 gl_ObjectRayDirectionNV;"
6148 "in float gl_RayTminNV;"
6149 "in float gl_RayTminEXT;"
6150 "in float gl_RayTmaxNV;"
6151 "in float gl_RayTmaxEXT;"
6152 "in uint gl_IncomingRayFlagsNV;"
6153 "in uint gl_IncomingRayFlagsEXT;"
6154 "in float gl_CurrentRayTimeNV;"
6155 "in uint gl_CullMaskEXT;"
6156 "\n";
6157
6158 const char *callableDecls =
6159 "in uvec3 gl_LaunchIDNV;"
6160 "in uvec3 gl_LaunchIDEXT;"
6161 "in uvec3 gl_LaunchSizeNV;"
6162 "in uvec3 gl_LaunchSizeEXT;"
6163 "\n";
6164
6165
6166 commonBuiltins.append(constRayQueryIntersection);
6167 commonBuiltins.append(constRayFlags);
6168
6169 stageBuiltins[EShLangRayGen].append(rayGenDecls);
6170 stageBuiltins[EShLangIntersect].append(intersectDecls);
6171 stageBuiltins[EShLangAnyHit].append(hitDecls);
6172 stageBuiltins[EShLangClosestHit].append(hitDecls);
6173 stageBuiltins[EShLangMiss].append(missDecls);
6174 stageBuiltins[EShLangCallable].append(callableDecls);
6175
6176 }
6177
6178 if ((profile != EEsProfile && version >= 140)) {
6179 const char *deviceIndex =
6180 "in highp int gl_DeviceIndex;" // GL_EXT_device_group
6181 "\n";
6182
6183 stageBuiltins[EShLangRayGen].append(deviceIndex);
6184 stageBuiltins[EShLangIntersect].append(deviceIndex);
6185 stageBuiltins[EShLangAnyHit].append(deviceIndex);
6186 stageBuiltins[EShLangClosestHit].append(deviceIndex);
6187 stageBuiltins[EShLangMiss].append(deviceIndex);
6188 }
6189
6190 if ((profile != EEsProfile && version >= 420) ||
6191 (profile == EEsProfile && version >= 310)) {
6192 commonBuiltins.append("const int gl_ScopeDevice = 1;\n");
6193 commonBuiltins.append("const int gl_ScopeWorkgroup = 2;\n");
6194 commonBuiltins.append("const int gl_ScopeSubgroup = 3;\n");
6195 commonBuiltins.append("const int gl_ScopeInvocation = 4;\n");
6196 commonBuiltins.append("const int gl_ScopeQueueFamily = 5;\n");
6197 commonBuiltins.append("const int gl_ScopeShaderCallEXT = 6;\n");
6198
6199 commonBuiltins.append("const int gl_SemanticsRelaxed = 0x0;\n");
6200 commonBuiltins.append("const int gl_SemanticsAcquire = 0x2;\n");
6201 commonBuiltins.append("const int gl_SemanticsRelease = 0x4;\n");
6202 commonBuiltins.append("const int gl_SemanticsAcquireRelease = 0x8;\n");
6203 commonBuiltins.append("const int gl_SemanticsMakeAvailable = 0x2000;\n");
6204 commonBuiltins.append("const int gl_SemanticsMakeVisible = 0x4000;\n");
6205 commonBuiltins.append("const int gl_SemanticsVolatile = 0x8000;\n");
6206
6207 commonBuiltins.append("const int gl_StorageSemanticsNone = 0x0;\n");
6208 commonBuiltins.append("const int gl_StorageSemanticsBuffer = 0x40;\n");
6209 commonBuiltins.append("const int gl_StorageSemanticsShared = 0x100;\n");
6210 commonBuiltins.append("const int gl_StorageSemanticsImage = 0x800;\n");
6211 commonBuiltins.append("const int gl_StorageSemanticsOutput = 0x1000;\n");
6212 }
6213
6214 // Adding these to common built-ins triggers an assert due to a memory corruption in related code when testing
6215 // So instead add to each stage individually, avoiding the GLSLang bug
6216 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 310)) {
6217 for (int stage=EShLangVertex; stage<EShLangCount; stage++)
6218 {
6219 stageBuiltins[static_cast<EShLanguage>(stage)].append("const highp int gl_ShadingRateFlag2VerticalPixelsEXT = 1;\n");
6220 stageBuiltins[static_cast<EShLanguage>(stage)].append("const highp int gl_ShadingRateFlag4VerticalPixelsEXT = 2;\n");
6221 stageBuiltins[static_cast<EShLanguage>(stage)].append("const highp int gl_ShadingRateFlag2HorizontalPixelsEXT = 4;\n");
6222 stageBuiltins[static_cast<EShLanguage>(stage)].append("const highp int gl_ShadingRateFlag4HorizontalPixelsEXT = 8;\n");
6223 }
6224 }
6225
6226 // GL_EXT_shader_image_int64
6227 if ((profile != EEsProfile && version >= 420) ||
6228 (profile == EEsProfile && version >= 310)) {
6229
6230 const TBasicType bTypes[] = { EbtInt64, EbtUint64 };
6231 for (int ms = 0; ms <= 1; ++ms) { // loop over "bool" multisample or not
6232 for (int arrayed = 0; arrayed <= 1; ++arrayed) { // loop over "bool" arrayed or not
6233 for (int dim = Esd1D; dim < EsdSubpass; ++dim) { // 1D, ..., buffer
6234 if ((dim == Esd1D || dim == EsdRect) && profile == EEsProfile)
6235 continue;
6236
6237 if ((dim == Esd3D || dim == EsdRect || dim == EsdBuffer) && arrayed)
6238 continue;
6239
6240 if (dim != Esd2D && ms)
6241 continue;
6242
6243 // Loop over the bTypes
6244 for (size_t bType = 0; bType < sizeof(bTypes)/sizeof(TBasicType); ++bType) {
6245 //
6246 // Now, make all the function prototypes for the type we just built...
6247 //
6248 TSampler sampler;
6249
6250 sampler.setImage(bTypes[bType], (TSamplerDim)dim, arrayed ? true : false,
6251 false,
6252 ms ? true : false);
6253
6254 TString typeName = sampler.getString();
6255
6256 addQueryFunctions(sampler, typeName, version, profile);
6257 addImageFunctions(sampler, typeName, version, profile);
6258 }
6259 }
6260 }
6261 }
6262 }
6263
6264 // printf("%s\n", commonBuiltins.c_str());
6265 // printf("%s\n", stageBuiltins[EShLangFragment].c_str());
6266 }
6267
6268 //
6269 // Helper function for initialize(), to add the second set of names for texturing,
6270 // when adding context-independent built-in functions.
6271 //
add2ndGenerationSamplingImaging(int version,EProfile profile,const SpvVersion & spvVersion)6272 void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile, const SpvVersion& spvVersion)
6273 {
6274 //
6275 // In this function proper, enumerate the types, then calls the next set of functions
6276 // to enumerate all the uses for that type.
6277 //
6278
6279 // enumerate all the types
6280 const TBasicType bTypes[] = { EbtFloat, EbtInt, EbtUint,
6281 EbtFloat16
6282 };
6283 bool skipBuffer = (profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 140);
6284 bool skipCubeArrayed = (profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 130);
6285 for (int image = 0; image <= 1; ++image) // loop over "bool" image vs sampler
6286 {
6287 for (int shadow = 0; shadow <= 1; ++shadow) { // loop over "bool" shadow or not
6288 for (int ms = 0; ms <= 1; ++ms) // loop over "bool" multisample or not
6289 {
6290 if ((ms || image) && shadow)
6291 continue;
6292 if (ms && profile != EEsProfile && version < 150)
6293 continue;
6294 if (ms && image && profile == EEsProfile)
6295 continue;
6296 if (ms && profile == EEsProfile && version < 310)
6297 continue;
6298
6299 for (int arrayed = 0; arrayed <= 1; ++arrayed) { // loop over "bool" arrayed or not
6300 for (int dim = Esd1D; dim < EsdNumDims; ++dim) { // 1D, ..., buffer, subpass
6301 if (dim == EsdAttachmentEXT)
6302 continue;
6303 if (dim == EsdSubpass && spvVersion.vulkan == 0)
6304 continue;
6305 if (dim == EsdSubpass && (image || shadow || arrayed))
6306 continue;
6307 if ((dim == Esd1D || dim == EsdRect) && profile == EEsProfile)
6308 continue;
6309 if (dim == EsdSubpass && spvVersion.vulkan == 0)
6310 continue;
6311 if (dim == EsdSubpass && (image || shadow || arrayed))
6312 continue;
6313 if ((dim == Esd1D || dim == EsdRect) && profile == EEsProfile)
6314 continue;
6315 if (dim != Esd2D && dim != EsdSubpass && ms)
6316 continue;
6317 if (dim == EsdBuffer && skipBuffer)
6318 continue;
6319 if (dim == EsdBuffer && (shadow || arrayed || ms))
6320 continue;
6321 if (ms && arrayed && profile == EEsProfile && version < 310)
6322 continue;
6323 if (dim == Esd3D && shadow)
6324 continue;
6325 if (dim == EsdCube && arrayed && skipCubeArrayed)
6326 continue;
6327 if ((dim == Esd3D || dim == EsdRect) && arrayed)
6328 continue;
6329
6330 // Loop over the bTypes
6331 for (size_t bType = 0; bType < sizeof(bTypes)/sizeof(TBasicType); ++bType) {
6332 if (bTypes[bType] == EbtFloat16 && (profile == EEsProfile || version < 450))
6333 continue;
6334 if (dim == EsdRect && version < 140 && bType > 0)
6335 continue;
6336 if (shadow && (bTypes[bType] == EbtInt || bTypes[bType] == EbtUint))
6337 continue;
6338 //
6339 // Now, make all the function prototypes for the type we just built...
6340 //
6341 TSampler sampler;
6342 if (dim == EsdSubpass) {
6343 sampler.setSubpass(bTypes[bType], ms ? true : false);
6344 } else if (dim == EsdAttachmentEXT) {
6345 sampler.setAttachmentEXT(bTypes[bType]);
6346 } else
6347 if (image) {
6348 sampler.setImage(bTypes[bType], (TSamplerDim)dim, arrayed ? true : false,
6349 shadow ? true : false,
6350 ms ? true : false);
6351 } else {
6352 sampler.set(bTypes[bType], (TSamplerDim)dim, arrayed ? true : false,
6353 shadow ? true : false,
6354 ms ? true : false);
6355 }
6356
6357 TString typeName = sampler.getString();
6358
6359 if (dim == EsdSubpass) {
6360 addSubpassSampling(sampler, typeName, version, profile);
6361 continue;
6362 }
6363
6364 addQueryFunctions(sampler, typeName, version, profile);
6365
6366 if (image)
6367 addImageFunctions(sampler, typeName, version, profile);
6368 else {
6369 addSamplingFunctions(sampler, typeName, version, profile);
6370 addGatherFunctions(sampler, typeName, version, profile);
6371 if (spvVersion.vulkan > 0 && sampler.isCombined() && !sampler.shadow) {
6372 // Base Vulkan allows texelFetch() for
6373 // textureBuffer (i.e. without sampler).
6374 //
6375 // GL_EXT_samplerless_texture_functions
6376 // allows texelFetch() and query functions
6377 // (other than textureQueryLod()) for all
6378 // texture types.
6379 sampler.setTexture(sampler.type, sampler.dim, sampler.arrayed, sampler.shadow,
6380 sampler.ms);
6381 TString textureTypeName = sampler.getString();
6382 addSamplingFunctions(sampler, textureTypeName, version, profile);
6383 addQueryFunctions(sampler, textureTypeName, version, profile);
6384 }
6385 }
6386 }
6387 }
6388 }
6389 }
6390 }
6391 }
6392
6393 //
6394 // sparseTexelsResidentARB()
6395 //
6396 if (profile != EEsProfile && version >= 450) {
6397 commonBuiltins.append("bool sparseTexelsResidentARB(int code);\n");
6398 }
6399 }
6400
6401 //
6402 // Helper function for add2ndGenerationSamplingImaging(),
6403 // when adding context-independent built-in functions.
6404 //
6405 // Add all the query functions for the given type.
6406 //
addQueryFunctions(TSampler sampler,const TString & typeName,int version,EProfile profile)6407 void TBuiltIns::addQueryFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile)
6408 {
6409 //
6410 // textureSize() and imageSize()
6411 //
6412
6413 int sizeDims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0) - (sampler.dim == EsdCube ? 1 : 0);
6414
6415 if (sampler.isImage() && ((profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 420)))
6416 return;
6417
6418 if (profile == EEsProfile)
6419 commonBuiltins.append("highp ");
6420 if (sizeDims == 1)
6421 commonBuiltins.append("int");
6422 else {
6423 commonBuiltins.append("ivec");
6424 commonBuiltins.append(postfixes[sizeDims]);
6425 }
6426 if (sampler.isImage())
6427 commonBuiltins.append(" imageSize(readonly writeonly volatile coherent ");
6428 else
6429 commonBuiltins.append(" textureSize(");
6430 commonBuiltins.append(typeName);
6431 if (! sampler.isImage() && ! sampler.isRect() && ! sampler.isBuffer() && ! sampler.isMultiSample())
6432 commonBuiltins.append(",int);\n");
6433 else
6434 commonBuiltins.append(");\n");
6435
6436 //
6437 // textureSamples() and imageSamples()
6438 //
6439
6440 // GL_ARB_shader_texture_image_samples
6441 // TODO: spec issue? there are no memory qualifiers; how to query a writeonly/readonly image, etc?
6442 if (profile != EEsProfile && version >= 430 && sampler.isMultiSample()) {
6443 commonBuiltins.append("int ");
6444 if (sampler.isImage())
6445 commonBuiltins.append("imageSamples(readonly writeonly volatile coherent ");
6446 else
6447 commonBuiltins.append("textureSamples(");
6448 commonBuiltins.append(typeName);
6449 commonBuiltins.append(");\n");
6450 }
6451
6452 //
6453 // textureQueryLod(), fragment stage only
6454 // Also enabled with extension GL_ARB_texture_query_lod
6455 // Extension GL_ARB_texture_query_lod says that textureQueryLOD() also exist at extension.
6456
6457 if (profile != EEsProfile && version >= 150 && sampler.isCombined() && sampler.dim != EsdRect &&
6458 ! sampler.isMultiSample() && ! sampler.isBuffer()) {
6459
6460 const TString funcName[2] = {"vec2 textureQueryLod(", "vec2 textureQueryLOD("};
6461
6462 for (int i = 0; i < 2; ++i){
6463 for (int f16TexAddr = 0; f16TexAddr < 2; ++f16TexAddr) {
6464 if (f16TexAddr && sampler.type != EbtFloat16)
6465 continue;
6466 stageBuiltins[EShLangFragment].append(funcName[i]);
6467 stageBuiltins[EShLangFragment].append(typeName);
6468 if (dimMap[sampler.dim] == 1)
6469 if (f16TexAddr)
6470 stageBuiltins[EShLangFragment].append(", float16_t");
6471 else
6472 stageBuiltins[EShLangFragment].append(", float");
6473 else {
6474 if (f16TexAddr)
6475 stageBuiltins[EShLangFragment].append(", f16vec");
6476 else
6477 stageBuiltins[EShLangFragment].append(", vec");
6478 stageBuiltins[EShLangFragment].append(postfixes[dimMap[sampler.dim]]);
6479 }
6480 stageBuiltins[EShLangFragment].append(");\n");
6481 }
6482
6483 stageBuiltins[EShLangCompute].append(funcName[i]);
6484 stageBuiltins[EShLangCompute].append(typeName);
6485 if (dimMap[sampler.dim] == 1)
6486 stageBuiltins[EShLangCompute].append(", float");
6487 else {
6488 stageBuiltins[EShLangCompute].append(", vec");
6489 stageBuiltins[EShLangCompute].append(postfixes[dimMap[sampler.dim]]);
6490 }
6491 stageBuiltins[EShLangCompute].append(");\n");
6492 }
6493 }
6494
6495 //
6496 // textureQueryLevels()
6497 //
6498
6499 if (profile != EEsProfile && version >= 430 && ! sampler.isImage() && sampler.dim != EsdRect &&
6500 ! sampler.isMultiSample() && ! sampler.isBuffer()) {
6501 commonBuiltins.append("int textureQueryLevels(");
6502 commonBuiltins.append(typeName);
6503 commonBuiltins.append(");\n");
6504 }
6505 }
6506
6507 //
6508 // Helper function for add2ndGenerationSamplingImaging(),
6509 // when adding context-independent built-in functions.
6510 //
6511 // Add all the image access functions for the given type.
6512 //
addImageFunctions(TSampler sampler,const TString & typeName,int version,EProfile profile)6513 void TBuiltIns::addImageFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile)
6514 {
6515 int dims = dimMap[sampler.dim];
6516 // most things with an array add a dimension, except for cubemaps
6517 if (sampler.arrayed && sampler.dim != EsdCube)
6518 ++dims;
6519
6520 TString imageParams = typeName;
6521 if (dims == 1)
6522 imageParams.append(", int");
6523 else {
6524 imageParams.append(", ivec");
6525 imageParams.append(postfixes[dims]);
6526 }
6527 if (sampler.isMultiSample())
6528 imageParams.append(", int");
6529
6530 if (profile == EEsProfile)
6531 commonBuiltins.append("highp ");
6532 commonBuiltins.append(prefixes[sampler.type]);
6533 commonBuiltins.append("vec4 imageLoad(readonly volatile coherent ");
6534 commonBuiltins.append(imageParams);
6535 commonBuiltins.append(");\n");
6536
6537 commonBuiltins.append("void imageStore(writeonly volatile coherent ");
6538 commonBuiltins.append(imageParams);
6539 commonBuiltins.append(", ");
6540 commonBuiltins.append(prefixes[sampler.type]);
6541 commonBuiltins.append("vec4);\n");
6542
6543 if (! sampler.is1D() && ! sampler.isBuffer() && profile != EEsProfile && version >= 450) {
6544 commonBuiltins.append("int sparseImageLoadARB(readonly volatile coherent ");
6545 commonBuiltins.append(imageParams);
6546 commonBuiltins.append(", out ");
6547 commonBuiltins.append(prefixes[sampler.type]);
6548 commonBuiltins.append("vec4");
6549 commonBuiltins.append(");\n");
6550 }
6551
6552 if ( profile != EEsProfile ||
6553 (profile == EEsProfile && version >= 310)) {
6554 if (sampler.type == EbtInt || sampler.type == EbtUint || sampler.type == EbtInt64 || sampler.type == EbtUint64 ) {
6555
6556 const char* dataType;
6557 switch (sampler.type) {
6558 case(EbtInt): dataType = "highp int"; break;
6559 case(EbtUint): dataType = "highp uint"; break;
6560 case(EbtInt64): dataType = "highp int64_t"; break;
6561 case(EbtUint64): dataType = "highp uint64_t"; break;
6562 default: dataType = "";
6563 }
6564
6565 const int numBuiltins = 7;
6566
6567 static const char* atomicFunc[numBuiltins] = {
6568 " imageAtomicAdd(volatile coherent ",
6569 " imageAtomicMin(volatile coherent ",
6570 " imageAtomicMax(volatile coherent ",
6571 " imageAtomicAnd(volatile coherent ",
6572 " imageAtomicOr(volatile coherent ",
6573 " imageAtomicXor(volatile coherent ",
6574 " imageAtomicExchange(volatile coherent "
6575 };
6576
6577 // Loop twice to add prototypes with/without scope/semantics
6578 for (int j = 0; j < 2; ++j) {
6579 for (size_t i = 0; i < numBuiltins; ++i) {
6580 commonBuiltins.append(dataType);
6581 commonBuiltins.append(atomicFunc[i]);
6582 commonBuiltins.append(imageParams);
6583 commonBuiltins.append(", ");
6584 commonBuiltins.append(dataType);
6585 if (j == 1) {
6586 commonBuiltins.append(", int, int, int");
6587 }
6588 commonBuiltins.append(");\n");
6589 }
6590
6591 commonBuiltins.append(dataType);
6592 commonBuiltins.append(" imageAtomicCompSwap(volatile coherent ");
6593 commonBuiltins.append(imageParams);
6594 commonBuiltins.append(", ");
6595 commonBuiltins.append(dataType);
6596 commonBuiltins.append(", ");
6597 commonBuiltins.append(dataType);
6598 if (j == 1) {
6599 commonBuiltins.append(", int, int, int, int, int");
6600 }
6601 commonBuiltins.append(");\n");
6602 }
6603
6604 commonBuiltins.append(dataType);
6605 commonBuiltins.append(" imageAtomicLoad(volatile coherent ");
6606 commonBuiltins.append(imageParams);
6607 commonBuiltins.append(", int, int, int);\n");
6608
6609 commonBuiltins.append("void imageAtomicStore(volatile coherent ");
6610 commonBuiltins.append(imageParams);
6611 commonBuiltins.append(", ");
6612 commonBuiltins.append(dataType);
6613 commonBuiltins.append(", int, int, int);\n");
6614
6615 } else {
6616 // not int or uint
6617 // GL_ARB_ES3_1_compatibility
6618 // TODO: spec issue: are there restrictions on the kind of layout() that can be used? what about dropping memory qualifiers?
6619 if (profile == EEsProfile && version >= 310) {
6620 commonBuiltins.append("float imageAtomicExchange(volatile coherent ");
6621 commonBuiltins.append(imageParams);
6622 commonBuiltins.append(", float);\n");
6623 }
6624 if (profile != EEsProfile && version >= 450) {
6625 commonBuiltins.append("float imageAtomicAdd(volatile coherent ");
6626 commonBuiltins.append(imageParams);
6627 commonBuiltins.append(", float);\n");
6628
6629 commonBuiltins.append("float imageAtomicAdd(volatile coherent ");
6630 commonBuiltins.append(imageParams);
6631 commonBuiltins.append(", float");
6632 commonBuiltins.append(", int, int, int);\n");
6633
6634 commonBuiltins.append("float imageAtomicExchange(volatile coherent ");
6635 commonBuiltins.append(imageParams);
6636 commonBuiltins.append(", float);\n");
6637
6638 commonBuiltins.append("float imageAtomicExchange(volatile coherent ");
6639 commonBuiltins.append(imageParams);
6640 commonBuiltins.append(", float");
6641 commonBuiltins.append(", int, int, int);\n");
6642
6643 commonBuiltins.append("float imageAtomicLoad(readonly volatile coherent ");
6644 commonBuiltins.append(imageParams);
6645 commonBuiltins.append(", int, int, int);\n");
6646
6647 commonBuiltins.append("void imageAtomicStore(writeonly volatile coherent ");
6648 commonBuiltins.append(imageParams);
6649 commonBuiltins.append(", float");
6650 commonBuiltins.append(", int, int, int);\n");
6651
6652 commonBuiltins.append("float imageAtomicMin(volatile coherent ");
6653 commonBuiltins.append(imageParams);
6654 commonBuiltins.append(", float);\n");
6655
6656 commonBuiltins.append("float imageAtomicMin(volatile coherent ");
6657 commonBuiltins.append(imageParams);
6658 commonBuiltins.append(", float");
6659 commonBuiltins.append(", int, int, int);\n");
6660
6661 commonBuiltins.append("float imageAtomicMax(volatile coherent ");
6662 commonBuiltins.append(imageParams);
6663 commonBuiltins.append(", float);\n");
6664
6665 commonBuiltins.append("float imageAtomicMax(volatile coherent ");
6666 commonBuiltins.append(imageParams);
6667 commonBuiltins.append(", float");
6668 commonBuiltins.append(", int, int, int);\n");
6669 }
6670 }
6671 }
6672
6673 if (sampler.dim == EsdRect || sampler.dim == EsdBuffer || sampler.shadow || sampler.isMultiSample())
6674 return;
6675
6676 if (profile == EEsProfile || version < 450)
6677 return;
6678
6679 TString imageLodParams = typeName;
6680 if (dims == 1)
6681 imageLodParams.append(", int");
6682 else {
6683 imageLodParams.append(", ivec");
6684 imageLodParams.append(postfixes[dims]);
6685 }
6686 imageLodParams.append(", int");
6687
6688 commonBuiltins.append(prefixes[sampler.type]);
6689 commonBuiltins.append("vec4 imageLoadLodAMD(readonly volatile coherent ");
6690 commonBuiltins.append(imageLodParams);
6691 commonBuiltins.append(");\n");
6692
6693 commonBuiltins.append("void imageStoreLodAMD(writeonly volatile coherent ");
6694 commonBuiltins.append(imageLodParams);
6695 commonBuiltins.append(", ");
6696 commonBuiltins.append(prefixes[sampler.type]);
6697 commonBuiltins.append("vec4);\n");
6698
6699 if (! sampler.is1D()) {
6700 commonBuiltins.append("int sparseImageLoadLodAMD(readonly volatile coherent ");
6701 commonBuiltins.append(imageLodParams);
6702 commonBuiltins.append(", out ");
6703 commonBuiltins.append(prefixes[sampler.type]);
6704 commonBuiltins.append("vec4");
6705 commonBuiltins.append(");\n");
6706 }
6707 }
6708
6709 //
6710 // Helper function for initialize(),
6711 // when adding context-independent built-in functions.
6712 //
6713 // Add all the subpass access functions for the given type.
6714 //
addSubpassSampling(TSampler sampler,const TString & typeName,int,EProfile)6715 void TBuiltIns::addSubpassSampling(TSampler sampler, const TString& typeName, int /*version*/, EProfile /*profile*/)
6716 {
6717 stageBuiltins[EShLangFragment].append(prefixes[sampler.type]);
6718 stageBuiltins[EShLangFragment].append("vec4 subpassLoad");
6719 stageBuiltins[EShLangFragment].append("(");
6720 stageBuiltins[EShLangFragment].append(typeName.c_str());
6721 if (sampler.isMultiSample())
6722 stageBuiltins[EShLangFragment].append(", int");
6723 stageBuiltins[EShLangFragment].append(");\n");
6724 }
6725
6726 //
6727 // Helper function for add2ndGenerationSamplingImaging(),
6728 // when adding context-independent built-in functions.
6729 //
6730 // Add all the texture lookup functions for the given type.
6731 //
addSamplingFunctions(TSampler sampler,const TString & typeName,int version,EProfile profile)6732 void TBuiltIns::addSamplingFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile)
6733 {
6734 //
6735 // texturing
6736 //
6737 for (int proj = 0; proj <= 1; ++proj) { // loop over "bool" projective or not
6738
6739 if (proj && (sampler.dim == EsdCube || sampler.isBuffer() || sampler.arrayed || sampler.isMultiSample()
6740 || !sampler.isCombined()))
6741 continue;
6742
6743 for (int lod = 0; lod <= 1; ++lod) {
6744
6745 if (lod && (sampler.isBuffer() || sampler.isRect() || sampler.isMultiSample() || !sampler.isCombined()))
6746 continue;
6747 if (lod && sampler.dim == Esd2D && sampler.arrayed && sampler.shadow)
6748 continue;
6749 if (lod && sampler.dim == EsdCube && sampler.shadow)
6750 continue;
6751
6752 for (int bias = 0; bias <= 1; ++bias) {
6753
6754 if (bias && (lod || sampler.isMultiSample() || !sampler.isCombined()))
6755 continue;
6756 if (bias && (sampler.dim == Esd2D || sampler.dim == EsdCube) && sampler.shadow && sampler.arrayed)
6757 continue;
6758 if (bias && (sampler.isRect() || sampler.isBuffer()))
6759 continue;
6760
6761 for (int offset = 0; offset <= 1; ++offset) { // loop over "bool" offset or not
6762
6763 if (proj + offset + bias + lod > 3)
6764 continue;
6765 if (offset && (sampler.dim == EsdCube || sampler.isBuffer() || sampler.isMultiSample()))
6766 continue;
6767
6768 for (int fetch = 0; fetch <= 1; ++fetch) { // loop over "bool" fetch or not
6769
6770 if (proj + offset + fetch + bias + lod > 3)
6771 continue;
6772 if (fetch && (lod || bias))
6773 continue;
6774 if (fetch && (sampler.shadow || sampler.dim == EsdCube))
6775 continue;
6776 if (fetch == 0 && (sampler.isMultiSample() || sampler.isBuffer()
6777 || !sampler.isCombined()))
6778 continue;
6779
6780 for (int grad = 0; grad <= 1; ++grad) { // loop over "bool" grad or not
6781
6782 if (grad && (lod || bias || sampler.isMultiSample() || !sampler.isCombined()))
6783 continue;
6784 if (grad && sampler.isBuffer())
6785 continue;
6786 if (proj + offset + fetch + grad + bias + lod > 3)
6787 continue;
6788
6789 for (int extraProj = 0; extraProj <= 1; ++extraProj) {
6790 bool compare = false;
6791 int totalDims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0);
6792 // skip dummy unused second component for 1D non-array shadows
6793 if (sampler.shadow && totalDims < 2)
6794 totalDims = 2;
6795 totalDims += (sampler.shadow ? 1 : 0) + proj;
6796 if (totalDims > 4 && sampler.shadow) {
6797 compare = true;
6798 totalDims = 4;
6799 }
6800 assert(totalDims <= 4);
6801
6802 if (extraProj && ! proj)
6803 continue;
6804 if (extraProj && (sampler.dim == Esd3D || sampler.shadow || !sampler.isCombined()))
6805 continue;
6806
6807 // loop over 16-bit floating-point texel addressing
6808 for (int f16TexAddr = 0; f16TexAddr <= 1; ++f16TexAddr)
6809 {
6810 if (f16TexAddr && sampler.type != EbtFloat16)
6811 continue;
6812 if (f16TexAddr && sampler.shadow && ! compare) {
6813 compare = true; // compare argument is always present
6814 totalDims--;
6815 }
6816 // loop over "bool" lod clamp
6817 for (int lodClamp = 0; lodClamp <= 1 ;++lodClamp)
6818 {
6819 if (lodClamp && (profile == EEsProfile || version < 450))
6820 continue;
6821 if (lodClamp && (proj || lod || fetch))
6822 continue;
6823
6824 // loop over "bool" sparse or not
6825 for (int sparse = 0; sparse <= 1; ++sparse)
6826 {
6827 if (sparse && (profile == EEsProfile || version < 450))
6828 continue;
6829 // Sparse sampling is not for 1D/1D array texture, buffer texture, and
6830 // projective texture
6831 if (sparse && (sampler.is1D() || sampler.isBuffer() || proj))
6832 continue;
6833
6834 TString s;
6835
6836 // return type
6837 if (sparse)
6838 s.append("int ");
6839 else {
6840 if (sampler.shadow)
6841 if (sampler.type == EbtFloat16)
6842 s.append("float16_t ");
6843 else
6844 s.append("float ");
6845 else {
6846 s.append(prefixes[sampler.type]);
6847 s.append("vec4 ");
6848 }
6849 }
6850
6851 // name
6852 if (sparse) {
6853 if (fetch)
6854 s.append("sparseTexel");
6855 else
6856 s.append("sparseTexture");
6857 }
6858 else {
6859 if (fetch)
6860 s.append("texel");
6861 else
6862 s.append("texture");
6863 }
6864 if (proj)
6865 s.append("Proj");
6866 if (lod)
6867 s.append("Lod");
6868 if (grad)
6869 s.append("Grad");
6870 if (fetch)
6871 s.append("Fetch");
6872 if (offset)
6873 s.append("Offset");
6874 if (lodClamp)
6875 s.append("Clamp");
6876 if (lodClamp != 0 || sparse)
6877 s.append("ARB");
6878 s.append("(");
6879
6880 // sampler type
6881 s.append(typeName);
6882 // P coordinate
6883 if (extraProj) {
6884 if (f16TexAddr)
6885 s.append(",f16vec4");
6886 else
6887 s.append(",vec4");
6888 } else {
6889 s.append(",");
6890 TBasicType t = fetch ? EbtInt : (f16TexAddr ? EbtFloat16 : EbtFloat);
6891 if (totalDims == 1)
6892 s.append(TType::getBasicString(t));
6893 else {
6894 s.append(prefixes[t]);
6895 s.append("vec");
6896 s.append(postfixes[totalDims]);
6897 }
6898 }
6899 // non-optional compare
6900 if (compare)
6901 s.append(",float");
6902
6903 // non-optional lod argument (lod that's not driven by lod loop) or sample
6904 if ((fetch && !sampler.isBuffer() &&
6905 !sampler.isRect() && !sampler.isMultiSample())
6906 || (sampler.isMultiSample() && fetch))
6907 s.append(",int");
6908 // non-optional lod
6909 if (lod) {
6910 if (f16TexAddr)
6911 s.append(",float16_t");
6912 else
6913 s.append(",float");
6914 }
6915
6916 // gradient arguments
6917 if (grad) {
6918 if (dimMap[sampler.dim] == 1) {
6919 if (f16TexAddr)
6920 s.append(",float16_t,float16_t");
6921 else
6922 s.append(",float,float");
6923 } else {
6924 if (f16TexAddr)
6925 s.append(",f16vec");
6926 else
6927 s.append(",vec");
6928 s.append(postfixes[dimMap[sampler.dim]]);
6929 if (f16TexAddr)
6930 s.append(",f16vec");
6931 else
6932 s.append(",vec");
6933 s.append(postfixes[dimMap[sampler.dim]]);
6934 }
6935 }
6936 // offset
6937 if (offset) {
6938 if (dimMap[sampler.dim] == 1)
6939 s.append(",int");
6940 else {
6941 s.append(",ivec");
6942 s.append(postfixes[dimMap[sampler.dim]]);
6943 }
6944 }
6945
6946 // lod clamp
6947 if (lodClamp) {
6948 if (f16TexAddr)
6949 s.append(",float16_t");
6950 else
6951 s.append(",float");
6952 }
6953 // texel out (for sparse texture)
6954 if (sparse) {
6955 s.append(",out ");
6956 if (sampler.shadow)
6957 if (sampler.type == EbtFloat16)
6958 s.append("float16_t");
6959 else
6960 s.append("float");
6961 else {
6962 s.append(prefixes[sampler.type]);
6963 s.append("vec4");
6964 }
6965 }
6966 // optional bias
6967 if (bias) {
6968 if (f16TexAddr)
6969 s.append(",float16_t");
6970 else
6971 s.append(",float");
6972 }
6973 s.append(");\n");
6974
6975 // Add to the per-language set of built-ins
6976 if (!grad && (bias || lodClamp != 0)) {
6977 stageBuiltins[EShLangFragment].append(s);
6978 stageBuiltins[EShLangCompute].append(s);
6979 } else
6980 commonBuiltins.append(s);
6981
6982 }
6983 }
6984 }
6985 }
6986 }
6987 }
6988 }
6989 }
6990 }
6991 }
6992 }
6993
6994 //
6995 // Helper function for add2ndGenerationSamplingImaging(),
6996 // when adding context-independent built-in functions.
6997 //
6998 // Add all the texture gather functions for the given type.
6999 //
addGatherFunctions(TSampler sampler,const TString & typeName,int version,EProfile profile)7000 void TBuiltIns::addGatherFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile)
7001 {
7002 switch (sampler.dim) {
7003 case Esd2D:
7004 case EsdRect:
7005 case EsdCube:
7006 break;
7007 default:
7008 return;
7009 }
7010
7011 if (sampler.isMultiSample())
7012 return;
7013
7014 if (version < 140 && sampler.dim == EsdRect && sampler.type != EbtFloat)
7015 return;
7016
7017 for (int f16TexAddr = 0; f16TexAddr <= 1; ++f16TexAddr) { // loop over 16-bit floating-point texel addressing
7018
7019 if (f16TexAddr && sampler.type != EbtFloat16)
7020 continue;
7021 for (int offset = 0; offset < 3; ++offset) { // loop over three forms of offset in the call name: none, Offset, and Offsets
7022
7023 for (int comp = 0; comp < 2; ++comp) { // loop over presence of comp argument
7024
7025 if (comp > 0 && sampler.shadow)
7026 continue;
7027
7028 if (offset > 0 && sampler.dim == EsdCube)
7029 continue;
7030
7031 for (int sparse = 0; sparse <= 1; ++sparse) { // loop over "bool" sparse or not
7032 if (sparse && (profile == EEsProfile || version < 450))
7033 continue;
7034
7035 TString s;
7036
7037 // return type
7038 if (sparse)
7039 s.append("int ");
7040 else {
7041 s.append(prefixes[sampler.type]);
7042 s.append("vec4 ");
7043 }
7044
7045 // name
7046 if (sparse)
7047 s.append("sparseTextureGather");
7048 else
7049 s.append("textureGather");
7050 switch (offset) {
7051 case 1:
7052 s.append("Offset");
7053 break;
7054 case 2:
7055 s.append("Offsets");
7056 break;
7057 default:
7058 break;
7059 }
7060 if (sparse)
7061 s.append("ARB");
7062 s.append("(");
7063
7064 // sampler type argument
7065 s.append(typeName);
7066
7067 // P coordinate argument
7068 if (f16TexAddr)
7069 s.append(",f16vec");
7070 else
7071 s.append(",vec");
7072 int totalDims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0);
7073 s.append(postfixes[totalDims]);
7074
7075 // refZ argument
7076 if (sampler.shadow)
7077 s.append(",float");
7078
7079 // offset argument
7080 if (offset > 0) {
7081 s.append(",ivec2");
7082 if (offset == 2)
7083 s.append("[4]");
7084 }
7085
7086 // texel out (for sparse texture)
7087 if (sparse) {
7088 s.append(",out ");
7089 s.append(prefixes[sampler.type]);
7090 s.append("vec4 ");
7091 }
7092
7093 // comp argument
7094 if (comp)
7095 s.append(",int");
7096
7097 s.append(");\n");
7098 commonBuiltins.append(s);
7099 }
7100 }
7101 }
7102 }
7103
7104 if (sampler.dim == EsdRect || sampler.shadow)
7105 return;
7106
7107 if (profile == EEsProfile || version < 450)
7108 return;
7109
7110 for (int bias = 0; bias < 2; ++bias) { // loop over presence of bias argument
7111
7112 for (int lod = 0; lod < 2; ++lod) { // loop over presence of lod argument
7113
7114 if ((lod && bias) || (lod == 0 && bias == 0))
7115 continue;
7116
7117 for (int f16TexAddr = 0; f16TexAddr <= 1; ++f16TexAddr) { // loop over 16-bit floating-point texel addressing
7118
7119 if (f16TexAddr && sampler.type != EbtFloat16)
7120 continue;
7121
7122 for (int offset = 0; offset < 3; ++offset) { // loop over three forms of offset in the call name: none, Offset, and Offsets
7123
7124 for (int comp = 0; comp < 2; ++comp) { // loop over presence of comp argument
7125
7126 if (comp == 0 && bias)
7127 continue;
7128
7129 if (offset > 0 && sampler.dim == EsdCube)
7130 continue;
7131
7132 for (int sparse = 0; sparse <= 1; ++sparse) { // loop over "bool" sparse or not
7133 if (sparse && (profile == EEsProfile || version < 450))
7134 continue;
7135
7136 TString s;
7137
7138 // return type
7139 if (sparse)
7140 s.append("int ");
7141 else {
7142 s.append(prefixes[sampler.type]);
7143 s.append("vec4 ");
7144 }
7145
7146 // name
7147 if (sparse)
7148 s.append("sparseTextureGather");
7149 else
7150 s.append("textureGather");
7151
7152 if (lod)
7153 s.append("Lod");
7154
7155 switch (offset) {
7156 case 1:
7157 s.append("Offset");
7158 break;
7159 case 2:
7160 s.append("Offsets");
7161 break;
7162 default:
7163 break;
7164 }
7165
7166 if (lod)
7167 s.append("AMD");
7168 else if (sparse)
7169 s.append("ARB");
7170
7171 s.append("(");
7172
7173 // sampler type argument
7174 s.append(typeName);
7175
7176 // P coordinate argument
7177 if (f16TexAddr)
7178 s.append(",f16vec");
7179 else
7180 s.append(",vec");
7181 int totalDims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0);
7182 s.append(postfixes[totalDims]);
7183
7184 // lod argument
7185 if (lod) {
7186 if (f16TexAddr)
7187 s.append(",float16_t");
7188 else
7189 s.append(",float");
7190 }
7191
7192 // offset argument
7193 if (offset > 0) {
7194 s.append(",ivec2");
7195 if (offset == 2)
7196 s.append("[4]");
7197 }
7198
7199 // texel out (for sparse texture)
7200 if (sparse) {
7201 s.append(",out ");
7202 s.append(prefixes[sampler.type]);
7203 s.append("vec4 ");
7204 }
7205
7206 // comp argument
7207 if (comp)
7208 s.append(",int");
7209
7210 // bias argument
7211 if (bias) {
7212 if (f16TexAddr)
7213 s.append(",float16_t");
7214 else
7215 s.append(",float");
7216 }
7217
7218 s.append(");\n");
7219 if (bias)
7220 stageBuiltins[EShLangFragment].append(s);
7221 else
7222 commonBuiltins.append(s);
7223 }
7224 }
7225 }
7226 }
7227 }
7228 }
7229 }
7230
7231 //
7232 // Add context-dependent built-in functions and variables that are present
7233 // for the given version and profile. All the results are put into just the
7234 // commonBuiltins, because it is called for just a specific stage. So,
7235 // add stage-specific entries to the commonBuiltins, and only if that stage
7236 // was requested.
7237 //
initialize(const TBuiltInResource & resources,int version,EProfile profile,const SpvVersion & spvVersion,EShLanguage language)7238 void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language)
7239 {
7240 //
7241 // Initialize the context-dependent (resource-dependent) built-in strings for parsing.
7242 //
7243
7244 //============================================================================
7245 //
7246 // Standard Uniforms
7247 //
7248 //============================================================================
7249
7250 TString& s = commonBuiltins;
7251 const int maxSize = 200;
7252 char builtInConstant[maxSize];
7253
7254 //
7255 // Build string of implementation dependent constants.
7256 //
7257
7258 if (profile == EEsProfile) {
7259 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs);
7260 s.append(builtInConstant);
7261
7262 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxVertexUniformVectors = %d;", resources.maxVertexUniformVectors);
7263 s.append(builtInConstant);
7264
7265 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxVertexTextureImageUnits = %d;", resources.maxVertexTextureImageUnits);
7266 s.append(builtInConstant);
7267
7268 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxCombinedTextureImageUnits = %d;", resources.maxCombinedTextureImageUnits);
7269 s.append(builtInConstant);
7270
7271 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits);
7272 s.append(builtInConstant);
7273
7274 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxFragmentUniformVectors = %d;", resources.maxFragmentUniformVectors);
7275 s.append(builtInConstant);
7276
7277 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxDrawBuffers = %d;", resources.maxDrawBuffers);
7278 s.append(builtInConstant);
7279
7280 if (version == 100) {
7281 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxVaryingVectors = %d;", resources.maxVaryingVectors);
7282 s.append(builtInConstant);
7283 } else {
7284 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxVertexOutputVectors = %d;", resources.maxVertexOutputVectors);
7285 s.append(builtInConstant);
7286
7287 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxFragmentInputVectors = %d;", resources.maxFragmentInputVectors);
7288 s.append(builtInConstant);
7289
7290 snprintf(builtInConstant, maxSize, "const mediump int gl_MinProgramTexelOffset = %d;", resources.minProgramTexelOffset);
7291 s.append(builtInConstant);
7292
7293 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxProgramTexelOffset = %d;", resources.maxProgramTexelOffset);
7294 s.append(builtInConstant);
7295 }
7296
7297 if (version >= 310) {
7298 // geometry
7299
7300 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryInputComponents = %d;", resources.maxGeometryInputComponents);
7301 s.append(builtInConstant);
7302 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryOutputComponents = %d;", resources.maxGeometryOutputComponents);
7303 s.append(builtInConstant);
7304 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryImageUniforms = %d;", resources.maxGeometryImageUniforms);
7305 s.append(builtInConstant);
7306 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryTextureImageUnits = %d;", resources.maxGeometryTextureImageUnits);
7307 s.append(builtInConstant);
7308 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryOutputVertices = %d;", resources.maxGeometryOutputVertices);
7309 s.append(builtInConstant);
7310 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryTotalOutputComponents = %d;", resources.maxGeometryTotalOutputComponents);
7311 s.append(builtInConstant);
7312 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryUniformComponents = %d;", resources.maxGeometryUniformComponents);
7313 s.append(builtInConstant);
7314 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounters = %d;", resources.maxGeometryAtomicCounters);
7315 s.append(builtInConstant);
7316 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounterBuffers = %d;", resources.maxGeometryAtomicCounterBuffers);
7317 s.append(builtInConstant);
7318
7319 // tessellation
7320
7321 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlInputComponents = %d;", resources.maxTessControlInputComponents);
7322 s.append(builtInConstant);
7323 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlOutputComponents = %d;", resources.maxTessControlOutputComponents);
7324 s.append(builtInConstant);
7325 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlTextureImageUnits = %d;", resources.maxTessControlTextureImageUnits);
7326 s.append(builtInConstant);
7327 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlUniformComponents = %d;", resources.maxTessControlUniformComponents);
7328 s.append(builtInConstant);
7329 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlTotalOutputComponents = %d;", resources.maxTessControlTotalOutputComponents);
7330 s.append(builtInConstant);
7331
7332 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationInputComponents = %d;", resources.maxTessEvaluationInputComponents);
7333 s.append(builtInConstant);
7334 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationOutputComponents = %d;", resources.maxTessEvaluationOutputComponents);
7335 s.append(builtInConstant);
7336 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationTextureImageUnits = %d;", resources.maxTessEvaluationTextureImageUnits);
7337 s.append(builtInConstant);
7338 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationUniformComponents = %d;", resources.maxTessEvaluationUniformComponents);
7339 s.append(builtInConstant);
7340
7341 snprintf(builtInConstant, maxSize, "const int gl_MaxTessPatchComponents = %d;", resources.maxTessPatchComponents);
7342 s.append(builtInConstant);
7343
7344 snprintf(builtInConstant, maxSize, "const int gl_MaxPatchVertices = %d;", resources.maxPatchVertices);
7345 s.append(builtInConstant);
7346 snprintf(builtInConstant, maxSize, "const int gl_MaxTessGenLevel = %d;", resources.maxTessGenLevel);
7347 s.append(builtInConstant);
7348
7349 // this is here instead of with the others in initialize(version, profile) due to the dependence on gl_MaxPatchVertices
7350 if (language == EShLangTessControl || language == EShLangTessEvaluation) {
7351 s.append(
7352 "in gl_PerVertex {"
7353 "highp vec4 gl_Position;"
7354 "highp float gl_PointSize;"
7355 "highp vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
7356 "highp vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
7357 "} gl_in[gl_MaxPatchVertices];"
7358 "\n");
7359 }
7360 }
7361
7362 if (version >= 320) {
7363 // tessellation
7364
7365 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlImageUniforms = %d;", resources.maxTessControlImageUniforms);
7366 s.append(builtInConstant);
7367 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationImageUniforms = %d;", resources.maxTessEvaluationImageUniforms);
7368 s.append(builtInConstant);
7369 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounters = %d;", resources.maxTessControlAtomicCounters);
7370 s.append(builtInConstant);
7371 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounters = %d;", resources.maxTessEvaluationAtomicCounters);
7372 s.append(builtInConstant);
7373 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounterBuffers = %d;", resources.maxTessControlAtomicCounterBuffers);
7374 s.append(builtInConstant);
7375 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounterBuffers = %d;", resources.maxTessEvaluationAtomicCounterBuffers);
7376 s.append(builtInConstant);
7377 }
7378
7379 if (version >= 100) {
7380 // GL_EXT_blend_func_extended
7381 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxDualSourceDrawBuffersEXT = %d;", resources.maxDualSourceDrawBuffersEXT);
7382 s.append(builtInConstant);
7383 // this is here instead of with the others in initialize(version, profile) due to the dependence on gl_MaxDualSourceDrawBuffersEXT
7384 if (language == EShLangFragment) {
7385 s.append(
7386 "mediump vec4 gl_SecondaryFragColorEXT;"
7387 "mediump vec4 gl_SecondaryFragDataEXT[gl_MaxDualSourceDrawBuffersEXT];"
7388 "\n");
7389 }
7390 }
7391 } else {
7392 // non-ES profile
7393
7394 if (version > 400) {
7395 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexUniformVectors = %d;", resources.maxVertexUniformVectors);
7396 s.append(builtInConstant);
7397
7398 snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentUniformVectors = %d;", resources.maxFragmentUniformVectors);
7399 s.append(builtInConstant);
7400
7401 snprintf(builtInConstant, maxSize, "const int gl_MaxVaryingVectors = %d;", resources.maxVaryingVectors);
7402 s.append(builtInConstant);
7403 }
7404
7405 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs);
7406 s.append(builtInConstant);
7407
7408 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexTextureImageUnits = %d;", resources.maxVertexTextureImageUnits);
7409 s.append(builtInConstant);
7410
7411 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedTextureImageUnits = %d;", resources.maxCombinedTextureImageUnits);
7412 s.append(builtInConstant);
7413
7414 snprintf(builtInConstant, maxSize, "const int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits);
7415 s.append(builtInConstant);
7416
7417 snprintf(builtInConstant, maxSize, "const int gl_MaxDrawBuffers = %d;", resources.maxDrawBuffers);
7418 s.append(builtInConstant);
7419
7420 snprintf(builtInConstant, maxSize, "const int gl_MaxLights = %d;", resources.maxLights);
7421 s.append(builtInConstant);
7422
7423 snprintf(builtInConstant, maxSize, "const int gl_MaxClipPlanes = %d;", resources.maxClipPlanes);
7424 s.append(builtInConstant);
7425
7426 snprintf(builtInConstant, maxSize, "const int gl_MaxTextureUnits = %d;", resources.maxTextureUnits);
7427 s.append(builtInConstant);
7428
7429 snprintf(builtInConstant, maxSize, "const int gl_MaxTextureCoords = %d;", resources.maxTextureCoords);
7430 s.append(builtInConstant);
7431
7432 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexUniformComponents = %d;", resources.maxVertexUniformComponents);
7433 s.append(builtInConstant);
7434
7435 // Moved from just being deprecated into compatibility profile only as of 4.20
7436 if (version < 420 || profile == ECompatibilityProfile) {
7437 snprintf(builtInConstant, maxSize, "const int gl_MaxVaryingFloats = %d;", resources.maxVaryingFloats);
7438 s.append(builtInConstant);
7439 }
7440
7441 snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentUniformComponents = %d;", resources.maxFragmentUniformComponents);
7442 s.append(builtInConstant);
7443
7444 if (spvVersion.spv == 0 && IncludeLegacy(version, profile, spvVersion)) {
7445 //
7446 // OpenGL'uniform' state. Page numbers are in reference to version
7447 // 1.4 of the OpenGL specification.
7448 //
7449
7450 //
7451 // Matrix state. p. 31, 32, 37, 39, 40.
7452 //
7453 s.append("uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];"
7454
7455 //
7456 // Derived matrix state that provides inverse and transposed versions
7457 // of the matrices above.
7458 //
7459 "uniform mat4 gl_TextureMatrixInverse[gl_MaxTextureCoords];"
7460
7461 "uniform mat4 gl_TextureMatrixTranspose[gl_MaxTextureCoords];"
7462
7463 "uniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords];"
7464
7465 //
7466 // Clip planes p. 42.
7467 //
7468 "uniform vec4 gl_ClipPlane[gl_MaxClipPlanes];"
7469
7470 //
7471 // Light State p 50, 53, 55.
7472 //
7473 "uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];"
7474
7475 //
7476 // Derived state from products of light.
7477 //
7478 "uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];"
7479 "uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];"
7480
7481 //
7482 // Texture Environment and Generation, p. 152, p. 40-42.
7483 //
7484 "uniform vec4 gl_TextureEnvColor[gl_MaxTextureImageUnits];"
7485 "uniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];"
7486 "uniform vec4 gl_EyePlaneT[gl_MaxTextureCoords];"
7487 "uniform vec4 gl_EyePlaneR[gl_MaxTextureCoords];"
7488 "uniform vec4 gl_EyePlaneQ[gl_MaxTextureCoords];"
7489 "uniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoords];"
7490 "uniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoords];"
7491 "uniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoords];"
7492 "uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoords];");
7493 }
7494
7495 if (version >= 130) {
7496 snprintf(builtInConstant, maxSize, "const int gl_MaxClipDistances = %d;", resources.maxClipDistances);
7497 s.append(builtInConstant);
7498 snprintf(builtInConstant, maxSize, "const int gl_MaxVaryingComponents = %d;", resources.maxVaryingComponents);
7499 s.append(builtInConstant);
7500
7501 // GL_ARB_shading_language_420pack
7502 snprintf(builtInConstant, maxSize, "const mediump int gl_MinProgramTexelOffset = %d;", resources.minProgramTexelOffset);
7503 s.append(builtInConstant);
7504 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxProgramTexelOffset = %d;", resources.maxProgramTexelOffset);
7505 s.append(builtInConstant);
7506 }
7507
7508 // geometry
7509 if (version >= 150) {
7510 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryInputComponents = %d;", resources.maxGeometryInputComponents);
7511 s.append(builtInConstant);
7512 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryOutputComponents = %d;", resources.maxGeometryOutputComponents);
7513 s.append(builtInConstant);
7514 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryTextureImageUnits = %d;", resources.maxGeometryTextureImageUnits);
7515 s.append(builtInConstant);
7516 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryOutputVertices = %d;", resources.maxGeometryOutputVertices);
7517 s.append(builtInConstant);
7518 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryTotalOutputComponents = %d;", resources.maxGeometryTotalOutputComponents);
7519 s.append(builtInConstant);
7520 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryUniformComponents = %d;", resources.maxGeometryUniformComponents);
7521 s.append(builtInConstant);
7522 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryVaryingComponents = %d;", resources.maxGeometryVaryingComponents);
7523 s.append(builtInConstant);
7524
7525 }
7526
7527 if (version >= 150) {
7528 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexOutputComponents = %d;", resources.maxVertexOutputComponents);
7529 s.append(builtInConstant);
7530 snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentInputComponents = %d;", resources.maxFragmentInputComponents);
7531 s.append(builtInConstant);
7532 }
7533
7534 // tessellation
7535 if (version >= 150) {
7536 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlInputComponents = %d;", resources.maxTessControlInputComponents);
7537 s.append(builtInConstant);
7538 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlOutputComponents = %d;", resources.maxTessControlOutputComponents);
7539 s.append(builtInConstant);
7540 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlTextureImageUnits = %d;", resources.maxTessControlTextureImageUnits);
7541 s.append(builtInConstant);
7542 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlUniformComponents = %d;", resources.maxTessControlUniformComponents);
7543 s.append(builtInConstant);
7544 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlTotalOutputComponents = %d;", resources.maxTessControlTotalOutputComponents);
7545 s.append(builtInConstant);
7546
7547 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationInputComponents = %d;", resources.maxTessEvaluationInputComponents);
7548 s.append(builtInConstant);
7549 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationOutputComponents = %d;", resources.maxTessEvaluationOutputComponents);
7550 s.append(builtInConstant);
7551 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationTextureImageUnits = %d;", resources.maxTessEvaluationTextureImageUnits);
7552 s.append(builtInConstant);
7553 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationUniformComponents = %d;", resources.maxTessEvaluationUniformComponents);
7554 s.append(builtInConstant);
7555
7556 snprintf(builtInConstant, maxSize, "const int gl_MaxTessPatchComponents = %d;", resources.maxTessPatchComponents);
7557 s.append(builtInConstant);
7558 snprintf(builtInConstant, maxSize, "const int gl_MaxTessGenLevel = %d;", resources.maxTessGenLevel);
7559 s.append(builtInConstant);
7560 snprintf(builtInConstant, maxSize, "const int gl_MaxPatchVertices = %d;", resources.maxPatchVertices);
7561 s.append(builtInConstant);
7562
7563 // this is here instead of with the others in initialize(version, profile) due to the dependence on gl_MaxPatchVertices
7564 if (language == EShLangTessControl || language == EShLangTessEvaluation) {
7565 s.append(
7566 "in gl_PerVertex {"
7567 "vec4 gl_Position;"
7568 "float gl_PointSize;"
7569 "float gl_ClipDistance[];"
7570 );
7571 if (profile == ECompatibilityProfile)
7572 s.append(
7573 "vec4 gl_ClipVertex;"
7574 "vec4 gl_FrontColor;"
7575 "vec4 gl_BackColor;"
7576 "vec4 gl_FrontSecondaryColor;"
7577 "vec4 gl_BackSecondaryColor;"
7578 "vec4 gl_TexCoord[];"
7579 "float gl_FogFragCoord;"
7580 );
7581 if (profile != EEsProfile && version >= 450)
7582 s.append(
7583 "float gl_CullDistance[];"
7584 "vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering
7585 "vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes
7586 );
7587 s.append(
7588 "} gl_in[gl_MaxPatchVertices];"
7589 "\n");
7590 }
7591 }
7592
7593 if (version >= 150) {
7594 snprintf(builtInConstant, maxSize, "const int gl_MaxViewports = %d;", resources.maxViewports);
7595 s.append(builtInConstant);
7596 }
7597
7598 // images
7599 if (version >= 130) {
7600 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedImageUnitsAndFragmentOutputs = %d;", resources.maxCombinedImageUnitsAndFragmentOutputs);
7601 s.append(builtInConstant);
7602 snprintf(builtInConstant, maxSize, "const int gl_MaxImageSamples = %d;", resources.maxImageSamples);
7603 s.append(builtInConstant);
7604 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlImageUniforms = %d;", resources.maxTessControlImageUniforms);
7605 s.append(builtInConstant);
7606 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationImageUniforms = %d;", resources.maxTessEvaluationImageUniforms);
7607 s.append(builtInConstant);
7608 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryImageUniforms = %d;", resources.maxGeometryImageUniforms);
7609 s.append(builtInConstant);
7610 }
7611
7612 // enhanced layouts
7613 if (version >= 430) {
7614 snprintf(builtInConstant, maxSize, "const int gl_MaxTransformFeedbackBuffers = %d;", resources.maxTransformFeedbackBuffers);
7615 s.append(builtInConstant);
7616 snprintf(builtInConstant, maxSize, "const int gl_MaxTransformFeedbackInterleavedComponents = %d;", resources.maxTransformFeedbackInterleavedComponents);
7617 s.append(builtInConstant);
7618 }
7619 }
7620
7621 // compute
7622 if ((profile == EEsProfile && version >= 310) || (profile != EEsProfile && version >= 420)) {
7623 snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxComputeWorkGroupCount = ivec3(%d,%d,%d);", resources.maxComputeWorkGroupCountX,
7624 resources.maxComputeWorkGroupCountY,
7625 resources.maxComputeWorkGroupCountZ);
7626 s.append(builtInConstant);
7627 snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxComputeWorkGroupSize = ivec3(%d,%d,%d);", resources.maxComputeWorkGroupSizeX,
7628 resources.maxComputeWorkGroupSizeY,
7629 resources.maxComputeWorkGroupSizeZ);
7630 s.append(builtInConstant);
7631
7632 snprintf(builtInConstant, maxSize, "const int gl_MaxComputeUniformComponents = %d;", resources.maxComputeUniformComponents);
7633 s.append(builtInConstant);
7634 snprintf(builtInConstant, maxSize, "const int gl_MaxComputeTextureImageUnits = %d;", resources.maxComputeTextureImageUnits);
7635 s.append(builtInConstant);
7636
7637 s.append("\n");
7638 }
7639
7640 // images (some in compute below)
7641 if ((profile == EEsProfile && version >= 310) ||
7642 (profile != EEsProfile && version >= 130)) {
7643 snprintf(builtInConstant, maxSize, "const int gl_MaxImageUnits = %d;", resources.maxImageUnits);
7644 s.append(builtInConstant);
7645 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedShaderOutputResources = %d;", resources.maxCombinedShaderOutputResources);
7646 s.append(builtInConstant);
7647 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexImageUniforms = %d;", resources.maxVertexImageUniforms);
7648 s.append(builtInConstant);
7649 snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentImageUniforms = %d;", resources.maxFragmentImageUniforms);
7650 s.append(builtInConstant);
7651 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedImageUniforms = %d;", resources.maxCombinedImageUniforms);
7652 s.append(builtInConstant);
7653 }
7654
7655 // compute
7656 if ((profile == EEsProfile && version >= 310) || (profile != EEsProfile && version >= 420)) {
7657 snprintf(builtInConstant, maxSize, "const int gl_MaxComputeImageUniforms = %d;", resources.maxComputeImageUniforms);
7658 s.append(builtInConstant);
7659 snprintf(builtInConstant, maxSize, "const int gl_MaxComputeAtomicCounters = %d;", resources.maxComputeAtomicCounters);
7660 s.append(builtInConstant);
7661 snprintf(builtInConstant, maxSize, "const int gl_MaxComputeAtomicCounterBuffers = %d;", resources.maxComputeAtomicCounterBuffers);
7662 s.append(builtInConstant);
7663
7664 s.append("\n");
7665 }
7666
7667 // atomic counters (some in compute below)
7668 if ((profile == EEsProfile && version >= 310) ||
7669 (profile != EEsProfile && version >= 420)) {
7670 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAtomicCounters = %d;", resources. maxVertexAtomicCounters);
7671 s.append(builtInConstant);
7672 snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentAtomicCounters = %d;", resources. maxFragmentAtomicCounters);
7673 s.append(builtInConstant);
7674 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedAtomicCounters = %d;", resources. maxCombinedAtomicCounters);
7675 s.append(builtInConstant);
7676 snprintf(builtInConstant, maxSize, "const int gl_MaxAtomicCounterBindings = %d;", resources. maxAtomicCounterBindings);
7677 s.append(builtInConstant);
7678 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAtomicCounterBuffers = %d;", resources. maxVertexAtomicCounterBuffers);
7679 s.append(builtInConstant);
7680 snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentAtomicCounterBuffers = %d;", resources. maxFragmentAtomicCounterBuffers);
7681 s.append(builtInConstant);
7682 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedAtomicCounterBuffers = %d;", resources. maxCombinedAtomicCounterBuffers);
7683 s.append(builtInConstant);
7684 snprintf(builtInConstant, maxSize, "const int gl_MaxAtomicCounterBufferSize = %d;", resources. maxAtomicCounterBufferSize);
7685 s.append(builtInConstant);
7686 }
7687 if (profile != EEsProfile && version >= 420) {
7688 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounters = %d;", resources. maxTessControlAtomicCounters);
7689 s.append(builtInConstant);
7690 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounters = %d;", resources. maxTessEvaluationAtomicCounters);
7691 s.append(builtInConstant);
7692 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounters = %d;", resources. maxGeometryAtomicCounters);
7693 s.append(builtInConstant);
7694 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounterBuffers = %d;", resources. maxTessControlAtomicCounterBuffers);
7695 s.append(builtInConstant);
7696 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounterBuffers = %d;", resources. maxTessEvaluationAtomicCounterBuffers);
7697 s.append(builtInConstant);
7698 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounterBuffers = %d;", resources. maxGeometryAtomicCounterBuffers);
7699 s.append(builtInConstant);
7700
7701 s.append("\n");
7702 }
7703
7704 // GL_ARB_cull_distance
7705 if (profile != EEsProfile && version >= 450) {
7706 snprintf(builtInConstant, maxSize, "const int gl_MaxCullDistances = %d;", resources.maxCullDistances);
7707 s.append(builtInConstant);
7708 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedClipAndCullDistances = %d;", resources.maxCombinedClipAndCullDistances);
7709 s.append(builtInConstant);
7710 }
7711
7712 // GL_ARB_ES3_1_compatibility
7713 if ((profile != EEsProfile && version >= 450) ||
7714 (profile == EEsProfile && version >= 310)) {
7715 snprintf(builtInConstant, maxSize, "const int gl_MaxSamples = %d;", resources.maxSamples);
7716 s.append(builtInConstant);
7717 }
7718
7719 // SPV_NV_mesh_shader
7720 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
7721 snprintf(builtInConstant, maxSize, "const int gl_MaxMeshOutputVerticesNV = %d;", resources.maxMeshOutputVerticesNV);
7722 s.append(builtInConstant);
7723
7724 snprintf(builtInConstant, maxSize, "const int gl_MaxMeshOutputPrimitivesNV = %d;", resources.maxMeshOutputPrimitivesNV);
7725 s.append(builtInConstant);
7726
7727 snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxMeshWorkGroupSizeNV = ivec3(%d,%d,%d);", resources.maxMeshWorkGroupSizeX_NV,
7728 resources.maxMeshWorkGroupSizeY_NV,
7729 resources.maxMeshWorkGroupSizeZ_NV);
7730 s.append(builtInConstant);
7731 snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxTaskWorkGroupSizeNV = ivec3(%d,%d,%d);", resources.maxTaskWorkGroupSizeX_NV,
7732 resources.maxTaskWorkGroupSizeY_NV,
7733 resources.maxTaskWorkGroupSizeZ_NV);
7734 s.append(builtInConstant);
7735
7736 snprintf(builtInConstant, maxSize, "const int gl_MaxMeshViewCountNV = %d;", resources.maxMeshViewCountNV);
7737 s.append(builtInConstant);
7738
7739 s.append("\n");
7740 }
7741
7742 s.append("\n");
7743 }
7744
7745 //
7746 // To support special built-ins that have a special qualifier that cannot be declared textually
7747 // in a shader, like gl_Position.
7748 //
7749 // This lets the type of the built-in be declared textually, and then have just its qualifier be
7750 // updated afterward.
7751 //
7752 // Safe to call even if name is not present.
7753 //
7754 // Only use this for built-in variables that have a special qualifier in TStorageQualifier.
7755 // New built-in variables should use a generic (textually declarable) qualifier in
7756 // TStoraregQualifier and only call BuiltInVariable().
7757 //
SpecialQualifier(const char * name,TStorageQualifier qualifier,TBuiltInVariable builtIn,TSymbolTable & symbolTable)7758 static void SpecialQualifier(const char* name, TStorageQualifier qualifier, TBuiltInVariable builtIn, TSymbolTable& symbolTable)
7759 {
7760 TSymbol* symbol = symbolTable.find(name);
7761 if (symbol == nullptr)
7762 return;
7763
7764 TQualifier& symQualifier = symbol->getWritableType().getQualifier();
7765 symQualifier.storage = qualifier;
7766 symQualifier.builtIn = builtIn;
7767 }
7768
7769 //
7770 // Modify the symbol's flat decoration.
7771 //
7772 // Safe to call even if name is not present.
7773 //
7774 // Originally written to transform gl_SubGroupSizeARB from uniform to fragment input in Vulkan.
7775 //
ModifyFlatDecoration(const char * name,bool flat,TSymbolTable & symbolTable)7776 static void ModifyFlatDecoration(const char* name, bool flat, TSymbolTable& symbolTable)
7777 {
7778 TSymbol* symbol = symbolTable.find(name);
7779 if (symbol == nullptr)
7780 return;
7781
7782 TQualifier& symQualifier = symbol->getWritableType().getQualifier();
7783 symQualifier.flat = flat;
7784 }
7785
7786 //
7787 // To tag built-in variables with their TBuiltInVariable enum. Use this when the
7788 // normal declaration text already gets the qualifier right, and all that's needed
7789 // is setting the builtIn field. This should be the normal way for all new
7790 // built-in variables.
7791 //
7792 // If SpecialQualifier() was called, this does not need to be called.
7793 //
7794 // Safe to call even if name is not present.
7795 //
BuiltInVariable(const char * name,TBuiltInVariable builtIn,TSymbolTable & symbolTable)7796 static void BuiltInVariable(const char* name, TBuiltInVariable builtIn, TSymbolTable& symbolTable)
7797 {
7798 TSymbol* symbol = symbolTable.find(name);
7799 if (symbol == nullptr)
7800 return;
7801
7802 TQualifier& symQualifier = symbol->getWritableType().getQualifier();
7803 symQualifier.builtIn = builtIn;
7804 }
7805
RetargetVariable(const char * from,const char * to,TSymbolTable & symbolTable)7806 static void RetargetVariable(const char* from, const char* to, TSymbolTable& symbolTable)
7807 {
7808 symbolTable.retargetSymbol(from, to);
7809 }
7810
7811 //
7812 // For built-in variables inside a named block.
7813 // SpecialQualifier() won't ever go inside a block; their member's qualifier come
7814 // from the qualification of the block.
7815 //
7816 // See comments above for other detail.
7817 //
BuiltInVariable(const char * blockName,const char * name,TBuiltInVariable builtIn,TSymbolTable & symbolTable)7818 static void BuiltInVariable(const char* blockName, const char* name, TBuiltInVariable builtIn, TSymbolTable& symbolTable)
7819 {
7820 TSymbol* symbol = symbolTable.find(blockName);
7821 if (symbol == nullptr)
7822 return;
7823
7824 TTypeList& structure = *symbol->getWritableType().getWritableStruct();
7825 for (int i = 0; i < (int)structure.size(); ++i) {
7826 if (structure[i].type->getFieldName().compare(name) == 0) {
7827 structure[i].type->getQualifier().builtIn = builtIn;
7828 return;
7829 }
7830 }
7831 }
7832
7833 //
7834 // Finish adding/processing context-independent built-in symbols.
7835 // 1) Programmatically add symbols that could not be added by simple text strings above.
7836 // 2) Map built-in functions to operators, for those that will turn into an operation node
7837 // instead of remaining a function call.
7838 // 3) Tag extension-related symbols added to their base version with their extensions, so
7839 // that if an early version has the extension turned off, there is an error reported on use.
7840 //
identifyBuiltIns(int version,EProfile profile,const SpvVersion & spvVersion,EShLanguage language,TSymbolTable & symbolTable)7841 void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable)
7842 {
7843 //
7844 // Tag built-in variables and functions with additional qualifier and extension information
7845 // that cannot be declared with the text strings.
7846 //
7847
7848 // N.B.: a symbol should only be tagged once, and this function is called multiple times, once
7849 // per stage that's used for this profile. So
7850 // - generally, stick common ones in the fragment stage to ensure they are tagged exactly once
7851 // - for ES, which has different precisions for different stages, the coarsest-grained tagging
7852 // for a built-in used in many stages needs to be once for the fragment stage and once for
7853 // the vertex stage
7854
7855 switch(language) {
7856 case EShLangVertex:
7857 if (spvVersion.vulkan > 0) {
7858 BuiltInVariable("gl_VertexIndex", EbvVertexIndex, symbolTable);
7859 BuiltInVariable("gl_InstanceIndex", EbvInstanceIndex, symbolTable);
7860 }
7861
7862 if (spvVersion.vulkan == 0) {
7863 SpecialQualifier("gl_VertexID", EvqVertexId, EbvVertexId, symbolTable);
7864 SpecialQualifier("gl_InstanceID", EvqInstanceId, EbvInstanceId, symbolTable);
7865 if (version < 140)
7866 symbolTable.setVariableExtensions("gl_InstanceID", 1, &E_GL_EXT_draw_instanced);
7867 }
7868
7869 if (spvVersion.vulkan > 0 && spvVersion.vulkanRelaxed) {
7870 // treat these built-ins as aliases of VertexIndex and InstanceIndex
7871 RetargetVariable("gl_InstanceID", "gl_InstanceIndex", symbolTable);
7872 RetargetVariable("gl_VertexID", "gl_VertexIndex", symbolTable);
7873 }
7874
7875 if (profile != EEsProfile) {
7876 if (version >= 440) {
7877 symbolTable.setVariableExtensions("gl_BaseVertexARB", 1, &E_GL_ARB_shader_draw_parameters);
7878 symbolTable.setVariableExtensions("gl_BaseInstanceARB", 1, &E_GL_ARB_shader_draw_parameters);
7879 symbolTable.setVariableExtensions("gl_DrawIDARB", 1, &E_GL_ARB_shader_draw_parameters);
7880 BuiltInVariable("gl_BaseVertexARB", EbvBaseVertex, symbolTable);
7881 BuiltInVariable("gl_BaseInstanceARB", EbvBaseInstance, symbolTable);
7882 BuiltInVariable("gl_DrawIDARB", EbvDrawId, symbolTable);
7883 }
7884 if (version >= 460) {
7885 BuiltInVariable("gl_BaseVertex", EbvBaseVertex, symbolTable);
7886 BuiltInVariable("gl_BaseInstance", EbvBaseInstance, symbolTable);
7887 BuiltInVariable("gl_DrawID", EbvDrawId, symbolTable);
7888 }
7889 symbolTable.setVariableExtensions("gl_SubGroupSizeARB", 1, &E_GL_ARB_shader_ballot);
7890 symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
7891 symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB", 1, &E_GL_ARB_shader_ballot);
7892 symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB", 1, &E_GL_ARB_shader_ballot);
7893 symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB", 1, &E_GL_ARB_shader_ballot);
7894 symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB", 1, &E_GL_ARB_shader_ballot);
7895 symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB", 1, &E_GL_ARB_shader_ballot);
7896
7897 symbolTable.setFunctionExtensions("ballotARB", 1, &E_GL_ARB_shader_ballot);
7898 symbolTable.setFunctionExtensions("readInvocationARB", 1, &E_GL_ARB_shader_ballot);
7899 symbolTable.setFunctionExtensions("readFirstInvocationARB", 1, &E_GL_ARB_shader_ballot);
7900
7901 if (version >= 430) {
7902 symbolTable.setFunctionExtensions("anyInvocationARB", 1, &E_GL_ARB_shader_group_vote);
7903 symbolTable.setFunctionExtensions("allInvocationsARB", 1, &E_GL_ARB_shader_group_vote);
7904 symbolTable.setFunctionExtensions("allInvocationsEqualARB", 1, &E_GL_ARB_shader_group_vote);
7905 }
7906 }
7907
7908
7909 if (profile != EEsProfile) {
7910 symbolTable.setFunctionExtensions("minInvocationsAMD", 1, &E_GL_AMD_shader_ballot);
7911 symbolTable.setFunctionExtensions("maxInvocationsAMD", 1, &E_GL_AMD_shader_ballot);
7912 symbolTable.setFunctionExtensions("addInvocationsAMD", 1, &E_GL_AMD_shader_ballot);
7913 symbolTable.setFunctionExtensions("minInvocationsNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
7914 symbolTable.setFunctionExtensions("maxInvocationsNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
7915 symbolTable.setFunctionExtensions("addInvocationsNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
7916 symbolTable.setFunctionExtensions("swizzleInvocationsAMD", 1, &E_GL_AMD_shader_ballot);
7917 symbolTable.setFunctionExtensions("swizzleInvocationsWithPatternAMD", 1, &E_GL_AMD_shader_ballot);
7918 symbolTable.setFunctionExtensions("writeInvocationAMD", 1, &E_GL_AMD_shader_ballot);
7919 symbolTable.setFunctionExtensions("mbcntAMD", 1, &E_GL_AMD_shader_ballot);
7920
7921 symbolTable.setFunctionExtensions("minInvocationsInclusiveScanAMD", 1, &E_GL_AMD_shader_ballot);
7922 symbolTable.setFunctionExtensions("maxInvocationsInclusiveScanAMD", 1, &E_GL_AMD_shader_ballot);
7923 symbolTable.setFunctionExtensions("addInvocationsInclusiveScanAMD", 1, &E_GL_AMD_shader_ballot);
7924 symbolTable.setFunctionExtensions("minInvocationsInclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
7925 symbolTable.setFunctionExtensions("maxInvocationsInclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
7926 symbolTable.setFunctionExtensions("addInvocationsInclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
7927 symbolTable.setFunctionExtensions("minInvocationsExclusiveScanAMD", 1, &E_GL_AMD_shader_ballot);
7928 symbolTable.setFunctionExtensions("maxInvocationsExclusiveScanAMD", 1, &E_GL_AMD_shader_ballot);
7929 symbolTable.setFunctionExtensions("addInvocationsExclusiveScanAMD", 1, &E_GL_AMD_shader_ballot);
7930 symbolTable.setFunctionExtensions("minInvocationsExclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
7931 symbolTable.setFunctionExtensions("maxInvocationsExclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
7932 symbolTable.setFunctionExtensions("addInvocationsExclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot);
7933 }
7934
7935 if (profile != EEsProfile) {
7936 symbolTable.setFunctionExtensions("min3", 1, &E_GL_AMD_shader_trinary_minmax);
7937 symbolTable.setFunctionExtensions("max3", 1, &E_GL_AMD_shader_trinary_minmax);
7938 symbolTable.setFunctionExtensions("mid3", 1, &E_GL_AMD_shader_trinary_minmax);
7939 }
7940
7941 if (profile != EEsProfile) {
7942 symbolTable.setVariableExtensions("gl_SIMDGroupSizeAMD", 1, &E_GL_AMD_gcn_shader);
7943 SpecialQualifier("gl_SIMDGroupSizeAMD", EvqVaryingIn, EbvSubGroupSize, symbolTable);
7944
7945 symbolTable.setFunctionExtensions("cubeFaceIndexAMD", 1, &E_GL_AMD_gcn_shader);
7946 symbolTable.setFunctionExtensions("cubeFaceCoordAMD", 1, &E_GL_AMD_gcn_shader);
7947 symbolTable.setFunctionExtensions("timeAMD", 1, &E_GL_AMD_gcn_shader);
7948 }
7949
7950 if (profile != EEsProfile) {
7951 symbolTable.setFunctionExtensions("fragmentMaskFetchAMD", 1, &E_GL_AMD_shader_fragment_mask);
7952 symbolTable.setFunctionExtensions("fragmentFetchAMD", 1, &E_GL_AMD_shader_fragment_mask);
7953 }
7954
7955 symbolTable.setFunctionExtensions("countLeadingZeros", 1, &E_GL_INTEL_shader_integer_functions2);
7956 symbolTable.setFunctionExtensions("countTrailingZeros", 1, &E_GL_INTEL_shader_integer_functions2);
7957 symbolTable.setFunctionExtensions("absoluteDifference", 1, &E_GL_INTEL_shader_integer_functions2);
7958 symbolTable.setFunctionExtensions("addSaturate", 1, &E_GL_INTEL_shader_integer_functions2);
7959 symbolTable.setFunctionExtensions("subtractSaturate", 1, &E_GL_INTEL_shader_integer_functions2);
7960 symbolTable.setFunctionExtensions("average", 1, &E_GL_INTEL_shader_integer_functions2);
7961 symbolTable.setFunctionExtensions("averageRounded", 1, &E_GL_INTEL_shader_integer_functions2);
7962 symbolTable.setFunctionExtensions("multiply32x16", 1, &E_GL_INTEL_shader_integer_functions2);
7963
7964 symbolTable.setFunctionExtensions("textureFootprintNV", 1, &E_GL_NV_shader_texture_footprint);
7965 symbolTable.setFunctionExtensions("textureFootprintClampNV", 1, &E_GL_NV_shader_texture_footprint);
7966 symbolTable.setFunctionExtensions("textureFootprintLodNV", 1, &E_GL_NV_shader_texture_footprint);
7967 symbolTable.setFunctionExtensions("textureFootprintGradNV", 1, &E_GL_NV_shader_texture_footprint);
7968 symbolTable.setFunctionExtensions("textureFootprintGradClampNV", 1, &E_GL_NV_shader_texture_footprint);
7969 // Compatibility variables, vertex only
7970 if (spvVersion.spv == 0) {
7971 BuiltInVariable("gl_Color", EbvColor, symbolTable);
7972 BuiltInVariable("gl_SecondaryColor", EbvSecondaryColor, symbolTable);
7973 BuiltInVariable("gl_Normal", EbvNormal, symbolTable);
7974 BuiltInVariable("gl_Vertex", EbvVertex, symbolTable);
7975 BuiltInVariable("gl_MultiTexCoord0", EbvMultiTexCoord0, symbolTable);
7976 BuiltInVariable("gl_MultiTexCoord1", EbvMultiTexCoord1, symbolTable);
7977 BuiltInVariable("gl_MultiTexCoord2", EbvMultiTexCoord2, symbolTable);
7978 BuiltInVariable("gl_MultiTexCoord3", EbvMultiTexCoord3, symbolTable);
7979 BuiltInVariable("gl_MultiTexCoord4", EbvMultiTexCoord4, symbolTable);
7980 BuiltInVariable("gl_MultiTexCoord5", EbvMultiTexCoord5, symbolTable);
7981 BuiltInVariable("gl_MultiTexCoord6", EbvMultiTexCoord6, symbolTable);
7982 BuiltInVariable("gl_MultiTexCoord7", EbvMultiTexCoord7, symbolTable);
7983 BuiltInVariable("gl_FogCoord", EbvFogFragCoord, symbolTable);
7984 }
7985
7986 if (profile == EEsProfile) {
7987 if (spvVersion.spv == 0) {
7988 symbolTable.setFunctionExtensions("texture2DGradEXT", 1, &E_GL_EXT_shader_texture_lod);
7989 symbolTable.setFunctionExtensions("texture2DProjGradEXT", 1, &E_GL_EXT_shader_texture_lod);
7990 symbolTable.setFunctionExtensions("textureCubeGradEXT", 1, &E_GL_EXT_shader_texture_lod);
7991 if (version == 310)
7992 symbolTable.setFunctionExtensions("textureGatherOffsets", Num_AEP_gpu_shader5, AEP_gpu_shader5);
7993 }
7994 if (version == 310)
7995 symbolTable.setFunctionExtensions("fma", Num_AEP_gpu_shader5, AEP_gpu_shader5);
7996 }
7997
7998 if (profile == EEsProfile && version < 320) {
7999 symbolTable.setFunctionExtensions("imageAtomicAdd", 1, &E_GL_OES_shader_image_atomic);
8000 symbolTable.setFunctionExtensions("imageAtomicMin", 1, &E_GL_OES_shader_image_atomic);
8001 symbolTable.setFunctionExtensions("imageAtomicMax", 1, &E_GL_OES_shader_image_atomic);
8002 symbolTable.setFunctionExtensions("imageAtomicAnd", 1, &E_GL_OES_shader_image_atomic);
8003 symbolTable.setFunctionExtensions("imageAtomicOr", 1, &E_GL_OES_shader_image_atomic);
8004 symbolTable.setFunctionExtensions("imageAtomicXor", 1, &E_GL_OES_shader_image_atomic);
8005 symbolTable.setFunctionExtensions("imageAtomicExchange", 1, &E_GL_OES_shader_image_atomic);
8006 symbolTable.setFunctionExtensions("imageAtomicCompSwap", 1, &E_GL_OES_shader_image_atomic);
8007 }
8008
8009 if (version >= 300 /* both ES and non-ES */) {
8010 symbolTable.setVariableExtensions("gl_ViewID_OVR", Num_OVR_multiview_EXTs, OVR_multiview_EXTs);
8011 BuiltInVariable("gl_ViewID_OVR", EbvViewIndex, symbolTable);
8012 }
8013
8014 if (profile == EEsProfile) {
8015 symbolTable.setFunctionExtensions("shadow2DEXT", 1, &E_GL_EXT_shadow_samplers);
8016 symbolTable.setFunctionExtensions("shadow2DProjEXT", 1, &E_GL_EXT_shadow_samplers);
8017 }
8018
8019 // E_GL_EXT_texture_array
8020 if (profile != EEsProfile && spvVersion.spv == 0) {
8021 symbolTable.setFunctionExtensions("texture1DArray", 1, &E_GL_EXT_texture_array);
8022 symbolTable.setFunctionExtensions("texture2DArray", 1, &E_GL_EXT_texture_array);
8023 symbolTable.setFunctionExtensions("shadow1DArray", 1, &E_GL_EXT_texture_array);
8024 symbolTable.setFunctionExtensions("shadow2DArray", 1, &E_GL_EXT_texture_array);
8025
8026 symbolTable.setFunctionExtensions("texture1DArrayLod", 1, &E_GL_EXT_texture_array);
8027 symbolTable.setFunctionExtensions("texture2DArrayLod", 1, &E_GL_EXT_texture_array);
8028 symbolTable.setFunctionExtensions("shadow1DArrayLod", 1, &E_GL_EXT_texture_array);
8029 }
8030 // Fall through
8031
8032 case EShLangTessControl:
8033 if (profile == EEsProfile && version >= 310) {
8034 BuiltInVariable("gl_BoundingBoxEXT", EbvBoundingBox, symbolTable);
8035 symbolTable.setVariableExtensions("gl_BoundingBoxEXT", 1,
8036 &E_GL_EXT_primitive_bounding_box);
8037 BuiltInVariable("gl_BoundingBoxOES", EbvBoundingBox, symbolTable);
8038 symbolTable.setVariableExtensions("gl_BoundingBoxOES", 1,
8039 &E_GL_OES_primitive_bounding_box);
8040
8041 if (version >= 320) {
8042 BuiltInVariable("gl_BoundingBox", EbvBoundingBox, symbolTable);
8043 }
8044 }
8045 // Fall through
8046
8047 case EShLangTessEvaluation:
8048 case EShLangGeometry:
8049 SpecialQualifier("gl_Position", EvqPosition, EbvPosition, symbolTable);
8050 SpecialQualifier("gl_PointSize", EvqPointSize, EbvPointSize, symbolTable);
8051
8052 BuiltInVariable("gl_in", "gl_Position", EbvPosition, symbolTable);
8053 BuiltInVariable("gl_in", "gl_PointSize", EbvPointSize, symbolTable);
8054
8055 BuiltInVariable("gl_out", "gl_Position", EbvPosition, symbolTable);
8056 BuiltInVariable("gl_out", "gl_PointSize", EbvPointSize, symbolTable);
8057
8058 SpecialQualifier("gl_ClipVertex", EvqClipVertex, EbvClipVertex, symbolTable);
8059
8060 BuiltInVariable("gl_in", "gl_ClipDistance", EbvClipDistance, symbolTable);
8061 BuiltInVariable("gl_in", "gl_CullDistance", EbvCullDistance, symbolTable);
8062
8063 BuiltInVariable("gl_out", "gl_ClipDistance", EbvClipDistance, symbolTable);
8064 BuiltInVariable("gl_out", "gl_CullDistance", EbvCullDistance, symbolTable);
8065
8066 BuiltInVariable("gl_ClipDistance", EbvClipDistance, symbolTable);
8067 BuiltInVariable("gl_CullDistance", EbvCullDistance, symbolTable);
8068 BuiltInVariable("gl_PrimitiveIDIn", EbvPrimitiveId, symbolTable);
8069 BuiltInVariable("gl_PrimitiveID", EbvPrimitiveId, symbolTable);
8070 BuiltInVariable("gl_InvocationID", EbvInvocationId, symbolTable);
8071 BuiltInVariable("gl_Layer", EbvLayer, symbolTable);
8072 BuiltInVariable("gl_ViewportIndex", EbvViewportIndex, symbolTable);
8073
8074 if (language != EShLangGeometry) {
8075 symbolTable.setVariableExtensions("gl_Layer", Num_viewportEXTs, viewportEXTs);
8076 symbolTable.setVariableExtensions("gl_ViewportIndex", Num_viewportEXTs, viewportEXTs);
8077 }
8078 symbolTable.setVariableExtensions("gl_ViewportMask", 1, &E_GL_NV_viewport_array2);
8079 symbolTable.setVariableExtensions("gl_SecondaryPositionNV", 1, &E_GL_NV_stereo_view_rendering);
8080 symbolTable.setVariableExtensions("gl_SecondaryViewportMaskNV", 1, &E_GL_NV_stereo_view_rendering);
8081 symbolTable.setVariableExtensions("gl_PositionPerViewNV", 1, &E_GL_NVX_multiview_per_view_attributes);
8082 symbolTable.setVariableExtensions("gl_ViewportMaskPerViewNV", 1, &E_GL_NVX_multiview_per_view_attributes);
8083
8084 BuiltInVariable("gl_ViewportMask", EbvViewportMaskNV, symbolTable);
8085 BuiltInVariable("gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable);
8086 BuiltInVariable("gl_SecondaryViewportMaskNV", EbvSecondaryViewportMaskNV, symbolTable);
8087 BuiltInVariable("gl_PositionPerViewNV", EbvPositionPerViewNV, symbolTable);
8088 BuiltInVariable("gl_ViewportMaskPerViewNV", EbvViewportMaskPerViewNV, symbolTable);
8089
8090 if (language == EShLangVertex || language == EShLangGeometry) {
8091 symbolTable.setVariableExtensions("gl_in", "gl_SecondaryPositionNV", 1, &E_GL_NV_stereo_view_rendering);
8092 symbolTable.setVariableExtensions("gl_in", "gl_PositionPerViewNV", 1, &E_GL_NVX_multiview_per_view_attributes);
8093
8094 BuiltInVariable("gl_in", "gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable);
8095 BuiltInVariable("gl_in", "gl_PositionPerViewNV", EbvPositionPerViewNV, symbolTable);
8096 }
8097 symbolTable.setVariableExtensions("gl_out", "gl_ViewportMask", 1, &E_GL_NV_viewport_array2);
8098 symbolTable.setVariableExtensions("gl_out", "gl_SecondaryPositionNV", 1, &E_GL_NV_stereo_view_rendering);
8099 symbolTable.setVariableExtensions("gl_out", "gl_SecondaryViewportMaskNV", 1, &E_GL_NV_stereo_view_rendering);
8100 symbolTable.setVariableExtensions("gl_out", "gl_PositionPerViewNV", 1, &E_GL_NVX_multiview_per_view_attributes);
8101 symbolTable.setVariableExtensions("gl_out", "gl_ViewportMaskPerViewNV", 1, &E_GL_NVX_multiview_per_view_attributes);
8102
8103 BuiltInVariable("gl_out", "gl_ViewportMask", EbvViewportMaskNV, symbolTable);
8104 BuiltInVariable("gl_out", "gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable);
8105 BuiltInVariable("gl_out", "gl_SecondaryViewportMaskNV", EbvSecondaryViewportMaskNV, symbolTable);
8106 BuiltInVariable("gl_out", "gl_PositionPerViewNV", EbvPositionPerViewNV, symbolTable);
8107 BuiltInVariable("gl_out", "gl_ViewportMaskPerViewNV", EbvViewportMaskPerViewNV, symbolTable);
8108
8109 BuiltInVariable("gl_PatchVerticesIn", EbvPatchVertices, symbolTable);
8110 BuiltInVariable("gl_TessLevelOuter", EbvTessLevelOuter, symbolTable);
8111 BuiltInVariable("gl_TessLevelInner", EbvTessLevelInner, symbolTable);
8112 BuiltInVariable("gl_TessCoord", EbvTessCoord, symbolTable);
8113
8114 if (version < 410)
8115 symbolTable.setVariableExtensions("gl_ViewportIndex", 1, &E_GL_ARB_viewport_array);
8116
8117 // Compatibility variables
8118
8119 BuiltInVariable("gl_in", "gl_ClipVertex", EbvClipVertex, symbolTable);
8120 BuiltInVariable("gl_in", "gl_FrontColor", EbvFrontColor, symbolTable);
8121 BuiltInVariable("gl_in", "gl_BackColor", EbvBackColor, symbolTable);
8122 BuiltInVariable("gl_in", "gl_FrontSecondaryColor", EbvFrontSecondaryColor, symbolTable);
8123 BuiltInVariable("gl_in", "gl_BackSecondaryColor", EbvBackSecondaryColor, symbolTable);
8124 BuiltInVariable("gl_in", "gl_TexCoord", EbvTexCoord, symbolTable);
8125 BuiltInVariable("gl_in", "gl_FogFragCoord", EbvFogFragCoord, symbolTable);
8126
8127 BuiltInVariable("gl_out", "gl_ClipVertex", EbvClipVertex, symbolTable);
8128 BuiltInVariable("gl_out", "gl_FrontColor", EbvFrontColor, symbolTable);
8129 BuiltInVariable("gl_out", "gl_BackColor", EbvBackColor, symbolTable);
8130 BuiltInVariable("gl_out", "gl_FrontSecondaryColor", EbvFrontSecondaryColor, symbolTable);
8131 BuiltInVariable("gl_out", "gl_BackSecondaryColor", EbvBackSecondaryColor, symbolTable);
8132 BuiltInVariable("gl_out", "gl_TexCoord", EbvTexCoord, symbolTable);
8133 BuiltInVariable("gl_out", "gl_FogFragCoord", EbvFogFragCoord, symbolTable);
8134
8135 BuiltInVariable("gl_ClipVertex", EbvClipVertex, symbolTable);
8136 BuiltInVariable("gl_FrontColor", EbvFrontColor, symbolTable);
8137 BuiltInVariable("gl_BackColor", EbvBackColor, symbolTable);
8138 BuiltInVariable("gl_FrontSecondaryColor", EbvFrontSecondaryColor, symbolTable);
8139 BuiltInVariable("gl_BackSecondaryColor", EbvBackSecondaryColor, symbolTable);
8140 BuiltInVariable("gl_TexCoord", EbvTexCoord, symbolTable);
8141 BuiltInVariable("gl_FogFragCoord", EbvFogFragCoord, symbolTable);
8142
8143 // gl_PointSize, when it needs to be tied to an extension, is always a member of a block.
8144 // (Sometimes with an instance name, sometimes anonymous).
8145 if (profile == EEsProfile) {
8146 if (language == EShLangGeometry) {
8147 symbolTable.setVariableExtensions("gl_PointSize", Num_AEP_geometry_point_size, AEP_geometry_point_size);
8148 symbolTable.setVariableExtensions("gl_in", "gl_PointSize", Num_AEP_geometry_point_size, AEP_geometry_point_size);
8149 } else if (language == EShLangTessEvaluation || language == EShLangTessControl) {
8150 // gl_in tessellation settings of gl_PointSize are in the context-dependent paths
8151 symbolTable.setVariableExtensions("gl_PointSize", Num_AEP_tessellation_point_size, AEP_tessellation_point_size);
8152 symbolTable.setVariableExtensions("gl_out", "gl_PointSize", Num_AEP_tessellation_point_size, AEP_tessellation_point_size);
8153 }
8154 }
8155
8156 if ((profile != EEsProfile && version >= 140) ||
8157 (profile == EEsProfile && version >= 310)) {
8158 symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
8159 BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
8160 symbolTable.setVariableExtensions("gl_ViewIndex", 1, &E_GL_EXT_multiview);
8161 BuiltInVariable("gl_ViewIndex", EbvViewIndex, symbolTable);
8162 }
8163
8164 if (profile != EEsProfile) {
8165 BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
8166 BuiltInVariable("gl_SubGroupEqMaskARB", EbvSubGroupEqMask, symbolTable);
8167 BuiltInVariable("gl_SubGroupGeMaskARB", EbvSubGroupGeMask, symbolTable);
8168 BuiltInVariable("gl_SubGroupGtMaskARB", EbvSubGroupGtMask, symbolTable);
8169 BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
8170 BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
8171
8172 if (spvVersion.vulkan > 0) {
8173 // Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
8174 SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
8175 if (language == EShLangFragment)
8176 ModifyFlatDecoration("gl_SubGroupSizeARB", true, symbolTable);
8177 }
8178 else
8179 BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
8180 }
8181
8182 // GL_KHR_shader_subgroup
8183 if ((profile == EEsProfile && version >= 310) ||
8184 (profile != EEsProfile && version >= 140)) {
8185 symbolTable.setVariableExtensions("gl_SubgroupSize", 1, &E_GL_KHR_shader_subgroup_basic);
8186 symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
8187 symbolTable.setVariableExtensions("gl_SubgroupEqMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8188 symbolTable.setVariableExtensions("gl_SubgroupGeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8189 symbolTable.setVariableExtensions("gl_SubgroupGtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8190 symbolTable.setVariableExtensions("gl_SubgroupLeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8191 symbolTable.setVariableExtensions("gl_SubgroupLtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8192
8193 BuiltInVariable("gl_SubgroupSize", EbvSubgroupSize2, symbolTable);
8194 BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
8195 BuiltInVariable("gl_SubgroupEqMask", EbvSubgroupEqMask2, symbolTable);
8196 BuiltInVariable("gl_SubgroupGeMask", EbvSubgroupGeMask2, symbolTable);
8197 BuiltInVariable("gl_SubgroupGtMask", EbvSubgroupGtMask2, symbolTable);
8198 BuiltInVariable("gl_SubgroupLeMask", EbvSubgroupLeMask2, symbolTable);
8199 BuiltInVariable("gl_SubgroupLtMask", EbvSubgroupLtMask2, symbolTable);
8200
8201 // GL_NV_shader_sm_builtins
8202 symbolTable.setVariableExtensions("gl_WarpsPerSMNV", 1, &E_GL_NV_shader_sm_builtins);
8203 symbolTable.setVariableExtensions("gl_SMCountNV", 1, &E_GL_NV_shader_sm_builtins);
8204 symbolTable.setVariableExtensions("gl_WarpIDNV", 1, &E_GL_NV_shader_sm_builtins);
8205 symbolTable.setVariableExtensions("gl_SMIDNV", 1, &E_GL_NV_shader_sm_builtins);
8206 BuiltInVariable("gl_WarpsPerSMNV", EbvWarpsPerSM, symbolTable);
8207 BuiltInVariable("gl_SMCountNV", EbvSMCount, symbolTable);
8208 BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable);
8209 BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable);
8210
8211 // GL_ARM_shader_core_builtins
8212 symbolTable.setVariableExtensions("gl_CoreCountARM", 1, &E_GL_ARM_shader_core_builtins);
8213 symbolTable.setVariableExtensions("gl_CoreIDARM", 1, &E_GL_ARM_shader_core_builtins);
8214 symbolTable.setVariableExtensions("gl_CoreMaxIDARM", 1, &E_GL_ARM_shader_core_builtins);
8215 symbolTable.setVariableExtensions("gl_WarpIDARM", 1, &E_GL_ARM_shader_core_builtins);
8216 symbolTable.setVariableExtensions("gl_WarpMaxIDARM", 1, &E_GL_ARM_shader_core_builtins);
8217
8218 BuiltInVariable("gl_CoreCountARM", EbvCoreCountARM, symbolTable);
8219 BuiltInVariable("gl_CoreIDARM", EbvCoreIDARM, symbolTable);
8220 BuiltInVariable("gl_CoreMaxIDARM", EbvCoreMaxIDARM, symbolTable);
8221 BuiltInVariable("gl_WarpIDARM", EbvWarpIDARM, symbolTable);
8222 BuiltInVariable("gl_WarpMaxIDARM", EbvWarpMaxIDARM, symbolTable);
8223 }
8224
8225 if (language == EShLangGeometry || language == EShLangVertex) {
8226 if ((profile == EEsProfile && version >= 310) ||
8227 (profile != EEsProfile && version >= 450)) {
8228 symbolTable.setVariableExtensions("gl_PrimitiveShadingRateEXT", 1, &E_GL_EXT_fragment_shading_rate);
8229 BuiltInVariable("gl_PrimitiveShadingRateEXT", EbvPrimitiveShadingRateKHR, symbolTable);
8230
8231 symbolTable.setVariableExtensions("gl_ShadingRateFlag2VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8232 symbolTable.setVariableExtensions("gl_ShadingRateFlag4VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8233 symbolTable.setVariableExtensions("gl_ShadingRateFlag2HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8234 symbolTable.setVariableExtensions("gl_ShadingRateFlag4HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8235 }
8236 }
8237 break;
8238
8239 case EShLangFragment:
8240 SpecialQualifier("gl_FrontFacing", EvqFace, EbvFace, symbolTable);
8241 SpecialQualifier("gl_FragCoord", EvqFragCoord, EbvFragCoord, symbolTable);
8242 SpecialQualifier("gl_PointCoord", EvqPointCoord, EbvPointCoord, symbolTable);
8243 if (spvVersion.spv == 0)
8244 SpecialQualifier("gl_FragColor", EvqFragColor, EbvFragColor, symbolTable);
8245 else {
8246 TSymbol* symbol = symbolTable.find("gl_FragColor");
8247 if (symbol) {
8248 symbol->getWritableType().getQualifier().storage = EvqVaryingOut;
8249 symbol->getWritableType().getQualifier().layoutLocation = 0;
8250 }
8251 }
8252 SpecialQualifier("gl_FragDepth", EvqFragDepth, EbvFragDepth, symbolTable);
8253 SpecialQualifier("gl_FragDepthEXT", EvqFragDepth, EbvFragDepth, symbolTable);
8254 SpecialQualifier("gl_FragStencilRefARB", EvqFragStencil, EbvFragStencilRef, symbolTable);
8255 SpecialQualifier("gl_HelperInvocation", EvqVaryingIn, EbvHelperInvocation, symbolTable);
8256
8257 BuiltInVariable("gl_ClipDistance", EbvClipDistance, symbolTable);
8258 BuiltInVariable("gl_CullDistance", EbvCullDistance, symbolTable);
8259 BuiltInVariable("gl_PrimitiveID", EbvPrimitiveId, symbolTable);
8260
8261 if (profile != EEsProfile && version >= 140) {
8262 symbolTable.setVariableExtensions("gl_FragStencilRefARB", 1, &E_GL_ARB_shader_stencil_export);
8263 BuiltInVariable("gl_FragStencilRefARB", EbvFragStencilRef, symbolTable);
8264 }
8265
8266 if (profile != EEsProfile && version < 400) {
8267 symbolTable.setFunctionExtensions("textureQueryLOD", 1, &E_GL_ARB_texture_query_lod);
8268 }
8269
8270 if (profile != EEsProfile && version >= 460) {
8271 symbolTable.setFunctionExtensions("rayQueryInitializeEXT", 1, &E_GL_EXT_ray_query);
8272 symbolTable.setFunctionExtensions("rayQueryTerminateEXT", 1, &E_GL_EXT_ray_query);
8273 symbolTable.setFunctionExtensions("rayQueryGenerateIntersectionEXT", 1, &E_GL_EXT_ray_query);
8274 symbolTable.setFunctionExtensions("rayQueryConfirmIntersectionEXT", 1, &E_GL_EXT_ray_query);
8275 symbolTable.setFunctionExtensions("rayQueryProceedEXT", 1, &E_GL_EXT_ray_query);
8276 symbolTable.setFunctionExtensions("rayQueryGetIntersectionTypeEXT", 1, &E_GL_EXT_ray_query);
8277 symbolTable.setFunctionExtensions("rayQueryGetIntersectionTEXT", 1, &E_GL_EXT_ray_query);
8278 symbolTable.setFunctionExtensions("rayQueryGetRayFlagsEXT", 1, &E_GL_EXT_ray_query);
8279 symbolTable.setFunctionExtensions("rayQueryGetRayTMinEXT", 1, &E_GL_EXT_ray_query);
8280 symbolTable.setFunctionExtensions("rayQueryGetIntersectionInstanceCustomIndexEXT", 1, &E_GL_EXT_ray_query);
8281 symbolTable.setFunctionExtensions("rayQueryGetIntersectionInstanceIdEXT", 1, &E_GL_EXT_ray_query);
8282 symbolTable.setFunctionExtensions("rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT", 1, &E_GL_EXT_ray_query);
8283 symbolTable.setFunctionExtensions("rayQueryGetIntersectionGeometryIndexEXT", 1, &E_GL_EXT_ray_query);
8284 symbolTable.setFunctionExtensions("rayQueryGetIntersectionPrimitiveIndexEXT", 1, &E_GL_EXT_ray_query);
8285 symbolTable.setFunctionExtensions("rayQueryGetIntersectionBarycentricsEXT", 1, &E_GL_EXT_ray_query);
8286 symbolTable.setFunctionExtensions("rayQueryGetIntersectionFrontFaceEXT", 1, &E_GL_EXT_ray_query);
8287 symbolTable.setFunctionExtensions("rayQueryGetIntersectionCandidateAABBOpaqueEXT", 1, &E_GL_EXT_ray_query);
8288 symbolTable.setFunctionExtensions("rayQueryGetIntersectionObjectRayDirectionEXT", 1, &E_GL_EXT_ray_query);
8289 symbolTable.setFunctionExtensions("rayQueryGetIntersectionObjectRayOriginEXT", 1, &E_GL_EXT_ray_query);
8290 symbolTable.setFunctionExtensions("rayQueryGetIntersectionObjectToWorldEXT", 1, &E_GL_EXT_ray_query);
8291 symbolTable.setFunctionExtensions("rayQueryGetIntersectionWorldToObjectEXT", 1, &E_GL_EXT_ray_query);
8292 symbolTable.setFunctionExtensions("rayQueryGetWorldRayOriginEXT", 1, &E_GL_EXT_ray_query);
8293 symbolTable.setFunctionExtensions("rayQueryGetWorldRayDirectionEXT", 1, &E_GL_EXT_ray_query);
8294 symbolTable.setFunctionExtensions("rayQueryGetIntersectionTriangleVertexPositionsEXT", 1, &E_GL_EXT_ray_tracing_position_fetch);
8295 symbolTable.setVariableExtensions("gl_RayFlagsSkipAABBEXT", 1, &E_GL_EXT_ray_flags_primitive_culling);
8296 symbolTable.setVariableExtensions("gl_RayFlagsSkipTrianglesEXT", 1, &E_GL_EXT_ray_flags_primitive_culling);
8297 symbolTable.setVariableExtensions("gl_RayFlagsForceOpacityMicromap2StateEXT", 1, &E_GL_EXT_opacity_micromap);
8298 }
8299
8300 if ((profile != EEsProfile && version >= 130) ||
8301 (profile == EEsProfile && version >= 310)) {
8302 BuiltInVariable("gl_SampleID", EbvSampleId, symbolTable);
8303 BuiltInVariable("gl_SamplePosition", EbvSamplePosition, symbolTable);
8304 BuiltInVariable("gl_SampleMask", EbvSampleMask, symbolTable);
8305
8306 if (profile != EEsProfile && version < 400) {
8307 BuiltInVariable("gl_NumSamples", EbvSampleMask, symbolTable);
8308
8309 symbolTable.setVariableExtensions("gl_SampleMask", 1, &E_GL_ARB_sample_shading);
8310 symbolTable.setVariableExtensions("gl_SampleID", 1, &E_GL_ARB_sample_shading);
8311 symbolTable.setVariableExtensions("gl_SamplePosition", 1, &E_GL_ARB_sample_shading);
8312 symbolTable.setVariableExtensions("gl_NumSamples", 1, &E_GL_ARB_sample_shading);
8313 } else {
8314 BuiltInVariable("gl_SampleMaskIn", EbvSampleMask, symbolTable);
8315
8316 if (profile == EEsProfile && version < 320) {
8317 symbolTable.setVariableExtensions("gl_SampleID", 1, &E_GL_OES_sample_variables);
8318 symbolTable.setVariableExtensions("gl_SamplePosition", 1, &E_GL_OES_sample_variables);
8319 symbolTable.setVariableExtensions("gl_SampleMaskIn", 1, &E_GL_OES_sample_variables);
8320 symbolTable.setVariableExtensions("gl_SampleMask", 1, &E_GL_OES_sample_variables);
8321 symbolTable.setVariableExtensions("gl_NumSamples", 1, &E_GL_OES_sample_variables);
8322 }
8323 }
8324 }
8325
8326 BuiltInVariable("gl_Layer", EbvLayer, symbolTable);
8327 BuiltInVariable("gl_ViewportIndex", EbvViewportIndex, symbolTable);
8328
8329 // Compatibility variables
8330
8331 BuiltInVariable("gl_in", "gl_FogFragCoord", EbvFogFragCoord, symbolTable);
8332 BuiltInVariable("gl_in", "gl_TexCoord", EbvTexCoord, symbolTable);
8333 BuiltInVariable("gl_in", "gl_Color", EbvColor, symbolTable);
8334 BuiltInVariable("gl_in", "gl_SecondaryColor", EbvSecondaryColor, symbolTable);
8335
8336 BuiltInVariable("gl_FogFragCoord", EbvFogFragCoord, symbolTable);
8337 BuiltInVariable("gl_TexCoord", EbvTexCoord, symbolTable);
8338 BuiltInVariable("gl_Color", EbvColor, symbolTable);
8339 BuiltInVariable("gl_SecondaryColor", EbvSecondaryColor, symbolTable);
8340
8341 // built-in functions
8342
8343 if (profile == EEsProfile) {
8344 if (spvVersion.spv == 0) {
8345 symbolTable.setFunctionExtensions("texture2DLodEXT", 1, &E_GL_EXT_shader_texture_lod);
8346 symbolTable.setFunctionExtensions("texture2DProjLodEXT", 1, &E_GL_EXT_shader_texture_lod);
8347 symbolTable.setFunctionExtensions("textureCubeLodEXT", 1, &E_GL_EXT_shader_texture_lod);
8348 symbolTable.setFunctionExtensions("texture2DGradEXT", 1, &E_GL_EXT_shader_texture_lod);
8349 symbolTable.setFunctionExtensions("texture2DProjGradEXT", 1, &E_GL_EXT_shader_texture_lod);
8350 symbolTable.setFunctionExtensions("textureCubeGradEXT", 1, &E_GL_EXT_shader_texture_lod);
8351 if (version < 320)
8352 symbolTable.setFunctionExtensions("textureGatherOffsets", Num_AEP_gpu_shader5, AEP_gpu_shader5);
8353 }
8354 if (version == 100) {
8355 symbolTable.setFunctionExtensions("dFdx", 1, &E_GL_OES_standard_derivatives);
8356 symbolTable.setFunctionExtensions("dFdy", 1, &E_GL_OES_standard_derivatives);
8357 symbolTable.setFunctionExtensions("fwidth", 1, &E_GL_OES_standard_derivatives);
8358 }
8359 if (version == 310) {
8360 symbolTable.setFunctionExtensions("fma", Num_AEP_gpu_shader5, AEP_gpu_shader5);
8361 symbolTable.setFunctionExtensions("interpolateAtCentroid", 1, &E_GL_OES_shader_multisample_interpolation);
8362 symbolTable.setFunctionExtensions("interpolateAtSample", 1, &E_GL_OES_shader_multisample_interpolation);
8363 symbolTable.setFunctionExtensions("interpolateAtOffset", 1, &E_GL_OES_shader_multisample_interpolation);
8364 }
8365 } else if (version < 130) {
8366 if (spvVersion.spv == 0) {
8367 symbolTable.setFunctionExtensions("texture1DLod", 1, &E_GL_ARB_shader_texture_lod);
8368 symbolTable.setFunctionExtensions("texture2DLod", 1, &E_GL_ARB_shader_texture_lod);
8369 symbolTable.setFunctionExtensions("texture3DLod", 1, &E_GL_ARB_shader_texture_lod);
8370 symbolTable.setFunctionExtensions("textureCubeLod", 1, &E_GL_ARB_shader_texture_lod);
8371 symbolTable.setFunctionExtensions("texture1DProjLod", 1, &E_GL_ARB_shader_texture_lod);
8372 symbolTable.setFunctionExtensions("texture2DProjLod", 1, &E_GL_ARB_shader_texture_lod);
8373 symbolTable.setFunctionExtensions("texture3DProjLod", 1, &E_GL_ARB_shader_texture_lod);
8374 symbolTable.setFunctionExtensions("shadow1DLod", 1, &E_GL_ARB_shader_texture_lod);
8375 symbolTable.setFunctionExtensions("shadow2DLod", 1, &E_GL_ARB_shader_texture_lod);
8376 symbolTable.setFunctionExtensions("shadow1DProjLod", 1, &E_GL_ARB_shader_texture_lod);
8377 symbolTable.setFunctionExtensions("shadow2DProjLod", 1, &E_GL_ARB_shader_texture_lod);
8378 }
8379 }
8380
8381 // E_GL_ARB_shader_texture_lod functions usable only with the extension enabled
8382 if (profile != EEsProfile && spvVersion.spv == 0) {
8383 symbolTable.setFunctionExtensions("texture1DGradARB", 1, &E_GL_ARB_shader_texture_lod);
8384 symbolTable.setFunctionExtensions("texture1DProjGradARB", 1, &E_GL_ARB_shader_texture_lod);
8385 symbolTable.setFunctionExtensions("texture2DGradARB", 1, &E_GL_ARB_shader_texture_lod);
8386 symbolTable.setFunctionExtensions("texture2DProjGradARB", 1, &E_GL_ARB_shader_texture_lod);
8387 symbolTable.setFunctionExtensions("texture3DGradARB", 1, &E_GL_ARB_shader_texture_lod);
8388 symbolTable.setFunctionExtensions("texture3DProjGradARB", 1, &E_GL_ARB_shader_texture_lod);
8389 symbolTable.setFunctionExtensions("textureCubeGradARB", 1, &E_GL_ARB_shader_texture_lod);
8390 symbolTable.setFunctionExtensions("shadow1DGradARB", 1, &E_GL_ARB_shader_texture_lod);
8391 symbolTable.setFunctionExtensions("shadow1DProjGradARB", 1, &E_GL_ARB_shader_texture_lod);
8392 symbolTable.setFunctionExtensions("shadow2DGradARB", 1, &E_GL_ARB_shader_texture_lod);
8393 symbolTable.setFunctionExtensions("shadow2DProjGradARB", 1, &E_GL_ARB_shader_texture_lod);
8394 symbolTable.setFunctionExtensions("texture2DRectGradARB", 1, &E_GL_ARB_shader_texture_lod);
8395 symbolTable.setFunctionExtensions("texture2DRectProjGradARB", 1, &E_GL_ARB_shader_texture_lod);
8396 symbolTable.setFunctionExtensions("shadow2DRectGradARB", 1, &E_GL_ARB_shader_texture_lod);
8397 symbolTable.setFunctionExtensions("shadow2DRectProjGradARB", 1, &E_GL_ARB_shader_texture_lod);
8398 }
8399
8400 // E_GL_ARB_shader_image_load_store
8401 if (profile != EEsProfile && version < 420)
8402 symbolTable.setFunctionExtensions("memoryBarrier", 1, &E_GL_ARB_shader_image_load_store);
8403 // All the image access functions are protected by checks on the type of the first argument.
8404
8405 // E_GL_ARB_shader_atomic_counters
8406 if (profile != EEsProfile && version < 420) {
8407 symbolTable.setFunctionExtensions("atomicCounterIncrement", 1, &E_GL_ARB_shader_atomic_counters);
8408 symbolTable.setFunctionExtensions("atomicCounterDecrement", 1, &E_GL_ARB_shader_atomic_counters);
8409 symbolTable.setFunctionExtensions("atomicCounter" , 1, &E_GL_ARB_shader_atomic_counters);
8410 }
8411
8412 // E_GL_ARB_shader_atomic_counter_ops
8413 if (profile != EEsProfile && version == 450) {
8414 symbolTable.setFunctionExtensions("atomicCounterAddARB" , 1, &E_GL_ARB_shader_atomic_counter_ops);
8415 symbolTable.setFunctionExtensions("atomicCounterSubtractARB", 1, &E_GL_ARB_shader_atomic_counter_ops);
8416 symbolTable.setFunctionExtensions("atomicCounterMinARB" , 1, &E_GL_ARB_shader_atomic_counter_ops);
8417 symbolTable.setFunctionExtensions("atomicCounterMaxARB" , 1, &E_GL_ARB_shader_atomic_counter_ops);
8418 symbolTable.setFunctionExtensions("atomicCounterAndARB" , 1, &E_GL_ARB_shader_atomic_counter_ops);
8419 symbolTable.setFunctionExtensions("atomicCounterOrARB" , 1, &E_GL_ARB_shader_atomic_counter_ops);
8420 symbolTable.setFunctionExtensions("atomicCounterXorARB" , 1, &E_GL_ARB_shader_atomic_counter_ops);
8421 symbolTable.setFunctionExtensions("atomicCounterExchangeARB", 1, &E_GL_ARB_shader_atomic_counter_ops);
8422 symbolTable.setFunctionExtensions("atomicCounterCompSwapARB", 1, &E_GL_ARB_shader_atomic_counter_ops);
8423 }
8424
8425 // E_GL_ARB_derivative_control
8426 if (profile != EEsProfile && version < 450) {
8427 symbolTable.setFunctionExtensions("dFdxFine", 1, &E_GL_ARB_derivative_control);
8428 symbolTable.setFunctionExtensions("dFdyFine", 1, &E_GL_ARB_derivative_control);
8429 symbolTable.setFunctionExtensions("fwidthFine", 1, &E_GL_ARB_derivative_control);
8430 symbolTable.setFunctionExtensions("dFdxCoarse", 1, &E_GL_ARB_derivative_control);
8431 symbolTable.setFunctionExtensions("dFdyCoarse", 1, &E_GL_ARB_derivative_control);
8432 symbolTable.setFunctionExtensions("fwidthCoarse", 1, &E_GL_ARB_derivative_control);
8433 }
8434
8435 // E_GL_ARB_sparse_texture2
8436 if (profile != EEsProfile)
8437 {
8438 symbolTable.setFunctionExtensions("sparseTextureARB", 1, &E_GL_ARB_sparse_texture2);
8439 symbolTable.setFunctionExtensions("sparseTextureLodARB", 1, &E_GL_ARB_sparse_texture2);
8440 symbolTable.setFunctionExtensions("sparseTextureOffsetARB", 1, &E_GL_ARB_sparse_texture2);
8441 symbolTable.setFunctionExtensions("sparseTexelFetchARB", 1, &E_GL_ARB_sparse_texture2);
8442 symbolTable.setFunctionExtensions("sparseTexelFetchOffsetARB", 1, &E_GL_ARB_sparse_texture2);
8443 symbolTable.setFunctionExtensions("sparseTextureLodOffsetARB", 1, &E_GL_ARB_sparse_texture2);
8444 symbolTable.setFunctionExtensions("sparseTextureGradARB", 1, &E_GL_ARB_sparse_texture2);
8445 symbolTable.setFunctionExtensions("sparseTextureGradOffsetARB", 1, &E_GL_ARB_sparse_texture2);
8446 symbolTable.setFunctionExtensions("sparseTextureGatherARB", 1, &E_GL_ARB_sparse_texture2);
8447 symbolTable.setFunctionExtensions("sparseTextureGatherOffsetARB", 1, &E_GL_ARB_sparse_texture2);
8448 symbolTable.setFunctionExtensions("sparseTextureGatherOffsetsARB", 1, &E_GL_ARB_sparse_texture2);
8449 symbolTable.setFunctionExtensions("sparseImageLoadARB", 1, &E_GL_ARB_sparse_texture2);
8450 symbolTable.setFunctionExtensions("sparseTexelsResident", 1, &E_GL_ARB_sparse_texture2);
8451 }
8452
8453 // E_GL_ARB_sparse_texture_clamp
8454 if (profile != EEsProfile)
8455 {
8456 symbolTable.setFunctionExtensions("sparseTextureClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
8457 symbolTable.setFunctionExtensions("sparseTextureOffsetClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
8458 symbolTable.setFunctionExtensions("sparseTextureGradClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
8459 symbolTable.setFunctionExtensions("sparseTextureGradOffsetClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
8460 symbolTable.setFunctionExtensions("textureClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
8461 symbolTable.setFunctionExtensions("textureOffsetClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
8462 symbolTable.setFunctionExtensions("textureGradClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
8463 symbolTable.setFunctionExtensions("textureGradOffsetClampARB", 1, &E_GL_ARB_sparse_texture_clamp);
8464 }
8465
8466 // E_GL_AMD_shader_explicit_vertex_parameter
8467 if (profile != EEsProfile) {
8468 symbolTable.setVariableExtensions("gl_BaryCoordNoPerspAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter);
8469 symbolTable.setVariableExtensions("gl_BaryCoordNoPerspCentroidAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter);
8470 symbolTable.setVariableExtensions("gl_BaryCoordNoPerspSampleAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter);
8471 symbolTable.setVariableExtensions("gl_BaryCoordSmoothAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter);
8472 symbolTable.setVariableExtensions("gl_BaryCoordSmoothCentroidAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter);
8473 symbolTable.setVariableExtensions("gl_BaryCoordSmoothSampleAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter);
8474 symbolTable.setVariableExtensions("gl_BaryCoordPullModelAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter);
8475
8476 symbolTable.setFunctionExtensions("interpolateAtVertexAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter);
8477
8478 BuiltInVariable("gl_BaryCoordNoPerspAMD", EbvBaryCoordNoPersp, symbolTable);
8479 BuiltInVariable("gl_BaryCoordNoPerspCentroidAMD", EbvBaryCoordNoPerspCentroid, symbolTable);
8480 BuiltInVariable("gl_BaryCoordNoPerspSampleAMD", EbvBaryCoordNoPerspSample, symbolTable);
8481 BuiltInVariable("gl_BaryCoordSmoothAMD", EbvBaryCoordSmooth, symbolTable);
8482 BuiltInVariable("gl_BaryCoordSmoothCentroidAMD", EbvBaryCoordSmoothCentroid, symbolTable);
8483 BuiltInVariable("gl_BaryCoordSmoothSampleAMD", EbvBaryCoordSmoothSample, symbolTable);
8484 BuiltInVariable("gl_BaryCoordPullModelAMD", EbvBaryCoordPullModel, symbolTable);
8485 }
8486
8487 // E_GL_AMD_texture_gather_bias_lod
8488 if (profile != EEsProfile) {
8489 symbolTable.setFunctionExtensions("textureGatherLodAMD", 1, &E_GL_AMD_texture_gather_bias_lod);
8490 symbolTable.setFunctionExtensions("textureGatherLodOffsetAMD", 1, &E_GL_AMD_texture_gather_bias_lod);
8491 symbolTable.setFunctionExtensions("textureGatherLodOffsetsAMD", 1, &E_GL_AMD_texture_gather_bias_lod);
8492 symbolTable.setFunctionExtensions("sparseTextureGatherLodAMD", 1, &E_GL_AMD_texture_gather_bias_lod);
8493 symbolTable.setFunctionExtensions("sparseTextureGatherLodOffsetAMD", 1, &E_GL_AMD_texture_gather_bias_lod);
8494 symbolTable.setFunctionExtensions("sparseTextureGatherLodOffsetsAMD", 1, &E_GL_AMD_texture_gather_bias_lod);
8495 }
8496
8497 // E_GL_AMD_shader_image_load_store_lod
8498 if (profile != EEsProfile) {
8499 symbolTable.setFunctionExtensions("imageLoadLodAMD", 1, &E_GL_AMD_shader_image_load_store_lod);
8500 symbolTable.setFunctionExtensions("imageStoreLodAMD", 1, &E_GL_AMD_shader_image_load_store_lod);
8501 symbolTable.setFunctionExtensions("sparseImageLoadLodAMD", 1, &E_GL_AMD_shader_image_load_store_lod);
8502 }
8503 if (profile != EEsProfile && version >= 430) {
8504 symbolTable.setVariableExtensions("gl_FragFullyCoveredNV", 1, &E_GL_NV_conservative_raster_underestimation);
8505 BuiltInVariable("gl_FragFullyCoveredNV", EbvFragFullyCoveredNV, symbolTable);
8506 }
8507 if ((profile != EEsProfile && version >= 450) ||
8508 (profile == EEsProfile && version >= 320)) {
8509 symbolTable.setVariableExtensions("gl_FragmentSizeNV", 1, &E_GL_NV_shading_rate_image);
8510 symbolTable.setVariableExtensions("gl_InvocationsPerPixelNV", 1, &E_GL_NV_shading_rate_image);
8511 BuiltInVariable("gl_FragmentSizeNV", EbvFragmentSizeNV, symbolTable);
8512 BuiltInVariable("gl_InvocationsPerPixelNV", EbvInvocationsPerPixelNV, symbolTable);
8513 symbolTable.setVariableExtensions("gl_BaryCoordNV", 1, &E_GL_NV_fragment_shader_barycentric);
8514 symbolTable.setVariableExtensions("gl_BaryCoordNoPerspNV", 1, &E_GL_NV_fragment_shader_barycentric);
8515 BuiltInVariable("gl_BaryCoordNV", EbvBaryCoordNV, symbolTable);
8516 BuiltInVariable("gl_BaryCoordNoPerspNV", EbvBaryCoordNoPerspNV, symbolTable);
8517 symbolTable.setVariableExtensions("gl_BaryCoordEXT", 1, &E_GL_EXT_fragment_shader_barycentric);
8518 symbolTable.setVariableExtensions("gl_BaryCoordNoPerspEXT", 1, &E_GL_EXT_fragment_shader_barycentric);
8519 BuiltInVariable("gl_BaryCoordEXT", EbvBaryCoordEXT, symbolTable);
8520 BuiltInVariable("gl_BaryCoordNoPerspEXT", EbvBaryCoordNoPerspEXT, symbolTable);
8521 }
8522
8523 if ((profile != EEsProfile && version >= 450) ||
8524 (profile == EEsProfile && version >= 310)) {
8525 symbolTable.setVariableExtensions("gl_FragSizeEXT", 1, &E_GL_EXT_fragment_invocation_density);
8526 symbolTable.setVariableExtensions("gl_FragInvocationCountEXT", 1, &E_GL_EXT_fragment_invocation_density);
8527 BuiltInVariable("gl_FragSizeEXT", EbvFragSizeEXT, symbolTable);
8528 BuiltInVariable("gl_FragInvocationCountEXT", EbvFragInvocationCountEXT, symbolTable);
8529 }
8530
8531 symbolTable.setVariableExtensions("gl_FragDepthEXT", 1, &E_GL_EXT_frag_depth);
8532
8533 symbolTable.setFunctionExtensions("clockARB", 1, &E_GL_ARB_shader_clock);
8534 symbolTable.setFunctionExtensions("clock2x32ARB", 1, &E_GL_ARB_shader_clock);
8535
8536 symbolTable.setFunctionExtensions("clockRealtimeEXT", 1, &E_GL_EXT_shader_realtime_clock);
8537 symbolTable.setFunctionExtensions("clockRealtime2x32EXT", 1, &E_GL_EXT_shader_realtime_clock);
8538
8539 if (profile == EEsProfile && version < 320) {
8540 symbolTable.setVariableExtensions("gl_PrimitiveID", Num_AEP_geometry_shader, AEP_geometry_shader);
8541 symbolTable.setVariableExtensions("gl_Layer", Num_AEP_geometry_shader, AEP_geometry_shader);
8542 }
8543
8544 if (profile == EEsProfile && version < 320) {
8545 symbolTable.setFunctionExtensions("imageAtomicAdd", 1, &E_GL_OES_shader_image_atomic);
8546 symbolTable.setFunctionExtensions("imageAtomicMin", 1, &E_GL_OES_shader_image_atomic);
8547 symbolTable.setFunctionExtensions("imageAtomicMax", 1, &E_GL_OES_shader_image_atomic);
8548 symbolTable.setFunctionExtensions("imageAtomicAnd", 1, &E_GL_OES_shader_image_atomic);
8549 symbolTable.setFunctionExtensions("imageAtomicOr", 1, &E_GL_OES_shader_image_atomic);
8550 symbolTable.setFunctionExtensions("imageAtomicXor", 1, &E_GL_OES_shader_image_atomic);
8551 symbolTable.setFunctionExtensions("imageAtomicExchange", 1, &E_GL_OES_shader_image_atomic);
8552 symbolTable.setFunctionExtensions("imageAtomicCompSwap", 1, &E_GL_OES_shader_image_atomic);
8553 }
8554
8555 if (profile != EEsProfile && version < 330 ) {
8556 const char* bitsConvertExt[2] = {E_GL_ARB_shader_bit_encoding, E_GL_ARB_gpu_shader5};
8557 symbolTable.setFunctionExtensions("floatBitsToInt", 2, bitsConvertExt);
8558 symbolTable.setFunctionExtensions("floatBitsToUint", 2, bitsConvertExt);
8559 symbolTable.setFunctionExtensions("intBitsToFloat", 2, bitsConvertExt);
8560 symbolTable.setFunctionExtensions("uintBitsToFloat", 2, bitsConvertExt);
8561 }
8562
8563 if (profile != EEsProfile && version < 430 ) {
8564 symbolTable.setFunctionExtensions("imageSize", 1, &E_GL_ARB_shader_image_size);
8565 }
8566
8567 // GL_ARB_shader_storage_buffer_object
8568 if (profile != EEsProfile && version < 430 ) {
8569 symbolTable.setFunctionExtensions("atomicAdd", 1, &E_GL_ARB_shader_storage_buffer_object);
8570 symbolTable.setFunctionExtensions("atomicMin", 1, &E_GL_ARB_shader_storage_buffer_object);
8571 symbolTable.setFunctionExtensions("atomicMax", 1, &E_GL_ARB_shader_storage_buffer_object);
8572 symbolTable.setFunctionExtensions("atomicAnd", 1, &E_GL_ARB_shader_storage_buffer_object);
8573 symbolTable.setFunctionExtensions("atomicOr", 1, &E_GL_ARB_shader_storage_buffer_object);
8574 symbolTable.setFunctionExtensions("atomicXor", 1, &E_GL_ARB_shader_storage_buffer_object);
8575 symbolTable.setFunctionExtensions("atomicExchange", 1, &E_GL_ARB_shader_storage_buffer_object);
8576 symbolTable.setFunctionExtensions("atomicCompSwap", 1, &E_GL_ARB_shader_storage_buffer_object);
8577 }
8578
8579 // GL_ARB_shading_language_packing
8580 if (profile != EEsProfile && version < 400 ) {
8581 symbolTable.setFunctionExtensions("packUnorm2x16", 1, &E_GL_ARB_shading_language_packing);
8582 symbolTable.setFunctionExtensions("unpackUnorm2x16", 1, &E_GL_ARB_shading_language_packing);
8583 symbolTable.setFunctionExtensions("packSnorm4x8", 1, &E_GL_ARB_shading_language_packing);
8584 symbolTable.setFunctionExtensions("packUnorm4x8", 1, &E_GL_ARB_shading_language_packing);
8585 symbolTable.setFunctionExtensions("unpackSnorm4x8", 1, &E_GL_ARB_shading_language_packing);
8586 symbolTable.setFunctionExtensions("unpackUnorm4x8", 1, &E_GL_ARB_shading_language_packing);
8587 }
8588 if (profile != EEsProfile && version < 420 ) {
8589 symbolTable.setFunctionExtensions("packSnorm2x16", 1, &E_GL_ARB_shading_language_packing);
8590 symbolTable.setFunctionExtensions("unpackSnorm2x16", 1, &E_GL_ARB_shading_language_packing);
8591 symbolTable.setFunctionExtensions("unpackHalf2x16", 1, &E_GL_ARB_shading_language_packing);
8592 symbolTable.setFunctionExtensions("packHalf2x16", 1, &E_GL_ARB_shading_language_packing);
8593 }
8594
8595 symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
8596 BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
8597 symbolTable.setVariableExtensions("gl_ViewIndex", 1, &E_GL_EXT_multiview);
8598 BuiltInVariable("gl_ViewIndex", EbvViewIndex, symbolTable);
8599 if (version >= 300 /* both ES and non-ES */) {
8600 symbolTable.setVariableExtensions("gl_ViewID_OVR", Num_OVR_multiview_EXTs, OVR_multiview_EXTs);
8601 BuiltInVariable("gl_ViewID_OVR", EbvViewIndex, symbolTable);
8602 }
8603
8604 // GL_ARB_shader_ballot
8605 if (profile != EEsProfile) {
8606 symbolTable.setVariableExtensions("gl_SubGroupSizeARB", 1, &E_GL_ARB_shader_ballot);
8607 symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
8608 symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB", 1, &E_GL_ARB_shader_ballot);
8609 symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB", 1, &E_GL_ARB_shader_ballot);
8610 symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB", 1, &E_GL_ARB_shader_ballot);
8611 symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB", 1, &E_GL_ARB_shader_ballot);
8612 symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB", 1, &E_GL_ARB_shader_ballot);
8613
8614 BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
8615 BuiltInVariable("gl_SubGroupEqMaskARB", EbvSubGroupEqMask, symbolTable);
8616 BuiltInVariable("gl_SubGroupGeMaskARB", EbvSubGroupGeMask, symbolTable);
8617 BuiltInVariable("gl_SubGroupGtMaskARB", EbvSubGroupGtMask, symbolTable);
8618 BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
8619 BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
8620
8621 if (spvVersion.vulkan > 0) {
8622 // Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
8623 SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
8624 if (language == EShLangFragment)
8625 ModifyFlatDecoration("gl_SubGroupSizeARB", true, symbolTable);
8626 }
8627 else
8628 BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
8629 }
8630
8631 // GL_KHR_shader_subgroup
8632 if ((profile == EEsProfile && version >= 310) ||
8633 (profile != EEsProfile && version >= 140)) {
8634 symbolTable.setVariableExtensions("gl_SubgroupSize", 1, &E_GL_KHR_shader_subgroup_basic);
8635 symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
8636 symbolTable.setVariableExtensions("gl_SubgroupEqMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8637 symbolTable.setVariableExtensions("gl_SubgroupGeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8638 symbolTable.setVariableExtensions("gl_SubgroupGtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8639 symbolTable.setVariableExtensions("gl_SubgroupLeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8640 symbolTable.setVariableExtensions("gl_SubgroupLtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8641
8642 BuiltInVariable("gl_SubgroupSize", EbvSubgroupSize2, symbolTable);
8643 BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
8644 BuiltInVariable("gl_SubgroupEqMask", EbvSubgroupEqMask2, symbolTable);
8645 BuiltInVariable("gl_SubgroupGeMask", EbvSubgroupGeMask2, symbolTable);
8646 BuiltInVariable("gl_SubgroupGtMask", EbvSubgroupGtMask2, symbolTable);
8647 BuiltInVariable("gl_SubgroupLeMask", EbvSubgroupLeMask2, symbolTable);
8648 BuiltInVariable("gl_SubgroupLtMask", EbvSubgroupLtMask2, symbolTable);
8649
8650 symbolTable.setFunctionExtensions("subgroupBarrier", 1, &E_GL_KHR_shader_subgroup_basic);
8651 symbolTable.setFunctionExtensions("subgroupMemoryBarrier", 1, &E_GL_KHR_shader_subgroup_basic);
8652 symbolTable.setFunctionExtensions("subgroupMemoryBarrierBuffer", 1, &E_GL_KHR_shader_subgroup_basic);
8653 symbolTable.setFunctionExtensions("subgroupMemoryBarrierImage", 1, &E_GL_KHR_shader_subgroup_basic);
8654 symbolTable.setFunctionExtensions("subgroupElect", 1, &E_GL_KHR_shader_subgroup_basic);
8655 symbolTable.setFunctionExtensions("subgroupAll", 1, &E_GL_KHR_shader_subgroup_vote);
8656 symbolTable.setFunctionExtensions("subgroupAny", 1, &E_GL_KHR_shader_subgroup_vote);
8657 symbolTable.setFunctionExtensions("subgroupAllEqual", 1, &E_GL_KHR_shader_subgroup_vote);
8658 symbolTable.setFunctionExtensions("subgroupBroadcast", 1, &E_GL_KHR_shader_subgroup_ballot);
8659 symbolTable.setFunctionExtensions("subgroupBroadcastFirst", 1, &E_GL_KHR_shader_subgroup_ballot);
8660 symbolTable.setFunctionExtensions("subgroupBallot", 1, &E_GL_KHR_shader_subgroup_ballot);
8661 symbolTable.setFunctionExtensions("subgroupInverseBallot", 1, &E_GL_KHR_shader_subgroup_ballot);
8662 symbolTable.setFunctionExtensions("subgroupBallotBitExtract", 1, &E_GL_KHR_shader_subgroup_ballot);
8663 symbolTable.setFunctionExtensions("subgroupBallotBitCount", 1, &E_GL_KHR_shader_subgroup_ballot);
8664 symbolTable.setFunctionExtensions("subgroupBallotInclusiveBitCount", 1, &E_GL_KHR_shader_subgroup_ballot);
8665 symbolTable.setFunctionExtensions("subgroupBallotExclusiveBitCount", 1, &E_GL_KHR_shader_subgroup_ballot);
8666 symbolTable.setFunctionExtensions("subgroupBallotFindLSB", 1, &E_GL_KHR_shader_subgroup_ballot);
8667 symbolTable.setFunctionExtensions("subgroupBallotFindMSB", 1, &E_GL_KHR_shader_subgroup_ballot);
8668 symbolTable.setFunctionExtensions("subgroupShuffle", 1, &E_GL_KHR_shader_subgroup_shuffle);
8669 symbolTable.setFunctionExtensions("subgroupShuffleXor", 1, &E_GL_KHR_shader_subgroup_shuffle);
8670 symbolTable.setFunctionExtensions("subgroupShuffleUp", 1, &E_GL_KHR_shader_subgroup_shuffle_relative);
8671 symbolTable.setFunctionExtensions("subgroupShuffleDown", 1, &E_GL_KHR_shader_subgroup_shuffle_relative);
8672 symbolTable.setFunctionExtensions("subgroupAdd", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8673 symbolTable.setFunctionExtensions("subgroupMul", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8674 symbolTable.setFunctionExtensions("subgroupMin", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8675 symbolTable.setFunctionExtensions("subgroupMax", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8676 symbolTable.setFunctionExtensions("subgroupAnd", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8677 symbolTable.setFunctionExtensions("subgroupOr", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8678 symbolTable.setFunctionExtensions("subgroupXor", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8679 symbolTable.setFunctionExtensions("subgroupInclusiveAdd", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8680 symbolTable.setFunctionExtensions("subgroupInclusiveMul", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8681 symbolTable.setFunctionExtensions("subgroupInclusiveMin", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8682 symbolTable.setFunctionExtensions("subgroupInclusiveMax", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8683 symbolTable.setFunctionExtensions("subgroupInclusiveAnd", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8684 symbolTable.setFunctionExtensions("subgroupInclusiveOr", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8685 symbolTable.setFunctionExtensions("subgroupInclusiveXor", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8686 symbolTable.setFunctionExtensions("subgroupExclusiveAdd", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8687 symbolTable.setFunctionExtensions("subgroupExclusiveMul", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8688 symbolTable.setFunctionExtensions("subgroupExclusiveMin", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8689 symbolTable.setFunctionExtensions("subgroupExclusiveMax", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8690 symbolTable.setFunctionExtensions("subgroupExclusiveAnd", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8691 symbolTable.setFunctionExtensions("subgroupExclusiveOr", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8692 symbolTable.setFunctionExtensions("subgroupExclusiveXor", 1, &E_GL_KHR_shader_subgroup_arithmetic);
8693 symbolTable.setFunctionExtensions("subgroupClusteredAdd", 1, &E_GL_KHR_shader_subgroup_clustered);
8694 symbolTable.setFunctionExtensions("subgroupClusteredMul", 1, &E_GL_KHR_shader_subgroup_clustered);
8695 symbolTable.setFunctionExtensions("subgroupClusteredMin", 1, &E_GL_KHR_shader_subgroup_clustered);
8696 symbolTable.setFunctionExtensions("subgroupClusteredMax", 1, &E_GL_KHR_shader_subgroup_clustered);
8697 symbolTable.setFunctionExtensions("subgroupClusteredAnd", 1, &E_GL_KHR_shader_subgroup_clustered);
8698 symbolTable.setFunctionExtensions("subgroupClusteredOr", 1, &E_GL_KHR_shader_subgroup_clustered);
8699 symbolTable.setFunctionExtensions("subgroupClusteredXor", 1, &E_GL_KHR_shader_subgroup_clustered);
8700 symbolTable.setFunctionExtensions("subgroupQuadBroadcast", 1, &E_GL_KHR_shader_subgroup_quad);
8701 symbolTable.setFunctionExtensions("subgroupQuadSwapHorizontal", 1, &E_GL_KHR_shader_subgroup_quad);
8702 symbolTable.setFunctionExtensions("subgroupQuadSwapVertical", 1, &E_GL_KHR_shader_subgroup_quad);
8703 symbolTable.setFunctionExtensions("subgroupQuadSwapDiagonal", 1, &E_GL_KHR_shader_subgroup_quad);
8704 symbolTable.setFunctionExtensions("subgroupPartitionNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8705 symbolTable.setFunctionExtensions("subgroupPartitionedAddNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8706 symbolTable.setFunctionExtensions("subgroupPartitionedMulNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8707 symbolTable.setFunctionExtensions("subgroupPartitionedMinNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8708 symbolTable.setFunctionExtensions("subgroupPartitionedMaxNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8709 symbolTable.setFunctionExtensions("subgroupPartitionedAndNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8710 symbolTable.setFunctionExtensions("subgroupPartitionedOrNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8711 symbolTable.setFunctionExtensions("subgroupPartitionedXorNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8712 symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveAddNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8713 symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveMulNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8714 symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveMinNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8715 symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveMaxNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8716 symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveAndNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8717 symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveOrNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8718 symbolTable.setFunctionExtensions("subgroupPartitionedInclusiveXorNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8719 symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveAddNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8720 symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveMulNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8721 symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveMinNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8722 symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveMaxNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8723 symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveAndNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8724 symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveOrNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8725 symbolTable.setFunctionExtensions("subgroupPartitionedExclusiveXorNV", 1, &E_GL_NV_shader_subgroup_partitioned);
8726
8727 // GL_NV_shader_sm_builtins
8728 symbolTable.setVariableExtensions("gl_WarpsPerSMNV", 1, &E_GL_NV_shader_sm_builtins);
8729 symbolTable.setVariableExtensions("gl_SMCountNV", 1, &E_GL_NV_shader_sm_builtins);
8730 symbolTable.setVariableExtensions("gl_WarpIDNV", 1, &E_GL_NV_shader_sm_builtins);
8731 symbolTable.setVariableExtensions("gl_SMIDNV", 1, &E_GL_NV_shader_sm_builtins);
8732 BuiltInVariable("gl_WarpsPerSMNV", EbvWarpsPerSM, symbolTable);
8733 BuiltInVariable("gl_SMCountNV", EbvSMCount, symbolTable);
8734 BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable);
8735 BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable);
8736
8737 // GL_ARM_shader_core_builtins
8738 symbolTable.setVariableExtensions("gl_CoreCountARM", 1, &E_GL_ARM_shader_core_builtins);
8739 symbolTable.setVariableExtensions("gl_CoreIDARM", 1, &E_GL_ARM_shader_core_builtins);
8740 symbolTable.setVariableExtensions("gl_CoreMaxIDARM", 1, &E_GL_ARM_shader_core_builtins);
8741 symbolTable.setVariableExtensions("gl_WarpIDARM", 1, &E_GL_ARM_shader_core_builtins);
8742 symbolTable.setVariableExtensions("gl_WarpMaxIDARM", 1, &E_GL_ARM_shader_core_builtins);
8743
8744 BuiltInVariable("gl_CoreCountARM", EbvCoreCountARM, symbolTable);
8745 BuiltInVariable("gl_CoreIDARM", EbvCoreIDARM, symbolTable);
8746 BuiltInVariable("gl_CoreMaxIDARM", EbvCoreMaxIDARM, symbolTable);
8747 BuiltInVariable("gl_WarpIDARM", EbvWarpIDARM, symbolTable);
8748 BuiltInVariable("gl_WarpMaxIDARM", EbvWarpMaxIDARM, symbolTable);
8749 }
8750
8751 if (profile == EEsProfile) {
8752 symbolTable.setFunctionExtensions("shadow2DEXT", 1, &E_GL_EXT_shadow_samplers);
8753 symbolTable.setFunctionExtensions("shadow2DProjEXT", 1, &E_GL_EXT_shadow_samplers);
8754 }
8755
8756 if (spvVersion.vulkan > 0) {
8757 symbolTable.setVariableExtensions("gl_ScopeDevice", 1, &E_GL_KHR_memory_scope_semantics);
8758 symbolTable.setVariableExtensions("gl_ScopeWorkgroup", 1, &E_GL_KHR_memory_scope_semantics);
8759 symbolTable.setVariableExtensions("gl_ScopeSubgroup", 1, &E_GL_KHR_memory_scope_semantics);
8760 symbolTable.setVariableExtensions("gl_ScopeInvocation", 1, &E_GL_KHR_memory_scope_semantics);
8761
8762 symbolTable.setVariableExtensions("gl_SemanticsRelaxed", 1, &E_GL_KHR_memory_scope_semantics);
8763 symbolTable.setVariableExtensions("gl_SemanticsAcquire", 1, &E_GL_KHR_memory_scope_semantics);
8764 symbolTable.setVariableExtensions("gl_SemanticsRelease", 1, &E_GL_KHR_memory_scope_semantics);
8765 symbolTable.setVariableExtensions("gl_SemanticsAcquireRelease", 1, &E_GL_KHR_memory_scope_semantics);
8766 symbolTable.setVariableExtensions("gl_SemanticsMakeAvailable", 1, &E_GL_KHR_memory_scope_semantics);
8767 symbolTable.setVariableExtensions("gl_SemanticsMakeVisible", 1, &E_GL_KHR_memory_scope_semantics);
8768 symbolTable.setVariableExtensions("gl_SemanticsVolatile", 1, &E_GL_KHR_memory_scope_semantics);
8769
8770 symbolTable.setVariableExtensions("gl_StorageSemanticsNone", 1, &E_GL_KHR_memory_scope_semantics);
8771 symbolTable.setVariableExtensions("gl_StorageSemanticsBuffer", 1, &E_GL_KHR_memory_scope_semantics);
8772 symbolTable.setVariableExtensions("gl_StorageSemanticsShared", 1, &E_GL_KHR_memory_scope_semantics);
8773 symbolTable.setVariableExtensions("gl_StorageSemanticsImage", 1, &E_GL_KHR_memory_scope_semantics);
8774 symbolTable.setVariableExtensions("gl_StorageSemanticsOutput", 1, &E_GL_KHR_memory_scope_semantics);
8775 }
8776
8777 symbolTable.setFunctionExtensions("helperInvocationEXT", 1, &E_GL_EXT_demote_to_helper_invocation);
8778
8779 if ((profile == EEsProfile && version >= 310) ||
8780 (profile != EEsProfile && version >= 450)) {
8781 symbolTable.setVariableExtensions("gl_ShadingRateEXT", 1, &E_GL_EXT_fragment_shading_rate);
8782 BuiltInVariable("gl_ShadingRateEXT", EbvShadingRateKHR, symbolTable);
8783
8784 symbolTable.setVariableExtensions("gl_ShadingRateFlag2VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8785 symbolTable.setVariableExtensions("gl_ShadingRateFlag4VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8786 symbolTable.setVariableExtensions("gl_ShadingRateFlag2HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8787 symbolTable.setVariableExtensions("gl_ShadingRateFlag4HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8788 }
8789
8790 // GL_EXT_shader_tile_image
8791 symbolTable.setFunctionExtensions("stencilAttachmentReadEXT", 1, &E_GL_EXT_shader_tile_image);
8792 symbolTable.setFunctionExtensions("depthAttachmentReadEXT", 1, &E_GL_EXT_shader_tile_image);
8793 symbolTable.setFunctionExtensions("colorAttachmentReadEXT", 1, &E_GL_EXT_shader_tile_image);
8794
8795 if ((profile == EEsProfile && version >= 310) ||
8796 (profile != EEsProfile && version >= 140)) {
8797 symbolTable.setFunctionExtensions("textureWeightedQCOM", 1, &E_GL_QCOM_image_processing);
8798 symbolTable.setFunctionExtensions("textureBoxFilterQCOM", 1, &E_GL_QCOM_image_processing);
8799 symbolTable.setFunctionExtensions("textureBlockMatchSADQCOM", 1, &E_GL_QCOM_image_processing);
8800 symbolTable.setFunctionExtensions("textureBlockMatchSSDQCOM", 1, &E_GL_QCOM_image_processing);
8801 }
8802 break;
8803
8804 case EShLangCompute:
8805 BuiltInVariable("gl_NumWorkGroups", EbvNumWorkGroups, symbolTable);
8806 BuiltInVariable("gl_WorkGroupSize", EbvWorkGroupSize, symbolTable);
8807 BuiltInVariable("gl_WorkGroupID", EbvWorkGroupId, symbolTable);
8808 BuiltInVariable("gl_LocalInvocationID", EbvLocalInvocationId, symbolTable);
8809 BuiltInVariable("gl_GlobalInvocationID", EbvGlobalInvocationId, symbolTable);
8810 BuiltInVariable("gl_LocalInvocationIndex", EbvLocalInvocationIndex, symbolTable);
8811 BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
8812 BuiltInVariable("gl_ViewIndex", EbvViewIndex, symbolTable);
8813
8814 if ((profile != EEsProfile && version >= 140) ||
8815 (profile == EEsProfile && version >= 310)) {
8816 symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
8817 symbolTable.setVariableExtensions("gl_ViewIndex", 1, &E_GL_EXT_multiview);
8818 }
8819
8820 if (profile != EEsProfile && version < 430) {
8821 symbolTable.setVariableExtensions("gl_NumWorkGroups", 1, &E_GL_ARB_compute_shader);
8822 symbolTable.setVariableExtensions("gl_WorkGroupSize", 1, &E_GL_ARB_compute_shader);
8823 symbolTable.setVariableExtensions("gl_WorkGroupID", 1, &E_GL_ARB_compute_shader);
8824 symbolTable.setVariableExtensions("gl_LocalInvocationID", 1, &E_GL_ARB_compute_shader);
8825 symbolTable.setVariableExtensions("gl_GlobalInvocationID", 1, &E_GL_ARB_compute_shader);
8826 symbolTable.setVariableExtensions("gl_LocalInvocationIndex", 1, &E_GL_ARB_compute_shader);
8827
8828 symbolTable.setVariableExtensions("gl_MaxComputeWorkGroupCount", 1, &E_GL_ARB_compute_shader);
8829 symbolTable.setVariableExtensions("gl_MaxComputeWorkGroupSize", 1, &E_GL_ARB_compute_shader);
8830 symbolTable.setVariableExtensions("gl_MaxComputeUniformComponents", 1, &E_GL_ARB_compute_shader);
8831 symbolTable.setVariableExtensions("gl_MaxComputeTextureImageUnits", 1, &E_GL_ARB_compute_shader);
8832 symbolTable.setVariableExtensions("gl_MaxComputeImageUniforms", 1, &E_GL_ARB_compute_shader);
8833 symbolTable.setVariableExtensions("gl_MaxComputeAtomicCounters", 1, &E_GL_ARB_compute_shader);
8834 symbolTable.setVariableExtensions("gl_MaxComputeAtomicCounterBuffers", 1, &E_GL_ARB_compute_shader);
8835
8836 symbolTable.setFunctionExtensions("barrier", 1, &E_GL_ARB_compute_shader);
8837 symbolTable.setFunctionExtensions("memoryBarrierAtomicCounter", 1, &E_GL_ARB_compute_shader);
8838 symbolTable.setFunctionExtensions("memoryBarrierBuffer", 1, &E_GL_ARB_compute_shader);
8839 symbolTable.setFunctionExtensions("memoryBarrierImage", 1, &E_GL_ARB_compute_shader);
8840 symbolTable.setFunctionExtensions("memoryBarrierShared", 1, &E_GL_ARB_compute_shader);
8841 symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_ARB_compute_shader);
8842 }
8843
8844
8845 symbolTable.setFunctionExtensions("controlBarrier", 1, &E_GL_KHR_memory_scope_semantics);
8846 symbolTable.setFunctionExtensions("debugPrintfEXT", 1, &E_GL_EXT_debug_printf);
8847
8848 // GL_ARB_shader_ballot
8849 if (profile != EEsProfile) {
8850 symbolTable.setVariableExtensions("gl_SubGroupSizeARB", 1, &E_GL_ARB_shader_ballot);
8851 symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
8852 symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB", 1, &E_GL_ARB_shader_ballot);
8853 symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB", 1, &E_GL_ARB_shader_ballot);
8854 symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB", 1, &E_GL_ARB_shader_ballot);
8855 symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB", 1, &E_GL_ARB_shader_ballot);
8856 symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB", 1, &E_GL_ARB_shader_ballot);
8857
8858 BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
8859 BuiltInVariable("gl_SubGroupEqMaskARB", EbvSubGroupEqMask, symbolTable);
8860 BuiltInVariable("gl_SubGroupGeMaskARB", EbvSubGroupGeMask, symbolTable);
8861 BuiltInVariable("gl_SubGroupGtMaskARB", EbvSubGroupGtMask, symbolTable);
8862 BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
8863 BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
8864
8865 if (spvVersion.vulkan > 0) {
8866 // Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
8867 SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
8868 if (language == EShLangFragment)
8869 ModifyFlatDecoration("gl_SubGroupSizeARB", true, symbolTable);
8870 }
8871 else
8872 BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
8873 }
8874
8875 // GL_KHR_shader_subgroup
8876 if ((profile == EEsProfile && version >= 310) ||
8877 (profile != EEsProfile && version >= 140)) {
8878 symbolTable.setVariableExtensions("gl_SubgroupSize", 1, &E_GL_KHR_shader_subgroup_basic);
8879 symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
8880 symbolTable.setVariableExtensions("gl_SubgroupEqMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8881 symbolTable.setVariableExtensions("gl_SubgroupGeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8882 symbolTable.setVariableExtensions("gl_SubgroupGtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8883 symbolTable.setVariableExtensions("gl_SubgroupLeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8884 symbolTable.setVariableExtensions("gl_SubgroupLtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
8885
8886 BuiltInVariable("gl_SubgroupSize", EbvSubgroupSize2, symbolTable);
8887 BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
8888 BuiltInVariable("gl_SubgroupEqMask", EbvSubgroupEqMask2, symbolTable);
8889 BuiltInVariable("gl_SubgroupGeMask", EbvSubgroupGeMask2, symbolTable);
8890 BuiltInVariable("gl_SubgroupGtMask", EbvSubgroupGtMask2, symbolTable);
8891 BuiltInVariable("gl_SubgroupLeMask", EbvSubgroupLeMask2, symbolTable);
8892 BuiltInVariable("gl_SubgroupLtMask", EbvSubgroupLtMask2, symbolTable);
8893
8894 // GL_NV_shader_sm_builtins
8895 symbolTable.setVariableExtensions("gl_WarpsPerSMNV", 1, &E_GL_NV_shader_sm_builtins);
8896 symbolTable.setVariableExtensions("gl_SMCountNV", 1, &E_GL_NV_shader_sm_builtins);
8897 symbolTable.setVariableExtensions("gl_WarpIDNV", 1, &E_GL_NV_shader_sm_builtins);
8898 symbolTable.setVariableExtensions("gl_SMIDNV", 1, &E_GL_NV_shader_sm_builtins);
8899 BuiltInVariable("gl_WarpsPerSMNV", EbvWarpsPerSM, symbolTable);
8900 BuiltInVariable("gl_SMCountNV", EbvSMCount, symbolTable);
8901 BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable);
8902 BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable);
8903
8904 // GL_ARM_shader_core_builtins
8905 symbolTable.setVariableExtensions("gl_CoreCountARM", 1, &E_GL_ARM_shader_core_builtins);
8906 symbolTable.setVariableExtensions("gl_CoreIDARM", 1, &E_GL_ARM_shader_core_builtins);
8907 symbolTable.setVariableExtensions("gl_CoreMaxIDARM", 1, &E_GL_ARM_shader_core_builtins);
8908 symbolTable.setVariableExtensions("gl_WarpIDARM", 1, &E_GL_ARM_shader_core_builtins);
8909 symbolTable.setVariableExtensions("gl_WarpMaxIDARM", 1, &E_GL_ARM_shader_core_builtins);
8910
8911 BuiltInVariable("gl_CoreCountARM", EbvCoreCountARM, symbolTable);
8912 BuiltInVariable("gl_CoreIDARM", EbvCoreIDARM, symbolTable);
8913 BuiltInVariable("gl_CoreMaxIDARM", EbvCoreMaxIDARM, symbolTable);
8914 BuiltInVariable("gl_WarpIDARM", EbvWarpIDARM, symbolTable);
8915 BuiltInVariable("gl_WarpMaxIDARM", EbvWarpMaxIDARM, symbolTable);
8916 }
8917
8918 // GL_KHR_shader_subgroup
8919 if ((profile == EEsProfile && version >= 310) ||
8920 (profile != EEsProfile && version >= 140)) {
8921 symbolTable.setVariableExtensions("gl_NumSubgroups", 1, &E_GL_KHR_shader_subgroup_basic);
8922 symbolTable.setVariableExtensions("gl_SubgroupID", 1, &E_GL_KHR_shader_subgroup_basic);
8923
8924 BuiltInVariable("gl_NumSubgroups", EbvNumSubgroups, symbolTable);
8925 BuiltInVariable("gl_SubgroupID", EbvSubgroupID, symbolTable);
8926
8927 symbolTable.setFunctionExtensions("subgroupMemoryBarrierShared", 1, &E_GL_KHR_shader_subgroup_basic);
8928 }
8929
8930 {
8931 const char *coopExt[2] = { E_GL_NV_cooperative_matrix, E_GL_NV_integer_cooperative_matrix };
8932 symbolTable.setFunctionExtensions("coopMatLoadNV", 2, coopExt);
8933 symbolTable.setFunctionExtensions("coopMatStoreNV", 2, coopExt);
8934 symbolTable.setFunctionExtensions("coopMatMulAddNV", 2, coopExt);
8935 }
8936
8937 {
8938 symbolTable.setFunctionExtensions("coopMatLoad", 1, &E_GL_KHR_cooperative_matrix);
8939 symbolTable.setFunctionExtensions("coopMatStore", 1, &E_GL_KHR_cooperative_matrix);
8940 symbolTable.setFunctionExtensions("coopMatMulAdd", 1, &E_GL_KHR_cooperative_matrix);
8941 }
8942
8943 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
8944 symbolTable.setFunctionExtensions("dFdx", 1, &E_GL_NV_compute_shader_derivatives);
8945 symbolTable.setFunctionExtensions("dFdy", 1, &E_GL_NV_compute_shader_derivatives);
8946 symbolTable.setFunctionExtensions("fwidth", 1, &E_GL_NV_compute_shader_derivatives);
8947 symbolTable.setFunctionExtensions("dFdxFine", 1, &E_GL_NV_compute_shader_derivatives);
8948 symbolTable.setFunctionExtensions("dFdyFine", 1, &E_GL_NV_compute_shader_derivatives);
8949 symbolTable.setFunctionExtensions("fwidthFine", 1, &E_GL_NV_compute_shader_derivatives);
8950 symbolTable.setFunctionExtensions("dFdxCoarse", 1, &E_GL_NV_compute_shader_derivatives);
8951 symbolTable.setFunctionExtensions("dFdyCoarse", 1, &E_GL_NV_compute_shader_derivatives);
8952 symbolTable.setFunctionExtensions("fwidthCoarse", 1, &E_GL_NV_compute_shader_derivatives);
8953 }
8954
8955 if ((profile == EEsProfile && version >= 310) ||
8956 (profile != EEsProfile && version >= 450)) {
8957 symbolTable.setVariableExtensions("gl_ShadingRateFlag2VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8958 symbolTable.setVariableExtensions("gl_ShadingRateFlag4VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8959 symbolTable.setVariableExtensions("gl_ShadingRateFlag2HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8960 symbolTable.setVariableExtensions("gl_ShadingRateFlag4HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
8961 }
8962
8963 if ((profile != EEsProfile && version >= 460)) {
8964 symbolTable.setFunctionExtensions("fetchMicroTriangleVertexPositionNV", 1, &E_GL_NV_displacement_micromap);
8965 symbolTable.setFunctionExtensions("fetchMicroTriangleVertexBarycentricNV", 1, &E_GL_NV_displacement_micromap);
8966 }
8967 break;
8968
8969 case EShLangRayGen:
8970 case EShLangIntersect:
8971 case EShLangAnyHit:
8972 case EShLangClosestHit:
8973 case EShLangMiss:
8974 case EShLangCallable:
8975 if (profile != EEsProfile && version >= 460) {
8976 const char *rtexts[] = { E_GL_NV_ray_tracing, E_GL_EXT_ray_tracing };
8977 symbolTable.setVariableExtensions("gl_LaunchIDNV", 1, &E_GL_NV_ray_tracing);
8978 symbolTable.setVariableExtensions("gl_LaunchIDEXT", 1, &E_GL_EXT_ray_tracing);
8979 symbolTable.setVariableExtensions("gl_LaunchSizeNV", 1, &E_GL_NV_ray_tracing);
8980 symbolTable.setVariableExtensions("gl_LaunchSizeEXT", 1, &E_GL_EXT_ray_tracing);
8981 symbolTable.setVariableExtensions("gl_PrimitiveID", 2, rtexts);
8982 symbolTable.setVariableExtensions("gl_InstanceID", 2, rtexts);
8983 symbolTable.setVariableExtensions("gl_InstanceCustomIndexNV", 1, &E_GL_NV_ray_tracing);
8984 symbolTable.setVariableExtensions("gl_InstanceCustomIndexEXT", 1, &E_GL_EXT_ray_tracing);
8985 symbolTable.setVariableExtensions("gl_GeometryIndexEXT", 1, &E_GL_EXT_ray_tracing);
8986 symbolTable.setVariableExtensions("gl_WorldRayOriginNV", 1, &E_GL_NV_ray_tracing);
8987 symbolTable.setVariableExtensions("gl_WorldRayOriginEXT", 1, &E_GL_EXT_ray_tracing);
8988 symbolTable.setVariableExtensions("gl_WorldRayDirectionNV", 1, &E_GL_NV_ray_tracing);
8989 symbolTable.setVariableExtensions("gl_WorldRayDirectionEXT", 1, &E_GL_EXT_ray_tracing);
8990 symbolTable.setVariableExtensions("gl_ObjectRayOriginNV", 1, &E_GL_NV_ray_tracing);
8991 symbolTable.setVariableExtensions("gl_ObjectRayOriginEXT", 1, &E_GL_EXT_ray_tracing);
8992 symbolTable.setVariableExtensions("gl_ObjectRayDirectionNV", 1, &E_GL_NV_ray_tracing);
8993 symbolTable.setVariableExtensions("gl_ObjectRayDirectionEXT", 1, &E_GL_EXT_ray_tracing);
8994 symbolTable.setVariableExtensions("gl_RayTminNV", 1, &E_GL_NV_ray_tracing);
8995 symbolTable.setVariableExtensions("gl_RayTminEXT", 1, &E_GL_EXT_ray_tracing);
8996 symbolTable.setVariableExtensions("gl_RayTmaxNV", 1, &E_GL_NV_ray_tracing);
8997 symbolTable.setVariableExtensions("gl_RayTmaxEXT", 1, &E_GL_EXT_ray_tracing);
8998 symbolTable.setVariableExtensions("gl_CullMaskEXT", 1, &E_GL_EXT_ray_cull_mask);
8999 symbolTable.setVariableExtensions("gl_HitTNV", 1, &E_GL_NV_ray_tracing);
9000 symbolTable.setVariableExtensions("gl_HitTEXT", 1, &E_GL_EXT_ray_tracing);
9001 symbolTable.setVariableExtensions("gl_HitKindNV", 1, &E_GL_NV_ray_tracing);
9002 symbolTable.setVariableExtensions("gl_HitKindEXT", 1, &E_GL_EXT_ray_tracing);
9003 symbolTable.setVariableExtensions("gl_ObjectToWorldNV", 1, &E_GL_NV_ray_tracing);
9004 symbolTable.setVariableExtensions("gl_ObjectToWorldEXT", 1, &E_GL_EXT_ray_tracing);
9005 symbolTable.setVariableExtensions("gl_ObjectToWorld3x4EXT", 1, &E_GL_EXT_ray_tracing);
9006 symbolTable.setVariableExtensions("gl_WorldToObjectNV", 1, &E_GL_NV_ray_tracing);
9007 symbolTable.setVariableExtensions("gl_WorldToObjectEXT", 1, &E_GL_EXT_ray_tracing);
9008 symbolTable.setVariableExtensions("gl_WorldToObject3x4EXT", 1, &E_GL_EXT_ray_tracing);
9009 symbolTable.setVariableExtensions("gl_IncomingRayFlagsNV", 1, &E_GL_NV_ray_tracing);
9010 symbolTable.setVariableExtensions("gl_IncomingRayFlagsEXT", 1, &E_GL_EXT_ray_tracing);
9011 symbolTable.setVariableExtensions("gl_CurrentRayTimeNV", 1, &E_GL_NV_ray_tracing_motion_blur);
9012 symbolTable.setVariableExtensions("gl_HitTriangleVertexPositionsEXT", 1, &E_GL_EXT_ray_tracing_position_fetch);
9013 symbolTable.setVariableExtensions("gl_HitMicroTriangleVertexPositionsNV", 1, &E_GL_NV_displacement_micromap);
9014 symbolTable.setVariableExtensions("gl_HitMicroTriangleVertexBarycentricsNV", 1, &E_GL_NV_displacement_micromap);
9015
9016 symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
9017
9018
9019 symbolTable.setFunctionExtensions("traceNV", 1, &E_GL_NV_ray_tracing);
9020 symbolTable.setFunctionExtensions("traceRayMotionNV", 1, &E_GL_NV_ray_tracing_motion_blur);
9021 symbolTable.setFunctionExtensions("traceRayEXT", 1, &E_GL_EXT_ray_tracing);
9022 symbolTable.setFunctionExtensions("reportIntersectionNV", 1, &E_GL_NV_ray_tracing);
9023 symbolTable.setFunctionExtensions("reportIntersectionEXT", 1, &E_GL_EXT_ray_tracing);
9024 symbolTable.setFunctionExtensions("ignoreIntersectionNV", 1, &E_GL_NV_ray_tracing);
9025 symbolTable.setFunctionExtensions("terminateRayNV", 1, &E_GL_NV_ray_tracing);
9026 symbolTable.setFunctionExtensions("executeCallableNV", 1, &E_GL_NV_ray_tracing);
9027 symbolTable.setFunctionExtensions("executeCallableEXT", 1, &E_GL_EXT_ray_tracing);
9028
9029 symbolTable.setFunctionExtensions("hitObjectTraceRayNV", 1, &E_GL_NV_shader_invocation_reorder);
9030 symbolTable.setFunctionExtensions("hitObjectTraceRayMotionNV", 1, &E_GL_NV_shader_invocation_reorder);
9031 symbolTable.setFunctionExtensions("hitObjectRecordHitNV", 1, &E_GL_NV_shader_invocation_reorder);
9032 symbolTable.setFunctionExtensions("hitObjectRecordHitMotionNV", 1, &E_GL_NV_shader_invocation_reorder);
9033 symbolTable.setFunctionExtensions("hitObjectRecordHitWithIndexNV", 1, &E_GL_NV_shader_invocation_reorder);
9034 symbolTable.setFunctionExtensions("hitObjectRecordHitWithIndexMotionNV", 1, &E_GL_NV_shader_invocation_reorder);
9035 symbolTable.setFunctionExtensions("hitObjectRecordMissNV", 1, &E_GL_NV_shader_invocation_reorder);
9036 symbolTable.setFunctionExtensions("hitObjectRecordMissMotionNV", 1, &E_GL_NV_shader_invocation_reorder);
9037 symbolTable.setFunctionExtensions("hitObjectRecordEmptyNV", 1, &E_GL_NV_shader_invocation_reorder);
9038 symbolTable.setFunctionExtensions("hitObjectExecuteShaderNV", 1, &E_GL_NV_shader_invocation_reorder);
9039 symbolTable.setFunctionExtensions("hitObjectIsEmptyNV", 1, &E_GL_NV_shader_invocation_reorder);
9040 symbolTable.setFunctionExtensions("hitObjectIsMissNV", 1, &E_GL_NV_shader_invocation_reorder);
9041 symbolTable.setFunctionExtensions("hitObjectIsHitNV", 1, &E_GL_NV_shader_invocation_reorder);
9042 symbolTable.setFunctionExtensions("hitObjectGetRayTMinNV", 1, &E_GL_NV_shader_invocation_reorder);
9043 symbolTable.setFunctionExtensions("hitObjectGetRayTMaxNV", 1, &E_GL_NV_shader_invocation_reorder);
9044 symbolTable.setFunctionExtensions("hitObjectGetObjectRayOriginNV", 1, &E_GL_NV_shader_invocation_reorder);
9045 symbolTable.setFunctionExtensions("hitObjectGetObjectRayDirectionNV", 1, &E_GL_NV_shader_invocation_reorder);
9046 symbolTable.setFunctionExtensions("hitObjectGetWorldRayOriginNV", 1, &E_GL_NV_shader_invocation_reorder);
9047 symbolTable.setFunctionExtensions("hitObjectGetWorldRayDirectionNV", 1, &E_GL_NV_shader_invocation_reorder);
9048 symbolTable.setFunctionExtensions("hitObjectGetWorldToObjectNV", 1, &E_GL_NV_shader_invocation_reorder);
9049 symbolTable.setFunctionExtensions("hitObjectGetbjectToWorldNV", 1, &E_GL_NV_shader_invocation_reorder);
9050 symbolTable.setFunctionExtensions("hitObjectGetInstanceCustomIndexNV", 1, &E_GL_NV_shader_invocation_reorder);
9051 symbolTable.setFunctionExtensions("hitObjectGetInstanceIdNV", 1, &E_GL_NV_shader_invocation_reorder);
9052 symbolTable.setFunctionExtensions("hitObjectGetGeometryIndexNV", 1, &E_GL_NV_shader_invocation_reorder);
9053 symbolTable.setFunctionExtensions("hitObjectGetPrimitiveIndexNV", 1, &E_GL_NV_shader_invocation_reorder);
9054 symbolTable.setFunctionExtensions("hitObjectGetHitKindNV", 1, &E_GL_NV_shader_invocation_reorder);
9055 symbolTable.setFunctionExtensions("hitObjectGetAttributesNV", 1, &E_GL_NV_shader_invocation_reorder);
9056 symbolTable.setFunctionExtensions("hitObjectGetCurrentTimeNV", 1, &E_GL_NV_shader_invocation_reorder);
9057 symbolTable.setFunctionExtensions("hitObjectGetShaderBindingTableRecordIndexNV", 1, &E_GL_NV_shader_invocation_reorder);
9058 symbolTable.setFunctionExtensions("hitObjectGetShaderRecordBufferHandleNV", 1, &E_GL_NV_shader_invocation_reorder);
9059 symbolTable.setFunctionExtensions("reorderThreadNV", 1, &E_GL_NV_shader_invocation_reorder);
9060 symbolTable.setFunctionExtensions("fetchMicroTriangleVertexPositionNV", 1, &E_GL_NV_displacement_micromap);
9061 symbolTable.setFunctionExtensions("fetchMicroTriangleVertexBarycentricNV", 1, &E_GL_NV_displacement_micromap);
9062
9063
9064 BuiltInVariable("gl_LaunchIDNV", EbvLaunchId, symbolTable);
9065 BuiltInVariable("gl_LaunchIDEXT", EbvLaunchId, symbolTable);
9066 BuiltInVariable("gl_LaunchSizeNV", EbvLaunchSize, symbolTable);
9067 BuiltInVariable("gl_LaunchSizeEXT", EbvLaunchSize, symbolTable);
9068 BuiltInVariable("gl_PrimitiveID", EbvPrimitiveId, symbolTable);
9069 BuiltInVariable("gl_InstanceID", EbvInstanceId, symbolTable);
9070 BuiltInVariable("gl_InstanceCustomIndexNV", EbvInstanceCustomIndex,symbolTable);
9071 BuiltInVariable("gl_InstanceCustomIndexEXT", EbvInstanceCustomIndex,symbolTable);
9072 BuiltInVariable("gl_GeometryIndexEXT", EbvGeometryIndex, symbolTable);
9073 BuiltInVariable("gl_WorldRayOriginNV", EbvWorldRayOrigin, symbolTable);
9074 BuiltInVariable("gl_WorldRayOriginEXT", EbvWorldRayOrigin, symbolTable);
9075 BuiltInVariable("gl_WorldRayDirectionNV", EbvWorldRayDirection, symbolTable);
9076 BuiltInVariable("gl_WorldRayDirectionEXT", EbvWorldRayDirection, symbolTable);
9077 BuiltInVariable("gl_ObjectRayOriginNV", EbvObjectRayOrigin, symbolTable);
9078 BuiltInVariable("gl_ObjectRayOriginEXT", EbvObjectRayOrigin, symbolTable);
9079 BuiltInVariable("gl_ObjectRayDirectionNV", EbvObjectRayDirection, symbolTable);
9080 BuiltInVariable("gl_ObjectRayDirectionEXT", EbvObjectRayDirection, symbolTable);
9081 BuiltInVariable("gl_RayTminNV", EbvRayTmin, symbolTable);
9082 BuiltInVariable("gl_RayTminEXT", EbvRayTmin, symbolTable);
9083 BuiltInVariable("gl_RayTmaxNV", EbvRayTmax, symbolTable);
9084 BuiltInVariable("gl_RayTmaxEXT", EbvRayTmax, symbolTable);
9085 BuiltInVariable("gl_CullMaskEXT", EbvCullMask, symbolTable);
9086 BuiltInVariable("gl_HitTNV", EbvHitT, symbolTable);
9087 BuiltInVariable("gl_HitTEXT", EbvHitT, symbolTable);
9088 BuiltInVariable("gl_HitKindNV", EbvHitKind, symbolTable);
9089 BuiltInVariable("gl_HitKindEXT", EbvHitKind, symbolTable);
9090 BuiltInVariable("gl_ObjectToWorldNV", EbvObjectToWorld, symbolTable);
9091 BuiltInVariable("gl_ObjectToWorldEXT", EbvObjectToWorld, symbolTable);
9092 BuiltInVariable("gl_ObjectToWorld3x4EXT", EbvObjectToWorld3x4, symbolTable);
9093 BuiltInVariable("gl_WorldToObjectNV", EbvWorldToObject, symbolTable);
9094 BuiltInVariable("gl_WorldToObjectEXT", EbvWorldToObject, symbolTable);
9095 BuiltInVariable("gl_WorldToObject3x4EXT", EbvWorldToObject3x4, symbolTable);
9096 BuiltInVariable("gl_IncomingRayFlagsNV", EbvIncomingRayFlags, symbolTable);
9097 BuiltInVariable("gl_IncomingRayFlagsEXT", EbvIncomingRayFlags, symbolTable);
9098 BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
9099 BuiltInVariable("gl_CurrentRayTimeNV", EbvCurrentRayTimeNV, symbolTable);
9100 BuiltInVariable("gl_HitTriangleVertexPositionsEXT", EbvPositionFetch, symbolTable);
9101 BuiltInVariable("gl_HitMicroTriangleVertexPositionsNV", EbvMicroTrianglePositionNV, symbolTable);
9102 BuiltInVariable("gl_HitMicroTriangleVertexBarycentricsNV", EbvMicroTriangleBaryNV, symbolTable);
9103 BuiltInVariable("gl_HitKindFrontFacingMicroTriangleNV", EbvHitKindFrontFacingMicroTriangleNV, symbolTable);
9104 BuiltInVariable("gl_HitKindBackFacingMicroTriangleNV", EbvHitKindBackFacingMicroTriangleNV, symbolTable);
9105
9106 // GL_ARB_shader_ballot
9107 symbolTable.setVariableExtensions("gl_SubGroupSizeARB", 1, &E_GL_ARB_shader_ballot);
9108 symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
9109 symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB", 1, &E_GL_ARB_shader_ballot);
9110 symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB", 1, &E_GL_ARB_shader_ballot);
9111 symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB", 1, &E_GL_ARB_shader_ballot);
9112 symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB", 1, &E_GL_ARB_shader_ballot);
9113 symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB", 1, &E_GL_ARB_shader_ballot);
9114
9115 BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
9116 BuiltInVariable("gl_SubGroupEqMaskARB", EbvSubGroupEqMask, symbolTable);
9117 BuiltInVariable("gl_SubGroupGeMaskARB", EbvSubGroupGeMask, symbolTable);
9118 BuiltInVariable("gl_SubGroupGtMaskARB", EbvSubGroupGtMask, symbolTable);
9119 BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
9120 BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
9121
9122 if (spvVersion.vulkan > 0) {
9123 // Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
9124 SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
9125 if (language == EShLangFragment)
9126 ModifyFlatDecoration("gl_SubGroupSizeARB", true, symbolTable);
9127 }
9128 else
9129 BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
9130
9131 // GL_KHR_shader_subgroup
9132 symbolTable.setVariableExtensions("gl_NumSubgroups", 1, &E_GL_KHR_shader_subgroup_basic);
9133 symbolTable.setVariableExtensions("gl_SubgroupID", 1, &E_GL_KHR_shader_subgroup_basic);
9134 symbolTable.setVariableExtensions("gl_SubgroupSize", 1, &E_GL_KHR_shader_subgroup_basic);
9135 symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
9136 symbolTable.setVariableExtensions("gl_SubgroupEqMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9137 symbolTable.setVariableExtensions("gl_SubgroupGeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9138 symbolTable.setVariableExtensions("gl_SubgroupGtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9139 symbolTable.setVariableExtensions("gl_SubgroupLeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9140 symbolTable.setVariableExtensions("gl_SubgroupLtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9141
9142 BuiltInVariable("gl_NumSubgroups", EbvNumSubgroups, symbolTable);
9143 BuiltInVariable("gl_SubgroupID", EbvSubgroupID, symbolTable);
9144 BuiltInVariable("gl_SubgroupSize", EbvSubgroupSize2, symbolTable);
9145 BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
9146 BuiltInVariable("gl_SubgroupEqMask", EbvSubgroupEqMask2, symbolTable);
9147 BuiltInVariable("gl_SubgroupGeMask", EbvSubgroupGeMask2, symbolTable);
9148 BuiltInVariable("gl_SubgroupGtMask", EbvSubgroupGtMask2, symbolTable);
9149 BuiltInVariable("gl_SubgroupLeMask", EbvSubgroupLeMask2, symbolTable);
9150 BuiltInVariable("gl_SubgroupLtMask", EbvSubgroupLtMask2, symbolTable);
9151
9152 // GL_NV_shader_sm_builtins
9153 symbolTable.setVariableExtensions("gl_WarpsPerSMNV", 1, &E_GL_NV_shader_sm_builtins);
9154 symbolTable.setVariableExtensions("gl_SMCountNV", 1, &E_GL_NV_shader_sm_builtins);
9155 symbolTable.setVariableExtensions("gl_WarpIDNV", 1, &E_GL_NV_shader_sm_builtins);
9156 symbolTable.setVariableExtensions("gl_SMIDNV", 1, &E_GL_NV_shader_sm_builtins);
9157 BuiltInVariable("gl_WarpsPerSMNV", EbvWarpsPerSM, symbolTable);
9158 BuiltInVariable("gl_SMCountNV", EbvSMCount, symbolTable);
9159 BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable);
9160 BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable);
9161
9162 // GL_ARM_shader_core_builtins
9163 symbolTable.setVariableExtensions("gl_CoreCountARM", 1, &E_GL_ARM_shader_core_builtins);
9164 symbolTable.setVariableExtensions("gl_CoreIDARM", 1, &E_GL_ARM_shader_core_builtins);
9165 symbolTable.setVariableExtensions("gl_CoreMaxIDARM", 1, &E_GL_ARM_shader_core_builtins);
9166 symbolTable.setVariableExtensions("gl_WarpIDARM", 1, &E_GL_ARM_shader_core_builtins);
9167 symbolTable.setVariableExtensions("gl_WarpMaxIDARM", 1, &E_GL_ARM_shader_core_builtins);
9168
9169 BuiltInVariable("gl_CoreCountARM", EbvCoreCountARM, symbolTable);
9170 BuiltInVariable("gl_CoreIDARM", EbvCoreIDARM, symbolTable);
9171 BuiltInVariable("gl_CoreMaxIDARM", EbvCoreMaxIDARM, symbolTable);
9172 BuiltInVariable("gl_WarpIDARM", EbvWarpIDARM, symbolTable);
9173 BuiltInVariable("gl_WarpMaxIDARM", EbvWarpMaxIDARM, symbolTable);
9174 }
9175 if ((profile == EEsProfile && version >= 310) ||
9176 (profile != EEsProfile && version >= 450)) {
9177 symbolTable.setVariableExtensions("gl_ShadingRateFlag2VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9178 symbolTable.setVariableExtensions("gl_ShadingRateFlag4VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9179 symbolTable.setVariableExtensions("gl_ShadingRateFlag2HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9180 symbolTable.setVariableExtensions("gl_ShadingRateFlag4HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9181 }
9182 break;
9183
9184 case EShLangMesh:
9185 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
9186 // per-vertex builtins
9187 symbolTable.setVariableExtensions("gl_MeshVerticesNV", "gl_Position", 1, &E_GL_NV_mesh_shader);
9188 symbolTable.setVariableExtensions("gl_MeshVerticesNV", "gl_PointSize", 1, &E_GL_NV_mesh_shader);
9189 symbolTable.setVariableExtensions("gl_MeshVerticesNV", "gl_ClipDistance", 1, &E_GL_NV_mesh_shader);
9190 symbolTable.setVariableExtensions("gl_MeshVerticesNV", "gl_CullDistance", 1, &E_GL_NV_mesh_shader);
9191
9192 BuiltInVariable("gl_MeshVerticesNV", "gl_Position", EbvPosition, symbolTable);
9193 BuiltInVariable("gl_MeshVerticesNV", "gl_PointSize", EbvPointSize, symbolTable);
9194 BuiltInVariable("gl_MeshVerticesNV", "gl_ClipDistance", EbvClipDistance, symbolTable);
9195 BuiltInVariable("gl_MeshVerticesNV", "gl_CullDistance", EbvCullDistance, symbolTable);
9196
9197 symbolTable.setVariableExtensions("gl_MeshVerticesNV", "gl_PositionPerViewNV", 1, &E_GL_NV_mesh_shader);
9198 symbolTable.setVariableExtensions("gl_MeshVerticesNV", "gl_ClipDistancePerViewNV", 1, &E_GL_NV_mesh_shader);
9199 symbolTable.setVariableExtensions("gl_MeshVerticesNV", "gl_CullDistancePerViewNV", 1, &E_GL_NV_mesh_shader);
9200
9201 BuiltInVariable("gl_MeshVerticesNV", "gl_PositionPerViewNV", EbvPositionPerViewNV, symbolTable);
9202 BuiltInVariable("gl_MeshVerticesNV", "gl_ClipDistancePerViewNV", EbvClipDistancePerViewNV, symbolTable);
9203 BuiltInVariable("gl_MeshVerticesNV", "gl_CullDistancePerViewNV", EbvCullDistancePerViewNV, symbolTable);
9204
9205 // per-primitive builtins
9206 symbolTable.setVariableExtensions("gl_MeshPrimitivesNV", "gl_PrimitiveID", 1, &E_GL_NV_mesh_shader);
9207 symbolTable.setVariableExtensions("gl_MeshPrimitivesNV", "gl_Layer", 1, &E_GL_NV_mesh_shader);
9208 symbolTable.setVariableExtensions("gl_MeshPrimitivesNV", "gl_ViewportIndex", 1, &E_GL_NV_mesh_shader);
9209 symbolTable.setVariableExtensions("gl_MeshPrimitivesNV", "gl_ViewportMask", 1, &E_GL_NV_mesh_shader);
9210
9211 BuiltInVariable("gl_MeshPrimitivesNV", "gl_PrimitiveID", EbvPrimitiveId, symbolTable);
9212 BuiltInVariable("gl_MeshPrimitivesNV", "gl_Layer", EbvLayer, symbolTable);
9213 BuiltInVariable("gl_MeshPrimitivesNV", "gl_ViewportIndex", EbvViewportIndex, symbolTable);
9214 BuiltInVariable("gl_MeshPrimitivesNV", "gl_ViewportMask", EbvViewportMaskNV, symbolTable);
9215
9216 // per-view per-primitive builtins
9217 symbolTable.setVariableExtensions("gl_MeshPrimitivesNV", "gl_LayerPerViewNV", 1, &E_GL_NV_mesh_shader);
9218 symbolTable.setVariableExtensions("gl_MeshPrimitivesNV", "gl_ViewportMaskPerViewNV", 1, &E_GL_NV_mesh_shader);
9219
9220 BuiltInVariable("gl_MeshPrimitivesNV", "gl_LayerPerViewNV", EbvLayerPerViewNV, symbolTable);
9221 BuiltInVariable("gl_MeshPrimitivesNV", "gl_ViewportMaskPerViewNV", EbvViewportMaskPerViewNV, symbolTable);
9222
9223 // other builtins
9224 symbolTable.setVariableExtensions("gl_PrimitiveCountNV", 1, &E_GL_NV_mesh_shader);
9225 symbolTable.setVariableExtensions("gl_PrimitiveIndicesNV", 1, &E_GL_NV_mesh_shader);
9226 symbolTable.setVariableExtensions("gl_MeshViewCountNV", 1, &E_GL_NV_mesh_shader);
9227 symbolTable.setVariableExtensions("gl_MeshViewIndicesNV", 1, &E_GL_NV_mesh_shader);
9228 if (profile != EEsProfile) {
9229 symbolTable.setVariableExtensions("gl_WorkGroupSize", Num_AEP_mesh_shader, AEP_mesh_shader);
9230 symbolTable.setVariableExtensions("gl_WorkGroupID", Num_AEP_mesh_shader, AEP_mesh_shader);
9231 symbolTable.setVariableExtensions("gl_LocalInvocationID", Num_AEP_mesh_shader, AEP_mesh_shader);
9232 symbolTable.setVariableExtensions("gl_GlobalInvocationID", Num_AEP_mesh_shader, AEP_mesh_shader);
9233 symbolTable.setVariableExtensions("gl_LocalInvocationIndex", Num_AEP_mesh_shader, AEP_mesh_shader);
9234 } else {
9235 symbolTable.setVariableExtensions("gl_WorkGroupSize", 1, &E_GL_NV_mesh_shader);
9236 symbolTable.setVariableExtensions("gl_WorkGroupID", 1, &E_GL_NV_mesh_shader);
9237 symbolTable.setVariableExtensions("gl_LocalInvocationID", 1, &E_GL_NV_mesh_shader);
9238 symbolTable.setVariableExtensions("gl_GlobalInvocationID", 1, &E_GL_NV_mesh_shader);
9239 symbolTable.setVariableExtensions("gl_LocalInvocationIndex", 1, &E_GL_NV_mesh_shader);
9240 }
9241 BuiltInVariable("gl_PrimitiveCountNV", EbvPrimitiveCountNV, symbolTable);
9242 BuiltInVariable("gl_PrimitiveIndicesNV", EbvPrimitiveIndicesNV, symbolTable);
9243 BuiltInVariable("gl_MeshViewCountNV", EbvMeshViewCountNV, symbolTable);
9244 BuiltInVariable("gl_MeshViewIndicesNV", EbvMeshViewIndicesNV, symbolTable);
9245 BuiltInVariable("gl_WorkGroupSize", EbvWorkGroupSize, symbolTable);
9246 BuiltInVariable("gl_WorkGroupID", EbvWorkGroupId, symbolTable);
9247 BuiltInVariable("gl_LocalInvocationID", EbvLocalInvocationId, symbolTable);
9248 BuiltInVariable("gl_GlobalInvocationID", EbvGlobalInvocationId, symbolTable);
9249 BuiltInVariable("gl_LocalInvocationIndex", EbvLocalInvocationIndex, symbolTable);
9250
9251 // builtin constants
9252 symbolTable.setVariableExtensions("gl_MaxMeshOutputVerticesNV", 1, &E_GL_NV_mesh_shader);
9253 symbolTable.setVariableExtensions("gl_MaxMeshOutputPrimitivesNV", 1, &E_GL_NV_mesh_shader);
9254 symbolTable.setVariableExtensions("gl_MaxMeshWorkGroupSizeNV", 1, &E_GL_NV_mesh_shader);
9255 symbolTable.setVariableExtensions("gl_MaxMeshViewCountNV", 1, &E_GL_NV_mesh_shader);
9256
9257 // builtin functions
9258 if (profile != EEsProfile) {
9259 symbolTable.setFunctionExtensions("barrier", Num_AEP_mesh_shader, AEP_mesh_shader);
9260 symbolTable.setFunctionExtensions("memoryBarrierShared", Num_AEP_mesh_shader, AEP_mesh_shader);
9261 symbolTable.setFunctionExtensions("groupMemoryBarrier", Num_AEP_mesh_shader, AEP_mesh_shader);
9262 } else {
9263 symbolTable.setFunctionExtensions("barrier", 1, &E_GL_NV_mesh_shader);
9264 symbolTable.setFunctionExtensions("memoryBarrierShared", 1, &E_GL_NV_mesh_shader);
9265 symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_NV_mesh_shader);
9266 }
9267 symbolTable.setFunctionExtensions("writePackedPrimitiveIndices4x8NV", 1, &E_GL_NV_mesh_shader);
9268 }
9269
9270 if (profile != EEsProfile && version >= 450) {
9271 // GL_EXT_Mesh_shader
9272 symbolTable.setVariableExtensions("gl_PrimitivePointIndicesEXT", 1, &E_GL_EXT_mesh_shader);
9273 symbolTable.setVariableExtensions("gl_PrimitiveLineIndicesEXT", 1, &E_GL_EXT_mesh_shader);
9274 symbolTable.setVariableExtensions("gl_PrimitiveTriangleIndicesEXT", 1, &E_GL_EXT_mesh_shader);
9275 symbolTable.setVariableExtensions("gl_NumWorkGroups", 1, &E_GL_EXT_mesh_shader);
9276
9277 BuiltInVariable("gl_PrimitivePointIndicesEXT", EbvPrimitivePointIndicesEXT, symbolTable);
9278 BuiltInVariable("gl_PrimitiveLineIndicesEXT", EbvPrimitiveLineIndicesEXT, symbolTable);
9279 BuiltInVariable("gl_PrimitiveTriangleIndicesEXT", EbvPrimitiveTriangleIndicesEXT, symbolTable);
9280 BuiltInVariable("gl_NumWorkGroups", EbvNumWorkGroups, symbolTable);
9281
9282 symbolTable.setVariableExtensions("gl_MeshVerticesEXT", "gl_Position", 1, &E_GL_EXT_mesh_shader);
9283 symbolTable.setVariableExtensions("gl_MeshVerticesEXT", "gl_PointSize", 1, &E_GL_EXT_mesh_shader);
9284 symbolTable.setVariableExtensions("gl_MeshVerticesEXT", "gl_ClipDistance", 1, &E_GL_EXT_mesh_shader);
9285 symbolTable.setVariableExtensions("gl_MeshVerticesEXT", "gl_CullDistance", 1, &E_GL_EXT_mesh_shader);
9286
9287 BuiltInVariable("gl_MeshVerticesEXT", "gl_Position", EbvPosition, symbolTable);
9288 BuiltInVariable("gl_MeshVerticesEXT", "gl_PointSize", EbvPointSize, symbolTable);
9289 BuiltInVariable("gl_MeshVerticesEXT", "gl_ClipDistance", EbvClipDistance, symbolTable);
9290 BuiltInVariable("gl_MeshVerticesEXT", "gl_CullDistance", EbvCullDistance, symbolTable);
9291
9292 symbolTable.setVariableExtensions("gl_MeshPrimitivesEXT", "gl_PrimitiveID", 1, &E_GL_EXT_mesh_shader);
9293 symbolTable.setVariableExtensions("gl_MeshPrimitivesEXT", "gl_Layer", 1, &E_GL_EXT_mesh_shader);
9294 symbolTable.setVariableExtensions("gl_MeshPrimitivesEXT", "gl_ViewportIndex", 1, &E_GL_EXT_mesh_shader);
9295 symbolTable.setVariableExtensions("gl_MeshPrimitivesEXT", "gl_CullPrimitiveEXT", 1, &E_GL_EXT_mesh_shader);
9296
9297 // note: technically this member requires both GL_EXT_mesh_shader and GL_EXT_fragment_shading_rate
9298 // since setVariableExtensions only needs *one of* the extensions to validate, it's more useful to specify EXT_fragment_shading_rate
9299 // GL_EXT_mesh_shader will be required in practice by use of other fields of gl_MeshPrimitivesEXT
9300 symbolTable.setVariableExtensions("gl_MeshPrimitivesEXT", "gl_PrimitiveShadingRateEXT", 1, &E_GL_EXT_fragment_shading_rate);
9301
9302 BuiltInVariable("gl_MeshPrimitivesEXT", "gl_PrimitiveID", EbvPrimitiveId, symbolTable);
9303 BuiltInVariable("gl_MeshPrimitivesEXT", "gl_Layer", EbvLayer, symbolTable);
9304 BuiltInVariable("gl_MeshPrimitivesEXT", "gl_ViewportIndex", EbvViewportIndex, symbolTable);
9305 BuiltInVariable("gl_MeshPrimitivesEXT", "gl_CullPrimitiveEXT", EbvCullPrimitiveEXT, symbolTable);
9306 BuiltInVariable("gl_MeshPrimitivesEXT", "gl_PrimitiveShadingRateEXT", EbvPrimitiveShadingRateKHR, symbolTable);
9307
9308 symbolTable.setFunctionExtensions("SetMeshOutputsEXT", 1, &E_GL_EXT_mesh_shader);
9309
9310 // GL_EXT_device_group
9311 symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
9312 BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
9313
9314 // GL_ARB_shader_draw_parameters
9315 symbolTable.setVariableExtensions("gl_DrawIDARB", 1, &E_GL_ARB_shader_draw_parameters);
9316 BuiltInVariable("gl_DrawIDARB", EbvDrawId, symbolTable);
9317 if (version >= 460) {
9318 BuiltInVariable("gl_DrawID", EbvDrawId, symbolTable);
9319 }
9320 // GL_EXT_multiview
9321 BuiltInVariable("gl_ViewIndex", EbvViewIndex, symbolTable);
9322 symbolTable.setVariableExtensions("gl_ViewIndex", 1, &E_GL_EXT_multiview);
9323
9324 // GL_ARB_shader_ballot
9325 symbolTable.setVariableExtensions("gl_SubGroupSizeARB", 1, &E_GL_ARB_shader_ballot);
9326 symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
9327 symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB", 1, &E_GL_ARB_shader_ballot);
9328 symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB", 1, &E_GL_ARB_shader_ballot);
9329 symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB", 1, &E_GL_ARB_shader_ballot);
9330 symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB", 1, &E_GL_ARB_shader_ballot);
9331 symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB", 1, &E_GL_ARB_shader_ballot);
9332
9333 BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
9334 BuiltInVariable("gl_SubGroupEqMaskARB", EbvSubGroupEqMask, symbolTable);
9335 BuiltInVariable("gl_SubGroupGeMaskARB", EbvSubGroupGeMask, symbolTable);
9336 BuiltInVariable("gl_SubGroupGtMaskARB", EbvSubGroupGtMask, symbolTable);
9337 BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
9338 BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
9339
9340 if (spvVersion.vulkan > 0) {
9341 // Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
9342 SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
9343 if (language == EShLangFragment)
9344 ModifyFlatDecoration("gl_SubGroupSizeARB", true, symbolTable);
9345 }
9346 else
9347 BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
9348 }
9349
9350 // GL_KHR_shader_subgroup
9351 if ((profile == EEsProfile && version >= 310) ||
9352 (profile != EEsProfile && version >= 140)) {
9353 symbolTable.setVariableExtensions("gl_NumSubgroups", 1, &E_GL_KHR_shader_subgroup_basic);
9354 symbolTable.setVariableExtensions("gl_SubgroupID", 1, &E_GL_KHR_shader_subgroup_basic);
9355 symbolTable.setVariableExtensions("gl_SubgroupSize", 1, &E_GL_KHR_shader_subgroup_basic);
9356 symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
9357 symbolTable.setVariableExtensions("gl_SubgroupEqMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9358 symbolTable.setVariableExtensions("gl_SubgroupGeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9359 symbolTable.setVariableExtensions("gl_SubgroupGtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9360 symbolTable.setVariableExtensions("gl_SubgroupLeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9361 symbolTable.setVariableExtensions("gl_SubgroupLtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9362
9363 BuiltInVariable("gl_NumSubgroups", EbvNumSubgroups, symbolTable);
9364 BuiltInVariable("gl_SubgroupID", EbvSubgroupID, symbolTable);
9365 BuiltInVariable("gl_SubgroupSize", EbvSubgroupSize2, symbolTable);
9366 BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
9367 BuiltInVariable("gl_SubgroupEqMask", EbvSubgroupEqMask2, symbolTable);
9368 BuiltInVariable("gl_SubgroupGeMask", EbvSubgroupGeMask2, symbolTable);
9369 BuiltInVariable("gl_SubgroupGtMask", EbvSubgroupGtMask2, symbolTable);
9370 BuiltInVariable("gl_SubgroupLeMask", EbvSubgroupLeMask2, symbolTable);
9371 BuiltInVariable("gl_SubgroupLtMask", EbvSubgroupLtMask2, symbolTable);
9372
9373 symbolTable.setFunctionExtensions("subgroupMemoryBarrierShared", 1, &E_GL_KHR_shader_subgroup_basic);
9374
9375 // GL_NV_shader_sm_builtins
9376 symbolTable.setVariableExtensions("gl_WarpsPerSMNV", 1, &E_GL_NV_shader_sm_builtins);
9377 symbolTable.setVariableExtensions("gl_SMCountNV", 1, &E_GL_NV_shader_sm_builtins);
9378 symbolTable.setVariableExtensions("gl_WarpIDNV", 1, &E_GL_NV_shader_sm_builtins);
9379 symbolTable.setVariableExtensions("gl_SMIDNV", 1, &E_GL_NV_shader_sm_builtins);
9380 BuiltInVariable("gl_WarpsPerSMNV", EbvWarpsPerSM, symbolTable);
9381 BuiltInVariable("gl_SMCountNV", EbvSMCount, symbolTable);
9382 BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable);
9383 BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable);
9384
9385 // GL_ARM_shader_core_builtins
9386 symbolTable.setVariableExtensions("gl_CoreCountARM", 1, &E_GL_ARM_shader_core_builtins);
9387 symbolTable.setVariableExtensions("gl_CoreIDARM", 1, &E_GL_ARM_shader_core_builtins);
9388 symbolTable.setVariableExtensions("gl_CoreMaxIDARM", 1, &E_GL_ARM_shader_core_builtins);
9389 symbolTable.setVariableExtensions("gl_WarpIDARM", 1, &E_GL_ARM_shader_core_builtins);
9390 symbolTable.setVariableExtensions("gl_WarpMaxIDARM", 1, &E_GL_ARM_shader_core_builtins);
9391
9392 BuiltInVariable("gl_CoreCountARM", EbvCoreCountARM, symbolTable);
9393 BuiltInVariable("gl_CoreIDARM", EbvCoreIDARM, symbolTable);
9394 BuiltInVariable("gl_CoreMaxIDARM", EbvCoreMaxIDARM, symbolTable);
9395 BuiltInVariable("gl_WarpIDARM", EbvWarpIDARM, symbolTable);
9396 BuiltInVariable("gl_WarpMaxIDARM", EbvWarpMaxIDARM, symbolTable);
9397 }
9398
9399 if ((profile == EEsProfile && version >= 310) ||
9400 (profile != EEsProfile && version >= 450)) {
9401 symbolTable.setVariableExtensions("gl_ShadingRateFlag2VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9402 symbolTable.setVariableExtensions("gl_ShadingRateFlag4VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9403 symbolTable.setVariableExtensions("gl_ShadingRateFlag2HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9404 symbolTable.setVariableExtensions("gl_ShadingRateFlag4HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9405 }
9406
9407 // Builtins for GL_NV_displacment_micromap
9408 if ((profile != EEsProfile && version >= 460)) {
9409 symbolTable.setFunctionExtensions("fetchMicroTriangleVertexPositionNV", 1, &E_GL_NV_displacement_micromap);
9410 symbolTable.setFunctionExtensions("fetchMicroTriangleVertexBarycentricNV", 1, &E_GL_NV_displacement_micromap);
9411 }
9412
9413 break;
9414
9415 case EShLangTask:
9416 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
9417 symbolTable.setVariableExtensions("gl_TaskCountNV", 1, &E_GL_NV_mesh_shader);
9418 symbolTable.setVariableExtensions("gl_MeshViewCountNV", 1, &E_GL_NV_mesh_shader);
9419 symbolTable.setVariableExtensions("gl_MeshViewIndicesNV", 1, &E_GL_NV_mesh_shader);
9420 if (profile != EEsProfile) {
9421 symbolTable.setVariableExtensions("gl_WorkGroupSize", Num_AEP_mesh_shader, AEP_mesh_shader);
9422 symbolTable.setVariableExtensions("gl_WorkGroupID", Num_AEP_mesh_shader, AEP_mesh_shader);
9423 symbolTable.setVariableExtensions("gl_LocalInvocationID", Num_AEP_mesh_shader, AEP_mesh_shader);
9424 symbolTable.setVariableExtensions("gl_GlobalInvocationID", Num_AEP_mesh_shader, AEP_mesh_shader);
9425 symbolTable.setVariableExtensions("gl_LocalInvocationIndex", Num_AEP_mesh_shader, AEP_mesh_shader);
9426 } else {
9427 symbolTable.setVariableExtensions("gl_WorkGroupSize", 1, &E_GL_NV_mesh_shader);
9428 symbolTable.setVariableExtensions("gl_WorkGroupID", 1, &E_GL_NV_mesh_shader);
9429 symbolTable.setVariableExtensions("gl_LocalInvocationID", 1, &E_GL_NV_mesh_shader);
9430 symbolTable.setVariableExtensions("gl_GlobalInvocationID", 1, &E_GL_NV_mesh_shader);
9431 symbolTable.setVariableExtensions("gl_LocalInvocationIndex", 1, &E_GL_NV_mesh_shader);
9432 }
9433
9434 BuiltInVariable("gl_TaskCountNV", EbvTaskCountNV, symbolTable);
9435 BuiltInVariable("gl_WorkGroupSize", EbvWorkGroupSize, symbolTable);
9436 BuiltInVariable("gl_WorkGroupID", EbvWorkGroupId, symbolTable);
9437 BuiltInVariable("gl_LocalInvocationID", EbvLocalInvocationId, symbolTable);
9438 BuiltInVariable("gl_GlobalInvocationID", EbvGlobalInvocationId, symbolTable);
9439 BuiltInVariable("gl_LocalInvocationIndex", EbvLocalInvocationIndex, symbolTable);
9440 BuiltInVariable("gl_MeshViewCountNV", EbvMeshViewCountNV, symbolTable);
9441 BuiltInVariable("gl_MeshViewIndicesNV", EbvMeshViewIndicesNV, symbolTable);
9442
9443 symbolTable.setVariableExtensions("gl_MaxTaskWorkGroupSizeNV", 1, &E_GL_NV_mesh_shader);
9444 symbolTable.setVariableExtensions("gl_MaxMeshViewCountNV", 1, &E_GL_NV_mesh_shader);
9445
9446 if (profile != EEsProfile) {
9447 symbolTable.setFunctionExtensions("barrier", Num_AEP_mesh_shader, AEP_mesh_shader);
9448 symbolTable.setFunctionExtensions("memoryBarrierShared", Num_AEP_mesh_shader, AEP_mesh_shader);
9449 symbolTable.setFunctionExtensions("groupMemoryBarrier", Num_AEP_mesh_shader, AEP_mesh_shader);
9450 } else {
9451 symbolTable.setFunctionExtensions("barrier", 1, &E_GL_NV_mesh_shader);
9452 symbolTable.setFunctionExtensions("memoryBarrierShared", 1, &E_GL_NV_mesh_shader);
9453 symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_NV_mesh_shader);
9454 }
9455 }
9456
9457 if (profile != EEsProfile && version >= 450) {
9458 // GL_EXT_mesh_shader
9459 symbolTable.setFunctionExtensions("EmitMeshTasksEXT", 1, &E_GL_EXT_mesh_shader);
9460 symbolTable.setVariableExtensions("gl_NumWorkGroups", 1, &E_GL_EXT_mesh_shader);
9461 BuiltInVariable("gl_NumWorkGroups", EbvNumWorkGroups, symbolTable);
9462
9463 // GL_EXT_device_group
9464 symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group);
9465 BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable);
9466
9467 // GL_ARB_shader_draw_parameters
9468 symbolTable.setVariableExtensions("gl_DrawIDARB", 1, &E_GL_ARB_shader_draw_parameters);
9469 BuiltInVariable("gl_DrawIDARB", EbvDrawId, symbolTable);
9470 if (version >= 460) {
9471 BuiltInVariable("gl_DrawID", EbvDrawId, symbolTable);
9472 }
9473
9474 // GL_ARB_shader_ballot
9475 symbolTable.setVariableExtensions("gl_SubGroupSizeARB", 1, &E_GL_ARB_shader_ballot);
9476 symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot);
9477 symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB", 1, &E_GL_ARB_shader_ballot);
9478 symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB", 1, &E_GL_ARB_shader_ballot);
9479 symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB", 1, &E_GL_ARB_shader_ballot);
9480 symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB", 1, &E_GL_ARB_shader_ballot);
9481 symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB", 1, &E_GL_ARB_shader_ballot);
9482
9483 BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable);
9484 BuiltInVariable("gl_SubGroupEqMaskARB", EbvSubGroupEqMask, symbolTable);
9485 BuiltInVariable("gl_SubGroupGeMaskARB", EbvSubGroupGeMask, symbolTable);
9486 BuiltInVariable("gl_SubGroupGtMaskARB", EbvSubGroupGtMask, symbolTable);
9487 BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable);
9488 BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable);
9489
9490 if (spvVersion.vulkan > 0) {
9491 // Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan
9492 SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable);
9493 if (language == EShLangFragment)
9494 ModifyFlatDecoration("gl_SubGroupSizeARB", true, symbolTable);
9495 }
9496 else
9497 BuiltInVariable("gl_SubGroupSizeARB", EbvSubGroupSize, symbolTable);
9498 }
9499
9500 // GL_KHR_shader_subgroup
9501 if ((profile == EEsProfile && version >= 310) ||
9502 (profile != EEsProfile && version >= 140)) {
9503 symbolTable.setVariableExtensions("gl_NumSubgroups", 1, &E_GL_KHR_shader_subgroup_basic);
9504 symbolTable.setVariableExtensions("gl_SubgroupID", 1, &E_GL_KHR_shader_subgroup_basic);
9505 symbolTable.setVariableExtensions("gl_SubgroupSize", 1, &E_GL_KHR_shader_subgroup_basic);
9506 symbolTable.setVariableExtensions("gl_SubgroupInvocationID", 1, &E_GL_KHR_shader_subgroup_basic);
9507 symbolTable.setVariableExtensions("gl_SubgroupEqMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9508 symbolTable.setVariableExtensions("gl_SubgroupGeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9509 symbolTable.setVariableExtensions("gl_SubgroupGtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9510 symbolTable.setVariableExtensions("gl_SubgroupLeMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9511 symbolTable.setVariableExtensions("gl_SubgroupLtMask", 1, &E_GL_KHR_shader_subgroup_ballot);
9512
9513 BuiltInVariable("gl_NumSubgroups", EbvNumSubgroups, symbolTable);
9514 BuiltInVariable("gl_SubgroupID", EbvSubgroupID, symbolTable);
9515 BuiltInVariable("gl_SubgroupSize", EbvSubgroupSize2, symbolTable);
9516 BuiltInVariable("gl_SubgroupInvocationID", EbvSubgroupInvocation2, symbolTable);
9517 BuiltInVariable("gl_SubgroupEqMask", EbvSubgroupEqMask2, symbolTable);
9518 BuiltInVariable("gl_SubgroupGeMask", EbvSubgroupGeMask2, symbolTable);
9519 BuiltInVariable("gl_SubgroupGtMask", EbvSubgroupGtMask2, symbolTable);
9520 BuiltInVariable("gl_SubgroupLeMask", EbvSubgroupLeMask2, symbolTable);
9521 BuiltInVariable("gl_SubgroupLtMask", EbvSubgroupLtMask2, symbolTable);
9522
9523 symbolTable.setFunctionExtensions("subgroupMemoryBarrierShared", 1, &E_GL_KHR_shader_subgroup_basic);
9524
9525 // GL_NV_shader_sm_builtins
9526 symbolTable.setVariableExtensions("gl_WarpsPerSMNV", 1, &E_GL_NV_shader_sm_builtins);
9527 symbolTable.setVariableExtensions("gl_SMCountNV", 1, &E_GL_NV_shader_sm_builtins);
9528 symbolTable.setVariableExtensions("gl_WarpIDNV", 1, &E_GL_NV_shader_sm_builtins);
9529 symbolTable.setVariableExtensions("gl_SMIDNV", 1, &E_GL_NV_shader_sm_builtins);
9530 BuiltInVariable("gl_WarpsPerSMNV", EbvWarpsPerSM, symbolTable);
9531 BuiltInVariable("gl_SMCountNV", EbvSMCount, symbolTable);
9532 BuiltInVariable("gl_WarpIDNV", EbvWarpID, symbolTable);
9533 BuiltInVariable("gl_SMIDNV", EbvSMID, symbolTable);
9534
9535 // GL_ARM_shader_core_builtins
9536 symbolTable.setVariableExtensions("gl_CoreCountARM", 1, &E_GL_ARM_shader_core_builtins);
9537 symbolTable.setVariableExtensions("gl_CoreIDARM", 1, &E_GL_ARM_shader_core_builtins);
9538 symbolTable.setVariableExtensions("gl_CoreMaxIDARM", 1, &E_GL_ARM_shader_core_builtins);
9539 symbolTable.setVariableExtensions("gl_WarpIDARM", 1, &E_GL_ARM_shader_core_builtins);
9540 symbolTable.setVariableExtensions("gl_WarpMaxIDARM", 1, &E_GL_ARM_shader_core_builtins);
9541
9542 BuiltInVariable("gl_CoreCountARM", EbvCoreCountARM, symbolTable);
9543 BuiltInVariable("gl_CoreIDARM", EbvCoreIDARM, symbolTable);
9544 BuiltInVariable("gl_CoreMaxIDARM", EbvCoreMaxIDARM, symbolTable);
9545 BuiltInVariable("gl_WarpIDARM", EbvWarpIDARM, symbolTable);
9546 BuiltInVariable("gl_WarpMaxIDARM", EbvWarpMaxIDARM, symbolTable);
9547 }
9548 if ((profile == EEsProfile && version >= 310) ||
9549 (profile != EEsProfile && version >= 450)) {
9550 symbolTable.setVariableExtensions("gl_ShadingRateFlag2VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9551 symbolTable.setVariableExtensions("gl_ShadingRateFlag4VerticalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9552 symbolTable.setVariableExtensions("gl_ShadingRateFlag2HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9553 symbolTable.setVariableExtensions("gl_ShadingRateFlag4HorizontalPixelsEXT", 1, &E_GL_EXT_fragment_shading_rate);
9554 }
9555 break;
9556
9557 default:
9558 assert(false && "Language not supported");
9559 break;
9560 }
9561
9562 //
9563 // Next, identify which built-ins have a mapping to an operator.
9564 // If PureOperatorBuiltins is false, those that are not identified as such are
9565 // expected to be resolved through a library of functions, versus as
9566 // operations.
9567 //
9568
9569 relateTabledBuiltins(version, profile, spvVersion, language, symbolTable);
9570
9571 symbolTable.relateToOperator("doubleBitsToInt64", EOpDoubleBitsToInt64);
9572 symbolTable.relateToOperator("doubleBitsToUint64", EOpDoubleBitsToUint64);
9573 symbolTable.relateToOperator("int64BitsToDouble", EOpInt64BitsToDouble);
9574 symbolTable.relateToOperator("uint64BitsToDouble", EOpUint64BitsToDouble);
9575 symbolTable.relateToOperator("halfBitsToInt16", EOpFloat16BitsToInt16);
9576 symbolTable.relateToOperator("halfBitsToUint16", EOpFloat16BitsToUint16);
9577 symbolTable.relateToOperator("float16BitsToInt16", EOpFloat16BitsToInt16);
9578 symbolTable.relateToOperator("float16BitsToUint16", EOpFloat16BitsToUint16);
9579 symbolTable.relateToOperator("int16BitsToFloat16", EOpInt16BitsToFloat16);
9580 symbolTable.relateToOperator("uint16BitsToFloat16", EOpUint16BitsToFloat16);
9581
9582 symbolTable.relateToOperator("int16BitsToHalf", EOpInt16BitsToFloat16);
9583 symbolTable.relateToOperator("uint16BitsToHalf", EOpUint16BitsToFloat16);
9584
9585 symbolTable.relateToOperator("packSnorm4x8", EOpPackSnorm4x8);
9586 symbolTable.relateToOperator("unpackSnorm4x8", EOpUnpackSnorm4x8);
9587 symbolTable.relateToOperator("packUnorm4x8", EOpPackUnorm4x8);
9588 symbolTable.relateToOperator("unpackUnorm4x8", EOpUnpackUnorm4x8);
9589
9590 symbolTable.relateToOperator("packDouble2x32", EOpPackDouble2x32);
9591 symbolTable.relateToOperator("unpackDouble2x32", EOpUnpackDouble2x32);
9592
9593 symbolTable.relateToOperator("packInt2x32", EOpPackInt2x32);
9594 symbolTable.relateToOperator("unpackInt2x32", EOpUnpackInt2x32);
9595 symbolTable.relateToOperator("packUint2x32", EOpPackUint2x32);
9596 symbolTable.relateToOperator("unpackUint2x32", EOpUnpackUint2x32);
9597
9598 symbolTable.relateToOperator("packInt2x16", EOpPackInt2x16);
9599 symbolTable.relateToOperator("unpackInt2x16", EOpUnpackInt2x16);
9600 symbolTable.relateToOperator("packUint2x16", EOpPackUint2x16);
9601 symbolTable.relateToOperator("unpackUint2x16", EOpUnpackUint2x16);
9602
9603 symbolTable.relateToOperator("packInt4x16", EOpPackInt4x16);
9604 symbolTable.relateToOperator("unpackInt4x16", EOpUnpackInt4x16);
9605 symbolTable.relateToOperator("packUint4x16", EOpPackUint4x16);
9606 symbolTable.relateToOperator("unpackUint4x16", EOpUnpackUint4x16);
9607 symbolTable.relateToOperator("packFloat2x16", EOpPackFloat2x16);
9608 symbolTable.relateToOperator("unpackFloat2x16", EOpUnpackFloat2x16);
9609
9610 symbolTable.relateToOperator("pack16", EOpPack16);
9611 symbolTable.relateToOperator("pack32", EOpPack32);
9612 symbolTable.relateToOperator("pack64", EOpPack64);
9613
9614 symbolTable.relateToOperator("unpack32", EOpUnpack32);
9615 symbolTable.relateToOperator("unpack16", EOpUnpack16);
9616 symbolTable.relateToOperator("unpack8", EOpUnpack8);
9617
9618 symbolTable.relateToOperator("controlBarrier", EOpBarrier);
9619 symbolTable.relateToOperator("memoryBarrierAtomicCounter", EOpMemoryBarrierAtomicCounter);
9620 symbolTable.relateToOperator("memoryBarrierImage", EOpMemoryBarrierImage);
9621
9622 if (spvVersion.vulkanRelaxed) {
9623 //
9624 // functions signature have been replaced to take uint operations on buffer variables
9625 // remap atomic counter functions to atomic operations
9626 //
9627 symbolTable.relateToOperator("memoryBarrierAtomicCounter", EOpMemoryBarrierBuffer);
9628 }
9629
9630 symbolTable.relateToOperator("atomicLoad", EOpAtomicLoad);
9631 symbolTable.relateToOperator("atomicStore", EOpAtomicStore);
9632
9633 symbolTable.relateToOperator("atomicCounterIncrement", EOpAtomicCounterIncrement);
9634 symbolTable.relateToOperator("atomicCounterDecrement", EOpAtomicCounterDecrement);
9635 symbolTable.relateToOperator("atomicCounter", EOpAtomicCounter);
9636
9637 if (spvVersion.vulkanRelaxed) {
9638 //
9639 // functions signature have been replaced to take uint operations
9640 // remap atomic counter functions to atomic operations
9641 //
9642 // these atomic counter functions do not match signatures of glsl
9643 // atomic functions, so they will be remapped to semantically
9644 // equivalent functions in the parser
9645 //
9646 symbolTable.relateToOperator("atomicCounterIncrement", EOpNull);
9647 symbolTable.relateToOperator("atomicCounterDecrement", EOpNull);
9648 symbolTable.relateToOperator("atomicCounter", EOpNull);
9649 }
9650
9651 symbolTable.relateToOperator("clockARB", EOpReadClockSubgroupKHR);
9652 symbolTable.relateToOperator("clock2x32ARB", EOpReadClockSubgroupKHR);
9653
9654 symbolTable.relateToOperator("clockRealtimeEXT", EOpReadClockDeviceKHR);
9655 symbolTable.relateToOperator("clockRealtime2x32EXT", EOpReadClockDeviceKHR);
9656
9657 if (profile != EEsProfile && version == 450) {
9658 symbolTable.relateToOperator("atomicCounterAddARB", EOpAtomicCounterAdd);
9659 symbolTable.relateToOperator("atomicCounterSubtractARB", EOpAtomicCounterSubtract);
9660 symbolTable.relateToOperator("atomicCounterMinARB", EOpAtomicCounterMin);
9661 symbolTable.relateToOperator("atomicCounterMaxARB", EOpAtomicCounterMax);
9662 symbolTable.relateToOperator("atomicCounterAndARB", EOpAtomicCounterAnd);
9663 symbolTable.relateToOperator("atomicCounterOrARB", EOpAtomicCounterOr);
9664 symbolTable.relateToOperator("atomicCounterXorARB", EOpAtomicCounterXor);
9665 symbolTable.relateToOperator("atomicCounterExchangeARB", EOpAtomicCounterExchange);
9666 symbolTable.relateToOperator("atomicCounterCompSwapARB", EOpAtomicCounterCompSwap);
9667 }
9668
9669 if (profile != EEsProfile && version >= 460) {
9670 symbolTable.relateToOperator("atomicCounterAdd", EOpAtomicCounterAdd);
9671 symbolTable.relateToOperator("atomicCounterSubtract", EOpAtomicCounterSubtract);
9672 symbolTable.relateToOperator("atomicCounterMin", EOpAtomicCounterMin);
9673 symbolTable.relateToOperator("atomicCounterMax", EOpAtomicCounterMax);
9674 symbolTable.relateToOperator("atomicCounterAnd", EOpAtomicCounterAnd);
9675 symbolTable.relateToOperator("atomicCounterOr", EOpAtomicCounterOr);
9676 symbolTable.relateToOperator("atomicCounterXor", EOpAtomicCounterXor);
9677 symbolTable.relateToOperator("atomicCounterExchange", EOpAtomicCounterExchange);
9678 symbolTable.relateToOperator("atomicCounterCompSwap", EOpAtomicCounterCompSwap);
9679 }
9680
9681 if (spvVersion.vulkanRelaxed) {
9682 //
9683 // functions signature have been replaced to take 'uint' instead of 'atomic_uint'
9684 // remap atomic counter functions to non-counter atomic ops so
9685 // functions act as aliases to non-counter atomic ops
9686 //
9687 symbolTable.relateToOperator("atomicCounterAdd", EOpAtomicAdd);
9688 symbolTable.relateToOperator("atomicCounterSubtract", EOpAtomicSubtract);
9689 symbolTable.relateToOperator("atomicCounterMin", EOpAtomicMin);
9690 symbolTable.relateToOperator("atomicCounterMax", EOpAtomicMax);
9691 symbolTable.relateToOperator("atomicCounterAnd", EOpAtomicAnd);
9692 symbolTable.relateToOperator("atomicCounterOr", EOpAtomicOr);
9693 symbolTable.relateToOperator("atomicCounterXor", EOpAtomicXor);
9694 symbolTable.relateToOperator("atomicCounterExchange", EOpAtomicExchange);
9695 symbolTable.relateToOperator("atomicCounterCompSwap", EOpAtomicCompSwap);
9696 }
9697
9698 symbolTable.relateToOperator("fma", EOpFma);
9699 symbolTable.relateToOperator("frexp", EOpFrexp);
9700 symbolTable.relateToOperator("ldexp", EOpLdexp);
9701 symbolTable.relateToOperator("uaddCarry", EOpAddCarry);
9702 symbolTable.relateToOperator("usubBorrow", EOpSubBorrow);
9703 symbolTable.relateToOperator("umulExtended", EOpUMulExtended);
9704 symbolTable.relateToOperator("imulExtended", EOpIMulExtended);
9705 symbolTable.relateToOperator("bitfieldExtract", EOpBitfieldExtract);
9706 symbolTable.relateToOperator("bitfieldInsert", EOpBitfieldInsert);
9707 symbolTable.relateToOperator("bitfieldReverse", EOpBitFieldReverse);
9708 symbolTable.relateToOperator("bitCount", EOpBitCount);
9709 symbolTable.relateToOperator("findLSB", EOpFindLSB);
9710 symbolTable.relateToOperator("findMSB", EOpFindMSB);
9711
9712 symbolTable.relateToOperator("helperInvocationEXT", EOpIsHelperInvocation);
9713
9714 symbolTable.relateToOperator("countLeadingZeros", EOpCountLeadingZeros);
9715 symbolTable.relateToOperator("countTrailingZeros", EOpCountTrailingZeros);
9716 symbolTable.relateToOperator("absoluteDifference", EOpAbsDifference);
9717 symbolTable.relateToOperator("addSaturate", EOpAddSaturate);
9718 symbolTable.relateToOperator("subtractSaturate", EOpSubSaturate);
9719 symbolTable.relateToOperator("average", EOpAverage);
9720 symbolTable.relateToOperator("averageRounded", EOpAverageRounded);
9721 symbolTable.relateToOperator("multiply32x16", EOpMul32x16);
9722 symbolTable.relateToOperator("debugPrintfEXT", EOpDebugPrintf);
9723
9724
9725 if (PureOperatorBuiltins) {
9726 symbolTable.relateToOperator("imageSize", EOpImageQuerySize);
9727 symbolTable.relateToOperator("imageSamples", EOpImageQuerySamples);
9728 symbolTable.relateToOperator("imageLoad", EOpImageLoad);
9729 symbolTable.relateToOperator("imageStore", EOpImageStore);
9730 symbolTable.relateToOperator("imageAtomicAdd", EOpImageAtomicAdd);
9731 symbolTable.relateToOperator("imageAtomicMin", EOpImageAtomicMin);
9732 symbolTable.relateToOperator("imageAtomicMax", EOpImageAtomicMax);
9733 symbolTable.relateToOperator("imageAtomicAnd", EOpImageAtomicAnd);
9734 symbolTable.relateToOperator("imageAtomicOr", EOpImageAtomicOr);
9735 symbolTable.relateToOperator("imageAtomicXor", EOpImageAtomicXor);
9736 symbolTable.relateToOperator("imageAtomicExchange", EOpImageAtomicExchange);
9737 symbolTable.relateToOperator("imageAtomicCompSwap", EOpImageAtomicCompSwap);
9738 symbolTable.relateToOperator("imageAtomicLoad", EOpImageAtomicLoad);
9739 symbolTable.relateToOperator("imageAtomicStore", EOpImageAtomicStore);
9740
9741 symbolTable.relateToOperator("subpassLoad", EOpSubpassLoad);
9742 symbolTable.relateToOperator("subpassLoadMS", EOpSubpassLoadMS);
9743
9744 symbolTable.relateToOperator("textureGather", EOpTextureGather);
9745 symbolTable.relateToOperator("textureGatherOffset", EOpTextureGatherOffset);
9746 symbolTable.relateToOperator("textureGatherOffsets", EOpTextureGatherOffsets);
9747
9748 symbolTable.relateToOperator("noise1", EOpNoise);
9749 symbolTable.relateToOperator("noise2", EOpNoise);
9750 symbolTable.relateToOperator("noise3", EOpNoise);
9751 symbolTable.relateToOperator("noise4", EOpNoise);
9752
9753 symbolTable.relateToOperator("textureFootprintNV", EOpImageSampleFootprintNV);
9754 symbolTable.relateToOperator("textureFootprintClampNV", EOpImageSampleFootprintClampNV);
9755 symbolTable.relateToOperator("textureFootprintLodNV", EOpImageSampleFootprintLodNV);
9756 symbolTable.relateToOperator("textureFootprintGradNV", EOpImageSampleFootprintGradNV);
9757 symbolTable.relateToOperator("textureFootprintGradClampNV", EOpImageSampleFootprintGradClampNV);
9758
9759 if (spvVersion.spv == 0 && IncludeLegacy(version, profile, spvVersion))
9760 symbolTable.relateToOperator("ftransform", EOpFtransform);
9761
9762 if (spvVersion.spv == 0 && (IncludeLegacy(version, profile, spvVersion) ||
9763 (profile == EEsProfile && version == 100))) {
9764
9765 symbolTable.relateToOperator("texture1D", EOpTexture);
9766 symbolTable.relateToOperator("texture1DGradARB", EOpTextureGrad);
9767 symbolTable.relateToOperator("texture1DProj", EOpTextureProj);
9768 symbolTable.relateToOperator("texture1DProjGradARB", EOpTextureProjGrad);
9769 symbolTable.relateToOperator("texture1DLod", EOpTextureLod);
9770 symbolTable.relateToOperator("texture1DProjLod", EOpTextureProjLod);
9771
9772 symbolTable.relateToOperator("texture2DRect", EOpTexture);
9773 symbolTable.relateToOperator("texture2DRectProj", EOpTextureProj);
9774 symbolTable.relateToOperator("texture2DRectGradARB", EOpTextureGrad);
9775 symbolTable.relateToOperator("texture2DRectProjGradARB", EOpTextureProjGrad);
9776 symbolTable.relateToOperator("shadow2DRect", EOpTexture);
9777 symbolTable.relateToOperator("shadow2DRectProj", EOpTextureProj);
9778 symbolTable.relateToOperator("shadow2DRectGradARB", EOpTextureGrad);
9779 symbolTable.relateToOperator("shadow2DRectProjGradARB", EOpTextureProjGrad);
9780
9781 symbolTable.relateToOperator("texture2D", EOpTexture);
9782 symbolTable.relateToOperator("texture2DProj", EOpTextureProj);
9783 symbolTable.relateToOperator("texture2DGradEXT", EOpTextureGrad);
9784 symbolTable.relateToOperator("texture2DGradARB", EOpTextureGrad);
9785 symbolTable.relateToOperator("texture2DProjGradEXT", EOpTextureProjGrad);
9786 symbolTable.relateToOperator("texture2DProjGradARB", EOpTextureProjGrad);
9787 symbolTable.relateToOperator("texture2DLod", EOpTextureLod);
9788 symbolTable.relateToOperator("texture2DLodEXT", EOpTextureLod);
9789 symbolTable.relateToOperator("texture2DProjLod", EOpTextureProjLod);
9790 symbolTable.relateToOperator("texture2DProjLodEXT", EOpTextureProjLod);
9791
9792 symbolTable.relateToOperator("texture3D", EOpTexture);
9793 symbolTable.relateToOperator("texture3DGradARB", EOpTextureGrad);
9794 symbolTable.relateToOperator("texture3DProj", EOpTextureProj);
9795 symbolTable.relateToOperator("texture3DProjGradARB", EOpTextureProjGrad);
9796 symbolTable.relateToOperator("texture3DLod", EOpTextureLod);
9797 symbolTable.relateToOperator("texture3DProjLod", EOpTextureProjLod);
9798 symbolTable.relateToOperator("textureCube", EOpTexture);
9799 symbolTable.relateToOperator("textureCubeGradEXT", EOpTextureGrad);
9800 symbolTable.relateToOperator("textureCubeGradARB", EOpTextureGrad);
9801 symbolTable.relateToOperator("textureCubeLod", EOpTextureLod);
9802 symbolTable.relateToOperator("textureCubeLodEXT", EOpTextureLod);
9803 symbolTable.relateToOperator("shadow1D", EOpTexture);
9804 symbolTable.relateToOperator("shadow1DGradARB", EOpTextureGrad);
9805 symbolTable.relateToOperator("shadow2D", EOpTexture);
9806 symbolTable.relateToOperator("shadow2DGradARB", EOpTextureGrad);
9807 symbolTable.relateToOperator("shadow1DProj", EOpTextureProj);
9808 symbolTable.relateToOperator("shadow2DProj", EOpTextureProj);
9809 symbolTable.relateToOperator("shadow1DProjGradARB", EOpTextureProjGrad);
9810 symbolTable.relateToOperator("shadow2DProjGradARB", EOpTextureProjGrad);
9811 symbolTable.relateToOperator("shadow1DLod", EOpTextureLod);
9812 symbolTable.relateToOperator("shadow2DLod", EOpTextureLod);
9813 symbolTable.relateToOperator("shadow1DProjLod", EOpTextureProjLod);
9814 symbolTable.relateToOperator("shadow2DProjLod", EOpTextureProjLod);
9815 }
9816
9817 if (profile != EEsProfile) {
9818 symbolTable.relateToOperator("sparseTextureARB", EOpSparseTexture);
9819 symbolTable.relateToOperator("sparseTextureLodARB", EOpSparseTextureLod);
9820 symbolTable.relateToOperator("sparseTextureOffsetARB", EOpSparseTextureOffset);
9821 symbolTable.relateToOperator("sparseTexelFetchARB", EOpSparseTextureFetch);
9822 symbolTable.relateToOperator("sparseTexelFetchOffsetARB", EOpSparseTextureFetchOffset);
9823 symbolTable.relateToOperator("sparseTextureLodOffsetARB", EOpSparseTextureLodOffset);
9824 symbolTable.relateToOperator("sparseTextureGradARB", EOpSparseTextureGrad);
9825 symbolTable.relateToOperator("sparseTextureGradOffsetARB", EOpSparseTextureGradOffset);
9826 symbolTable.relateToOperator("sparseTextureGatherARB", EOpSparseTextureGather);
9827 symbolTable.relateToOperator("sparseTextureGatherOffsetARB", EOpSparseTextureGatherOffset);
9828 symbolTable.relateToOperator("sparseTextureGatherOffsetsARB", EOpSparseTextureGatherOffsets);
9829 symbolTable.relateToOperator("sparseImageLoadARB", EOpSparseImageLoad);
9830 symbolTable.relateToOperator("sparseTexelsResidentARB", EOpSparseTexelsResident);
9831
9832 symbolTable.relateToOperator("sparseTextureClampARB", EOpSparseTextureClamp);
9833 symbolTable.relateToOperator("sparseTextureOffsetClampARB", EOpSparseTextureOffsetClamp);
9834 symbolTable.relateToOperator("sparseTextureGradClampARB", EOpSparseTextureGradClamp);
9835 symbolTable.relateToOperator("sparseTextureGradOffsetClampARB", EOpSparseTextureGradOffsetClamp);
9836 symbolTable.relateToOperator("textureClampARB", EOpTextureClamp);
9837 symbolTable.relateToOperator("textureOffsetClampARB", EOpTextureOffsetClamp);
9838 symbolTable.relateToOperator("textureGradClampARB", EOpTextureGradClamp);
9839 symbolTable.relateToOperator("textureGradOffsetClampARB", EOpTextureGradOffsetClamp);
9840
9841 symbolTable.relateToOperator("ballotARB", EOpBallot);
9842 symbolTable.relateToOperator("readInvocationARB", EOpReadInvocation);
9843 symbolTable.relateToOperator("readFirstInvocationARB", EOpReadFirstInvocation);
9844
9845 if (version >= 430) {
9846 symbolTable.relateToOperator("anyInvocationARB", EOpAnyInvocation);
9847 symbolTable.relateToOperator("allInvocationsARB", EOpAllInvocations);
9848 symbolTable.relateToOperator("allInvocationsEqualARB", EOpAllInvocationsEqual);
9849 }
9850 if (version >= 460) {
9851 symbolTable.relateToOperator("anyInvocation", EOpAnyInvocation);
9852 symbolTable.relateToOperator("allInvocations", EOpAllInvocations);
9853 symbolTable.relateToOperator("allInvocationsEqual", EOpAllInvocationsEqual);
9854 }
9855 symbolTable.relateToOperator("minInvocationsAMD", EOpMinInvocations);
9856 symbolTable.relateToOperator("maxInvocationsAMD", EOpMaxInvocations);
9857 symbolTable.relateToOperator("addInvocationsAMD", EOpAddInvocations);
9858 symbolTable.relateToOperator("minInvocationsNonUniformAMD", EOpMinInvocationsNonUniform);
9859 symbolTable.relateToOperator("maxInvocationsNonUniformAMD", EOpMaxInvocationsNonUniform);
9860 symbolTable.relateToOperator("addInvocationsNonUniformAMD", EOpAddInvocationsNonUniform);
9861 symbolTable.relateToOperator("minInvocationsInclusiveScanAMD", EOpMinInvocationsInclusiveScan);
9862 symbolTable.relateToOperator("maxInvocationsInclusiveScanAMD", EOpMaxInvocationsInclusiveScan);
9863 symbolTable.relateToOperator("addInvocationsInclusiveScanAMD", EOpAddInvocationsInclusiveScan);
9864 symbolTable.relateToOperator("minInvocationsInclusiveScanNonUniformAMD", EOpMinInvocationsInclusiveScanNonUniform);
9865 symbolTable.relateToOperator("maxInvocationsInclusiveScanNonUniformAMD", EOpMaxInvocationsInclusiveScanNonUniform);
9866 symbolTable.relateToOperator("addInvocationsInclusiveScanNonUniformAMD", EOpAddInvocationsInclusiveScanNonUniform);
9867 symbolTable.relateToOperator("minInvocationsExclusiveScanAMD", EOpMinInvocationsExclusiveScan);
9868 symbolTable.relateToOperator("maxInvocationsExclusiveScanAMD", EOpMaxInvocationsExclusiveScan);
9869 symbolTable.relateToOperator("addInvocationsExclusiveScanAMD", EOpAddInvocationsExclusiveScan);
9870 symbolTable.relateToOperator("minInvocationsExclusiveScanNonUniformAMD", EOpMinInvocationsExclusiveScanNonUniform);
9871 symbolTable.relateToOperator("maxInvocationsExclusiveScanNonUniformAMD", EOpMaxInvocationsExclusiveScanNonUniform);
9872 symbolTable.relateToOperator("addInvocationsExclusiveScanNonUniformAMD", EOpAddInvocationsExclusiveScanNonUniform);
9873 symbolTable.relateToOperator("swizzleInvocationsAMD", EOpSwizzleInvocations);
9874 symbolTable.relateToOperator("swizzleInvocationsMaskedAMD", EOpSwizzleInvocationsMasked);
9875 symbolTable.relateToOperator("writeInvocationAMD", EOpWriteInvocation);
9876 symbolTable.relateToOperator("mbcntAMD", EOpMbcnt);
9877
9878 symbolTable.relateToOperator("min3", EOpMin3);
9879 symbolTable.relateToOperator("max3", EOpMax3);
9880 symbolTable.relateToOperator("mid3", EOpMid3);
9881
9882 symbolTable.relateToOperator("cubeFaceIndexAMD", EOpCubeFaceIndex);
9883 symbolTable.relateToOperator("cubeFaceCoordAMD", EOpCubeFaceCoord);
9884 symbolTable.relateToOperator("timeAMD", EOpTime);
9885
9886 symbolTable.relateToOperator("textureGatherLodAMD", EOpTextureGatherLod);
9887 symbolTable.relateToOperator("textureGatherLodOffsetAMD", EOpTextureGatherLodOffset);
9888 symbolTable.relateToOperator("textureGatherLodOffsetsAMD", EOpTextureGatherLodOffsets);
9889 symbolTable.relateToOperator("sparseTextureGatherLodAMD", EOpSparseTextureGatherLod);
9890 symbolTable.relateToOperator("sparseTextureGatherLodOffsetAMD", EOpSparseTextureGatherLodOffset);
9891 symbolTable.relateToOperator("sparseTextureGatherLodOffsetsAMD", EOpSparseTextureGatherLodOffsets);
9892
9893 symbolTable.relateToOperator("imageLoadLodAMD", EOpImageLoadLod);
9894 symbolTable.relateToOperator("imageStoreLodAMD", EOpImageStoreLod);
9895 symbolTable.relateToOperator("sparseImageLoadLodAMD", EOpSparseImageLoadLod);
9896
9897 symbolTable.relateToOperator("fragmentMaskFetchAMD", EOpFragmentMaskFetch);
9898 symbolTable.relateToOperator("fragmentFetchAMD", EOpFragmentFetch);
9899 }
9900
9901 // GL_KHR_shader_subgroup
9902 if ((profile == EEsProfile && version >= 310) ||
9903 (profile != EEsProfile && version >= 140)) {
9904 symbolTable.relateToOperator("subgroupBarrier", EOpSubgroupBarrier);
9905 symbolTable.relateToOperator("subgroupMemoryBarrier", EOpSubgroupMemoryBarrier);
9906 symbolTable.relateToOperator("subgroupMemoryBarrierBuffer", EOpSubgroupMemoryBarrierBuffer);
9907 symbolTable.relateToOperator("subgroupMemoryBarrierImage", EOpSubgroupMemoryBarrierImage);
9908 symbolTable.relateToOperator("subgroupElect", EOpSubgroupElect);
9909 symbolTable.relateToOperator("subgroupAll", EOpSubgroupAll);
9910 symbolTable.relateToOperator("subgroupAny", EOpSubgroupAny);
9911 symbolTable.relateToOperator("subgroupAllEqual", EOpSubgroupAllEqual);
9912 symbolTable.relateToOperator("subgroupBroadcast", EOpSubgroupBroadcast);
9913 symbolTable.relateToOperator("subgroupBroadcastFirst", EOpSubgroupBroadcastFirst);
9914 symbolTable.relateToOperator("subgroupBallot", EOpSubgroupBallot);
9915 symbolTable.relateToOperator("subgroupInverseBallot", EOpSubgroupInverseBallot);
9916 symbolTable.relateToOperator("subgroupBallotBitExtract", EOpSubgroupBallotBitExtract);
9917 symbolTable.relateToOperator("subgroupBallotBitCount", EOpSubgroupBallotBitCount);
9918 symbolTable.relateToOperator("subgroupBallotInclusiveBitCount", EOpSubgroupBallotInclusiveBitCount);
9919 symbolTable.relateToOperator("subgroupBallotExclusiveBitCount", EOpSubgroupBallotExclusiveBitCount);
9920 symbolTable.relateToOperator("subgroupBallotFindLSB", EOpSubgroupBallotFindLSB);
9921 symbolTable.relateToOperator("subgroupBallotFindMSB", EOpSubgroupBallotFindMSB);
9922 symbolTable.relateToOperator("subgroupShuffle", EOpSubgroupShuffle);
9923 symbolTable.relateToOperator("subgroupShuffleXor", EOpSubgroupShuffleXor);
9924 symbolTable.relateToOperator("subgroupShuffleUp", EOpSubgroupShuffleUp);
9925 symbolTable.relateToOperator("subgroupShuffleDown", EOpSubgroupShuffleDown);
9926 symbolTable.relateToOperator("subgroupAdd", EOpSubgroupAdd);
9927 symbolTable.relateToOperator("subgroupMul", EOpSubgroupMul);
9928 symbolTable.relateToOperator("subgroupMin", EOpSubgroupMin);
9929 symbolTable.relateToOperator("subgroupMax", EOpSubgroupMax);
9930 symbolTable.relateToOperator("subgroupAnd", EOpSubgroupAnd);
9931 symbolTable.relateToOperator("subgroupOr", EOpSubgroupOr);
9932 symbolTable.relateToOperator("subgroupXor", EOpSubgroupXor);
9933 symbolTable.relateToOperator("subgroupInclusiveAdd", EOpSubgroupInclusiveAdd);
9934 symbolTable.relateToOperator("subgroupInclusiveMul", EOpSubgroupInclusiveMul);
9935 symbolTable.relateToOperator("subgroupInclusiveMin", EOpSubgroupInclusiveMin);
9936 symbolTable.relateToOperator("subgroupInclusiveMax", EOpSubgroupInclusiveMax);
9937 symbolTable.relateToOperator("subgroupInclusiveAnd", EOpSubgroupInclusiveAnd);
9938 symbolTable.relateToOperator("subgroupInclusiveOr", EOpSubgroupInclusiveOr);
9939 symbolTable.relateToOperator("subgroupInclusiveXor", EOpSubgroupInclusiveXor);
9940 symbolTable.relateToOperator("subgroupExclusiveAdd", EOpSubgroupExclusiveAdd);
9941 symbolTable.relateToOperator("subgroupExclusiveMul", EOpSubgroupExclusiveMul);
9942 symbolTable.relateToOperator("subgroupExclusiveMin", EOpSubgroupExclusiveMin);
9943 symbolTable.relateToOperator("subgroupExclusiveMax", EOpSubgroupExclusiveMax);
9944 symbolTable.relateToOperator("subgroupExclusiveAnd", EOpSubgroupExclusiveAnd);
9945 symbolTable.relateToOperator("subgroupExclusiveOr", EOpSubgroupExclusiveOr);
9946 symbolTable.relateToOperator("subgroupExclusiveXor", EOpSubgroupExclusiveXor);
9947 symbolTable.relateToOperator("subgroupClusteredAdd", EOpSubgroupClusteredAdd);
9948 symbolTable.relateToOperator("subgroupClusteredMul", EOpSubgroupClusteredMul);
9949 symbolTable.relateToOperator("subgroupClusteredMin", EOpSubgroupClusteredMin);
9950 symbolTable.relateToOperator("subgroupClusteredMax", EOpSubgroupClusteredMax);
9951 symbolTable.relateToOperator("subgroupClusteredAnd", EOpSubgroupClusteredAnd);
9952 symbolTable.relateToOperator("subgroupClusteredOr", EOpSubgroupClusteredOr);
9953 symbolTable.relateToOperator("subgroupClusteredXor", EOpSubgroupClusteredXor);
9954 symbolTable.relateToOperator("subgroupQuadBroadcast", EOpSubgroupQuadBroadcast);
9955 symbolTable.relateToOperator("subgroupQuadSwapHorizontal", EOpSubgroupQuadSwapHorizontal);
9956 symbolTable.relateToOperator("subgroupQuadSwapVertical", EOpSubgroupQuadSwapVertical);
9957 symbolTable.relateToOperator("subgroupQuadSwapDiagonal", EOpSubgroupQuadSwapDiagonal);
9958
9959 symbolTable.relateToOperator("subgroupPartitionNV", EOpSubgroupPartition);
9960 symbolTable.relateToOperator("subgroupPartitionedAddNV", EOpSubgroupPartitionedAdd);
9961 symbolTable.relateToOperator("subgroupPartitionedMulNV", EOpSubgroupPartitionedMul);
9962 symbolTable.relateToOperator("subgroupPartitionedMinNV", EOpSubgroupPartitionedMin);
9963 symbolTable.relateToOperator("subgroupPartitionedMaxNV", EOpSubgroupPartitionedMax);
9964 symbolTable.relateToOperator("subgroupPartitionedAndNV", EOpSubgroupPartitionedAnd);
9965 symbolTable.relateToOperator("subgroupPartitionedOrNV", EOpSubgroupPartitionedOr);
9966 symbolTable.relateToOperator("subgroupPartitionedXorNV", EOpSubgroupPartitionedXor);
9967 symbolTable.relateToOperator("subgroupPartitionedInclusiveAddNV", EOpSubgroupPartitionedInclusiveAdd);
9968 symbolTable.relateToOperator("subgroupPartitionedInclusiveMulNV", EOpSubgroupPartitionedInclusiveMul);
9969 symbolTable.relateToOperator("subgroupPartitionedInclusiveMinNV", EOpSubgroupPartitionedInclusiveMin);
9970 symbolTable.relateToOperator("subgroupPartitionedInclusiveMaxNV", EOpSubgroupPartitionedInclusiveMax);
9971 symbolTable.relateToOperator("subgroupPartitionedInclusiveAndNV", EOpSubgroupPartitionedInclusiveAnd);
9972 symbolTable.relateToOperator("subgroupPartitionedInclusiveOrNV", EOpSubgroupPartitionedInclusiveOr);
9973 symbolTable.relateToOperator("subgroupPartitionedInclusiveXorNV", EOpSubgroupPartitionedInclusiveXor);
9974 symbolTable.relateToOperator("subgroupPartitionedExclusiveAddNV", EOpSubgroupPartitionedExclusiveAdd);
9975 symbolTable.relateToOperator("subgroupPartitionedExclusiveMulNV", EOpSubgroupPartitionedExclusiveMul);
9976 symbolTable.relateToOperator("subgroupPartitionedExclusiveMinNV", EOpSubgroupPartitionedExclusiveMin);
9977 symbolTable.relateToOperator("subgroupPartitionedExclusiveMaxNV", EOpSubgroupPartitionedExclusiveMax);
9978 symbolTable.relateToOperator("subgroupPartitionedExclusiveAndNV", EOpSubgroupPartitionedExclusiveAnd);
9979 symbolTable.relateToOperator("subgroupPartitionedExclusiveOrNV", EOpSubgroupPartitionedExclusiveOr);
9980 symbolTable.relateToOperator("subgroupPartitionedExclusiveXorNV", EOpSubgroupPartitionedExclusiveXor);
9981 }
9982
9983 if (profile == EEsProfile) {
9984 symbolTable.relateToOperator("shadow2DEXT", EOpTexture);
9985 symbolTable.relateToOperator("shadow2DProjEXT", EOpTextureProj);
9986 }
9987
9988 if ((profile == EEsProfile && version >= 310) ||
9989 (profile != EEsProfile && version >= 140)) {
9990 symbolTable.relateToOperator("textureWeightedQCOM", EOpImageSampleWeightedQCOM);
9991 symbolTable.relateToOperator("textureBoxFilterQCOM", EOpImageBoxFilterQCOM);
9992 symbolTable.relateToOperator("textureBlockMatchSADQCOM", EOpImageBlockMatchSADQCOM);
9993 symbolTable.relateToOperator("textureBlockMatchSSDQCOM", EOpImageBlockMatchSSDQCOM);
9994 }
9995
9996 if (profile != EEsProfile && spvVersion.spv == 0) {
9997 symbolTable.relateToOperator("texture1DArray", EOpTexture);
9998 symbolTable.relateToOperator("texture2DArray", EOpTexture);
9999 symbolTable.relateToOperator("shadow1DArray", EOpTexture);
10000 symbolTable.relateToOperator("shadow2DArray", EOpTexture);
10001
10002 symbolTable.relateToOperator("texture1DArrayLod", EOpTextureLod);
10003 symbolTable.relateToOperator("texture2DArrayLod", EOpTextureLod);
10004 symbolTable.relateToOperator("shadow1DArrayLod", EOpTextureLod);
10005 }
10006 }
10007
10008 switch(language) {
10009 case EShLangVertex:
10010 break;
10011
10012 case EShLangTessControl:
10013 case EShLangTessEvaluation:
10014 break;
10015
10016 case EShLangGeometry:
10017 symbolTable.relateToOperator("EmitStreamVertex", EOpEmitStreamVertex);
10018 symbolTable.relateToOperator("EndStreamPrimitive", EOpEndStreamPrimitive);
10019 symbolTable.relateToOperator("EmitVertex", EOpEmitVertex);
10020 symbolTable.relateToOperator("EndPrimitive", EOpEndPrimitive);
10021 break;
10022
10023 case EShLangFragment:
10024 if (profile != EEsProfile && version >= 400) {
10025 symbolTable.relateToOperator("dFdxFine", EOpDPdxFine);
10026 symbolTable.relateToOperator("dFdyFine", EOpDPdyFine);
10027 symbolTable.relateToOperator("fwidthFine", EOpFwidthFine);
10028 symbolTable.relateToOperator("dFdxCoarse", EOpDPdxCoarse);
10029 symbolTable.relateToOperator("dFdyCoarse", EOpDPdyCoarse);
10030 symbolTable.relateToOperator("fwidthCoarse", EOpFwidthCoarse);
10031 }
10032
10033 if (profile != EEsProfile && version >= 460) {
10034 symbolTable.relateToOperator("rayQueryInitializeEXT", EOpRayQueryInitialize);
10035 symbolTable.relateToOperator("rayQueryTerminateEXT", EOpRayQueryTerminate);
10036 symbolTable.relateToOperator("rayQueryGenerateIntersectionEXT", EOpRayQueryGenerateIntersection);
10037 symbolTable.relateToOperator("rayQueryConfirmIntersectionEXT", EOpRayQueryConfirmIntersection);
10038 symbolTable.relateToOperator("rayQueryProceedEXT", EOpRayQueryProceed);
10039 symbolTable.relateToOperator("rayQueryGetIntersectionTypeEXT", EOpRayQueryGetIntersectionType);
10040 symbolTable.relateToOperator("rayQueryGetRayTMinEXT", EOpRayQueryGetRayTMin);
10041 symbolTable.relateToOperator("rayQueryGetRayFlagsEXT", EOpRayQueryGetRayFlags);
10042 symbolTable.relateToOperator("rayQueryGetIntersectionTEXT", EOpRayQueryGetIntersectionT);
10043 symbolTable.relateToOperator("rayQueryGetIntersectionInstanceCustomIndexEXT", EOpRayQueryGetIntersectionInstanceCustomIndex);
10044 symbolTable.relateToOperator("rayQueryGetIntersectionInstanceIdEXT", EOpRayQueryGetIntersectionInstanceId);
10045 symbolTable.relateToOperator("rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT", EOpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffset);
10046 symbolTable.relateToOperator("rayQueryGetIntersectionGeometryIndexEXT", EOpRayQueryGetIntersectionGeometryIndex);
10047 symbolTable.relateToOperator("rayQueryGetIntersectionPrimitiveIndexEXT", EOpRayQueryGetIntersectionPrimitiveIndex);
10048 symbolTable.relateToOperator("rayQueryGetIntersectionBarycentricsEXT", EOpRayQueryGetIntersectionBarycentrics);
10049 symbolTable.relateToOperator("rayQueryGetIntersectionFrontFaceEXT", EOpRayQueryGetIntersectionFrontFace);
10050 symbolTable.relateToOperator("rayQueryGetIntersectionCandidateAABBOpaqueEXT", EOpRayQueryGetIntersectionCandidateAABBOpaque);
10051 symbolTable.relateToOperator("rayQueryGetIntersectionObjectRayDirectionEXT", EOpRayQueryGetIntersectionObjectRayDirection);
10052 symbolTable.relateToOperator("rayQueryGetIntersectionObjectRayOriginEXT", EOpRayQueryGetIntersectionObjectRayOrigin);
10053 symbolTable.relateToOperator("rayQueryGetWorldRayDirectionEXT", EOpRayQueryGetWorldRayDirection);
10054 symbolTable.relateToOperator("rayQueryGetWorldRayOriginEXT", EOpRayQueryGetWorldRayOrigin);
10055 symbolTable.relateToOperator("rayQueryGetIntersectionObjectToWorldEXT", EOpRayQueryGetIntersectionObjectToWorld);
10056 symbolTable.relateToOperator("rayQueryGetIntersectionWorldToObjectEXT", EOpRayQueryGetIntersectionWorldToObject);
10057 symbolTable.relateToOperator("rayQueryGetIntersectionTriangleVertexPositionsEXT", EOpRayQueryGetIntersectionTriangleVertexPositionsEXT);
10058 }
10059
10060 symbolTable.relateToOperator("interpolateAtCentroid", EOpInterpolateAtCentroid);
10061 symbolTable.relateToOperator("interpolateAtSample", EOpInterpolateAtSample);
10062 symbolTable.relateToOperator("interpolateAtOffset", EOpInterpolateAtOffset);
10063
10064 if (profile != EEsProfile)
10065 symbolTable.relateToOperator("interpolateAtVertexAMD", EOpInterpolateAtVertex);
10066
10067 symbolTable.relateToOperator("beginInvocationInterlockARB", EOpBeginInvocationInterlock);
10068 symbolTable.relateToOperator("endInvocationInterlockARB", EOpEndInvocationInterlock);
10069
10070 symbolTable.relateToOperator("stencilAttachmentReadEXT", EOpStencilAttachmentReadEXT);
10071 symbolTable.relateToOperator("depthAttachmentReadEXT", EOpDepthAttachmentReadEXT);
10072 symbolTable.relateToOperator("colorAttachmentReadEXT", EOpColorAttachmentReadEXT);
10073
10074 break;
10075
10076 case EShLangCompute:
10077 symbolTable.relateToOperator("subgroupMemoryBarrierShared", EOpSubgroupMemoryBarrierShared);
10078 if ((profile != EEsProfile && version >= 450) ||
10079 (profile == EEsProfile && version >= 320)) {
10080 symbolTable.relateToOperator("dFdx", EOpDPdx);
10081 symbolTable.relateToOperator("dFdy", EOpDPdy);
10082 symbolTable.relateToOperator("fwidth", EOpFwidth);
10083 symbolTable.relateToOperator("dFdxFine", EOpDPdxFine);
10084 symbolTable.relateToOperator("dFdyFine", EOpDPdyFine);
10085 symbolTable.relateToOperator("fwidthFine", EOpFwidthFine);
10086 symbolTable.relateToOperator("dFdxCoarse", EOpDPdxCoarse);
10087 symbolTable.relateToOperator("dFdyCoarse", EOpDPdyCoarse);
10088 symbolTable.relateToOperator("fwidthCoarse",EOpFwidthCoarse);
10089 }
10090 symbolTable.relateToOperator("coopMatLoadNV", EOpCooperativeMatrixLoadNV);
10091 symbolTable.relateToOperator("coopMatStoreNV", EOpCooperativeMatrixStoreNV);
10092 symbolTable.relateToOperator("coopMatMulAddNV", EOpCooperativeMatrixMulAddNV);
10093
10094 symbolTable.relateToOperator("coopMatLoad", EOpCooperativeMatrixLoad);
10095 symbolTable.relateToOperator("coopMatStore", EOpCooperativeMatrixStore);
10096 symbolTable.relateToOperator("coopMatMulAdd", EOpCooperativeMatrixMulAdd);
10097
10098 if (profile != EEsProfile && version >= 460) {
10099 symbolTable.relateToOperator("fetchMicroTriangleVertexPositionNV", EOpFetchMicroTriangleVertexPositionNV);
10100 symbolTable.relateToOperator("fetchMicroTriangleVertexBarycentricNV", EOpFetchMicroTriangleVertexBarycentricNV);
10101 }
10102 break;
10103
10104 case EShLangRayGen:
10105 if (profile != EEsProfile && version >= 460) {
10106 symbolTable.relateToOperator("fetchMicroTriangleVertexPositionNV", EOpFetchMicroTriangleVertexPositionNV);
10107 symbolTable.relateToOperator("fetchMicroTriangleVertexBarycentricNV", EOpFetchMicroTriangleVertexBarycentricNV);
10108 } // fallthrough
10109 case EShLangClosestHit:
10110 case EShLangMiss:
10111 if (profile != EEsProfile && version >= 460) {
10112 symbolTable.relateToOperator("traceNV", EOpTraceNV);
10113 symbolTable.relateToOperator("traceRayMotionNV", EOpTraceRayMotionNV);
10114 symbolTable.relateToOperator("traceRayEXT", EOpTraceKHR);
10115 symbolTable.relateToOperator("executeCallableNV", EOpExecuteCallableNV);
10116 symbolTable.relateToOperator("executeCallableEXT", EOpExecuteCallableKHR);
10117
10118 symbolTable.relateToOperator("hitObjectTraceRayNV", EOpHitObjectTraceRayNV);
10119 symbolTable.relateToOperator("hitObjectTraceRayMotionNV", EOpHitObjectTraceRayMotionNV);
10120 symbolTable.relateToOperator("hitObjectRecordHitNV", EOpHitObjectRecordHitNV);
10121 symbolTable.relateToOperator("hitObjectRecordHitMotionNV", EOpHitObjectRecordHitMotionNV);
10122 symbolTable.relateToOperator("hitObjectRecordHitWithIndexNV", EOpHitObjectRecordHitWithIndexNV);
10123 symbolTable.relateToOperator("hitObjectRecordHitWithIndexMotionNV", EOpHitObjectRecordHitWithIndexMotionNV);
10124 symbolTable.relateToOperator("hitObjectRecordMissNV", EOpHitObjectRecordMissNV);
10125 symbolTable.relateToOperator("hitObjectRecordMissMotionNV", EOpHitObjectRecordMissMotionNV);
10126 symbolTable.relateToOperator("hitObjectRecordEmptyNV", EOpHitObjectRecordEmptyNV);
10127 symbolTable.relateToOperator("hitObjectExecuteShaderNV", EOpHitObjectExecuteShaderNV);
10128 symbolTable.relateToOperator("hitObjectIsEmptyNV", EOpHitObjectIsEmptyNV);
10129 symbolTable.relateToOperator("hitObjectIsMissNV", EOpHitObjectIsMissNV);
10130 symbolTable.relateToOperator("hitObjectIsHitNV", EOpHitObjectIsHitNV);
10131 symbolTable.relateToOperator("hitObjectGetRayTMinNV", EOpHitObjectGetRayTMinNV);
10132 symbolTable.relateToOperator("hitObjectGetRayTMaxNV", EOpHitObjectGetRayTMaxNV);
10133 symbolTable.relateToOperator("hitObjectGetObjectRayOriginNV", EOpHitObjectGetObjectRayOriginNV);
10134 symbolTable.relateToOperator("hitObjectGetObjectRayDirectionNV", EOpHitObjectGetObjectRayDirectionNV);
10135 symbolTable.relateToOperator("hitObjectGetWorldRayOriginNV", EOpHitObjectGetWorldRayOriginNV);
10136 symbolTable.relateToOperator("hitObjectGetWorldRayDirectionNV", EOpHitObjectGetWorldRayDirectionNV);
10137 symbolTable.relateToOperator("hitObjectGetWorldToObjectNV", EOpHitObjectGetWorldToObjectNV);
10138 symbolTable.relateToOperator("hitObjectGetObjectToWorldNV", EOpHitObjectGetObjectToWorldNV);
10139 symbolTable.relateToOperator("hitObjectGetInstanceCustomIndexNV", EOpHitObjectGetInstanceCustomIndexNV);
10140 symbolTable.relateToOperator("hitObjectGetInstanceIdNV", EOpHitObjectGetInstanceIdNV);
10141 symbolTable.relateToOperator("hitObjectGetGeometryIndexNV", EOpHitObjectGetGeometryIndexNV);
10142 symbolTable.relateToOperator("hitObjectGetPrimitiveIndexNV", EOpHitObjectGetPrimitiveIndexNV);
10143 symbolTable.relateToOperator("hitObjectGetHitKindNV", EOpHitObjectGetHitKindNV);
10144 symbolTable.relateToOperator("hitObjectGetAttributesNV", EOpHitObjectGetAttributesNV);
10145 symbolTable.relateToOperator("hitObjectGetCurrentTimeNV", EOpHitObjectGetCurrentTimeNV);
10146 symbolTable.relateToOperator("hitObjectGetShaderBindingTableRecordIndexNV", EOpHitObjectGetShaderBindingTableRecordIndexNV);
10147 symbolTable.relateToOperator("hitObjectGetShaderRecordBufferHandleNV", EOpHitObjectGetShaderRecordBufferHandleNV);
10148 symbolTable.relateToOperator("reorderThreadNV", EOpReorderThreadNV);
10149 }
10150 break;
10151 case EShLangIntersect:
10152 if (profile != EEsProfile && version >= 460) {
10153 symbolTable.relateToOperator("reportIntersectionNV", EOpReportIntersection);
10154 symbolTable.relateToOperator("reportIntersectionEXT", EOpReportIntersection);
10155 }
10156 break;
10157 case EShLangAnyHit:
10158 if (profile != EEsProfile && version >= 460) {
10159 symbolTable.relateToOperator("ignoreIntersectionNV", EOpIgnoreIntersectionNV);
10160 symbolTable.relateToOperator("terminateRayNV", EOpTerminateRayNV);
10161 }
10162 break;
10163 case EShLangCallable:
10164 if (profile != EEsProfile && version >= 460) {
10165 symbolTable.relateToOperator("executeCallableNV", EOpExecuteCallableNV);
10166 symbolTable.relateToOperator("executeCallableEXT", EOpExecuteCallableKHR);
10167 }
10168 break;
10169 case EShLangMesh:
10170 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
10171 symbolTable.relateToOperator("writePackedPrimitiveIndices4x8NV", EOpWritePackedPrimitiveIndices4x8NV);
10172 symbolTable.relateToOperator("memoryBarrierShared", EOpMemoryBarrierShared);
10173 symbolTable.relateToOperator("groupMemoryBarrier", EOpGroupMemoryBarrier);
10174 symbolTable.relateToOperator("subgroupMemoryBarrierShared", EOpSubgroupMemoryBarrierShared);
10175 }
10176
10177 if (profile != EEsProfile && version >= 450) {
10178 symbolTable.relateToOperator("SetMeshOutputsEXT", EOpSetMeshOutputsEXT);
10179 }
10180
10181 if (profile != EEsProfile && version >= 460) {
10182 // Builtins for GL_NV_displacement_micromap.
10183 symbolTable.relateToOperator("fetchMicroTriangleVertexPositionNV", EOpFetchMicroTriangleVertexPositionNV);
10184 symbolTable.relateToOperator("fetchMicroTriangleVertexBarycentricNV", EOpFetchMicroTriangleVertexBarycentricNV);
10185 }
10186 break;
10187 case EShLangTask:
10188 if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
10189 symbolTable.relateToOperator("memoryBarrierShared", EOpMemoryBarrierShared);
10190 symbolTable.relateToOperator("groupMemoryBarrier", EOpGroupMemoryBarrier);
10191 symbolTable.relateToOperator("subgroupMemoryBarrierShared", EOpSubgroupMemoryBarrierShared);
10192 }
10193 if (profile != EEsProfile && version >= 450) {
10194 symbolTable.relateToOperator("EmitMeshTasksEXT", EOpEmitMeshTasksEXT);
10195 }
10196 break;
10197
10198 default:
10199 assert(false && "Language not supported");
10200 }
10201 }
10202
10203 //
10204 // Add context-dependent (resource-specific) built-ins not handled by the above. These
10205 // would be ones that need to be programmatically added because they cannot
10206 // be added by simple text strings. For these, also
10207 // 1) Map built-in functions to operators, for those that will turn into an operation node
10208 // instead of remaining a function call.
10209 // 2) Tag extension-related symbols added to their base version with their extensions, so
10210 // that if an early version has the extension turned off, there is an error reported on use.
10211 //
identifyBuiltIns(int version,EProfile profile,const SpvVersion & spvVersion,EShLanguage language,TSymbolTable & symbolTable,const TBuiltInResource & resources)10212 void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources)
10213 {
10214 if (profile != EEsProfile && version >= 430 && version < 440) {
10215 symbolTable.setVariableExtensions("gl_MaxTransformFeedbackBuffers", 1, &E_GL_ARB_enhanced_layouts);
10216 symbolTable.setVariableExtensions("gl_MaxTransformFeedbackInterleavedComponents", 1, &E_GL_ARB_enhanced_layouts);
10217 }
10218 if (profile != EEsProfile && version >= 130 && version < 420) {
10219 symbolTable.setVariableExtensions("gl_MinProgramTexelOffset", 1, &E_GL_ARB_shading_language_420pack);
10220 symbolTable.setVariableExtensions("gl_MaxProgramTexelOffset", 1, &E_GL_ARB_shading_language_420pack);
10221 }
10222 if (profile != EEsProfile && version >= 150 && version < 410)
10223 symbolTable.setVariableExtensions("gl_MaxViewports", 1, &E_GL_ARB_viewport_array);
10224
10225 switch(language) {
10226 case EShLangFragment:
10227 // Set up gl_FragData based on current array size.
10228 if (version == 100 || IncludeLegacy(version, profile, spvVersion) || (! ForwardCompatibility && profile != EEsProfile && version < 420)) {
10229 TPrecisionQualifier pq = profile == EEsProfile ? EpqMedium : EpqNone;
10230 TType fragData(EbtFloat, EvqFragColor, pq, 4);
10231 TArraySizes* arraySizes = new TArraySizes;
10232 arraySizes->addInnerSize(resources.maxDrawBuffers);
10233 fragData.transferArraySizes(arraySizes);
10234 symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));
10235 SpecialQualifier("gl_FragData", EvqFragColor, EbvFragData, symbolTable);
10236 }
10237
10238 // GL_EXT_blend_func_extended
10239 if (profile == EEsProfile && version >= 100) {
10240 symbolTable.setVariableExtensions("gl_MaxDualSourceDrawBuffersEXT", 1, &E_GL_EXT_blend_func_extended);
10241 symbolTable.setVariableExtensions("gl_SecondaryFragColorEXT", 1, &E_GL_EXT_blend_func_extended);
10242 symbolTable.setVariableExtensions("gl_SecondaryFragDataEXT", 1, &E_GL_EXT_blend_func_extended);
10243 SpecialQualifier("gl_SecondaryFragColorEXT", EvqVaryingOut, EbvSecondaryFragColorEXT, symbolTable);
10244 SpecialQualifier("gl_SecondaryFragDataEXT", EvqVaryingOut, EbvSecondaryFragDataEXT, symbolTable);
10245 }
10246
10247 break;
10248
10249 case EShLangTessControl:
10250 case EShLangTessEvaluation:
10251 // Because of the context-dependent array size (gl_MaxPatchVertices),
10252 // these variables were added later than the others and need to be mapped now.
10253
10254 // standard members
10255 BuiltInVariable("gl_in", "gl_Position", EbvPosition, symbolTable);
10256 BuiltInVariable("gl_in", "gl_PointSize", EbvPointSize, symbolTable);
10257 BuiltInVariable("gl_in", "gl_ClipDistance", EbvClipDistance, symbolTable);
10258 BuiltInVariable("gl_in", "gl_CullDistance", EbvCullDistance, symbolTable);
10259
10260 // compatibility members
10261 BuiltInVariable("gl_in", "gl_ClipVertex", EbvClipVertex, symbolTable);
10262 BuiltInVariable("gl_in", "gl_FrontColor", EbvFrontColor, symbolTable);
10263 BuiltInVariable("gl_in", "gl_BackColor", EbvBackColor, symbolTable);
10264 BuiltInVariable("gl_in", "gl_FrontSecondaryColor", EbvFrontSecondaryColor, symbolTable);
10265 BuiltInVariable("gl_in", "gl_BackSecondaryColor", EbvBackSecondaryColor, symbolTable);
10266 BuiltInVariable("gl_in", "gl_TexCoord", EbvTexCoord, symbolTable);
10267 BuiltInVariable("gl_in", "gl_FogFragCoord", EbvFogFragCoord, symbolTable);
10268
10269 symbolTable.setVariableExtensions("gl_in", "gl_SecondaryPositionNV", 1, &E_GL_NV_stereo_view_rendering);
10270 symbolTable.setVariableExtensions("gl_in", "gl_PositionPerViewNV", 1, &E_GL_NVX_multiview_per_view_attributes);
10271
10272 BuiltInVariable("gl_in", "gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable);
10273 BuiltInVariable("gl_in", "gl_PositionPerViewNV", EbvPositionPerViewNV, symbolTable);
10274
10275 // extension requirements
10276 if (profile == EEsProfile) {
10277 symbolTable.setVariableExtensions("gl_in", "gl_PointSize", Num_AEP_tessellation_point_size, AEP_tessellation_point_size);
10278 }
10279
10280 break;
10281
10282 default:
10283 break;
10284 }
10285 }
10286
10287 } // end namespace glslang
10288