daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1 | // |
Nicolas Capens | 1fbc287 | 2014-01-03 14:12:09 -0500 | [diff] [blame] | 2 | // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | // |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 8 | // Create symbols that declare built-in definitions, add built-ins that |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 9 | // cannot be expressed in the files, and establish mappings between |
| 10 | // built-in functions and operators. |
| 11 | // |
| 12 | |
Geoff Lang | 1773282 | 2013-08-29 13:46:49 -0400 | [diff] [blame] | 13 | #include "compiler/translator/Initialize.h" |
Dmitry Skiba | 0197111 | 2015-07-10 14:54:00 -0400 | [diff] [blame] | 14 | #include "compiler/translator/Cache.h" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 15 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 16 | #include "compiler/translator/IntermNode.h" |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 17 | #include "angle_gl.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 18 | |
Jamie Madill | 45bcc78 | 2016-11-07 13:58:48 -0500 | [diff] [blame^] | 19 | namespace sh |
| 20 | { |
| 21 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 22 | void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &symbolTable) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 23 | { |
Martin Radev | 2cc85b3 | 2016-08-05 16:22:53 +0300 | [diff] [blame] | 24 | const TType *voidType = TCache::getType(EbtVoid); |
Dmitry Skiba | 0197111 | 2015-07-10 14:54:00 -0400 | [diff] [blame] | 25 | const TType *float1 = TCache::getType(EbtFloat); |
| 26 | const TType *float2 = TCache::getType(EbtFloat, 2); |
| 27 | const TType *float3 = TCache::getType(EbtFloat, 3); |
| 28 | const TType *float4 = TCache::getType(EbtFloat, 4); |
| 29 | const TType *int1 = TCache::getType(EbtInt); |
| 30 | const TType *int2 = TCache::getType(EbtInt, 2); |
| 31 | const TType *int3 = TCache::getType(EbtInt, 3); |
| 32 | const TType *uint1 = TCache::getType(EbtUInt); |
| 33 | const TType *bool1 = TCache::getType(EbtBool); |
| 34 | const TType *genType = TCache::getType(EbtGenType); |
| 35 | const TType *genIType = TCache::getType(EbtGenIType); |
| 36 | const TType *genUType = TCache::getType(EbtGenUType); |
| 37 | const TType *genBType = TCache::getType(EbtGenBType); |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 38 | |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 39 | // |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 40 | // Angle and Trigonometric Functions. |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 41 | // |
Nicolas Capens | 482907e | 2015-02-23 16:56:33 -0500 | [diff] [blame] | 42 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpRadians, genType, "radians", genType); |
| 43 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpDegrees, genType, "degrees", genType); |
| 44 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSin, genType, "sin", genType); |
| 45 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpCos, genType, "cos", genType); |
| 46 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpTan, genType, "tan", genType); |
| 47 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAsin, genType, "asin", genType); |
| 48 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAcos, genType, "acos", genType); |
| 49 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAtan, genType, "atan", genType, genType); |
| 50 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAtan, genType, "atan", genType); |
| 51 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpSinh, genType, "sinh", genType); |
| 52 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpCosh, genType, "cosh", genType); |
| 53 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTanh, genType, "tanh", genType); |
| 54 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpAsinh, genType, "asinh", genType); |
| 55 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpAcosh, genType, "acosh", genType); |
| 56 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpAtanh, genType, "atanh", genType); |
Olli Etuaho | 5c9cd3d | 2014-12-18 13:04:25 +0200 | [diff] [blame] | 57 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 58 | // |
| 59 | // Exponential Functions. |
| 60 | // |
Nicolas Capens | 482907e | 2015-02-23 16:56:33 -0500 | [diff] [blame] | 61 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpPow, genType, "pow", genType, genType); |
| 62 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpExp, genType, "exp", genType); |
| 63 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLog, genType, "log", genType); |
| 64 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpExp2, genType, "exp2", genType); |
| 65 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLog2, genType, "log2", genType); |
| 66 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSqrt, genType, "sqrt", genType); |
| 67 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpInverseSqrt, genType, "inversesqrt", genType); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 68 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 69 | // |
| 70 | // Common Functions. |
| 71 | // |
Nicolas Capens | 482907e | 2015-02-23 16:56:33 -0500 | [diff] [blame] | 72 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAbs, genType, "abs", genType); |
| 73 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpAbs, genIType, "abs", genIType); |
| 74 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSign, genType, "sign", genType); |
| 75 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpSign, genIType, "sign", genIType); |
| 76 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpFloor, genType, "floor", genType); |
Qingqing Deng | 5dbece5 | 2015-02-27 20:35:38 -0800 | [diff] [blame] | 77 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTrunc, genType, "trunc", genType); |
| 78 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpRound, genType, "round", genType); |
| 79 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpRoundEven, genType, "roundEven", genType); |
Nicolas Capens | 482907e | 2015-02-23 16:56:33 -0500 | [diff] [blame] | 80 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpCeil, genType, "ceil", genType); |
| 81 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpFract, genType, "fract", genType); |
| 82 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMod, genType, "mod", genType, float1); |
| 83 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMod, genType, "mod", genType, genType); |
| 84 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMin, genType, "min", genType, float1); |
| 85 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMin, genType, "min", genType, genType); |
| 86 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMin, genIType, "min", genIType, genIType); |
| 87 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMin, genIType, "min", genIType, int1); |
Arun Patole | 7749005 | 2015-03-03 18:36:05 +0530 | [diff] [blame] | 88 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMin, genUType, "min", genUType, genUType); |
Nicolas Capens | 482907e | 2015-02-23 16:56:33 -0500 | [diff] [blame] | 89 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMin, genUType, "min", genUType, uint1); |
| 90 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMax, genType, "max", genType, float1); |
| 91 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMax, genType, "max", genType, genType); |
| 92 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMax, genIType, "max", genIType, genIType); |
| 93 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMax, genIType, "max", genIType, int1); |
| 94 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMax, genUType, "max", genUType, genUType); |
| 95 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMax, genUType, "max", genUType, uint1); |
| 96 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpClamp, genType, "clamp", genType, float1, float1); |
| 97 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpClamp, genType, "clamp", genType, genType, genType); |
| 98 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpClamp, genIType, "clamp", genIType, int1, int1); |
| 99 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpClamp, genIType, "clamp", genIType, genIType, genIType); |
| 100 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpClamp, genUType, "clamp", genUType, uint1, uint1); |
| 101 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpClamp, genUType, "clamp", genUType, genUType, genUType); |
| 102 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMix, genType, "mix", genType, genType, float1); |
| 103 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMix, genType, "mix", genType, genType, genType); |
Arun Patole | d94f664 | 2015-05-18 16:25:12 +0530 | [diff] [blame] | 104 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMix, genType, "mix", genType, genType, genBType); |
Nicolas Capens | 482907e | 2015-02-23 16:56:33 -0500 | [diff] [blame] | 105 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpStep, genType, "step", genType, genType); |
| 106 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpStep, genType, "step", float1, genType); |
| 107 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSmoothStep, genType, "smoothstep", genType, genType, genType); |
| 108 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSmoothStep, genType, "smoothstep", float1, float1, genType); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 109 | |
Dmitry Skiba | 0197111 | 2015-07-10 14:54:00 -0400 | [diff] [blame] | 110 | const TType *outFloat1 = TCache::getType(EbtFloat, EvqOut); |
| 111 | const TType *outFloat2 = TCache::getType(EbtFloat, EvqOut, 2); |
| 112 | const TType *outFloat3 = TCache::getType(EbtFloat, EvqOut, 3); |
| 113 | const TType *outFloat4 = TCache::getType(EbtFloat, EvqOut, 4); |
Olli Etuaho | b6e07a6 | 2015-02-16 12:22:10 +0200 | [diff] [blame] | 114 | |
Nicolas Capens | 482907e | 2015-02-23 16:56:33 -0500 | [diff] [blame] | 115 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpModf, float1, "modf", float1, outFloat1); |
| 116 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpModf, float2, "modf", float2, outFloat2); |
| 117 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpModf, float3, "modf", float3, outFloat3); |
| 118 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpModf, float4, "modf", float4, outFloat4); |
Olli Etuaho | b6e07a6 | 2015-02-16 12:22:10 +0200 | [diff] [blame] | 119 | |
Nicolas Capens | 482907e | 2015-02-23 16:56:33 -0500 | [diff] [blame] | 120 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpIsNan, genBType, "isnan", genType); |
| 121 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpIsInf, genBType, "isinf", genType); |
| 122 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpFloatBitsToInt, genIType, "floatBitsToInt", genType); |
| 123 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpFloatBitsToUint, genUType, "floatBitsToUint", genType); |
| 124 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpIntBitsToFloat, genType, "intBitsToFloat", genIType); |
| 125 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpUintBitsToFloat, genType, "uintBitsToFloat", genUType); |
Olli Etuaho | e8d2c07 | 2015-01-08 16:33:54 +0200 | [diff] [blame] | 126 | |
Nicolas Capens | 482907e | 2015-02-23 16:56:33 -0500 | [diff] [blame] | 127 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpPackSnorm2x16, uint1, "packSnorm2x16", float2); |
| 128 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpPackUnorm2x16, uint1, "packUnorm2x16", float2); |
| 129 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpPackHalf2x16, uint1, "packHalf2x16", float2); |
| 130 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpUnpackSnorm2x16, float2, "unpackSnorm2x16", uint1); |
| 131 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpUnpackUnorm2x16, float2, "unpackUnorm2x16", uint1); |
| 132 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpUnpackHalf2x16, float2, "unpackHalf2x16", uint1); |
Olli Etuaho | 7700ff6 | 2015-01-15 12:16:29 +0200 | [diff] [blame] | 133 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 134 | // |
| 135 | // Geometric Functions. |
| 136 | // |
Nicolas Capens | 482907e | 2015-02-23 16:56:33 -0500 | [diff] [blame] | 137 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLength, float1, "length", genType); |
| 138 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpDistance, float1, "distance", genType, genType); |
| 139 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpDot, float1, "dot", genType, genType); |
| 140 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpCross, float3, "cross", float3, float3); |
| 141 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpNormalize, genType, "normalize", genType); |
| 142 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpFaceForward, genType, "faceforward", genType, genType, genType); |
| 143 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpReflect, genType, "reflect", genType, genType); |
| 144 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpRefract, genType, "refract", genType, genType, float1); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 145 | |
Dmitry Skiba | 0197111 | 2015-07-10 14:54:00 -0400 | [diff] [blame] | 146 | const TType *mat2 = TCache::getType(EbtFloat, 2, 2); |
| 147 | const TType *mat3 = TCache::getType(EbtFloat, 3, 3); |
| 148 | const TType *mat4 = TCache::getType(EbtFloat, 4, 4); |
| 149 | const TType *mat2x3 = TCache::getType(EbtFloat, 2, 3); |
| 150 | const TType *mat3x2 = TCache::getType(EbtFloat, 3, 2); |
| 151 | const TType *mat2x4 = TCache::getType(EbtFloat, 2, 4); |
| 152 | const TType *mat4x2 = TCache::getType(EbtFloat, 4, 2); |
| 153 | const TType *mat3x4 = TCache::getType(EbtFloat, 3, 4); |
| 154 | const TType *mat4x3 = TCache::getType(EbtFloat, 4, 3); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 155 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 156 | // |
| 157 | // Matrix Functions. |
| 158 | // |
Nicolas Capens | 482907e | 2015-02-23 16:56:33 -0500 | [diff] [blame] | 159 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMul, mat2, "matrixCompMult", mat2, mat2); |
| 160 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMul, mat3, "matrixCompMult", mat3, mat3); |
| 161 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMul, mat4, "matrixCompMult", mat4, mat4); |
| 162 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat2x3, "matrixCompMult", mat2x3, mat2x3); |
| 163 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat3x2, "matrixCompMult", mat3x2, mat3x2); |
| 164 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat2x4, "matrixCompMult", mat2x4, mat2x4); |
| 165 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat4x2, "matrixCompMult", mat4x2, mat4x2); |
| 166 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat3x4, "matrixCompMult", mat3x4, mat3x4); |
| 167 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat4x3, "matrixCompMult", mat4x3, mat4x3); |
Olli Etuaho | e39706d | 2014-12-30 16:40:36 +0200 | [diff] [blame] | 168 | |
Nicolas Capens | 482907e | 2015-02-23 16:56:33 -0500 | [diff] [blame] | 169 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat2, "outerProduct", float2, float2); |
| 170 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat3, "outerProduct", float3, float3); |
| 171 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat4, "outerProduct", float4, float4); |
| 172 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat2x3, "outerProduct", float3, float2); |
| 173 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat3x2, "outerProduct", float2, float3); |
| 174 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat2x4, "outerProduct", float4, float2); |
| 175 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat4x2, "outerProduct", float2, float4); |
| 176 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat3x4, "outerProduct", float4, float3); |
| 177 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat4x3, "outerProduct", float3, float4); |
Olli Etuaho | e39706d | 2014-12-30 16:40:36 +0200 | [diff] [blame] | 178 | |
Nicolas Capens | 482907e | 2015-02-23 16:56:33 -0500 | [diff] [blame] | 179 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat2, "transpose", mat2); |
| 180 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat3, "transpose", mat3); |
| 181 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat4, "transpose", mat4); |
| 182 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat2x3, "transpose", mat3x2); |
| 183 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat3x2, "transpose", mat2x3); |
| 184 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat2x4, "transpose", mat4x2); |
| 185 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat4x2, "transpose", mat2x4); |
| 186 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat3x4, "transpose", mat4x3); |
| 187 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat4x3, "transpose", mat3x4); |
Olli Etuaho | e39706d | 2014-12-30 16:40:36 +0200 | [diff] [blame] | 188 | |
Nicolas Capens | 482907e | 2015-02-23 16:56:33 -0500 | [diff] [blame] | 189 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDeterminant, float1, "determinant", mat2); |
| 190 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDeterminant, float1, "determinant", mat3); |
| 191 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDeterminant, float1, "determinant", mat4); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 192 | |
Nicolas Capens | 482907e | 2015-02-23 16:56:33 -0500 | [diff] [blame] | 193 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpInverse, mat2, "inverse", mat2); |
| 194 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpInverse, mat3, "inverse", mat3); |
| 195 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpInverse, mat4, "inverse", mat4); |
Olli Etuaho | abf6dad | 2015-01-14 14:45:16 +0200 | [diff] [blame] | 196 | |
Dmitry Skiba | 0197111 | 2015-07-10 14:54:00 -0400 | [diff] [blame] | 197 | const TType *vec = TCache::getType(EbtVec); |
| 198 | const TType *ivec = TCache::getType(EbtIVec); |
| 199 | const TType *uvec = TCache::getType(EbtUVec); |
| 200 | const TType *bvec = TCache::getType(EbtBVec); |
Nicolas Capens | f3cc4ae | 2015-02-23 13:51:25 -0500 | [diff] [blame] | 201 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 202 | // |
| 203 | // Vector relational functions. |
| 204 | // |
Nicolas Capens | 482907e | 2015-02-23 16:56:33 -0500 | [diff] [blame] | 205 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThan, bvec, "lessThan", vec, vec); |
| 206 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThan, bvec, "lessThan", ivec, ivec); |
| 207 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpLessThan, bvec, "lessThan", uvec, uvec); |
| 208 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThanEqual, bvec, "lessThanEqual", vec, vec); |
| 209 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThanEqual, bvec, "lessThanEqual", ivec, ivec); |
| 210 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpLessThanEqual, bvec, "lessThanEqual", uvec, uvec); |
| 211 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThan, bvec, "greaterThan", vec, vec); |
| 212 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThan, bvec, "greaterThan", ivec, ivec); |
| 213 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpGreaterThan, bvec, "greaterThan", uvec, uvec); |
| 214 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThanEqual, bvec, "greaterThanEqual", vec, vec); |
| 215 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThanEqual, bvec, "greaterThanEqual", ivec, ivec); |
| 216 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpGreaterThanEqual, bvec, "greaterThanEqual", uvec, uvec); |
| 217 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorEqual, bvec, "equal", vec, vec); |
| 218 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorEqual, bvec, "equal", ivec, ivec); |
| 219 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpVectorEqual, bvec, "equal", uvec, uvec); |
| 220 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorEqual, bvec, "equal", bvec, bvec); |
| 221 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", vec, vec); |
| 222 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", ivec, ivec); |
| 223 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", uvec, uvec); |
| 224 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", bvec, bvec); |
| 225 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAny, bool1, "any", bvec); |
| 226 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAll, bool1, "all", bvec); |
| 227 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorLogicalNot, bvec, "not", bvec); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 228 | |
Dmitry Skiba | 0197111 | 2015-07-10 14:54:00 -0400 | [diff] [blame] | 229 | const TType *sampler2D = TCache::getType(EbtSampler2D); |
| 230 | const TType *samplerCube = TCache::getType(EbtSamplerCube); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 231 | |
| 232 | // |
| 233 | // Texture Functions for GLSL ES 1.0 |
| 234 | // |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 235 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, float2); |
| 236 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float3); |
| 237 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float4); |
| 238 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, float3); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 239 | |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 240 | if (resources.OES_EGL_image_external || resources.NV_EGL_stream_consumer_external) |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 241 | { |
Dmitry Skiba | 0197111 | 2015-07-10 14:54:00 -0400 | [diff] [blame] | 242 | const TType *samplerExternalOES = TCache::getType(EbtSamplerExternalOES); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 243 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 244 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", samplerExternalOES, float2); |
| 245 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, float3); |
| 246 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, float4); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 247 | } |
| 248 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 249 | if (resources.ARB_texture_rectangle) |
| 250 | { |
Dmitry Skiba | 0197111 | 2015-07-10 14:54:00 -0400 | [diff] [blame] | 251 | const TType *sampler2DRect = TCache::getType(EbtSampler2DRect); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 252 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 253 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRect", sampler2DRect, float2); |
| 254 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect, float3); |
| 255 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect, float4); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 256 | } |
| 257 | |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 258 | if (resources.EXT_shader_texture_lod) |
| 259 | { |
| 260 | /* The *Grad* variants are new to both vertex and fragment shaders; the fragment |
| 261 | * shader specific pieces are added separately below. |
| 262 | */ |
Nicolas Capens | c9d9b30 | 2015-02-20 23:02:15 -0500 | [diff] [blame] | 263 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "texture2DGradEXT", sampler2D, float2, float2, float2); |
| 264 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "texture2DProjGradEXT", sampler2D, float3, float2, float2); |
| 265 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "texture2DProjGradEXT", sampler2D, float4, float2, float2); |
| 266 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "textureCubeGradEXT", samplerCube, float3, float3, float3); |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 267 | } |
| 268 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 269 | if (type == GL_FRAGMENT_SHADER) |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 270 | { |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 271 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, float2, float1); |
| 272 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float3, float1); |
| 273 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float4, float1); |
| 274 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, float3, float1); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 275 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 276 | if (resources.OES_standard_derivatives) |
| 277 | { |
Nicolas Capens | c9d9b30 | 2015-02-20 23:02:15 -0500 | [diff] [blame] | 278 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpDFdx, "GL_OES_standard_derivatives", genType, "dFdx", genType); |
| 279 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpDFdy, "GL_OES_standard_derivatives", genType, "dFdy", genType); |
| 280 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpFwidth, "GL_OES_standard_derivatives", genType, "fwidth", genType); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 281 | } |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 282 | |
| 283 | if (resources.EXT_shader_texture_lod) |
| 284 | { |
Nicolas Capens | c9d9b30 | 2015-02-20 23:02:15 -0500 | [diff] [blame] | 285 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "texture2DLodEXT", sampler2D, float2, float1); |
| 286 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "texture2DProjLodEXT", sampler2D, float3, float1); |
| 287 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "texture2DProjLodEXT", sampler2D, float4, float1); |
| 288 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, "GL_EXT_shader_texture_lod", float4, "textureCubeLodEXT", samplerCube, float3, float1); |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 289 | } |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 290 | } |
| 291 | |
Nicolas Capens | f3cc4ae | 2015-02-23 13:51:25 -0500 | [diff] [blame] | 292 | if (type == GL_VERTEX_SHADER) |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 293 | { |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 294 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DLod", sampler2D, float2, float1); |
| 295 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, float3, float1); |
| 296 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, float4, float1); |
| 297 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeLod", samplerCube, float3, float1); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 298 | } |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 299 | |
Dmitry Skiba | 0197111 | 2015-07-10 14:54:00 -0400 | [diff] [blame] | 300 | const TType *gvec4 = TCache::getType(EbtGVec4); |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 301 | |
Dmitry Skiba | 0197111 | 2015-07-10 14:54:00 -0400 | [diff] [blame] | 302 | const TType *gsampler2D = TCache::getType(EbtGSampler2D); |
| 303 | const TType *gsamplerCube = TCache::getType(EbtGSamplerCube); |
| 304 | const TType *gsampler3D = TCache::getType(EbtGSampler3D); |
| 305 | const TType *gsampler2DArray = TCache::getType(EbtGSampler2DArray); |
Nicolas Capens | 73f5bf6 | 2013-06-17 16:13:33 -0400 | [diff] [blame] | 306 | |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 307 | // |
| 308 | // Texture Functions for GLSL ES 3.0 |
| 309 | // |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 310 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2D, float2); |
| 311 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler3D, float3); |
| 312 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsamplerCube, float3); |
| 313 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2DArray, float3); |
| 314 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float3); |
| 315 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float4); |
| 316 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler3D, float4); |
| 317 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler2D, float2, float1); |
| 318 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler3D, float3, float1); |
| 319 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsamplerCube, float3, float1); |
| 320 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler2DArray, float3, float1); |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 321 | |
Geoff Lang | b66a909 | 2016-05-16 15:59:14 -0400 | [diff] [blame] | 322 | if (resources.OES_EGL_image_external_essl3) |
| 323 | { |
| 324 | const TType *samplerExternalOES = TCache::getType(EbtSamplerExternalOES); |
| 325 | |
| 326 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "texture", samplerExternalOES, float2); |
| 327 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "textureProj", samplerExternalOES, |
| 328 | float3); |
| 329 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "textureProj", samplerExternalOES, |
| 330 | float4); |
| 331 | } |
| 332 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 333 | if (type == GL_FRAGMENT_SHADER) |
Nicolas Capens | 67a819f | 2013-07-09 12:08:58 -0400 | [diff] [blame] | 334 | { |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 335 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2D, float2, float1); |
| 336 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler3D, float3, float1); |
| 337 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsamplerCube, float3, float1); |
| 338 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2DArray, float3, float1); |
| 339 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float3, float1); |
| 340 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float4, float1); |
| 341 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler3D, float4, float1); |
Geoff Lang | b66a909 | 2016-05-16 15:59:14 -0400 | [diff] [blame] | 342 | |
| 343 | if (resources.OES_EGL_image_external_essl3) |
| 344 | { |
| 345 | const TType *samplerExternalOES = TCache::getType(EbtSamplerExternalOES); |
| 346 | |
| 347 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "texture", samplerExternalOES, float2, |
| 348 | float1); |
| 349 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "textureProj", samplerExternalOES, |
| 350 | float3, float1); |
| 351 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "textureProj", samplerExternalOES, |
| 352 | float4, float1); |
| 353 | } |
Nicolas Capens | 67a819f | 2013-07-09 12:08:58 -0400 | [diff] [blame] | 354 | } |
| 355 | |
Dmitry Skiba | 0197111 | 2015-07-10 14:54:00 -0400 | [diff] [blame] | 356 | const TType *sampler2DShadow = TCache::getType(EbtSampler2DShadow); |
| 357 | const TType *samplerCubeShadow = TCache::getType(EbtSamplerCubeShadow); |
| 358 | const TType *sampler2DArrayShadow = TCache::getType(EbtSampler2DArrayShadow); |
Nicolas Capens | 77c9d1a | 2013-07-11 11:10:34 -0400 | [diff] [blame] | 359 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 360 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DShadow, float3); |
| 361 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", samplerCubeShadow, float4); |
| 362 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DArrayShadow, float4); |
| 363 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProj", sampler2DShadow, float4); |
Jamie Madill | 16a1c07 | 2013-10-22 15:42:15 -0400 | [diff] [blame] | 364 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureLod", sampler2DShadow, float3, float1); |
Nicolas Capens | 77c9d1a | 2013-07-11 11:10:34 -0400 | [diff] [blame] | 365 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 366 | if (type == GL_FRAGMENT_SHADER) |
Nicolas Capens | 77c9d1a | 2013-07-11 11:10:34 -0400 | [diff] [blame] | 367 | { |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 368 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DShadow, float3, float1); |
| 369 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", samplerCubeShadow, float4, float1); |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 370 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProj", sampler2DShadow, float4, float1); |
Nicolas Capens | 77c9d1a | 2013-07-11 11:10:34 -0400 | [diff] [blame] | 371 | } |
| 372 | |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 373 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", gsampler2D, int1); |
| 374 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", gsampler3D, int1); |
| 375 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", gsamplerCube, int1); |
| 376 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", gsampler2DArray, int1); |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 377 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", sampler2DShadow, int1); |
| 378 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", samplerCubeShadow, int1); |
| 379 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", sampler2DArrayShadow, int1); |
Nicolas Capens | 75fb475 | 2013-07-10 15:14:47 -0400 | [diff] [blame] | 380 | |
Geoff Lang | b66a909 | 2016-05-16 15:59:14 -0400 | [diff] [blame] | 381 | if (resources.OES_EGL_image_external_essl3) |
| 382 | { |
| 383 | const TType *samplerExternalOES = TCache::getType(EbtSamplerExternalOES); |
| 384 | |
| 385 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", samplerExternalOES, int1); |
| 386 | } |
| 387 | |
Nicolas Capens | f3cc4ae | 2015-02-23 13:51:25 -0500 | [diff] [blame] | 388 | if (type == GL_FRAGMENT_SHADER) |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 389 | { |
Olli Etuaho | 687ef22 | 2015-03-03 10:58:05 +0200 | [diff] [blame] | 390 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDFdx, genType, "dFdx", genType); |
| 391 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDFdy, genType, "dFdy", genType); |
| 392 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpFwidth, genType, "fwidth", genType); |
alokp@chromium.org | 0609889 | 2010-08-26 19:36:42 +0000 | [diff] [blame] | 393 | } |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 394 | |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 395 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2); |
| 396 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler3D, float3, int3); |
| 397 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureOffset", sampler2DShadow, float3, int2); |
| 398 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2DArray, float3, int2); |
| 399 | |
Nicolas Capens | f3cc4ae | 2015-02-23 13:51:25 -0500 | [diff] [blame] | 400 | if (type == GL_FRAGMENT_SHADER) |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 401 | { |
| 402 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2, float1); |
| 403 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler3D, float3, int3, float1); |
| 404 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureOffset", sampler2DShadow, float3, int2, float1); |
| 405 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2DArray, float3, int2, float1); |
| 406 | } |
Nicolas Capens | 1fbc287 | 2014-01-03 14:12:09 -0500 | [diff] [blame] | 407 | |
Nicolas Capens | df86c6b | 2014-02-14 20:09:17 -0500 | [diff] [blame] | 408 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float3, int2); |
| 409 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float4, int2); |
| 410 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler3D, float4, int3); |
| 411 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjOffset", sampler2DShadow, float4, int2); |
| 412 | |
Nicolas Capens | f3cc4ae | 2015-02-23 13:51:25 -0500 | [diff] [blame] | 413 | if (type == GL_FRAGMENT_SHADER) |
Nicolas Capens | df86c6b | 2014-02-14 20:09:17 -0500 | [diff] [blame] | 414 | { |
| 415 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float3, int2, float1); |
| 416 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float4, int2, float1); |
| 417 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler3D, float4, int3, float1); |
| 418 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjOffset", sampler2DShadow, float4, int2, float1); |
| 419 | } |
| 420 | |
| 421 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler2D, float2, float1, int2); |
| 422 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler3D, float3, float1, int3); |
| 423 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureLodOffset", sampler2DShadow, float3, float1, int2); |
| 424 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler2DArray, float3, float1, int2); |
| 425 | |
Nicolas Capens | 2adc256 | 2014-02-14 23:50:59 -0500 | [diff] [blame] | 426 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler2D, float3, float1); |
| 427 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler2D, float4, float1); |
| 428 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler3D, float4, float1); |
| 429 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjLod", sampler2DShadow, float4, float1); |
| 430 | |
| 431 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler2D, float3, float1, int2); |
| 432 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler2D, float4, float1, int2); |
| 433 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler3D, float4, float1, int3); |
| 434 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjLodOffset", sampler2DShadow, float4, float1, int2); |
| 435 | |
Nicolas Capens | fc01454 | 2014-02-18 14:47:13 -0500 | [diff] [blame] | 436 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler2D, int2, int1); |
| 437 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler3D, int3, int1); |
| 438 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler2DArray, int3, int1); |
| 439 | |
Geoff Lang | b66a909 | 2016-05-16 15:59:14 -0400 | [diff] [blame] | 440 | if (resources.OES_EGL_image_external_essl3) |
| 441 | { |
| 442 | const TType *samplerExternalOES = TCache::getType(EbtSamplerExternalOES); |
| 443 | |
| 444 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "texelFetch", samplerExternalOES, int2, |
| 445 | int1); |
| 446 | } |
| 447 | |
Nicolas Capens | fc01454 | 2014-02-18 14:47:13 -0500 | [diff] [blame] | 448 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler2D, int2, int1, int2); |
| 449 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler3D, int3, int1, int3); |
| 450 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler2DArray, int3, int1, int2); |
| 451 | |
Nicolas Capens | d11d549 | 2014-02-19 17:06:10 -0500 | [diff] [blame] | 452 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler2D, float2, float2, float2); |
| 453 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler3D, float3, float3, float3); |
| 454 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsamplerCube, float3, float3, float3); |
| 455 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", sampler2DShadow, float3, float2, float2); |
| 456 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", samplerCubeShadow, float4, float3, float3); |
| 457 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler2DArray, float3, float2, float2); |
| 458 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", sampler2DArrayShadow, float4, float2, float2); |
| 459 | |
Nicolas Capens | bf7db10 | 2014-02-19 17:20:28 -0500 | [diff] [blame] | 460 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler2D, float2, float2, float2, int2); |
| 461 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler3D, float3, float3, float3, int3); |
| 462 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGradOffset", sampler2DShadow, float3, float2, float2, int2); |
| 463 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler2DArray, float3, float2, float2, int2); |
| 464 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGradOffset", sampler2DArrayShadow, float4, float2, float2, int2); |
| 465 | |
Nicolas Capens | f7378e3 | 2014-02-19 17:29:32 -0500 | [diff] [blame] | 466 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler2D, float3, float2, float2); |
| 467 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler2D, float4, float2, float2); |
| 468 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler3D, float4, float3, float3); |
| 469 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjGrad", sampler2DShadow, float4, float2, float2); |
| 470 | |
| 471 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler2D, float3, float2, float2, int2); |
| 472 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler2D, float4, float2, float2, int2); |
| 473 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler3D, float4, float3, float3, int3); |
| 474 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjGradOffset", sampler2DShadow, float4, float2, float2, int2); |
| 475 | |
Martin Radev | 2cc85b3 | 2016-08-05 16:22:53 +0300 | [diff] [blame] | 476 | const TType *gimage2D = TCache::getType(EbtGImage2D); |
| 477 | const TType *gimage3D = TCache::getType(EbtGImage3D); |
| 478 | const TType *gimage2DArray = TCache::getType(EbtGImage2DArray); |
| 479 | const TType *gimageCube = TCache::getType(EbtGImageCube); |
| 480 | |
| 481 | symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, voidType, "imageStore", gimage2D, int2, gvec4); |
| 482 | symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, voidType, "imageStore", gimage3D, int3, gvec4); |
| 483 | symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, voidType, "imageStore", gimage2DArray, int3, gvec4); |
| 484 | symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, voidType, "imageStore", gimageCube, int3, gvec4); |
| 485 | |
| 486 | symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "imageLoad", gimage2D, int2); |
| 487 | symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "imageLoad", gimage3D, int3); |
| 488 | symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "imageLoad", gimage2DArray, int3); |
| 489 | symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, gvec4, "imageLoad", gimageCube, int3); |
| 490 | |
| 491 | symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, int2, "imageSize", gimage2D); |
| 492 | symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, int3, "imageSize", gimage3D); |
| 493 | symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, int3, "imageSize", gimage2DArray); |
| 494 | symbolTable.insertBuiltIn(ESSL3_1_BUILTINS, int3, "imageSize", gimageCube); |
| 495 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 496 | // |
| 497 | // Depth range in window coordinates |
| 498 | // |
Jamie Madill | 98493dd | 2013-07-08 14:39:03 -0400 | [diff] [blame] | 499 | TFieldList *fields = NewPoolTFieldList(); |
Jamie Madill | 37f77d2 | 2014-04-30 16:10:13 -0400 | [diff] [blame] | 500 | TSourceLoc zeroSourceLoc = {0, 0, 0, 0}; |
Jamie Madill | e064d44 | 2016-06-21 20:00:41 -0400 | [diff] [blame] | 501 | auto highpFloat1 = new TType(EbtFloat, EbpHigh, EvqGlobal, 1); |
| 502 | TField *near = new TField(highpFloat1, NewPoolTString("near"), zeroSourceLoc); |
| 503 | TField *far = new TField(highpFloat1, NewPoolTString("far"), zeroSourceLoc); |
| 504 | TField *diff = new TField(highpFloat1, NewPoolTString("diff"), zeroSourceLoc); |
Jamie Madill | 98493dd | 2013-07-08 14:39:03 -0400 | [diff] [blame] | 505 | fields->push_back(near); |
| 506 | fields->push_back(far); |
| 507 | fields->push_back(diff); |
| 508 | TStructure *depthRangeStruct = new TStructure(NewPoolTString("gl_DepthRangeParameters"), fields); |
Jamie Madill | e064d44 | 2016-06-21 20:00:41 -0400 | [diff] [blame] | 509 | TVariable *depthRangeParameters = |
| 510 | new TVariable(&depthRangeStruct->name(), TType(depthRangeStruct), true); |
Nicolas Capens | adfffe4 | 2014-06-17 02:13:36 -0400 | [diff] [blame] | 511 | symbolTable.insert(COMMON_BUILTINS, depthRangeParameters); |
Jamie Madill | 98493dd | 2013-07-08 14:39:03 -0400 | [diff] [blame] | 512 | TVariable *depthRange = new TVariable(NewPoolTString("gl_DepthRange"), TType(depthRangeStruct)); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 513 | depthRange->setQualifier(EvqUniform); |
Jamie Madill | e064d44 | 2016-06-21 20:00:41 -0400 | [diff] [blame] | 514 | // Ensure we evaluate the mangled name for depth range, so we allocate to the current scope. |
| 515 | depthRangeParameters->getType().getMangledName(); |
| 516 | depthRange->getType().getMangledName(); |
Nicolas Capens | adfffe4 | 2014-06-17 02:13:36 -0400 | [diff] [blame] | 517 | symbolTable.insert(COMMON_BUILTINS, depthRange); |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 518 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 519 | // |
| 520 | // Implementation dependent built-in constants. |
| 521 | // |
Martin Radev | e93d24e | 2016-07-28 12:06:05 +0300 | [diff] [blame] | 522 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexAttribs", resources.MaxVertexAttribs, |
| 523 | EbpMedium); |
| 524 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexUniformVectors", |
| 525 | resources.MaxVertexUniformVectors, EbpMedium); |
| 526 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexTextureImageUnits", |
| 527 | resources.MaxVertexTextureImageUnits, EbpMedium); |
| 528 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxCombinedTextureImageUnits", |
| 529 | resources.MaxCombinedTextureImageUnits, EbpMedium); |
| 530 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxTextureImageUnits", |
| 531 | resources.MaxTextureImageUnits, EbpMedium); |
| 532 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxFragmentUniformVectors", |
| 533 | resources.MaxFragmentUniformVectors, EbpMedium); |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 534 | |
Martin Radev | e93d24e | 2016-07-28 12:06:05 +0300 | [diff] [blame] | 535 | symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxVaryingVectors", resources.MaxVaryingVectors, |
| 536 | EbpMedium); |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 537 | |
Qiankun Miao | c2c5fc4 | 2016-08-31 15:24:22 +0800 | [diff] [blame] | 538 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxDrawBuffers", resources.MaxDrawBuffers, |
| 539 | EbpMedium); |
| 540 | if (resources.EXT_blend_func_extended) |
shannon.woods%transgaming.com@gtempaccount.com | 5209de8 | 2013-04-13 03:41:53 +0000 | [diff] [blame] | 541 | { |
Qiankun Miao | c2c5fc4 | 2016-08-31 15:24:22 +0800 | [diff] [blame] | 542 | symbolTable.insertConstIntExt(COMMON_BUILTINS, "GL_EXT_blend_func_extended", |
| 543 | "gl_MaxDualSourceDrawBuffersEXT", |
| 544 | resources.MaxDualSourceDrawBuffers); |
shannon.woods%transgaming.com@gtempaccount.com | 5209de8 | 2013-04-13 03:41:53 +0000 | [diff] [blame] | 545 | } |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 546 | |
Martin Radev | e93d24e | 2016-07-28 12:06:05 +0300 | [diff] [blame] | 547 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxVertexOutputVectors", |
| 548 | resources.MaxVertexOutputVectors, EbpMedium); |
| 549 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxFragmentInputVectors", |
| 550 | resources.MaxFragmentInputVectors, EbpMedium); |
| 551 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MinProgramTexelOffset", |
| 552 | resources.MinProgramTexelOffset, EbpMedium); |
| 553 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxProgramTexelOffset", |
| 554 | resources.MaxProgramTexelOffset, EbpMedium); |
| 555 | |
| 556 | symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxImageUnits", resources.MaxImageUnits, |
| 557 | EbpMedium); |
| 558 | symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxVertexImageUniforms", |
| 559 | resources.MaxVertexImageUniforms, EbpMedium); |
| 560 | symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxFragmentImageUniforms", |
| 561 | resources.MaxFragmentImageUniforms, EbpMedium); |
| 562 | symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxComputeImageUniforms", |
| 563 | resources.MaxComputeImageUniforms, EbpMedium); |
| 564 | symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxCombinedImageUniforms", |
| 565 | resources.MaxCombinedImageUniforms, EbpMedium); |
| 566 | |
| 567 | symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxCombinedShaderOutputResources", |
| 568 | resources.MaxCombinedShaderOutputResources, EbpMedium); |
| 569 | |
| 570 | symbolTable.insertConstIvec3(ESSL3_1_BUILTINS, "gl_MaxComputeWorkGroupCount", |
| 571 | resources.MaxComputeWorkGroupCount, EbpHigh); |
| 572 | symbolTable.insertConstIvec3(ESSL3_1_BUILTINS, "gl_MaxComputeWorkGroupSize", |
| 573 | resources.MaxComputeWorkGroupSize, EbpHigh); |
| 574 | symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxComputeUniformComponents", |
| 575 | resources.MaxComputeUniformComponents, EbpMedium); |
| 576 | symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxComputeTextureImageUnits", |
| 577 | resources.MaxComputeTextureImageUnits, EbpMedium); |
| 578 | |
| 579 | symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxComputeAtomicCounters", |
| 580 | resources.MaxComputeAtomicCounters, EbpMedium); |
| 581 | symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxComputeAtomicCounterBuffers", |
| 582 | resources.MaxComputeAtomicCounterBuffers, EbpMedium); |
| 583 | |
| 584 | symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxVertexAtomicCounters", |
| 585 | resources.MaxVertexAtomicCounters, EbpMedium); |
| 586 | symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxFragmentAtomicCounters", |
| 587 | resources.MaxFragmentAtomicCounters, EbpMedium); |
| 588 | symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxCombinedAtomicCounters", |
| 589 | resources.MaxCombinedAtomicCounters, EbpMedium); |
| 590 | symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxAtomicCounterBindings", |
| 591 | resources.MaxAtomicCounterBindings, EbpMedium); |
| 592 | |
| 593 | symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxVertexAtomicCounterBuffers", |
| 594 | resources.MaxVertexAtomicCounterBuffers, EbpMedium); |
| 595 | symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxFragmentAtomicCounterBuffers", |
| 596 | resources.MaxFragmentAtomicCounterBuffers, EbpMedium); |
| 597 | symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxCombinedAtomicCounterBuffers", |
| 598 | resources.MaxCombinedAtomicCounterBuffers, EbpMedium); |
| 599 | symbolTable.insertConstInt(ESSL3_1_BUILTINS, "gl_MaxAtomicCounterBufferSize", |
| 600 | resources.MaxAtomicCounterBufferSize, EbpMedium); |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 601 | } |
| 602 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 603 | void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec, |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 604 | const ShBuiltInResources &resources, |
| 605 | TSymbolTable &symbolTable) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 606 | { |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 607 | // |
Olli Etuaho | 4f52da4 | 2015-03-11 10:48:41 +0200 | [diff] [blame] | 608 | // Insert some special built-in variables that are not in |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 609 | // the built-in header files. |
| 610 | // |
Olli Etuaho | 61ffec8 | 2015-03-11 10:35:01 +0200 | [diff] [blame] | 611 | switch (type) |
| 612 | { |
| 613 | case GL_FRAGMENT_SHADER: |
Qiankun Miao | c2c5fc4 | 2016-08-31 15:24:22 +0800 | [diff] [blame] | 614 | { |
| 615 | symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FragCoord"), |
| 616 | TType(EbtFloat, EbpMedium, EvqFragCoord, 4))); |
| 617 | symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FrontFacing"), |
| 618 | TType(EbtBool, EbpUndefined, EvqFrontFacing, 1))); |
| 619 | symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointCoord"), |
| 620 | TType(EbtFloat, EbpMedium, EvqPointCoord, 2))); |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 621 | |
Qiankun Miao | c2c5fc4 | 2016-08-31 15:24:22 +0800 | [diff] [blame] | 622 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragColor"), |
| 623 | TType(EbtFloat, EbpMedium, EvqFragColor, 4))); |
| 624 | TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true); |
| 625 | fragData.setArraySize(resources.MaxDrawBuffers); |
| 626 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData"), fragData)); |
Olli Etuaho | 4f52da4 | 2015-03-11 10:48:41 +0200 | [diff] [blame] | 627 | |
Qiankun Miao | c2c5fc4 | 2016-08-31 15:24:22 +0800 | [diff] [blame] | 628 | if (resources.EXT_blend_func_extended) |
| 629 | { |
| 630 | symbolTable.insert( |
| 631 | ESSL1_BUILTINS, "GL_EXT_blend_func_extended", |
| 632 | new TVariable(NewPoolTString("gl_SecondaryFragColorEXT"), |
| 633 | TType(EbtFloat, EbpMedium, EvqSecondaryFragColorEXT, 4))); |
| 634 | TType secondaryFragData(EbtFloat, EbpMedium, EvqSecondaryFragDataEXT, 4, 1, true); |
| 635 | secondaryFragData.setArraySize(resources.MaxDualSourceDrawBuffers); |
| 636 | symbolTable.insert( |
| 637 | ESSL1_BUILTINS, "GL_EXT_blend_func_extended", |
| 638 | new TVariable(NewPoolTString("gl_SecondaryFragDataEXT"), secondaryFragData)); |
| 639 | } |
Kimmo Kinnunen | b18609b | 2015-07-16 14:13:11 +0300 | [diff] [blame] | 640 | |
Qiankun Miao | c2c5fc4 | 2016-08-31 15:24:22 +0800 | [diff] [blame] | 641 | if (resources.EXT_frag_depth) |
| 642 | { |
| 643 | symbolTable.insert( |
| 644 | ESSL1_BUILTINS, "GL_EXT_frag_depth", |
| 645 | new TVariable( |
| 646 | NewPoolTString("gl_FragDepthEXT"), |
| 647 | TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, |
| 648 | EvqFragDepthEXT, 1))); |
| 649 | } |
Olli Etuaho | 4f52da4 | 2015-03-11 10:48:41 +0200 | [diff] [blame] | 650 | |
Qiankun Miao | c2c5fc4 | 2016-08-31 15:24:22 +0800 | [diff] [blame] | 651 | symbolTable.insert(ESSL3_BUILTINS, |
| 652 | new TVariable(NewPoolTString("gl_FragDepth"), |
| 653 | TType(EbtFloat, EbpHigh, EvqFragDepth, 1))); |
Kimmo Kinnunen | 5f0246c | 2015-07-22 10:30:35 +0300 | [diff] [blame] | 654 | |
Qiankun Miao | c2c5fc4 | 2016-08-31 15:24:22 +0800 | [diff] [blame] | 655 | if (resources.EXT_shader_framebuffer_fetch || resources.NV_shader_framebuffer_fetch) |
| 656 | { |
| 657 | TType lastFragData(EbtFloat, EbpMedium, EvqLastFragData, 4, 1, true); |
| 658 | lastFragData.setArraySize(resources.MaxDrawBuffers); |
Olli Etuaho | 4f52da4 | 2015-03-11 10:48:41 +0200 | [diff] [blame] | 659 | |
Qiankun Miao | c2c5fc4 | 2016-08-31 15:24:22 +0800 | [diff] [blame] | 660 | if (resources.EXT_shader_framebuffer_fetch) |
| 661 | { |
| 662 | symbolTable.insert(ESSL1_BUILTINS, "GL_EXT_shader_framebuffer_fetch", |
| 663 | new TVariable(NewPoolTString("gl_LastFragData"), lastFragData)); |
| 664 | } |
| 665 | else if (resources.NV_shader_framebuffer_fetch) |
| 666 | { |
| 667 | symbolTable.insert(ESSL1_BUILTINS, "GL_NV_shader_framebuffer_fetch", |
| 668 | new TVariable(NewPoolTString("gl_LastFragColor"), |
| 669 | TType(EbtFloat, EbpMedium, EvqLastFragColor, 4))); |
| 670 | symbolTable.insert(ESSL1_BUILTINS, "GL_NV_shader_framebuffer_fetch", |
| 671 | new TVariable(NewPoolTString("gl_LastFragData"), lastFragData)); |
| 672 | } |
| 673 | } |
| 674 | else if (resources.ARM_shader_framebuffer_fetch) |
| 675 | { |
| 676 | symbolTable.insert(ESSL1_BUILTINS, "GL_ARM_shader_framebuffer_fetch", |
| 677 | new TVariable(NewPoolTString("gl_LastFragColorARM"), |
| 678 | TType(EbtFloat, EbpMedium, EvqLastFragColor, 4))); |
| 679 | } |
| 680 | } |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 681 | |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 682 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 683 | |
Olli Etuaho | 61ffec8 | 2015-03-11 10:35:01 +0200 | [diff] [blame] | 684 | case GL_VERTEX_SHADER: |
| 685 | symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_Position"), |
| 686 | TType(EbtFloat, EbpHigh, EvqPosition, 4))); |
| 687 | symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointSize"), |
| 688 | TType(EbtFloat, EbpMedium, EvqPointSize, 1))); |
| 689 | symbolTable.insert(ESSL3_BUILTINS, new TVariable(NewPoolTString("gl_InstanceID"), |
| 690 | TType(EbtInt, EbpHigh, EvqInstanceID, 1))); |
Corentin Wallez | b076add | 2016-01-11 16:45:46 -0500 | [diff] [blame] | 691 | symbolTable.insert(ESSL3_BUILTINS, new TVariable(NewPoolTString("gl_VertexID"), |
| 692 | TType(EbtInt, EbpHigh, EvqVertexID, 1))); |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 693 | break; |
Martin Radev | 802abe0 | 2016-08-04 17:48:32 +0300 | [diff] [blame] | 694 | case GL_COMPUTE_SHADER: |
Martin Radev | b088360 | 2016-08-04 17:48:58 +0300 | [diff] [blame] | 695 | { |
| 696 | symbolTable.insert(ESSL3_1_BUILTINS, |
| 697 | new TVariable(NewPoolTString("gl_NumWorkGroups"), |
| 698 | TType(EbtUInt, EbpUndefined, EvqNumWorkGroups, 3))); |
| 699 | symbolTable.insert(ESSL3_1_BUILTINS, |
| 700 | new TVariable(NewPoolTString("gl_WorkGroupSize"), |
| 701 | TType(EbtUInt, EbpUndefined, EvqWorkGroupSize, 3))); |
| 702 | symbolTable.insert(ESSL3_1_BUILTINS, |
| 703 | new TVariable(NewPoolTString("gl_WorkGroupID"), |
| 704 | TType(EbtUInt, EbpUndefined, EvqWorkGroupID, 3))); |
| 705 | symbolTable.insert(ESSL3_1_BUILTINS, |
| 706 | new TVariable(NewPoolTString("gl_LocalInvocationID"), |
| 707 | TType(EbtUInt, EbpUndefined, EvqLocalInvocationID, 3))); |
| 708 | symbolTable.insert(ESSL3_1_BUILTINS, |
| 709 | new TVariable(NewPoolTString("gl_GlobalInvocationID"), |
| 710 | TType(EbtUInt, EbpUndefined, EvqGlobalInvocationID, 3))); |
| 711 | symbolTable.insert( |
| 712 | ESSL3_1_BUILTINS, |
| 713 | new TVariable(NewPoolTString("gl_LocalInvocationIndex"), |
| 714 | TType(EbtUInt, EbpUndefined, EvqLocalInvocationIndex, 1))); |
| 715 | } |
| 716 | break; |
| 717 | |
Olli Etuaho | 61ffec8 | 2015-03-11 10:35:01 +0200 | [diff] [blame] | 718 | default: |
| 719 | assert(false && "Language not supported"); |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 720 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 721 | } |
| 722 | |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 723 | void InitExtensionBehavior(const ShBuiltInResources& resources, |
alokp@chromium.org | ad771eb | 2010-09-07 17:36:23 +0000 | [diff] [blame] | 724 | TExtensionBehavior& extBehavior) |
| 725 | { |
| 726 | if (resources.OES_standard_derivatives) |
zmo@google.com | 09c323a | 2011-08-12 18:22:25 +0000 | [diff] [blame] | 727 | extBehavior["GL_OES_standard_derivatives"] = EBhUndefined; |
| 728 | if (resources.OES_EGL_image_external) |
| 729 | extBehavior["GL_OES_EGL_image_external"] = EBhUndefined; |
Geoff Lang | b66a909 | 2016-05-16 15:59:14 -0400 | [diff] [blame] | 730 | if (resources.OES_EGL_image_external_essl3) |
| 731 | extBehavior["GL_OES_EGL_image_external_essl3"] = EBhUndefined; |
Ian Ewell | bda7559 | 2016-04-18 17:25:54 -0400 | [diff] [blame] | 732 | if (resources.NV_EGL_stream_consumer_external) |
| 733 | extBehavior["GL_NV_EGL_stream_consumer_external"] = EBhUndefined; |
kbr@chromium.org | 205fef3 | 2011-11-22 20:50:02 +0000 | [diff] [blame] | 734 | if (resources.ARB_texture_rectangle) |
| 735 | extBehavior["GL_ARB_texture_rectangle"] = EBhUndefined; |
Kimmo Kinnunen | b18609b | 2015-07-16 14:13:11 +0300 | [diff] [blame] | 736 | if (resources.EXT_blend_func_extended) |
| 737 | extBehavior["GL_EXT_blend_func_extended"] = EBhUndefined; |
shannon.woods@transgaming.com | 550cd09 | 2013-02-28 23:19:54 +0000 | [diff] [blame] | 738 | if (resources.EXT_draw_buffers) |
| 739 | extBehavior["GL_EXT_draw_buffers"] = EBhUndefined; |
Jamie Madill | 2aeb26a | 2013-07-08 14:02:55 -0400 | [diff] [blame] | 740 | if (resources.EXT_frag_depth) |
| 741 | extBehavior["GL_EXT_frag_depth"] = EBhUndefined; |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 742 | if (resources.EXT_shader_texture_lod) |
| 743 | extBehavior["GL_EXT_shader_texture_lod"] = EBhUndefined; |
Erik Dahlström | ea7a212 | 2014-11-17 16:15:57 +0100 | [diff] [blame] | 744 | if (resources.EXT_shader_framebuffer_fetch) |
| 745 | extBehavior["GL_EXT_shader_framebuffer_fetch"] = EBhUndefined; |
| 746 | if (resources.NV_shader_framebuffer_fetch) |
| 747 | extBehavior["GL_NV_shader_framebuffer_fetch"] = EBhUndefined; |
| 748 | if (resources.ARM_shader_framebuffer_fetch) |
| 749 | extBehavior["GL_ARM_shader_framebuffer_fetch"] = EBhUndefined; |
alokp@chromium.org | ad771eb | 2010-09-07 17:36:23 +0000 | [diff] [blame] | 750 | } |
David Yen | 0fbd128 | 2015-02-02 14:46:09 -0800 | [diff] [blame] | 751 | |
| 752 | void ResetExtensionBehavior(TExtensionBehavior &extBehavior) |
| 753 | { |
| 754 | for (auto ext_iter = extBehavior.begin(); |
| 755 | ext_iter != extBehavior.end(); |
| 756 | ++ext_iter) |
| 757 | { |
| 758 | ext_iter->second = EBhUndefined; |
| 759 | } |
| 760 | } |
Jamie Madill | 45bcc78 | 2016-11-07 13:58:48 -0500 | [diff] [blame^] | 761 | |
| 762 | } // namespace sh |