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" |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 14 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 15 | #include "compiler/translator/IntermNode.h" |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 16 | #include "angle_gl.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 17 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 18 | 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] | 19 | { |
Nicolas Capens | c950884 | 2014-02-14 17:48:50 -0500 | [diff] [blame] | 20 | TType *float1 = new TType(EbtFloat); |
| 21 | TType *float2 = new TType(EbtFloat, 2); |
| 22 | TType *float3 = new TType(EbtFloat, 3); |
| 23 | TType *float4 = new TType(EbtFloat, 4); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 24 | |
Nicolas Capens | c950884 | 2014-02-14 17:48:50 -0500 | [diff] [blame] | 25 | TType *int1 = new TType(EbtInt); |
| 26 | TType *int2 = new TType(EbtInt, 2); |
| 27 | TType *int3 = new TType(EbtInt, 3); |
| 28 | TType *int4 = new TType(EbtInt, 4); |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 29 | |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 30 | // |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 31 | // Angle and Trigonometric Functions. |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 32 | // |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 33 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "radians", float1); |
| 34 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "radians", float2); |
| 35 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "radians", float3); |
| 36 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "radians", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 37 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 38 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "degrees", float1); |
| 39 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "degrees", float2); |
| 40 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "degrees", float3); |
| 41 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "degrees", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 42 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 43 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sin", float1); |
| 44 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sin", float2); |
| 45 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sin", float3); |
| 46 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sin", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 47 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 48 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "cos", float1); |
| 49 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "cos", float2); |
| 50 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "cos", float3); |
| 51 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "cos", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 52 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 53 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "tan", float1); |
| 54 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "tan", float2); |
| 55 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "tan", float3); |
| 56 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "tan", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 57 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 58 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "asin", float1); |
| 59 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "asin", float2); |
| 60 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "asin", float3); |
| 61 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "asin", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 62 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 63 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "acos", float1); |
| 64 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "acos", float2); |
| 65 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "acos", float3); |
| 66 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "acos", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 67 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 68 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "atan", float1, float1); |
| 69 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "atan", float2, float2); |
| 70 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "atan", float3, float3); |
| 71 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "atan", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 72 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 73 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "atan", float1); |
| 74 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "atan", float2); |
| 75 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "atan", float3); |
| 76 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "atan", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 77 | |
Olli Etuaho | 5c9cd3d | 2014-12-18 13:04:25 +0200 | [diff] [blame] | 78 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "sinh", float1); |
| 79 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "sinh", float2); |
| 80 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "sinh", float3); |
| 81 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "sinh", float4); |
| 82 | |
| 83 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "cosh", float1); |
| 84 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "cosh", float2); |
| 85 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "cosh", float3); |
| 86 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "cosh", float4); |
| 87 | |
| 88 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "tanh", float1); |
| 89 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "tanh", float2); |
| 90 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "tanh", float3); |
| 91 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "tanh", float4); |
| 92 | |
| 93 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "asinh", float1); |
| 94 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "asinh", float2); |
| 95 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "asinh", float3); |
| 96 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "asinh", float4); |
| 97 | |
| 98 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "acosh", float1); |
| 99 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "acosh", float2); |
| 100 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "acosh", float3); |
| 101 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "acosh", float4); |
| 102 | |
| 103 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "atanh", float1); |
| 104 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "atanh", float2); |
| 105 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "atanh", float3); |
| 106 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "atanh", float4); |
| 107 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 108 | // |
| 109 | // Exponential Functions. |
| 110 | // |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 111 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "pow", float1, float1); |
| 112 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "pow", float2, float2); |
| 113 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "pow", float3, float3); |
| 114 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "pow", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 115 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 116 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "exp", float1); |
| 117 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "exp", float2); |
| 118 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "exp", float3); |
| 119 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "exp", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 120 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 121 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "log", float1); |
| 122 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "log", float2); |
| 123 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "log", float3); |
| 124 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "log", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 125 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 126 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "exp2", float1); |
| 127 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "exp2", float2); |
| 128 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "exp2", float3); |
| 129 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "exp2", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 130 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 131 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "log2", float1); |
| 132 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "log2", float2); |
| 133 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "log2", float3); |
| 134 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "log2", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 135 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 136 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sqrt", float1); |
| 137 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sqrt", float2); |
| 138 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sqrt", float3); |
| 139 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sqrt", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 140 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 141 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "inversesqrt", float1); |
| 142 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "inversesqrt", float2); |
| 143 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "inversesqrt", float3); |
| 144 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "inversesqrt", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 145 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 146 | // |
| 147 | // Common Functions. |
| 148 | // |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 149 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "abs", float1); |
| 150 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "abs", float2); |
| 151 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "abs", float3); |
| 152 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "abs", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 153 | |
Arun Patole | 3e142e4 | 2015-02-19 09:40:39 +0530 | [diff] [blame] | 154 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "abs", int1); |
| 155 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "abs", int2); |
| 156 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "abs", int3); |
| 157 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "abs", int4); |
| 158 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 159 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sign", float1); |
| 160 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sign", float2); |
| 161 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sign", float3); |
| 162 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sign", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 163 | |
Arun Patole | 3e142e4 | 2015-02-19 09:40:39 +0530 | [diff] [blame] | 164 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "sign", int1); |
| 165 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "sign", int2); |
| 166 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "sign", int3); |
| 167 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "sign", int4); |
| 168 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 169 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "floor", float1); |
| 170 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "floor", float2); |
| 171 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "floor", float3); |
| 172 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "floor", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 173 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 174 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "ceil", float1); |
| 175 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "ceil", float2); |
| 176 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "ceil", float3); |
| 177 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "ceil", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 178 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 179 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "fract", float1); |
| 180 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "fract", float2); |
| 181 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "fract", float3); |
| 182 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "fract", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 183 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 184 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "mod", float1, float1); |
| 185 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mod", float2, float1); |
| 186 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mod", float3, float1); |
| 187 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mod", float4, float1); |
| 188 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mod", float2, float2); |
| 189 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mod", float3, float3); |
| 190 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mod", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 191 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 192 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "min", float1, float1); |
| 193 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "min", float2, float1); |
| 194 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "min", float3, float1); |
| 195 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "min", float4, float1); |
| 196 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "min", float2, float2); |
| 197 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "min", float3, float3); |
| 198 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "min", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 199 | |
Arun Patole | 42077bb | 2015-02-16 15:32:37 +0530 | [diff] [blame] | 200 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "min", int1, int1); |
| 201 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "min", int2, int2); |
| 202 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "min", int3, int3); |
| 203 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "min", int4, int4); |
| 204 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "min", int2, int1); |
| 205 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "min", int3, int1); |
| 206 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "min", int4, int1); |
| 207 | |
| 208 | TType *uint1 = new TType(EbtUInt); |
| 209 | TType *uint2 = new TType(EbtUInt, 2); |
| 210 | TType *uint3 = new TType(EbtUInt, 3); |
| 211 | TType *uint4 = new TType(EbtUInt, 4); |
| 212 | |
| 213 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "min", uint1, uint1); |
| 214 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "min", uint2, uint2); |
| 215 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "min", uint3, uint3); |
| 216 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "min", uint4, uint4); |
| 217 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "min", uint2, uint1); |
| 218 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "min", uint3, uint1); |
| 219 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "min", uint4, uint1); |
| 220 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 221 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "max", float1, float1); |
| 222 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "max", float2, float1); |
| 223 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "max", float3, float1); |
| 224 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "max", float4, float1); |
| 225 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "max", float2, float2); |
| 226 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "max", float3, float3); |
| 227 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "max", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 228 | |
Arun Patole | 42077bb | 2015-02-16 15:32:37 +0530 | [diff] [blame] | 229 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "max", int1, int1); |
| 230 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "max", int2, int2); |
| 231 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "max", int3, int3); |
| 232 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "max", int4, int4); |
| 233 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "max", int2, int1); |
| 234 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "max", int3, int1); |
| 235 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "max", int4, int1); |
| 236 | |
| 237 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "max", uint1, uint1); |
| 238 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "max", uint2, uint2); |
| 239 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "max", uint3, uint3); |
| 240 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "max", uint4, uint4); |
| 241 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "max", uint2, uint1); |
| 242 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "max", uint3, uint1); |
| 243 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "max", uint4, uint1); |
| 244 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 245 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "clamp", float1, float1, float1); |
| 246 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "clamp", float2, float1, float1); |
| 247 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "clamp", float3, float1, float1); |
| 248 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "clamp", float4, float1, float1); |
| 249 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "clamp", float2, float2, float2); |
| 250 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "clamp", float3, float3, float3); |
| 251 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "clamp", float4, float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 252 | |
Arun Patole | 42077bb | 2015-02-16 15:32:37 +0530 | [diff] [blame] | 253 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "clamp", int1, int1, int1); |
| 254 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "clamp", int2, int1, int1); |
| 255 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "clamp", int3, int1, int1); |
| 256 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "clamp", int4, int1, int1); |
| 257 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "clamp", int2, int2, int2); |
| 258 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "clamp", int3, int3, int3); |
| 259 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "clamp", int4, int4, int4); |
| 260 | |
| 261 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "clamp", uint1, uint1, uint1); |
| 262 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "clamp", uint2, uint1, uint1); |
| 263 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "clamp", uint3, uint1, uint1); |
| 264 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "clamp", uint4, uint1, uint1); |
| 265 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "clamp", uint2, uint2, uint2); |
| 266 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "clamp", uint3, uint3, uint3); |
| 267 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "clamp", uint4, uint4, uint4); |
| 268 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 269 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "mix", float1, float1, float1); |
| 270 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mix", float2, float2, float1); |
| 271 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mix", float3, float3, float1); |
| 272 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mix", float4, float4, float1); |
| 273 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mix", float2, float2, float2); |
| 274 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mix", float3, float3, float3); |
| 275 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mix", float4, float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 276 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 277 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "step", float1, float1); |
| 278 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "step", float2, float2); |
| 279 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "step", float3, float3); |
| 280 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "step", float4, float4); |
| 281 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "step", float1, float2); |
| 282 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "step", float1, float3); |
| 283 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "step", float1, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 284 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 285 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "smoothstep", float1, float1, float1); |
| 286 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "smoothstep", float2, float2, float2); |
| 287 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "smoothstep", float3, float3, float3); |
| 288 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "smoothstep", float4, float4, float4); |
| 289 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "smoothstep", float1, float1, float2); |
| 290 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "smoothstep", float1, float1, float3); |
| 291 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "smoothstep", float1, float1, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 292 | |
Olli Etuaho | b6e07a6 | 2015-02-16 12:22:10 +0200 | [diff] [blame^] | 293 | TType *outFloat1 = new TType(EbtFloat); |
| 294 | TType *outFloat2 = new TType(EbtFloat, 2); |
| 295 | TType *outFloat3 = new TType(EbtFloat, 3); |
| 296 | TType *outFloat4 = new TType(EbtFloat, 4); |
| 297 | outFloat1->setQualifier(EvqOut); |
| 298 | outFloat2->setQualifier(EvqOut); |
| 299 | outFloat3->setQualifier(EvqOut); |
| 300 | outFloat4->setQualifier(EvqOut); |
| 301 | |
| 302 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "modf", float1, outFloat1); |
| 303 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "modf", float2, outFloat2); |
| 304 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "modf", float3, outFloat3); |
| 305 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "modf", float4, outFloat4); |
| 306 | |
Arun Patole | 0c1726e | 2015-02-18 14:35:02 +0530 | [diff] [blame] | 307 | TType *bool1 = new TType(EbtBool); |
| 308 | TType *bool2 = new TType(EbtBool, 2); |
| 309 | TType *bool3 = new TType(EbtBool, 3); |
| 310 | TType *bool4 = new TType(EbtBool, 4); |
| 311 | |
| 312 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool1, "isnan", float1); |
| 313 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "isnan", float2); |
| 314 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "isnan", float3); |
| 315 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "isnan", float4); |
| 316 | |
| 317 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool1, "isinf", float1); |
| 318 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "isinf", float2); |
| 319 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "isinf", float3); |
| 320 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "isinf", float4); |
| 321 | |
Olli Etuaho | e8d2c07 | 2015-01-08 16:33:54 +0200 | [diff] [blame] | 322 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "floatBitsToInt", float1); |
| 323 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "floatBitsToInt", float2); |
| 324 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "floatBitsToInt", float3); |
| 325 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "floatBitsToInt", float4); |
| 326 | |
| 327 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "floatBitsToUint", float1); |
| 328 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "floatBitsToUint", float2); |
| 329 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "floatBitsToUint", float3); |
| 330 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "floatBitsToUint", float4); |
| 331 | |
| 332 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "intBitsToFloat", int1); |
| 333 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "intBitsToFloat", int2); |
| 334 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "intBitsToFloat", int3); |
| 335 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "intBitsToFloat", int4); |
| 336 | |
| 337 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "uintBitsToFloat", uint1); |
| 338 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "uintBitsToFloat", uint2); |
| 339 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "uintBitsToFloat", uint3); |
| 340 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "uintBitsToFloat", uint4); |
| 341 | |
Olli Etuaho | 7700ff6 | 2015-01-15 12:16:29 +0200 | [diff] [blame] | 342 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "packSnorm2x16", float2); |
| 343 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "packUnorm2x16", float2); |
| 344 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "packHalf2x16", float2); |
| 345 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "unpackSnorm2x16", uint1); |
| 346 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "unpackUnorm2x16", uint1); |
| 347 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "unpackHalf2x16", uint1); |
| 348 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 349 | // |
| 350 | // Geometric Functions. |
| 351 | // |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 352 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float1); |
| 353 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float2); |
| 354 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float3); |
| 355 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 356 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 357 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float1, float1); |
| 358 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float2, float2); |
| 359 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float3, float3); |
| 360 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 361 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 362 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float1, float1); |
| 363 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float2, float2); |
| 364 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float3, float3); |
| 365 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 366 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 367 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "cross", float3, float3); |
| 368 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "normalize", float1); |
| 369 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "normalize", float2); |
| 370 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "normalize", float3); |
| 371 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "normalize", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 372 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 373 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "faceforward", float1, float1, float1); |
| 374 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "faceforward", float2, float2, float2); |
| 375 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "faceforward", float3, float3, float3); |
| 376 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "faceforward", float4, float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 377 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 378 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "reflect", float1, float1); |
| 379 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "reflect", float2, float2); |
| 380 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "reflect", float3, float3); |
| 381 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "reflect", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 382 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 383 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "refract", float1, float1, float1); |
| 384 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "refract", float2, float2, float1); |
| 385 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "refract", float3, float3, float1); |
| 386 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "refract", float4, float4, float1); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 387 | |
Nicolas Capens | c950884 | 2014-02-14 17:48:50 -0500 | [diff] [blame] | 388 | TType *mat2 = new TType(EbtFloat, 2, 2); |
| 389 | TType *mat3 = new TType(EbtFloat, 3, 3); |
| 390 | TType *mat4 = new TType(EbtFloat, 4, 4); |
Olli Etuaho | e39706d | 2014-12-30 16:40:36 +0200 | [diff] [blame] | 391 | TType *mat2x3 = new TType(EbtFloat, 2, 3); |
| 392 | TType *mat3x2 = new TType(EbtFloat, 3, 2); |
| 393 | TType *mat2x4 = new TType(EbtFloat, 2, 4); |
| 394 | TType *mat4x2 = new TType(EbtFloat, 4, 2); |
| 395 | TType *mat3x4 = new TType(EbtFloat, 3, 4); |
| 396 | TType *mat4x3 = new TType(EbtFloat, 4, 3); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 397 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 398 | // |
| 399 | // Matrix Functions. |
| 400 | // |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 401 | symbolTable.insertBuiltIn(COMMON_BUILTINS, mat2, "matrixCompMult", mat2, mat2); |
| 402 | symbolTable.insertBuiltIn(COMMON_BUILTINS, mat3, "matrixCompMult", mat3, mat3); |
| 403 | symbolTable.insertBuiltIn(COMMON_BUILTINS, mat4, "matrixCompMult", mat4, mat4); |
Olli Etuaho | e39706d | 2014-12-30 16:40:36 +0200 | [diff] [blame] | 404 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2x3, "matrixCompMult", mat2x3, mat2x3); |
| 405 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3x2, "matrixCompMult", mat3x2, mat3x2); |
| 406 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2x4, "matrixCompMult", mat2x4, mat2x4); |
| 407 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4x2, "matrixCompMult", mat4x2, mat4x2); |
| 408 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3x4, "matrixCompMult", mat3x4, mat3x4); |
| 409 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4x3, "matrixCompMult", mat4x3, mat4x3); |
| 410 | |
| 411 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2, "outerProduct", float2, float2); |
| 412 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3, "outerProduct", float3, float3); |
| 413 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4, "outerProduct", float4, float4); |
| 414 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2x3, "outerProduct", float3, float2); |
| 415 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3x2, "outerProduct", float2, float3); |
| 416 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2x4, "outerProduct", float4, float2); |
| 417 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4x2, "outerProduct", float2, float4); |
| 418 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3x4, "outerProduct", float4, float3); |
| 419 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4x3, "outerProduct", float3, float4); |
| 420 | |
| 421 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2, "transpose", mat2); |
| 422 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3, "transpose", mat3); |
| 423 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4, "transpose", mat4); |
| 424 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2x3, "transpose", mat3x2); |
| 425 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3x2, "transpose", mat2x3); |
| 426 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2x4, "transpose", mat4x2); |
| 427 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4x2, "transpose", mat2x4); |
| 428 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3x4, "transpose", mat4x3); |
| 429 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4x3, "transpose", mat3x4); |
| 430 | |
| 431 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "determinant", mat2); |
| 432 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "determinant", mat3); |
| 433 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "determinant", mat4); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 434 | |
Olli Etuaho | abf6dad | 2015-01-14 14:45:16 +0200 | [diff] [blame] | 435 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2, "inverse", mat2); |
| 436 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3, "inverse", mat3); |
| 437 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4, "inverse", mat4); |
| 438 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 439 | // |
| 440 | // Vector relational functions. |
| 441 | // |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 442 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThan", float2, float2); |
| 443 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThan", float3, float3); |
| 444 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThan", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 445 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 446 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThan", int2, int2); |
| 447 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThan", int3, int3); |
| 448 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThan", int4, int4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 449 | |
Arun Patole | 2b45573 | 2015-02-17 20:24:59 +0530 | [diff] [blame] | 450 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "lessThan", uint2, uint2); |
| 451 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "lessThan", uint3, uint3); |
| 452 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "lessThan", uint4, uint4); |
| 453 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 454 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThanEqual", float2, float2); |
| 455 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThanEqual", float3, float3); |
| 456 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThanEqual", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 457 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 458 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThanEqual", int2, int2); |
| 459 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThanEqual", int3, int3); |
| 460 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThanEqual", int4, int4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 461 | |
Arun Patole | 2b45573 | 2015-02-17 20:24:59 +0530 | [diff] [blame] | 462 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "lessThanEqual", uint2, uint2); |
| 463 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "lessThanEqual", uint3, uint3); |
| 464 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "lessThanEqual", uint4, uint4); |
| 465 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 466 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThan", float2, float2); |
| 467 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThan", float3, float3); |
| 468 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThan", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 469 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 470 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThan", int2, int2); |
| 471 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThan", int3, int3); |
| 472 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThan", int4, int4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 473 | |
Arun Patole | 2b45573 | 2015-02-17 20:24:59 +0530 | [diff] [blame] | 474 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "greaterThan", uint2, uint2); |
| 475 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "greaterThan", uint3, uint3); |
| 476 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "greaterThan", uint4, uint4); |
| 477 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 478 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThanEqual", float2, float2); |
| 479 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThanEqual", float3, float3); |
| 480 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThanEqual", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 481 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 482 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThanEqual", int2, int2); |
| 483 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThanEqual", int3, int3); |
| 484 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThanEqual", int4, int4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 485 | |
Arun Patole | 2b45573 | 2015-02-17 20:24:59 +0530 | [diff] [blame] | 486 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "greaterThanEqual", uint2, uint2); |
| 487 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "greaterThanEqual", uint3, uint3); |
| 488 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "greaterThanEqual", uint4, uint4); |
| 489 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 490 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", float2, float2); |
| 491 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", float3, float3); |
| 492 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 493 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 494 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", int2, int2); |
| 495 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", int3, int3); |
| 496 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", int4, int4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 497 | |
Arun Patole | 2b45573 | 2015-02-17 20:24:59 +0530 | [diff] [blame] | 498 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "equal", uint2, uint2); |
| 499 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "equal", uint3, uint3); |
| 500 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "equal", uint4, uint4); |
| 501 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 502 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", bool2, bool2); |
| 503 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", bool3, bool3); |
| 504 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", bool4, bool4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 505 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 506 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", float2, float2); |
| 507 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", float3, float3); |
| 508 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 509 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 510 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", int2, int2); |
| 511 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", int3, int3); |
| 512 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", int4, int4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 513 | |
Arun Patole | 2b45573 | 2015-02-17 20:24:59 +0530 | [diff] [blame] | 514 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "notEqual", uint2, uint2); |
| 515 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "notEqual", uint3, uint3); |
| 516 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "notEqual", uint4, uint4); |
| 517 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 518 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", bool2, bool2); |
| 519 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", bool3, bool3); |
| 520 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", bool4, bool4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 521 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 522 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool2); |
| 523 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool3); |
| 524 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 525 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 526 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool2); |
| 527 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool3); |
| 528 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 529 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 530 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "not", bool2); |
| 531 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "not", bool3); |
| 532 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "not", bool4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 533 | |
Nicolas Capens | c950884 | 2014-02-14 17:48:50 -0500 | [diff] [blame] | 534 | TType *sampler2D = new TType(EbtSampler2D); |
| 535 | TType *samplerCube = new TType(EbtSamplerCube); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 536 | |
| 537 | // |
| 538 | // Texture Functions for GLSL ES 1.0 |
| 539 | // |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 540 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, float2); |
| 541 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float3); |
| 542 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float4); |
| 543 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, float3); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 544 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 545 | if (resources.OES_EGL_image_external) |
| 546 | { |
Nicolas Capens | c950884 | 2014-02-14 17:48:50 -0500 | [diff] [blame] | 547 | TType *samplerExternalOES = new TType(EbtSamplerExternalOES); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 548 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 549 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", samplerExternalOES, float2); |
| 550 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, float3); |
| 551 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, float4); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 552 | } |
| 553 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 554 | if (resources.ARB_texture_rectangle) |
| 555 | { |
Nicolas Capens | c950884 | 2014-02-14 17:48:50 -0500 | [diff] [blame] | 556 | TType *sampler2DRect = new TType(EbtSampler2DRect); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 557 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 558 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRect", sampler2DRect, float2); |
| 559 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect, float3); |
| 560 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect, float4); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 561 | } |
| 562 | |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 563 | if (resources.EXT_shader_texture_lod) |
| 564 | { |
| 565 | /* The *Grad* variants are new to both vertex and fragment shaders; the fragment |
| 566 | * shader specific pieces are added separately below. |
| 567 | */ |
| 568 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DGradEXT", sampler2D, float2, float2, float2); |
| 569 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjGradEXT", sampler2D, float3, float2, float2); |
| 570 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjGradEXT", sampler2D, float4, float2, float2); |
| 571 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeGradEXT", samplerCube, float3, float3, float3); |
| 572 | } |
| 573 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 574 | if (type == GL_FRAGMENT_SHADER) |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 575 | { |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 576 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, float2, float1); |
| 577 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float3, float1); |
| 578 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float4, float1); |
| 579 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, float3, float1); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 580 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 581 | if (resources.OES_standard_derivatives) |
| 582 | { |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 583 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "dFdx", float1); |
| 584 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "dFdx", float2); |
| 585 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "dFdx", float3); |
| 586 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "dFdx", float4); |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 587 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 588 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "dFdy", float1); |
| 589 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "dFdy", float2); |
| 590 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "dFdy", float3); |
| 591 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "dFdy", float4); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 592 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 593 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "fwidth", float1); |
| 594 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "fwidth", float2); |
| 595 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "fwidth", float3); |
| 596 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "fwidth", float4); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 597 | } |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 598 | |
| 599 | if (resources.EXT_shader_texture_lod) |
| 600 | { |
| 601 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DLodEXT", sampler2D, float2, float1); |
| 602 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLodEXT", sampler2D, float3, float1); |
| 603 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLodEXT", sampler2D, float4, float1); |
| 604 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeLodEXT", samplerCube, float3, float1); |
| 605 | } |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 606 | } |
| 607 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 608 | if(type == GL_VERTEX_SHADER) |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 609 | { |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 610 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DLod", sampler2D, float2, float1); |
| 611 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, float3, float1); |
| 612 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, float4, float1); |
| 613 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeLod", samplerCube, float3, float1); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 614 | } |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 615 | |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 616 | TType *gvec4 = new TType(EbtGVec4); |
| 617 | |
| 618 | TType *gsampler2D = new TType(EbtGSampler2D); |
| 619 | TType *gsamplerCube = new TType(EbtGSamplerCube); |
| 620 | TType *gsampler3D = new TType(EbtGSampler3D); |
| 621 | TType *gsampler2DArray = new TType(EbtGSampler2DArray); |
Nicolas Capens | 73f5bf6 | 2013-06-17 16:13:33 -0400 | [diff] [blame] | 622 | |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 623 | // |
| 624 | // Texture Functions for GLSL ES 3.0 |
| 625 | // |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 626 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2D, float2); |
| 627 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler3D, float3); |
| 628 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsamplerCube, float3); |
| 629 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2DArray, float3); |
| 630 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float3); |
| 631 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float4); |
| 632 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler3D, float4); |
| 633 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler2D, float2, float1); |
| 634 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler3D, float3, float1); |
| 635 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsamplerCube, float3, float1); |
| 636 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler2DArray, float3, float1); |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 637 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 638 | if (type == GL_FRAGMENT_SHADER) |
Nicolas Capens | 67a819f | 2013-07-09 12:08:58 -0400 | [diff] [blame] | 639 | { |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 640 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2D, float2, float1); |
| 641 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler3D, float3, float1); |
| 642 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsamplerCube, float3, float1); |
| 643 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2DArray, float3, float1); |
| 644 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float3, float1); |
| 645 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float4, float1); |
| 646 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler3D, float4, float1); |
Nicolas Capens | 67a819f | 2013-07-09 12:08:58 -0400 | [diff] [blame] | 647 | } |
| 648 | |
Nicolas Capens | c950884 | 2014-02-14 17:48:50 -0500 | [diff] [blame] | 649 | TType *sampler2DShadow = new TType(EbtSampler2DShadow); |
| 650 | TType *samplerCubeShadow = new TType(EbtSamplerCubeShadow); |
| 651 | TType *sampler2DArrayShadow = new TType(EbtSampler2DArrayShadow); |
Nicolas Capens | 77c9d1a | 2013-07-11 11:10:34 -0400 | [diff] [blame] | 652 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 653 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DShadow, float3); |
| 654 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", samplerCubeShadow, float4); |
| 655 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DArrayShadow, float4); |
| 656 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProj", sampler2DShadow, float4); |
Jamie Madill | 16a1c07 | 2013-10-22 15:42:15 -0400 | [diff] [blame] | 657 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureLod", sampler2DShadow, float3, float1); |
Nicolas Capens | 77c9d1a | 2013-07-11 11:10:34 -0400 | [diff] [blame] | 658 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 659 | if (type == GL_FRAGMENT_SHADER) |
Nicolas Capens | 77c9d1a | 2013-07-11 11:10:34 -0400 | [diff] [blame] | 660 | { |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 661 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DShadow, float3, float1); |
| 662 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", samplerCubeShadow, float4, float1); |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 663 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProj", sampler2DShadow, float4, float1); |
Nicolas Capens | 77c9d1a | 2013-07-11 11:10:34 -0400 | [diff] [blame] | 664 | } |
| 665 | |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 666 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", gsampler2D, int1); |
| 667 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", gsampler3D, int1); |
| 668 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", gsamplerCube, int1); |
| 669 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", gsampler2DArray, int1); |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 670 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", sampler2DShadow, int1); |
| 671 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", samplerCubeShadow, int1); |
| 672 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", sampler2DArrayShadow, int1); |
Nicolas Capens | 75fb475 | 2013-07-10 15:14:47 -0400 | [diff] [blame] | 673 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 674 | if(type == GL_FRAGMENT_SHADER) |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 675 | { |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 676 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "dFdx", float1); |
| 677 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "dFdx", float2); |
| 678 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "dFdx", float3); |
| 679 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "dFdx", float4); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 680 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 681 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "dFdy", float1); |
| 682 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "dFdy", float2); |
| 683 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "dFdy", float3); |
| 684 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "dFdy", float4); |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 685 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 686 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "fwidth", float1); |
| 687 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "fwidth", float2); |
| 688 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "fwidth", float3); |
| 689 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "fwidth", float4); |
alokp@chromium.org | 0609889 | 2010-08-26 19:36:42 +0000 | [diff] [blame] | 690 | } |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 691 | |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 692 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2); |
| 693 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler3D, float3, int3); |
| 694 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureOffset", sampler2DShadow, float3, int2); |
| 695 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2DArray, float3, int2); |
| 696 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 697 | if(type == GL_FRAGMENT_SHADER) |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 698 | { |
| 699 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2, float1); |
| 700 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler3D, float3, int3, float1); |
| 701 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureOffset", sampler2DShadow, float3, int2, float1); |
| 702 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2DArray, float3, int2, float1); |
| 703 | } |
Nicolas Capens | 1fbc287 | 2014-01-03 14:12:09 -0500 | [diff] [blame] | 704 | |
Nicolas Capens | df86c6b | 2014-02-14 20:09:17 -0500 | [diff] [blame] | 705 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float3, int2); |
| 706 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float4, int2); |
| 707 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler3D, float4, int3); |
| 708 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjOffset", sampler2DShadow, float4, int2); |
| 709 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 710 | if(type == GL_FRAGMENT_SHADER) |
Nicolas Capens | df86c6b | 2014-02-14 20:09:17 -0500 | [diff] [blame] | 711 | { |
| 712 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float3, int2, float1); |
| 713 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float4, int2, float1); |
| 714 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler3D, float4, int3, float1); |
| 715 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjOffset", sampler2DShadow, float4, int2, float1); |
| 716 | } |
| 717 | |
| 718 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler2D, float2, float1, int2); |
| 719 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler3D, float3, float1, int3); |
| 720 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureLodOffset", sampler2DShadow, float3, float1, int2); |
| 721 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler2DArray, float3, float1, int2); |
| 722 | |
Nicolas Capens | 2adc256 | 2014-02-14 23:50:59 -0500 | [diff] [blame] | 723 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler2D, float3, float1); |
| 724 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler2D, float4, float1); |
| 725 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler3D, float4, float1); |
| 726 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjLod", sampler2DShadow, float4, float1); |
| 727 | |
| 728 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler2D, float3, float1, int2); |
| 729 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler2D, float4, float1, int2); |
| 730 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler3D, float4, float1, int3); |
| 731 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjLodOffset", sampler2DShadow, float4, float1, int2); |
| 732 | |
Nicolas Capens | fc01454 | 2014-02-18 14:47:13 -0500 | [diff] [blame] | 733 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler2D, int2, int1); |
| 734 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler3D, int3, int1); |
| 735 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler2DArray, int3, int1); |
| 736 | |
| 737 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler2D, int2, int1, int2); |
| 738 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler3D, int3, int1, int3); |
| 739 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler2DArray, int3, int1, int2); |
| 740 | |
Nicolas Capens | d11d549 | 2014-02-19 17:06:10 -0500 | [diff] [blame] | 741 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler2D, float2, float2, float2); |
| 742 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler3D, float3, float3, float3); |
| 743 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsamplerCube, float3, float3, float3); |
| 744 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", sampler2DShadow, float3, float2, float2); |
| 745 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", samplerCubeShadow, float4, float3, float3); |
| 746 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler2DArray, float3, float2, float2); |
| 747 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", sampler2DArrayShadow, float4, float2, float2); |
| 748 | |
Nicolas Capens | bf7db10 | 2014-02-19 17:20:28 -0500 | [diff] [blame] | 749 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler2D, float2, float2, float2, int2); |
| 750 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler3D, float3, float3, float3, int3); |
| 751 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGradOffset", sampler2DShadow, float3, float2, float2, int2); |
| 752 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler2DArray, float3, float2, float2, int2); |
| 753 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGradOffset", sampler2DArrayShadow, float4, float2, float2, int2); |
| 754 | |
Nicolas Capens | f7378e3 | 2014-02-19 17:29:32 -0500 | [diff] [blame] | 755 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler2D, float3, float2, float2); |
| 756 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler2D, float4, float2, float2); |
| 757 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler3D, float4, float3, float3); |
| 758 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjGrad", sampler2DShadow, float4, float2, float2); |
| 759 | |
| 760 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler2D, float3, float2, float2, int2); |
| 761 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler2D, float4, float2, float2, int2); |
| 762 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler3D, float4, float3, float3, int3); |
| 763 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjGradOffset", sampler2DShadow, float4, float2, float2, int2); |
| 764 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 765 | // |
| 766 | // Depth range in window coordinates |
| 767 | // |
Jamie Madill | 98493dd | 2013-07-08 14:39:03 -0400 | [diff] [blame] | 768 | TFieldList *fields = NewPoolTFieldList(); |
Jamie Madill | 37f77d2 | 2014-04-30 16:10:13 -0400 | [diff] [blame] | 769 | TSourceLoc zeroSourceLoc = {0, 0, 0, 0}; |
Jamie Madill | 98493dd | 2013-07-08 14:39:03 -0400 | [diff] [blame] | 770 | TField *near = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("near"), zeroSourceLoc); |
| 771 | TField *far = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("far"), zeroSourceLoc); |
| 772 | TField *diff = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("diff"), zeroSourceLoc); |
| 773 | fields->push_back(near); |
| 774 | fields->push_back(far); |
| 775 | fields->push_back(diff); |
| 776 | TStructure *depthRangeStruct = new TStructure(NewPoolTString("gl_DepthRangeParameters"), fields); |
| 777 | TVariable *depthRangeParameters = new TVariable(&depthRangeStruct->name(), depthRangeStruct, true); |
Nicolas Capens | adfffe4 | 2014-06-17 02:13:36 -0400 | [diff] [blame] | 778 | symbolTable.insert(COMMON_BUILTINS, depthRangeParameters); |
Jamie Madill | 98493dd | 2013-07-08 14:39:03 -0400 | [diff] [blame] | 779 | TVariable *depthRange = new TVariable(NewPoolTString("gl_DepthRange"), TType(depthRangeStruct)); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 780 | depthRange->setQualifier(EvqUniform); |
Nicolas Capens | adfffe4 | 2014-06-17 02:13:36 -0400 | [diff] [blame] | 781 | symbolTable.insert(COMMON_BUILTINS, depthRange); |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 782 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 783 | // |
| 784 | // Implementation dependent built-in constants. |
| 785 | // |
| 786 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexAttribs", resources.MaxVertexAttribs); |
| 787 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexUniformVectors", resources.MaxVertexUniformVectors); |
| 788 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexTextureImageUnits", resources.MaxVertexTextureImageUnits); |
| 789 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxCombinedTextureImageUnits", resources.MaxCombinedTextureImageUnits); |
| 790 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxTextureImageUnits", resources.MaxTextureImageUnits); |
| 791 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxFragmentUniformVectors", resources.MaxFragmentUniformVectors); |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 792 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 793 | symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxVaryingVectors", resources.MaxVaryingVectors); |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 794 | |
| 795 | if (spec != SH_CSS_SHADERS_SPEC) |
shannon.woods%transgaming.com@gtempaccount.com | 5209de8 | 2013-04-13 03:41:53 +0000 | [diff] [blame] | 796 | { |
Jamie Madill | 455a6f5 | 2013-10-17 10:45:46 -0400 | [diff] [blame] | 797 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxDrawBuffers", resources.MaxDrawBuffers); |
shannon.woods%transgaming.com@gtempaccount.com | 5209de8 | 2013-04-13 03:41:53 +0000 | [diff] [blame] | 798 | } |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 799 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 800 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxVertexOutputVectors", resources.MaxVertexOutputVectors); |
| 801 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxFragmentInputVectors", resources.MaxFragmentInputVectors); |
| 802 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MinProgramTexelOffset", resources.MinProgramTexelOffset); |
| 803 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxProgramTexelOffset", resources.MaxProgramTexelOffset); |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 804 | } |
| 805 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 806 | void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec, |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 807 | const ShBuiltInResources &resources, |
| 808 | TSymbolTable &symbolTable) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 809 | { |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 810 | // |
| 811 | // First, insert some special built-in variables that are not in |
| 812 | // the built-in header files. |
| 813 | // |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 814 | switch(type) { |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 815 | case GL_FRAGMENT_SHADER: |
Nicolas Capens | adfffe4 | 2014-06-17 02:13:36 -0400 | [diff] [blame] | 816 | symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FragCoord"), TType(EbtFloat, EbpMedium, EvqFragCoord, 4))); |
| 817 | symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool, EbpUndefined, EvqFrontFacing, 1))); |
| 818 | symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointCoord"), TType(EbtFloat, EbpMedium, EvqPointCoord, 2))); |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 819 | |
| 820 | // |
| 821 | // In CSS Shaders, gl_FragColor, gl_FragData, and gl_MaxDrawBuffers are not available. |
| 822 | // Instead, css_MixColor and css_ColorMatrix are available. |
| 823 | // |
| 824 | if (spec != SH_CSS_SHADERS_SPEC) { |
Nicolas Capens | adfffe4 | 2014-06-17 02:13:36 -0400 | [diff] [blame] | 825 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EbpMedium, EvqFragColor, 4))); |
| 826 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqFragData, 4))); |
Jamie Madill | 2aeb26a | 2013-07-08 14:02:55 -0400 | [diff] [blame] | 827 | if (resources.EXT_frag_depth) { |
Nicolas Capens | adfffe4 | 2014-06-17 02:13:36 -0400 | [diff] [blame] | 828 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragDepthEXT"), TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepth, 1))); |
Jamie Madill | 2aeb26a | 2013-07-08 14:02:55 -0400 | [diff] [blame] | 829 | symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_FragDepthEXT", "GL_EXT_frag_depth"); |
| 830 | } |
Erik Dahlström | ea7a212 | 2014-11-17 16:15:57 +0100 | [diff] [blame] | 831 | if (resources.EXT_shader_framebuffer_fetch) |
| 832 | { |
| 833 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqLastFragData, 4))); |
| 834 | } |
| 835 | else if (resources.NV_shader_framebuffer_fetch) |
| 836 | { |
| 837 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragColor"), TType(EbtFloat, EbpMedium, EvqLastFragColor, 4))); |
| 838 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqLastFragData, 4))); |
| 839 | } |
| 840 | else if (resources.ARM_shader_framebuffer_fetch) |
| 841 | { |
| 842 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragColorARM"), TType(EbtFloat, EbpMedium, EvqLastFragColor, 4))); |
| 843 | } |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 844 | } else { |
Nicolas Capens | adfffe4 | 2014-06-17 02:13:36 -0400 | [diff] [blame] | 845 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("css_MixColor"), TType(EbtFloat, EbpMedium, EvqGlobal, 4))); |
| 846 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("css_ColorMatrix"), TType(EbtFloat, EbpMedium, EvqGlobal, 4, 4))); |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 847 | } |
| 848 | |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 849 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 850 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 851 | case GL_VERTEX_SHADER: |
Nicolas Capens | adfffe4 | 2014-06-17 02:13:36 -0400 | [diff] [blame] | 852 | symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EbpHigh, EvqPosition, 4))); |
| 853 | symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EbpMedium, EvqPointSize, 1))); |
Gregoire Payen de La Garanderie | b3dced2 | 2015-01-12 14:54:55 +0000 | [diff] [blame] | 854 | symbolTable.insert(ESSL3_BUILTINS, new TVariable(NewPoolTString("gl_InstanceID"), TType(EbtInt, EbpHigh, EvqInstanceID, 1))); |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 855 | break; |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 856 | |
| 857 | default: assert(false && "Language not supported"); |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 858 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 859 | |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 860 | // |
| 861 | // Next, identify which built-ins from the already loaded headers have |
| 862 | // a mapping to an operator. Those that are not identified as such are |
| 863 | // expected to be resolved through a library of functions, versus as |
| 864 | // operations. |
| 865 | // |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 866 | symbolTable.relateToOperator(COMMON_BUILTINS, "matrixCompMult", EOpMul); |
Olli Etuaho | e39706d | 2014-12-30 16:40:36 +0200 | [diff] [blame] | 867 | symbolTable.relateToOperator(ESSL3_BUILTINS, "matrixCompMult", EOpMul); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 868 | |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 869 | symbolTable.relateToOperator(COMMON_BUILTINS, "equal", EOpVectorEqual); |
| 870 | symbolTable.relateToOperator(COMMON_BUILTINS, "notEqual", EOpVectorNotEqual); |
| 871 | symbolTable.relateToOperator(COMMON_BUILTINS, "lessThan", EOpLessThan); |
| 872 | symbolTable.relateToOperator(COMMON_BUILTINS, "greaterThan", EOpGreaterThan); |
| 873 | symbolTable.relateToOperator(COMMON_BUILTINS, "lessThanEqual", EOpLessThanEqual); |
| 874 | symbolTable.relateToOperator(COMMON_BUILTINS, "greaterThanEqual", EOpGreaterThanEqual); |
Arun Patole | 2b45573 | 2015-02-17 20:24:59 +0530 | [diff] [blame] | 875 | |
| 876 | symbolTable.relateToOperator(ESSL3_BUILTINS, "equal", EOpVectorEqual); |
| 877 | symbolTable.relateToOperator(ESSL3_BUILTINS, "notEqual", EOpVectorNotEqual); |
| 878 | symbolTable.relateToOperator(ESSL3_BUILTINS, "lessThan", EOpLessThan); |
| 879 | symbolTable.relateToOperator(ESSL3_BUILTINS, "greaterThan", EOpGreaterThan); |
| 880 | symbolTable.relateToOperator(ESSL3_BUILTINS, "lessThanEqual", EOpLessThanEqual); |
| 881 | symbolTable.relateToOperator(ESSL3_BUILTINS, "greaterThanEqual", EOpGreaterThanEqual); |
| 882 | |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 883 | symbolTable.relateToOperator(COMMON_BUILTINS, "radians", EOpRadians); |
| 884 | symbolTable.relateToOperator(COMMON_BUILTINS, "degrees", EOpDegrees); |
| 885 | symbolTable.relateToOperator(COMMON_BUILTINS, "sin", EOpSin); |
| 886 | symbolTable.relateToOperator(COMMON_BUILTINS, "cos", EOpCos); |
| 887 | symbolTable.relateToOperator(COMMON_BUILTINS, "tan", EOpTan); |
| 888 | symbolTable.relateToOperator(COMMON_BUILTINS, "asin", EOpAsin); |
| 889 | symbolTable.relateToOperator(COMMON_BUILTINS, "acos", EOpAcos); |
| 890 | symbolTable.relateToOperator(COMMON_BUILTINS, "atan", EOpAtan); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 891 | |
Olli Etuaho | 5c9cd3d | 2014-12-18 13:04:25 +0200 | [diff] [blame] | 892 | symbolTable.relateToOperator(ESSL3_BUILTINS, "sinh", EOpSinh); |
| 893 | symbolTable.relateToOperator(ESSL3_BUILTINS, "cosh", EOpCosh); |
| 894 | symbolTable.relateToOperator(ESSL3_BUILTINS, "tanh", EOpTanh); |
| 895 | symbolTable.relateToOperator(ESSL3_BUILTINS, "asinh", EOpAsinh); |
| 896 | symbolTable.relateToOperator(ESSL3_BUILTINS, "acosh", EOpAcosh); |
| 897 | symbolTable.relateToOperator(ESSL3_BUILTINS, "atanh", EOpAtanh); |
| 898 | |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 899 | symbolTable.relateToOperator(COMMON_BUILTINS, "pow", EOpPow); |
| 900 | symbolTable.relateToOperator(COMMON_BUILTINS, "exp2", EOpExp2); |
| 901 | symbolTable.relateToOperator(COMMON_BUILTINS, "log", EOpLog); |
| 902 | symbolTable.relateToOperator(COMMON_BUILTINS, "exp", EOpExp); |
| 903 | symbolTable.relateToOperator(COMMON_BUILTINS, "log2", EOpLog2); |
| 904 | symbolTable.relateToOperator(COMMON_BUILTINS, "sqrt", EOpSqrt); |
| 905 | symbolTable.relateToOperator(COMMON_BUILTINS, "inversesqrt", EOpInverseSqrt); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 906 | |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 907 | symbolTable.relateToOperator(COMMON_BUILTINS, "abs", EOpAbs); |
| 908 | symbolTable.relateToOperator(COMMON_BUILTINS, "sign", EOpSign); |
| 909 | symbolTable.relateToOperator(COMMON_BUILTINS, "floor", EOpFloor); |
| 910 | symbolTable.relateToOperator(COMMON_BUILTINS, "ceil", EOpCeil); |
| 911 | symbolTable.relateToOperator(COMMON_BUILTINS, "fract", EOpFract); |
| 912 | symbolTable.relateToOperator(COMMON_BUILTINS, "mod", EOpMod); |
| 913 | symbolTable.relateToOperator(COMMON_BUILTINS, "min", EOpMin); |
| 914 | symbolTable.relateToOperator(COMMON_BUILTINS, "max", EOpMax); |
| 915 | symbolTable.relateToOperator(COMMON_BUILTINS, "clamp", EOpClamp); |
| 916 | symbolTable.relateToOperator(COMMON_BUILTINS, "mix", EOpMix); |
| 917 | symbolTable.relateToOperator(COMMON_BUILTINS, "step", EOpStep); |
| 918 | symbolTable.relateToOperator(COMMON_BUILTINS, "smoothstep", EOpSmoothStep); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 919 | |
Arun Patole | 3e142e4 | 2015-02-19 09:40:39 +0530 | [diff] [blame] | 920 | symbolTable.relateToOperator(ESSL3_BUILTINS, "abs", EOpAbs); |
| 921 | symbolTable.relateToOperator(ESSL3_BUILTINS, "sign", EOpSign); |
Olli Etuaho | b6e07a6 | 2015-02-16 12:22:10 +0200 | [diff] [blame^] | 922 | symbolTable.relateToOperator(ESSL3_BUILTINS, "modf", EOpModf); |
Arun Patole | 42077bb | 2015-02-16 15:32:37 +0530 | [diff] [blame] | 923 | symbolTable.relateToOperator(ESSL3_BUILTINS, "min", EOpMin); |
| 924 | symbolTable.relateToOperator(ESSL3_BUILTINS, "max", EOpMax); |
| 925 | symbolTable.relateToOperator(ESSL3_BUILTINS, "clamp", EOpClamp); |
Arun Patole | 0c1726e | 2015-02-18 14:35:02 +0530 | [diff] [blame] | 926 | symbolTable.relateToOperator(ESSL3_BUILTINS, "isnan", EOpIsNan); |
| 927 | symbolTable.relateToOperator(ESSL3_BUILTINS, "isinf", EOpIsInf); |
Arun Patole | 42077bb | 2015-02-16 15:32:37 +0530 | [diff] [blame] | 928 | |
Olli Etuaho | e8d2c07 | 2015-01-08 16:33:54 +0200 | [diff] [blame] | 929 | symbolTable.relateToOperator(ESSL3_BUILTINS, "floatBitsToInt", EOpFloatBitsToInt); |
| 930 | symbolTable.relateToOperator(ESSL3_BUILTINS, "floatBitsToUint", EOpFloatBitsToUint); |
| 931 | symbolTable.relateToOperator(ESSL3_BUILTINS, "intBitsToFloat", EOpIntBitsToFloat); |
| 932 | symbolTable.relateToOperator(ESSL3_BUILTINS, "uintBitsToFloat", EOpUintBitsToFloat); |
| 933 | |
Olli Etuaho | 7700ff6 | 2015-01-15 12:16:29 +0200 | [diff] [blame] | 934 | symbolTable.relateToOperator(ESSL3_BUILTINS, "packSnorm2x16", EOpPackSnorm2x16); |
| 935 | symbolTable.relateToOperator(ESSL3_BUILTINS, "packUnorm2x16", EOpPackUnorm2x16); |
| 936 | symbolTable.relateToOperator(ESSL3_BUILTINS, "packHalf2x16", EOpPackHalf2x16); |
| 937 | |
| 938 | symbolTable.relateToOperator(ESSL3_BUILTINS, "unpackSnorm2x16", EOpUnpackSnorm2x16); |
| 939 | symbolTable.relateToOperator(ESSL3_BUILTINS, "unpackUnorm2x16", EOpUnpackUnorm2x16); |
| 940 | symbolTable.relateToOperator(ESSL3_BUILTINS, "unpackHalf2x16", EOpUnpackHalf2x16); |
| 941 | |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 942 | symbolTable.relateToOperator(COMMON_BUILTINS, "length", EOpLength); |
| 943 | symbolTable.relateToOperator(COMMON_BUILTINS, "distance", EOpDistance); |
| 944 | symbolTable.relateToOperator(COMMON_BUILTINS, "dot", EOpDot); |
| 945 | symbolTable.relateToOperator(COMMON_BUILTINS, "cross", EOpCross); |
| 946 | symbolTable.relateToOperator(COMMON_BUILTINS, "normalize", EOpNormalize); |
| 947 | symbolTable.relateToOperator(COMMON_BUILTINS, "faceforward", EOpFaceForward); |
| 948 | symbolTable.relateToOperator(COMMON_BUILTINS, "reflect", EOpReflect); |
| 949 | symbolTable.relateToOperator(COMMON_BUILTINS, "refract", EOpRefract); |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 950 | |
Olli Etuaho | e39706d | 2014-12-30 16:40:36 +0200 | [diff] [blame] | 951 | symbolTable.relateToOperator(ESSL3_BUILTINS, "outerProduct", EOpOuterProduct); |
| 952 | symbolTable.relateToOperator(ESSL3_BUILTINS, "transpose", EOpTranspose); |
| 953 | symbolTable.relateToOperator(ESSL3_BUILTINS, "determinant", EOpDeterminant); |
Olli Etuaho | abf6dad | 2015-01-14 14:45:16 +0200 | [diff] [blame] | 954 | symbolTable.relateToOperator(ESSL3_BUILTINS, "inverse", EOpInverse); |
Olli Etuaho | e39706d | 2014-12-30 16:40:36 +0200 | [diff] [blame] | 955 | |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 956 | symbolTable.relateToOperator(COMMON_BUILTINS, "any", EOpAny); |
| 957 | symbolTable.relateToOperator(COMMON_BUILTINS, "all", EOpAll); |
| 958 | symbolTable.relateToOperator(COMMON_BUILTINS, "not", EOpVectorLogicalNot); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 959 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 960 | // Map language-specific operators. |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 961 | switch(type) { |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 962 | case GL_VERTEX_SHADER: |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 963 | break; |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 964 | case GL_FRAGMENT_SHADER: |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 965 | if (resources.OES_standard_derivatives) |
| 966 | { |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 967 | symbolTable.relateToOperator(ESSL1_BUILTINS, "dFdx", EOpDFdx); |
| 968 | symbolTable.relateToOperator(ESSL1_BUILTINS, "dFdy", EOpDFdy); |
| 969 | symbolTable.relateToOperator(ESSL1_BUILTINS, "fwidth", EOpFwidth); |
alokp@chromium.org | 8815d7f | 2010-09-09 17:30:03 +0000 | [diff] [blame] | 970 | |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 971 | symbolTable.relateToExtension(ESSL1_BUILTINS, "dFdx", "GL_OES_standard_derivatives"); |
| 972 | symbolTable.relateToExtension(ESSL1_BUILTINS, "dFdy", "GL_OES_standard_derivatives"); |
| 973 | symbolTable.relateToExtension(ESSL1_BUILTINS, "fwidth", "GL_OES_standard_derivatives"); |
alokp@chromium.org | 0609889 | 2010-08-26 19:36:42 +0000 | [diff] [blame] | 974 | } |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 975 | if (resources.EXT_shader_texture_lod) |
| 976 | { |
| 977 | symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DLodEXT", "GL_EXT_shader_texture_lod"); |
| 978 | symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DProjLodEXT", "GL_EXT_shader_texture_lod"); |
| 979 | symbolTable.relateToExtension(ESSL1_BUILTINS, "textureCubeLodEXT", "GL_EXT_shader_texture_lod"); |
| 980 | } |
Erik Dahlström | ea7a212 | 2014-11-17 16:15:57 +0100 | [diff] [blame] | 981 | if (resources.NV_shader_framebuffer_fetch) |
| 982 | { |
| 983 | symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_LastFragColor", "GL_NV_shader_framebuffer_fetch"); |
| 984 | } |
| 985 | else if (resources.ARM_shader_framebuffer_fetch) |
| 986 | { |
| 987 | symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_LastFragColorARM", "GL_ARM_shader_framebuffer_fetch"); |
| 988 | } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 989 | break; |
| 990 | default: break; |
| 991 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 992 | |
Nicolas Capens | f4cb0e1 | 2013-06-24 16:11:36 -0400 | [diff] [blame] | 993 | symbolTable.relateToOperator(ESSL3_BUILTINS, "dFdx", EOpDFdx); |
| 994 | symbolTable.relateToOperator(ESSL3_BUILTINS, "dFdy", EOpDFdy); |
| 995 | symbolTable.relateToOperator(ESSL3_BUILTINS, "fwidth", EOpFwidth); |
| 996 | |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 997 | if (resources.EXT_shader_texture_lod) |
| 998 | { |
| 999 | symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DGradEXT", "GL_EXT_shader_texture_lod"); |
| 1000 | symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DProjGradEXT", "GL_EXT_shader_texture_lod"); |
| 1001 | symbolTable.relateToExtension(ESSL1_BUILTINS, "textureCubeGradEXT", "GL_EXT_shader_texture_lod"); |
| 1002 | } |
| 1003 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 1004 | // Finally add resource-specific variables. |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 1005 | switch(type) { |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 1006 | case GL_FRAGMENT_SHADER: |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 1007 | if (spec != SH_CSS_SHADERS_SPEC) { |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 1008 | // Set up gl_FragData. The array size. |
shannonwoods@chromium.org | 09e0988 | 2013-05-30 00:18:25 +0000 | [diff] [blame] | 1009 | TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true); |
alokp@chromium.org | 94a86ad | 2010-08-25 20:02:11 +0000 | [diff] [blame] | 1010 | fragData.setArraySize(resources.MaxDrawBuffers); |
Nicolas Capens | adfffe4 | 2014-06-17 02:13:36 -0400 | [diff] [blame] | 1011 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData"), fragData)); |
Erik Dahlström | ea7a212 | 2014-11-17 16:15:57 +0100 | [diff] [blame] | 1012 | |
| 1013 | if (resources.EXT_shader_framebuffer_fetch || resources.NV_shader_framebuffer_fetch) { |
| 1014 | // Set up gl_LastFragData. The array size. |
| 1015 | TType lastFragData(EbtFloat, EbpMedium, EvqLastFragData, 4, 1, true); |
| 1016 | lastFragData.setArraySize(resources.MaxDrawBuffers); |
| 1017 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragData"), lastFragData)); |
| 1018 | |
| 1019 | if (resources.EXT_shader_framebuffer_fetch) |
| 1020 | { |
| 1021 | symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_LastFragData", "GL_EXT_shader_framebuffer_fetch"); |
| 1022 | } |
| 1023 | else if (resources.NV_shader_framebuffer_fetch) |
| 1024 | { |
| 1025 | symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_LastFragData", "GL_NV_shader_framebuffer_fetch"); |
| 1026 | } |
| 1027 | } |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 1028 | } |
| 1029 | break; |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 1030 | default: break; |
| 1031 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1032 | } |
| 1033 | |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 1034 | void InitExtensionBehavior(const ShBuiltInResources& resources, |
alokp@chromium.org | ad771eb | 2010-09-07 17:36:23 +0000 | [diff] [blame] | 1035 | TExtensionBehavior& extBehavior) |
| 1036 | { |
| 1037 | if (resources.OES_standard_derivatives) |
zmo@google.com | 09c323a | 2011-08-12 18:22:25 +0000 | [diff] [blame] | 1038 | extBehavior["GL_OES_standard_derivatives"] = EBhUndefined; |
| 1039 | if (resources.OES_EGL_image_external) |
| 1040 | extBehavior["GL_OES_EGL_image_external"] = EBhUndefined; |
kbr@chromium.org | 205fef3 | 2011-11-22 20:50:02 +0000 | [diff] [blame] | 1041 | if (resources.ARB_texture_rectangle) |
| 1042 | extBehavior["GL_ARB_texture_rectangle"] = EBhUndefined; |
shannon.woods@transgaming.com | 550cd09 | 2013-02-28 23:19:54 +0000 | [diff] [blame] | 1043 | if (resources.EXT_draw_buffers) |
| 1044 | extBehavior["GL_EXT_draw_buffers"] = EBhUndefined; |
Jamie Madill | 2aeb26a | 2013-07-08 14:02:55 -0400 | [diff] [blame] | 1045 | if (resources.EXT_frag_depth) |
| 1046 | extBehavior["GL_EXT_frag_depth"] = EBhUndefined; |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 1047 | if (resources.EXT_shader_texture_lod) |
| 1048 | extBehavior["GL_EXT_shader_texture_lod"] = EBhUndefined; |
Erik Dahlström | ea7a212 | 2014-11-17 16:15:57 +0100 | [diff] [blame] | 1049 | if (resources.EXT_shader_framebuffer_fetch) |
| 1050 | extBehavior["GL_EXT_shader_framebuffer_fetch"] = EBhUndefined; |
| 1051 | if (resources.NV_shader_framebuffer_fetch) |
| 1052 | extBehavior["GL_NV_shader_framebuffer_fetch"] = EBhUndefined; |
| 1053 | if (resources.ARM_shader_framebuffer_fetch) |
| 1054 | extBehavior["GL_ARM_shader_framebuffer_fetch"] = EBhUndefined; |
alokp@chromium.org | ad771eb | 2010-09-07 17:36:23 +0000 | [diff] [blame] | 1055 | } |
David Yen | 0fbd128 | 2015-02-02 14:46:09 -0800 | [diff] [blame] | 1056 | |
| 1057 | void ResetExtensionBehavior(TExtensionBehavior &extBehavior) |
| 1058 | { |
| 1059 | for (auto ext_iter = extBehavior.begin(); |
| 1060 | ext_iter != extBehavior.end(); |
| 1061 | ++ext_iter) |
| 1062 | { |
| 1063 | ext_iter->second = EBhUndefined; |
| 1064 | } |
| 1065 | } |