1 // 2 // Copyright (C) 2002-2005 3Dlabs Inc. Ltd. 3 // Copyright (C) 2012-2016 LunarG, Inc. 4 // Copyright (C) 2015-2016 Google, Inc. 5 // 6 // All rights reserved. 7 // 8 // Redistribution and use in source and binary forms, with or without 9 // modification, are permitted provided that the following conditions 10 // are met: 11 // 12 // Redistributions of source code must retain the above copyright 13 // notice, this list of conditions and the following disclaimer. 14 // 15 // Redistributions in binary form must reproduce the above 16 // copyright notice, this list of conditions and the following 17 // disclaimer in the documentation and/or other materials provided 18 // with the distribution. 19 // 20 // Neither the name of 3Dlabs Inc. Ltd. nor the names of its 21 // contributors may be used to endorse or promote products derived 22 // from this software without specific prior written permission. 23 // 24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 28 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 29 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 30 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 32 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 34 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 // POSSIBILITY OF SUCH DAMAGE. 36 // 37 38 // 39 // Create strings that declare built-in definitions, add built-ins programmatically 40 // that cannot be expressed in the strings, and establish mappings between 41 // built-in functions and operators. 42 // 43 // Where to put a built-in: 44 // TBuiltIns::initialize(version,profile) context-independent textual built-ins; add them to the right string 45 // TBuiltIns::initialize(resources,...) context-dependent textual built-ins; add them to the right string 46 // TBuiltIns::identifyBuiltIns(...,symbolTable) context-independent programmatic additions/mappings to the symbol table, 47 // including identifying what extensions are needed if a version does not allow a symbol 48 // TBuiltIns::identifyBuiltIns(...,symbolTable, resources) context-dependent programmatic additions/mappings to the symbol table, 49 // including identifying what extensions are needed if a version does not allow a symbol 50 // 51 52 #include "../Include/intermediate.h" 53 #include "Initialize.h" 54 55 namespace glslang { 56 57 // TODO: ARB_Compatability: do full extension support 58 const bool ARBCompatibility = true; 59 60 const bool ForwardCompatibility = false; 61 62 // change this back to false if depending on textual spellings of texturing calls when consuming the AST 63 // Using PureOperatorBuiltins=false is deprecated. 64 bool PureOperatorBuiltins = true; 65 66 inline bool IncludeLegacy(int version, EProfile profile, const SpvVersion& spvVersion) 67 { 68 return profile != EEsProfile && (version <= 130 || (spvVersion.spv == 0 && ARBCompatibility) || profile == ECompatibilityProfile); 69 } 70 71 // Construct TBuiltInParseables base class. This can be used for language-common constructs. 72 TBuiltInParseables::TBuiltInParseables() 73 { 74 } 75 76 // Destroy TBuiltInParseables. 77 TBuiltInParseables::~TBuiltInParseables() 78 { 79 } 80 81 TBuiltIns::TBuiltIns() 82 { 83 // Set up textual representations for making all the permutations 84 // of texturing/imaging functions. 85 prefixes[EbtFloat] = ""; 86 prefixes[EbtInt] = "i"; 87 prefixes[EbtUint] = "u"; 88 postfixes[2] = "2"; 89 postfixes[3] = "3"; 90 postfixes[4] = "4"; 91 92 // Map from symbolic class of texturing dimension to numeric dimensions. 93 dimMap[Esd1D] = 1; 94 dimMap[Esd2D] = 2; 95 dimMap[EsdRect] = 2; 96 dimMap[Esd3D] = 3; 97 dimMap[EsdCube] = 3; 98 dimMap[EsdBuffer] = 1; 99 dimMap[EsdSubpass] = 2; // potientially unused for now 100 } 101 102 TBuiltIns::~TBuiltIns() 103 { 104 } 105 106 107 // 108 // Add all context-independent built-in functions and variables that are present 109 // for the given version and profile. Share common ones across stages, otherwise 110 // make stage-specific entries. 111 // 112 // Most built-ins variables can be added as simple text strings. Some need to 113 // be added programmatically, which is done later in IdentifyBuiltIns() below. 114 // 115 void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvVersion) 116 { 117 //============================================================================ 118 // 119 // Prototypes for built-in functions seen by both vertex and fragment shaders. 120 // 121 //============================================================================ 122 123 // 124 // Angle and Trigonometric Functions. 125 // 126 commonBuiltins.append( 127 "float radians(float degrees);" 128 "vec2 radians(vec2 degrees);" 129 "vec3 radians(vec3 degrees);" 130 "vec4 radians(vec4 degrees);" 131 132 "float degrees(float radians);" 133 "vec2 degrees(vec2 radians);" 134 "vec3 degrees(vec3 radians);" 135 "vec4 degrees(vec4 radians);" 136 137 "float sin(float angle);" 138 "vec2 sin(vec2 angle);" 139 "vec3 sin(vec3 angle);" 140 "vec4 sin(vec4 angle);" 141 142 "float cos(float angle);" 143 "vec2 cos(vec2 angle);" 144 "vec3 cos(vec3 angle);" 145 "vec4 cos(vec4 angle);" 146 147 "float tan(float angle);" 148 "vec2 tan(vec2 angle);" 149 "vec3 tan(vec3 angle);" 150 "vec4 tan(vec4 angle);" 151 152 "float asin(float x);" 153 "vec2 asin(vec2 x);" 154 "vec3 asin(vec3 x);" 155 "vec4 asin(vec4 x);" 156 157 "float acos(float x);" 158 "vec2 acos(vec2 x);" 159 "vec3 acos(vec3 x);" 160 "vec4 acos(vec4 x);" 161 162 "float atan(float y, float x);" 163 "vec2 atan(vec2 y, vec2 x);" 164 "vec3 atan(vec3 y, vec3 x);" 165 "vec4 atan(vec4 y, vec4 x);" 166 167 "float atan(float y_over_x);" 168 "vec2 atan(vec2 y_over_x);" 169 "vec3 atan(vec3 y_over_x);" 170 "vec4 atan(vec4 y_over_x);" 171 172 "\n"); 173 174 if (version >= 130) { 175 commonBuiltins.append( 176 "float sinh(float angle);" 177 "vec2 sinh(vec2 angle);" 178 "vec3 sinh(vec3 angle);" 179 "vec4 sinh(vec4 angle);" 180 181 "float cosh(float angle);" 182 "vec2 cosh(vec2 angle);" 183 "vec3 cosh(vec3 angle);" 184 "vec4 cosh(vec4 angle);" 185 186 "float tanh(float angle);" 187 "vec2 tanh(vec2 angle);" 188 "vec3 tanh(vec3 angle);" 189 "vec4 tanh(vec4 angle);" 190 191 "float asinh(float x);" 192 "vec2 asinh(vec2 x);" 193 "vec3 asinh(vec3 x);" 194 "vec4 asinh(vec4 x);" 195 196 "float acosh(float x);" 197 "vec2 acosh(vec2 x);" 198 "vec3 acosh(vec3 x);" 199 "vec4 acosh(vec4 x);" 200 201 "float atanh(float y_over_x);" 202 "vec2 atanh(vec2 y_over_x);" 203 "vec3 atanh(vec3 y_over_x);" 204 "vec4 atanh(vec4 y_over_x);" 205 206 "\n"); 207 } 208 209 // 210 // Exponential Functions. 211 // 212 commonBuiltins.append( 213 "float pow(float x, float y);" 214 "vec2 pow(vec2 x, vec2 y);" 215 "vec3 pow(vec3 x, vec3 y);" 216 "vec4 pow(vec4 x, vec4 y);" 217 218 "float exp(float x);" 219 "vec2 exp(vec2 x);" 220 "vec3 exp(vec3 x);" 221 "vec4 exp(vec4 x);" 222 223 "float log(float x);" 224 "vec2 log(vec2 x);" 225 "vec3 log(vec3 x);" 226 "vec4 log(vec4 x);" 227 228 "float exp2(float x);" 229 "vec2 exp2(vec2 x);" 230 "vec3 exp2(vec3 x);" 231 "vec4 exp2(vec4 x);" 232 233 "float log2(float x);" 234 "vec2 log2(vec2 x);" 235 "vec3 log2(vec3 x);" 236 "vec4 log2(vec4 x);" 237 238 "float sqrt(float x);" 239 "vec2 sqrt(vec2 x);" 240 "vec3 sqrt(vec3 x);" 241 "vec4 sqrt(vec4 x);" 242 243 "float inversesqrt(float x);" 244 "vec2 inversesqrt(vec2 x);" 245 "vec3 inversesqrt(vec3 x);" 246 "vec4 inversesqrt(vec4 x);" 247 248 "\n"); 249 250 // 251 // Common Functions. 252 // 253 commonBuiltins.append( 254 "float abs(float x);" 255 "vec2 abs(vec2 x);" 256 "vec3 abs(vec3 x);" 257 "vec4 abs(vec4 x);" 258 259 "float sign(float x);" 260 "vec2 sign(vec2 x);" 261 "vec3 sign(vec3 x);" 262 "vec4 sign(vec4 x);" 263 264 "float floor(float x);" 265 "vec2 floor(vec2 x);" 266 "vec3 floor(vec3 x);" 267 "vec4 floor(vec4 x);" 268 269 "float ceil(float x);" 270 "vec2 ceil(vec2 x);" 271 "vec3 ceil(vec3 x);" 272 "vec4 ceil(vec4 x);" 273 274 "float fract(float x);" 275 "vec2 fract(vec2 x);" 276 "vec3 fract(vec3 x);" 277 "vec4 fract(vec4 x);" 278 279 "float mod(float x, float y);" 280 "vec2 mod(vec2 x, float y);" 281 "vec3 mod(vec3 x, float y);" 282 "vec4 mod(vec4 x, float y);" 283 "vec2 mod(vec2 x, vec2 y);" 284 "vec3 mod(vec3 x, vec3 y);" 285 "vec4 mod(vec4 x, vec4 y);" 286 287 "float min(float x, float y);" 288 "vec2 min(vec2 x, float y);" 289 "vec3 min(vec3 x, float y);" 290 "vec4 min(vec4 x, float y);" 291 "vec2 min(vec2 x, vec2 y);" 292 "vec3 min(vec3 x, vec3 y);" 293 "vec4 min(vec4 x, vec4 y);" 294 295 "float max(float x, float y);" 296 "vec2 max(vec2 x, float y);" 297 "vec3 max(vec3 x, float y);" 298 "vec4 max(vec4 x, float y);" 299 "vec2 max(vec2 x, vec2 y);" 300 "vec3 max(vec3 x, vec3 y);" 301 "vec4 max(vec4 x, vec4 y);" 302 303 "float clamp(float x, float minVal, float maxVal);" 304 "vec2 clamp(vec2 x, float minVal, float maxVal);" 305 "vec3 clamp(vec3 x, float minVal, float maxVal);" 306 "vec4 clamp(vec4 x, float minVal, float maxVal);" 307 "vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal);" 308 "vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal);" 309 "vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal);" 310 311 "float mix(float x, float y, float a);" 312 "vec2 mix(vec2 x, vec2 y, float a);" 313 "vec3 mix(vec3 x, vec3 y, float a);" 314 "vec4 mix(vec4 x, vec4 y, float a);" 315 "vec2 mix(vec2 x, vec2 y, vec2 a);" 316 "vec3 mix(vec3 x, vec3 y, vec3 a);" 317 "vec4 mix(vec4 x, vec4 y, vec4 a);" 318 319 "float step(float edge, float x);" 320 "vec2 step(vec2 edge, vec2 x);" 321 "vec3 step(vec3 edge, vec3 x);" 322 "vec4 step(vec4 edge, vec4 x);" 323 "vec2 step(float edge, vec2 x);" 324 "vec3 step(float edge, vec3 x);" 325 "vec4 step(float edge, vec4 x);" 326 327 "float smoothstep(float edge0, float edge1, float x);" 328 "vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x);" 329 "vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x);" 330 "vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x);" 331 "vec2 smoothstep(float edge0, float edge1, vec2 x);" 332 "vec3 smoothstep(float edge0, float edge1, vec3 x);" 333 "vec4 smoothstep(float edge0, float edge1, vec4 x);" 334 335 "\n"); 336 337 if (version >= 130) { 338 commonBuiltins.append( 339 " int abs( int x);" 340 "ivec2 abs(ivec2 x);" 341 "ivec3 abs(ivec3 x);" 342 "ivec4 abs(ivec4 x);" 343 344 " int sign( int x);" 345 "ivec2 sign(ivec2 x);" 346 "ivec3 sign(ivec3 x);" 347 "ivec4 sign(ivec4 x);" 348 349 "float trunc(float x);" 350 "vec2 trunc(vec2 x);" 351 "vec3 trunc(vec3 x);" 352 "vec4 trunc(vec4 x);" 353 354 "float round(float x);" 355 "vec2 round(vec2 x);" 356 "vec3 round(vec3 x);" 357 "vec4 round(vec4 x);" 358 359 "float roundEven(float x);" 360 "vec2 roundEven(vec2 x);" 361 "vec3 roundEven(vec3 x);" 362 "vec4 roundEven(vec4 x);" 363 364 "float modf(float, out float);" 365 "vec2 modf(vec2, out vec2 );" 366 "vec3 modf(vec3, out vec3 );" 367 "vec4 modf(vec4, out vec4 );" 368 369 " int min(int x, int y);" 370 "ivec2 min(ivec2 x, int y);" 371 "ivec3 min(ivec3 x, int y);" 372 "ivec4 min(ivec4 x, int y);" 373 "ivec2 min(ivec2 x, ivec2 y);" 374 "ivec3 min(ivec3 x, ivec3 y);" 375 "ivec4 min(ivec4 x, ivec4 y);" 376 377 " uint min(uint x, uint y);" 378 "uvec2 min(uvec2 x, uint y);" 379 "uvec3 min(uvec3 x, uint y);" 380 "uvec4 min(uvec4 x, uint y);" 381 "uvec2 min(uvec2 x, uvec2 y);" 382 "uvec3 min(uvec3 x, uvec3 y);" 383 "uvec4 min(uvec4 x, uvec4 y);" 384 385 " int max(int x, int y);" 386 "ivec2 max(ivec2 x, int y);" 387 "ivec3 max(ivec3 x, int y);" 388 "ivec4 max(ivec4 x, int y);" 389 "ivec2 max(ivec2 x, ivec2 y);" 390 "ivec3 max(ivec3 x, ivec3 y);" 391 "ivec4 max(ivec4 x, ivec4 y);" 392 393 " uint max(uint x, uint y);" 394 "uvec2 max(uvec2 x, uint y);" 395 "uvec3 max(uvec3 x, uint y);" 396 "uvec4 max(uvec4 x, uint y);" 397 "uvec2 max(uvec2 x, uvec2 y);" 398 "uvec3 max(uvec3 x, uvec3 y);" 399 "uvec4 max(uvec4 x, uvec4 y);" 400 401 "int clamp(int x, int minVal, int maxVal);" 402 "ivec2 clamp(ivec2 x, int minVal, int maxVal);" 403 "ivec3 clamp(ivec3 x, int minVal, int maxVal);" 404 "ivec4 clamp(ivec4 x, int minVal, int maxVal);" 405 "ivec2 clamp(ivec2 x, ivec2 minVal, ivec2 maxVal);" 406 "ivec3 clamp(ivec3 x, ivec3 minVal, ivec3 maxVal);" 407 "ivec4 clamp(ivec4 x, ivec4 minVal, ivec4 maxVal);" 408 409 "uint clamp(uint x, uint minVal, uint maxVal);" 410 "uvec2 clamp(uvec2 x, uint minVal, uint maxVal);" 411 "uvec3 clamp(uvec3 x, uint minVal, uint maxVal);" 412 "uvec4 clamp(uvec4 x, uint minVal, uint maxVal);" 413 "uvec2 clamp(uvec2 x, uvec2 minVal, uvec2 maxVal);" 414 "uvec3 clamp(uvec3 x, uvec3 minVal, uvec3 maxVal);" 415 "uvec4 clamp(uvec4 x, uvec4 minVal, uvec4 maxVal);" 416 417 "float mix(float x, float y, bool a);" 418 "vec2 mix(vec2 x, vec2 y, bvec2 a);" 419 "vec3 mix(vec3 x, vec3 y, bvec3 a);" 420 "vec4 mix(vec4 x, vec4 y, bvec4 a);" 421 422 "bool isnan(float x);" 423 "bvec2 isnan(vec2 x);" 424 "bvec3 isnan(vec3 x);" 425 "bvec4 isnan(vec4 x);" 426 427 "bool isinf(float x);" 428 "bvec2 isinf(vec2 x);" 429 "bvec3 isinf(vec3 x);" 430 "bvec4 isinf(vec4 x);" 431 432 "\n"); 433 } 434 435 // 436 // double functions added to desktop 4.00, but not fma, frexp, ldexp, or pack/unpack 437 // 438 if (profile != EEsProfile && version >= 400) { 439 commonBuiltins.append( 440 441 "double sqrt(double);" 442 "dvec2 sqrt(dvec2);" 443 "dvec3 sqrt(dvec3);" 444 "dvec4 sqrt(dvec4);" 445 446 "double inversesqrt(double);" 447 "dvec2 inversesqrt(dvec2);" 448 "dvec3 inversesqrt(dvec3);" 449 "dvec4 inversesqrt(dvec4);" 450 451 "double abs(double);" 452 "dvec2 abs(dvec2);" 453 "dvec3 abs(dvec3);" 454 "dvec4 abs(dvec4);" 455 456 "double sign(double);" 457 "dvec2 sign(dvec2);" 458 "dvec3 sign(dvec3);" 459 "dvec4 sign(dvec4);" 460 461 "double floor(double);" 462 "dvec2 floor(dvec2);" 463 "dvec3 floor(dvec3);" 464 "dvec4 floor(dvec4);" 465 466 "double trunc(double);" 467 "dvec2 trunc(dvec2);" 468 "dvec3 trunc(dvec3);" 469 "dvec4 trunc(dvec4);" 470 471 "double round(double);" 472 "dvec2 round(dvec2);" 473 "dvec3 round(dvec3);" 474 "dvec4 round(dvec4);" 475 476 "double roundEven(double);" 477 "dvec2 roundEven(dvec2);" 478 "dvec3 roundEven(dvec3);" 479 "dvec4 roundEven(dvec4);" 480 481 "double ceil(double);" 482 "dvec2 ceil(dvec2);" 483 "dvec3 ceil(dvec3);" 484 "dvec4 ceil(dvec4);" 485 486 "double fract(double);" 487 "dvec2 fract(dvec2);" 488 "dvec3 fract(dvec3);" 489 "dvec4 fract(dvec4);" 490 491 "double mod(double, double);" 492 "dvec2 mod(dvec2 , double);" 493 "dvec3 mod(dvec3 , double);" 494 "dvec4 mod(dvec4 , double);" 495 "dvec2 mod(dvec2 , dvec2);" 496 "dvec3 mod(dvec3 , dvec3);" 497 "dvec4 mod(dvec4 , dvec4);" 498 499 "double modf(double, out double);" 500 "dvec2 modf(dvec2, out dvec2);" 501 "dvec3 modf(dvec3, out dvec3);" 502 "dvec4 modf(dvec4, out dvec4);" 503 504 "double min(double, double);" 505 "dvec2 min(dvec2, double);" 506 "dvec3 min(dvec3, double);" 507 "dvec4 min(dvec4, double);" 508 "dvec2 min(dvec2, dvec2);" 509 "dvec3 min(dvec3, dvec3);" 510 "dvec4 min(dvec4, dvec4);" 511 512 "double max(double, double);" 513 "dvec2 max(dvec2 , double);" 514 "dvec3 max(dvec3 , double);" 515 "dvec4 max(dvec4 , double);" 516 "dvec2 max(dvec2 , dvec2);" 517 "dvec3 max(dvec3 , dvec3);" 518 "dvec4 max(dvec4 , dvec4);" 519 520 "double clamp(double, double, double);" 521 "dvec2 clamp(dvec2 , double, double);" 522 "dvec3 clamp(dvec3 , double, double);" 523 "dvec4 clamp(dvec4 , double, double);" 524 "dvec2 clamp(dvec2 , dvec2 , dvec2);" 525 "dvec3 clamp(dvec3 , dvec3 , dvec3);" 526 "dvec4 clamp(dvec4 , dvec4 , dvec4);" 527 528 "double mix(double, double, double);" 529 "dvec2 mix(dvec2, dvec2, double);" 530 "dvec3 mix(dvec3, dvec3, double);" 531 "dvec4 mix(dvec4, dvec4, double);" 532 "dvec2 mix(dvec2, dvec2, dvec2);" 533 "dvec3 mix(dvec3, dvec3, dvec3);" 534 "dvec4 mix(dvec4, dvec4, dvec4);" 535 "double mix(double, double, bool);" 536 "dvec2 mix(dvec2, dvec2, bvec2);" 537 "dvec3 mix(dvec3, dvec3, bvec3);" 538 "dvec4 mix(dvec4, dvec4, bvec4);" 539 540 "double step(double, double);" 541 "dvec2 step(dvec2 , dvec2);" 542 "dvec3 step(dvec3 , dvec3);" 543 "dvec4 step(dvec4 , dvec4);" 544 "dvec2 step(double, dvec2);" 545 "dvec3 step(double, dvec3);" 546 "dvec4 step(double, dvec4);" 547 548 "double smoothstep(double, double, double);" 549 "dvec2 smoothstep(dvec2 , dvec2 , dvec2);" 550 "dvec3 smoothstep(dvec3 , dvec3 , dvec3);" 551 "dvec4 smoothstep(dvec4 , dvec4 , dvec4);" 552 "dvec2 smoothstep(double, double, dvec2);" 553 "dvec3 smoothstep(double, double, dvec3);" 554 "dvec4 smoothstep(double, double, dvec4);" 555 556 "bool isnan(double);" 557 "bvec2 isnan(dvec2);" 558 "bvec3 isnan(dvec3);" 559 "bvec4 isnan(dvec4);" 560 561 "bool isinf(double);" 562 "bvec2 isinf(dvec2);" 563 "bvec3 isinf(dvec3);" 564 "bvec4 isinf(dvec4);" 565 566 "double length(double);" 567 "double length(dvec2);" 568 "double length(dvec3);" 569 "double length(dvec4);" 570 571 "double distance(double, double);" 572 "double distance(dvec2 , dvec2);" 573 "double distance(dvec3 , dvec3);" 574 "double distance(dvec4 , dvec4);" 575 576 "double dot(double, double);" 577 "double dot(dvec2 , dvec2);" 578 "double dot(dvec3 , dvec3);" 579 "double dot(dvec4 , dvec4);" 580 581 "dvec3 cross(dvec3, dvec3);" 582 583 "double normalize(double);" 584 "dvec2 normalize(dvec2);" 585 "dvec3 normalize(dvec3);" 586 "dvec4 normalize(dvec4);" 587 588 "double faceforward(double, double, double);" 589 "dvec2 faceforward(dvec2, dvec2, dvec2);" 590 "dvec3 faceforward(dvec3, dvec3, dvec3);" 591 "dvec4 faceforward(dvec4, dvec4, dvec4);" 592 593 "double reflect(double, double);" 594 "dvec2 reflect(dvec2 , dvec2 );" 595 "dvec3 reflect(dvec3 , dvec3 );" 596 "dvec4 reflect(dvec4 , dvec4 );" 597 598 "double refract(double, double, double);" 599 "dvec2 refract(dvec2 , dvec2 , double);" 600 "dvec3 refract(dvec3 , dvec3 , double);" 601 "dvec4 refract(dvec4 , dvec4 , double);" 602 603 "dmat2 matrixCompMult(dmat2, dmat2);" 604 "dmat3 matrixCompMult(dmat3, dmat3);" 605 "dmat4 matrixCompMult(dmat4, dmat4);" 606 "dmat2x3 matrixCompMult(dmat2x3, dmat2x3);" 607 "dmat2x4 matrixCompMult(dmat2x4, dmat2x4);" 608 "dmat3x2 matrixCompMult(dmat3x2, dmat3x2);" 609 "dmat3x4 matrixCompMult(dmat3x4, dmat3x4);" 610 "dmat4x2 matrixCompMult(dmat4x2, dmat4x2);" 611 "dmat4x3 matrixCompMult(dmat4x3, dmat4x3);" 612 613 "dmat2 outerProduct(dvec2, dvec2);" 614 "dmat3 outerProduct(dvec3, dvec3);" 615 "dmat4 outerProduct(dvec4, dvec4);" 616 "dmat2x3 outerProduct(dvec3, dvec2);" 617 "dmat3x2 outerProduct(dvec2, dvec3);" 618 "dmat2x4 outerProduct(dvec4, dvec2);" 619 "dmat4x2 outerProduct(dvec2, dvec4);" 620 "dmat3x4 outerProduct(dvec4, dvec3);" 621 "dmat4x3 outerProduct(dvec3, dvec4);" 622 623 "dmat2 transpose(dmat2);" 624 "dmat3 transpose(dmat3);" 625 "dmat4 transpose(dmat4);" 626 "dmat2x3 transpose(dmat3x2);" 627 "dmat3x2 transpose(dmat2x3);" 628 "dmat2x4 transpose(dmat4x2);" 629 "dmat4x2 transpose(dmat2x4);" 630 "dmat3x4 transpose(dmat4x3);" 631 "dmat4x3 transpose(dmat3x4);" 632 633 "double determinant(dmat2);" 634 "double determinant(dmat3);" 635 "double determinant(dmat4);" 636 637 "dmat2 inverse(dmat2);" 638 "dmat3 inverse(dmat3);" 639 "dmat4 inverse(dmat4);" 640 641 "bvec2 lessThan(dvec2, dvec2);" 642 "bvec3 lessThan(dvec3, dvec3);" 643 "bvec4 lessThan(dvec4, dvec4);" 644 645 "bvec2 lessThanEqual(dvec2, dvec2);" 646 "bvec3 lessThanEqual(dvec3, dvec3);" 647 "bvec4 lessThanEqual(dvec4, dvec4);" 648 649 "bvec2 greaterThan(dvec2, dvec2);" 650 "bvec3 greaterThan(dvec3, dvec3);" 651 "bvec4 greaterThan(dvec4, dvec4);" 652 653 "bvec2 greaterThanEqual(dvec2, dvec2);" 654 "bvec3 greaterThanEqual(dvec3, dvec3);" 655 "bvec4 greaterThanEqual(dvec4, dvec4);" 656 657 "bvec2 equal(dvec2, dvec2);" 658 "bvec3 equal(dvec3, dvec3);" 659 "bvec4 equal(dvec4, dvec4);" 660 661 "bvec2 notEqual(dvec2, dvec2);" 662 "bvec3 notEqual(dvec3, dvec3);" 663 "bvec4 notEqual(dvec4, dvec4);" 664 665 "\n"); 666 } 667 668 if (profile != EEsProfile && version >= 450) { 669 commonBuiltins.append( 670 671 "int64_t abs(int64_t);" 672 "i64vec2 abs(i64vec2);" 673 "i64vec3 abs(i64vec3);" 674 "i64vec4 abs(i64vec4);" 675 676 "int64_t sign(int64_t);" 677 "i64vec2 sign(i64vec2);" 678 "i64vec3 sign(i64vec3);" 679 "i64vec4 sign(i64vec4);" 680 681 "int64_t min(int64_t, int64_t);" 682 "i64vec2 min(i64vec2, int64_t);" 683 "i64vec3 min(i64vec3, int64_t);" 684 "i64vec4 min(i64vec4, int64_t);" 685 "i64vec2 min(i64vec2, i64vec2);" 686 "i64vec3 min(i64vec3, i64vec3);" 687 "i64vec4 min(i64vec4, i64vec4);" 688 "uint64_t min(uint64_t, uint64_t);" 689 "u64vec2 min(u64vec2, uint64_t);" 690 "u64vec3 min(u64vec3, uint64_t);" 691 "u64vec4 min(u64vec4, uint64_t);" 692 "u64vec2 min(u64vec2, u64vec2);" 693 "u64vec3 min(u64vec3, u64vec3);" 694 "u64vec4 min(u64vec4, u64vec4);" 695 696 "int64_t max(int64_t, int64_t);" 697 "i64vec2 max(i64vec2, int64_t);" 698 "i64vec3 max(i64vec3, int64_t);" 699 "i64vec4 max(i64vec4, int64_t);" 700 "i64vec2 max(i64vec2, i64vec2);" 701 "i64vec3 max(i64vec3, i64vec3);" 702 "i64vec4 max(i64vec4, i64vec4);" 703 "uint64_t max(uint64_t, uint64_t);" 704 "u64vec2 max(u64vec2, uint64_t);" 705 "u64vec3 max(u64vec3, uint64_t);" 706 "u64vec4 max(u64vec4, uint64_t);" 707 "u64vec2 max(u64vec2, u64vec2);" 708 "u64vec3 max(u64vec3, u64vec3);" 709 "u64vec4 max(u64vec4, u64vec4);" 710 711 "int64_t clamp(int64_t, int64_t, int64_t);" 712 "i64vec2 clamp(i64vec2, int64_t, int64_t);" 713 "i64vec3 clamp(i64vec3, int64_t, int64_t);" 714 "i64vec4 clamp(i64vec4, int64_t, int64_t);" 715 "i64vec2 clamp(i64vec2, i64vec2, i64vec2);" 716 "i64vec3 clamp(i64vec3, i64vec3, i64vec3);" 717 "i64vec4 clamp(i64vec4, i64vec4, i64vec4);" 718 "uint64_t clamp(uint64_t, uint64_t, uint64_t);" 719 "u64vec2 clamp(u64vec2, uint64_t, uint64_t);" 720 "u64vec3 clamp(u64vec3, uint64_t, uint64_t);" 721 "u64vec4 clamp(u64vec4, uint64_t, uint64_t);" 722 "u64vec2 clamp(u64vec2, u64vec2, u64vec2);" 723 "u64vec3 clamp(u64vec3, u64vec3, u64vec3);" 724 "u64vec4 clamp(u64vec4, u64vec4, u64vec4);" 725 726 "int64_t mix(int64_t, int64_t, bool);" 727 "i64vec2 mix(i64vec2, i64vec2, bvec2);" 728 "i64vec3 mix(i64vec3, i64vec3, bvec3);" 729 "i64vec4 mix(i64vec4, i64vec4, bvec4);" 730 "uint64_t mix(uint64_t, uint64_t, bool);" 731 "u64vec2 mix(u64vec2, u64vec2, bvec2);" 732 "u64vec3 mix(u64vec3, u64vec3, bvec3);" 733 "u64vec4 mix(u64vec4, u64vec4, bvec4);" 734 735 "int64_t doubleBitsToInt64(double);" 736 "i64vec2 doubleBitsToInt64(dvec2);" 737 "i64vec3 doubleBitsToInt64(dvec3);" 738 "i64vec4 doubleBitsToInt64(dvec4);" 739 740 "uint64_t doubleBitsToUint64(double);" 741 "u64vec2 doubleBitsToUint64(dvec2);" 742 "u64vec3 doubleBitsToUint64(dvec3);" 743 "u64vec4 doubleBitsToUint64(dvec4);" 744 745 "double int64BitsToDouble(int64_t);" 746 "dvec2 int64BitsToDouble(i64vec2);" 747 "dvec3 int64BitsToDouble(i64vec3);" 748 "dvec4 int64BitsToDouble(i64vec4);" 749 750 "double uint64BitsToDouble(uint64_t);" 751 "dvec2 uint64BitsToDouble(u64vec2);" 752 "dvec3 uint64BitsToDouble(u64vec3);" 753 "dvec4 uint64BitsToDouble(u64vec4);" 754 755 "int64_t packInt2x32(ivec2);" 756 "uint64_t packUint2x32(uvec2);" 757 "ivec2 unpackInt2x32(int64_t);" 758 "uvec2 unpackUint2x32(uint64_t);" 759 760 "bvec2 lessThan(i64vec2, i64vec2);" 761 "bvec3 lessThan(i64vec3, i64vec3);" 762 "bvec4 lessThan(i64vec4, i64vec4);" 763 "bvec2 lessThan(u64vec2, u64vec2);" 764 "bvec3 lessThan(u64vec3, u64vec3);" 765 "bvec4 lessThan(u64vec4, u64vec4);" 766 767 "bvec2 lessThanEqual(i64vec2, i64vec2);" 768 "bvec3 lessThanEqual(i64vec3, i64vec3);" 769 "bvec4 lessThanEqual(i64vec4, i64vec4);" 770 "bvec2 lessThanEqual(u64vec2, u64vec2);" 771 "bvec3 lessThanEqual(u64vec3, u64vec3);" 772 "bvec4 lessThanEqual(u64vec4, u64vec4);" 773 774 "bvec2 greaterThan(i64vec2, i64vec2);" 775 "bvec3 greaterThan(i64vec3, i64vec3);" 776 "bvec4 greaterThan(i64vec4, i64vec4);" 777 "bvec2 greaterThan(u64vec2, u64vec2);" 778 "bvec3 greaterThan(u64vec3, u64vec3);" 779 "bvec4 greaterThan(u64vec4, u64vec4);" 780 781 "bvec2 greaterThanEqual(i64vec2, i64vec2);" 782 "bvec3 greaterThanEqual(i64vec3, i64vec3);" 783 "bvec4 greaterThanEqual(i64vec4, i64vec4);" 784 "bvec2 greaterThanEqual(u64vec2, u64vec2);" 785 "bvec3 greaterThanEqual(u64vec3, u64vec3);" 786 "bvec4 greaterThanEqual(u64vec4, u64vec4);" 787 788 "bvec2 equal(i64vec2, i64vec2);" 789 "bvec3 equal(i64vec3, i64vec3);" 790 "bvec4 equal(i64vec4, i64vec4);" 791 "bvec2 equal(u64vec2, u64vec2);" 792 "bvec3 equal(u64vec3, u64vec3);" 793 "bvec4 equal(u64vec4, u64vec4);" 794 795 "bvec2 notEqual(i64vec2, i64vec2);" 796 "bvec3 notEqual(i64vec3, i64vec3);" 797 "bvec4 notEqual(i64vec4, i64vec4);" 798 "bvec2 notEqual(u64vec2, u64vec2);" 799 "bvec3 notEqual(u64vec3, u64vec3);" 800 "bvec4 notEqual(u64vec4, u64vec4);" 801 802 #ifdef AMD_EXTENSIONS 803 "int findLSB(int64_t);" 804 "ivec2 findLSB(i64vec2);" 805 "ivec3 findLSB(i64vec3);" 806 "ivec4 findLSB(i64vec4);" 807 808 "int findLSB(uint64_t);" 809 "ivec2 findLSB(u64vec2);" 810 "ivec3 findLSB(u64vec3);" 811 "ivec4 findLSB(u64vec4);" 812 813 "int findMSB(int64_t);" 814 "ivec2 findMSB(i64vec2);" 815 "ivec3 findMSB(i64vec3);" 816 "ivec4 findMSB(i64vec4);" 817 818 "int findMSB(uint64_t);" 819 "ivec2 findMSB(u64vec2);" 820 "ivec3 findMSB(u64vec3);" 821 "ivec4 findMSB(u64vec4);" 822 #endif 823 "\n" 824 ); 825 } 826 827 #ifdef AMD_EXTENSIONS 828 // GL_AMD_shader_trinary_minmax 829 if (profile != EEsProfile && version >= 430) { 830 commonBuiltins.append( 831 "float min3(float, float, float);" 832 "vec2 min3(vec2, vec2, vec2);" 833 "vec3 min3(vec3, vec3, vec3);" 834 "vec4 min3(vec4, vec4, vec4);" 835 836 "int min3(int, int, int);" 837 "ivec2 min3(ivec2, ivec2, ivec2);" 838 "ivec3 min3(ivec3, ivec3, ivec3);" 839 "ivec4 min3(ivec4, ivec4, ivec4);" 840 841 "uint min3(uint, uint, uint);" 842 "uvec2 min3(uvec2, uvec2, uvec2);" 843 "uvec3 min3(uvec3, uvec3, uvec3);" 844 "uvec4 min3(uvec4, uvec4, uvec4);" 845 846 "float max3(float, float, float);" 847 "vec2 max3(vec2, vec2, vec2);" 848 "vec3 max3(vec3, vec3, vec3);" 849 "vec4 max3(vec4, vec4, vec4);" 850 851 "int max3(int, int, int);" 852 "ivec2 max3(ivec2, ivec2, ivec2);" 853 "ivec3 max3(ivec3, ivec3, ivec3);" 854 "ivec4 max3(ivec4, ivec4, ivec4);" 855 856 "uint max3(uint, uint, uint);" 857 "uvec2 max3(uvec2, uvec2, uvec2);" 858 "uvec3 max3(uvec3, uvec3, uvec3);" 859 "uvec4 max3(uvec4, uvec4, uvec4);" 860 861 "float mid3(float, float, float);" 862 "vec2 mid3(vec2, vec2, vec2);" 863 "vec3 mid3(vec3, vec3, vec3);" 864 "vec4 mid3(vec4, vec4, vec4);" 865 866 "int mid3(int, int, int);" 867 "ivec2 mid3(ivec2, ivec2, ivec2);" 868 "ivec3 mid3(ivec3, ivec3, ivec3);" 869 "ivec4 mid3(ivec4, ivec4, ivec4);" 870 871 "uint mid3(uint, uint, uint);" 872 "uvec2 mid3(uvec2, uvec2, uvec2);" 873 "uvec3 mid3(uvec3, uvec3, uvec3);" 874 "uvec4 mid3(uvec4, uvec4, uvec4);" 875 876 "float16_t min3(float16_t, float16_t, float16_t);" 877 "f16vec2 min3(f16vec2, f16vec2, f16vec2);" 878 "f16vec3 min3(f16vec3, f16vec3, f16vec3);" 879 "f16vec4 min3(f16vec4, f16vec4, f16vec4);" 880 881 "float16_t max3(float16_t, float16_t, float16_t);" 882 "f16vec2 max3(f16vec2, f16vec2, f16vec2);" 883 "f16vec3 max3(f16vec3, f16vec3, f16vec3);" 884 "f16vec4 max3(f16vec4, f16vec4, f16vec4);" 885 886 "float16_t mid3(float16_t, float16_t, float16_t);" 887 "f16vec2 mid3(f16vec2, f16vec2, f16vec2);" 888 "f16vec3 mid3(f16vec3, f16vec3, f16vec3);" 889 "f16vec4 mid3(f16vec4, f16vec4, f16vec4);" 890 891 "\n" 892 ); 893 } 894 #endif 895 896 if ((profile == EEsProfile && version >= 310) || 897 (profile != EEsProfile && version >= 430)) { 898 commonBuiltins.append( 899 "uint atomicAdd(coherent volatile inout uint, uint);" 900 " int atomicAdd(coherent volatile inout int, int);" 901 902 "uint atomicMin(coherent volatile inout uint, uint);" 903 " int atomicMin(coherent volatile inout int, int);" 904 905 "uint atomicMax(coherent volatile inout uint, uint);" 906 " int atomicMax(coherent volatile inout int, int);" 907 908 "uint atomicAnd(coherent volatile inout uint, uint);" 909 " int atomicAnd(coherent volatile inout int, int);" 910 911 "uint atomicOr (coherent volatile inout uint, uint);" 912 " int atomicOr (coherent volatile inout int, int);" 913 914 "uint atomicXor(coherent volatile inout uint, uint);" 915 " int atomicXor(coherent volatile inout int, int);" 916 917 "uint atomicExchange(coherent volatile inout uint, uint);" 918 " int atomicExchange(coherent volatile inout int, int);" 919 920 "uint atomicCompSwap(coherent volatile inout uint, uint, uint);" 921 " int atomicCompSwap(coherent volatile inout int, int, int);" 922 923 "\n"); 924 } 925 926 if ((profile == EEsProfile && version >= 310) || 927 (profile != EEsProfile && version >= 450)) { 928 commonBuiltins.append( 929 "int mix(int x, int y, bool a);" 930 "ivec2 mix(ivec2 x, ivec2 y, bvec2 a);" 931 "ivec3 mix(ivec3 x, ivec3 y, bvec3 a);" 932 "ivec4 mix(ivec4 x, ivec4 y, bvec4 a);" 933 934 "uint mix(uint x, uint y, bool a);" 935 "uvec2 mix(uvec2 x, uvec2 y, bvec2 a);" 936 "uvec3 mix(uvec3 x, uvec3 y, bvec3 a);" 937 "uvec4 mix(uvec4 x, uvec4 y, bvec4 a);" 938 939 "bool mix(bool x, bool y, bool a);" 940 "bvec2 mix(bvec2 x, bvec2 y, bvec2 a);" 941 "bvec3 mix(bvec3 x, bvec3 y, bvec3 a);" 942 "bvec4 mix(bvec4 x, bvec4 y, bvec4 a);" 943 944 "\n"); 945 } 946 947 if ((profile == EEsProfile && version >= 300) || 948 (profile != EEsProfile && version >= 330)) { 949 commonBuiltins.append( 950 "int floatBitsToInt(highp float value);" 951 "ivec2 floatBitsToInt(highp vec2 value);" 952 "ivec3 floatBitsToInt(highp vec3 value);" 953 "ivec4 floatBitsToInt(highp vec4 value);" 954 955 "uint floatBitsToUint(highp float value);" 956 "uvec2 floatBitsToUint(highp vec2 value);" 957 "uvec3 floatBitsToUint(highp vec3 value);" 958 "uvec4 floatBitsToUint(highp vec4 value);" 959 960 "float intBitsToFloat(highp int value);" 961 "vec2 intBitsToFloat(highp ivec2 value);" 962 "vec3 intBitsToFloat(highp ivec3 value);" 963 "vec4 intBitsToFloat(highp ivec4 value);" 964 965 "float uintBitsToFloat(highp uint value);" 966 "vec2 uintBitsToFloat(highp uvec2 value);" 967 "vec3 uintBitsToFloat(highp uvec3 value);" 968 "vec4 uintBitsToFloat(highp uvec4 value);" 969 970 "\n"); 971 } 972 973 if ((profile != EEsProfile && version >= 400) || 974 (profile == EEsProfile && version >= 310)) { // GL_OES_gpu_shader5 975 976 commonBuiltins.append( 977 "float fma(float, float, float );" 978 "vec2 fma(vec2, vec2, vec2 );" 979 "vec3 fma(vec3, vec3, vec3 );" 980 "vec4 fma(vec4, vec4, vec4 );" 981 "\n"); 982 983 if (profile != EEsProfile) { 984 commonBuiltins.append( 985 "double fma(double, double, double);" 986 "dvec2 fma(dvec2, dvec2, dvec2 );" 987 "dvec3 fma(dvec3, dvec3, dvec3 );" 988 "dvec4 fma(dvec4, dvec4, dvec4 );" 989 "\n"); 990 } 991 } 992 993 if ((profile == EEsProfile && version >= 310) || 994 (profile != EEsProfile && version >= 400)) { 995 commonBuiltins.append( 996 "float frexp(highp float, out highp int);" 997 "vec2 frexp(highp vec2, out highp ivec2);" 998 "vec3 frexp(highp vec3, out highp ivec3);" 999 "vec4 frexp(highp vec4, out highp ivec4);" 1000 1001 "float ldexp(highp float, highp int);" 1002 "vec2 ldexp(highp vec2, highp ivec2);" 1003 "vec3 ldexp(highp vec3, highp ivec3);" 1004 "vec4 ldexp(highp vec4, highp ivec4);" 1005 1006 "\n"); 1007 } 1008 1009 if (profile != EEsProfile && version >= 400) { 1010 commonBuiltins.append( 1011 "double frexp(double, out int);" 1012 "dvec2 frexp( dvec2, out ivec2);" 1013 "dvec3 frexp( dvec3, out ivec3);" 1014 "dvec4 frexp( dvec4, out ivec4);" 1015 1016 "double ldexp(double, int);" 1017 "dvec2 ldexp( dvec2, ivec2);" 1018 "dvec3 ldexp( dvec3, ivec3);" 1019 "dvec4 ldexp( dvec4, ivec4);" 1020 1021 "double packDouble2x32(uvec2);" 1022 "uvec2 unpackDouble2x32(double);" 1023 1024 "\n"); 1025 } 1026 1027 if ((profile == EEsProfile && version >= 300) || 1028 (profile != EEsProfile && version >= 400)) { 1029 commonBuiltins.append( 1030 "highp uint packUnorm2x16(vec2);" 1031 "vec2 unpackUnorm2x16(highp uint);" 1032 "\n"); 1033 } 1034 1035 if ((profile == EEsProfile && version >= 300) || 1036 (profile != EEsProfile && version >= 420)) { 1037 commonBuiltins.append( 1038 "highp uint packSnorm2x16(vec2);" 1039 " vec2 unpackSnorm2x16(highp uint);" 1040 "highp uint packHalf2x16(vec2);" 1041 "\n"); 1042 } 1043 1044 if (profile == EEsProfile && version >= 300) { 1045 commonBuiltins.append( 1046 "mediump vec2 unpackHalf2x16(highp uint);" 1047 "\n"); 1048 } else if (profile != EEsProfile && version >= 420) { 1049 commonBuiltins.append( 1050 " vec2 unpackHalf2x16(highp uint);" 1051 "\n"); 1052 } 1053 1054 if ((profile == EEsProfile && version >= 310) || 1055 (profile != EEsProfile && version >= 400)) { 1056 commonBuiltins.append( 1057 "highp uint packSnorm4x8(vec4);" 1058 "highp uint packUnorm4x8(vec4);" 1059 "\n"); 1060 } 1061 1062 if (profile == EEsProfile && version >= 310) { 1063 commonBuiltins.append( 1064 "mediump vec4 unpackSnorm4x8(highp uint);" 1065 "mediump vec4 unpackUnorm4x8(highp uint);" 1066 "\n"); 1067 } else if (profile != EEsProfile && version >= 400) { 1068 commonBuiltins.append( 1069 "vec4 unpackSnorm4x8(highp uint);" 1070 "vec4 unpackUnorm4x8(highp uint);" 1071 "\n"); 1072 } 1073 1074 // 1075 // Geometric Functions. 1076 // 1077 commonBuiltins.append( 1078 "float length(float x);" 1079 "float length(vec2 x);" 1080 "float length(vec3 x);" 1081 "float length(vec4 x);" 1082 1083 "float distance(float p0, float p1);" 1084 "float distance(vec2 p0, vec2 p1);" 1085 "float distance(vec3 p0, vec3 p1);" 1086 "float distance(vec4 p0, vec4 p1);" 1087 1088 "float dot(float x, float y);" 1089 "float dot(vec2 x, vec2 y);" 1090 "float dot(vec3 x, vec3 y);" 1091 "float dot(vec4 x, vec4 y);" 1092 1093 "vec3 cross(vec3 x, vec3 y);" 1094 "float normalize(float x);" 1095 "vec2 normalize(vec2 x);" 1096 "vec3 normalize(vec3 x);" 1097 "vec4 normalize(vec4 x);" 1098 1099 "float faceforward(float N, float I, float Nref);" 1100 "vec2 faceforward(vec2 N, vec2 I, vec2 Nref);" 1101 "vec3 faceforward(vec3 N, vec3 I, vec3 Nref);" 1102 "vec4 faceforward(vec4 N, vec4 I, vec4 Nref);" 1103 1104 "float reflect(float I, float N);" 1105 "vec2 reflect(vec2 I, vec2 N);" 1106 "vec3 reflect(vec3 I, vec3 N);" 1107 "vec4 reflect(vec4 I, vec4 N);" 1108 1109 "float refract(float I, float N, float eta);" 1110 "vec2 refract(vec2 I, vec2 N, float eta);" 1111 "vec3 refract(vec3 I, vec3 N, float eta);" 1112 "vec4 refract(vec4 I, vec4 N, float eta);" 1113 1114 "\n"); 1115 1116 // 1117 // Matrix Functions. 1118 // 1119 commonBuiltins.append( 1120 "mat2 matrixCompMult(mat2 x, mat2 y);" 1121 "mat3 matrixCompMult(mat3 x, mat3 y);" 1122 "mat4 matrixCompMult(mat4 x, mat4 y);" 1123 1124 "\n"); 1125 1126 // 120 is correct for both ES and desktop 1127 if (version >= 120) { 1128 commonBuiltins.append( 1129 "mat2 outerProduct(vec2 c, vec2 r);" 1130 "mat3 outerProduct(vec3 c, vec3 r);" 1131 "mat4 outerProduct(vec4 c, vec4 r);" 1132 "mat2x3 outerProduct(vec3 c, vec2 r);" 1133 "mat3x2 outerProduct(vec2 c, vec3 r);" 1134 "mat2x4 outerProduct(vec4 c, vec2 r);" 1135 "mat4x2 outerProduct(vec2 c, vec4 r);" 1136 "mat3x4 outerProduct(vec4 c, vec3 r);" 1137 "mat4x3 outerProduct(vec3 c, vec4 r);" 1138 1139 "mat2 transpose(mat2 m);" 1140 "mat3 transpose(mat3 m);" 1141 "mat4 transpose(mat4 m);" 1142 "mat2x3 transpose(mat3x2 m);" 1143 "mat3x2 transpose(mat2x3 m);" 1144 "mat2x4 transpose(mat4x2 m);" 1145 "mat4x2 transpose(mat2x4 m);" 1146 "mat3x4 transpose(mat4x3 m);" 1147 "mat4x3 transpose(mat3x4 m);" 1148 1149 "mat2x3 matrixCompMult(mat2x3, mat2x3);" 1150 "mat2x4 matrixCompMult(mat2x4, mat2x4);" 1151 "mat3x2 matrixCompMult(mat3x2, mat3x2);" 1152 "mat3x4 matrixCompMult(mat3x4, mat3x4);" 1153 "mat4x2 matrixCompMult(mat4x2, mat4x2);" 1154 "mat4x3 matrixCompMult(mat4x3, mat4x3);" 1155 1156 "\n"); 1157 1158 // 150 is correct for both ES and desktop 1159 if (version >= 150) { 1160 commonBuiltins.append( 1161 "float determinant(mat2 m);" 1162 "float determinant(mat3 m);" 1163 "float determinant(mat4 m);" 1164 1165 "mat2 inverse(mat2 m);" 1166 "mat3 inverse(mat3 m);" 1167 "mat4 inverse(mat4 m);" 1168 1169 "\n"); 1170 } 1171 } 1172 1173 // 1174 // Vector relational functions. 1175 // 1176 commonBuiltins.append( 1177 "bvec2 lessThan(vec2 x, vec2 y);" 1178 "bvec3 lessThan(vec3 x, vec3 y);" 1179 "bvec4 lessThan(vec4 x, vec4 y);" 1180 1181 "bvec2 lessThan(ivec2 x, ivec2 y);" 1182 "bvec3 lessThan(ivec3 x, ivec3 y);" 1183 "bvec4 lessThan(ivec4 x, ivec4 y);" 1184 1185 "bvec2 lessThanEqual(vec2 x, vec2 y);" 1186 "bvec3 lessThanEqual(vec3 x, vec3 y);" 1187 "bvec4 lessThanEqual(vec4 x, vec4 y);" 1188 1189 "bvec2 lessThanEqual(ivec2 x, ivec2 y);" 1190 "bvec3 lessThanEqual(ivec3 x, ivec3 y);" 1191 "bvec4 lessThanEqual(ivec4 x, ivec4 y);" 1192 1193 "bvec2 greaterThan(vec2 x, vec2 y);" 1194 "bvec3 greaterThan(vec3 x, vec3 y);" 1195 "bvec4 greaterThan(vec4 x, vec4 y);" 1196 1197 "bvec2 greaterThan(ivec2 x, ivec2 y);" 1198 "bvec3 greaterThan(ivec3 x, ivec3 y);" 1199 "bvec4 greaterThan(ivec4 x, ivec4 y);" 1200 1201 "bvec2 greaterThanEqual(vec2 x, vec2 y);" 1202 "bvec3 greaterThanEqual(vec3 x, vec3 y);" 1203 "bvec4 greaterThanEqual(vec4 x, vec4 y);" 1204 1205 "bvec2 greaterThanEqual(ivec2 x, ivec2 y);" 1206 "bvec3 greaterThanEqual(ivec3 x, ivec3 y);" 1207 "bvec4 greaterThanEqual(ivec4 x, ivec4 y);" 1208 1209 "bvec2 equal(vec2 x, vec2 y);" 1210 "bvec3 equal(vec3 x, vec3 y);" 1211 "bvec4 equal(vec4 x, vec4 y);" 1212 1213 "bvec2 equal(ivec2 x, ivec2 y);" 1214 "bvec3 equal(ivec3 x, ivec3 y);" 1215 "bvec4 equal(ivec4 x, ivec4 y);" 1216 1217 "bvec2 equal(bvec2 x, bvec2 y);" 1218 "bvec3 equal(bvec3 x, bvec3 y);" 1219 "bvec4 equal(bvec4 x, bvec4 y);" 1220 1221 "bvec2 notEqual(vec2 x, vec2 y);" 1222 "bvec3 notEqual(vec3 x, vec3 y);" 1223 "bvec4 notEqual(vec4 x, vec4 y);" 1224 1225 "bvec2 notEqual(ivec2 x, ivec2 y);" 1226 "bvec3 notEqual(ivec3 x, ivec3 y);" 1227 "bvec4 notEqual(ivec4 x, ivec4 y);" 1228 1229 "bvec2 notEqual(bvec2 x, bvec2 y);" 1230 "bvec3 notEqual(bvec3 x, bvec3 y);" 1231 "bvec4 notEqual(bvec4 x, bvec4 y);" 1232 1233 "bool any(bvec2 x);" 1234 "bool any(bvec3 x);" 1235 "bool any(bvec4 x);" 1236 1237 "bool all(bvec2 x);" 1238 "bool all(bvec3 x);" 1239 "bool all(bvec4 x);" 1240 1241 "bvec2 not(bvec2 x);" 1242 "bvec3 not(bvec3 x);" 1243 "bvec4 not(bvec4 x);" 1244 1245 "\n"); 1246 1247 if (version >= 130) { 1248 commonBuiltins.append( 1249 "bvec2 lessThan(uvec2 x, uvec2 y);" 1250 "bvec3 lessThan(uvec3 x, uvec3 y);" 1251 "bvec4 lessThan(uvec4 x, uvec4 y);" 1252 1253 "bvec2 lessThanEqual(uvec2 x, uvec2 y);" 1254 "bvec3 lessThanEqual(uvec3 x, uvec3 y);" 1255 "bvec4 lessThanEqual(uvec4 x, uvec4 y);" 1256 1257 "bvec2 greaterThan(uvec2 x, uvec2 y);" 1258 "bvec3 greaterThan(uvec3 x, uvec3 y);" 1259 "bvec4 greaterThan(uvec4 x, uvec4 y);" 1260 1261 "bvec2 greaterThanEqual(uvec2 x, uvec2 y);" 1262 "bvec3 greaterThanEqual(uvec3 x, uvec3 y);" 1263 "bvec4 greaterThanEqual(uvec4 x, uvec4 y);" 1264 1265 "bvec2 equal(uvec2 x, uvec2 y);" 1266 "bvec3 equal(uvec3 x, uvec3 y);" 1267 "bvec4 equal(uvec4 x, uvec4 y);" 1268 1269 "bvec2 notEqual(uvec2 x, uvec2 y);" 1270 "bvec3 notEqual(uvec3 x, uvec3 y);" 1271 "bvec4 notEqual(uvec4 x, uvec4 y);" 1272 1273 "\n"); 1274 } 1275 1276 // 1277 // Original-style texture functions existing in all stages. 1278 // (Per-stage functions below.) 1279 // 1280 if ((profile == EEsProfile && version == 100) || 1281 profile == ECompatibilityProfile || 1282 (profile == ECoreProfile && version < 420) || 1283 profile == ENoProfile) { 1284 if (spvVersion.spv == 0) { 1285 commonBuiltins.append( 1286 "vec4 texture2D(sampler2D, vec2);" 1287 1288 "vec4 texture2DProj(sampler2D, vec3);" 1289 "vec4 texture2DProj(sampler2D, vec4);" 1290 1291 "vec4 texture3D(sampler3D, vec3);" // OES_texture_3D, but caught by keyword check 1292 "vec4 texture3DProj(sampler3D, vec4);" // OES_texture_3D, but caught by keyword check 1293 1294 "vec4 textureCube(samplerCube, vec3);" 1295 1296 "\n"); 1297 } 1298 } 1299 1300 if ( profile == ECompatibilityProfile || 1301 (profile == ECoreProfile && version < 420) || 1302 profile == ENoProfile) { 1303 if (spvVersion.spv == 0) { 1304 commonBuiltins.append( 1305 "vec4 texture1D(sampler1D, float);" 1306 1307 "vec4 texture1DProj(sampler1D, vec2);" 1308 "vec4 texture1DProj(sampler1D, vec4);" 1309 1310 "vec4 shadow1D(sampler1DShadow, vec3);" 1311 "vec4 shadow2D(sampler2DShadow, vec3);" 1312 "vec4 shadow1DProj(sampler1DShadow, vec4);" 1313 "vec4 shadow2DProj(sampler2DShadow, vec4);" 1314 1315 "vec4 texture2DRect(sampler2DRect, vec2);" // GL_ARB_texture_rectangle, caught by keyword check 1316 "vec4 texture2DRectProj(sampler2DRect, vec3);" // GL_ARB_texture_rectangle, caught by keyword check 1317 "vec4 texture2DRectProj(sampler2DRect, vec4);" // GL_ARB_texture_rectangle, caught by keyword check 1318 "vec4 shadow2DRect(sampler2DRectShadow, vec3);" // GL_ARB_texture_rectangle, caught by keyword check 1319 "vec4 shadow2DRectProj(sampler2DRectShadow, vec4);" // GL_ARB_texture_rectangle, caught by keyword check 1320 1321 "\n"); 1322 } 1323 } 1324 1325 if (profile == EEsProfile) { 1326 if (spvVersion.spv == 0) { 1327 commonBuiltins.append( 1328 "vec4 texture2D(samplerExternalOES, vec2 coord);" // GL_OES_EGL_image_external, caught by keyword check 1329 "vec4 texture2DProj(samplerExternalOES, vec3);" // GL_OES_EGL_image_external, caught by keyword check 1330 "vec4 texture2DProj(samplerExternalOES, vec4);" // GL_OES_EGL_image_external, caught by keyword check 1331 "vec4 texture2DGradEXT(sampler2D, vec2, vec2, vec2);" // GL_EXT_shader_texture_lod 1332 "vec4 texture2DProjGradEXT(sampler2D, vec3, vec2, vec2);" // GL_EXT_shader_texture_lod 1333 "vec4 texture2DProjGradEXT(sampler2D, vec4, vec2, vec2);" // GL_EXT_shader_texture_lod 1334 "vec4 textureCubeGradEXT(samplerCube, vec3, vec3, vec3);" // GL_EXT_shader_texture_lod 1335 1336 "float shadow2DEXT(sampler2DShadow, vec3);" // GL_EXT_shadow_samplers 1337 "float shadow2DProjEXT(sampler2DShadow, vec4);" // GL_EXT_shadow_samplers 1338 1339 "\n"); 1340 } 1341 } 1342 1343 // 1344 // Noise functions. 1345 // 1346 if (profile != EEsProfile) { 1347 commonBuiltins.append( 1348 "float noise1(float x);" 1349 "float noise1(vec2 x);" 1350 "float noise1(vec3 x);" 1351 "float noise1(vec4 x);" 1352 1353 "vec2 noise2(float x);" 1354 "vec2 noise2(vec2 x);" 1355 "vec2 noise2(vec3 x);" 1356 "vec2 noise2(vec4 x);" 1357 1358 "vec3 noise3(float x);" 1359 "vec3 noise3(vec2 x);" 1360 "vec3 noise3(vec3 x);" 1361 "vec3 noise3(vec4 x);" 1362 1363 "vec4 noise4(float x);" 1364 "vec4 noise4(vec2 x);" 1365 "vec4 noise4(vec3 x);" 1366 "vec4 noise4(vec4 x);" 1367 1368 "\n"); 1369 } 1370 1371 if (spvVersion.vulkan == 0) { 1372 // 1373 // Atomic counter functions. 1374 // 1375 if ((profile != EEsProfile && version >= 300) || 1376 (profile == EEsProfile && version >= 310)) { 1377 commonBuiltins.append( 1378 "uint atomicCounterIncrement(atomic_uint);" 1379 "uint atomicCounterDecrement(atomic_uint);" 1380 "uint atomicCounter(atomic_uint);" 1381 1382 "\n"); 1383 } 1384 if (profile != EEsProfile && version >= 460) { 1385 commonBuiltins.append( 1386 "uint atomicCounterAdd(atomic_uint, uint);" 1387 "uint atomicCounterSubtract(atomic_uint, uint);" 1388 "uint atomicCounterMin(atomic_uint, uint);" 1389 "uint atomicCounterMax(atomic_uint, uint);" 1390 "uint atomicCounterAnd(atomic_uint, uint);" 1391 "uint atomicCounterOr(atomic_uint, uint);" 1392 "uint atomicCounterXor(atomic_uint, uint);" 1393 "uint atomicCounterExchange(atomic_uint, uint);" 1394 "uint atomicCounterCompSwap(atomic_uint, uint, uint);" 1395 1396 "\n"); 1397 } 1398 } 1399 1400 // Bitfield 1401 if ((profile == EEsProfile && version >= 310) || 1402 (profile != EEsProfile && version >= 400)) { 1403 commonBuiltins.append( 1404 " int bitfieldExtract( int, int, int);" 1405 "ivec2 bitfieldExtract(ivec2, int, int);" 1406 "ivec3 bitfieldExtract(ivec3, int, int);" 1407 "ivec4 bitfieldExtract(ivec4, int, int);" 1408 1409 " uint bitfieldExtract( uint, int, int);" 1410 "uvec2 bitfieldExtract(uvec2, int, int);" 1411 "uvec3 bitfieldExtract(uvec3, int, int);" 1412 "uvec4 bitfieldExtract(uvec4, int, int);" 1413 1414 " int bitfieldInsert( int base, int, int, int);" 1415 "ivec2 bitfieldInsert(ivec2 base, ivec2, int, int);" 1416 "ivec3 bitfieldInsert(ivec3 base, ivec3, int, int);" 1417 "ivec4 bitfieldInsert(ivec4 base, ivec4, int, int);" 1418 1419 " uint bitfieldInsert( uint base, uint, int, int);" 1420 "uvec2 bitfieldInsert(uvec2 base, uvec2, int, int);" 1421 "uvec3 bitfieldInsert(uvec3 base, uvec3, int, int);" 1422 "uvec4 bitfieldInsert(uvec4 base, uvec4, int, int);" 1423 1424 "\n"); 1425 } 1426 1427 if (profile != EEsProfile && version >= 400) { 1428 commonBuiltins.append( 1429 " int findLSB( int);" 1430 "ivec2 findLSB(ivec2);" 1431 "ivec3 findLSB(ivec3);" 1432 "ivec4 findLSB(ivec4);" 1433 1434 " int findLSB( uint);" 1435 "ivec2 findLSB(uvec2);" 1436 "ivec3 findLSB(uvec3);" 1437 "ivec4 findLSB(uvec4);" 1438 1439 "\n"); 1440 } else if (profile == EEsProfile && version >= 310) { 1441 commonBuiltins.append( 1442 "lowp int findLSB( int);" 1443 "lowp ivec2 findLSB(ivec2);" 1444 "lowp ivec3 findLSB(ivec3);" 1445 "lowp ivec4 findLSB(ivec4);" 1446 1447 "lowp int findLSB( uint);" 1448 "lowp ivec2 findLSB(uvec2);" 1449 "lowp ivec3 findLSB(uvec3);" 1450 "lowp ivec4 findLSB(uvec4);" 1451 1452 "\n"); 1453 } 1454 1455 if (profile != EEsProfile && version >= 400) { 1456 commonBuiltins.append( 1457 " int bitCount( int);" 1458 "ivec2 bitCount(ivec2);" 1459 "ivec3 bitCount(ivec3);" 1460 "ivec4 bitCount(ivec4);" 1461 1462 " int bitCount( uint);" 1463 "ivec2 bitCount(uvec2);" 1464 "ivec3 bitCount(uvec3);" 1465 "ivec4 bitCount(uvec4);" 1466 1467 " int findMSB(highp int);" 1468 "ivec2 findMSB(highp ivec2);" 1469 "ivec3 findMSB(highp ivec3);" 1470 "ivec4 findMSB(highp ivec4);" 1471 1472 " int findMSB(highp uint);" 1473 "ivec2 findMSB(highp uvec2);" 1474 "ivec3 findMSB(highp uvec3);" 1475 "ivec4 findMSB(highp uvec4);" 1476 1477 "\n"); 1478 } 1479 1480 if ((profile == EEsProfile && version >= 310) || 1481 (profile != EEsProfile && version >= 400)) { 1482 commonBuiltins.append( 1483 " uint uaddCarry(highp uint, highp uint, out lowp uint carry);" 1484 "uvec2 uaddCarry(highp uvec2, highp uvec2, out lowp uvec2 carry);" 1485 "uvec3 uaddCarry(highp uvec3, highp uvec3, out lowp uvec3 carry);" 1486 "uvec4 uaddCarry(highp uvec4, highp uvec4, out lowp uvec4 carry);" 1487 1488 " uint usubBorrow(highp uint, highp uint, out lowp uint borrow);" 1489 "uvec2 usubBorrow(highp uvec2, highp uvec2, out lowp uvec2 borrow);" 1490 "uvec3 usubBorrow(highp uvec3, highp uvec3, out lowp uvec3 borrow);" 1491 "uvec4 usubBorrow(highp uvec4, highp uvec4, out lowp uvec4 borrow);" 1492 1493 "void umulExtended(highp uint, highp uint, out highp uint, out highp uint lsb);" 1494 "void umulExtended(highp uvec2, highp uvec2, out highp uvec2, out highp uvec2 lsb);" 1495 "void umulExtended(highp uvec3, highp uvec3, out highp uvec3, out highp uvec3 lsb);" 1496 "void umulExtended(highp uvec4, highp uvec4, out highp uvec4, out highp uvec4 lsb);" 1497 1498 "void imulExtended(highp int, highp int, out highp int, out highp int lsb);" 1499 "void imulExtended(highp ivec2, highp ivec2, out highp ivec2, out highp ivec2 lsb);" 1500 "void imulExtended(highp ivec3, highp ivec3, out highp ivec3, out highp ivec3 lsb);" 1501 "void imulExtended(highp ivec4, highp ivec4, out highp ivec4, out highp ivec4 lsb);" 1502 1503 " int bitfieldReverse(highp int);" 1504 "ivec2 bitfieldReverse(highp ivec2);" 1505 "ivec3 bitfieldReverse(highp ivec3);" 1506 "ivec4 bitfieldReverse(highp ivec4);" 1507 1508 " uint bitfieldReverse(highp uint);" 1509 "uvec2 bitfieldReverse(highp uvec2);" 1510 "uvec3 bitfieldReverse(highp uvec3);" 1511 "uvec4 bitfieldReverse(highp uvec4);" 1512 1513 "\n"); 1514 } 1515 1516 if (profile == EEsProfile && version >= 310) { 1517 commonBuiltins.append( 1518 "lowp int bitCount( int);" 1519 "lowp ivec2 bitCount(ivec2);" 1520 "lowp ivec3 bitCount(ivec3);" 1521 "lowp ivec4 bitCount(ivec4);" 1522 1523 "lowp int bitCount( uint);" 1524 "lowp ivec2 bitCount(uvec2);" 1525 "lowp ivec3 bitCount(uvec3);" 1526 "lowp ivec4 bitCount(uvec4);" 1527 1528 "lowp int findMSB(highp int);" 1529 "lowp ivec2 findMSB(highp ivec2);" 1530 "lowp ivec3 findMSB(highp ivec3);" 1531 "lowp ivec4 findMSB(highp ivec4);" 1532 1533 "lowp int findMSB(highp uint);" 1534 "lowp ivec2 findMSB(highp uvec2);" 1535 "lowp ivec3 findMSB(highp uvec3);" 1536 "lowp ivec4 findMSB(highp uvec4);" 1537 1538 "\n"); 1539 } 1540 1541 // GL_ARB_shader_ballot 1542 if (profile != EEsProfile && version >= 450) { 1543 commonBuiltins.append( 1544 "uint64_t ballotARB(bool);" 1545 1546 "float readInvocationARB(float, uint);" 1547 "vec2 readInvocationARB(vec2, uint);" 1548 "vec3 readInvocationARB(vec3, uint);" 1549 "vec4 readInvocationARB(vec4, uint);" 1550 1551 "int readInvocationARB(int, uint);" 1552 "ivec2 readInvocationARB(ivec2, uint);" 1553 "ivec3 readInvocationARB(ivec3, uint);" 1554 "ivec4 readInvocationARB(ivec4, uint);" 1555 1556 "uint readInvocationARB(uint, uint);" 1557 "uvec2 readInvocationARB(uvec2, uint);" 1558 "uvec3 readInvocationARB(uvec3, uint);" 1559 "uvec4 readInvocationARB(uvec4, uint);" 1560 1561 "float readFirstInvocationARB(float);" 1562 "vec2 readFirstInvocationARB(vec2);" 1563 "vec3 readFirstInvocationARB(vec3);" 1564 "vec4 readFirstInvocationARB(vec4);" 1565 1566 "int readFirstInvocationARB(int);" 1567 "ivec2 readFirstInvocationARB(ivec2);" 1568 "ivec3 readFirstInvocationARB(ivec3);" 1569 "ivec4 readFirstInvocationARB(ivec4);" 1570 1571 "uint readFirstInvocationARB(uint);" 1572 "uvec2 readFirstInvocationARB(uvec2);" 1573 "uvec3 readFirstInvocationARB(uvec3);" 1574 "uvec4 readFirstInvocationARB(uvec4);" 1575 1576 "\n"); 1577 } 1578 1579 // GL_ARB_shader_group_vote 1580 if (profile != EEsProfile && version >= 430) { 1581 commonBuiltins.append( 1582 "bool anyInvocationARB(bool);" 1583 "bool allInvocationsARB(bool);" 1584 "bool allInvocationsEqualARB(bool);" 1585 1586 "\n"); 1587 } 1588 1589 if (profile != EEsProfile && version >= 460) { 1590 commonBuiltins.append( 1591 "bool anyInvocation(bool);" 1592 "bool allInvocations(bool);" 1593 "bool allInvocationsEqual(bool);" 1594 1595 "\n"); 1596 } 1597 1598 #ifdef AMD_EXTENSIONS 1599 // GL_AMD_shader_ballot 1600 if (profile != EEsProfile && version >= 450) { 1601 commonBuiltins.append( 1602 "float minInvocationsAMD(float);" 1603 "vec2 minInvocationsAMD(vec2);" 1604 "vec3 minInvocationsAMD(vec3);" 1605 "vec4 minInvocationsAMD(vec4);" 1606 1607 "int minInvocationsAMD(int);" 1608 "ivec2 minInvocationsAMD(ivec2);" 1609 "ivec3 minInvocationsAMD(ivec3);" 1610 "ivec4 minInvocationsAMD(ivec4);" 1611 1612 "uint minInvocationsAMD(uint);" 1613 "uvec2 minInvocationsAMD(uvec2);" 1614 "uvec3 minInvocationsAMD(uvec3);" 1615 "uvec4 minInvocationsAMD(uvec4);" 1616 1617 "double minInvocationsAMD(double);" 1618 "dvec2 minInvocationsAMD(dvec2);" 1619 "dvec3 minInvocationsAMD(dvec3);" 1620 "dvec4 minInvocationsAMD(dvec4);" 1621 1622 "int64_t minInvocationsAMD(int64_t);" 1623 "i64vec2 minInvocationsAMD(i64vec2);" 1624 "i64vec3 minInvocationsAMD(i64vec3);" 1625 "i64vec4 minInvocationsAMD(i64vec4);" 1626 1627 "uint64_t minInvocationsAMD(uint64_t);" 1628 "u64vec2 minInvocationsAMD(u64vec2);" 1629 "u64vec3 minInvocationsAMD(u64vec3);" 1630 "u64vec4 minInvocationsAMD(u64vec4);" 1631 1632 "float16_t minInvocationsAMD(float16_t);" 1633 "f16vec2 minInvocationsAMD(f16vec2);" 1634 "f16vec3 minInvocationsAMD(f16vec3);" 1635 "f16vec4 minInvocationsAMD(f16vec4);" 1636 1637 "float minInvocationsInclusiveScanAMD(float);" 1638 "vec2 minInvocationsInclusiveScanAMD(vec2);" 1639 "vec3 minInvocationsInclusiveScanAMD(vec3);" 1640 "vec4 minInvocationsInclusiveScanAMD(vec4);" 1641 1642 "int minInvocationsInclusiveScanAMD(int);" 1643 "ivec2 minInvocationsInclusiveScanAMD(ivec2);" 1644 "ivec3 minInvocationsInclusiveScanAMD(ivec3);" 1645 "ivec4 minInvocationsInclusiveScanAMD(ivec4);" 1646 1647 "uint minInvocationsInclusiveScanAMD(uint);" 1648 "uvec2 minInvocationsInclusiveScanAMD(uvec2);" 1649 "uvec3 minInvocationsInclusiveScanAMD(uvec3);" 1650 "uvec4 minInvocationsInclusiveScanAMD(uvec4);" 1651 1652 "double minInvocationsInclusiveScanAMD(double);" 1653 "dvec2 minInvocationsInclusiveScanAMD(dvec2);" 1654 "dvec3 minInvocationsInclusiveScanAMD(dvec3);" 1655 "dvec4 minInvocationsInclusiveScanAMD(dvec4);" 1656 1657 "int64_t minInvocationsInclusiveScanAMD(int64_t);" 1658 "i64vec2 minInvocationsInclusiveScanAMD(i64vec2);" 1659 "i64vec3 minInvocationsInclusiveScanAMD(i64vec3);" 1660 "i64vec4 minInvocationsInclusiveScanAMD(i64vec4);" 1661 1662 "uint64_t minInvocationsInclusiveScanAMD(uint64_t);" 1663 "u64vec2 minInvocationsInclusiveScanAMD(u64vec2);" 1664 "u64vec3 minInvocationsInclusiveScanAMD(u64vec3);" 1665 "u64vec4 minInvocationsInclusiveScanAMD(u64vec4);" 1666 1667 "float16_t minInvocationsInclusiveScanAMD(float16_t);" 1668 "f16vec2 minInvocationsInclusiveScanAMD(f16vec2);" 1669 "f16vec3 minInvocationsInclusiveScanAMD(f16vec3);" 1670 "f16vec4 minInvocationsInclusiveScanAMD(f16vec4);" 1671 1672 "float minInvocationsExclusiveScanAMD(float);" 1673 "vec2 minInvocationsExclusiveScanAMD(vec2);" 1674 "vec3 minInvocationsExclusiveScanAMD(vec3);" 1675 "vec4 minInvocationsExclusiveScanAMD(vec4);" 1676 1677 "int minInvocationsExclusiveScanAMD(int);" 1678 "ivec2 minInvocationsExclusiveScanAMD(ivec2);" 1679 "ivec3 minInvocationsExclusiveScanAMD(ivec3);" 1680 "ivec4 minInvocationsExclusiveScanAMD(ivec4);" 1681 1682 "uint minInvocationsExclusiveScanAMD(uint);" 1683 "uvec2 minInvocationsExclusiveScanAMD(uvec2);" 1684 "uvec3 minInvocationsExclusiveScanAMD(uvec3);" 1685 "uvec4 minInvocationsExclusiveScanAMD(uvec4);" 1686 1687 "double minInvocationsExclusiveScanAMD(double);" 1688 "dvec2 minInvocationsExclusiveScanAMD(dvec2);" 1689 "dvec3 minInvocationsExclusiveScanAMD(dvec3);" 1690 "dvec4 minInvocationsExclusiveScanAMD(dvec4);" 1691 1692 "int64_t minInvocationsExclusiveScanAMD(int64_t);" 1693 "i64vec2 minInvocationsExclusiveScanAMD(i64vec2);" 1694 "i64vec3 minInvocationsExclusiveScanAMD(i64vec3);" 1695 "i64vec4 minInvocationsExclusiveScanAMD(i64vec4);" 1696 1697 "uint64_t minInvocationsExclusiveScanAMD(uint64_t);" 1698 "u64vec2 minInvocationsExclusiveScanAMD(u64vec2);" 1699 "u64vec3 minInvocationsExclusiveScanAMD(u64vec3);" 1700 "u64vec4 minInvocationsExclusiveScanAMD(u64vec4);" 1701 1702 "float16_t minInvocationsExclusiveScanAMD(float16_t);" 1703 "f16vec2 minInvocationsExclusiveScanAMD(f16vec2);" 1704 "f16vec3 minInvocationsExclusiveScanAMD(f16vec3);" 1705 "f16vec4 minInvocationsExclusiveScanAMD(f16vec4);" 1706 1707 "float maxInvocationsAMD(float);" 1708 "vec2 maxInvocationsAMD(vec2);" 1709 "vec3 maxInvocationsAMD(vec3);" 1710 "vec4 maxInvocationsAMD(vec4);" 1711 1712 "int maxInvocationsAMD(int);" 1713 "ivec2 maxInvocationsAMD(ivec2);" 1714 "ivec3 maxInvocationsAMD(ivec3);" 1715 "ivec4 maxInvocationsAMD(ivec4);" 1716 1717 "uint maxInvocationsAMD(uint);" 1718 "uvec2 maxInvocationsAMD(uvec2);" 1719 "uvec3 maxInvocationsAMD(uvec3);" 1720 "uvec4 maxInvocationsAMD(uvec4);" 1721 1722 "double maxInvocationsAMD(double);" 1723 "dvec2 maxInvocationsAMD(dvec2);" 1724 "dvec3 maxInvocationsAMD(dvec3);" 1725 "dvec4 maxInvocationsAMD(dvec4);" 1726 1727 "int64_t maxInvocationsAMD(int64_t);" 1728 "i64vec2 maxInvocationsAMD(i64vec2);" 1729 "i64vec3 maxInvocationsAMD(i64vec3);" 1730 "i64vec4 maxInvocationsAMD(i64vec4);" 1731 1732 "uint64_t maxInvocationsAMD(uint64_t);" 1733 "u64vec2 maxInvocationsAMD(u64vec2);" 1734 "u64vec3 maxInvocationsAMD(u64vec3);" 1735 "u64vec4 maxInvocationsAMD(u64vec4);" 1736 1737 "float16_t maxInvocationsAMD(float16_t);" 1738 "f16vec2 maxInvocationsAMD(f16vec2);" 1739 "f16vec3 maxInvocationsAMD(f16vec3);" 1740 "f16vec4 maxInvocationsAMD(f16vec4);" 1741 1742 "float maxInvocationsInclusiveScanAMD(float);" 1743 "vec2 maxInvocationsInclusiveScanAMD(vec2);" 1744 "vec3 maxInvocationsInclusiveScanAMD(vec3);" 1745 "vec4 maxInvocationsInclusiveScanAMD(vec4);" 1746 1747 "int maxInvocationsInclusiveScanAMD(int);" 1748 "ivec2 maxInvocationsInclusiveScanAMD(ivec2);" 1749 "ivec3 maxInvocationsInclusiveScanAMD(ivec3);" 1750 "ivec4 maxInvocationsInclusiveScanAMD(ivec4);" 1751 1752 "uint maxInvocationsInclusiveScanAMD(uint);" 1753 "uvec2 maxInvocationsInclusiveScanAMD(uvec2);" 1754 "uvec3 maxInvocationsInclusiveScanAMD(uvec3);" 1755 "uvec4 maxInvocationsInclusiveScanAMD(uvec4);" 1756 1757 "double maxInvocationsInclusiveScanAMD(double);" 1758 "dvec2 maxInvocationsInclusiveScanAMD(dvec2);" 1759 "dvec3 maxInvocationsInclusiveScanAMD(dvec3);" 1760 "dvec4 maxInvocationsInclusiveScanAMD(dvec4);" 1761 1762 "int64_t maxInvocationsInclusiveScanAMD(int64_t);" 1763 "i64vec2 maxInvocationsInclusiveScanAMD(i64vec2);" 1764 "i64vec3 maxInvocationsInclusiveScanAMD(i64vec3);" 1765 "i64vec4 maxInvocationsInclusiveScanAMD(i64vec4);" 1766 1767 "uint64_t maxInvocationsInclusiveScanAMD(uint64_t);" 1768 "u64vec2 maxInvocationsInclusiveScanAMD(u64vec2);" 1769 "u64vec3 maxInvocationsInclusiveScanAMD(u64vec3);" 1770 "u64vec4 maxInvocationsInclusiveScanAMD(u64vec4);" 1771 1772 "float16_t maxInvocationsInclusiveScanAMD(float16_t);" 1773 "f16vec2 maxInvocationsInclusiveScanAMD(f16vec2);" 1774 "f16vec3 maxInvocationsInclusiveScanAMD(f16vec3);" 1775 "f16vec4 maxInvocationsInclusiveScanAMD(f16vec4);" 1776 1777 "float maxInvocationsExclusiveScanAMD(float);" 1778 "vec2 maxInvocationsExclusiveScanAMD(vec2);" 1779 "vec3 maxInvocationsExclusiveScanAMD(vec3);" 1780 "vec4 maxInvocationsExclusiveScanAMD(vec4);" 1781 1782 "int maxInvocationsExclusiveScanAMD(int);" 1783 "ivec2 maxInvocationsExclusiveScanAMD(ivec2);" 1784 "ivec3 maxInvocationsExclusiveScanAMD(ivec3);" 1785 "ivec4 maxInvocationsExclusiveScanAMD(ivec4);" 1786 1787 "uint maxInvocationsExclusiveScanAMD(uint);" 1788 "uvec2 maxInvocationsExclusiveScanAMD(uvec2);" 1789 "uvec3 maxInvocationsExclusiveScanAMD(uvec3);" 1790 "uvec4 maxInvocationsExclusiveScanAMD(uvec4);" 1791 1792 "double maxInvocationsExclusiveScanAMD(double);" 1793 "dvec2 maxInvocationsExclusiveScanAMD(dvec2);" 1794 "dvec3 maxInvocationsExclusiveScanAMD(dvec3);" 1795 "dvec4 maxInvocationsExclusiveScanAMD(dvec4);" 1796 1797 "int64_t maxInvocationsExclusiveScanAMD(int64_t);" 1798 "i64vec2 maxInvocationsExclusiveScanAMD(i64vec2);" 1799 "i64vec3 maxInvocationsExclusiveScanAMD(i64vec3);" 1800 "i64vec4 maxInvocationsExclusiveScanAMD(i64vec4);" 1801 1802 "uint64_t maxInvocationsExclusiveScanAMD(uint64_t);" 1803 "u64vec2 maxInvocationsExclusiveScanAMD(u64vec2);" 1804 "u64vec3 maxInvocationsExclusiveScanAMD(u64vec3);" 1805 "u64vec4 maxInvocationsExclusiveScanAMD(u64vec4);" 1806 1807 "float16_t maxInvocationsExclusiveScanAMD(float16_t);" 1808 "f16vec2 maxInvocationsExclusiveScanAMD(f16vec2);" 1809 "f16vec3 maxInvocationsExclusiveScanAMD(f16vec3);" 1810 "f16vec4 maxInvocationsExclusiveScanAMD(f16vec4);" 1811 1812 "float addInvocationsAMD(float);" 1813 "vec2 addInvocationsAMD(vec2);" 1814 "vec3 addInvocationsAMD(vec3);" 1815 "vec4 addInvocationsAMD(vec4);" 1816 1817 "int addInvocationsAMD(int);" 1818 "ivec2 addInvocationsAMD(ivec2);" 1819 "ivec3 addInvocationsAMD(ivec3);" 1820 "ivec4 addInvocationsAMD(ivec4);" 1821 1822 "uint addInvocationsAMD(uint);" 1823 "uvec2 addInvocationsAMD(uvec2);" 1824 "uvec3 addInvocationsAMD(uvec3);" 1825 "uvec4 addInvocationsAMD(uvec4);" 1826 1827 "double addInvocationsAMD(double);" 1828 "dvec2 addInvocationsAMD(dvec2);" 1829 "dvec3 addInvocationsAMD(dvec3);" 1830 "dvec4 addInvocationsAMD(dvec4);" 1831 1832 "int64_t addInvocationsAMD(int64_t);" 1833 "i64vec2 addInvocationsAMD(i64vec2);" 1834 "i64vec3 addInvocationsAMD(i64vec3);" 1835 "i64vec4 addInvocationsAMD(i64vec4);" 1836 1837 "uint64_t addInvocationsAMD(uint64_t);" 1838 "u64vec2 addInvocationsAMD(u64vec2);" 1839 "u64vec3 addInvocationsAMD(u64vec3);" 1840 "u64vec4 addInvocationsAMD(u64vec4);" 1841 1842 "float16_t addInvocationsAMD(float16_t);" 1843 "f16vec2 addInvocationsAMD(f16vec2);" 1844 "f16vec3 addInvocationsAMD(f16vec3);" 1845 "f16vec4 addInvocationsAMD(f16vec4);" 1846 1847 "float addInvocationsInclusiveScanAMD(float);" 1848 "vec2 addInvocationsInclusiveScanAMD(vec2);" 1849 "vec3 addInvocationsInclusiveScanAMD(vec3);" 1850 "vec4 addInvocationsInclusiveScanAMD(vec4);" 1851 1852 "int addInvocationsInclusiveScanAMD(int);" 1853 "ivec2 addInvocationsInclusiveScanAMD(ivec2);" 1854 "ivec3 addInvocationsInclusiveScanAMD(ivec3);" 1855 "ivec4 addInvocationsInclusiveScanAMD(ivec4);" 1856 1857 "uint addInvocationsInclusiveScanAMD(uint);" 1858 "uvec2 addInvocationsInclusiveScanAMD(uvec2);" 1859 "uvec3 addInvocationsInclusiveScanAMD(uvec3);" 1860 "uvec4 addInvocationsInclusiveScanAMD(uvec4);" 1861 1862 "double addInvocationsInclusiveScanAMD(double);" 1863 "dvec2 addInvocationsInclusiveScanAMD(dvec2);" 1864 "dvec3 addInvocationsInclusiveScanAMD(dvec3);" 1865 "dvec4 addInvocationsInclusiveScanAMD(dvec4);" 1866 1867 "int64_t addInvocationsInclusiveScanAMD(int64_t);" 1868 "i64vec2 addInvocationsInclusiveScanAMD(i64vec2);" 1869 "i64vec3 addInvocationsInclusiveScanAMD(i64vec3);" 1870 "i64vec4 addInvocationsInclusiveScanAMD(i64vec4);" 1871 1872 "uint64_t addInvocationsInclusiveScanAMD(uint64_t);" 1873 "u64vec2 addInvocationsInclusiveScanAMD(u64vec2);" 1874 "u64vec3 addInvocationsInclusiveScanAMD(u64vec3);" 1875 "u64vec4 addInvocationsInclusiveScanAMD(u64vec4);" 1876 1877 "float16_t addInvocationsInclusiveScanAMD(float16_t);" 1878 "f16vec2 addInvocationsInclusiveScanAMD(f16vec2);" 1879 "f16vec3 addInvocationsInclusiveScanAMD(f16vec3);" 1880 "f16vec4 addInvocationsInclusiveScanAMD(f16vec4);" 1881 1882 "float addInvocationsExclusiveScanAMD(float);" 1883 "vec2 addInvocationsExclusiveScanAMD(vec2);" 1884 "vec3 addInvocationsExclusiveScanAMD(vec3);" 1885 "vec4 addInvocationsExclusiveScanAMD(vec4);" 1886 1887 "int addInvocationsExclusiveScanAMD(int);" 1888 "ivec2 addInvocationsExclusiveScanAMD(ivec2);" 1889 "ivec3 addInvocationsExclusiveScanAMD(ivec3);" 1890 "ivec4 addInvocationsExclusiveScanAMD(ivec4);" 1891 1892 "uint addInvocationsExclusiveScanAMD(uint);" 1893 "uvec2 addInvocationsExclusiveScanAMD(uvec2);" 1894 "uvec3 addInvocationsExclusiveScanAMD(uvec3);" 1895 "uvec4 addInvocationsExclusiveScanAMD(uvec4);" 1896 1897 "double addInvocationsExclusiveScanAMD(double);" 1898 "dvec2 addInvocationsExclusiveScanAMD(dvec2);" 1899 "dvec3 addInvocationsExclusiveScanAMD(dvec3);" 1900 "dvec4 addInvocationsExclusiveScanAMD(dvec4);" 1901 1902 "int64_t addInvocationsExclusiveScanAMD(int64_t);" 1903 "i64vec2 addInvocationsExclusiveScanAMD(i64vec2);" 1904 "i64vec3 addInvocationsExclusiveScanAMD(i64vec3);" 1905 "i64vec4 addInvocationsExclusiveScanAMD(i64vec4);" 1906 1907 "uint64_t addInvocationsExclusiveScanAMD(uint64_t);" 1908 "u64vec2 addInvocationsExclusiveScanAMD(u64vec2);" 1909 "u64vec3 addInvocationsExclusiveScanAMD(u64vec3);" 1910 "u64vec4 addInvocationsExclusiveScanAMD(u64vec4);" 1911 1912 "float16_t addInvocationsExclusiveScanAMD(float16_t);" 1913 "f16vec2 addInvocationsExclusiveScanAMD(f16vec2);" 1914 "f16vec3 addInvocationsExclusiveScanAMD(f16vec3);" 1915 "f16vec4 addInvocationsExclusiveScanAMD(f16vec4);" 1916 1917 "float minInvocationsNonUniformAMD(float);" 1918 "vec2 minInvocationsNonUniformAMD(vec2);" 1919 "vec3 minInvocationsNonUniformAMD(vec3);" 1920 "vec4 minInvocationsNonUniformAMD(vec4);" 1921 1922 "int minInvocationsNonUniformAMD(int);" 1923 "ivec2 minInvocationsNonUniformAMD(ivec2);" 1924 "ivec3 minInvocationsNonUniformAMD(ivec3);" 1925 "ivec4 minInvocationsNonUniformAMD(ivec4);" 1926 1927 "uint minInvocationsNonUniformAMD(uint);" 1928 "uvec2 minInvocationsNonUniformAMD(uvec2);" 1929 "uvec3 minInvocationsNonUniformAMD(uvec3);" 1930 "uvec4 minInvocationsNonUniformAMD(uvec4);" 1931 1932 "double minInvocationsNonUniformAMD(double);" 1933 "dvec2 minInvocationsNonUniformAMD(dvec2);" 1934 "dvec3 minInvocationsNonUniformAMD(dvec3);" 1935 "dvec4 minInvocationsNonUniformAMD(dvec4);" 1936 1937 "int64_t minInvocationsNonUniformAMD(int64_t);" 1938 "i64vec2 minInvocationsNonUniformAMD(i64vec2);" 1939 "i64vec3 minInvocationsNonUniformAMD(i64vec3);" 1940 "i64vec4 minInvocationsNonUniformAMD(i64vec4);" 1941 1942 "uint64_t minInvocationsNonUniformAMD(uint64_t);" 1943 "u64vec2 minInvocationsNonUniformAMD(u64vec2);" 1944 "u64vec3 minInvocationsNonUniformAMD(u64vec3);" 1945 "u64vec4 minInvocationsNonUniformAMD(u64vec4);" 1946 1947 "float16_t minInvocationsNonUniformAMD(float16_t);" 1948 "f16vec2 minInvocationsNonUniformAMD(f16vec2);" 1949 "f16vec3 minInvocationsNonUniformAMD(f16vec3);" 1950 "f16vec4 minInvocationsNonUniformAMD(f16vec4);" 1951 1952 "float minInvocationsInclusiveScanNonUniformAMD(float);" 1953 "vec2 minInvocationsInclusiveScanNonUniformAMD(vec2);" 1954 "vec3 minInvocationsInclusiveScanNonUniformAMD(vec3);" 1955 "vec4 minInvocationsInclusiveScanNonUniformAMD(vec4);" 1956 1957 "int minInvocationsInclusiveScanNonUniformAMD(int);" 1958 "ivec2 minInvocationsInclusiveScanNonUniformAMD(ivec2);" 1959 "ivec3 minInvocationsInclusiveScanNonUniformAMD(ivec3);" 1960 "ivec4 minInvocationsInclusiveScanNonUniformAMD(ivec4);" 1961 1962 "uint minInvocationsInclusiveScanNonUniformAMD(uint);" 1963 "uvec2 minInvocationsInclusiveScanNonUniformAMD(uvec2);" 1964 "uvec3 minInvocationsInclusiveScanNonUniformAMD(uvec3);" 1965 "uvec4 minInvocationsInclusiveScanNonUniformAMD(uvec4);" 1966 1967 "double minInvocationsInclusiveScanNonUniformAMD(double);" 1968 "dvec2 minInvocationsInclusiveScanNonUniformAMD(dvec2);" 1969 "dvec3 minInvocationsInclusiveScanNonUniformAMD(dvec3);" 1970 "dvec4 minInvocationsInclusiveScanNonUniformAMD(dvec4);" 1971 1972 "int64_t minInvocationsInclusiveScanNonUniformAMD(int64_t);" 1973 "i64vec2 minInvocationsInclusiveScanNonUniformAMD(i64vec2);" 1974 "i64vec3 minInvocationsInclusiveScanNonUniformAMD(i64vec3);" 1975 "i64vec4 minInvocationsInclusiveScanNonUniformAMD(i64vec4);" 1976 1977 "uint64_t minInvocationsInclusiveScanNonUniformAMD(uint64_t);" 1978 "u64vec2 minInvocationsInclusiveScanNonUniformAMD(u64vec2);" 1979 "u64vec3 minInvocationsInclusiveScanNonUniformAMD(u64vec3);" 1980 "u64vec4 minInvocationsInclusiveScanNonUniformAMD(u64vec4);" 1981 1982 "float16_t minInvocationsInclusiveScanNonUniformAMD(float16_t);" 1983 "f16vec2 minInvocationsInclusiveScanNonUniformAMD(f16vec2);" 1984 "f16vec3 minInvocationsInclusiveScanNonUniformAMD(f16vec3);" 1985 "f16vec4 minInvocationsInclusiveScanNonUniformAMD(f16vec4);" 1986 1987 "float minInvocationsExclusiveScanNonUniformAMD(float);" 1988 "vec2 minInvocationsExclusiveScanNonUniformAMD(vec2);" 1989 "vec3 minInvocationsExclusiveScanNonUniformAMD(vec3);" 1990 "vec4 minInvocationsExclusiveScanNonUniformAMD(vec4);" 1991 1992 "int minInvocationsExclusiveScanNonUniformAMD(int);" 1993 "ivec2 minInvocationsExclusiveScanNonUniformAMD(ivec2);" 1994 "ivec3 minInvocationsExclusiveScanNonUniformAMD(ivec3);" 1995 "ivec4 minInvocationsExclusiveScanNonUniformAMD(ivec4);" 1996 1997 "uint minInvocationsExclusiveScanNonUniformAMD(uint);" 1998 "uvec2 minInvocationsExclusiveScanNonUniformAMD(uvec2);" 1999 "uvec3 minInvocationsExclusiveScanNonUniformAMD(uvec3);" 2000 "uvec4 minInvocationsExclusiveScanNonUniformAMD(uvec4);" 2001 2002 "double minInvocationsExclusiveScanNonUniformAMD(double);" 2003 "dvec2 minInvocationsExclusiveScanNonUniformAMD(dvec2);" 2004 "dvec3 minInvocationsExclusiveScanNonUniformAMD(dvec3);" 2005 "dvec4 minInvocationsExclusiveScanNonUniformAMD(dvec4);" 2006 2007 "int64_t minInvocationsExclusiveScanNonUniformAMD(int64_t);" 2008 "i64vec2 minInvocationsExclusiveScanNonUniformAMD(i64vec2);" 2009 "i64vec3 minInvocationsExclusiveScanNonUniformAMD(i64vec3);" 2010 "i64vec4 minInvocationsExclusiveScanNonUniformAMD(i64vec4);" 2011 2012 "uint64_t minInvocationsExclusiveScanNonUniformAMD(uint64_t);" 2013 "u64vec2 minInvocationsExclusiveScanNonUniformAMD(u64vec2);" 2014 "u64vec3 minInvocationsExclusiveScanNonUniformAMD(u64vec3);" 2015 "u64vec4 minInvocationsExclusiveScanNonUniformAMD(u64vec4);" 2016 2017 "float16_t minInvocationsExclusiveScanNonUniformAMD(float16_t);" 2018 "f16vec2 minInvocationsExclusiveScanNonUniformAMD(f16vec2);" 2019 "f16vec3 minInvocationsExclusiveScanNonUniformAMD(f16vec3);" 2020 "f16vec4 minInvocationsExclusiveScanNonUniformAMD(f16vec4);" 2021 2022 "float maxInvocationsNonUniformAMD(float);" 2023 "vec2 maxInvocationsNonUniformAMD(vec2);" 2024 "vec3 maxInvocationsNonUniformAMD(vec3);" 2025 "vec4 maxInvocationsNonUniformAMD(vec4);" 2026 2027 "int maxInvocationsNonUniformAMD(int);" 2028 "ivec2 maxInvocationsNonUniformAMD(ivec2);" 2029 "ivec3 maxInvocationsNonUniformAMD(ivec3);" 2030 "ivec4 maxInvocationsNonUniformAMD(ivec4);" 2031 2032 "uint maxInvocationsNonUniformAMD(uint);" 2033 "uvec2 maxInvocationsNonUniformAMD(uvec2);" 2034 "uvec3 maxInvocationsNonUniformAMD(uvec3);" 2035 "uvec4 maxInvocationsNonUniformAMD(uvec4);" 2036 2037 "double maxInvocationsNonUniformAMD(double);" 2038 "dvec2 maxInvocationsNonUniformAMD(dvec2);" 2039 "dvec3 maxInvocationsNonUniformAMD(dvec3);" 2040 "dvec4 maxInvocationsNonUniformAMD(dvec4);" 2041 2042 "int64_t maxInvocationsNonUniformAMD(int64_t);" 2043 "i64vec2 maxInvocationsNonUniformAMD(i64vec2);" 2044 "i64vec3 maxInvocationsNonUniformAMD(i64vec3);" 2045 "i64vec4 maxInvocationsNonUniformAMD(i64vec4);" 2046 2047 "uint64_t maxInvocationsNonUniformAMD(uint64_t);" 2048 "u64vec2 maxInvocationsNonUniformAMD(u64vec2);" 2049 "u64vec3 maxInvocationsNonUniformAMD(u64vec3);" 2050 "u64vec4 maxInvocationsNonUniformAMD(u64vec4);" 2051 2052 "float16_t maxInvocationsNonUniformAMD(float16_t);" 2053 "f16vec2 maxInvocationsNonUniformAMD(f16vec2);" 2054 "f16vec3 maxInvocationsNonUniformAMD(f16vec3);" 2055 "f16vec4 maxInvocationsNonUniformAMD(f16vec4);" 2056 2057 "float maxInvocationsInclusiveScanNonUniformAMD(float);" 2058 "vec2 maxInvocationsInclusiveScanNonUniformAMD(vec2);" 2059 "vec3 maxInvocationsInclusiveScanNonUniformAMD(vec3);" 2060 "vec4 maxInvocationsInclusiveScanNonUniformAMD(vec4);" 2061 2062 "int maxInvocationsInclusiveScanNonUniformAMD(int);" 2063 "ivec2 maxInvocationsInclusiveScanNonUniformAMD(ivec2);" 2064 "ivec3 maxInvocationsInclusiveScanNonUniformAMD(ivec3);" 2065 "ivec4 maxInvocationsInclusiveScanNonUniformAMD(ivec4);" 2066 2067 "uint maxInvocationsInclusiveScanNonUniformAMD(uint);" 2068 "uvec2 maxInvocationsInclusiveScanNonUniformAMD(uvec2);" 2069 "uvec3 maxInvocationsInclusiveScanNonUniformAMD(uvec3);" 2070 "uvec4 maxInvocationsInclusiveScanNonUniformAMD(uvec4);" 2071 2072 "double maxInvocationsInclusiveScanNonUniformAMD(double);" 2073 "dvec2 maxInvocationsInclusiveScanNonUniformAMD(dvec2);" 2074 "dvec3 maxInvocationsInclusiveScanNonUniformAMD(dvec3);" 2075 "dvec4 maxInvocationsInclusiveScanNonUniformAMD(dvec4);" 2076 2077 "int64_t maxInvocationsInclusiveScanNonUniformAMD(int64_t);" 2078 "i64vec2 maxInvocationsInclusiveScanNonUniformAMD(i64vec2);" 2079 "i64vec3 maxInvocationsInclusiveScanNonUniformAMD(i64vec3);" 2080 "i64vec4 maxInvocationsInclusiveScanNonUniformAMD(i64vec4);" 2081 2082 "uint64_t maxInvocationsInclusiveScanNonUniformAMD(uint64_t);" 2083 "u64vec2 maxInvocationsInclusiveScanNonUniformAMD(u64vec2);" 2084 "u64vec3 maxInvocationsInclusiveScanNonUniformAMD(u64vec3);" 2085 "u64vec4 maxInvocationsInclusiveScanNonUniformAMD(u64vec4);" 2086 2087 "float16_t maxInvocationsInclusiveScanNonUniformAMD(float16_t);" 2088 "f16vec2 maxInvocationsInclusiveScanNonUniformAMD(f16vec2);" 2089 "f16vec3 maxInvocationsInclusiveScanNonUniformAMD(f16vec3);" 2090 "f16vec4 maxInvocationsInclusiveScanNonUniformAMD(f16vec4);" 2091 2092 "float maxInvocationsExclusiveScanNonUniformAMD(float);" 2093 "vec2 maxInvocationsExclusiveScanNonUniformAMD(vec2);" 2094 "vec3 maxInvocationsExclusiveScanNonUniformAMD(vec3);" 2095 "vec4 maxInvocationsExclusiveScanNonUniformAMD(vec4);" 2096 2097 "int maxInvocationsExclusiveScanNonUniformAMD(int);" 2098 "ivec2 maxInvocationsExclusiveScanNonUniformAMD(ivec2);" 2099 "ivec3 maxInvocationsExclusiveScanNonUniformAMD(ivec3);" 2100 "ivec4 maxInvocationsExclusiveScanNonUniformAMD(ivec4);" 2101 2102 "uint maxInvocationsExclusiveScanNonUniformAMD(uint);" 2103 "uvec2 maxInvocationsExclusiveScanNonUniformAMD(uvec2);" 2104 "uvec3 maxInvocationsExclusiveScanNonUniformAMD(uvec3);" 2105 "uvec4 maxInvocationsExclusiveScanNonUniformAMD(uvec4);" 2106 2107 "double maxInvocationsExclusiveScanNonUniformAMD(double);" 2108 "dvec2 maxInvocationsExclusiveScanNonUniformAMD(dvec2);" 2109 "dvec3 maxInvocationsExclusiveScanNonUniformAMD(dvec3);" 2110 "dvec4 maxInvocationsExclusiveScanNonUniformAMD(dvec4);" 2111 2112 "int64_t maxInvocationsExclusiveScanNonUniformAMD(int64_t);" 2113 "i64vec2 maxInvocationsExclusiveScanNonUniformAMD(i64vec2);" 2114 "i64vec3 maxInvocationsExclusiveScanNonUniformAMD(i64vec3);" 2115 "i64vec4 maxInvocationsExclusiveScanNonUniformAMD(i64vec4);" 2116 2117 "uint64_t maxInvocationsExclusiveScanNonUniformAMD(uint64_t);" 2118 "u64vec2 maxInvocationsExclusiveScanNonUniformAMD(u64vec2);" 2119 "u64vec3 maxInvocationsExclusiveScanNonUniformAMD(u64vec3);" 2120 "u64vec4 maxInvocationsExclusiveScanNonUniformAMD(u64vec4);" 2121 2122 "float16_t maxInvocationsExclusiveScanNonUniformAMD(float16_t);" 2123 "f16vec2 maxInvocationsExclusiveScanNonUniformAMD(f16vec2);" 2124 "f16vec3 maxInvocationsExclusiveScanNonUniformAMD(f16vec3);" 2125 "f16vec4 maxInvocationsExclusiveScanNonUniformAMD(f16vec4);" 2126 2127 "float addInvocationsNonUniformAMD(float);" 2128 "vec2 addInvocationsNonUniformAMD(vec2);" 2129 "vec3 addInvocationsNonUniformAMD(vec3);" 2130 "vec4 addInvocationsNonUniformAMD(vec4);" 2131 2132 "int addInvocationsNonUniformAMD(int);" 2133 "ivec2 addInvocationsNonUniformAMD(ivec2);" 2134 "ivec3 addInvocationsNonUniformAMD(ivec3);" 2135 "ivec4 addInvocationsNonUniformAMD(ivec4);" 2136 2137 "uint addInvocationsNonUniformAMD(uint);" 2138 "uvec2 addInvocationsNonUniformAMD(uvec2);" 2139 "uvec3 addInvocationsNonUniformAMD(uvec3);" 2140 "uvec4 addInvocationsNonUniformAMD(uvec4);" 2141 2142 "double addInvocationsNonUniformAMD(double);" 2143 "dvec2 addInvocationsNonUniformAMD(dvec2);" 2144 "dvec3 addInvocationsNonUniformAMD(dvec3);" 2145 "dvec4 addInvocationsNonUniformAMD(dvec4);" 2146 2147 "int64_t addInvocationsNonUniformAMD(int64_t);" 2148 "i64vec2 addInvocationsNonUniformAMD(i64vec2);" 2149 "i64vec3 addInvocationsNonUniformAMD(i64vec3);" 2150 "i64vec4 addInvocationsNonUniformAMD(i64vec4);" 2151 2152 "uint64_t addInvocationsNonUniformAMD(uint64_t);" 2153 "u64vec2 addInvocationsNonUniformAMD(u64vec2);" 2154 "u64vec3 addInvocationsNonUniformAMD(u64vec3);" 2155 "u64vec4 addInvocationsNonUniformAMD(u64vec4);" 2156 2157 "float16_t addInvocationsNonUniformAMD(float16_t);" 2158 "f16vec2 addInvocationsNonUniformAMD(f16vec2);" 2159 "f16vec3 addInvocationsNonUniformAMD(f16vec3);" 2160 "f16vec4 addInvocationsNonUniformAMD(f16vec4);" 2161 2162 "float addInvocationsInclusiveScanNonUniformAMD(float);" 2163 "vec2 addInvocationsInclusiveScanNonUniformAMD(vec2);" 2164 "vec3 addInvocationsInclusiveScanNonUniformAMD(vec3);" 2165 "vec4 addInvocationsInclusiveScanNonUniformAMD(vec4);" 2166 2167 "int addInvocationsInclusiveScanNonUniformAMD(int);" 2168 "ivec2 addInvocationsInclusiveScanNonUniformAMD(ivec2);" 2169 "ivec3 addInvocationsInclusiveScanNonUniformAMD(ivec3);" 2170 "ivec4 addInvocationsInclusiveScanNonUniformAMD(ivec4);" 2171 2172 "uint addInvocationsInclusiveScanNonUniformAMD(uint);" 2173 "uvec2 addInvocationsInclusiveScanNonUniformAMD(uvec2);" 2174 "uvec3 addInvocationsInclusiveScanNonUniformAMD(uvec3);" 2175 "uvec4 addInvocationsInclusiveScanNonUniformAMD(uvec4);" 2176 2177 "double addInvocationsInclusiveScanNonUniformAMD(double);" 2178 "dvec2 addInvocationsInclusiveScanNonUniformAMD(dvec2);" 2179 "dvec3 addInvocationsInclusiveScanNonUniformAMD(dvec3);" 2180 "dvec4 addInvocationsInclusiveScanNonUniformAMD(dvec4);" 2181 2182 "int64_t addInvocationsInclusiveScanNonUniformAMD(int64_t);" 2183 "i64vec2 addInvocationsInclusiveScanNonUniformAMD(i64vec2);" 2184 "i64vec3 addInvocationsInclusiveScanNonUniformAMD(i64vec3);" 2185 "i64vec4 addInvocationsInclusiveScanNonUniformAMD(i64vec4);" 2186 2187 "uint64_t addInvocationsInclusiveScanNonUniformAMD(uint64_t);" 2188 "u64vec2 addInvocationsInclusiveScanNonUniformAMD(u64vec2);" 2189 "u64vec3 addInvocationsInclusiveScanNonUniformAMD(u64vec3);" 2190 "u64vec4 addInvocationsInclusiveScanNonUniformAMD(u64vec4);" 2191 2192 "float16_t addInvocationsInclusiveScanNonUniformAMD(float16_t);" 2193 "f16vec2 addInvocationsInclusiveScanNonUniformAMD(f16vec2);" 2194 "f16vec3 addInvocationsInclusiveScanNonUniformAMD(f16vec3);" 2195 "f16vec4 addInvocationsInclusiveScanNonUniformAMD(f16vec4);" 2196 2197 "float addInvocationsExclusiveScanNonUniformAMD(float);" 2198 "vec2 addInvocationsExclusiveScanNonUniformAMD(vec2);" 2199 "vec3 addInvocationsExclusiveScanNonUniformAMD(vec3);" 2200 "vec4 addInvocationsExclusiveScanNonUniformAMD(vec4);" 2201 2202 "int addInvocationsExclusiveScanNonUniformAMD(int);" 2203 "ivec2 addInvocationsExclusiveScanNonUniformAMD(ivec2);" 2204 "ivec3 addInvocationsExclusiveScanNonUniformAMD(ivec3);" 2205 "ivec4 addInvocationsExclusiveScanNonUniformAMD(ivec4);" 2206 2207 "uint addInvocationsExclusiveScanNonUniformAMD(uint);" 2208 "uvec2 addInvocationsExclusiveScanNonUniformAMD(uvec2);" 2209 "uvec3 addInvocationsExclusiveScanNonUniformAMD(uvec3);" 2210 "uvec4 addInvocationsExclusiveScanNonUniformAMD(uvec4);" 2211 2212 "double addInvocationsExclusiveScanNonUniformAMD(double);" 2213 "dvec2 addInvocationsExclusiveScanNonUniformAMD(dvec2);" 2214 "dvec3 addInvocationsExclusiveScanNonUniformAMD(dvec3);" 2215 "dvec4 addInvocationsExclusiveScanNonUniformAMD(dvec4);" 2216 2217 "int64_t addInvocationsExclusiveScanNonUniformAMD(int64_t);" 2218 "i64vec2 addInvocationsExclusiveScanNonUniformAMD(i64vec2);" 2219 "i64vec3 addInvocationsExclusiveScanNonUniformAMD(i64vec3);" 2220 "i64vec4 addInvocationsExclusiveScanNonUniformAMD(i64vec4);" 2221 2222 "uint64_t addInvocationsExclusiveScanNonUniformAMD(uint64_t);" 2223 "u64vec2 addInvocationsExclusiveScanNonUniformAMD(u64vec2);" 2224 "u64vec3 addInvocationsExclusiveScanNonUniformAMD(u64vec3);" 2225 "u64vec4 addInvocationsExclusiveScanNonUniformAMD(u64vec4);" 2226 2227 "float16_t addInvocationsExclusiveScanNonUniformAMD(float16_t);" 2228 "f16vec2 addInvocationsExclusiveScanNonUniformAMD(f16vec2);" 2229 "f16vec3 addInvocationsExclusiveScanNonUniformAMD(f16vec3);" 2230 "f16vec4 addInvocationsExclusiveScanNonUniformAMD(f16vec4);" 2231 2232 "float swizzleInvocationsAMD(float, uvec4);" 2233 "vec2 swizzleInvocationsAMD(vec2, uvec4);" 2234 "vec3 swizzleInvocationsAMD(vec3, uvec4);" 2235 "vec4 swizzleInvocationsAMD(vec4, uvec4);" 2236 2237 "int swizzleInvocationsAMD(int, uvec4);" 2238 "ivec2 swizzleInvocationsAMD(ivec2, uvec4);" 2239 "ivec3 swizzleInvocationsAMD(ivec3, uvec4);" 2240 "ivec4 swizzleInvocationsAMD(ivec4, uvec4);" 2241 2242 "uint swizzleInvocationsAMD(uint, uvec4);" 2243 "uvec2 swizzleInvocationsAMD(uvec2, uvec4);" 2244 "uvec3 swizzleInvocationsAMD(uvec3, uvec4);" 2245 "uvec4 swizzleInvocationsAMD(uvec4, uvec4);" 2246 2247 "float swizzleInvocationsMaskedAMD(float, uvec3);" 2248 "vec2 swizzleInvocationsMaskedAMD(vec2, uvec3);" 2249 "vec3 swizzleInvocationsMaskedAMD(vec3, uvec3);" 2250 "vec4 swizzleInvocationsMaskedAMD(vec4, uvec3);" 2251 2252 "int swizzleInvocationsMaskedAMD(int, uvec3);" 2253 "ivec2 swizzleInvocationsMaskedAMD(ivec2, uvec3);" 2254 "ivec3 swizzleInvocationsMaskedAMD(ivec3, uvec3);" 2255 "ivec4 swizzleInvocationsMaskedAMD(ivec4, uvec3);" 2256 2257 "uint swizzleInvocationsMaskedAMD(uint, uvec3);" 2258 "uvec2 swizzleInvocationsMaskedAMD(uvec2, uvec3);" 2259 "uvec3 swizzleInvocationsMaskedAMD(uvec3, uvec3);" 2260 "uvec4 swizzleInvocationsMaskedAMD(uvec4, uvec3);" 2261 2262 "float writeInvocationAMD(float, float, uint);" 2263 "vec2 writeInvocationAMD(vec2, vec2, uint);" 2264 "vec3 writeInvocationAMD(vec3, vec3, uint);" 2265 "vec4 writeInvocationAMD(vec4, vec4, uint);" 2266 2267 "int writeInvocationAMD(int, int, uint);" 2268 "ivec2 writeInvocationAMD(ivec2, ivec2, uint);" 2269 "ivec3 writeInvocationAMD(ivec3, ivec3, uint);" 2270 "ivec4 writeInvocationAMD(ivec4, ivec4, uint);" 2271 2272 "uint writeInvocationAMD(uint, uint, uint);" 2273 "uvec2 writeInvocationAMD(uvec2, uvec2, uint);" 2274 "uvec3 writeInvocationAMD(uvec3, uvec3, uint);" 2275 "uvec4 writeInvocationAMD(uvec4, uvec4, uint);" 2276 2277 "uint mbcntAMD(uint64_t);" 2278 2279 "\n"); 2280 } 2281 2282 // GL_AMD_gcn_shader 2283 if (profile != EEsProfile && version >= 450) { 2284 commonBuiltins.append( 2285 "float cubeFaceIndexAMD(vec3);" 2286 "vec2 cubeFaceCoordAMD(vec3);" 2287 "uint64_t timeAMD();" 2288 2289 "\n"); 2290 } 2291 2292 // GL_AMD_gpu_shader_half_float 2293 if (profile != EEsProfile && version >= 450) { 2294 commonBuiltins.append( 2295 "float16_t radians(float16_t);" 2296 "f16vec2 radians(f16vec2);" 2297 "f16vec3 radians(f16vec3);" 2298 "f16vec4 radians(f16vec4);" 2299 2300 "float16_t degrees(float16_t);" 2301 "f16vec2 degrees(f16vec2);" 2302 "f16vec3 degrees(f16vec3);" 2303 "f16vec4 degrees(f16vec4);" 2304 2305 "float16_t sin(float16_t);" 2306 "f16vec2 sin(f16vec2);" 2307 "f16vec3 sin(f16vec3);" 2308 "f16vec4 sin(f16vec4);" 2309 2310 "float16_t cos(float16_t);" 2311 "f16vec2 cos(f16vec2);" 2312 "f16vec3 cos(f16vec3);" 2313 "f16vec4 cos(f16vec4);" 2314 2315 "float16_t tan(float16_t);" 2316 "f16vec2 tan(f16vec2);" 2317 "f16vec3 tan(f16vec3);" 2318 "f16vec4 tan(f16vec4);" 2319 2320 "float16_t asin(float16_t);" 2321 "f16vec2 asin(f16vec2);" 2322 "f16vec3 asin(f16vec3);" 2323 "f16vec4 asin(f16vec4);" 2324 2325 "float16_t acos(float16_t);" 2326 "f16vec2 acos(f16vec2);" 2327 "f16vec3 acos(f16vec3);" 2328 "f16vec4 acos(f16vec4);" 2329 2330 "float16_t atan(float16_t, float16_t);" 2331 "f16vec2 atan(f16vec2, f16vec2);" 2332 "f16vec3 atan(f16vec3, f16vec3);" 2333 "f16vec4 atan(f16vec4, f16vec4);" 2334 2335 "float16_t atan(float16_t);" 2336 "f16vec2 atan(f16vec2);" 2337 "f16vec3 atan(f16vec3);" 2338 "f16vec4 atan(f16vec4);" 2339 2340 "float16_t sinh(float16_t);" 2341 "f16vec2 sinh(f16vec2);" 2342 "f16vec3 sinh(f16vec3);" 2343 "f16vec4 sinh(f16vec4);" 2344 2345 "float16_t cosh(float16_t);" 2346 "f16vec2 cosh(f16vec2);" 2347 "f16vec3 cosh(f16vec3);" 2348 "f16vec4 cosh(f16vec4);" 2349 2350 "float16_t tanh(float16_t);" 2351 "f16vec2 tanh(f16vec2);" 2352 "f16vec3 tanh(f16vec3);" 2353 "f16vec4 tanh(f16vec4);" 2354 2355 "float16_t asinh(float16_t);" 2356 "f16vec2 asinh(f16vec2);" 2357 "f16vec3 asinh(f16vec3);" 2358 "f16vec4 asinh(f16vec4);" 2359 2360 "float16_t acosh(float16_t);" 2361 "f16vec2 acosh(f16vec2);" 2362 "f16vec3 acosh(f16vec3);" 2363 "f16vec4 acosh(f16vec4);" 2364 2365 "float16_t atanh(float16_t);" 2366 "f16vec2 atanh(f16vec2);" 2367 "f16vec3 atanh(f16vec3);" 2368 "f16vec4 atanh(f16vec4);" 2369 2370 "float16_t pow(float16_t, float16_t);" 2371 "f16vec2 pow(f16vec2, f16vec2);" 2372 "f16vec3 pow(f16vec3, f16vec3);" 2373 "f16vec4 pow(f16vec4, f16vec4);" 2374 2375 "float16_t exp(float16_t);" 2376 "f16vec2 exp(f16vec2);" 2377 "f16vec3 exp(f16vec3);" 2378 "f16vec4 exp(f16vec4);" 2379 2380 "float16_t log(float16_t);" 2381 "f16vec2 log(f16vec2);" 2382 "f16vec3 log(f16vec3);" 2383 "f16vec4 log(f16vec4);" 2384 2385 "float16_t exp2(float16_t);" 2386 "f16vec2 exp2(f16vec2);" 2387 "f16vec3 exp2(f16vec3);" 2388 "f16vec4 exp2(f16vec4);" 2389 2390 "float16_t log2(float16_t);" 2391 "f16vec2 log2(f16vec2);" 2392 "f16vec3 log2(f16vec3);" 2393 "f16vec4 log2(f16vec4);" 2394 2395 "float16_t sqrt(float16_t);" 2396 "f16vec2 sqrt(f16vec2);" 2397 "f16vec3 sqrt(f16vec3);" 2398 "f16vec4 sqrt(f16vec4);" 2399 2400 "float16_t inversesqrt(float16_t);" 2401 "f16vec2 inversesqrt(f16vec2);" 2402 "f16vec3 inversesqrt(f16vec3);" 2403 "f16vec4 inversesqrt(f16vec4);" 2404 2405 "float16_t abs(float16_t);" 2406 "f16vec2 abs(f16vec2);" 2407 "f16vec3 abs(f16vec3);" 2408 "f16vec4 abs(f16vec4);" 2409 2410 "float16_t sign(float16_t);" 2411 "f16vec2 sign(f16vec2);" 2412 "f16vec3 sign(f16vec3);" 2413 "f16vec4 sign(f16vec4);" 2414 2415 "float16_t floor(float16_t);" 2416 "f16vec2 floor(f16vec2);" 2417 "f16vec3 floor(f16vec3);" 2418 "f16vec4 floor(f16vec4);" 2419 2420 "float16_t trunc(float16_t);" 2421 "f16vec2 trunc(f16vec2);" 2422 "f16vec3 trunc(f16vec3);" 2423 "f16vec4 trunc(f16vec4);" 2424 2425 "float16_t round(float16_t);" 2426 "f16vec2 round(f16vec2);" 2427 "f16vec3 round(f16vec3);" 2428 "f16vec4 round(f16vec4);" 2429 2430 "float16_t roundEven(float16_t);" 2431 "f16vec2 roundEven(f16vec2);" 2432 "f16vec3 roundEven(f16vec3);" 2433 "f16vec4 roundEven(f16vec4);" 2434 2435 "float16_t ceil(float16_t);" 2436 "f16vec2 ceil(f16vec2);" 2437 "f16vec3 ceil(f16vec3);" 2438 "f16vec4 ceil(f16vec4);" 2439 2440 "float16_t fract(float16_t);" 2441 "f16vec2 fract(f16vec2);" 2442 "f16vec3 fract(f16vec3);" 2443 "f16vec4 fract(f16vec4);" 2444 2445 "float16_t mod(float16_t, float16_t);" 2446 "f16vec2 mod(f16vec2, float16_t);" 2447 "f16vec3 mod(f16vec3, float16_t);" 2448 "f16vec4 mod(f16vec4, float16_t);" 2449 "f16vec2 mod(f16vec2, f16vec2);" 2450 "f16vec3 mod(f16vec3, f16vec3);" 2451 "f16vec4 mod(f16vec4, f16vec4);" 2452 2453 "float16_t modf(float16_t, out float16_t);" 2454 "f16vec2 modf(f16vec2, out f16vec2);" 2455 "f16vec3 modf(f16vec3, out f16vec3);" 2456 "f16vec4 modf(f16vec4, out f16vec4);" 2457 2458 "float16_t min(float16_t, float16_t);" 2459 "f16vec2 min(f16vec2, float16_t);" 2460 "f16vec3 min(f16vec3, float16_t);" 2461 "f16vec4 min(f16vec4, float16_t);" 2462 "f16vec2 min(f16vec2, f16vec2);" 2463 "f16vec3 min(f16vec3, f16vec3);" 2464 "f16vec4 min(f16vec4, f16vec4);" 2465 2466 "float16_t max(float16_t, float16_t);" 2467 "f16vec2 max(f16vec2, float16_t);" 2468 "f16vec3 max(f16vec3, float16_t);" 2469 "f16vec4 max(f16vec4, float16_t);" 2470 "f16vec2 max(f16vec2, f16vec2);" 2471 "f16vec3 max(f16vec3, f16vec3);" 2472 "f16vec4 max(f16vec4, f16vec4);" 2473 2474 "float16_t clamp(float16_t, float16_t, float16_t);" 2475 "f16vec2 clamp(f16vec2, float16_t, float16_t);" 2476 "f16vec3 clamp(f16vec3, float16_t, float16_t);" 2477 "f16vec4 clamp(f16vec4, float16_t, float16_t);" 2478 "f16vec2 clamp(f16vec2, f16vec2, f16vec2);" 2479 "f16vec3 clamp(f16vec3, f16vec3, f16vec3);" 2480 "f16vec4 clamp(f16vec4, f16vec4, f16vec4);" 2481 2482 "float16_t mix(float16_t, float16_t, float16_t);" 2483 "f16vec2 mix(f16vec2, f16vec2, float16_t);" 2484 "f16vec3 mix(f16vec3, f16vec3, float16_t);" 2485 "f16vec4 mix(f16vec4, f16vec4, float16_t);" 2486 "f16vec2 mix(f16vec2, f16vec2, f16vec2);" 2487 "f16vec3 mix(f16vec3, f16vec3, f16vec3);" 2488 "f16vec4 mix(f16vec4, f16vec4, f16vec4);" 2489 "float16_t mix(float16_t, float16_t, bool);" 2490 "f16vec2 mix(f16vec2, f16vec2, bvec2);" 2491 "f16vec3 mix(f16vec3, f16vec3, bvec3);" 2492 "f16vec4 mix(f16vec4, f16vec4, bvec4);" 2493 2494 "float16_t step(float16_t, float16_t);" 2495 "f16vec2 step(f16vec2, f16vec2);" 2496 "f16vec3 step(f16vec3, f16vec3);" 2497 "f16vec4 step(f16vec4, f16vec4);" 2498 "f16vec2 step(float16_t, f16vec2);" 2499 "f16vec3 step(float16_t, f16vec3);" 2500 "f16vec4 step(float16_t, f16vec4);" 2501 2502 "float16_t smoothstep(float16_t, float16_t, float16_t);" 2503 "f16vec2 smoothstep(f16vec2, f16vec2, f16vec2);" 2504 "f16vec3 smoothstep(f16vec3, f16vec3, f16vec3);" 2505 "f16vec4 smoothstep(f16vec4, f16vec4, f16vec4);" 2506 "f16vec2 smoothstep(float16_t, float16_t, f16vec2);" 2507 "f16vec3 smoothstep(float16_t, float16_t, f16vec3);" 2508 "f16vec4 smoothstep(float16_t, float16_t, f16vec4);" 2509 2510 "bool isnan(float16_t);" 2511 "bvec2 isnan(f16vec2);" 2512 "bvec3 isnan(f16vec3);" 2513 "bvec4 isnan(f16vec4);" 2514 2515 "bool isinf(float16_t);" 2516 "bvec2 isinf(f16vec2);" 2517 "bvec3 isinf(f16vec3);" 2518 "bvec4 isinf(f16vec4);" 2519 2520 "float16_t fma(float16_t, float16_t, float16_t);" 2521 "f16vec2 fma(f16vec2, f16vec2, f16vec2);" 2522 "f16vec3 fma(f16vec3, f16vec3, f16vec3);" 2523 "f16vec4 fma(f16vec4, f16vec4, f16vec4);" 2524 2525 "float16_t frexp(float16_t, out int);" 2526 "f16vec2 frexp(f16vec2, out ivec2);" 2527 "f16vec3 frexp(f16vec3, out ivec3);" 2528 "f16vec4 frexp(f16vec4, out ivec4);" 2529 2530 "float16_t ldexp(float16_t, in int);" 2531 "f16vec2 ldexp(f16vec2, in ivec2);" 2532 "f16vec3 ldexp(f16vec3, in ivec3);" 2533 "f16vec4 ldexp(f16vec4, in ivec4);" 2534 2535 "uint packFloat2x16(f16vec2);" 2536 "f16vec2 unpackFloat2x16(uint);" 2537 2538 "float16_t length(float16_t);" 2539 "float16_t length(f16vec2);" 2540 "float16_t length(f16vec3);" 2541 "float16_t length(f16vec4);" 2542 2543 "float16_t distance(float16_t, float16_t);" 2544 "float16_t distance(f16vec2, f16vec2);" 2545 "float16_t distance(f16vec3, f16vec3);" 2546 "float16_t distance(f16vec4, f16vec4);" 2547 2548 "float16_t dot(float16_t, float16_t);" 2549 "float16_t dot(f16vec2, f16vec2);" 2550 "float16_t dot(f16vec3, f16vec3);" 2551 "float16_t dot(f16vec4, f16vec4);" 2552 2553 "f16vec3 cross(f16vec3, f16vec3);" 2554 2555 "float16_t normalize(float16_t);" 2556 "f16vec2 normalize(f16vec2);" 2557 "f16vec3 normalize(f16vec3);" 2558 "f16vec4 normalize(f16vec4);" 2559 2560 "float16_t faceforward(float16_t, float16_t, float16_t);" 2561 "f16vec2 faceforward(f16vec2, f16vec2, f16vec2);" 2562 "f16vec3 faceforward(f16vec3, f16vec3, f16vec3);" 2563 "f16vec4 faceforward(f16vec4, f16vec4, f16vec4);" 2564 2565 "float16_t reflect(float16_t, float16_t);" 2566 "f16vec2 reflect(f16vec2, f16vec2);" 2567 "f16vec3 reflect(f16vec3, f16vec3);" 2568 "f16vec4 reflect(f16vec4, f16vec4);" 2569 2570 "float16_t refract(float16_t, float16_t, float16_t);" 2571 "f16vec2 refract(f16vec2, f16vec2, float16_t);" 2572 "f16vec3 refract(f16vec3, f16vec3, float16_t);" 2573 "f16vec4 refract(f16vec4, f16vec4, float16_t);" 2574 2575 "f16mat2 matrixCompMult(f16mat2, f16mat2);" 2576 "f16mat3 matrixCompMult(f16mat3, f16mat3);" 2577 "f16mat4 matrixCompMult(f16mat4, f16mat4);" 2578 "f16mat2x3 matrixCompMult(f16mat2x3, f16mat2x3);" 2579 "f16mat2x4 matrixCompMult(f16mat2x4, f16mat2x4);" 2580 "f16mat3x2 matrixCompMult(f16mat3x2, f16mat3x2);" 2581 "f16mat3x4 matrixCompMult(f16mat3x4, f16mat3x4);" 2582 "f16mat4x2 matrixCompMult(f16mat4x2, f16mat4x2);" 2583 "f16mat4x3 matrixCompMult(f16mat4x3, f16mat4x3);" 2584 2585 "f16mat2 outerProduct(f16vec2, f16vec2);" 2586 "f16mat3 outerProduct(f16vec3, f16vec3);" 2587 "f16mat4 outerProduct(f16vec4, f16vec4);" 2588 "f16mat2x3 outerProduct(f16vec3, f16vec2);" 2589 "f16mat3x2 outerProduct(f16vec2, f16vec3);" 2590 "f16mat2x4 outerProduct(f16vec4, f16vec2);" 2591 "f16mat4x2 outerProduct(f16vec2, f16vec4);" 2592 "f16mat3x4 outerProduct(f16vec4, f16vec3);" 2593 "f16mat4x3 outerProduct(f16vec3, f16vec4);" 2594 2595 "f16mat2 transpose(f16mat2);" 2596 "f16mat3 transpose(f16mat3);" 2597 "f16mat4 transpose(f16mat4);" 2598 "f16mat2x3 transpose(f16mat3x2);" 2599 "f16mat3x2 transpose(f16mat2x3);" 2600 "f16mat2x4 transpose(f16mat4x2);" 2601 "f16mat4x2 transpose(f16mat2x4);" 2602 "f16mat3x4 transpose(f16mat4x3);" 2603 "f16mat4x3 transpose(f16mat3x4);" 2604 2605 "float16_t determinant(f16mat2);" 2606 "float16_t determinant(f16mat3);" 2607 "float16_t determinant(f16mat4);" 2608 2609 "f16mat2 inverse(f16mat2);" 2610 "f16mat3 inverse(f16mat3);" 2611 "f16mat4 inverse(f16mat4);" 2612 2613 "bvec2 lessThan(f16vec2, f16vec2);" 2614 "bvec3 lessThan(f16vec3, f16vec3);" 2615 "bvec4 lessThan(f16vec4, f16vec4);" 2616 2617 "bvec2 lessThanEqual(f16vec2, f16vec2);" 2618 "bvec3 lessThanEqual(f16vec3, f16vec3);" 2619 "bvec4 lessThanEqual(f16vec4, f16vec4);" 2620 2621 "bvec2 greaterThan(f16vec2, f16vec2);" 2622 "bvec3 greaterThan(f16vec3, f16vec3);" 2623 "bvec4 greaterThan(f16vec4, f16vec4);" 2624 2625 "bvec2 greaterThanEqual(f16vec2, f16vec2);" 2626 "bvec3 greaterThanEqual(f16vec3, f16vec3);" 2627 "bvec4 greaterThanEqual(f16vec4, f16vec4);" 2628 2629 "bvec2 equal(f16vec2, f16vec2);" 2630 "bvec3 equal(f16vec3, f16vec3);" 2631 "bvec4 equal(f16vec4, f16vec4);" 2632 2633 "bvec2 notEqual(f16vec2, f16vec2);" 2634 "bvec3 notEqual(f16vec3, f16vec3);" 2635 "bvec4 notEqual(f16vec4, f16vec4);" 2636 2637 "\n"); 2638 } 2639 2640 // GL_AMD_gpu_shader_int16 2641 if (profile != EEsProfile && version >= 450) { 2642 commonBuiltins.append( 2643 "int16_t abs(int16_t);" 2644 "i16vec2 abs(i16vec2);" 2645 "i16vec3 abs(i16vec3);" 2646 "i16vec4 abs(i16vec4);" 2647 2648 "int16_t sign(int16_t);" 2649 "i16vec2 sign(i16vec2);" 2650 "i16vec3 sign(i16vec3);" 2651 "i16vec4 sign(i16vec4);" 2652 2653 "int16_t min(int16_t, int16_t);" 2654 "i16vec2 min(i16vec2, int16_t);" 2655 "i16vec3 min(i16vec3, int16_t);" 2656 "i16vec4 min(i16vec4, int16_t);" 2657 "i16vec2 min(i16vec2, i16vec2);" 2658 "i16vec3 min(i16vec3, i16vec3);" 2659 "i16vec4 min(i16vec4, i16vec4);" 2660 "uint16_t min(uint16_t, uint16_t);" 2661 "u16vec2 min(u16vec2, uint16_t);" 2662 "u16vec3 min(u16vec3, uint16_t);" 2663 "u16vec4 min(u16vec4, uint16_t);" 2664 "u16vec2 min(u16vec2, u16vec2);" 2665 "u16vec3 min(u16vec3, u16vec3);" 2666 "u16vec4 min(u16vec4, u16vec4);" 2667 2668 "int16_t max(int16_t, int16_t);" 2669 "i16vec2 max(i16vec2, int16_t);" 2670 "i16vec3 max(i16vec3, int16_t);" 2671 "i16vec4 max(i16vec4, int16_t);" 2672 "i16vec2 max(i16vec2, i16vec2);" 2673 "i16vec3 max(i16vec3, i16vec3);" 2674 "i16vec4 max(i16vec4, i16vec4);" 2675 "uint16_t max(uint16_t, uint16_t);" 2676 "u16vec2 max(u16vec2, uint16_t);" 2677 "u16vec3 max(u16vec3, uint16_t);" 2678 "u16vec4 max(u16vec4, uint16_t);" 2679 "u16vec2 max(u16vec2, u16vec2);" 2680 "u16vec3 max(u16vec3, u16vec3);" 2681 "u16vec4 max(u16vec4, u16vec4);" 2682 2683 "int16_t clamp(int16_t, int16_t, int16_t);" 2684 "i16vec2 clamp(i16vec2, int16_t, int16_t);" 2685 "i16vec3 clamp(i16vec3, int16_t, int16_t);" 2686 "i16vec4 clamp(i16vec4, int16_t, int16_t);" 2687 "i16vec2 clamp(i16vec2, i16vec2, i16vec2);" 2688 "i16vec3 clamp(i16vec3, i16vec3, i16vec3);" 2689 "i16vec4 clamp(i16vec4, i16vec4, i16vec4);" 2690 "uint16_t clamp(uint16_t, uint16_t, uint16_t);" 2691 "u16vec2 clamp(u16vec2, uint16_t, uint16_t);" 2692 "u16vec3 clamp(u16vec3, uint16_t, uint16_t);" 2693 "u16vec4 clamp(u16vec4, uint16_t, uint16_t);" 2694 "u16vec2 clamp(u16vec2, u16vec2, u16vec2);" 2695 "u16vec3 clamp(u16vec3, u16vec3, u16vec3);" 2696 "u16vec4 clamp(u16vec4, u16vec4, u16vec4);" 2697 2698 "int16_t mix(int16_t, int16_t, bool);" 2699 "i16vec2 mix(i16vec2, i16vec2, bvec2);" 2700 "i16vec3 mix(i16vec3, i16vec3, bvec3);" 2701 "i16vec4 mix(i16vec4, i16vec4, bvec4);" 2702 "uint16_t mix(uint16_t, uint16_t, bool);" 2703 "u16vec2 mix(u16vec2, u16vec2, bvec2);" 2704 "u16vec3 mix(u16vec3, u16vec3, bvec3);" 2705 "u16vec4 mix(u16vec4, u16vec4, bvec4);" 2706 2707 "float16_t frexp(float16_t, out int16_t);" 2708 "f16vec2 frexp(f16vec2, out i16vec2);" 2709 "f16vec3 frexp(f16vec3, out i16vec3);" 2710 "f16vec4 frexp(f16vec4, out i16vec4);" 2711 2712 "float16_t ldexp(float16_t, int16_t);" 2713 "f16vec2 ldexp(f16vec2, i16vec2);" 2714 "f16vec3 ldexp(f16vec3, i16vec3);" 2715 "f16vec4 ldexp(f16vec4, i16vec4);" 2716 2717 "int16_t float16BitsToInt16(float16_t);" 2718 "i16vec2 float16BitsToInt16(f16vec2);" 2719 "i16vec3 float16BitsToInt16(f16vec3);" 2720 "i16vec4 float16BitsToInt16(f16vec4);" 2721 2722 "uint16_t float16BitsToUint16(float16_t);" 2723 "u16vec2 float16BitsToUint16(f16vec2);" 2724 "u16vec3 float16BitsToUint16(f16vec3);" 2725 "u16vec4 float16BitsToUint16(f16vec4);" 2726 2727 "float16_t int16BitsToFloat16(int16_t);" 2728 "f16vec2 int16BitsToFloat16(i16vec2);" 2729 "f16vec3 int16BitsToFloat16(i16vec3);" 2730 "f16vec4 int16BitsToFloat16(i16vec4);" 2731 2732 "float16_t uint16BitsToFloat16(uint16_t);" 2733 "f16vec2 uint16BitsToFloat16(u16vec2);" 2734 "f16vec3 uint16BitsToFloat16(u16vec3);" 2735 "f16vec4 uint16BitsToFloat16(u16vec4);" 2736 2737 "int packInt2x16(i16vec2);" 2738 "uint packUint2x16(u16vec2);" 2739 "int64_t packInt4x16(i16vec4);" 2740 "uint64_t packUint4x16(u16vec4);" 2741 "i16vec2 unpackInt2x16(int);" 2742 "u16vec2 unpackUint2x16(uint);" 2743 "i16vec4 unpackInt4x16(int64_t);" 2744 "u16vec4 unpackUint4x16(uint64_t);" 2745 2746 "bvec2 lessThan(i16vec2, i16vec2);" 2747 "bvec3 lessThan(i16vec3, i16vec3);" 2748 "bvec4 lessThan(i16vec4, i16vec4);" 2749 "bvec2 lessThan(u16vec2, u16vec2);" 2750 "bvec3 lessThan(u16vec3, u16vec3);" 2751 "bvec4 lessThan(u16vec4, u16vec4);" 2752 2753 "bvec2 lessThanEqual(i16vec2, i16vec2);" 2754 "bvec3 lessThanEqual(i16vec3, i16vec3);" 2755 "bvec4 lessThanEqual(i16vec4, i16vec4);" 2756 "bvec2 lessThanEqual(u16vec2, u16vec2);" 2757 "bvec3 lessThanEqual(u16vec3, u16vec3);" 2758 "bvec4 lessThanEqual(u16vec4, u16vec4);" 2759 2760 "bvec2 greaterThan(i16vec2, i16vec2);" 2761 "bvec3 greaterThan(i16vec3, i16vec3);" 2762 "bvec4 greaterThan(i16vec4, i16vec4);" 2763 "bvec2 greaterThan(u16vec2, u16vec2);" 2764 "bvec3 greaterThan(u16vec3, u16vec3);" 2765 "bvec4 greaterThan(u16vec4, u16vec4);" 2766 2767 "bvec2 greaterThanEqual(i16vec2, i16vec2);" 2768 "bvec3 greaterThanEqual(i16vec3, i16vec3);" 2769 "bvec4 greaterThanEqual(i16vec4, i16vec4);" 2770 "bvec2 greaterThanEqual(u16vec2, u16vec2);" 2771 "bvec3 greaterThanEqual(u16vec3, u16vec3);" 2772 "bvec4 greaterThanEqual(u16vec4, u16vec4);" 2773 2774 "bvec2 equal(i16vec2, i16vec2);" 2775 "bvec3 equal(i16vec3, i16vec3);" 2776 "bvec4 equal(i16vec4, i16vec4);" 2777 "bvec2 equal(u16vec2, u16vec2);" 2778 "bvec3 equal(u16vec3, u16vec3);" 2779 "bvec4 equal(u16vec4, u16vec4);" 2780 2781 "bvec2 notEqual(i16vec2, i16vec2);" 2782 "bvec3 notEqual(i16vec3, i16vec3);" 2783 "bvec4 notEqual(i16vec4, i16vec4);" 2784 "bvec2 notEqual(u16vec2, u16vec2);" 2785 "bvec3 notEqual(u16vec3, u16vec3);" 2786 "bvec4 notEqual(u16vec4, u16vec4);" 2787 2788 "\n"); 2789 } 2790 #endif 2791 2792 //============================================================================ 2793 // 2794 // Prototypes for built-in functions seen by vertex shaders only. 2795 // (Except legacy lod functions, where it depends which release they are 2796 // vertex only.) 2797 // 2798 //============================================================================ 2799 2800 // 2801 // Geometric Functions. 2802 // 2803 if (IncludeLegacy(version, profile, spvVersion)) 2804 stageBuiltins[EShLangVertex].append("vec4 ftransform();"); 2805 2806 // 2807 // Original-style texture Functions with lod. 2808 // 2809 TString* s; 2810 if (version == 100) 2811 s = &stageBuiltins[EShLangVertex]; 2812 else 2813 s = &commonBuiltins; 2814 if ((profile == EEsProfile && version == 100) || 2815 profile == ECompatibilityProfile || 2816 (profile == ECoreProfile && version < 420) || 2817 profile == ENoProfile) { 2818 if (spvVersion.spv == 0) { 2819 s->append( 2820 "vec4 texture2DLod(sampler2D, vec2, float);" // GL_ARB_shader_texture_lod 2821 "vec4 texture2DProjLod(sampler2D, vec3, float);" // GL_ARB_shader_texture_lod 2822 "vec4 texture2DProjLod(sampler2D, vec4, float);" // GL_ARB_shader_texture_lod 2823 "vec4 texture3DLod(sampler3D, vec3, float);" // GL_ARB_shader_texture_lod // OES_texture_3D, but caught by keyword check 2824 "vec4 texture3DProjLod(sampler3D, vec4, float);" // GL_ARB_shader_texture_lod // OES_texture_3D, but caught by keyword check 2825 "vec4 textureCubeLod(samplerCube, vec3, float);" // GL_ARB_shader_texture_lod 2826 2827 "\n"); 2828 } 2829 } 2830 if ( profile == ECompatibilityProfile || 2831 (profile == ECoreProfile && version < 420) || 2832 profile == ENoProfile) { 2833 if (spvVersion.spv == 0) { 2834 s->append( 2835 "vec4 texture1DLod(sampler1D, float, float);" // GL_ARB_shader_texture_lod 2836 "vec4 texture1DProjLod(sampler1D, vec2, float);" // GL_ARB_shader_texture_lod 2837 "vec4 texture1DProjLod(sampler1D, vec4, float);" // GL_ARB_shader_texture_lod 2838 "vec4 shadow1DLod(sampler1DShadow, vec3, float);" // GL_ARB_shader_texture_lod 2839 "vec4 shadow2DLod(sampler2DShadow, vec3, float);" // GL_ARB_shader_texture_lod 2840 "vec4 shadow1DProjLod(sampler1DShadow, vec4, float);" // GL_ARB_shader_texture_lod 2841 "vec4 shadow2DProjLod(sampler2DShadow, vec4, float);" // GL_ARB_shader_texture_lod 2842 2843 "vec4 texture1DGradARB(sampler1D, float, float, float);" // GL_ARB_shader_texture_lod 2844 "vec4 texture1DProjGradARB(sampler1D, vec2, float, float);" // GL_ARB_shader_texture_lod 2845 "vec4 texture1DProjGradARB(sampler1D, vec4, float, float);" // GL_ARB_shader_texture_lod 2846 "vec4 texture2DGradARB(sampler2D, vec2, vec2, vec2);" // GL_ARB_shader_texture_lod 2847 "vec4 texture2DProjGradARB(sampler2D, vec3, vec2, vec2);" // GL_ARB_shader_texture_lod 2848 "vec4 texture2DProjGradARB(sampler2D, vec4, vec2, vec2);" // GL_ARB_shader_texture_lod 2849 "vec4 texture3DGradARB(sampler3D, vec3, vec3, vec3);" // GL_ARB_shader_texture_lod 2850 "vec4 texture3DProjGradARB(sampler3D, vec4, vec3, vec3);" // GL_ARB_shader_texture_lod 2851 "vec4 textureCubeGradARB(samplerCube, vec3, vec3, vec3);" // GL_ARB_shader_texture_lod 2852 "vec4 shadow1DGradARB(sampler1DShadow, vec3, float, float);" // GL_ARB_shader_texture_lod 2853 "vec4 shadow1DProjGradARB( sampler1DShadow, vec4, float, float);" // GL_ARB_shader_texture_lod 2854 "vec4 shadow2DGradARB(sampler2DShadow, vec3, vec2, vec2);" // GL_ARB_shader_texture_lod 2855 "vec4 shadow2DProjGradARB( sampler2DShadow, vec4, vec2, vec2);" // GL_ARB_shader_texture_lod 2856 "vec4 texture2DRectGradARB(sampler2DRect, vec2, vec2, vec2);" // GL_ARB_shader_texture_lod 2857 "vec4 texture2DRectProjGradARB( sampler2DRect, vec3, vec2, vec2);" // GL_ARB_shader_texture_lod 2858 "vec4 texture2DRectProjGradARB( sampler2DRect, vec4, vec2, vec2);" // GL_ARB_shader_texture_lod 2859 "vec4 shadow2DRectGradARB( sampler2DRectShadow, vec3, vec2, vec2);" // GL_ARB_shader_texture_lod 2860 "vec4 shadow2DRectProjGradARB(sampler2DRectShadow, vec4, vec2, vec2);" // GL_ARB_shader_texture_lod 2861 2862 "\n"); 2863 } 2864 } 2865 2866 if ((profile != EEsProfile && version >= 150) || 2867 (profile == EEsProfile && version >= 310)) { 2868 //============================================================================ 2869 // 2870 // Prototypes for built-in functions seen by geometry shaders only. 2871 // 2872 //============================================================================ 2873 2874 if (profile != EEsProfile && version >= 400) { 2875 stageBuiltins[EShLangGeometry].append( 2876 "void EmitStreamVertex(int);" 2877 "void EndStreamPrimitive(int);" 2878 ); 2879 } 2880 stageBuiltins[EShLangGeometry].append( 2881 "void EmitVertex();" 2882 "void EndPrimitive();" 2883 "\n"); 2884 } 2885 2886 //============================================================================ 2887 // 2888 // Prototypes for all control functions. 2889 // 2890 //============================================================================ 2891 bool esBarrier = (profile == EEsProfile && version >= 310); 2892 if ((profile != EEsProfile && version >= 150) || esBarrier) 2893 stageBuiltins[EShLangTessControl].append( 2894 "void barrier();" 2895 ); 2896 if ((profile != EEsProfile && version >= 420) || esBarrier) 2897 stageBuiltins[EShLangCompute].append( 2898 "void barrier();" 2899 ); 2900 if ((profile != EEsProfile && version >= 130) || esBarrier) 2901 commonBuiltins.append( 2902 "void memoryBarrier();" 2903 ); 2904 if ((profile != EEsProfile && version >= 420) || esBarrier) { 2905 commonBuiltins.append( 2906 "void memoryBarrierAtomicCounter();" 2907 "void memoryBarrierBuffer();" 2908 "void memoryBarrierImage();" 2909 ); 2910 stageBuiltins[EShLangCompute].append( 2911 "void memoryBarrierShared();" 2912 "void groupMemoryBarrier();" 2913 ); 2914 } 2915 2916 //============================================================================ 2917 // 2918 // Prototypes for built-in functions seen by fragment shaders only. 2919 // 2920 //============================================================================ 2921 2922 // 2923 // Original-style texture Functions with bias. 2924 // 2925 if (spvVersion.spv == 0 && (profile != EEsProfile || version == 100)) { 2926 stageBuiltins[EShLangFragment].append( 2927 "vec4 texture2D(sampler2D, vec2, float);" 2928 "vec4 texture2DProj(sampler2D, vec3, float);" 2929 "vec4 texture2DProj(sampler2D, vec4, float);" 2930 "vec4 texture3D(sampler3D, vec3, float);" // OES_texture_3D 2931 "vec4 texture3DProj(sampler3D, vec4, float);" // OES_texture_3D 2932 "vec4 textureCube(samplerCube, vec3, float);" 2933 2934 "\n"); 2935 } 2936 if (spvVersion.spv == 0 && (profile != EEsProfile && version > 100)) { 2937 stageBuiltins[EShLangFragment].append( 2938 "vec4 texture1D(sampler1D, float, float);" 2939 "vec4 texture1DProj(sampler1D, vec2, float);" 2940 "vec4 texture1DProj(sampler1D, vec4, float);" 2941 "vec4 shadow1D(sampler1DShadow, vec3, float);" 2942 "vec4 shadow2D(sampler2DShadow, vec3, float);" 2943 "vec4 shadow1DProj(sampler1DShadow, vec4, float);" 2944 "vec4 shadow2DProj(sampler2DShadow, vec4, float);" 2945 2946 "\n"); 2947 } 2948 if (spvVersion.spv == 0 && profile == EEsProfile) { 2949 stageBuiltins[EShLangFragment].append( 2950 "vec4 texture2DLodEXT(sampler2D, vec2, float);" // GL_EXT_shader_texture_lod 2951 "vec4 texture2DProjLodEXT(sampler2D, vec3, float);" // GL_EXT_shader_texture_lod 2952 "vec4 texture2DProjLodEXT(sampler2D, vec4, float);" // GL_EXT_shader_texture_lod 2953 "vec4 textureCubeLodEXT(samplerCube, vec3, float);" // GL_EXT_shader_texture_lod 2954 2955 "\n"); 2956 } 2957 2958 stageBuiltins[EShLangFragment].append( 2959 "float dFdx(float p);" 2960 "vec2 dFdx(vec2 p);" 2961 "vec3 dFdx(vec3 p);" 2962 "vec4 dFdx(vec4 p);" 2963 2964 "float dFdy(float p);" 2965 "vec2 dFdy(vec2 p);" 2966 "vec3 dFdy(vec3 p);" 2967 "vec4 dFdy(vec4 p);" 2968 2969 "float fwidth(float p);" 2970 "vec2 fwidth(vec2 p);" 2971 "vec3 fwidth(vec3 p);" 2972 "vec4 fwidth(vec4 p);" 2973 2974 "\n"); 2975 2976 // GL_ARB_derivative_control 2977 if (profile != EEsProfile && version >= 400) { 2978 stageBuiltins[EShLangFragment].append( 2979 "float dFdxFine(float p);" 2980 "vec2 dFdxFine(vec2 p);" 2981 "vec3 dFdxFine(vec3 p);" 2982 "vec4 dFdxFine(vec4 p);" 2983 2984 "float dFdyFine(float p);" 2985 "vec2 dFdyFine(vec2 p);" 2986 "vec3 dFdyFine(vec3 p);" 2987 "vec4 dFdyFine(vec4 p);" 2988 2989 "float fwidthFine(float p);" 2990 "vec2 fwidthFine(vec2 p);" 2991 "vec3 fwidthFine(vec3 p);" 2992 "vec4 fwidthFine(vec4 p);" 2993 2994 "\n"); 2995 2996 stageBuiltins[EShLangFragment].append( 2997 "float dFdxCoarse(float p);" 2998 "vec2 dFdxCoarse(vec2 p);" 2999 "vec3 dFdxCoarse(vec3 p);" 3000 "vec4 dFdxCoarse(vec4 p);" 3001 3002 "float dFdyCoarse(float p);" 3003 "vec2 dFdyCoarse(vec2 p);" 3004 "vec3 dFdyCoarse(vec3 p);" 3005 "vec4 dFdyCoarse(vec4 p);" 3006 3007 "float fwidthCoarse(float p);" 3008 "vec2 fwidthCoarse(vec2 p);" 3009 "vec3 fwidthCoarse(vec3 p);" 3010 "vec4 fwidthCoarse(vec4 p);" 3011 3012 "\n"); 3013 } 3014 3015 // GL_OES_shader_multisample_interpolation 3016 if ((profile == EEsProfile && version >= 310) || 3017 (profile != EEsProfile && version >= 400)) { 3018 stageBuiltins[EShLangFragment].append( 3019 "float interpolateAtCentroid(float);" 3020 "vec2 interpolateAtCentroid(vec2);" 3021 "vec3 interpolateAtCentroid(vec3);" 3022 "vec4 interpolateAtCentroid(vec4);" 3023 3024 "float interpolateAtSample(float, int);" 3025 "vec2 interpolateAtSample(vec2, int);" 3026 "vec3 interpolateAtSample(vec3, int);" 3027 "vec4 interpolateAtSample(vec4, int);" 3028 3029 "float interpolateAtOffset(float, vec2);" 3030 "vec2 interpolateAtOffset(vec2, vec2);" 3031 "vec3 interpolateAtOffset(vec3, vec2);" 3032 "vec4 interpolateAtOffset(vec4, vec2);" 3033 3034 "\n"); 3035 } 3036 3037 #ifdef AMD_EXTENSIONS 3038 // GL_AMD_shader_explicit_vertex_parameter 3039 if (profile != EEsProfile && version >= 450) { 3040 stageBuiltins[EShLangFragment].append( 3041 "float interpolateAtVertexAMD(float, uint);" 3042 "vec2 interpolateAtVertexAMD(vec2, uint);" 3043 "vec3 interpolateAtVertexAMD(vec3, uint);" 3044 "vec4 interpolateAtVertexAMD(vec4, uint);" 3045 3046 "int interpolateAtVertexAMD(int, uint);" 3047 "ivec2 interpolateAtVertexAMD(ivec2, uint);" 3048 "ivec3 interpolateAtVertexAMD(ivec3, uint);" 3049 "ivec4 interpolateAtVertexAMD(ivec4, uint);" 3050 3051 "uint interpolateAtVertexAMD(uint, uint);" 3052 "uvec2 interpolateAtVertexAMD(uvec2, uint);" 3053 "uvec3 interpolateAtVertexAMD(uvec3, uint);" 3054 "uvec4 interpolateAtVertexAMD(uvec4, uint);" 3055 3056 "float16_t interpolateAtVertexAMD(float16_t, uint);" 3057 "f16vec2 interpolateAtVertexAMD(f16vec2, uint);" 3058 "f16vec3 interpolateAtVertexAMD(f16vec3, uint);" 3059 "f16vec4 interpolateAtVertexAMD(f16vec4, uint);" 3060 3061 "\n"); 3062 } 3063 3064 // GL_AMD_gpu_shader_half_float 3065 if (profile != EEsProfile && version >= 450) { 3066 stageBuiltins[EShLangFragment].append( 3067 "float16_t dFdx(float16_t);" 3068 "f16vec2 dFdx(f16vec2);" 3069 "f16vec3 dFdx(f16vec3);" 3070 "f16vec4 dFdx(f16vec4);" 3071 3072 "float16_t dFdy(float16_t);" 3073 "f16vec2 dFdy(f16vec2);" 3074 "f16vec3 dFdy(f16vec3);" 3075 "f16vec4 dFdy(f16vec4);" 3076 3077 "float16_t dFdxFine(float16_t);" 3078 "f16vec2 dFdxFine(f16vec2);" 3079 "f16vec3 dFdxFine(f16vec3);" 3080 "f16vec4 dFdxFine(f16vec4);" 3081 3082 "float16_t dFdyFine(float16_t);" 3083 "f16vec2 dFdyFine(f16vec2);" 3084 "f16vec3 dFdyFine(f16vec3);" 3085 "f16vec4 dFdyFine(f16vec4);" 3086 3087 "float16_t dFdxCoarse(float16_t);" 3088 "f16vec2 dFdxCoarse(f16vec2);" 3089 "f16vec3 dFdxCoarse(f16vec3);" 3090 "f16vec4 dFdxCoarse(f16vec4);" 3091 3092 "float16_t dFdyCoarse(float16_t);" 3093 "f16vec2 dFdyCoarse(f16vec2);" 3094 "f16vec3 dFdyCoarse(f16vec3);" 3095 "f16vec4 dFdyCoarse(f16vec4);" 3096 3097 "float16_t fwidth(float16_t);" 3098 "f16vec2 fwidth(f16vec2);" 3099 "f16vec3 fwidth(f16vec3);" 3100 "f16vec4 fwidth(f16vec4);" 3101 3102 "float16_t fwidthFine(float16_t);" 3103 "f16vec2 fwidthFine(f16vec2);" 3104 "f16vec3 fwidthFine(f16vec3);" 3105 "f16vec4 fwidthFine(f16vec4);" 3106 3107 "float16_t fwidthCoarse(float16_t);" 3108 "f16vec2 fwidthCoarse(f16vec2);" 3109 "f16vec3 fwidthCoarse(f16vec3);" 3110 "f16vec4 fwidthCoarse(f16vec4);" 3111 3112 "float16_t interpolateAtCentroid(float16_t);" 3113 "f16vec2 interpolateAtCentroid(f16vec2);" 3114 "f16vec3 interpolateAtCentroid(f16vec3);" 3115 "f16vec4 interpolateAtCentroid(f16vec4);" 3116 3117 "float16_t interpolateAtSample(float16_t, int);" 3118 "f16vec2 interpolateAtSample(f16vec2, int);" 3119 "f16vec3 interpolateAtSample(f16vec3, int);" 3120 "f16vec4 interpolateAtSample(f16vec4, int);" 3121 3122 "float16_t interpolateAtOffset(float16_t, f16vec2);" 3123 "f16vec2 interpolateAtOffset(f16vec2, f16vec2);" 3124 "f16vec3 interpolateAtOffset(f16vec3, f16vec2);" 3125 "f16vec4 interpolateAtOffset(f16vec4, f16vec2);" 3126 3127 "\n"); 3128 } 3129 #endif 3130 3131 //============================================================================ 3132 // 3133 // Standard Uniforms 3134 // 3135 //============================================================================ 3136 3137 // 3138 // Depth range in window coordinates, p. 33 3139 // 3140 if (spvVersion.spv == 0) { 3141 commonBuiltins.append( 3142 "struct gl_DepthRangeParameters {" 3143 ); 3144 if (profile == EEsProfile) { 3145 commonBuiltins.append( 3146 "highp float near;" // n 3147 "highp float far;" // f 3148 "highp float diff;" // f - n 3149 ); 3150 } else { 3151 commonBuiltins.append( 3152 "float near;" // n 3153 "float far;" // f 3154 "float diff;" // f - n 3155 ); 3156 } 3157 3158 commonBuiltins.append( 3159 "};" 3160 "uniform gl_DepthRangeParameters gl_DepthRange;" 3161 "\n"); 3162 } 3163 3164 if (spvVersion.spv == 0 && IncludeLegacy(version, profile, spvVersion)) { 3165 // 3166 // Matrix state. p. 31, 32, 37, 39, 40. 3167 // 3168 commonBuiltins.append( 3169 "uniform mat4 gl_ModelViewMatrix;" 3170 "uniform mat4 gl_ProjectionMatrix;" 3171 "uniform mat4 gl_ModelViewProjectionMatrix;" 3172 3173 // 3174 // Derived matrix state that provides inverse and transposed versions 3175 // of the matrices above. 3176 // 3177 "uniform mat3 gl_NormalMatrix;" 3178 3179 "uniform mat4 gl_ModelViewMatrixInverse;" 3180 "uniform mat4 gl_ProjectionMatrixInverse;" 3181 "uniform mat4 gl_ModelViewProjectionMatrixInverse;" 3182 3183 "uniform mat4 gl_ModelViewMatrixTranspose;" 3184 "uniform mat4 gl_ProjectionMatrixTranspose;" 3185 "uniform mat4 gl_ModelViewProjectionMatrixTranspose;" 3186 3187 "uniform mat4 gl_ModelViewMatrixInverseTranspose;" 3188 "uniform mat4 gl_ProjectionMatrixInverseTranspose;" 3189 "uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;" 3190 3191 // 3192 // Normal scaling p. 39. 3193 // 3194 "uniform float gl_NormalScale;" 3195 3196 // 3197 // Point Size, p. 66, 67. 3198 // 3199 "struct gl_PointParameters {" 3200 "float size;" 3201 "float sizeMin;" 3202 "float sizeMax;" 3203 "float fadeThresholdSize;" 3204 "float distanceConstantAttenuation;" 3205 "float distanceLinearAttenuation;" 3206 "float distanceQuadraticAttenuation;" 3207 "};" 3208 3209 "uniform gl_PointParameters gl_Point;" 3210 3211 // 3212 // Material State p. 50, 55. 3213 // 3214 "struct gl_MaterialParameters {" 3215 "vec4 emission;" // Ecm 3216 "vec4 ambient;" // Acm 3217 "vec4 diffuse;" // Dcm 3218 "vec4 specular;" // Scm 3219 "float shininess;" // Srm 3220 "};" 3221 "uniform gl_MaterialParameters gl_FrontMaterial;" 3222 "uniform gl_MaterialParameters gl_BackMaterial;" 3223 3224 // 3225 // Light State p 50, 53, 55. 3226 // 3227 "struct gl_LightSourceParameters {" 3228 "vec4 ambient;" // Acli 3229 "vec4 diffuse;" // Dcli 3230 "vec4 specular;" // Scli 3231 "vec4 position;" // Ppli 3232 "vec4 halfVector;" // Derived: Hi 3233 "vec3 spotDirection;" // Sdli 3234 "float spotExponent;" // Srli 3235 "float spotCutoff;" // Crli 3236 // (range: [0.0,90.0], 180.0) 3237 "float spotCosCutoff;" // Derived: cos(Crli) 3238 // (range: [1.0,0.0],-1.0) 3239 "float constantAttenuation;" // K0 3240 "float linearAttenuation;" // K1 3241 "float quadraticAttenuation;"// K2 3242 "};" 3243 3244 "struct gl_LightModelParameters {" 3245 "vec4 ambient;" // Acs 3246 "};" 3247 3248 "uniform gl_LightModelParameters gl_LightModel;" 3249 3250 // 3251 // Derived state from products of light and material. 3252 // 3253 "struct gl_LightModelProducts {" 3254 "vec4 sceneColor;" // Derived. Ecm + Acm * Acs 3255 "};" 3256 3257 "uniform gl_LightModelProducts gl_FrontLightModelProduct;" 3258 "uniform gl_LightModelProducts gl_BackLightModelProduct;" 3259 3260 "struct gl_LightProducts {" 3261 "vec4 ambient;" // Acm * Acli 3262 "vec4 diffuse;" // Dcm * Dcli 3263 "vec4 specular;" // Scm * Scli 3264 "};" 3265 3266 // 3267 // Fog p. 161 3268 // 3269 "struct gl_FogParameters {" 3270 "vec4 color;" 3271 "float density;" 3272 "float start;" 3273 "float end;" 3274 "float scale;" // 1 / (gl_FogEnd - gl_FogStart) 3275 "};" 3276 3277 "uniform gl_FogParameters gl_Fog;" 3278 3279 "\n"); 3280 } 3281 3282 //============================================================================ 3283 // 3284 // Define the interface to the compute shader. 3285 // 3286 //============================================================================ 3287 3288 if ((profile != EEsProfile && version >= 420) || 3289 (profile == EEsProfile && version >= 310)) { 3290 stageBuiltins[EShLangCompute].append( 3291 "in highp uvec3 gl_NumWorkGroups;" 3292 "const highp uvec3 gl_WorkGroupSize = uvec3(1,1,1);" 3293 3294 "in highp uvec3 gl_WorkGroupID;" 3295 "in highp uvec3 gl_LocalInvocationID;" 3296 3297 "in highp uvec3 gl_GlobalInvocationID;" 3298 "in highp uint gl_LocalInvocationIndex;" 3299 3300 "\n"); 3301 } 3302 3303 if ((profile != EEsProfile && version >= 140) || 3304 (profile == EEsProfile && version >= 310)) { 3305 stageBuiltins[EShLangCompute].append( 3306 "in highp int gl_DeviceIndex;" // GL_EXT_device_group 3307 "\n"); 3308 } 3309 3310 //============================================================================ 3311 // 3312 // Define the interface to the vertex shader. 3313 // 3314 //============================================================================ 3315 3316 if (profile != EEsProfile) { 3317 if (version < 130) { 3318 stageBuiltins[EShLangVertex].append( 3319 "attribute vec4 gl_Color;" 3320 "attribute vec4 gl_SecondaryColor;" 3321 "attribute vec3 gl_Normal;" 3322 "attribute vec4 gl_Vertex;" 3323 "attribute vec4 gl_MultiTexCoord0;" 3324 "attribute vec4 gl_MultiTexCoord1;" 3325 "attribute vec4 gl_MultiTexCoord2;" 3326 "attribute vec4 gl_MultiTexCoord3;" 3327 "attribute vec4 gl_MultiTexCoord4;" 3328 "attribute vec4 gl_MultiTexCoord5;" 3329 "attribute vec4 gl_MultiTexCoord6;" 3330 "attribute vec4 gl_MultiTexCoord7;" 3331 "attribute float gl_FogCoord;" 3332 "\n"); 3333 } else if (IncludeLegacy(version, profile, spvVersion)) { 3334 stageBuiltins[EShLangVertex].append( 3335 "in vec4 gl_Color;" 3336 "in vec4 gl_SecondaryColor;" 3337 "in vec3 gl_Normal;" 3338 "in vec4 gl_Vertex;" 3339 "in vec4 gl_MultiTexCoord0;" 3340 "in vec4 gl_MultiTexCoord1;" 3341 "in vec4 gl_MultiTexCoord2;" 3342 "in vec4 gl_MultiTexCoord3;" 3343 "in vec4 gl_MultiTexCoord4;" 3344 "in vec4 gl_MultiTexCoord5;" 3345 "in vec4 gl_MultiTexCoord6;" 3346 "in vec4 gl_MultiTexCoord7;" 3347 "in float gl_FogCoord;" 3348 "\n"); 3349 } 3350 3351 if (version < 150) { 3352 if (version < 130) { 3353 stageBuiltins[EShLangVertex].append( 3354 " vec4 gl_ClipVertex;" // needs qualifier fixed later 3355 "varying vec4 gl_FrontColor;" 3356 "varying vec4 gl_BackColor;" 3357 "varying vec4 gl_FrontSecondaryColor;" 3358 "varying vec4 gl_BackSecondaryColor;" 3359 "varying vec4 gl_TexCoord[];" 3360 "varying float gl_FogFragCoord;" 3361 "\n"); 3362 } else if (IncludeLegacy(version, profile, spvVersion)) { 3363 stageBuiltins[EShLangVertex].append( 3364 " vec4 gl_ClipVertex;" // needs qualifier fixed later 3365 "out vec4 gl_FrontColor;" 3366 "out vec4 gl_BackColor;" 3367 "out vec4 gl_FrontSecondaryColor;" 3368 "out vec4 gl_BackSecondaryColor;" 3369 "out vec4 gl_TexCoord[];" 3370 "out float gl_FogFragCoord;" 3371 "\n"); 3372 } 3373 stageBuiltins[EShLangVertex].append( 3374 "vec4 gl_Position;" // needs qualifier fixed later 3375 "float gl_PointSize;" // needs qualifier fixed later 3376 ); 3377 3378 if (version == 130 || version == 140) 3379 stageBuiltins[EShLangVertex].append( 3380 "out float gl_ClipDistance[];" 3381 ); 3382 } else { 3383 // version >= 150 3384 stageBuiltins[EShLangVertex].append( 3385 "out gl_PerVertex {" 3386 "vec4 gl_Position;" // needs qualifier fixed later 3387 "float gl_PointSize;" // needs qualifier fixed later 3388 "float gl_ClipDistance[];" 3389 ); 3390 if (IncludeLegacy(version, profile, spvVersion)) 3391 stageBuiltins[EShLangVertex].append( 3392 "vec4 gl_ClipVertex;" // needs qualifier fixed later 3393 "vec4 gl_FrontColor;" 3394 "vec4 gl_BackColor;" 3395 "vec4 gl_FrontSecondaryColor;" 3396 "vec4 gl_BackSecondaryColor;" 3397 "vec4 gl_TexCoord[];" 3398 "float gl_FogFragCoord;" 3399 ); 3400 if (version >= 450) 3401 stageBuiltins[EShLangVertex].append( 3402 "float gl_CullDistance[];" 3403 ); 3404 stageBuiltins[EShLangVertex].append( 3405 "};" 3406 "\n"); 3407 } 3408 if (version >= 130 && spvVersion.vulkan == 0) 3409 stageBuiltins[EShLangVertex].append( 3410 "int gl_VertexID;" // needs qualifier fixed later 3411 ); 3412 if (version >= 140 && spvVersion.vulkan == 0) 3413 stageBuiltins[EShLangVertex].append( 3414 "int gl_InstanceID;" // needs qualifier fixed later 3415 ); 3416 if (spvVersion.vulkan >= 100 && version >= 140) 3417 stageBuiltins[EShLangVertex].append( 3418 "in int gl_VertexIndex;" 3419 "in int gl_InstanceIndex;" 3420 ); 3421 if (version >= 440) { 3422 stageBuiltins[EShLangVertex].append( 3423 "in int gl_BaseVertexARB;" 3424 "in int gl_BaseInstanceARB;" 3425 "in int gl_DrawIDARB;" 3426 ); 3427 } 3428 if (version >= 450) { 3429 stageBuiltins[EShLangVertex].append( 3430 "out int gl_ViewportIndex;" 3431 "out int gl_Layer;" 3432 ); 3433 } 3434 if (version >= 460) { 3435 stageBuiltins[EShLangVertex].append( 3436 "in int gl_BaseVertex;" 3437 "in int gl_BaseInstance;" 3438 "in int gl_DrawID;" 3439 ); 3440 } 3441 3442 #ifdef NV_EXTENSIONS 3443 if (version >= 450) 3444 stageBuiltins[EShLangVertex].append( 3445 "out int gl_ViewportMask[];" // GL_NV_viewport_array2 3446 "out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering 3447 "out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering 3448 "out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes 3449 "out int gl_ViewportMaskPerViewNV[];" // GL_NVX_multiview_per_view_attributes 3450 ); 3451 #endif 3452 3453 } else { 3454 // ES profile 3455 if (version == 100) { 3456 stageBuiltins[EShLangVertex].append( 3457 "highp vec4 gl_Position;" // needs qualifier fixed later 3458 "mediump float gl_PointSize;" // needs qualifier fixed later 3459 ); 3460 } else { 3461 if (spvVersion.vulkan == 0) 3462 stageBuiltins[EShLangVertex].append( 3463 "in highp int gl_VertexID;" // needs qualifier fixed later 3464 "in highp int gl_InstanceID;" // needs qualifier fixed later 3465 ); 3466 if (spvVersion.vulkan >= 100) 3467 stageBuiltins[EShLangVertex].append( 3468 "in highp int gl_VertexIndex;" 3469 "in highp int gl_InstanceIndex;" 3470 ); 3471 if (version < 310) 3472 stageBuiltins[EShLangVertex].append( 3473 "highp vec4 gl_Position;" // needs qualifier fixed later 3474 "highp float gl_PointSize;" // needs qualifier fixed later 3475 ); 3476 else 3477 stageBuiltins[EShLangVertex].append( 3478 "out gl_PerVertex {" 3479 "highp vec4 gl_Position;" // needs qualifier fixed later 3480 "highp float gl_PointSize;" // needs qualifier fixed later 3481 "};" 3482 ); 3483 } 3484 } 3485 3486 if ((profile != EEsProfile && version >= 140) || 3487 (profile == EEsProfile && version >= 310)) { 3488 stageBuiltins[EShLangVertex].append( 3489 "in highp int gl_DeviceIndex;" // GL_EXT_device_group 3490 "in highp int gl_ViewIndex;" // GL_EXT_multiview 3491 "\n"); 3492 } 3493 3494 if (version >= 300 /* both ES and non-ES */) { 3495 stageBuiltins[EShLangVertex].append( 3496 "in highp uint gl_ViewID_OVR;" // GL_OVR_multiview, GL_OVR_multiview2 3497 "\n"); 3498 } 3499 3500 3501 //============================================================================ 3502 // 3503 // Define the interface to the geometry shader. 3504 // 3505 //============================================================================ 3506 3507 if (profile == ECoreProfile || profile == ECompatibilityProfile) { 3508 stageBuiltins[EShLangGeometry].append( 3509 "in gl_PerVertex {" 3510 "vec4 gl_Position;" 3511 "float gl_PointSize;" 3512 "float gl_ClipDistance[];" 3513 ); 3514 if (profile == ECompatibilityProfile) 3515 stageBuiltins[EShLangGeometry].append( 3516 "vec4 gl_ClipVertex;" 3517 "vec4 gl_FrontColor;" 3518 "vec4 gl_BackColor;" 3519 "vec4 gl_FrontSecondaryColor;" 3520 "vec4 gl_BackSecondaryColor;" 3521 "vec4 gl_TexCoord[];" 3522 "float gl_FogFragCoord;" 3523 ); 3524 if (version >= 450) 3525 stageBuiltins[EShLangGeometry].append( 3526 "float gl_CullDistance[];" 3527 #ifdef NV_EXTENSIONS 3528 "vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering 3529 "vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes 3530 #endif 3531 ); 3532 stageBuiltins[EShLangGeometry].append( 3533 "} gl_in[];" 3534 3535 "in int gl_PrimitiveIDIn;" 3536 "out gl_PerVertex {" 3537 "vec4 gl_Position;" 3538 "float gl_PointSize;" 3539 "float gl_ClipDistance[];" 3540 "\n"); 3541 if (profile == ECompatibilityProfile && version >= 400) 3542 stageBuiltins[EShLangGeometry].append( 3543 "vec4 gl_ClipVertex;" 3544 "vec4 gl_FrontColor;" 3545 "vec4 gl_BackColor;" 3546 "vec4 gl_FrontSecondaryColor;" 3547 "vec4 gl_BackSecondaryColor;" 3548 "vec4 gl_TexCoord[];" 3549 "float gl_FogFragCoord;" 3550 ); 3551 if (version >= 450) 3552 stageBuiltins[EShLangGeometry].append( 3553 "float gl_CullDistance[];" 3554 ); 3555 stageBuiltins[EShLangGeometry].append( 3556 "};" 3557 3558 "out int gl_PrimitiveID;" 3559 "out int gl_Layer;"); 3560 3561 if (profile == ECompatibilityProfile && version < 400) 3562 stageBuiltins[EShLangGeometry].append( 3563 "out vec4 gl_ClipVertex;" 3564 ); 3565 3566 if (version >= 400) 3567 stageBuiltins[EShLangGeometry].append( 3568 "in int gl_InvocationID;" 3569 ); 3570 // GL_ARB_viewport_array 3571 if (version >= 150) 3572 stageBuiltins[EShLangGeometry].append( 3573 "out int gl_ViewportIndex;" 3574 ); 3575 3576 #ifdef NV_EXTENSIONS 3577 if (version >= 450) 3578 stageBuiltins[EShLangGeometry].append( 3579 "out int gl_ViewportMask[];" // GL_NV_viewport_array2 3580 "out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering 3581 "out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering 3582 "out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes 3583 "out int gl_ViewportMaskPerViewNV[];" // GL_NVX_multiview_per_view_attributes 3584 ); 3585 #endif 3586 3587 stageBuiltins[EShLangGeometry].append("\n"); 3588 } else if (profile == EEsProfile && version >= 310) { 3589 stageBuiltins[EShLangGeometry].append( 3590 "in gl_PerVertex {" 3591 "highp vec4 gl_Position;" 3592 "highp float gl_PointSize;" 3593 "} gl_in[];" 3594 "\n" 3595 "in highp int gl_PrimitiveIDIn;" 3596 "in highp int gl_InvocationID;" 3597 "\n" 3598 "out gl_PerVertex {" 3599 "highp vec4 gl_Position;" 3600 "highp float gl_PointSize;" 3601 "};" 3602 "\n" 3603 "out highp int gl_PrimitiveID;" 3604 "out highp int gl_Layer;" 3605 "\n" 3606 ); 3607 } 3608 3609 if ((profile != EEsProfile && version >= 140) || 3610 (profile == EEsProfile && version >= 310)) { 3611 stageBuiltins[EShLangGeometry].append( 3612 "in highp int gl_DeviceIndex;" // GL_EXT_device_group 3613 "in highp int gl_ViewIndex;" // GL_EXT_multiview 3614 "\n"); 3615 } 3616 3617 //============================================================================ 3618 // 3619 // Define the interface to the tessellation control shader. 3620 // 3621 //============================================================================ 3622 3623 if (profile != EEsProfile && version >= 150) { 3624 // Note: "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below, 3625 // as it depends on the resource sizing of gl_MaxPatchVertices. 3626 3627 stageBuiltins[EShLangTessControl].append( 3628 "in int gl_PatchVerticesIn;" 3629 "in int gl_PrimitiveID;" 3630 "in int gl_InvocationID;" 3631 3632 "out gl_PerVertex {" 3633 "vec4 gl_Position;" 3634 "float gl_PointSize;" 3635 "float gl_ClipDistance[];" 3636 ); 3637 if (profile == ECompatibilityProfile) 3638 stageBuiltins[EShLangTessControl].append( 3639 "vec4 gl_ClipVertex;" 3640 "vec4 gl_FrontColor;" 3641 "vec4 gl_BackColor;" 3642 "vec4 gl_FrontSecondaryColor;" 3643 "vec4 gl_BackSecondaryColor;" 3644 "vec4 gl_TexCoord[];" 3645 "float gl_FogFragCoord;" 3646 ); 3647 if (version >= 450) 3648 stageBuiltins[EShLangTessControl].append( 3649 "float gl_CullDistance[];" 3650 #ifdef NV_EXTENSIONS 3651 "int gl_ViewportIndex;" 3652 "int gl_Layer;" 3653 "int gl_ViewportMask[];" // GL_NV_viewport_array2 3654 "vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering 3655 "int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering 3656 "vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes 3657 "int gl_ViewportMaskPerViewNV[];" // GL_NVX_multiview_per_view_attributes 3658 #endif 3659 ); 3660 stageBuiltins[EShLangTessControl].append( 3661 "} gl_out[];" 3662 3663 "patch out float gl_TessLevelOuter[4];" 3664 "patch out float gl_TessLevelInner[2];" 3665 "\n"); 3666 } else { 3667 // Note: "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below, 3668 // as it depends on the resource sizing of gl_MaxPatchVertices. 3669 3670 stageBuiltins[EShLangTessControl].append( 3671 "in highp int gl_PatchVerticesIn;" 3672 "in highp int gl_PrimitiveID;" 3673 "in highp int gl_InvocationID;" 3674 3675 "out gl_PerVertex {" 3676 "highp vec4 gl_Position;" 3677 "highp float gl_PointSize;" 3678 ); 3679 stageBuiltins[EShLangTessControl].append( 3680 "} gl_out[];" 3681 3682 "patch out highp float gl_TessLevelOuter[4];" 3683 "patch out highp float gl_TessLevelInner[2];" 3684 "patch out highp vec4 gl_BoundingBoxOES[2];" 3685 "\n"); 3686 } 3687 3688 if ((profile != EEsProfile && version >= 140) || 3689 (profile == EEsProfile && version >= 310)) { 3690 stageBuiltins[EShLangTessControl].append( 3691 "in highp int gl_DeviceIndex;" // GL_EXT_device_group 3692 "in highp int gl_ViewIndex;" // GL_EXT_multiview 3693 "\n"); 3694 } 3695 3696 //============================================================================ 3697 // 3698 // Define the interface to the tessellation evaluation shader. 3699 // 3700 //============================================================================ 3701 3702 if (profile != EEsProfile && version >= 150) { 3703 // Note: "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below, 3704 // as it depends on the resource sizing of gl_MaxPatchVertices. 3705 3706 stageBuiltins[EShLangTessEvaluation].append( 3707 "in int gl_PatchVerticesIn;" 3708 "in int gl_PrimitiveID;" 3709 "in vec3 gl_TessCoord;" 3710 3711 "patch in float gl_TessLevelOuter[4];" 3712 "patch in float gl_TessLevelInner[2];" 3713 3714 "out gl_PerVertex {" 3715 "vec4 gl_Position;" 3716 "float gl_PointSize;" 3717 "float gl_ClipDistance[];" 3718 ); 3719 if (version >= 400 && profile == ECompatibilityProfile) 3720 stageBuiltins[EShLangTessEvaluation].append( 3721 "vec4 gl_ClipVertex;" 3722 "vec4 gl_FrontColor;" 3723 "vec4 gl_BackColor;" 3724 "vec4 gl_FrontSecondaryColor;" 3725 "vec4 gl_BackSecondaryColor;" 3726 "vec4 gl_TexCoord[];" 3727 "float gl_FogFragCoord;" 3728 ); 3729 if (version >= 450) 3730 stageBuiltins[EShLangTessEvaluation].append( 3731 "float gl_CullDistance[];" 3732 ); 3733 stageBuiltins[EShLangTessEvaluation].append( 3734 "};" 3735 "\n"); 3736 3737 if (version >= 450) 3738 stageBuiltins[EShLangTessEvaluation].append( 3739 "out int gl_ViewportIndex;" 3740 "out int gl_Layer;" 3741 ); 3742 3743 #ifdef NV_EXTENSIONS 3744 if (version >= 450) 3745 stageBuiltins[EShLangTessEvaluation].append( 3746 "out int gl_ViewportMask[];" // GL_NV_viewport_array2 3747 "out vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering 3748 "out int gl_SecondaryViewportMaskNV[];" // GL_NV_stereo_view_rendering 3749 "out vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes 3750 "out int gl_ViewportMaskPerViewNV[];" // GL_NVX_multiview_per_view_attributes 3751 ); 3752 #endif 3753 3754 } else if (profile == EEsProfile && version >= 310) { 3755 // Note: "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below, 3756 // as it depends on the resource sizing of gl_MaxPatchVertices. 3757 3758 stageBuiltins[EShLangTessEvaluation].append( 3759 "in highp int gl_PatchVerticesIn;" 3760 "in highp int gl_PrimitiveID;" 3761 "in highp vec3 gl_TessCoord;" 3762 3763 "patch in highp float gl_TessLevelOuter[4];" 3764 "patch in highp float gl_TessLevelInner[2];" 3765 3766 "out gl_PerVertex {" 3767 "highp vec4 gl_Position;" 3768 "highp float gl_PointSize;" 3769 ); 3770 stageBuiltins[EShLangTessEvaluation].append( 3771 "};" 3772 "\n"); 3773 } 3774 3775 if ((profile != EEsProfile && version >= 140) || 3776 (profile == EEsProfile && version >= 310)) { 3777 stageBuiltins[EShLangTessEvaluation].append( 3778 "in highp int gl_DeviceIndex;" // GL_EXT_device_group 3779 "in highp int gl_ViewIndex;" // GL_EXT_multiview 3780 "\n"); 3781 } 3782 3783 //============================================================================ 3784 // 3785 // Define the interface to the fragment shader. 3786 // 3787 //============================================================================ 3788 3789 if (profile != EEsProfile) { 3790 3791 stageBuiltins[EShLangFragment].append( 3792 "vec4 gl_FragCoord;" // needs qualifier fixed later 3793 "bool gl_FrontFacing;" // needs qualifier fixed later 3794 "float gl_FragDepth;" // needs qualifier fixed later 3795 ); 3796 if (version >= 120) 3797 stageBuiltins[EShLangFragment].append( 3798 "vec2 gl_PointCoord;" // needs qualifier fixed later 3799 ); 3800 if (version >= 140) 3801 stageBuiltins[EShLangFragment].append( 3802 "out int gl_FragStencilRefARB;" 3803 ); 3804 if (IncludeLegacy(version, profile, spvVersion) || (! ForwardCompatibility && version < 420)) 3805 stageBuiltins[EShLangFragment].append( 3806 "vec4 gl_FragColor;" // needs qualifier fixed later 3807 ); 3808 3809 if (version < 130) { 3810 stageBuiltins[EShLangFragment].append( 3811 "varying vec4 gl_Color;" 3812 "varying vec4 gl_SecondaryColor;" 3813 "varying vec4 gl_TexCoord[];" 3814 "varying float gl_FogFragCoord;" 3815 ); 3816 } else { 3817 stageBuiltins[EShLangFragment].append( 3818 "in float gl_ClipDistance[];" 3819 ); 3820 3821 if (IncludeLegacy(version, profile, spvVersion)) { 3822 if (version < 150) 3823 stageBuiltins[EShLangFragment].append( 3824 "in float gl_FogFragCoord;" 3825 "in vec4 gl_TexCoord[];" 3826 "in vec4 gl_Color;" 3827 "in vec4 gl_SecondaryColor;" 3828 ); 3829 else 3830 stageBuiltins[EShLangFragment].append( 3831 "in gl_PerFragment {" 3832 "in float gl_FogFragCoord;" 3833 "in vec4 gl_TexCoord[];" 3834 "in vec4 gl_Color;" 3835 "in vec4 gl_SecondaryColor;" 3836 "};" 3837 ); 3838 } 3839 } 3840 3841 if (version >= 150) 3842 stageBuiltins[EShLangFragment].append( 3843 "flat in int gl_PrimitiveID;" 3844 ); 3845 3846 if (version >= 400) { 3847 stageBuiltins[EShLangFragment].append( 3848 "flat in int gl_SampleID;" 3849 " in vec2 gl_SamplePosition;" 3850 "flat in int gl_SampleMaskIn[];" 3851 " out int gl_SampleMask[];" 3852 ); 3853 if (spvVersion.spv == 0) 3854 stageBuiltins[EShLangFragment].append( 3855 "uniform int gl_NumSamples;" 3856 ); 3857 } 3858 3859 if (version >= 430) 3860 stageBuiltins[EShLangFragment].append( 3861 "flat in int gl_Layer;" 3862 "flat in int gl_ViewportIndex;" 3863 ); 3864 3865 if (version >= 450) 3866 stageBuiltins[EShLangFragment].append( 3867 "in float gl_CullDistance[];" 3868 "bool gl_HelperInvocation;" // needs qualifier fixed later 3869 ); 3870 3871 #ifdef AMD_EXTENSIONS 3872 if (version >= 450) 3873 stageBuiltins[EShLangFragment].append( 3874 "in vec2 gl_BaryCoordNoPerspAMD;" 3875 "in vec2 gl_BaryCoordNoPerspCentroidAMD;" 3876 "in vec2 gl_BaryCoordNoPerspSampleAMD;" 3877 "in vec2 gl_BaryCoordSmoothAMD;" 3878 "in vec2 gl_BaryCoordSmoothCentroidAMD;" 3879 "in vec2 gl_BaryCoordSmoothSampleAMD;" 3880 "in vec3 gl_BaryCoordPullModelAMD;" 3881 ); 3882 #endif 3883 } else { 3884 // ES profile 3885 3886 if (version == 100) { 3887 stageBuiltins[EShLangFragment].append( 3888 "mediump vec4 gl_FragCoord;" // needs qualifier fixed later 3889 " bool gl_FrontFacing;" // needs qualifier fixed later 3890 "mediump vec4 gl_FragColor;" // needs qualifier fixed later 3891 "mediump vec2 gl_PointCoord;" // needs qualifier fixed later 3892 ); 3893 } 3894 if (version >= 300) { 3895 stageBuiltins[EShLangFragment].append( 3896 "highp vec4 gl_FragCoord;" // needs qualifier fixed later 3897 " bool gl_FrontFacing;" // needs qualifier fixed later 3898 "mediump vec2 gl_PointCoord;" // needs qualifier fixed later 3899 "highp float gl_FragDepth;" // needs qualifier fixed later 3900 ); 3901 } 3902 if (version >= 310) { 3903 stageBuiltins[EShLangFragment].append( 3904 "bool gl_HelperInvocation;" // needs qualifier fixed later 3905 "flat in highp int gl_PrimitiveID;" // needs qualifier fixed later 3906 "flat in highp int gl_Layer;" // needs qualifier fixed later 3907 ); 3908 3909 stageBuiltins[EShLangFragment].append( // GL_OES_sample_variables 3910 "flat in lowp int gl_SampleID;" 3911 " in mediump vec2 gl_SamplePosition;" 3912 "flat in highp int gl_SampleMaskIn[];" 3913 " out highp int gl_SampleMask[];" 3914 ); 3915 if (spvVersion.spv == 0) 3916 stageBuiltins[EShLangFragment].append( // GL_OES_sample_variables 3917 "uniform lowp int gl_NumSamples;" 3918 ); 3919 } 3920 stageBuiltins[EShLangFragment].append( 3921 "highp float gl_FragDepthEXT;" // GL_EXT_frag_depth 3922 ); 3923 } 3924 stageBuiltins[EShLangFragment].append("\n"); 3925 3926 if (version >= 130) 3927 add2ndGenerationSamplingImaging(version, profile, spvVersion); 3928 3929 // GL_ARB_shader_ballot 3930 if (profile != EEsProfile && version >= 450) { 3931 commonBuiltins.append( 3932 "uniform uint gl_SubGroupSizeARB;" 3933 3934 "in uint gl_SubGroupInvocationARB;" 3935 "in uint64_t gl_SubGroupEqMaskARB;" 3936 "in uint64_t gl_SubGroupGeMaskARB;" 3937 "in uint64_t gl_SubGroupGtMaskARB;" 3938 "in uint64_t gl_SubGroupLeMaskARB;" 3939 "in uint64_t gl_SubGroupLtMaskARB;" 3940 3941 "\n"); 3942 } 3943 3944 if ((profile != EEsProfile && version >= 140) || 3945 (profile == EEsProfile && version >= 310)) { 3946 stageBuiltins[EShLangFragment].append( 3947 "flat in highp int gl_DeviceIndex;" // GL_EXT_device_group 3948 "flat in highp int gl_ViewIndex;" // GL_EXT_multiview 3949 "\n"); 3950 } 3951 3952 if (version >= 300 /* both ES and non-ES */) { 3953 stageBuiltins[EShLangFragment].append( 3954 "flat in highp uint gl_ViewID_OVR;" // GL_OVR_multiview, GL_OVR_multiview2 3955 "\n"); 3956 } 3957 3958 // printf("%s\n", commonBuiltins.c_str()); 3959 // printf("%s\n", stageBuiltins[EShLangFragment].c_str()); 3960 } 3961 3962 // 3963 // Helper function for initialize(), to add the second set of names for texturing, 3964 // when adding context-independent built-in functions. 3965 // 3966 void TBuiltIns::add2ndGenerationSamplingImaging(int version, EProfile profile, const SpvVersion& spvVersion) 3967 { 3968 // 3969 // In this function proper, enumerate the types, then calls the next set of functions 3970 // to enumerate all the uses for that type. 3971 // 3972 3973 TBasicType bTypes[3] = { EbtFloat, EbtInt, EbtUint }; 3974 bool skipBuffer = (profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 140); 3975 bool skipCubeArrayed = (profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 130); 3976 3977 // enumerate all the types 3978 for (int image = 0; image <= 1; ++image) { // loop over "bool" image vs sampler 3979 3980 for (int shadow = 0; shadow <= 1; ++shadow) { // loop over "bool" shadow or not 3981 for (int ms = 0; ms <=1; ++ms) { 3982 if ((ms || image) && shadow) 3983 continue; 3984 if (ms && profile != EEsProfile && version < 150) 3985 continue; 3986 if (ms && image && profile == EEsProfile) 3987 continue; 3988 if (ms && profile == EEsProfile && version < 310) 3989 continue; 3990 3991 for (int arrayed = 0; arrayed <= 1; ++arrayed) { // loop over "bool" arrayed or not 3992 for (int dim = Esd1D; dim < EsdNumDims; ++dim) { // 1D, 2D, ..., buffer 3993 if (dim == EsdSubpass && spvVersion.vulkan == 0) 3994 continue; 3995 if (dim == EsdSubpass && (image || shadow || arrayed)) 3996 continue; 3997 if ((dim == Esd1D || dim == EsdRect) && profile == EEsProfile) 3998 continue; 3999 if (dim != Esd2D && dim != EsdSubpass && ms) 4000 continue; 4001 if ((dim == Esd3D || dim == EsdRect) && arrayed) 4002 continue; 4003 if (dim == Esd3D && shadow) 4004 continue; 4005 if (dim == EsdCube && arrayed && skipCubeArrayed) 4006 continue; 4007 if (dim == EsdBuffer && skipBuffer) 4008 continue; 4009 if (dim == EsdBuffer && (shadow || arrayed || ms)) 4010 continue; 4011 if (ms && arrayed && profile == EEsProfile && version < 310) 4012 continue; 4013 4014 for (int bType = 0; bType < 3; ++bType) { // float, int, uint results 4015 4016 if (shadow && bType > 0) 4017 continue; 4018 4019 if (dim == EsdRect && version < 140 && bType > 0) 4020 continue; 4021 4022 // 4023 // Now, make all the function prototypes for the type we just built... 4024 // 4025 4026 TSampler sampler; 4027 if (dim == EsdSubpass) { 4028 sampler.setSubpass(bTypes[bType], ms ? true : false); 4029 } else if (image) { 4030 sampler.setImage(bTypes[bType], (TSamplerDim)dim, arrayed ? true : false, 4031 shadow ? true : false, 4032 ms ? true : false); 4033 } else { 4034 sampler.set(bTypes[bType], (TSamplerDim)dim, arrayed ? true : false, 4035 shadow ? true : false, 4036 ms ? true : false); 4037 } 4038 4039 TString typeName = sampler.getString(); 4040 4041 if (dim == EsdSubpass) { 4042 addSubpassSampling(sampler, typeName, version, profile); 4043 continue; 4044 } 4045 4046 addQueryFunctions(sampler, typeName, version, profile); 4047 4048 if (image) 4049 addImageFunctions(sampler, typeName, version, profile); 4050 else { 4051 addSamplingFunctions(sampler, typeName, version, profile); 4052 addGatherFunctions(sampler, typeName, version, profile); 4053 4054 if (spvVersion.vulkan > 0 && sampler.dim == EsdBuffer && sampler.isCombined()) { 4055 // Vulkan wants a textureBuffer to allow texelFetch() -- 4056 // a sampled image with no sampler. 4057 // So, add sampling functions for both the 4058 // samplerBuffer and textureBuffer types. 4059 sampler.setTexture(sampler.type, sampler.dim, sampler.arrayed, sampler.shadow, 4060 sampler.ms); 4061 TString textureTypeName = sampler.getString(); 4062 addSamplingFunctions(sampler, textureTypeName, version, profile); 4063 } 4064 } 4065 } 4066 } 4067 } 4068 } 4069 } 4070 } 4071 4072 // 4073 // sparseTexelsResidentARB() 4074 // 4075 4076 if (profile != EEsProfile && version >= 450) { 4077 commonBuiltins.append("bool sparseTexelsResidentARB(int code);\n"); 4078 } 4079 } 4080 4081 // 4082 // Helper function for add2ndGenerationSamplingImaging(), 4083 // when adding context-independent built-in functions. 4084 // 4085 // Add all the query functions for the given type. 4086 // 4087 void TBuiltIns::addQueryFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile) 4088 { 4089 if (sampler.image && ((profile == EEsProfile && version < 310) || (profile != EEsProfile && version < 430))) 4090 return; 4091 4092 // 4093 // textureSize() and imageSize() 4094 // 4095 4096 int sizeDims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0) - (sampler.dim == EsdCube ? 1 : 0); 4097 if (profile == EEsProfile) 4098 commonBuiltins.append("highp "); 4099 if (sizeDims == 1) 4100 commonBuiltins.append("int"); 4101 else { 4102 commonBuiltins.append("ivec"); 4103 commonBuiltins.append(postfixes[sizeDims]); 4104 } 4105 if (sampler.image) 4106 commonBuiltins.append(" imageSize(readonly writeonly volatile coherent "); 4107 else 4108 commonBuiltins.append(" textureSize("); 4109 commonBuiltins.append(typeName); 4110 if (! sampler.image && sampler.dim != EsdRect && sampler.dim != EsdBuffer && ! sampler.ms) 4111 commonBuiltins.append(",int);\n"); 4112 else 4113 commonBuiltins.append(");\n"); 4114 4115 // 4116 // textureSamples() and imageSamples() 4117 // 4118 4119 // GL_ARB_shader_texture_image_samples 4120 // TODO: spec issue? there are no memory qualifiers; how to query a writeonly/readonly image, etc? 4121 if (profile != EEsProfile && version >= 430 && sampler.ms) { 4122 commonBuiltins.append("int "); 4123 if (sampler.image) 4124 commonBuiltins.append("imageSamples(readonly writeonly volatile coherent "); 4125 else 4126 commonBuiltins.append("textureSamples("); 4127 commonBuiltins.append(typeName); 4128 commonBuiltins.append(");\n"); 4129 } 4130 4131 // 4132 // textureQueryLod(), fragment stage only 4133 // 4134 4135 if (profile != EEsProfile && version >= 400 && ! sampler.image && sampler.dim != EsdRect && ! sampler.ms && sampler.dim != EsdBuffer) { 4136 stageBuiltins[EShLangFragment].append("vec2 textureQueryLod("); 4137 stageBuiltins[EShLangFragment].append(typeName); 4138 if (dimMap[sampler.dim] == 1) 4139 stageBuiltins[EShLangFragment].append(", float"); 4140 else { 4141 stageBuiltins[EShLangFragment].append(", vec"); 4142 stageBuiltins[EShLangFragment].append(postfixes[dimMap[sampler.dim]]); 4143 } 4144 stageBuiltins[EShLangFragment].append(");\n"); 4145 } 4146 4147 // 4148 // textureQueryLevels() 4149 // 4150 4151 if (profile != EEsProfile && version >= 430 && ! sampler.image && sampler.dim != EsdRect && ! sampler.ms && sampler.dim != EsdBuffer) { 4152 commonBuiltins.append("int textureQueryLevels("); 4153 commonBuiltins.append(typeName); 4154 commonBuiltins.append(");\n"); 4155 } 4156 } 4157 4158 // 4159 // Helper function for add2ndGenerationSamplingImaging(), 4160 // when adding context-independent built-in functions. 4161 // 4162 // Add all the image access functions for the given type. 4163 // 4164 void TBuiltIns::addImageFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile) 4165 { 4166 int dims = dimMap[sampler.dim]; 4167 // most things with an array add a dimension, except for cubemaps 4168 if (sampler.arrayed && sampler.dim != EsdCube) 4169 ++dims; 4170 4171 TString imageParams = typeName; 4172 if (dims == 1) 4173 imageParams.append(", int"); 4174 else { 4175 imageParams.append(", ivec"); 4176 imageParams.append(postfixes[dims]); 4177 } 4178 if (sampler.ms) 4179 imageParams.append(", int"); 4180 4181 if (profile == EEsProfile) 4182 commonBuiltins.append("highp "); 4183 commonBuiltins.append(prefixes[sampler.type]); 4184 commonBuiltins.append("vec4 imageLoad(readonly volatile coherent "); 4185 commonBuiltins.append(imageParams); 4186 commonBuiltins.append(");\n"); 4187 4188 commonBuiltins.append("void imageStore(writeonly volatile coherent "); 4189 commonBuiltins.append(imageParams); 4190 commonBuiltins.append(", "); 4191 commonBuiltins.append(prefixes[sampler.type]); 4192 commonBuiltins.append("vec4);\n"); 4193 4194 if (sampler.dim != Esd1D && sampler.dim != EsdBuffer && profile != EEsProfile && version >= 450) { 4195 commonBuiltins.append("int sparseImageLoadARB(readonly volatile coherent "); 4196 commonBuiltins.append(imageParams); 4197 commonBuiltins.append(", out "); 4198 commonBuiltins.append(prefixes[sampler.type]); 4199 commonBuiltins.append("vec4"); 4200 commonBuiltins.append(");\n"); 4201 } 4202 4203 if ( profile != EEsProfile || 4204 (profile == EEsProfile && version >= 310)) { 4205 if (sampler.type == EbtInt || sampler.type == EbtUint) { 4206 const char* dataType = sampler.type == EbtInt ? "highp int" : "highp uint"; 4207 4208 const int numBuiltins = 7; 4209 4210 static const char* atomicFunc[numBuiltins] = { 4211 " imageAtomicAdd(volatile coherent ", 4212 " imageAtomicMin(volatile coherent ", 4213 " imageAtomicMax(volatile coherent ", 4214 " imageAtomicAnd(volatile coherent ", 4215 " imageAtomicOr(volatile coherent ", 4216 " imageAtomicXor(volatile coherent ", 4217 " imageAtomicExchange(volatile coherent " 4218 }; 4219 4220 for (size_t i = 0; i < numBuiltins; ++i) { 4221 commonBuiltins.append(dataType); 4222 commonBuiltins.append(atomicFunc[i]); 4223 commonBuiltins.append(imageParams); 4224 commonBuiltins.append(", "); 4225 commonBuiltins.append(dataType); 4226 commonBuiltins.append(");\n"); 4227 } 4228 4229 commonBuiltins.append(dataType); 4230 commonBuiltins.append(" imageAtomicCompSwap(volatile coherent "); 4231 commonBuiltins.append(imageParams); 4232 commonBuiltins.append(", "); 4233 commonBuiltins.append(dataType); 4234 commonBuiltins.append(", "); 4235 commonBuiltins.append(dataType); 4236 commonBuiltins.append(");\n"); 4237 } else { 4238 // not int or uint 4239 // GL_ARB_ES3_1_compatibility 4240 // TODO: spec issue: are there restrictions on the kind of layout() that can be used? what about dropping memory qualifiers? 4241 if ((profile != EEsProfile && version >= 450) || 4242 (profile == EEsProfile && version >= 310)) { 4243 commonBuiltins.append("float imageAtomicExchange(volatile coherent "); 4244 commonBuiltins.append(imageParams); 4245 commonBuiltins.append(", float);\n"); 4246 } 4247 } 4248 } 4249 4250 #ifdef AMD_EXTENSIONS 4251 if (sampler.dim == EsdRect || sampler.dim == EsdBuffer || sampler.shadow || sampler.ms) 4252 return; 4253 4254 if (profile == EEsProfile || version < 450) 4255 return; 4256 4257 TString imageLodParams = typeName; 4258 if (dims == 1) 4259 imageLodParams.append(", int"); 4260 else { 4261 imageLodParams.append(", ivec"); 4262 imageLodParams.append(postfixes[dims]); 4263 } 4264 imageLodParams.append(", int"); 4265 4266 commonBuiltins.append(prefixes[sampler.type]); 4267 commonBuiltins.append("vec4 imageLoadLodAMD(readonly volatile coherent "); 4268 commonBuiltins.append(imageLodParams); 4269 commonBuiltins.append(");\n"); 4270 4271 commonBuiltins.append("void imageStoreLodAMD(writeonly volatile coherent "); 4272 commonBuiltins.append(imageLodParams); 4273 commonBuiltins.append(", "); 4274 commonBuiltins.append(prefixes[sampler.type]); 4275 commonBuiltins.append("vec4);\n"); 4276 4277 if (sampler.dim != Esd1D) { 4278 commonBuiltins.append("int sparseImageLoadLodAMD(readonly volatile coherent "); 4279 commonBuiltins.append(imageLodParams); 4280 commonBuiltins.append(", out "); 4281 commonBuiltins.append(prefixes[sampler.type]); 4282 commonBuiltins.append("vec4"); 4283 commonBuiltins.append(");\n"); 4284 } 4285 #endif 4286 } 4287 4288 // 4289 // Helper function for initialize(), 4290 // when adding context-independent built-in functions. 4291 // 4292 // Add all the subpass access functions for the given type. 4293 // 4294 void TBuiltIns::addSubpassSampling(TSampler sampler, const TString& typeName, int /*version*/, EProfile /*profile*/) 4295 { 4296 stageBuiltins[EShLangFragment].append(prefixes[sampler.type]); 4297 stageBuiltins[EShLangFragment].append("vec4 subpassLoad"); 4298 stageBuiltins[EShLangFragment].append("("); 4299 stageBuiltins[EShLangFragment].append(typeName.c_str()); 4300 if (sampler.ms) 4301 stageBuiltins[EShLangFragment].append(", int"); 4302 stageBuiltins[EShLangFragment].append(");\n"); 4303 } 4304 4305 // 4306 // Helper function for add2ndGenerationSamplingImaging(), 4307 // when adding context-independent built-in functions. 4308 // 4309 // Add all the texture lookup functions for the given type. 4310 // 4311 void TBuiltIns::addSamplingFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile) 4312 { 4313 // 4314 // texturing 4315 // 4316 for (int proj = 0; proj <= 1; ++proj) { // loop over "bool" projective or not 4317 4318 if (proj && (sampler.dim == EsdCube || sampler.dim == EsdBuffer || sampler.arrayed || sampler.ms)) 4319 continue; 4320 4321 for (int lod = 0; lod <= 1; ++lod) { 4322 4323 if (lod && (sampler.dim == EsdBuffer || sampler.dim == EsdRect || sampler.ms)) 4324 continue; 4325 if (lod && sampler.dim == Esd2D && sampler.arrayed && sampler.shadow) 4326 continue; 4327 if (lod && sampler.dim == EsdCube && sampler.shadow) 4328 continue; 4329 4330 for (int bias = 0; bias <= 1; ++bias) { 4331 4332 if (bias && (lod || sampler.ms)) 4333 continue; 4334 if (bias && sampler.dim == Esd2D && sampler.shadow && sampler.arrayed) 4335 continue; 4336 if (bias && (sampler.dim == EsdRect || sampler.dim == EsdBuffer)) 4337 continue; 4338 4339 for (int offset = 0; offset <= 1; ++offset) { // loop over "bool" offset or not 4340 4341 if (proj + offset + bias + lod > 3) 4342 continue; 4343 if (offset && (sampler.dim == EsdCube || sampler.dim == EsdBuffer || sampler.ms)) 4344 continue; 4345 4346 for (int fetch = 0; fetch <= 1; ++fetch) { // loop over "bool" fetch or not 4347 4348 if (proj + offset + fetch + bias + lod > 3) 4349 continue; 4350 if (fetch && (lod || bias)) 4351 continue; 4352 if (fetch && (sampler.shadow || sampler.dim == EsdCube)) 4353 continue; 4354 if (fetch == 0 && (sampler.ms || sampler.dim == EsdBuffer)) 4355 continue; 4356 4357 for (int grad = 0; grad <= 1; ++grad) { // loop over "bool" grad or not 4358 4359 if (grad && (lod || bias || sampler.ms)) 4360 continue; 4361 if (grad && sampler.dim == EsdBuffer) 4362 continue; 4363 if (proj + offset + fetch + grad + bias + lod > 3) 4364 continue; 4365 4366 for (int extraProj = 0; extraProj <= 1; ++extraProj) { 4367 bool compare = false; 4368 int totalDims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0); 4369 // skip dummy unused second component for 1D non-array shadows 4370 if (sampler.shadow && totalDims < 2) 4371 totalDims = 2; 4372 totalDims += (sampler.shadow ? 1 : 0) + proj; 4373 if (totalDims > 4 && sampler.shadow) { 4374 compare = true; 4375 totalDims = 4; 4376 } 4377 assert(totalDims <= 4); 4378 4379 if (extraProj && ! proj) 4380 continue; 4381 if (extraProj && (sampler.dim == Esd3D || sampler.shadow)) 4382 continue; 4383 4384 for (int lodClamp = 0; lodClamp <= 1 ;++lodClamp) { // loop over "bool" lod clamp 4385 4386 if (lodClamp && (profile == EEsProfile || version < 450)) 4387 continue; 4388 if (lodClamp && (proj || lod || fetch)) 4389 continue; 4390 4391 for (int sparse = 0; sparse <= 1; ++sparse) { // loop over "bool" sparse or not 4392 4393 if (sparse && (profile == EEsProfile || version < 450)) 4394 continue; 4395 // Sparse sampling is not for 1D/1D array texture, buffer texture, and projective texture 4396 if (sparse && (sampler.dim == Esd1D || sampler.dim == EsdBuffer || proj)) 4397 continue; 4398 4399 TString s; 4400 4401 // return type 4402 if (sparse) 4403 s.append("int "); 4404 else { 4405 if (sampler.shadow) 4406 s.append("float "); 4407 else { 4408 s.append(prefixes[sampler.type]); 4409 s.append("vec4 "); 4410 } 4411 } 4412 4413 // name 4414 if (sparse) { 4415 if (fetch) 4416 s.append("sparseTexel"); 4417 else 4418 s.append("sparseTexture"); 4419 } else { 4420 if (fetch) 4421 s.append("texel"); 4422 else 4423 s.append("texture"); 4424 } 4425 if (proj) 4426 s.append("Proj"); 4427 if (lod) 4428 s.append("Lod"); 4429 if (grad) 4430 s.append("Grad"); 4431 if (fetch) 4432 s.append("Fetch"); 4433 if (offset) 4434 s.append("Offset"); 4435 if (lodClamp) 4436 s.append("Clamp"); 4437 if (lodClamp || sparse) 4438 s.append("ARB"); 4439 s.append("("); 4440 4441 // sampler type 4442 s.append(typeName); 4443 4444 // P coordinate 4445 if (extraProj) 4446 s.append(",vec4"); 4447 else { 4448 s.append(","); 4449 TBasicType t = fetch ? EbtInt : EbtFloat; 4450 if (totalDims == 1) 4451 s.append(TType::getBasicString(t)); 4452 else { 4453 s.append(prefixes[t]); 4454 s.append("vec"); 4455 s.append(postfixes[totalDims]); 4456 } 4457 } 4458 4459 if (bias && compare) 4460 continue; 4461 4462 // non-optional lod argument (lod that's not driven by lod loop) or sample 4463 if ((fetch && sampler.dim != EsdBuffer && sampler.dim != EsdRect && !sampler.ms) || 4464 (sampler.ms && fetch)) 4465 s.append(",int"); 4466 4467 // non-optional lod 4468 if (lod) 4469 s.append(",float"); 4470 4471 // gradient arguments 4472 if (grad) { 4473 if (dimMap[sampler.dim] == 1) 4474 s.append(",float,float"); 4475 else { 4476 s.append(",vec"); 4477 s.append(postfixes[dimMap[sampler.dim]]); 4478 s.append(",vec"); 4479 s.append(postfixes[dimMap[sampler.dim]]); 4480 } 4481 } 4482 4483 // offset 4484 if (offset) { 4485 if (dimMap[sampler.dim] == 1) 4486 s.append(",int"); 4487 else { 4488 s.append(",ivec"); 4489 s.append(postfixes[dimMap[sampler.dim]]); 4490 } 4491 } 4492 4493 // non-optional compare 4494 if (compare) 4495 s.append(",float"); 4496 4497 // lod clamp 4498 if (lodClamp) 4499 s.append(",float"); 4500 4501 // texel out (for sparse texture) 4502 if (sparse) { 4503 s.append(",out "); 4504 if (sampler.shadow) 4505 s.append("float "); 4506 else { 4507 s.append(prefixes[sampler.type]); 4508 s.append("vec4 "); 4509 } 4510 } 4511 4512 // optional bias 4513 if (bias) 4514 s.append(",float"); 4515 4516 s.append(");\n"); 4517 4518 // Add to the per-language set of built-ins 4519 4520 if (bias || lodClamp) 4521 stageBuiltins[EShLangFragment].append(s); 4522 else 4523 commonBuiltins.append(s); 4524 } 4525 } 4526 } 4527 } 4528 } 4529 } 4530 } 4531 } 4532 } 4533 } 4534 4535 // 4536 // Helper function for add2ndGenerationSamplingImaging(), 4537 // when adding context-independent built-in functions. 4538 // 4539 // Add all the texture gather functions for the given type. 4540 // 4541 void TBuiltIns::addGatherFunctions(TSampler sampler, const TString& typeName, int version, EProfile profile) 4542 { 4543 switch (sampler.dim) { 4544 case Esd2D: 4545 case EsdRect: 4546 case EsdCube: 4547 break; 4548 default: 4549 return; 4550 } 4551 4552 if (sampler.ms) 4553 return; 4554 4555 if (version < 140 && sampler.dim == EsdRect && sampler.type != EbtFloat) 4556 return; 4557 4558 for (int offset = 0; offset < 3; ++offset) { // loop over three forms of offset in the call name: none, Offset, and Offsets 4559 4560 for (int comp = 0; comp < 2; ++comp) { // loop over presence of comp argument 4561 4562 if (comp > 0 && sampler.shadow) 4563 continue; 4564 4565 if (offset > 0 && sampler.dim == EsdCube) 4566 continue; 4567 4568 for (int sparse = 0; sparse <= 1; ++sparse) { // loop over "bool" sparse or not 4569 if (sparse && (profile == EEsProfile || version < 450)) 4570 continue; 4571 4572 TString s; 4573 4574 // return type 4575 if (sparse) 4576 s.append("int "); 4577 else { 4578 s.append(prefixes[sampler.type]); 4579 s.append("vec4 "); 4580 } 4581 4582 // name 4583 if (sparse) 4584 s.append("sparseTextureGather"); 4585 else 4586 s.append("textureGather"); 4587 switch (offset) { 4588 case 1: 4589 s.append("Offset"); 4590 break; 4591 case 2: 4592 s.append("Offsets"); 4593 default: 4594 break; 4595 } 4596 4597 if (sparse) 4598 s.append("ARB"); 4599 s.append("("); 4600 4601 // sampler type argument 4602 s.append(typeName); 4603 4604 // P coordinate argument 4605 s.append(",vec"); 4606 int totalDims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0); 4607 s.append(postfixes[totalDims]); 4608 4609 // refZ argument 4610 if (sampler.shadow) 4611 s.append(",float"); 4612 4613 // offset argument 4614 if (offset > 0) { 4615 s.append(",ivec2"); 4616 if (offset == 2) 4617 s.append("[4]"); 4618 } 4619 4620 // texel out (for sparse texture) 4621 if (sparse) { 4622 s.append(",out "); 4623 s.append(prefixes[sampler.type]); 4624 s.append("vec4 "); 4625 } 4626 4627 // comp argument 4628 if (comp) 4629 s.append(",int"); 4630 4631 s.append(");\n"); 4632 commonBuiltins.append(s); 4633 } 4634 } 4635 } 4636 4637 #ifdef AMD_EXTENSIONS 4638 if (sampler.dim == EsdRect || sampler.shadow) 4639 return; 4640 4641 if (profile == EEsProfile || version < 450) 4642 return; 4643 4644 for (int bias = 0; bias < 2; ++bias) { // loop over presence of bias argument 4645 4646 for (int lod = 0; lod < 2; ++lod) { // loop over presence of lod argument 4647 4648 if ((lod && bias) || (lod == 0 && bias == 0)) 4649 continue; 4650 4651 for (int offset = 0; offset < 3; ++offset) { // loop over three forms of offset in the call name: none, Offset, and Offsets 4652 4653 for (int comp = 0; comp < 2; ++comp) { // loop over presence of comp argument 4654 4655 if (comp == 0 && bias) 4656 continue; 4657 4658 if (offset > 0 && sampler.dim == EsdCube) 4659 continue; 4660 4661 for (int sparse = 0; sparse <= 1; ++sparse) { // loop over "bool" sparse or not 4662 if (sparse && (profile == EEsProfile || version < 450)) 4663 continue; 4664 4665 TString s; 4666 4667 // return type 4668 if (sparse) 4669 s.append("int "); 4670 else { 4671 s.append(prefixes[sampler.type]); 4672 s.append("vec4 "); 4673 } 4674 4675 // name 4676 if (sparse) 4677 s.append("sparseTextureGather"); 4678 else 4679 s.append("textureGather"); 4680 4681 if (lod) 4682 s.append("Lod"); 4683 4684 switch (offset) { 4685 case 1: 4686 s.append("Offset"); 4687 break; 4688 case 2: 4689 s.append("Offsets"); 4690 default: 4691 break; 4692 } 4693 4694 if (lod) 4695 s.append("AMD"); 4696 else if (sparse) 4697 s.append("ARB"); 4698 4699 s.append("("); 4700 4701 // sampler type argument 4702 s.append(typeName); 4703 4704 // P coordinate argument 4705 s.append(",vec"); 4706 int totalDims = dimMap[sampler.dim] + (sampler.arrayed ? 1 : 0); 4707 s.append(postfixes[totalDims]); 4708 4709 // lod argument 4710 if (lod) 4711 s.append(",float"); 4712 4713 // offset argument 4714 if (offset > 0) { 4715 s.append(",ivec2"); 4716 if (offset == 2) 4717 s.append("[4]"); 4718 } 4719 4720 // texel out (for sparse texture) 4721 if (sparse) { 4722 s.append(",out "); 4723 s.append(prefixes[sampler.type]); 4724 s.append("vec4 "); 4725 } 4726 4727 // comp argument 4728 if (comp) 4729 s.append(",int"); 4730 4731 // bias argument 4732 if (bias) 4733 s.append(",float"); 4734 4735 s.append(");\n"); 4736 if (bias) 4737 stageBuiltins[EShLangFragment].append(s); 4738 else 4739 commonBuiltins.append(s); 4740 } 4741 } 4742 } 4743 } 4744 } 4745 #endif 4746 } 4747 4748 // 4749 // Add context-dependent built-in functions and variables that are present 4750 // for the given version and profile. All the results are put into just the 4751 // commonBuiltins, because it is called for just a specific stage. So, 4752 // add stage-specific entries to the commonBuiltins, and only if that stage 4753 // was requested. 4754 // 4755 void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language) 4756 { 4757 // 4758 // Initialize the context-dependent (resource-dependent) built-in strings for parsing. 4759 // 4760 4761 //============================================================================ 4762 // 4763 // Standard Uniforms 4764 // 4765 //============================================================================ 4766 4767 TString& s = commonBuiltins; 4768 const int maxSize = 80; 4769 char builtInConstant[maxSize]; 4770 4771 // 4772 // Build string of implementation dependent constants. 4773 // 4774 4775 if (profile == EEsProfile) { 4776 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs); 4777 s.append(builtInConstant); 4778 4779 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxVertexUniformVectors = %d;", resources.maxVertexUniformVectors); 4780 s.append(builtInConstant); 4781 4782 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxVertexTextureImageUnits = %d;", resources.maxVertexTextureImageUnits); 4783 s.append(builtInConstant); 4784 4785 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxCombinedTextureImageUnits = %d;", resources.maxCombinedTextureImageUnits); 4786 s.append(builtInConstant); 4787 4788 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits); 4789 s.append(builtInConstant); 4790 4791 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxFragmentUniformVectors = %d;", resources.maxFragmentUniformVectors); 4792 s.append(builtInConstant); 4793 4794 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxDrawBuffers = %d;", resources.maxDrawBuffers); 4795 s.append(builtInConstant); 4796 4797 if (version == 100) { 4798 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxVaryingVectors = %d;", resources.maxVaryingVectors); 4799 s.append(builtInConstant); 4800 } else { 4801 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxVertexOutputVectors = %d;", resources.maxVertexOutputVectors); 4802 s.append(builtInConstant); 4803 4804 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxFragmentInputVectors = %d;", resources.maxFragmentInputVectors); 4805 s.append(builtInConstant); 4806 4807 snprintf(builtInConstant, maxSize, "const mediump int gl_MinProgramTexelOffset = %d;", resources.minProgramTexelOffset); 4808 s.append(builtInConstant); 4809 4810 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxProgramTexelOffset = %d;", resources.maxProgramTexelOffset); 4811 s.append(builtInConstant); 4812 } 4813 4814 if (version >= 310) { 4815 // geometry 4816 4817 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryInputComponents = %d;", resources.maxGeometryInputComponents); 4818 s.append(builtInConstant); 4819 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryOutputComponents = %d;", resources.maxGeometryOutputComponents); 4820 s.append(builtInConstant); 4821 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryImageUniforms = %d;", resources.maxGeometryImageUniforms); 4822 s.append(builtInConstant); 4823 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryTextureImageUnits = %d;", resources.maxGeometryTextureImageUnits); 4824 s.append(builtInConstant); 4825 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryOutputVertices = %d;", resources.maxGeometryOutputVertices); 4826 s.append(builtInConstant); 4827 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryTotalOutputComponents = %d;", resources.maxGeometryTotalOutputComponents); 4828 s.append(builtInConstant); 4829 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryUniformComponents = %d;", resources.maxGeometryUniformComponents); 4830 s.append(builtInConstant); 4831 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounters = %d;", resources.maxGeometryAtomicCounters); 4832 s.append(builtInConstant); 4833 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounterBuffers = %d;", resources.maxGeometryAtomicCounterBuffers); 4834 s.append(builtInConstant); 4835 4836 // tessellation 4837 4838 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlInputComponents = %d;", resources.maxTessControlInputComponents); 4839 s.append(builtInConstant); 4840 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlOutputComponents = %d;", resources.maxTessControlOutputComponents); 4841 s.append(builtInConstant); 4842 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlTextureImageUnits = %d;", resources.maxTessControlTextureImageUnits); 4843 s.append(builtInConstant); 4844 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlUniformComponents = %d;", resources.maxTessControlUniformComponents); 4845 s.append(builtInConstant); 4846 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlTotalOutputComponents = %d;", resources.maxTessControlTotalOutputComponents); 4847 s.append(builtInConstant); 4848 4849 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationInputComponents = %d;", resources.maxTessEvaluationInputComponents); 4850 s.append(builtInConstant); 4851 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationOutputComponents = %d;", resources.maxTessEvaluationOutputComponents); 4852 s.append(builtInConstant); 4853 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationTextureImageUnits = %d;", resources.maxTessEvaluationTextureImageUnits); 4854 s.append(builtInConstant); 4855 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationUniformComponents = %d;", resources.maxTessEvaluationUniformComponents); 4856 s.append(builtInConstant); 4857 4858 snprintf(builtInConstant, maxSize, "const int gl_MaxTessPatchComponents = %d;", resources.maxTessPatchComponents); 4859 s.append(builtInConstant); 4860 4861 snprintf(builtInConstant, maxSize, "const int gl_MaxPatchVertices = %d;", resources.maxPatchVertices); 4862 s.append(builtInConstant); 4863 snprintf(builtInConstant, maxSize, "const int gl_MaxTessGenLevel = %d;", resources.maxTessGenLevel); 4864 s.append(builtInConstant); 4865 4866 // this is here instead of with the others in initialize(version, profile) due to the dependence on gl_MaxPatchVertices 4867 if (language == EShLangTessControl || language == EShLangTessEvaluation) { 4868 s.append( 4869 "in gl_PerVertex {" 4870 "highp vec4 gl_Position;" 4871 "highp float gl_PointSize;" 4872 #ifdef NV_EXTENSIONS 4873 "highp vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering 4874 "highp vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes 4875 #endif 4876 "} gl_in[gl_MaxPatchVertices];" 4877 "\n"); 4878 } 4879 } 4880 4881 } else { 4882 // non-ES profile 4883 4884 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs); 4885 s.append(builtInConstant); 4886 4887 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexTextureImageUnits = %d;", resources.maxVertexTextureImageUnits); 4888 s.append(builtInConstant); 4889 4890 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedTextureImageUnits = %d;", resources.maxCombinedTextureImageUnits); 4891 s.append(builtInConstant); 4892 4893 snprintf(builtInConstant, maxSize, "const int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits); 4894 s.append(builtInConstant); 4895 4896 snprintf(builtInConstant, maxSize, "const int gl_MaxDrawBuffers = %d;", resources.maxDrawBuffers); 4897 s.append(builtInConstant); 4898 4899 snprintf(builtInConstant, maxSize, "const int gl_MaxLights = %d;", resources.maxLights); 4900 s.append(builtInConstant); 4901 4902 snprintf(builtInConstant, maxSize, "const int gl_MaxClipPlanes = %d;", resources.maxClipPlanes); 4903 s.append(builtInConstant); 4904 4905 snprintf(builtInConstant, maxSize, "const int gl_MaxTextureUnits = %d;", resources.maxTextureUnits); 4906 s.append(builtInConstant); 4907 4908 snprintf(builtInConstant, maxSize, "const int gl_MaxTextureCoords = %d;", resources.maxTextureCoords); 4909 s.append(builtInConstant); 4910 4911 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexUniformComponents = %d;", resources.maxVertexUniformComponents); 4912 s.append(builtInConstant); 4913 4914 if (version < 150 || ARBCompatibility) { 4915 snprintf(builtInConstant, maxSize, "const int gl_MaxVaryingFloats = %d;", resources.maxVaryingFloats); 4916 s.append(builtInConstant); 4917 } 4918 4919 snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentUniformComponents = %d;", resources.maxFragmentUniformComponents); 4920 s.append(builtInConstant); 4921 4922 if (spvVersion.spv == 0 && IncludeLegacy(version, profile, spvVersion)) { 4923 // 4924 // OpenGL'uniform' state. Page numbers are in reference to version 4925 // 1.4 of the OpenGL specification. 4926 // 4927 4928 // 4929 // Matrix state. p. 31, 32, 37, 39, 40. 4930 // 4931 s.append("uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];" 4932 4933 // 4934 // Derived matrix state that provides inverse and transposed versions 4935 // of the matrices above. 4936 // 4937 "uniform mat4 gl_TextureMatrixInverse[gl_MaxTextureCoords];" 4938 4939 "uniform mat4 gl_TextureMatrixTranspose[gl_MaxTextureCoords];" 4940 4941 "uniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords];" 4942 4943 // 4944 // Clip planes p. 42. 4945 // 4946 "uniform vec4 gl_ClipPlane[gl_MaxClipPlanes];" 4947 4948 // 4949 // Light State p 50, 53, 55. 4950 // 4951 "uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];" 4952 4953 // 4954 // Derived state from products of light. 4955 // 4956 "uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];" 4957 "uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];" 4958 4959 // 4960 // Texture Environment and Generation, p. 152, p. 40-42. 4961 // 4962 "uniform vec4 gl_TextureEnvColor[gl_MaxTextureImageUnits];" 4963 "uniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];" 4964 "uniform vec4 gl_EyePlaneT[gl_MaxTextureCoords];" 4965 "uniform vec4 gl_EyePlaneR[gl_MaxTextureCoords];" 4966 "uniform vec4 gl_EyePlaneQ[gl_MaxTextureCoords];" 4967 "uniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoords];" 4968 "uniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoords];" 4969 "uniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoords];" 4970 "uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoords];"); 4971 } 4972 4973 if (version >= 130) { 4974 snprintf(builtInConstant, maxSize, "const int gl_MaxClipDistances = %d;", resources.maxClipDistances); 4975 s.append(builtInConstant); 4976 snprintf(builtInConstant, maxSize, "const int gl_MaxVaryingComponents = %d;", resources.maxVaryingComponents); 4977 s.append(builtInConstant); 4978 4979 // GL_ARB_shading_language_420pack 4980 snprintf(builtInConstant, maxSize, "const mediump int gl_MinProgramTexelOffset = %d;", resources.minProgramTexelOffset); 4981 s.append(builtInConstant); 4982 snprintf(builtInConstant, maxSize, "const mediump int gl_MaxProgramTexelOffset = %d;", resources.maxProgramTexelOffset); 4983 s.append(builtInConstant); 4984 } 4985 4986 // geometry 4987 if (version >= 150) { 4988 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryInputComponents = %d;", resources.maxGeometryInputComponents); 4989 s.append(builtInConstant); 4990 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryOutputComponents = %d;", resources.maxGeometryOutputComponents); 4991 s.append(builtInConstant); 4992 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryTextureImageUnits = %d;", resources.maxGeometryTextureImageUnits); 4993 s.append(builtInConstant); 4994 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryOutputVertices = %d;", resources.maxGeometryOutputVertices); 4995 s.append(builtInConstant); 4996 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryTotalOutputComponents = %d;", resources.maxGeometryTotalOutputComponents); 4997 s.append(builtInConstant); 4998 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryUniformComponents = %d;", resources.maxGeometryUniformComponents); 4999 s.append(builtInConstant); 5000 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryVaryingComponents = %d;", resources.maxGeometryVaryingComponents); 5001 s.append(builtInConstant); 5002 5003 } 5004 5005 if (version >= 150) { 5006 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexOutputComponents = %d;", resources.maxVertexOutputComponents); 5007 s.append(builtInConstant); 5008 snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentInputComponents = %d;", resources.maxFragmentInputComponents); 5009 s.append(builtInConstant); 5010 } 5011 5012 // tessellation 5013 if (version >= 150) { 5014 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlInputComponents = %d;", resources.maxTessControlInputComponents); 5015 s.append(builtInConstant); 5016 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlOutputComponents = %d;", resources.maxTessControlOutputComponents); 5017 s.append(builtInConstant); 5018 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlTextureImageUnits = %d;", resources.maxTessControlTextureImageUnits); 5019 s.append(builtInConstant); 5020 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlUniformComponents = %d;", resources.maxTessControlUniformComponents); 5021 s.append(builtInConstant); 5022 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlTotalOutputComponents = %d;", resources.maxTessControlTotalOutputComponents); 5023 s.append(builtInConstant); 5024 5025 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationInputComponents = %d;", resources.maxTessEvaluationInputComponents); 5026 s.append(builtInConstant); 5027 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationOutputComponents = %d;", resources.maxTessEvaluationOutputComponents); 5028 s.append(builtInConstant); 5029 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationTextureImageUnits = %d;", resources.maxTessEvaluationTextureImageUnits); 5030 s.append(builtInConstant); 5031 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationUniformComponents = %d;", resources.maxTessEvaluationUniformComponents); 5032 s.append(builtInConstant); 5033 5034 snprintf(builtInConstant, maxSize, "const int gl_MaxTessPatchComponents = %d;", resources.maxTessPatchComponents); 5035 s.append(builtInConstant); 5036 snprintf(builtInConstant, maxSize, "const int gl_MaxTessGenLevel = %d;", resources.maxTessGenLevel); 5037 s.append(builtInConstant); 5038 snprintf(builtInConstant, maxSize, "const int gl_MaxPatchVertices = %d;", resources.maxPatchVertices); 5039 s.append(builtInConstant); 5040 5041 // this is here instead of with the others in initialize(version, profile) due to the dependence on gl_MaxPatchVertices 5042 if (language == EShLangTessControl || language == EShLangTessEvaluation) { 5043 s.append( 5044 "in gl_PerVertex {" 5045 "vec4 gl_Position;" 5046 "float gl_PointSize;" 5047 "float gl_ClipDistance[];" 5048 ); 5049 if (profile == ECompatibilityProfile) 5050 s.append( 5051 "vec4 gl_ClipVertex;" 5052 "vec4 gl_FrontColor;" 5053 "vec4 gl_BackColor;" 5054 "vec4 gl_FrontSecondaryColor;" 5055 "vec4 gl_BackSecondaryColor;" 5056 "vec4 gl_TexCoord[];" 5057 "float gl_FogFragCoord;" 5058 ); 5059 if (profile != EEsProfile && version >= 450) 5060 s.append( 5061 "float gl_CullDistance[];" 5062 #ifdef NV_EXTENSIONS 5063 "vec4 gl_SecondaryPositionNV;" // GL_NV_stereo_view_rendering 5064 "vec4 gl_PositionPerViewNV[];" // GL_NVX_multiview_per_view_attributes 5065 #endif 5066 ); 5067 s.append( 5068 "} gl_in[gl_MaxPatchVertices];" 5069 "\n"); 5070 } 5071 } 5072 5073 if (version >= 150) { 5074 snprintf(builtInConstant, maxSize, "const int gl_MaxViewports = %d;", resources.maxViewports); 5075 s.append(builtInConstant); 5076 } 5077 5078 // images 5079 if (version >= 130) { 5080 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedImageUnitsAndFragmentOutputs = %d;", resources.maxCombinedImageUnitsAndFragmentOutputs); 5081 s.append(builtInConstant); 5082 snprintf(builtInConstant, maxSize, "const int gl_MaxImageSamples = %d;", resources.maxImageSamples); 5083 s.append(builtInConstant); 5084 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlImageUniforms = %d;", resources.maxTessControlImageUniforms); 5085 s.append(builtInConstant); 5086 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationImageUniforms = %d;", resources.maxTessEvaluationImageUniforms); 5087 s.append(builtInConstant); 5088 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryImageUniforms = %d;", resources.maxGeometryImageUniforms); 5089 s.append(builtInConstant); 5090 } 5091 5092 // enhanced layouts 5093 if (version >= 430) { 5094 snprintf(builtInConstant, maxSize, "const int gl_MaxTransformFeedbackBuffers = %d;", resources.maxTransformFeedbackBuffers); 5095 s.append(builtInConstant); 5096 snprintf(builtInConstant, maxSize, "const int gl_MaxTransformFeedbackInterleavedComponents = %d;", resources.maxTransformFeedbackInterleavedComponents); 5097 s.append(builtInConstant); 5098 } 5099 } 5100 5101 // images (some in compute below) 5102 if ((profile == EEsProfile && version >= 310) || 5103 (profile != EEsProfile && version >= 130)) { 5104 snprintf(builtInConstant, maxSize, "const int gl_MaxImageUnits = %d;", resources.maxImageUnits); 5105 s.append(builtInConstant); 5106 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedShaderOutputResources = %d;", resources.maxCombinedShaderOutputResources); 5107 s.append(builtInConstant); 5108 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexImageUniforms = %d;", resources.maxVertexImageUniforms); 5109 s.append(builtInConstant); 5110 snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentImageUniforms = %d;", resources.maxFragmentImageUniforms); 5111 s.append(builtInConstant); 5112 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedImageUniforms = %d;", resources.maxCombinedImageUniforms); 5113 s.append(builtInConstant); 5114 } 5115 5116 // atomic counters (some in compute below) 5117 if ((profile == EEsProfile && version >= 310) || 5118 (profile != EEsProfile && version >= 420)) { 5119 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAtomicCounters = %d;", resources. maxVertexAtomicCounters); 5120 s.append(builtInConstant); 5121 snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentAtomicCounters = %d;", resources. maxFragmentAtomicCounters); 5122 s.append(builtInConstant); 5123 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedAtomicCounters = %d;", resources. maxCombinedAtomicCounters); 5124 s.append(builtInConstant); 5125 snprintf(builtInConstant, maxSize, "const int gl_MaxAtomicCounterBindings = %d;", resources. maxAtomicCounterBindings); 5126 s.append(builtInConstant); 5127 snprintf(builtInConstant, maxSize, "const int gl_MaxVertexAtomicCounterBuffers = %d;", resources. maxVertexAtomicCounterBuffers); 5128 s.append(builtInConstant); 5129 snprintf(builtInConstant, maxSize, "const int gl_MaxFragmentAtomicCounterBuffers = %d;", resources. maxFragmentAtomicCounterBuffers); 5130 s.append(builtInConstant); 5131 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedAtomicCounterBuffers = %d;", resources. maxCombinedAtomicCounterBuffers); 5132 s.append(builtInConstant); 5133 snprintf(builtInConstant, maxSize, "const int gl_MaxAtomicCounterBufferSize = %d;", resources. maxAtomicCounterBufferSize); 5134 s.append(builtInConstant); 5135 } 5136 if (profile != EEsProfile && version >= 420) { 5137 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounters = %d;", resources. maxTessControlAtomicCounters); 5138 s.append(builtInConstant); 5139 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounters = %d;", resources. maxTessEvaluationAtomicCounters); 5140 s.append(builtInConstant); 5141 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounters = %d;", resources. maxGeometryAtomicCounters); 5142 s.append(builtInConstant); 5143 snprintf(builtInConstant, maxSize, "const int gl_MaxTessControlAtomicCounterBuffers = %d;", resources. maxTessControlAtomicCounterBuffers); 5144 s.append(builtInConstant); 5145 snprintf(builtInConstant, maxSize, "const int gl_MaxTessEvaluationAtomicCounterBuffers = %d;", resources. maxTessEvaluationAtomicCounterBuffers); 5146 s.append(builtInConstant); 5147 snprintf(builtInConstant, maxSize, "const int gl_MaxGeometryAtomicCounterBuffers = %d;", resources. maxGeometryAtomicCounterBuffers); 5148 s.append(builtInConstant); 5149 5150 s.append("\n"); 5151 } 5152 5153 // compute 5154 if ((profile == EEsProfile && version >= 310) || (profile != EEsProfile && version >= 420)) { 5155 snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxComputeWorkGroupCount = ivec3(%d,%d,%d);", resources.maxComputeWorkGroupCountX, 5156 resources.maxComputeWorkGroupCountY, 5157 resources.maxComputeWorkGroupCountZ); 5158 s.append(builtInConstant); 5159 snprintf(builtInConstant, maxSize, "const ivec3 gl_MaxComputeWorkGroupSize = ivec3(%d,%d,%d);", resources.maxComputeWorkGroupSizeX, 5160 resources.maxComputeWorkGroupSizeY, 5161 resources.maxComputeWorkGroupSizeZ); 5162 s.append(builtInConstant); 5163 5164 snprintf(builtInConstant, maxSize, "const int gl_MaxComputeUniformComponents = %d;", resources.maxComputeUniformComponents); 5165 s.append(builtInConstant); 5166 snprintf(builtInConstant, maxSize, "const int gl_MaxComputeTextureImageUnits = %d;", resources.maxComputeTextureImageUnits); 5167 s.append(builtInConstant); 5168 snprintf(builtInConstant, maxSize, "const int gl_MaxComputeImageUniforms = %d;", resources.maxComputeImageUniforms); 5169 s.append(builtInConstant); 5170 snprintf(builtInConstant, maxSize, "const int gl_MaxComputeAtomicCounters = %d;", resources.maxComputeAtomicCounters); 5171 s.append(builtInConstant); 5172 snprintf(builtInConstant, maxSize, "const int gl_MaxComputeAtomicCounterBuffers = %d;", resources.maxComputeAtomicCounterBuffers); 5173 s.append(builtInConstant); 5174 5175 s.append("\n"); 5176 } 5177 5178 // GL_ARB_cull_distance 5179 if (profile != EEsProfile && version >= 450) { 5180 snprintf(builtInConstant, maxSize, "const int gl_MaxCullDistances = %d;", resources.maxCullDistances); 5181 s.append(builtInConstant); 5182 snprintf(builtInConstant, maxSize, "const int gl_MaxCombinedClipAndCullDistances = %d;", resources.maxCombinedClipAndCullDistances); 5183 s.append(builtInConstant); 5184 } 5185 5186 // GL_ARB_ES3_1_compatibility 5187 if ((profile != EEsProfile && version >= 450) || 5188 (profile == EEsProfile && version >= 310)) { 5189 snprintf(builtInConstant, maxSize, "const int gl_MaxSamples = %d;", resources.maxSamples); 5190 s.append(builtInConstant); 5191 } 5192 5193 #ifdef AMD_EXTENSIONS 5194 // GL_AMD_gcn_shader 5195 if (profile != EEsProfile && version >= 450) { 5196 snprintf(builtInConstant, maxSize, "const int gl_SIMDGroupSizeAMD = 64;"); 5197 s.append(builtInConstant); 5198 } 5199 #endif 5200 5201 s.append("\n"); 5202 } 5203 5204 // 5205 // To support special built-ins that have a special qualifier that cannot be declared textually 5206 // in a shader, like gl_Position. 5207 // 5208 // This lets the type of the built-in be declared textually, and then have just its qualifier be 5209 // updated afterward. 5210 // 5211 // Safe to call even if name is not present. 5212 // 5213 // Only use this for built-in variables that have a special qualifier in TStorageQualifier. 5214 // New built-in variables should use a generic (textually declarable) qualifier in 5215 // TStoraregQualifier and only call BuiltInVariable(). 5216 // 5217 static void SpecialQualifier(const char* name, TStorageQualifier qualifier, TBuiltInVariable builtIn, TSymbolTable& symbolTable) 5218 { 5219 TSymbol* symbol = symbolTable.find(name); 5220 if (symbol) { 5221 TQualifier& symQualifier = symbol->getWritableType().getQualifier(); 5222 symQualifier.storage = qualifier; 5223 symQualifier.builtIn = builtIn; 5224 } 5225 } 5226 5227 // 5228 // To tag built-in variables with their TBuiltInVariable enum. Use this when the 5229 // normal declaration text already gets the qualifier right, and all that's needed 5230 // is setting the builtIn field. This should be the normal way for all new 5231 // built-in variables. 5232 // 5233 // If SpecialQualifier() was called, this does not need to be called. 5234 // 5235 // Safe to call even if name is not present. 5236 // 5237 static void BuiltInVariable(const char* name, TBuiltInVariable builtIn, TSymbolTable& symbolTable) 5238 { 5239 TSymbol* symbol = symbolTable.find(name); 5240 if (! symbol) 5241 return; 5242 5243 TQualifier& symQualifier = symbol->getWritableType().getQualifier(); 5244 symQualifier.builtIn = builtIn; 5245 } 5246 5247 // 5248 // For built-in variables inside a named block. 5249 // SpecialQualifier() won't ever go inside a block; their member's qualifier come 5250 // from the qualification of the block. 5251 // 5252 // See comments above for other detail. 5253 // 5254 static void BuiltInVariable(const char* blockName, const char* name, TBuiltInVariable builtIn, TSymbolTable& symbolTable) 5255 { 5256 TSymbol* symbol = symbolTable.find(blockName); 5257 if (! symbol) 5258 return; 5259 5260 TTypeList& structure = *symbol->getWritableType().getWritableStruct(); 5261 for (int i = 0; i < (int)structure.size(); ++i) { 5262 if (structure[i].type->getFieldName().compare(name) == 0) { 5263 structure[i].type->getQualifier().builtIn = builtIn; 5264 return; 5265 } 5266 } 5267 } 5268 5269 // 5270 // Finish adding/processing context-independent built-in symbols. 5271 // 1) Programmatically add symbols that could not be added by simple text strings above. 5272 // 2) Map built-in functions to operators, for those that will turn into an operation node 5273 // instead of remaining a function call. 5274 // 3) Tag extension-related symbols added to their base version with their extensions, so 5275 // that if an early version has the extension turned off, there is an error reported on use. 5276 // 5277 void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable) 5278 { 5279 // 5280 // Tag built-in variables and functions with additional qualifier and extension information 5281 // that cannot be declared with the text strings. 5282 // 5283 5284 // N.B.: a symbol should only be tagged once, and this function is called multiple times, once 5285 // per stage that's used for this profile. So 5286 // - generally, stick common ones in the fragment stage to ensure they are tagged exactly once 5287 // - for ES, which has different precisions for different stages, the coarsest-grained tagging 5288 // for a built-in used in many stages needs to be once for the fragment stage and once for 5289 // the vertex stage 5290 5291 switch(language) { 5292 case EShLangVertex: 5293 if (profile != EEsProfile) { 5294 if (version >= 440) { 5295 symbolTable.setVariableExtensions("gl_BaseVertexARB", 1, &E_GL_ARB_shader_draw_parameters); 5296 symbolTable.setVariableExtensions("gl_BaseInstanceARB", 1, &E_GL_ARB_shader_draw_parameters); 5297 symbolTable.setVariableExtensions("gl_DrawIDARB", 1, &E_GL_ARB_shader_draw_parameters); 5298 BuiltInVariable("gl_BaseVertexARB", EbvBaseVertex, symbolTable); 5299 BuiltInVariable("gl_BaseInstanceARB", EbvBaseInstance, symbolTable); 5300 BuiltInVariable("gl_DrawIDARB", EbvDrawId, symbolTable); 5301 } 5302 if (version >= 460) { 5303 BuiltInVariable("gl_BaseVertex", EbvBaseVertex, symbolTable); 5304 BuiltInVariable("gl_BaseInstance", EbvBaseInstance, symbolTable); 5305 BuiltInVariable("gl_DrawID", EbvDrawId, symbolTable); 5306 } 5307 symbolTable.setVariableExtensions("gl_SubGroupSizeARB", 1, &E_GL_ARB_shader_ballot); 5308 symbolTable.setVariableExtensions("gl_SubGroupInvocationARB", 1, &E_GL_ARB_shader_ballot); 5309 symbolTable.setVariableExtensions("gl_SubGroupEqMaskARB", 1, &E_GL_ARB_shader_ballot); 5310 symbolTable.setVariableExtensions("gl_SubGroupGeMaskARB", 1, &E_GL_ARB_shader_ballot); 5311 symbolTable.setVariableExtensions("gl_SubGroupGtMaskARB", 1, &E_GL_ARB_shader_ballot); 5312 symbolTable.setVariableExtensions("gl_SubGroupLeMaskARB", 1, &E_GL_ARB_shader_ballot); 5313 symbolTable.setVariableExtensions("gl_SubGroupLtMaskARB", 1, &E_GL_ARB_shader_ballot); 5314 5315 symbolTable.setFunctionExtensions("ballotARB", 1, &E_GL_ARB_shader_ballot); 5316 symbolTable.setFunctionExtensions("readInvocationARB", 1, &E_GL_ARB_shader_ballot); 5317 symbolTable.setFunctionExtensions("readFirstInvocationARB", 1, &E_GL_ARB_shader_ballot); 5318 5319 BuiltInVariable("gl_SubGroupInvocationARB", EbvSubGroupInvocation, symbolTable); 5320 BuiltInVariable("gl_SubGroupEqMaskARB", EbvSubGroupEqMask, symbolTable); 5321 BuiltInVariable("gl_SubGroupGeMaskARB", EbvSubGroupGeMask, symbolTable); 5322 BuiltInVariable("gl_SubGroupGtMaskARB", EbvSubGroupGtMask, symbolTable); 5323 BuiltInVariable("gl_SubGroupLeMaskARB", EbvSubGroupLeMask, symbolTable); 5324 BuiltInVariable("gl_SubGroupLtMaskARB", EbvSubGroupLtMask, symbolTable); 5325 5326 if (spvVersion.vulkan >= 100) 5327 // Treat "gl_SubGroupSizeARB" as shader input instead of uniform for Vulkan 5328 SpecialQualifier("gl_SubGroupSizeARB", EvqVaryingIn, EbvSubGroupSize, symbolTable); 5329 5330 if (version >= 430) { 5331 symbolTable.setFunctionExtensions("anyInvocationARB", 1, &E_GL_ARB_shader_group_vote); 5332 symbolTable.setFunctionExtensions("allInvocationsARB", 1, &E_GL_ARB_shader_group_vote); 5333 symbolTable.setFunctionExtensions("allInvocationsEqualARB", 1, &E_GL_ARB_shader_group_vote); 5334 } 5335 } 5336 5337 #ifdef AMD_EXTENSIONS 5338 if (profile != EEsProfile) { 5339 symbolTable.setFunctionExtensions("minInvocationsAMD", 1, &E_GL_AMD_shader_ballot); 5340 symbolTable.setFunctionExtensions("maxInvocationsAMD", 1, &E_GL_AMD_shader_ballot); 5341 symbolTable.setFunctionExtensions("addInvocationsAMD", 1, &E_GL_AMD_shader_ballot); 5342 symbolTable.setFunctionExtensions("minInvocationsNonUniformAMD", 1, &E_GL_AMD_shader_ballot); 5343 symbolTable.setFunctionExtensions("maxInvocationsNonUniformAMD", 1, &E_GL_AMD_shader_ballot); 5344 symbolTable.setFunctionExtensions("addInvocationsNonUniformAMD", 1, &E_GL_AMD_shader_ballot); 5345 symbolTable.setFunctionExtensions("swizzleInvocationsAMD", 1, &E_GL_AMD_shader_ballot); 5346 symbolTable.setFunctionExtensions("swizzleInvocationsWithPatternAMD", 1, &E_GL_AMD_shader_ballot); 5347 symbolTable.setFunctionExtensions("writeInvocationAMD", 1, &E_GL_AMD_shader_ballot); 5348 symbolTable.setFunctionExtensions("mbcntAMD", 1, &E_GL_AMD_shader_ballot); 5349 5350 symbolTable.setFunctionExtensions("minInvocationsInclusiveScanAMD", 1, &E_GL_AMD_shader_ballot); 5351 symbolTable.setFunctionExtensions("maxInvocationsInclusiveScanAMD", 1, &E_GL_AMD_shader_ballot); 5352 symbolTable.setFunctionExtensions("addInvocationsInclusiveScanAMD", 1, &E_GL_AMD_shader_ballot); 5353 symbolTable.setFunctionExtensions("minInvocationsInclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot); 5354 symbolTable.setFunctionExtensions("maxInvocationsInclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot); 5355 symbolTable.setFunctionExtensions("addInvocationsInclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot); 5356 symbolTable.setFunctionExtensions("minInvocationsExclusiveScanAMD", 1, &E_GL_AMD_shader_ballot); 5357 symbolTable.setFunctionExtensions("maxInvocationsExclusiveScanAMD", 1, &E_GL_AMD_shader_ballot); 5358 symbolTable.setFunctionExtensions("addInvocationsExclusiveScanAMD", 1, &E_GL_AMD_shader_ballot); 5359 symbolTable.setFunctionExtensions("minInvocationsExclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot); 5360 symbolTable.setFunctionExtensions("maxInvocationsExclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot); 5361 symbolTable.setFunctionExtensions("addInvocationsExclusiveScanNonUniformAMD", 1, &E_GL_AMD_shader_ballot); 5362 } 5363 5364 if (profile != EEsProfile) { 5365 symbolTable.setFunctionExtensions("min3", 1, &E_GL_AMD_shader_trinary_minmax); 5366 symbolTable.setFunctionExtensions("max3", 1, &E_GL_AMD_shader_trinary_minmax); 5367 symbolTable.setFunctionExtensions("mid3", 1, &E_GL_AMD_shader_trinary_minmax); 5368 } 5369 5370 if (profile != EEsProfile) { 5371 symbolTable.setFunctionExtensions("cubeFaceIndexAMD", 1, &E_GL_AMD_gcn_shader); 5372 symbolTable.setFunctionExtensions("cubeFaceCoordAMD", 1, &E_GL_AMD_gcn_shader); 5373 symbolTable.setFunctionExtensions("timeAMD", 1, &E_GL_AMD_gcn_shader); 5374 } 5375 #endif 5376 5377 // Compatibility variables, vertex only 5378 if (spvVersion.spv == 0) { 5379 BuiltInVariable("gl_Color", EbvColor, symbolTable); 5380 BuiltInVariable("gl_SecondaryColor", EbvSecondaryColor, symbolTable); 5381 BuiltInVariable("gl_Normal", EbvNormal, symbolTable); 5382 BuiltInVariable("gl_Vertex", EbvVertex, symbolTable); 5383 BuiltInVariable("gl_MultiTexCoord0", EbvMultiTexCoord0, symbolTable); 5384 BuiltInVariable("gl_MultiTexCoord1", EbvMultiTexCoord1, symbolTable); 5385 BuiltInVariable("gl_MultiTexCoord2", EbvMultiTexCoord2, symbolTable); 5386 BuiltInVariable("gl_MultiTexCoord3", EbvMultiTexCoord3, symbolTable); 5387 BuiltInVariable("gl_MultiTexCoord4", EbvMultiTexCoord4, symbolTable); 5388 BuiltInVariable("gl_MultiTexCoord5", EbvMultiTexCoord5, symbolTable); 5389 BuiltInVariable("gl_MultiTexCoord6", EbvMultiTexCoord6, symbolTable); 5390 BuiltInVariable("gl_MultiTexCoord7", EbvMultiTexCoord7, symbolTable); 5391 BuiltInVariable("gl_FogCoord", EbvFogFragCoord, symbolTable); 5392 } 5393 5394 if (profile == EEsProfile) { 5395 if (spvVersion.spv == 0) { 5396 symbolTable.setFunctionExtensions("texture2DGradEXT", 1, &E_GL_EXT_shader_texture_lod); 5397 symbolTable.setFunctionExtensions("texture2DProjGradEXT", 1, &E_GL_EXT_shader_texture_lod); 5398 symbolTable.setFunctionExtensions("textureCubeGradEXT", 1, &E_GL_EXT_shader_texture_lod); 5399 if (version == 310) 5400 symbolTable.setFunctionExtensions("textureGatherOffsets", Num_AEP_gpu_shader5, AEP_gpu_shader5); 5401 } 5402 if (version == 310) 5403 symbolTable.setFunctionExtensions("fma", Num_AEP_gpu_shader5, AEP_gpu_shader5); 5404 } 5405 5406 if (profile == EEsProfile && version < 320) { 5407 symbolTable.setFunctionExtensions("imageAtomicAdd", 1, &E_GL_OES_shader_image_atomic); 5408 symbolTable.setFunctionExtensions("imageAtomicMin", 1, &E_GL_OES_shader_image_atomic); 5409 symbolTable.setFunctionExtensions("imageAtomicMax", 1, &E_GL_OES_shader_image_atomic); 5410 symbolTable.setFunctionExtensions("imageAtomicAnd", 1, &E_GL_OES_shader_image_atomic); 5411 symbolTable.setFunctionExtensions("imageAtomicOr", 1, &E_GL_OES_shader_image_atomic); 5412 symbolTable.setFunctionExtensions("imageAtomicXor", 1, &E_GL_OES_shader_image_atomic); 5413 symbolTable.setFunctionExtensions("imageAtomicExchange", 1, &E_GL_OES_shader_image_atomic); 5414 symbolTable.setFunctionExtensions("imageAtomicCompSwap", 1, &E_GL_OES_shader_image_atomic); 5415 } 5416 5417 if (spvVersion.vulkan == 0) { 5418 SpecialQualifier("gl_VertexID", EvqVertexId, EbvVertexId, symbolTable); 5419 SpecialQualifier("gl_InstanceID", EvqInstanceId, EbvInstanceId, symbolTable); 5420 } 5421 5422 if (spvVersion.vulkan >= 100) { 5423 BuiltInVariable("gl_VertexIndex", EbvVertexIndex, symbolTable); 5424 BuiltInVariable("gl_InstanceIndex", EbvInstanceIndex, symbolTable); 5425 } 5426 5427 if (version >= 300 /* both ES and non-ES */) { 5428 symbolTable.setVariableExtensions("gl_ViewID_OVR", Num_OVR_multiview_EXTs, OVR_multiview_EXTs); 5429 BuiltInVariable("gl_ViewID_OVR", EbvViewIndex, symbolTable); 5430 } 5431 5432 if (profile == EEsProfile) { 5433 symbolTable.setFunctionExtensions("shadow2DEXT", 1, &E_GL_EXT_shadow_samplers); 5434 symbolTable.setFunctionExtensions("shadow2DProjEXT", 1, &E_GL_EXT_shadow_samplers); 5435 } 5436 5437 // Fall through 5438 5439 case EShLangTessControl: 5440 if (profile == EEsProfile && version >= 310) { 5441 BuiltInVariable("gl_BoundingBoxOES", EbvBoundingBox, symbolTable); 5442 if (version < 320) 5443 symbolTable.setVariableExtensions("gl_BoundingBoxOES", Num_AEP_primitive_bounding_box, 5444 AEP_primitive_bounding_box); 5445 } 5446 5447 // Fall through 5448 5449 case EShLangTessEvaluation: 5450 case EShLangGeometry: 5451 SpecialQualifier("gl_Position", EvqPosition, EbvPosition, symbolTable); 5452 SpecialQualifier("gl_PointSize", EvqPointSize, EbvPointSize, symbolTable); 5453 SpecialQualifier("gl_ClipVertex", EvqClipVertex, EbvClipVertex, symbolTable); 5454 5455 BuiltInVariable("gl_in", "gl_Position", EbvPosition, symbolTable); 5456 BuiltInVariable("gl_in", "gl_PointSize", EbvPointSize, symbolTable); 5457 BuiltInVariable("gl_in", "gl_ClipDistance", EbvClipDistance, symbolTable); 5458 BuiltInVariable("gl_in", "gl_CullDistance", EbvCullDistance, symbolTable); 5459 5460 BuiltInVariable("gl_out", "gl_Position", EbvPosition, symbolTable); 5461 BuiltInVariable("gl_out", "gl_PointSize", EbvPointSize, symbolTable); 5462 BuiltInVariable("gl_out", "gl_ClipDistance", EbvClipDistance, symbolTable); 5463 BuiltInVariable("gl_out", "gl_CullDistance", EbvCullDistance, symbolTable); 5464 5465 BuiltInVariable("gl_ClipDistance", EbvClipDistance, symbolTable); 5466 BuiltInVariable("gl_CullDistance", EbvCullDistance, symbolTable); 5467 BuiltInVariable("gl_PrimitiveIDIn", EbvPrimitiveId, symbolTable); 5468 BuiltInVariable("gl_PrimitiveID", EbvPrimitiveId, symbolTable); 5469 BuiltInVariable("gl_InvocationID", EbvInvocationId, symbolTable); 5470 BuiltInVariable("gl_Layer", EbvLayer, symbolTable); 5471 BuiltInVariable("gl_ViewportIndex", EbvViewportIndex, symbolTable); 5472 5473 #ifdef NV_EXTENSIONS 5474 if (language != EShLangGeometry) { 5475 symbolTable.setVariableExtensions("gl_Layer", Num_viewportEXTs, viewportEXTs); 5476 symbolTable.setVariableExtensions("gl_ViewportIndex", Num_viewportEXTs, viewportEXTs); 5477 } 5478 #else 5479 if (language == EShLangVertex || language == EShLangTessEvaluation) { 5480 symbolTable.setVariableExtensions("gl_Layer", 1, &E_GL_ARB_shader_viewport_layer_array); 5481 symbolTable.setVariableExtensions("gl_ViewportIndex", 1, &E_GL_ARB_shader_viewport_layer_array); 5482 } 5483 #endif 5484 5485 #ifdef NV_EXTENSIONS 5486 symbolTable.setVariableExtensions("gl_ViewportMask", 1, &E_GL_NV_viewport_array2); 5487 symbolTable.setVariableExtensions("gl_SecondaryPositionNV", 1, &E_GL_NV_stereo_view_rendering); 5488 symbolTable.setVariableExtensions("gl_SecondaryViewportMaskNV", 1, &E_GL_NV_stereo_view_rendering); 5489 symbolTable.setVariableExtensions("gl_PositionPerViewNV", 1, &E_GL_NVX_multiview_per_view_attributes); 5490 symbolTable.setVariableExtensions("gl_ViewportMaskPerViewNV", 1, &E_GL_NVX_multiview_per_view_attributes); 5491 5492 BuiltInVariable("gl_ViewportMask", EbvViewportMaskNV, symbolTable); 5493 BuiltInVariable("gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable); 5494 BuiltInVariable("gl_SecondaryViewportMaskNV", EbvSecondaryViewportMaskNV, symbolTable); 5495 BuiltInVariable("gl_PositionPerViewNV", EbvPositionPerViewNV, symbolTable); 5496 BuiltInVariable("gl_ViewportMaskPerViewNV", EbvViewportMaskPerViewNV, symbolTable); 5497 5498 if (language != EShLangVertex) { 5499 BuiltInVariable("gl_in", "gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable); 5500 BuiltInVariable("gl_in", "gl_PositionPerViewNV", EbvPositionPerViewNV, symbolTable); 5501 } 5502 BuiltInVariable("gl_out", "gl_Layer", EbvLayer, symbolTable); 5503 BuiltInVariable("gl_out", "gl_ViewportIndex", EbvViewportIndex, symbolTable); 5504 BuiltInVariable("gl_out", "gl_ViewportMask", EbvViewportMaskNV, symbolTable); 5505 BuiltInVariable("gl_out", "gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable); 5506 BuiltInVariable("gl_out", "gl_SecondaryViewportMaskNV", EbvSecondaryViewportMaskNV, symbolTable); 5507 BuiltInVariable("gl_out", "gl_PositionPerViewNV", EbvPositionPerViewNV, symbolTable); 5508 BuiltInVariable("gl_out", "gl_ViewportMaskPerViewNV", EbvViewportMaskPerViewNV, symbolTable); 5509 #endif 5510 5511 BuiltInVariable("gl_PatchVerticesIn", EbvPatchVertices, symbolTable); 5512 BuiltInVariable("gl_TessLevelOuter", EbvTessLevelOuter, symbolTable); 5513 BuiltInVariable("gl_TessLevelInner", EbvTessLevelInner, symbolTable); 5514 BuiltInVariable("gl_TessCoord", EbvTessCoord, symbolTable); 5515 5516 if (version < 410) 5517 symbolTable.setVariableExtensions("gl_ViewportIndex", 1, &E_GL_ARB_viewport_array); 5518 5519 // Compatibility variables 5520 5521 BuiltInVariable("gl_in", "gl_ClipVertex", EbvClipVertex, symbolTable); 5522 BuiltInVariable("gl_in", "gl_FrontColor", EbvFrontColor, symbolTable); 5523 BuiltInVariable("gl_in", "gl_BackColor", EbvBackColor, symbolTable); 5524 BuiltInVariable("gl_in", "gl_FrontSecondaryColor", EbvFrontSecondaryColor, symbolTable); 5525 BuiltInVariable("gl_in", "gl_BackSecondaryColor", EbvBackSecondaryColor, symbolTable); 5526 BuiltInVariable("gl_in", "gl_TexCoord", EbvTexCoord, symbolTable); 5527 BuiltInVariable("gl_in", "gl_FogFragCoord", EbvFogFragCoord, symbolTable); 5528 5529 BuiltInVariable("gl_out", "gl_ClipVertex", EbvClipVertex, symbolTable); 5530 BuiltInVariable("gl_out", "gl_FrontColor", EbvFrontColor, symbolTable); 5531 BuiltInVariable("gl_out", "gl_BackColor", EbvBackColor, symbolTable); 5532 BuiltInVariable("gl_out", "gl_FrontSecondaryColor", EbvFrontSecondaryColor, symbolTable); 5533 BuiltInVariable("gl_out", "gl_BackSecondaryColor", EbvBackSecondaryColor, symbolTable); 5534 BuiltInVariable("gl_out", "gl_TexCoord", EbvTexCoord, symbolTable); 5535 BuiltInVariable("gl_out", "gl_FogFragCoord", EbvFogFragCoord, symbolTable); 5536 5537 BuiltInVariable("gl_ClipVertex", EbvClipVertex, symbolTable); 5538 BuiltInVariable("gl_FrontColor", EbvFrontColor, symbolTable); 5539 BuiltInVariable("gl_BackColor", EbvBackColor, symbolTable); 5540 BuiltInVariable("gl_FrontSecondaryColor", EbvFrontSecondaryColor, symbolTable); 5541 BuiltInVariable("gl_BackSecondaryColor", EbvBackSecondaryColor, symbolTable); 5542 BuiltInVariable("gl_TexCoord", EbvTexCoord, symbolTable); 5543 BuiltInVariable("gl_FogFragCoord", EbvFogFragCoord, symbolTable); 5544 5545 // gl_PointSize, when it needs to be tied to an extension, is always a member of a block. 5546 // (Sometimes with an instance name, sometimes anonymous). 5547 // However, the current automatic extension scheme does not work per block member, 5548 // so for now check when parsing. 5549 // 5550 // if (profile == EEsProfile) { 5551 // if (language == EShLangGeometry) 5552 // symbolTable.setVariableExtensions("gl_PointSize", Num_AEP_geometry_point_size, AEP_geometry_point_size); 5553 // else if (language == EShLangTessEvaluation || language == EShLangTessControl) 5554 // symbolTable.setVariableExtensions("gl_PointSize", Num_AEP_tessellation_point_size, AEP_tessellation_point_size); 5555 //} 5556 5557 if ((profile != EEsProfile && version >= 140) || 5558 (profile == EEsProfile && version >= 310)) { 5559 symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group); 5560 BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable); 5561 symbolTable.setVariableExtensions("gl_ViewIndex", 1, &E_GL_EXT_multiview); 5562 BuiltInVariable("gl_ViewIndex", EbvViewIndex, symbolTable); 5563 } 5564 5565 break; 5566 5567 case EShLangFragment: 5568 SpecialQualifier("gl_FrontFacing", EvqFace, EbvFace, symbolTable); 5569 SpecialQualifier("gl_FragCoord", EvqFragCoord, EbvFragCoord, symbolTable); 5570 SpecialQualifier("gl_PointCoord", EvqPointCoord, EbvPointCoord, symbolTable); 5571 if (spvVersion.spv == 0) 5572 SpecialQualifier("gl_FragColor", EvqFragColor, EbvFragColor, symbolTable); 5573 else { 5574 TSymbol* symbol = symbolTable.find("gl_FragColor"); 5575 if (symbol) { 5576 symbol->getWritableType().getQualifier().storage = EvqVaryingOut; 5577 symbol->getWritableType().getQualifier().layoutLocation = 0; 5578 } 5579 } 5580 SpecialQualifier("gl_FragDepth", EvqFragDepth, EbvFragDepth, symbolTable); 5581 SpecialQualifier("gl_FragDepthEXT", EvqFragDepth, EbvFragDepth, symbolTable); 5582 SpecialQualifier("gl_HelperInvocation", EvqVaryingIn, EbvHelperInvocation, symbolTable); 5583 5584 BuiltInVariable("gl_ClipDistance", EbvClipDistance, symbolTable); 5585 BuiltInVariable("gl_CullDistance", EbvCullDistance, symbolTable); 5586 BuiltInVariable("gl_PrimitiveID", EbvPrimitiveId, symbolTable); 5587 5588 if (profile != EEsProfile && version >= 140) { 5589 symbolTable.setVariableExtensions("gl_FragStencilRefARB", 1, &E_GL_ARB_shader_stencil_export); 5590 BuiltInVariable("gl_FragStencilRefARB", EbvFragStencilRef, symbolTable); 5591 } 5592 5593 if ((profile != EEsProfile && version >= 400) || 5594 (profile == EEsProfile && version >= 310)) { 5595 BuiltInVariable("gl_SampleID", EbvSampleId, symbolTable); 5596 BuiltInVariable("gl_SamplePosition", EbvSamplePosition, symbolTable); 5597 BuiltInVariable("gl_SampleMaskIn", EbvSampleMask, symbolTable); 5598 BuiltInVariable("gl_SampleMask", EbvSampleMask, symbolTable); 5599 if (profile == EEsProfile && version < 320) { 5600 symbolTable.setVariableExtensions("gl_SampleID", 1, &E_GL_OES_sample_variables); 5601 symbolTable.setVariableExtensions("gl_SamplePosition", 1, &E_GL_OES_sample_variables); 5602 symbolTable.setVariableExtensions("gl_SampleMaskIn", 1, &E_GL_OES_sample_variables); 5603 symbolTable.setVariableExtensions("gl_SampleMask", 1, &E_GL_OES_sample_variables); 5604 symbolTable.setVariableExtensions("gl_NumSamples", 1, &E_GL_OES_sample_variables); 5605 } 5606 } 5607 5608 BuiltInVariable("gl_Layer", EbvLayer, symbolTable); 5609 BuiltInVariable("gl_ViewportIndex", EbvViewportIndex, symbolTable); 5610 5611 // Compatibility variables 5612 5613 BuiltInVariable("gl_in", "gl_FogFragCoord", EbvFogFragCoord, symbolTable); 5614 BuiltInVariable("gl_in", "gl_TexCoord", EbvTexCoord, symbolTable); 5615 BuiltInVariable("gl_in", "gl_Color", EbvColor, symbolTable); 5616 BuiltInVariable("gl_in", "gl_SecondaryColor", EbvSecondaryColor, symbolTable); 5617 5618 BuiltInVariable("gl_FogFragCoord", EbvFogFragCoord, symbolTable); 5619 BuiltInVariable("gl_TexCoord", EbvTexCoord, symbolTable); 5620 BuiltInVariable("gl_Color", EbvColor, symbolTable); 5621 BuiltInVariable("gl_SecondaryColor", EbvSecondaryColor, symbolTable); 5622 5623 // built-in functions 5624 5625 if (profile == EEsProfile) { 5626 if (spvVersion.spv == 0) { 5627 symbolTable.setFunctionExtensions("texture2DLodEXT", 1, &E_GL_EXT_shader_texture_lod); 5628 symbolTable.setFunctionExtensions("texture2DProjLodEXT", 1, &E_GL_EXT_shader_texture_lod); 5629 symbolTable.setFunctionExtensions("textureCubeLodEXT", 1, &E_GL_EXT_shader_texture_lod); 5630 symbolTable.setFunctionExtensions("texture2DGradEXT", 1, &E_GL_EXT_shader_texture_lod); 5631 symbolTable.setFunctionExtensions("texture2DProjGradEXT", 1, &E_GL_EXT_shader_texture_lod); 5632 symbolTable.setFunctionExtensions("textureCubeGradEXT", 1, &E_GL_EXT_shader_texture_lod); 5633 if (version < 320) 5634 symbolTable.setFunctionExtensions("textureGatherOffsets", Num_AEP_gpu_shader5, AEP_gpu_shader5); 5635 } 5636 if (version == 100) { 5637 symbolTable.setFunctionExtensions("dFdx", 1, &E_GL_OES_standard_derivatives); 5638 symbolTable.setFunctionExtensions("dFdy", 1, &E_GL_OES_standard_derivatives); 5639 symbolTable.setFunctionExtensions("fwidth", 1, &E_GL_OES_standard_derivatives); 5640 } 5641 if (version == 310) { 5642 symbolTable.setFunctionExtensions("fma", Num_AEP_gpu_shader5, AEP_gpu_shader5); 5643 symbolTable.setFunctionExtensions("interpolateAtCentroid", 1, &E_GL_OES_shader_multisample_interpolation); 5644 symbolTable.setFunctionExtensions("interpolateAtSample", 1, &E_GL_OES_shader_multisample_interpolation); 5645 symbolTable.setFunctionExtensions("interpolateAtOffset", 1, &E_GL_OES_shader_multisample_interpolation); 5646 } 5647 } else if (version < 130) { 5648 if (spvVersion.spv == 0) { 5649 symbolTable.setFunctionExtensions("texture1DLod", 1, &E_GL_ARB_shader_texture_lod); 5650 symbolTable.setFunctionExtensions("texture2DLod", 1, &E_GL_ARB_shader_texture_lod); 5651 symbolTable.setFunctionExtensions("texture3DLod", 1, &E_GL_ARB_shader_texture_lod); 5652 symbolTable.setFunctionExtensions("textureCubeLod", 1, &E_GL_ARB_shader_texture_lod); 5653 symbolTable.setFunctionExtensions("texture1DProjLod", 1, &E_GL_ARB_shader_texture_lod); 5654 symbolTable.setFunctionExtensions("texture2DProjLod", 1, &E_GL_ARB_shader_texture_lod); 5655 symbolTable.setFunctionExtensions("texture3DProjLod", 1, &E_GL_ARB_shader_texture_lod); 5656 symbolTable.setFunctionExtensions("shadow1DLod", 1, &E_GL_ARB_shader_texture_lod); 5657 symbolTable.setFunctionExtensions("shadow2DLod", 1, &E_GL_ARB_shader_texture_lod); 5658 symbolTable.setFunctionExtensions("shadow1DProjLod", 1, &E_GL_ARB_shader_texture_lod); 5659 symbolTable.setFunctionExtensions("shadow2DProjLod", 1, &E_GL_ARB_shader_texture_lod); 5660 } 5661 } 5662 5663 // E_GL_ARB_shader_texture_lod functions usable only with the extension enabled 5664 if (profile != EEsProfile && spvVersion.spv == 0) { 5665 symbolTable.setFunctionExtensions("texture1DGradARB", 1, &E_GL_ARB_shader_texture_lod); 5666 symbolTable.setFunctionExtensions("texture1DProjGradARB", 1, &E_GL_ARB_shader_texture_lod); 5667 symbolTable.setFunctionExtensions("texture2DGradARB", 1, &E_GL_ARB_shader_texture_lod); 5668 symbolTable.setFunctionExtensions("texture2DProjGradARB", 1, &E_GL_ARB_shader_texture_lod); 5669 symbolTable.setFunctionExtensions("texture3DGradARB", 1, &E_GL_ARB_shader_texture_lod); 5670 symbolTable.setFunctionExtensions("texture3DProjGradARB", 1, &E_GL_ARB_shader_texture_lod); 5671 symbolTable.setFunctionExtensions("textureCubeGradARB", 1, &E_GL_ARB_shader_texture_lod); 5672 symbolTable.setFunctionExtensions("shadow1DGradARB", 1, &E_GL_ARB_shader_texture_lod); 5673 symbolTable.setFunctionExtensions("shadow1DProjGradARB", 1, &E_GL_ARB_shader_texture_lod); 5674 symbolTable.setFunctionExtensions("shadow2DGradARB", 1, &E_GL_ARB_shader_texture_lod); 5675 symbolTable.setFunctionExtensions("shadow2DProjGradARB", 1, &E_GL_ARB_shader_texture_lod); 5676 symbolTable.setFunctionExtensions("texture2DRectGradARB", 1, &E_GL_ARB_shader_texture_lod); 5677 symbolTable.setFunctionExtensions("texture2DRectProjGradARB", 1, &E_GL_ARB_shader_texture_lod); 5678 symbolTable.setFunctionExtensions("shadow2DRectGradARB", 1, &E_GL_ARB_shader_texture_lod); 5679 symbolTable.setFunctionExtensions("shadow2DRectProjGradARB", 1, &E_GL_ARB_shader_texture_lod); 5680 } 5681 5682 // E_GL_ARB_shader_image_load_store 5683 if (profile != EEsProfile && version < 420) 5684 symbolTable.setFunctionExtensions("memoryBarrier", 1, &E_GL_ARB_shader_image_load_store); 5685 // All the image access functions are protected by checks on the type of the first argument. 5686 5687 // E_GL_ARB_shader_atomic_counters 5688 if (profile != EEsProfile && version < 420) { 5689 symbolTable.setFunctionExtensions("atomicCounterIncrement", 1, &E_GL_ARB_shader_atomic_counters); 5690 symbolTable.setFunctionExtensions("atomicCounterDecrement", 1, &E_GL_ARB_shader_atomic_counters); 5691 symbolTable.setFunctionExtensions("atomicCounter" , 1, &E_GL_ARB_shader_atomic_counters); 5692 } 5693 5694 // E_GL_ARB_derivative_control 5695 if (profile != EEsProfile && version < 450) { 5696 symbolTable.setFunctionExtensions("dFdxFine", 1, &E_GL_ARB_derivative_control); 5697 symbolTable.setFunctionExtensions("dFdyFine", 1, &E_GL_ARB_derivative_control); 5698 symbolTable.setFunctionExtensions("fwidthFine", 1, &E_GL_ARB_derivative_control); 5699 symbolTable.setFunctionExtensions("dFdxCoarse", 1, &E_GL_ARB_derivative_control); 5700 symbolTable.setFunctionExtensions("dFdyCoarse", 1, &E_GL_ARB_derivative_control); 5701 symbolTable.setFunctionExtensions("fwidthCoarse", 1, &E_GL_ARB_derivative_control); 5702 } 5703 5704 // E_GL_ARB_sparse_texture2 5705 if (profile != EEsProfile) 5706 { 5707 symbolTable.setFunctionExtensions("sparseTextureARB", 1, &E_GL_ARB_sparse_texture2); 5708 symbolTable.setFunctionExtensions("sparseTextureLodARB", 1, &E_GL_ARB_sparse_texture2); 5709 symbolTable.setFunctionExtensions("sparseTextureOffsetARB", 1, &E_GL_ARB_sparse_texture2); 5710 symbolTable.setFunctionExtensions("sparseTexelFetchARB", 1, &E_GL_ARB_sparse_texture2); 5711 symbolTable.setFunctionExtensions("sparseTexelFetchOffsetARB", 1, &E_GL_ARB_sparse_texture2); 5712 symbolTable.setFunctionExtensions("sparseTextureLodOffsetARB", 1, &E_GL_ARB_sparse_texture2); 5713 symbolTable.setFunctionExtensions("sparseTextureGradARB", 1, &E_GL_ARB_sparse_texture2); 5714 symbolTable.setFunctionExtensions("sparseTextureGradOffsetARB", 1, &E_GL_ARB_sparse_texture2); 5715 symbolTable.setFunctionExtensions("sparseTextureGatherARB", 1, &E_GL_ARB_sparse_texture2); 5716 symbolTable.setFunctionExtensions("sparseTextureGatherOffsetARB", 1, &E_GL_ARB_sparse_texture2); 5717 symbolTable.setFunctionExtensions("sparseTextureGatherOffsetsARB", 1, &E_GL_ARB_sparse_texture2); 5718 symbolTable.setFunctionExtensions("sparseImageLoadARB", 1, &E_GL_ARB_sparse_texture2); 5719 symbolTable.setFunctionExtensions("sparseTexelsResident", 1, &E_GL_ARB_sparse_texture2); 5720 } 5721 5722 // E_GL_ARB_sparse_texture_clamp 5723 if (profile != EEsProfile) 5724 { 5725 symbolTable.setFunctionExtensions("sparseTextureClampARB", 1, &E_GL_ARB_sparse_texture_clamp); 5726 symbolTable.setFunctionExtensions("sparseTextureOffsetClampARB", 1, &E_GL_ARB_sparse_texture_clamp); 5727 symbolTable.setFunctionExtensions("sparseTextureGradClampARB", 1, &E_GL_ARB_sparse_texture_clamp); 5728 symbolTable.setFunctionExtensions("sparseTextureGradOffsetClampARB", 1, &E_GL_ARB_sparse_texture_clamp); 5729 symbolTable.setFunctionExtensions("textureClampARB", 1, &E_GL_ARB_sparse_texture_clamp); 5730 symbolTable.setFunctionExtensions("textureOffsetClampARB", 1, &E_GL_ARB_sparse_texture_clamp); 5731 symbolTable.setFunctionExtensions("textureGradClampARB", 1, &E_GL_ARB_sparse_texture_clamp); 5732 symbolTable.setFunctionExtensions("textureGradOffsetClampARB", 1, &E_GL_ARB_sparse_texture_clamp); 5733 } 5734 5735 #ifdef AMD_EXTENSIONS 5736 // E_GL_AMD_shader_explicit_vertex_parameter 5737 if (profile != EEsProfile) { 5738 symbolTable.setVariableExtensions("gl_BaryCoordNoPerspAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter); 5739 symbolTable.setVariableExtensions("gl_BaryCoordNoPerspCentroidAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter); 5740 symbolTable.setVariableExtensions("gl_BaryCoordNoPerspSampleAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter); 5741 symbolTable.setVariableExtensions("gl_BaryCoordSmoothAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter); 5742 symbolTable.setVariableExtensions("gl_BaryCoordSmoothCentroidAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter); 5743 symbolTable.setVariableExtensions("gl_BaryCoordSmoothSampleAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter); 5744 symbolTable.setVariableExtensions("gl_BaryCoordPullModelAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter); 5745 5746 symbolTable.setFunctionExtensions("interpolateAtVertexAMD", 1, &E_GL_AMD_shader_explicit_vertex_parameter); 5747 5748 BuiltInVariable("gl_BaryCoordNoPerspAMD", EbvBaryCoordNoPersp, symbolTable); 5749 BuiltInVariable("gl_BaryCoordNoPerspCentroidAMD", EbvBaryCoordNoPerspCentroid, symbolTable); 5750 BuiltInVariable("gl_BaryCoordNoPerspSampleAMD", EbvBaryCoordNoPerspSample, symbolTable); 5751 BuiltInVariable("gl_BaryCoordSmoothAMD", EbvBaryCoordSmooth, symbolTable); 5752 BuiltInVariable("gl_BaryCoordSmoothCentroidAMD", EbvBaryCoordSmoothCentroid, symbolTable); 5753 BuiltInVariable("gl_BaryCoordSmoothSampleAMD", EbvBaryCoordSmoothSample, symbolTable); 5754 BuiltInVariable("gl_BaryCoordPullModelAMD", EbvBaryCoordPullModel, symbolTable); 5755 } 5756 5757 // E_GL_AMD_texture_gather_bias_lod 5758 if (profile != EEsProfile) { 5759 symbolTable.setFunctionExtensions("textureGatherLodAMD", 1, &E_GL_AMD_texture_gather_bias_lod); 5760 symbolTable.setFunctionExtensions("textureGatherLodOffsetAMD", 1, &E_GL_AMD_texture_gather_bias_lod); 5761 symbolTable.setFunctionExtensions("textureGatherLodOffsetsAMD", 1, &E_GL_AMD_texture_gather_bias_lod); 5762 symbolTable.setFunctionExtensions("sparseTextureGatherLodAMD", 1, &E_GL_AMD_texture_gather_bias_lod); 5763 symbolTable.setFunctionExtensions("sparseTextureGatherLodOffsetAMD", 1, &E_GL_AMD_texture_gather_bias_lod); 5764 symbolTable.setFunctionExtensions("sparseTextureGatherLodOffsetsAMD", 1, &E_GL_AMD_texture_gather_bias_lod); 5765 } 5766 5767 // E_GL_AMD_shader_image_load_store_lod 5768 if (profile != EEsProfile) { 5769 symbolTable.setFunctionExtensions("imageLoadLodAMD", 1, &E_GL_AMD_shader_image_load_store_lod); 5770 symbolTable.setFunctionExtensions("imageStoreLodAMD", 1, &E_GL_AMD_shader_image_load_store_lod); 5771 symbolTable.setFunctionExtensions("sparseImageLoadLodAMD", 1, &E_GL_AMD_shader_image_load_store_lod); 5772 } 5773 #endif 5774 5775 symbolTable.setVariableExtensions("gl_FragDepthEXT", 1, &E_GL_EXT_frag_depth); 5776 5777 if (profile == EEsProfile && version < 320) { 5778 symbolTable.setVariableExtensions("gl_PrimitiveID", Num_AEP_geometry_shader, AEP_geometry_shader); 5779 symbolTable.setVariableExtensions("gl_Layer", Num_AEP_geometry_shader, AEP_geometry_shader); 5780 } 5781 5782 if (profile == EEsProfile && version < 320) { 5783 symbolTable.setFunctionExtensions("imageAtomicAdd", 1, &E_GL_OES_shader_image_atomic); 5784 symbolTable.setFunctionExtensions("imageAtomicMin", 1, &E_GL_OES_shader_image_atomic); 5785 symbolTable.setFunctionExtensions("imageAtomicMax", 1, &E_GL_OES_shader_image_atomic); 5786 symbolTable.setFunctionExtensions("imageAtomicAnd", 1, &E_GL_OES_shader_image_atomic); 5787 symbolTable.setFunctionExtensions("imageAtomicOr", 1, &E_GL_OES_shader_image_atomic); 5788 symbolTable.setFunctionExtensions("imageAtomicXor", 1, &E_GL_OES_shader_image_atomic); 5789 symbolTable.setFunctionExtensions("imageAtomicExchange", 1, &E_GL_OES_shader_image_atomic); 5790 symbolTable.setFunctionExtensions("imageAtomicCompSwap", 1, &E_GL_OES_shader_image_atomic); 5791 } 5792 5793 symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group); 5794 BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable); 5795 symbolTable.setVariableExtensions("gl_ViewIndex", 1, &E_GL_EXT_multiview); 5796 BuiltInVariable("gl_ViewIndex", EbvViewIndex, symbolTable); 5797 if (version >= 300 /* both ES and non-ES */) { 5798 symbolTable.setVariableExtensions("gl_ViewID_OVR", Num_OVR_multiview_EXTs, OVR_multiview_EXTs); 5799 BuiltInVariable("gl_ViewID_OVR", EbvViewIndex, symbolTable); 5800 } 5801 5802 if (profile == EEsProfile) { 5803 symbolTable.setFunctionExtensions("shadow2DEXT", 1, &E_GL_EXT_shadow_samplers); 5804 symbolTable.setFunctionExtensions("shadow2DProjEXT", 1, &E_GL_EXT_shadow_samplers); 5805 } 5806 break; 5807 5808 case EShLangCompute: 5809 BuiltInVariable("gl_NumWorkGroups", EbvNumWorkGroups, symbolTable); 5810 BuiltInVariable("gl_WorkGroupSize", EbvWorkGroupSize, symbolTable); 5811 BuiltInVariable("gl_WorkGroupID", EbvWorkGroupId, symbolTable); 5812 BuiltInVariable("gl_LocalInvocationID", EbvLocalInvocationId, symbolTable); 5813 BuiltInVariable("gl_GlobalInvocationID", EbvGlobalInvocationId, symbolTable); 5814 BuiltInVariable("gl_LocalInvocationIndex", EbvLocalInvocationIndex, symbolTable); 5815 5816 if (profile != EEsProfile && version < 430) { 5817 symbolTable.setVariableExtensions("gl_NumWorkGroups", 1, &E_GL_ARB_compute_shader); 5818 symbolTable.setVariableExtensions("gl_WorkGroupSize", 1, &E_GL_ARB_compute_shader); 5819 symbolTable.setVariableExtensions("gl_WorkGroupID", 1, &E_GL_ARB_compute_shader); 5820 symbolTable.setVariableExtensions("gl_LocalInvocationID", 1, &E_GL_ARB_compute_shader); 5821 symbolTable.setVariableExtensions("gl_GlobalInvocationID", 1, &E_GL_ARB_compute_shader); 5822 symbolTable.setVariableExtensions("gl_LocalInvocationIndex", 1, &E_GL_ARB_compute_shader); 5823 5824 symbolTable.setVariableExtensions("gl_MaxComputeWorkGroupCount", 1, &E_GL_ARB_compute_shader); 5825 symbolTable.setVariableExtensions("gl_MaxComputeWorkGroupSize", 1, &E_GL_ARB_compute_shader); 5826 symbolTable.setVariableExtensions("gl_MaxComputeUniformComponents", 1, &E_GL_ARB_compute_shader); 5827 symbolTable.setVariableExtensions("gl_MaxComputeTextureImageUnits", 1, &E_GL_ARB_compute_shader); 5828 symbolTable.setVariableExtensions("gl_MaxComputeImageUniforms", 1, &E_GL_ARB_compute_shader); 5829 symbolTable.setVariableExtensions("gl_MaxComputeAtomicCounters", 1, &E_GL_ARB_compute_shader); 5830 symbolTable.setVariableExtensions("gl_MaxComputeAtomicCounterBuffers", 1, &E_GL_ARB_compute_shader); 5831 5832 symbolTable.setFunctionExtensions("barrier", 1, &E_GL_ARB_compute_shader); 5833 symbolTable.setFunctionExtensions("memoryBarrierAtomicCounter", 1, &E_GL_ARB_compute_shader); 5834 symbolTable.setFunctionExtensions("memoryBarrierBuffer", 1, &E_GL_ARB_compute_shader); 5835 symbolTable.setFunctionExtensions("memoryBarrierImage", 1, &E_GL_ARB_compute_shader); 5836 symbolTable.setFunctionExtensions("memoryBarrierShared", 1, &E_GL_ARB_compute_shader); 5837 symbolTable.setFunctionExtensions("groupMemoryBarrier", 1, &E_GL_ARB_compute_shader); 5838 } 5839 5840 if ((profile != EEsProfile && version >= 140) || 5841 (profile == EEsProfile && version >= 310)) { 5842 symbolTable.setVariableExtensions("gl_DeviceIndex", 1, &E_GL_EXT_device_group); 5843 BuiltInVariable("gl_DeviceIndex", EbvDeviceIndex, symbolTable); 5844 symbolTable.setVariableExtensions("gl_ViewIndex", 1, &E_GL_EXT_multiview); 5845 BuiltInVariable("gl_ViewIndex", EbvViewIndex, symbolTable); 5846 } 5847 5848 break; 5849 5850 default: 5851 assert(false && "Language not supported"); 5852 break; 5853 } 5854 5855 // 5856 // Next, identify which built-ins have a mapping to an operator. 5857 // If PureOperatorBuiltins is false, those that are not identified as such are 5858 // expected to be resolved through a library of functions, versus as 5859 // operations. 5860 // 5861 symbolTable.relateToOperator("not", EOpVectorLogicalNot); 5862 5863 symbolTable.relateToOperator("matrixCompMult", EOpMul); 5864 // 120 and 150 are correct for both ES and desktop 5865 if (version >= 120) { 5866 symbolTable.relateToOperator("outerProduct", EOpOuterProduct); 5867 symbolTable.relateToOperator("transpose", EOpTranspose); 5868 if (version >= 150) { 5869 symbolTable.relateToOperator("determinant", EOpDeterminant); 5870 symbolTable.relateToOperator("inverse", EOpMatrixInverse); 5871 } 5872 } 5873 5874 symbolTable.relateToOperator("mod", EOpMod); 5875 symbolTable.relateToOperator("modf", EOpModf); 5876 5877 symbolTable.relateToOperator("equal", EOpVectorEqual); 5878 symbolTable.relateToOperator("notEqual", EOpVectorNotEqual); 5879 symbolTable.relateToOperator("lessThan", EOpLessThan); 5880 symbolTable.relateToOperator("greaterThan", EOpGreaterThan); 5881 symbolTable.relateToOperator("lessThanEqual", EOpLessThanEqual); 5882 symbolTable.relateToOperator("greaterThanEqual", EOpGreaterThanEqual); 5883 5884 symbolTable.relateToOperator("radians", EOpRadians); 5885 symbolTable.relateToOperator("degrees", EOpDegrees); 5886 symbolTable.relateToOperator("sin", EOpSin); 5887 symbolTable.relateToOperator("cos", EOpCos); 5888 symbolTable.relateToOperator("tan", EOpTan); 5889 symbolTable.relateToOperator("asin", EOpAsin); 5890 symbolTable.relateToOperator("acos", EOpAcos); 5891 symbolTable.relateToOperator("atan", EOpAtan); 5892 symbolTable.relateToOperator("sinh", EOpSinh); 5893 symbolTable.relateToOperator("cosh", EOpCosh); 5894 symbolTable.relateToOperator("tanh", EOpTanh); 5895 symbolTable.relateToOperator("asinh", EOpAsinh); 5896 symbolTable.relateToOperator("acosh", EOpAcosh); 5897 symbolTable.relateToOperator("atanh", EOpAtanh); 5898 5899 symbolTable.relateToOperator("pow", EOpPow); 5900 symbolTable.relateToOperator("exp2", EOpExp2); 5901 symbolTable.relateToOperator("log", EOpLog); 5902 symbolTable.relateToOperator("exp", EOpExp); 5903 symbolTable.relateToOperator("log2", EOpLog2); 5904 symbolTable.relateToOperator("sqrt", EOpSqrt); 5905 symbolTable.relateToOperator("inversesqrt", EOpInverseSqrt); 5906 5907 symbolTable.relateToOperator("abs", EOpAbs); 5908 symbolTable.relateToOperator("sign", EOpSign); 5909 symbolTable.relateToOperator("floor", EOpFloor); 5910 symbolTable.relateToOperator("trunc", EOpTrunc); 5911 symbolTable.relateToOperator("round", EOpRound); 5912 symbolTable.relateToOperator("roundEven", EOpRoundEven); 5913 symbolTable.relateToOperator("ceil", EOpCeil); 5914 symbolTable.relateToOperator("fract", EOpFract); 5915 symbolTable.relateToOperator("min", EOpMin); 5916 symbolTable.relateToOperator("max", EOpMax); 5917 symbolTable.relateToOperator("clamp", EOpClamp); 5918 symbolTable.relateToOperator("mix", EOpMix); 5919 symbolTable.relateToOperator("step", EOpStep); 5920 symbolTable.relateToOperator("smoothstep", EOpSmoothStep); 5921 5922 symbolTable.relateToOperator("isnan", EOpIsNan); 5923 symbolTable.relateToOperator("isinf", EOpIsInf); 5924 5925 symbolTable.relateToOperator("floatBitsToInt", EOpFloatBitsToInt); 5926 symbolTable.relateToOperator("floatBitsToUint", EOpFloatBitsToUint); 5927 symbolTable.relateToOperator("intBitsToFloat", EOpIntBitsToFloat); 5928 symbolTable.relateToOperator("uintBitsToFloat", EOpUintBitsToFloat); 5929 symbolTable.relateToOperator("doubleBitsToInt64", EOpDoubleBitsToInt64); 5930 symbolTable.relateToOperator("doubleBitsToUint64", EOpDoubleBitsToUint64); 5931 symbolTable.relateToOperator("int64BitsToDouble", EOpInt64BitsToDouble); 5932 symbolTable.relateToOperator("uint64BitsToDouble", EOpUint64BitsToDouble); 5933 #ifdef AMD_EXTENSIONS 5934 symbolTable.relateToOperator("float16BitsToInt16", EOpFloat16BitsToInt16); 5935 symbolTable.relateToOperator("float16BitsToUint16", EOpFloat16BitsToUint16); 5936 symbolTable.relateToOperator("int16BitsToFloat16", EOpInt16BitsToFloat16); 5937 symbolTable.relateToOperator("uint16BitsToFloat16", EOpUint16BitsToFloat16); 5938 #endif 5939 5940 symbolTable.relateToOperator("packSnorm2x16", EOpPackSnorm2x16); 5941 symbolTable.relateToOperator("unpackSnorm2x16", EOpUnpackSnorm2x16); 5942 symbolTable.relateToOperator("packUnorm2x16", EOpPackUnorm2x16); 5943 symbolTable.relateToOperator("unpackUnorm2x16", EOpUnpackUnorm2x16); 5944 5945 symbolTable.relateToOperator("packSnorm4x8", EOpPackSnorm4x8); 5946 symbolTable.relateToOperator("unpackSnorm4x8", EOpUnpackSnorm4x8); 5947 symbolTable.relateToOperator("packUnorm4x8", EOpPackUnorm4x8); 5948 symbolTable.relateToOperator("unpackUnorm4x8", EOpUnpackUnorm4x8); 5949 5950 symbolTable.relateToOperator("packDouble2x32", EOpPackDouble2x32); 5951 symbolTable.relateToOperator("unpackDouble2x32", EOpUnpackDouble2x32); 5952 5953 symbolTable.relateToOperator("packHalf2x16", EOpPackHalf2x16); 5954 symbolTable.relateToOperator("unpackHalf2x16", EOpUnpackHalf2x16); 5955 5956 symbolTable.relateToOperator("packInt2x32", EOpPackInt2x32); 5957 symbolTable.relateToOperator("unpackInt2x32", EOpUnpackInt2x32); 5958 symbolTable.relateToOperator("packUint2x32", EOpPackUint2x32); 5959 symbolTable.relateToOperator("unpackUint2x32", EOpUnpackUint2x32); 5960 5961 #ifdef AMD_EXTENSIONS 5962 symbolTable.relateToOperator("packInt2x16", EOpPackInt2x16); 5963 symbolTable.relateToOperator("unpackInt2x16", EOpUnpackInt2x16); 5964 symbolTable.relateToOperator("packUint2x16", EOpPackUint2x16); 5965 symbolTable.relateToOperator("unpackUint2x16", EOpUnpackUint2x16); 5966 5967 symbolTable.relateToOperator("packInt4x16", EOpPackInt4x16); 5968 symbolTable.relateToOperator("unpackInt4x16", EOpUnpackInt4x16); 5969 symbolTable.relateToOperator("packUint4x16", EOpPackUint4x16); 5970 symbolTable.relateToOperator("unpackUint4x16", EOpUnpackUint4x16); 5971 5972 symbolTable.relateToOperator("packFloat2x16", EOpPackFloat2x16); 5973 symbolTable.relateToOperator("unpackFloat2x16", EOpUnpackFloat2x16); 5974 #endif 5975 5976 symbolTable.relateToOperator("length", EOpLength); 5977 symbolTable.relateToOperator("distance", EOpDistance); 5978 symbolTable.relateToOperator("dot", EOpDot); 5979 symbolTable.relateToOperator("cross", EOpCross); 5980 symbolTable.relateToOperator("normalize", EOpNormalize); 5981 symbolTable.relateToOperator("faceforward", EOpFaceForward); 5982 symbolTable.relateToOperator("reflect", EOpReflect); 5983 symbolTable.relateToOperator("refract", EOpRefract); 5984 5985 symbolTable.relateToOperator("any", EOpAny); 5986 symbolTable.relateToOperator("all", EOpAll); 5987 5988 symbolTable.relateToOperator("barrier", EOpBarrier); 5989 symbolTable.relateToOperator("memoryBarrier", EOpMemoryBarrier); 5990 symbolTable.relateToOperator("memoryBarrierAtomicCounter", EOpMemoryBarrierAtomicCounter); 5991 symbolTable.relateToOperator("memoryBarrierBuffer", EOpMemoryBarrierBuffer); 5992 symbolTable.relateToOperator("memoryBarrierImage", EOpMemoryBarrierImage); 5993 5994 symbolTable.relateToOperator("atomicAdd", EOpAtomicAdd); 5995 symbolTable.relateToOperator("atomicMin", EOpAtomicMin); 5996 symbolTable.relateToOperator("atomicMax", EOpAtomicMax); 5997 symbolTable.relateToOperator("atomicAnd", EOpAtomicAnd); 5998 symbolTable.relateToOperator("atomicOr", EOpAtomicOr); 5999 symbolTable.relateToOperator("atomicXor", EOpAtomicXor); 6000 symbolTable.relateToOperator("atomicExchange", EOpAtomicExchange); 6001 symbolTable.relateToOperator("atomicCompSwap", EOpAtomicCompSwap); 6002 6003 symbolTable.relateToOperator("atomicCounterIncrement", EOpAtomicCounterIncrement); 6004 symbolTable.relateToOperator("atomicCounterDecrement", EOpAtomicCounterDecrement); 6005 symbolTable.relateToOperator("atomicCounter", EOpAtomicCounter); 6006 6007 if (profile != EEsProfile && version >= 460) { 6008 symbolTable.relateToOperator("atomicCounterAdd", EOpAtomicCounterAdd); 6009 symbolTable.relateToOperator("atomicCounterSubtract", EOpAtomicCounterSubtract); 6010 symbolTable.relateToOperator("atomicCounterMin", EOpAtomicCounterMin); 6011 symbolTable.relateToOperator("atomicCounterMax", EOpAtomicCounterMax); 6012 symbolTable.relateToOperator("atomicCounterAnd", EOpAtomicCounterAnd); 6013 symbolTable.relateToOperator("atomicCounterOr", EOpAtomicCounterOr); 6014 symbolTable.relateToOperator("atomicCounterXor", EOpAtomicCounterXor); 6015 symbolTable.relateToOperator("atomicCounterExchange", EOpAtomicCounterExchange); 6016 symbolTable.relateToOperator("atomicCounterCompSwap", EOpAtomicCounterCompSwap); 6017 } 6018 6019 symbolTable.relateToOperator("fma", EOpFma); 6020 symbolTable.relateToOperator("frexp", EOpFrexp); 6021 symbolTable.relateToOperator("ldexp", EOpLdexp); 6022 symbolTable.relateToOperator("uaddCarry", EOpAddCarry); 6023 symbolTable.relateToOperator("usubBorrow", EOpSubBorrow); 6024 symbolTable.relateToOperator("umulExtended", EOpUMulExtended); 6025 symbolTable.relateToOperator("imulExtended", EOpIMulExtended); 6026 symbolTable.relateToOperator("bitfieldExtract", EOpBitfieldExtract); 6027 symbolTable.relateToOperator("bitfieldInsert", EOpBitfieldInsert); 6028 symbolTable.relateToOperator("bitfieldReverse", EOpBitFieldReverse); 6029 symbolTable.relateToOperator("bitCount", EOpBitCount); 6030 symbolTable.relateToOperator("findLSB", EOpFindLSB); 6031 symbolTable.relateToOperator("findMSB", EOpFindMSB); 6032 6033 if (PureOperatorBuiltins) { 6034 symbolTable.relateToOperator("imageSize", EOpImageQuerySize); 6035 symbolTable.relateToOperator("imageSamples", EOpImageQuerySamples); 6036 symbolTable.relateToOperator("imageLoad", EOpImageLoad); 6037 symbolTable.relateToOperator("imageStore", EOpImageStore); 6038 symbolTable.relateToOperator("imageAtomicAdd", EOpImageAtomicAdd); 6039 symbolTable.relateToOperator("imageAtomicMin", EOpImageAtomicMin); 6040 symbolTable.relateToOperator("imageAtomicMax", EOpImageAtomicMax); 6041 symbolTable.relateToOperator("imageAtomicAnd", EOpImageAtomicAnd); 6042 symbolTable.relateToOperator("imageAtomicOr", EOpImageAtomicOr); 6043 symbolTable.relateToOperator("imageAtomicXor", EOpImageAtomicXor); 6044 symbolTable.relateToOperator("imageAtomicExchange", EOpImageAtomicExchange); 6045 symbolTable.relateToOperator("imageAtomicCompSwap", EOpImageAtomicCompSwap); 6046 6047 symbolTable.relateToOperator("subpassLoad", EOpSubpassLoad); 6048 symbolTable.relateToOperator("subpassLoadMS", EOpSubpassLoadMS); 6049 6050 symbolTable.relateToOperator("textureSize", EOpTextureQuerySize); 6051 symbolTable.relateToOperator("textureQueryLod", EOpTextureQueryLod); 6052 symbolTable.relateToOperator("textureQueryLevels", EOpTextureQueryLevels); 6053 symbolTable.relateToOperator("textureSamples", EOpTextureQuerySamples); 6054 symbolTable.relateToOperator("texture", EOpTexture); 6055 symbolTable.relateToOperator("textureProj", EOpTextureProj); 6056 symbolTable.relateToOperator("textureLod", EOpTextureLod); 6057 symbolTable.relateToOperator("textureOffset", EOpTextureOffset); 6058 symbolTable.relateToOperator("texelFetch", EOpTextureFetch); 6059 symbolTable.relateToOperator("texelFetchOffset", EOpTextureFetchOffset); 6060 symbolTable.relateToOperator("textureProjOffset", EOpTextureProjOffset); 6061 symbolTable.relateToOperator("textureLodOffset", EOpTextureLodOffset); 6062 symbolTable.relateToOperator("textureProjLod", EOpTextureProjLod); 6063 symbolTable.relateToOperator("textureProjLodOffset", EOpTextureProjLodOffset); 6064 symbolTable.relateToOperator("textureGrad", EOpTextureGrad); 6065 symbolTable.relateToOperator("textureGradOffset", EOpTextureGradOffset); 6066 symbolTable.relateToOperator("textureProjGrad", EOpTextureProjGrad); 6067 symbolTable.relateToOperator("textureProjGradOffset", EOpTextureProjGradOffset); 6068 symbolTable.relateToOperator("textureGather", EOpTextureGather); 6069 symbolTable.relateToOperator("textureGatherOffset", EOpTextureGatherOffset); 6070 symbolTable.relateToOperator("textureGatherOffsets", EOpTextureGatherOffsets); 6071 6072 symbolTable.relateToOperator("noise1", EOpNoise); 6073 symbolTable.relateToOperator("noise2", EOpNoise); 6074 symbolTable.relateToOperator("noise3", EOpNoise); 6075 symbolTable.relateToOperator("noise4", EOpNoise); 6076 6077 if (spvVersion.spv == 0 && (IncludeLegacy(version, profile, spvVersion) || 6078 (profile == EEsProfile && version == 100))) { 6079 symbolTable.relateToOperator("ftransform", EOpFtransform); 6080 6081 symbolTable.relateToOperator("texture1D", EOpTexture); 6082 symbolTable.relateToOperator("texture1DGradARB", EOpTextureGrad); 6083 symbolTable.relateToOperator("texture1DProj", EOpTextureProj); 6084 symbolTable.relateToOperator("texture1DProjGradARB", EOpTextureProjGrad); 6085 symbolTable.relateToOperator("texture1DLod", EOpTextureLod); 6086 symbolTable.relateToOperator("texture1DProjLod", EOpTextureProjLod); 6087 6088 symbolTable.relateToOperator("texture2DRect", EOpTexture); 6089 symbolTable.relateToOperator("texture2DRectProj", EOpTextureProj); 6090 symbolTable.relateToOperator("texture2DRectGradARB", EOpTextureGrad); 6091 symbolTable.relateToOperator("texture2DRectProjGradARB", EOpTextureProjGrad); 6092 symbolTable.relateToOperator("shadow2DRect", EOpTexture); 6093 symbolTable.relateToOperator("shadow2DRectProj", EOpTextureProj); 6094 symbolTable.relateToOperator("shadow2DRectGradARB", EOpTextureGrad); 6095 symbolTable.relateToOperator("shadow2DRectProjGradARB", EOpTextureProjGrad); 6096 6097 symbolTable.relateToOperator("texture2D", EOpTexture); 6098 symbolTable.relateToOperator("texture2DProj", EOpTextureProj); 6099 symbolTable.relateToOperator("texture2DGradEXT", EOpTextureGrad); 6100 symbolTable.relateToOperator("texture2DGradARB", EOpTextureGrad); 6101 symbolTable.relateToOperator("texture2DProjGradEXT", EOpTextureProjGrad); 6102 symbolTable.relateToOperator("texture2DProjGradARB", EOpTextureProjGrad); 6103 symbolTable.relateToOperator("texture2DLod", EOpTextureLod); 6104 symbolTable.relateToOperator("texture2DLodEXT", EOpTextureLod); 6105 symbolTable.relateToOperator("texture2DProjLod", EOpTextureProjLod); 6106 symbolTable.relateToOperator("texture2DProjLodEXT", EOpTextureProjLod); 6107 6108 symbolTable.relateToOperator("texture3D", EOpTexture); 6109 symbolTable.relateToOperator("texture3DGradARB", EOpTextureGrad); 6110 symbolTable.relateToOperator("texture3DProj", EOpTextureProj); 6111 symbolTable.relateToOperator("texture3DProjGradARB", EOpTextureProjGrad); 6112 symbolTable.relateToOperator("texture3DLod", EOpTextureLod); 6113 symbolTable.relateToOperator("texture3DProjLod", EOpTextureProjLod); 6114 symbolTable.relateToOperator("textureCube", EOpTexture); 6115 symbolTable.relateToOperator("textureCubeGradEXT", EOpTextureGrad); 6116 symbolTable.relateToOperator("textureCubeGradARB", EOpTextureGrad); 6117 symbolTable.relateToOperator("textureCubeLod", EOpTextureLod); 6118 symbolTable.relateToOperator("textureCubeLodEXT", EOpTextureLod); 6119 symbolTable.relateToOperator("shadow1D", EOpTexture); 6120 symbolTable.relateToOperator("shadow1DGradARB", EOpTextureGrad); 6121 symbolTable.relateToOperator("shadow2D", EOpTexture); 6122 symbolTable.relateToOperator("shadow2DGradARB", EOpTextureGrad); 6123 symbolTable.relateToOperator("shadow1DProj", EOpTextureProj); 6124 symbolTable.relateToOperator("shadow2DProj", EOpTextureProj); 6125 symbolTable.relateToOperator("shadow1DProjGradARB", EOpTextureProjGrad); 6126 symbolTable.relateToOperator("shadow2DProjGradARB", EOpTextureProjGrad); 6127 symbolTable.relateToOperator("shadow1DLod", EOpTextureLod); 6128 symbolTable.relateToOperator("shadow2DLod", EOpTextureLod); 6129 symbolTable.relateToOperator("shadow1DProjLod", EOpTextureProjLod); 6130 symbolTable.relateToOperator("shadow2DProjLod", EOpTextureProjLod); 6131 } 6132 6133 if (profile != EEsProfile) { 6134 symbolTable.relateToOperator("sparseTextureARB", EOpSparseTexture); 6135 symbolTable.relateToOperator("sparseTextureLodARB", EOpSparseTextureLod); 6136 symbolTable.relateToOperator("sparseTextureOffsetARB", EOpSparseTextureOffset); 6137 symbolTable.relateToOperator("sparseTexelFetchARB", EOpSparseTextureFetch); 6138 symbolTable.relateToOperator("sparseTexelFetchOffsetARB", EOpSparseTextureFetchOffset); 6139 symbolTable.relateToOperator("sparseTextureLodOffsetARB", EOpSparseTextureLodOffset); 6140 symbolTable.relateToOperator("sparseTextureGradARB", EOpSparseTextureGrad); 6141 symbolTable.relateToOperator("sparseTextureGradOffsetARB", EOpSparseTextureGradOffset); 6142 symbolTable.relateToOperator("sparseTextureGatherARB", EOpSparseTextureGather); 6143 symbolTable.relateToOperator("sparseTextureGatherOffsetARB", EOpSparseTextureGatherOffset); 6144 symbolTable.relateToOperator("sparseTextureGatherOffsetsARB", EOpSparseTextureGatherOffsets); 6145 symbolTable.relateToOperator("sparseImageLoadARB", EOpSparseImageLoad); 6146 symbolTable.relateToOperator("sparseTexelsResidentARB", EOpSparseTexelsResident); 6147 6148 symbolTable.relateToOperator("sparseTextureClampARB", EOpSparseTextureClamp); 6149 symbolTable.relateToOperator("sparseTextureOffsetClampARB", EOpSparseTextureOffsetClamp); 6150 symbolTable.relateToOperator("sparseTextureGradClampARB", EOpSparseTextureGradClamp); 6151 symbolTable.relateToOperator("sparseTextureGradOffsetClampARB", EOpSparseTextureGradOffsetClamp); 6152 symbolTable.relateToOperator("textureClampARB", EOpTextureClamp); 6153 symbolTable.relateToOperator("textureOffsetClampARB", EOpTextureOffsetClamp); 6154 symbolTable.relateToOperator("textureGradClampARB", EOpTextureGradClamp); 6155 symbolTable.relateToOperator("textureGradOffsetClampARB", EOpTextureGradOffsetClamp); 6156 6157 symbolTable.relateToOperator("ballotARB", EOpBallot); 6158 symbolTable.relateToOperator("readInvocationARB", EOpReadInvocation); 6159 symbolTable.relateToOperator("readFirstInvocationARB", EOpReadFirstInvocation); 6160 6161 if (version >= 430) { 6162 symbolTable.relateToOperator("anyInvocationARB", EOpAnyInvocation); 6163 symbolTable.relateToOperator("allInvocationsARB", EOpAllInvocations); 6164 symbolTable.relateToOperator("allInvocationsEqualARB", EOpAllInvocationsEqual); 6165 } 6166 if (version >= 460) { 6167 symbolTable.relateToOperator("anyInvocation", EOpAnyInvocation); 6168 symbolTable.relateToOperator("allInvocations", EOpAllInvocations); 6169 symbolTable.relateToOperator("allInvocationsEqual", EOpAllInvocationsEqual); 6170 } 6171 #ifdef AMD_EXTENSIONS 6172 symbolTable.relateToOperator("minInvocationsAMD", EOpMinInvocations); 6173 symbolTable.relateToOperator("maxInvocationsAMD", EOpMaxInvocations); 6174 symbolTable.relateToOperator("addInvocationsAMD", EOpAddInvocations); 6175 symbolTable.relateToOperator("minInvocationsNonUniformAMD", EOpMinInvocationsNonUniform); 6176 symbolTable.relateToOperator("maxInvocationsNonUniformAMD", EOpMaxInvocationsNonUniform); 6177 symbolTable.relateToOperator("addInvocationsNonUniformAMD", EOpAddInvocationsNonUniform); 6178 symbolTable.relateToOperator("minInvocationsInclusiveScanAMD", EOpMinInvocationsInclusiveScan); 6179 symbolTable.relateToOperator("maxInvocationsInclusiveScanAMD", EOpMaxInvocationsInclusiveScan); 6180 symbolTable.relateToOperator("addInvocationsInclusiveScanAMD", EOpAddInvocationsInclusiveScan); 6181 symbolTable.relateToOperator("minInvocationsInclusiveScanNonUniformAMD", EOpMinInvocationsInclusiveScanNonUniform); 6182 symbolTable.relateToOperator("maxInvocationsInclusiveScanNonUniformAMD", EOpMaxInvocationsInclusiveScanNonUniform); 6183 symbolTable.relateToOperator("addInvocationsInclusiveScanNonUniformAMD", EOpAddInvocationsInclusiveScanNonUniform); 6184 symbolTable.relateToOperator("minInvocationsExclusiveScanAMD", EOpMinInvocationsExclusiveScan); 6185 symbolTable.relateToOperator("maxInvocationsExclusiveScanAMD", EOpMaxInvocationsExclusiveScan); 6186 symbolTable.relateToOperator("addInvocationsExclusiveScanAMD", EOpAddInvocationsExclusiveScan); 6187 symbolTable.relateToOperator("minInvocationsExclusiveScanNonUniformAMD", EOpMinInvocationsExclusiveScanNonUniform); 6188 symbolTable.relateToOperator("maxInvocationsExclusiveScanNonUniformAMD", EOpMaxInvocationsExclusiveScanNonUniform); 6189 symbolTable.relateToOperator("addInvocationsExclusiveScanNonUniformAMD", EOpAddInvocationsExclusiveScanNonUniform); 6190 symbolTable.relateToOperator("swizzleInvocationsAMD", EOpSwizzleInvocations); 6191 symbolTable.relateToOperator("swizzleInvocationsMaskedAMD", EOpSwizzleInvocationsMasked); 6192 symbolTable.relateToOperator("writeInvocationAMD", EOpWriteInvocation); 6193 symbolTable.relateToOperator("mbcntAMD", EOpMbcnt); 6194 6195 symbolTable.relateToOperator("min3", EOpMin3); 6196 symbolTable.relateToOperator("max3", EOpMax3); 6197 symbolTable.relateToOperator("mid3", EOpMid3); 6198 6199 symbolTable.relateToOperator("cubeFaceIndexAMD", EOpCubeFaceIndex); 6200 symbolTable.relateToOperator("cubeFaceCoordAMD", EOpCubeFaceCoord); 6201 symbolTable.relateToOperator("timeAMD", EOpTime); 6202 6203 symbolTable.relateToOperator("textureGatherLodAMD", EOpTextureGatherLod); 6204 symbolTable.relateToOperator("textureGatherLodOffsetAMD", EOpTextureGatherLodOffset); 6205 symbolTable.relateToOperator("textureGatherLodOffsetsAMD", EOpTextureGatherLodOffsets); 6206 symbolTable.relateToOperator("sparseTextureGatherLodAMD", EOpSparseTextureGatherLod); 6207 symbolTable.relateToOperator("sparseTextureGatherLodOffsetAMD", EOpSparseTextureGatherLodOffset); 6208 symbolTable.relateToOperator("sparseTextureGatherLodOffsetsAMD", EOpSparseTextureGatherLodOffsets); 6209 6210 symbolTable.relateToOperator("imageLoadLodAMD", EOpImageLoadLod); 6211 symbolTable.relateToOperator("imageStoreLodAMD", EOpImageStoreLod); 6212 symbolTable.relateToOperator("sparseImageLoadLodAMD", EOpSparseImageLoadLod); 6213 #endif 6214 } 6215 if (profile == EEsProfile) { 6216 symbolTable.relateToOperator("shadow2DEXT", EOpTexture); 6217 symbolTable.relateToOperator("shadow2DProjEXT", EOpTextureProj); 6218 } 6219 } 6220 6221 switch(language) { 6222 case EShLangVertex: 6223 break; 6224 6225 case EShLangTessControl: 6226 case EShLangTessEvaluation: 6227 break; 6228 6229 case EShLangGeometry: 6230 symbolTable.relateToOperator("EmitStreamVertex", EOpEmitStreamVertex); 6231 symbolTable.relateToOperator("EndStreamPrimitive", EOpEndStreamPrimitive); 6232 symbolTable.relateToOperator("EmitVertex", EOpEmitVertex); 6233 symbolTable.relateToOperator("EndPrimitive", EOpEndPrimitive); 6234 break; 6235 6236 case EShLangFragment: 6237 symbolTable.relateToOperator("dFdx", EOpDPdx); 6238 symbolTable.relateToOperator("dFdy", EOpDPdy); 6239 symbolTable.relateToOperator("fwidth", EOpFwidth); 6240 if (profile != EEsProfile && version >= 400) { 6241 symbolTable.relateToOperator("dFdxFine", EOpDPdxFine); 6242 symbolTable.relateToOperator("dFdyFine", EOpDPdyFine); 6243 symbolTable.relateToOperator("fwidthFine", EOpFwidthFine); 6244 symbolTable.relateToOperator("dFdxCoarse", EOpDPdxCoarse); 6245 symbolTable.relateToOperator("dFdyCoarse", EOpDPdyCoarse); 6246 symbolTable.relateToOperator("fwidthCoarse", EOpFwidthCoarse); 6247 } 6248 symbolTable.relateToOperator("interpolateAtCentroid", EOpInterpolateAtCentroid); 6249 symbolTable.relateToOperator("interpolateAtSample", EOpInterpolateAtSample); 6250 symbolTable.relateToOperator("interpolateAtOffset", EOpInterpolateAtOffset); 6251 6252 #ifdef AMD_EXTENSIONS 6253 if (profile != EEsProfile) 6254 symbolTable.relateToOperator("interpolateAtVertexAMD", EOpInterpolateAtVertex); 6255 break; 6256 #endif 6257 6258 case EShLangCompute: 6259 symbolTable.relateToOperator("memoryBarrierShared", EOpMemoryBarrierShared); 6260 symbolTable.relateToOperator("groupMemoryBarrier", EOpGroupMemoryBarrier); 6261 break; 6262 6263 default: 6264 assert(false && "Language not supported"); 6265 } 6266 } 6267 6268 // 6269 // Add context-dependent (resource-specific) built-ins not handled by the above. These 6270 // would be ones that need to be programmatically added because they cannot 6271 // be added by simple text strings. For these, also 6272 // 1) Map built-in functions to operators, for those that will turn into an operation node 6273 // instead of remaining a function call. 6274 // 2) Tag extension-related symbols added to their base version with their extensions, so 6275 // that if an early version has the extension turned off, there is an error reported on use. 6276 // 6277 void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources) 6278 { 6279 if (profile != EEsProfile && version >= 430 && version < 440) { 6280 symbolTable.setVariableExtensions("gl_MaxTransformFeedbackBuffers", 1, &E_GL_ARB_enhanced_layouts); 6281 symbolTable.setVariableExtensions("gl_MaxTransformFeedbackInterleavedComponents", 1, &E_GL_ARB_enhanced_layouts); 6282 } 6283 if (profile != EEsProfile && version >= 130 && version < 420) { 6284 symbolTable.setVariableExtensions("gl_MinProgramTexelOffset", 1, &E_GL_ARB_shading_language_420pack); 6285 symbolTable.setVariableExtensions("gl_MaxProgramTexelOffset", 1, &E_GL_ARB_shading_language_420pack); 6286 } 6287 if (profile != EEsProfile && version >= 150 && version < 410) 6288 symbolTable.setVariableExtensions("gl_MaxViewports", 1, &E_GL_ARB_viewport_array); 6289 6290 switch(language) { 6291 case EShLangFragment: 6292 // Set up gl_FragData based on current array size. 6293 if (version == 100 || IncludeLegacy(version, profile, spvVersion) || (! ForwardCompatibility && profile != EEsProfile && version < 420)) { 6294 TPrecisionQualifier pq = profile == EEsProfile ? EpqMedium : EpqNone; 6295 TType fragData(EbtFloat, EvqFragColor, pq, 4); 6296 TArraySizes& arraySizes = *new TArraySizes; 6297 arraySizes.addInnerSize(resources.maxDrawBuffers); 6298 fragData.newArraySizes(arraySizes); 6299 symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData)); 6300 SpecialQualifier("gl_FragData", EvqFragColor, EbvFragData, symbolTable); 6301 } 6302 break; 6303 6304 case EShLangTessControl: 6305 case EShLangTessEvaluation: 6306 // Because of the context-dependent array size (gl_MaxPatchVertices), 6307 // these variables were added later than the others and need to be mapped now. 6308 6309 // standard members 6310 BuiltInVariable("gl_in", "gl_Position", EbvPosition, symbolTable); 6311 BuiltInVariable("gl_in", "gl_PointSize", EbvPointSize, symbolTable); 6312 BuiltInVariable("gl_in", "gl_ClipDistance", EbvClipDistance, symbolTable); 6313 BuiltInVariable("gl_in", "gl_CullDistance", EbvCullDistance, symbolTable); 6314 6315 // compatibility members 6316 BuiltInVariable("gl_in", "gl_ClipVertex", EbvClipVertex, symbolTable); 6317 BuiltInVariable("gl_in", "gl_FrontColor", EbvFrontColor, symbolTable); 6318 BuiltInVariable("gl_in", "gl_BackColor", EbvBackColor, symbolTable); 6319 BuiltInVariable("gl_in", "gl_FrontSecondaryColor", EbvFrontSecondaryColor, symbolTable); 6320 BuiltInVariable("gl_in", "gl_BackSecondaryColor", EbvBackSecondaryColor, symbolTable); 6321 BuiltInVariable("gl_in", "gl_TexCoord", EbvTexCoord, symbolTable); 6322 BuiltInVariable("gl_in", "gl_FogFragCoord", EbvFogFragCoord, symbolTable); 6323 break; 6324 6325 default: 6326 break; 6327 } 6328 } 6329 6330 } // end namespace glslang 6331