John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1 | // |
John Bauman | d4ae863 | 2014-05-06 16:18:33 -0400 | [diff] [blame] | 2 | // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [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 | // |
| 8 | // Create strings that declare built-in definitions, add built-ins that |
| 9 | // cannot be expressed in the files, and establish mappings between |
| 10 | // built-in functions and operators. |
| 11 | // |
| 12 | |
Nicolas Capens | cc863da | 2015-01-21 15:50:55 -0500 | [diff] [blame] | 13 | #include "Initialize.h" |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 14 | |
Nicolas Capens | cc863da | 2015-01-21 15:50:55 -0500 | [diff] [blame] | 15 | #include "intermediate.h" |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 16 | |
Nicolas Capens | 08ca3c6 | 2015-02-13 16:06:45 -0500 | [diff] [blame] | 17 | void InsertBuiltInFunctions(GLenum type, const ShBuiltInResources &resources, TSymbolTable &symbolTable) |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 18 | { |
Nicolas Capens | 70da3d4 | 2015-02-18 16:58:10 -0500 | [diff] [blame] | 19 | TType *float1 = new TType(EbtFloat); |
| 20 | TType *float2 = new TType(EbtFloat, 2); |
| 21 | TType *float3 = new TType(EbtFloat, 3); |
| 22 | TType *float4 = new TType(EbtFloat, 4); |
Nicolas Capens | 8fa9d23 | 2015-02-19 15:53:16 -0500 | [diff] [blame] | 23 | TType *genType = new TType(EbtGenType); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 24 | |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 25 | TType *int1 = new TType(EbtInt); |
Alexis Hetu | b5332c5 | 2015-06-04 13:04:17 -0400 | [diff] [blame] | 26 | TType *int2 = new TType(EbtInt, 2); |
| 27 | TType *int3 = new TType(EbtInt, 3); |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 28 | TType *uint1 = new TType(EbtUInt); |
| 29 | TType *genIType = new TType(EbtGenIType); |
| 30 | TType *genUType = new TType(EbtGenUType); |
| 31 | TType *genBType = new TType(EbtGenBType); |
| 32 | |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 33 | // |
| 34 | // Angle and Trigonometric Functions. |
| 35 | // |
Nicolas Capens | 33cda11 | 2015-02-24 17:35:47 -0500 | [diff] [blame] | 36 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpRadians, genType, "radians", genType); |
| 37 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpDegrees, genType, "degrees", genType); |
| 38 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSin, genType, "sin", genType); |
| 39 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpCos, genType, "cos", genType); |
| 40 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpTan, genType, "tan", genType); |
| 41 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAsin, genType, "asin", genType); |
| 42 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAcos, genType, "acos", genType); |
| 43 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAtan, genType, "atan", genType, genType); |
| 44 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAtan, genType, "atan", genType); |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 45 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpSinh, genType, "sinh", genType); |
| 46 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpCosh, genType, "cosh", genType); |
| 47 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTanh, genType, "tanh", genType); |
| 48 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpAsinh, genType, "asinh", genType); |
| 49 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpAcosh, genType, "acosh", genType); |
| 50 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpAtanh, genType, "atanh", genType); |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 51 | |
| 52 | // |
| 53 | // Exponential Functions. |
| 54 | // |
Nicolas Capens | 33cda11 | 2015-02-24 17:35:47 -0500 | [diff] [blame] | 55 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpPow, genType, "pow", genType, genType); |
| 56 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpExp, genType, "exp", genType); |
| 57 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLog, genType, "log", genType); |
| 58 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpExp2, genType, "exp2", genType); |
| 59 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLog2, genType, "log2", genType); |
| 60 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSqrt, genType, "sqrt", genType); |
| 61 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpInverseSqrt, genType, "inversesqrt", genType); |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 62 | |
| 63 | // |
| 64 | // Common Functions. |
| 65 | // |
Nicolas Capens | 33cda11 | 2015-02-24 17:35:47 -0500 | [diff] [blame] | 66 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAbs, genType, "abs", genType); |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 67 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpAbs, genIType, "abs", genIType); |
Nicolas Capens | 33cda11 | 2015-02-24 17:35:47 -0500 | [diff] [blame] | 68 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSign, genType, "sign", genType); |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 69 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpSign, genIType, "sign", genIType); |
Nicolas Capens | 33cda11 | 2015-02-24 17:35:47 -0500 | [diff] [blame] | 70 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpFloor, genType, "floor", genType); |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 71 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTrunc, genType, "trunc", genType); |
| 72 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpRound, genType, "round", genType); |
| 73 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpRoundEven, genType, "roundEven", genType); |
Nicolas Capens | 33cda11 | 2015-02-24 17:35:47 -0500 | [diff] [blame] | 74 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpCeil, genType, "ceil", genType); |
| 75 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpFract, genType, "fract", genType); |
| 76 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMod, genType, "mod", genType, float1); |
| 77 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMod, genType, "mod", genType, genType); |
| 78 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMin, genType, "min", genType, float1); |
| 79 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMin, genType, "min", genType, genType); |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 80 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMin, genIType, "min", genIType, genIType); |
| 81 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMin, genIType, "min", genIType, int1); |
| 82 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMin, genUType, "min", genUType, genUType); |
| 83 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMin, genUType, "min", genUType, uint1); |
Nicolas Capens | 33cda11 | 2015-02-24 17:35:47 -0500 | [diff] [blame] | 84 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMax, genType, "max", genType, float1); |
| 85 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMax, genType, "max", genType, genType); |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 86 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMax, genIType, "max", genIType, genIType); |
| 87 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMax, genIType, "max", genIType, int1); |
| 88 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMax, genUType, "max", genUType, genUType); |
| 89 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMax, genUType, "max", genUType, uint1); |
Nicolas Capens | 33cda11 | 2015-02-24 17:35:47 -0500 | [diff] [blame] | 90 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpClamp, genType, "clamp", genType, float1, float1); |
| 91 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpClamp, genType, "clamp", genType, genType, genType); |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 92 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpClamp, genIType, "clamp", genIType, int1, int1); |
| 93 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpClamp, genIType, "clamp", genIType, genIType, genIType); |
| 94 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpClamp, genUType, "clamp", genUType, uint1, uint1); |
| 95 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpClamp, genUType, "clamp", genUType, genUType, genUType); |
Nicolas Capens | 33cda11 | 2015-02-24 17:35:47 -0500 | [diff] [blame] | 96 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMix, genType, "mix", genType, genType, float1); |
| 97 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMix, genType, "mix", genType, genType, genType); |
| 98 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpStep, genType, "step", genType, genType); |
| 99 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpStep, genType, "step", float1, genType); |
| 100 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSmoothStep, genType, "smoothstep", genType, genType, genType); |
| 101 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpSmoothStep, genType, "smoothstep", float1, float1, genType); |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 102 | |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 103 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpIsNan, genBType, "isnan", genType); |
| 104 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpIsInf, genBType, "isinf", genType); |
| 105 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpFloatBitsToInt, genIType, "floatBitsToInt", genType); |
| 106 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpFloatBitsToUint, genUType, "floatBitsToUint", genType); |
| 107 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpIntBitsToFloat, genType, "intBitsToFloat", genIType); |
| 108 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpUintBitsToFloat, genType, "uintBitsToFloat", genUType);
|
| 109 |
|
| 110 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpPackSnorm2x16, uint1, "packSnorm2x16", float2); |
| 111 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpPackUnorm2x16, uint1, "packUnorm2x16", float2); |
| 112 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpPackHalf2x16, uint1, "packHalf2x16", float2); |
| 113 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpUnpackSnorm2x16, float2, "unpackSnorm2x16", uint1); |
| 114 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpUnpackUnorm2x16, float2, "unpackUnorm2x16", uint1); |
| 115 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpUnpackHalf2x16, float2, "unpackHalf2x16", uint1); |
| 116 | |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 117 | // |
| 118 | // Geometric Functions. |
| 119 | // |
Nicolas Capens | 33cda11 | 2015-02-24 17:35:47 -0500 | [diff] [blame] | 120 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLength, float1, "length", genType); |
| 121 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpDistance, float1, "distance", genType, genType); |
| 122 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpDot, float1, "dot", genType, genType); |
| 123 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpCross, float3, "cross", float3, float3); |
| 124 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpNormalize, genType, "normalize", genType); |
| 125 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpFaceForward, genType, "faceforward", genType, genType, genType); |
| 126 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpReflect, genType, "reflect", genType, genType); |
| 127 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpRefract, genType, "refract", genType, genType, float1); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 128 | |
Alexis Hetu | b14178b | 2015-04-13 13:23:20 -0400 | [diff] [blame] | 129 | TType *mat2 = new TType(EbtFloat, 2, 2); |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 130 | TType *mat2x3 = new TType(EbtFloat, 2, 3); |
| 131 | TType *mat2x4 = new TType(EbtFloat, 2, 4); |
| 132 | TType *mat3x2 = new TType(EbtFloat, 3, 2); |
Alexis Hetu | b14178b | 2015-04-13 13:23:20 -0400 | [diff] [blame] | 133 | TType *mat3 = new TType(EbtFloat, 3, 3); |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 134 | TType *mat3x4 = new TType(EbtFloat, 3, 4); |
| 135 | TType *mat4x2 = new TType(EbtFloat, 4, 2); |
| 136 | TType *mat4x3 = new TType(EbtFloat, 4, 3); |
Alexis Hetu | b14178b | 2015-04-13 13:23:20 -0400 | [diff] [blame] | 137 | TType *mat4 = new TType(EbtFloat, 4, 4); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 138 | |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 139 | // |
| 140 | // Matrix Functions. |
| 141 | // |
Nicolas Capens | 33cda11 | 2015-02-24 17:35:47 -0500 | [diff] [blame] | 142 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMul, mat2, "matrixCompMult", mat2, mat2); |
| 143 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMul, mat3, "matrixCompMult", mat3, mat3); |
| 144 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpMul, mat4, "matrixCompMult", mat4, mat4); |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 145 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat2x3, "matrixCompMult", mat2x3, mat2x3); |
| 146 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat3x2, "matrixCompMult", mat3x2, mat3x2); |
| 147 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat2x4, "matrixCompMult", mat2x4, mat2x4); |
| 148 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat4x2, "matrixCompMult", mat4x2, mat4x2); |
| 149 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat3x4, "matrixCompMult", mat3x4, mat3x4); |
| 150 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpMul, mat4x3, "matrixCompMult", mat4x3, mat4x3);
|
| 151 |
|
| 152 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat2, "outerProduct", float2, float2); |
| 153 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat3, "outerProduct", float3, float3); |
| 154 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat4, "outerProduct", float4, float4); |
| 155 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat2x3, "outerProduct", float3, float2); |
| 156 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat3x2, "outerProduct", float2, float3); |
| 157 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat2x4, "outerProduct", float4, float2); |
| 158 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat4x2, "outerProduct", float2, float4); |
| 159 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat3x4, "outerProduct", float4, float3); |
| 160 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpOuterProduct, mat4x3, "outerProduct", float3, float4);
|
| 161 |
|
| 162 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat2, "transpose", mat2); |
| 163 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat3, "transpose", mat3); |
| 164 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat4, "transpose", mat4); |
| 165 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat2x3, "transpose", mat3x2); |
| 166 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat3x2, "transpose", mat2x3); |
| 167 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat2x4, "transpose", mat4x2); |
| 168 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat4x2, "transpose", mat2x4); |
| 169 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat3x4, "transpose", mat4x3); |
| 170 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpTranspose, mat4x3, "transpose", mat3x4);
|
| 171 |
|
| 172 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDeterminant, float1, "determinant", mat2); |
| 173 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDeterminant, float1, "determinant", mat3); |
| 174 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDeterminant, float1, "determinant", mat4);
|
| 175 |
|
| 176 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpInverse, mat2, "inverse", mat2); |
| 177 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpInverse, mat3, "inverse", mat3); |
| 178 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpInverse, mat4, "inverse", mat4);
|
| 179 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 180 | |
Nicolas Capens | 70da3d4 | 2015-02-18 16:58:10 -0500 | [diff] [blame] | 181 | TType *bool1 = new TType(EbtBool); |
Nicolas Capens | 8fa9d23 | 2015-02-19 15:53:16 -0500 | [diff] [blame] | 182 | TType *vec = new TType(EbtVec); |
| 183 | TType *ivec = new TType(EbtIVec); |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 184 | TType *uvec = new TType(EbtUVec);
|
Nicolas Capens | 8fa9d23 | 2015-02-19 15:53:16 -0500 | [diff] [blame] | 185 | TType *bvec = new TType(EbtBVec); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 186 | |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 187 | // |
| 188 | // Vector relational functions. |
| 189 | // |
Nicolas Capens | 33cda11 | 2015-02-24 17:35:47 -0500 | [diff] [blame] | 190 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThan, bvec, "lessThan", vec, vec); |
| 191 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThan, bvec, "lessThan", ivec, ivec); |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 192 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpLessThan, bvec, "lessThan", uvec, uvec); |
Nicolas Capens | 33cda11 | 2015-02-24 17:35:47 -0500 | [diff] [blame] | 193 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThanEqual, bvec, "lessThanEqual", vec, vec); |
| 194 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpLessThanEqual, bvec, "lessThanEqual", ivec, ivec); |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 195 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpLessThanEqual, bvec, "lessThanEqual", uvec, uvec); |
Nicolas Capens | 33cda11 | 2015-02-24 17:35:47 -0500 | [diff] [blame] | 196 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThan, bvec, "greaterThan", vec, vec); |
| 197 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThan, bvec, "greaterThan", ivec, ivec); |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 198 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpGreaterThan, bvec, "greaterThan", uvec, uvec); |
Nicolas Capens | 33cda11 | 2015-02-24 17:35:47 -0500 | [diff] [blame] | 199 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThanEqual, bvec, "greaterThanEqual", vec, vec); |
| 200 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpGreaterThanEqual, bvec, "greaterThanEqual", ivec, ivec); |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 201 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpGreaterThanEqual, bvec, "greaterThanEqual", uvec, uvec); |
Nicolas Capens | 33cda11 | 2015-02-24 17:35:47 -0500 | [diff] [blame] | 202 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorEqual, bvec, "equal", vec, vec); |
| 203 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorEqual, bvec, "equal", ivec, ivec); |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 204 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpVectorEqual, bvec, "equal", uvec, uvec); |
Nicolas Capens | 33cda11 | 2015-02-24 17:35:47 -0500 | [diff] [blame] | 205 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorEqual, bvec, "equal", bvec, bvec); |
| 206 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", vec, vec); |
| 207 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", ivec, ivec); |
Alexis Hetu | 2205c20 | 2015-04-16 10:38:41 -0400 | [diff] [blame] | 208 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", uvec, uvec); |
Nicolas Capens | 33cda11 | 2015-02-24 17:35:47 -0500 | [diff] [blame] | 209 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorNotEqual, bvec, "notEqual", bvec, bvec); |
| 210 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAny, bool1, "any", bvec); |
| 211 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpAll, bool1, "all", bvec); |
| 212 | symbolTable.insertBuiltIn(COMMON_BUILTINS, EOpVectorLogicalNot, bvec, "not", bvec); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 213 | |
Nicolas Capens | 70da3d4 | 2015-02-18 16:58:10 -0500 | [diff] [blame] | 214 | TType *sampler2D = new TType(EbtSampler2D); |
| 215 | TType *samplerCube = new TType(EbtSamplerCube); |
| 216 | TType *sampler3D = new TType(EbtSampler3D); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 217 | |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 218 | // |
| 219 | // Texture Functions for GLSL ES 1.0 |
| 220 | // |
| 221 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, float2); |
| 222 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float3); |
| 223 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float4); |
| 224 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, float3); |
| 225 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture3D", sampler3D, float3); |
| 226 | |
| 227 | if(resources.OES_EGL_image_external) |
| 228 | { |
Nicolas Capens | 70da3d4 | 2015-02-18 16:58:10 -0500 | [diff] [blame] | 229 | TType *samplerExternalOES = new TType(EbtSamplerExternalOES); |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 230 | |
| 231 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", samplerExternalOES, float2); |
| 232 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, float3); |
| 233 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, float4); |
| 234 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture3D", samplerExternalOES, float3); |
| 235 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 236 | |
Nicolas Capens | 08ca3c6 | 2015-02-13 16:06:45 -0500 | [diff] [blame] | 237 | if(type == GL_FRAGMENT_SHADER) |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 238 | { |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 239 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, float2, float1); |
| 240 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float3, float1); |
| 241 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float4, float1); |
| 242 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, float3, float1); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 243 | |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 244 | if(resources.OES_standard_derivatives) |
John Bauman | d4ae863 | 2014-05-06 16:18:33 -0400 | [diff] [blame] | 245 | { |
Nicolas Capens | 18d5ef9 | 2015-02-24 17:38:08 -0500 | [diff] [blame] | 246 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpDFdx, "GL_OES_standard_derivatives", genType, "dFdx", genType); |
| 247 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpDFdy, "GL_OES_standard_derivatives", genType, "dFdy", genType); |
| 248 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, EOpFwidth,"GL_OES_standard_derivatives", genType, "fwidth", genType); |
John Bauman | d4ae863 | 2014-05-06 16:18:33 -0400 | [diff] [blame] | 249 | } |
| 250 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 251 | |
Nicolas Capens | 08ca3c6 | 2015-02-13 16:06:45 -0500 | [diff] [blame] | 252 | if(type == GL_VERTEX_SHADER) |
John Bauman | d4ae863 | 2014-05-06 16:18:33 -0400 | [diff] [blame] | 253 | { |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 254 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DLod", sampler2D, float2, float1); |
| 255 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, float3, float1); |
| 256 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, float4, float1); |
| 257 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeLod", samplerCube, float3, float1); |
| 258 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture3DLod", sampler3D, float3, float1); |
John Bauman | d4ae863 | 2014-05-06 16:18:33 -0400 | [diff] [blame] | 259 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 260 | |
Nicolas Capens | 82cd6d8 | 2015-02-18 17:53:39 -0500 | [diff] [blame] | 261 | TType *gvec4 = new TType(EbtGVec4); |
| 262 | |
| 263 | TType *gsampler2D = new TType(EbtGSampler2D); |
| 264 | TType *gsamplerCube = new TType(EbtGSamplerCube); |
| 265 | TType *gsampler3D = new TType(EbtGSampler3D); |
| 266 | TType *gsampler2DArray = new TType(EbtGSampler2DArray); |
| 267 | |
| 268 | // |
| 269 | // Texture Functions for GLSL ES 3.0 |
| 270 | // |
| 271 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2D, float2); |
| 272 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler3D, float3); |
| 273 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsamplerCube, float3); |
| 274 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2DArray, float3); |
| 275 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float3); |
| 276 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float4); |
| 277 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler3D, float4); |
| 278 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler2D, float2, float1); |
| 279 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler3D, float3, float1); |
| 280 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsamplerCube, float3, float1); |
| 281 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler2DArray, float3, float1); |
| 282 | |
| 283 | if(type == GL_FRAGMENT_SHADER) |
| 284 | { |
| 285 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2D, float2, float1); |
| 286 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler3D, float3, float1); |
| 287 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsamplerCube, float3, float1); |
| 288 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2DArray, float3, float1); |
| 289 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float3, float1); |
| 290 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float4, float1); |
| 291 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler3D, float4, float1); |
| 292 | } |
| 293 | |
Alexis Hetu | b5332c5 | 2015-06-04 13:04:17 -0400 | [diff] [blame] | 294 | TType *sampler2DShadow = new TType(EbtSampler2DShadow); |
| 295 | TType *samplerCubeShadow = new TType(EbtSamplerCubeShadow); |
| 296 | TType *sampler2DArrayShadow = new TType(EbtSampler2DArrayShadow); |
| 297 | |
| 298 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DShadow, float3); |
| 299 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", samplerCubeShadow, float4); |
| 300 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DArrayShadow, float4); |
| 301 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProj", sampler2DShadow, float4); |
| 302 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureLod", sampler2DShadow, float3, float1); |
| 303 | |
| 304 | if(type == GL_FRAGMENT_SHADER) |
| 305 | { |
| 306 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DShadow, float3, float1); |
| 307 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", samplerCubeShadow, float4, float1); |
| 308 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProj", sampler2DShadow, float4, float1); |
| 309 | } |
| 310 | |
| 311 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", gsampler2D, int1); |
| 312 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", gsampler3D, int1); |
| 313 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", gsamplerCube, int1); |
| 314 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", gsampler2DArray, int1); |
| 315 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", sampler2DShadow, int1); |
| 316 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", samplerCubeShadow, int1); |
| 317 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", sampler2DArrayShadow, int1); |
| 318 | |
| 319 | if(type == GL_FRAGMENT_SHADER) |
| 320 | { |
| 321 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDFdx, genType, "dFdx", genType); |
| 322 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpDFdy, genType, "dFdy", genType); |
| 323 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, EOpFwidth, genType, "fwidth", genType); |
| 324 | } |
| 325 | |
| 326 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2); |
| 327 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler3D, float3, int3); |
| 328 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureOffset", sampler2DShadow, float3, int2); |
| 329 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2DArray, float3, int2); |
| 330 | |
| 331 | if(type == GL_FRAGMENT_SHADER) |
| 332 | { |
| 333 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2, float1); |
| 334 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler3D, float3, int3, float1); |
| 335 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureOffset", sampler2DShadow, float3, int2, float1); |
| 336 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2DArray, float3, int2, float1); |
| 337 | } |
| 338 | |
| 339 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float3, int2); |
| 340 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float4, int2); |
| 341 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler3D, float4, int3); |
| 342 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjOffset", sampler2DShadow, float4, int2); |
| 343 | |
| 344 | if(type == GL_FRAGMENT_SHADER) |
| 345 | { |
| 346 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float3, int2, float1); |
| 347 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float4, int2, float1); |
| 348 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler3D, float4, int3, float1); |
| 349 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjOffset", sampler2DShadow, float4, int2, float1); |
| 350 | } |
| 351 | |
| 352 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler2D, float2, float1, int2); |
| 353 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler3D, float3, float1, int3); |
| 354 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureLodOffset", sampler2DShadow, float3, float1, int2); |
| 355 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler2DArray, float3, float1, int2); |
| 356 | |
| 357 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler2D, float3, float1); |
| 358 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler2D, float4, float1); |
| 359 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler3D, float4, float1); |
| 360 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjLod", sampler2DShadow, float4, float1); |
| 361 | |
| 362 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler2D, float3, float1, int2); |
| 363 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler2D, float4, float1, int2); |
| 364 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler3D, float4, float1, int3); |
| 365 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjLodOffset", sampler2DShadow, float4, float1, int2); |
| 366 | |
| 367 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler2D, int2, int1); |
| 368 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler3D, int3, int1); |
| 369 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler2DArray, int3, int1); |
| 370 | |
| 371 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler2D, int2, int1, int2); |
| 372 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler3D, int3, int1, int3); |
| 373 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler2DArray, int3, int1, int2); |
| 374 | |
| 375 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler2D, float2, float2, float2); |
| 376 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler3D, float3, float3, float3); |
| 377 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsamplerCube, float3, float3, float3); |
| 378 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", sampler2DShadow, float3, float2, float2); |
| 379 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", samplerCubeShadow, float4, float3, float3); |
| 380 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler2DArray, float3, float2, float2); |
| 381 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", sampler2DArrayShadow, float4, float2, float2); |
| 382 | |
| 383 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler2D, float2, float2, float2, int2); |
| 384 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler3D, float3, float3, float3, int3); |
| 385 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGradOffset", sampler2DShadow, float3, float2, float2, int2); |
| 386 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler2DArray, float3, float2, float2, int2); |
| 387 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGradOffset", sampler2DArrayShadow, float4, float2, float2, int2); |
| 388 | |
| 389 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler2D, float3, float2, float2); |
| 390 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler2D, float4, float2, float2); |
| 391 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler3D, float4, float3, float3); |
| 392 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjGrad", sampler2DShadow, float4, float2, float2); |
| 393 | |
| 394 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler2D, float3, float2, float2, int2); |
| 395 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler2D, float4, float2, float2, int2); |
| 396 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler3D, float4, float3, float3, int3); |
| 397 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjGradOffset", sampler2DShadow, float4, float2, float2, int2); |
| 398 | |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 399 | // |
| 400 | // Depth range in window coordinates |
| 401 | // |
Alexis Hetu | a8b364b | 2015-06-10 11:48:40 -0400 | [diff] [blame] | 402 | TFieldList *fields = NewPoolTFieldList(); |
Alexis Hetu | 253fdd1 | 2015-07-07 15:12:46 -0400 | [diff] [blame] | 403 | TSourceLoc zeroSourceLoc = { 0, 0, 0, 0 }; |
| 404 | TField *near = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("near"), zeroSourceLoc); |
| 405 | TField *far = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("far"), zeroSourceLoc); |
| 406 | TField *diff = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("diff"), zeroSourceLoc); |
Alexis Hetu | a8b364b | 2015-06-10 11:48:40 -0400 | [diff] [blame] | 407 | fields->push_back(near); |
| 408 | fields->push_back(far); |
| 409 | fields->push_back(diff); |
| 410 | TStructure *depthRangeStruct = new TStructure(NewPoolTString("gl_DepthRangeParameters"), fields); |
| 411 | TVariable *depthRangeParameters = new TVariable(&depthRangeStruct->name(), depthRangeStruct, true); |
Nicolas Capens | e285865 | 2015-02-18 15:30:51 -0500 | [diff] [blame] | 412 | symbolTable.insert(COMMON_BUILTINS, *depthRangeParameters); |
Alexis Hetu | a8b364b | 2015-06-10 11:48:40 -0400 | [diff] [blame] | 413 | TVariable *depthRange = new TVariable(NewPoolTString("gl_DepthRange"), TType(depthRangeStruct)); |
John Bauman | d4ae863 | 2014-05-06 16:18:33 -0400 | [diff] [blame] | 414 | depthRange->setQualifier(EvqUniform); |
Nicolas Capens | e285865 | 2015-02-18 15:30:51 -0500 | [diff] [blame] | 415 | symbolTable.insert(COMMON_BUILTINS, *depthRange); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 416 | |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 417 | // |
| 418 | // Implementation dependent built-in constants. |
| 419 | // |
| 420 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexAttribs", resources.MaxVertexAttribs); |
Nicolas Capens | e285865 | 2015-02-18 15:30:51 -0500 | [diff] [blame] | 421 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexUniformVectors", resources.MaxVertexUniformVectors); |
Nicolas Capens | e285865 | 2015-02-18 15:30:51 -0500 | [diff] [blame] | 422 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexTextureImageUnits", resources.MaxVertexTextureImageUnits); |
| 423 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxCombinedTextureImageUnits", resources.MaxCombinedTextureImageUnits); |
| 424 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxTextureImageUnits", resources.MaxTextureImageUnits); |
| 425 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxFragmentUniformVectors", resources.MaxFragmentUniformVectors); |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 426 | symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxVaryingVectors", resources.MaxVaryingVectors); |
| 427 | symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxDrawBuffers", resources.MaxDrawBuffers); |
Alexis Hetu | 6743bbf | 2015-04-21 17:06:14 -0400 | [diff] [blame] | 428 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxVertexOutputVectors", resources.MaxVertexOutputVectors); |
| 429 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxFragmentInputVectors", resources.MaxFragmentInputVectors); |
| 430 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MinProgramTexelOffset", resources.MinProgramTexelOffset); |
| 431 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxProgramTexelOffset", resources.MaxProgramTexelOffset); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 432 | } |
| 433 | |
Nicolas Capens | 08ca3c6 | 2015-02-13 16:06:45 -0500 | [diff] [blame] | 434 | void IdentifyBuiltIns(GLenum shaderType, |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 435 | const ShBuiltInResources &resources, |
John Bauman | d4ae863 | 2014-05-06 16:18:33 -0400 | [diff] [blame] | 436 | TSymbolTable &symbolTable) |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 437 | { |
| 438 | // |
| 439 | // First, insert some special built-in variables that are not in |
| 440 | // the built-in header files. |
| 441 | // |
Nicolas Capens | 08ca3c6 | 2015-02-13 16:06:45 -0500 | [diff] [blame] | 442 | switch(shaderType) |
| 443 | { |
| 444 | case GL_FRAGMENT_SHADER: |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 445 | symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_FragCoord"), TType(EbtFloat, EbpMedium, EvqFragCoord, 4))); |
| 446 | symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool, EbpUndefined, EvqFrontFacing, 1))); |
| 447 | symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_PointCoord"), TType(EbtFloat, EbpMedium, EvqPointCoord, 2))); |
| 448 | symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EbpMedium, EvqFragColor, 4))); |
| 449 | symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqFragData, 4))); |
Alexis Hetu | fe30f67 | 2015-09-21 08:03:54 -0400 | [diff] [blame] | 450 | symbolTable.insert(ESSL3_BUILTINS, *new TVariable(NewPoolTString("gl_FragDepth"), TType(EbtFloat, EbpHigh, EvqFragDepth, 1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 451 | break; |
Nicolas Capens | 08ca3c6 | 2015-02-13 16:06:45 -0500 | [diff] [blame] | 452 | case GL_VERTEX_SHADER: |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 453 | symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EbpHigh, EvqPosition, 4))); |
| 454 | symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EbpMedium, EvqPointSize, 1))); |
Alexis Hetu | 6743bbf | 2015-04-21 17:06:14 -0400 | [diff] [blame] | 455 | symbolTable.insert(ESSL3_BUILTINS, *new TVariable(NewPoolTString("gl_InstanceID"), TType(EbtInt, EbpHigh, EvqInstanceID, 1))); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 456 | break; |
| 457 | default: assert(false && "Language not supported"); |
| 458 | } |
| 459 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 460 | // Finally add resource-specific variables. |
Nicolas Capens | 08ca3c6 | 2015-02-13 16:06:45 -0500 | [diff] [blame] | 461 | switch(shaderType) |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 462 | { |
Nicolas Capens | 08ca3c6 | 2015-02-13 16:06:45 -0500 | [diff] [blame] | 463 | case GL_FRAGMENT_SHADER: |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 464 | { |
| 465 | // Set up gl_FragData. The array size. |
Alexis Hetu | b14178b | 2015-04-13 13:23:20 -0400 | [diff] [blame] | 466 | TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 467 | fragData.setArraySize(resources.MaxDrawBuffers); |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 468 | symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragData"), fragData)); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 469 | } |
| 470 | break; |
| 471 | default: break; |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | void InitExtensionBehavior(const ShBuiltInResources& resources, |
| 476 | TExtensionBehavior& extBehavior) |
| 477 | { |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 478 | if(resources.OES_standard_derivatives) |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 479 | extBehavior["GL_OES_standard_derivatives"] = EBhUndefined; |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 480 | if(resources.OES_fragment_precision_high) |
John Bauman | d4ae863 | 2014-05-06 16:18:33 -0400 | [diff] [blame] | 481 | extBehavior["GL_FRAGMENT_PRECISION_HIGH"] = EBhUndefined; |
Nicolas Capens | 3d7f6ed | 2015-02-18 16:34:50 -0500 | [diff] [blame] | 482 | if(resources.OES_EGL_image_external) |
| 483 | extBehavior["GL_OES_EGL_image_external"] = EBhUndefined; |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 484 | } |