daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1 | // |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 2 | // Copyright (c) 2002-2013 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 | // |
| 8 | // Create strings that declare built-in definitions, add built-ins that |
| 9 | // cannot be expressed in the files, and establish mappings between |
| 10 | // built-in functions and operators. |
| 11 | // |
| 12 | |
daniel@transgaming.com | bbf56f7 | 2010-04-20 18:52:13 +0000 | [diff] [blame] | 13 | #include "compiler/Initialize.h" |
| 14 | |
| 15 | #include "compiler/intermediate.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 16 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 17 | void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources &resources, |
| 18 | const TExtensionBehavior &extensionBehavior, TSymbolTable &symbolTable) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 19 | { |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 20 | TType *float1 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 1); |
| 21 | TType *float2 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 2); |
| 22 | TType *float3 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 3); |
| 23 | TType *float4 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 4); |
| 24 | |
| 25 | TType *int2 = new TType(EbtInt, EbpUndefined, EvqGlobal, 2); |
| 26 | TType *int3 = new TType(EbtInt, EbpUndefined, EvqGlobal, 3); |
| 27 | TType *int4 = new TType(EbtInt, EbpUndefined, EvqGlobal, 4); |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 28 | |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 29 | // |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 30 | // Angle and Trigonometric Functions. |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 31 | // |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 32 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "radians", float1, "degrees"); |
| 33 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "radians", float2, "degrees"); |
| 34 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "radians", float3, "degrees"); |
| 35 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "radians", float4, "degrees"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 36 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 37 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "degrees", float1, "radians"); |
| 38 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "degrees", float2, "radians"); |
| 39 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "degrees", float3, "radians"); |
| 40 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "degrees", float4, "radians"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 41 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 42 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sin", float1, "angle"); |
| 43 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sin", float2, "angle"); |
| 44 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sin", float3, "angle"); |
| 45 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sin", float4, "angle"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 46 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 47 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "cos", float1, "angle"); |
| 48 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "cos", float2, "angle"); |
| 49 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "cos", float3, "angle"); |
| 50 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "cos", float4, "angle"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 51 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 52 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "tan", float1, "angle"); |
| 53 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "tan", float2, "angle"); |
| 54 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "tan", float3, "angle"); |
| 55 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "tan", float4, "angle"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 56 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 57 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "asin", float1, "x"); |
| 58 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "asin", float2, "x"); |
| 59 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "asin", float3, "x"); |
| 60 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "asin", float4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 61 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 62 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "acos", float1, "x"); |
| 63 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "acos", float2, "x"); |
| 64 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "acos", float3, "x"); |
| 65 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "acos", float4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 66 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 67 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "atan", float1, "y", float1, "x"); |
| 68 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "atan", float2, "y", float2, "x"); |
| 69 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "atan", float3, "y", float3, "x"); |
| 70 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "atan", float4, "y", float4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 71 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 72 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "atan", float1, "y_over_x"); |
| 73 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "atan", float2, "y_over_x"); |
| 74 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "atan", float3, "y_over_x"); |
| 75 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "atan", float4, "y_over_x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 76 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 77 | // |
| 78 | // Exponential Functions. |
| 79 | // |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 80 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "pow", float1, "x", float1, "y"); |
| 81 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "pow", float2, "x", float2, "y"); |
| 82 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "pow", float3, "x", float3, "y"); |
| 83 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "pow", float4, "x", float4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 84 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 85 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "exp", float1, "x"); |
| 86 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "exp", float2, "x"); |
| 87 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "exp", float3, "x"); |
| 88 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "exp", float4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 89 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 90 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "log", float1, "x"); |
| 91 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "log", float2, "x"); |
| 92 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "log", float3, "x"); |
| 93 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "log", float4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 94 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 95 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "exp2", float1, "x"); |
| 96 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "exp2", float2, "x"); |
| 97 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "exp2", float3, "x"); |
| 98 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "exp2", float4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 99 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 100 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "log2", float1, "x"); |
| 101 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "log2", float2, "x"); |
| 102 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "log2", float3, "x"); |
| 103 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "log2", float4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 104 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 105 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sqrt", float1, "x"); |
| 106 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sqrt", float2, "x"); |
| 107 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sqrt", float3, "x"); |
| 108 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sqrt", float4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 109 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 110 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "inversesqrt", float1, "x"); |
| 111 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "inversesqrt", float2, "x"); |
| 112 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "inversesqrt", float3, "x"); |
| 113 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "inversesqrt", float4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 114 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 115 | // |
| 116 | // Common Functions. |
| 117 | // |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 118 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "abs", float1, "x"); |
| 119 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "abs", float2, "x"); |
| 120 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "abs", float3, "x"); |
| 121 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "abs", float4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 122 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 123 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sign", float1, "x"); |
| 124 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sign", float2, "x"); |
| 125 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sign", float3, "x"); |
| 126 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sign", float4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 127 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 128 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "floor", float1, "x"); |
| 129 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "floor", float2, "x"); |
| 130 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "floor", float3, "x"); |
| 131 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "floor", float4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 132 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 133 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "ceil", float1, "x"); |
| 134 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "ceil", float2, "x"); |
| 135 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "ceil", float3, "x"); |
| 136 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "ceil", float4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 137 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 138 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "fract", float1, "x"); |
| 139 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "fract", float2, "x"); |
| 140 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "fract", float3, "x"); |
| 141 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "fract", float4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 142 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 143 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "mod", float1, "x", float1, "y"); |
| 144 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mod", float2, "x", float1, "y"); |
| 145 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mod", float3, "x", float1, "y"); |
| 146 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mod", float4, "x", float1, "y"); |
| 147 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mod", float2, "x", float2, "y"); |
| 148 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mod", float3, "x", float3, "y"); |
| 149 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mod", float4, "x", float4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 150 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 151 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "min", float1, "x", float1, "y"); |
| 152 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "min", float2, "x", float1, "y"); |
| 153 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "min", float3, "x", float1, "y"); |
| 154 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "min", float4, "x", float1, "y"); |
| 155 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "min", float2, "x", float2, "y"); |
| 156 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "min", float3, "x", float3, "y"); |
| 157 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "min", float4, "x", float4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 158 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 159 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "max", float1, "x", float1, "y"); |
| 160 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "max", float2, "x", float1, "y"); |
| 161 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "max", float3, "x", float1, "y"); |
| 162 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "max", float4, "x", float1, "y"); |
| 163 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "max", float2, "x", float2, "y"); |
| 164 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "max", float3, "x", float3, "y"); |
| 165 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "max", float4, "x", float4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 166 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 167 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "clamp", float1, "x", float1, "minVal", float1, "maxVal"); |
| 168 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "clamp", float2, "x", float1, "minVal", float1, "maxVal"); |
| 169 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "clamp", float3, "x", float1, "minVal", float1, "maxVal"); |
| 170 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "clamp", float4, "x", float1, "minVal", float1, "maxVal"); |
| 171 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "clamp", float2, "x", float2, "minVal", float2, "maxVal"); |
| 172 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "clamp", float3, "x", float3, "minVal", float3, "maxVal"); |
| 173 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "clamp", float4, "x", float4, "minVal", float4, "maxVal"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 174 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 175 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "mix", float1, "x", float1, "y", float1, "a"); |
| 176 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mix", float2, "x", float2, "y", float1, "a"); |
| 177 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mix", float3, "x", float3, "y", float1, "a"); |
| 178 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mix", float4, "x", float4, "y", float1, "a"); |
| 179 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mix", float2, "x", float2, "y", float2, "a"); |
| 180 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mix", float3, "x", float3, "y", float3, "a"); |
| 181 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mix", float4, "x", float4, "y", float4, "a"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 182 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 183 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "step", float1, "edge", float1, "x"); |
| 184 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "step", float2, "edge", float2, "x"); |
| 185 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "step", float3, "edge", float3, "x"); |
| 186 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "step", float4, "edge", float4, "x"); |
| 187 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "step", float1, "edge", float2, "x"); |
| 188 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "step", float1, "edge", float3, "x"); |
| 189 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "step", float1, "edge", float4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 190 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 191 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "smoothstep", float1, "edge0", float1, "edge1", float1, "x"); |
| 192 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "smoothstep", float2, "edge0", float2, "edge1", float2, "x"); |
| 193 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "smoothstep", float3, "edge0", float3, "edge1", float3, "x"); |
| 194 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "smoothstep", float4, "edge0", float4, "edge1", float4, "x"); |
| 195 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "smoothstep", float1, "edge0", float1, "edge1", float2, "x"); |
| 196 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "smoothstep", float1, "edge0", float1, "edge1", float3, "x"); |
| 197 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "smoothstep", float1, "edge0", float1, "edge1", float4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 198 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 199 | // |
| 200 | // Geometric Functions. |
| 201 | // |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 202 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float1, "x"); |
| 203 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float2, "x"); |
| 204 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float3, "x"); |
| 205 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 206 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 207 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float1, "p0", float1, "p1"); |
| 208 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float2, "p0", float2, "p1"); |
| 209 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float3, "p0", float3, "p1"); |
| 210 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float4, "p0", float4, "p1"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 211 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 212 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float1, "x", float1, "y"); |
| 213 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float2, "x", float2, "y"); |
| 214 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float3, "x", float3, "y"); |
| 215 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float4, "x", float4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 216 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 217 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "cross", float3, "x", float3, "y"); |
| 218 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "normalize", float1, "x"); |
| 219 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "normalize", float2, "x"); |
| 220 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "normalize", float3, "x"); |
| 221 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "normalize", float4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 222 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 223 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "faceforward", float1, "N", float1, "I", float1, "Nref"); |
| 224 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "faceforward", float2, "N", float2, "I", float2, "Nref"); |
| 225 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "faceforward", float3, "N", float3, "I", float3, "Nref"); |
| 226 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "faceforward", float4, "N", float4, "I", float4, "Nref"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 227 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 228 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "reflect", float1, "I", float1, "N"); |
| 229 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "reflect", float2, "I", float2, "N"); |
| 230 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "reflect", float3, "I", float3, "N"); |
| 231 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "reflect", float4, "I", float4, "N"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 232 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 233 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "refract", float1, "I", float1, "N", float1, "eta"); |
| 234 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "refract", float2, "I", float2, "N", float1, "eta"); |
| 235 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "refract", float3, "I", float3, "N", float1, "eta"); |
| 236 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "refract", float4, "I", float4, "N", float1, "eta"); |
| 237 | |
| 238 | TType *mat2 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 2, 2); |
| 239 | TType *mat3 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 3, 3); |
| 240 | TType *mat4 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 4, 4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 241 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 242 | // |
| 243 | // Matrix Functions. |
| 244 | // |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 245 | symbolTable.insertBuiltIn(COMMON_BUILTINS, mat2, "matrixCompMult", mat2, "x", mat2, "y"); |
| 246 | symbolTable.insertBuiltIn(COMMON_BUILTINS, mat3, "matrixCompMult", mat3, "x", mat3, "y"); |
| 247 | symbolTable.insertBuiltIn(COMMON_BUILTINS, mat4, "matrixCompMult", mat4, "x", mat4, "y"); |
| 248 | |
| 249 | TType *bool1 = new TType(EbtBool, EbpUndefined, EvqGlobal, 1); |
| 250 | TType *bool2 = new TType(EbtBool, EbpUndefined, EvqGlobal, 2); |
| 251 | TType *bool3 = new TType(EbtBool, EbpUndefined, EvqGlobal, 3); |
| 252 | TType *bool4 = new TType(EbtBool, EbpUndefined, EvqGlobal, 4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 253 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 254 | // |
| 255 | // Vector relational functions. |
| 256 | // |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 257 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThan", float2, "x", float2, "y"); |
| 258 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThan", float3, "x", float3, "y"); |
| 259 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThan", float4, "x", float4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 260 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 261 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThan", int2, "x", int2, "y"); |
| 262 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThan", int3, "x", int3, "y"); |
| 263 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThan", int4, "x", int4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 264 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 265 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThanEqual", float2, "x", float2, "y"); |
| 266 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThanEqual", float3, "x", float3, "y"); |
| 267 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThanEqual", float4, "x", float4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 268 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 269 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThanEqual", int2, "x", int2, "y"); |
| 270 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThanEqual", int3, "x", int3, "y"); |
| 271 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThanEqual", int4, "x", int4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 272 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 273 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThan", float2, "x", float2, "y"); |
| 274 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThan", float3, "x", float3, "y"); |
| 275 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThan", float4, "x", float4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 276 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 277 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThan", int2, "x", int2, "y"); |
| 278 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThan", int3, "x", int3, "y"); |
| 279 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThan", int4, "x", int4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 280 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 281 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThanEqual", float2, "x", float2, "y"); |
| 282 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThanEqual", float3, "x", float3, "y"); |
| 283 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThanEqual", float4, "x", float4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 284 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 285 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThanEqual", int2, "x", int2, "y"); |
| 286 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThanEqual", int3, "x", int3, "y"); |
| 287 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThanEqual", int4, "x", int4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 288 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 289 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", float2, "x", float2, "y"); |
| 290 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", float3, "x", float3, "y"); |
| 291 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", float4, "x", float4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 292 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 293 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", int2, "x", int2, "y"); |
| 294 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", int3, "x", int3, "y"); |
| 295 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", int4, "x", int4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 296 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 297 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", bool2, "x", bool2, "y"); |
| 298 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", bool3, "x", bool3, "y"); |
| 299 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", bool4, "x", bool4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 300 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 301 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", float2, "x", float2, "y"); |
| 302 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", float3, "x", float3, "y"); |
| 303 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", float4, "x", float4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 304 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 305 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", int2, "x", int2, "y"); |
| 306 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", int3, "x", int3, "y"); |
| 307 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", int4, "x", int4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 308 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 309 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", bool2, "x", bool2, "y"); |
| 310 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", bool3, "x", bool3, "y"); |
| 311 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", bool4, "x", bool4, "y"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 312 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 313 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool2, "x"); |
| 314 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool3, "x"); |
| 315 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 316 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 317 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool2, "x"); |
| 318 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool3, "x"); |
| 319 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 320 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 321 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "not", bool2, "x"); |
| 322 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "not", bool3, "x"); |
| 323 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "not", bool4, "x"); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 324 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 325 | TType *sampler2D = new TType(EbtSampler2D, EbpUndefined, EvqGlobal, 1); |
| 326 | TType *samplerCube = new TType(EbtSamplerCube, EbpUndefined, EvqGlobal, 1); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 327 | |
| 328 | // |
| 329 | // Texture Functions for GLSL ES 1.0 |
| 330 | // |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 331 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, "sampler", float2, "coord"); |
| 332 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, "sampler", float3, "coord"); |
| 333 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, "sampler", float4, "coord"); |
| 334 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, "sampler", float3, "coord"); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 335 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 336 | if (resources.OES_EGL_image_external) |
| 337 | { |
| 338 | TType *samplerExternalOES = new TType(EbtSamplerExternalOES, EbpUndefined, EvqGlobal, 1); |
| 339 | |
| 340 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", samplerExternalOES, "sampler", float2, "coord"); |
| 341 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, "sampler", float3, "coord"); |
| 342 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, "sampler", float4, "coord"); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 343 | } |
| 344 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 345 | if (resources.ARB_texture_rectangle) |
| 346 | { |
| 347 | TType *sampler2DRect = new TType(EbtSampler2DRect, EbpUndefined, EvqGlobal, 1); |
| 348 | |
| 349 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRect", sampler2DRect, "sampler", float2, "coord"); |
| 350 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect, "sampler", float3, "coord"); |
| 351 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect, "sampler", float4, "coord"); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 352 | } |
| 353 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 354 | if(type == SH_FRAGMENT_SHADER) |
| 355 | { |
| 356 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, "sampler", float2, "coord", float1, "bias"); |
| 357 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, "sampler", float3, "coord", float1, "bias"); |
| 358 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, "sampler", float4, "coord", float1, "bias"); |
| 359 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, "sampler", float3, "coord", float1, "bias"); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 360 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 361 | if (resources.OES_standard_derivatives) |
| 362 | { |
| 363 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "dFdx", float1, "p"); |
| 364 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "dFdx", float2, "p"); |
| 365 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "dFdx", float3, "p"); |
| 366 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "dFdx", float4, "p"); |
| 367 | |
| 368 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "dFdy", float1, "p"); |
| 369 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "dFdy", float2, "p"); |
| 370 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "dFdy", float3, "p"); |
| 371 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "dFdy", float4, "p"); |
| 372 | |
| 373 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "fwidth", float1, "p"); |
| 374 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "fwidth", float2, "p"); |
| 375 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "fwidth", float3, "p"); |
| 376 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "fwidth", float4, "p"); |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | if(type == SH_VERTEX_SHADER) |
| 381 | { |
| 382 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DLod", sampler2D, "sampler", float2, "coord", float1, "lod"); |
| 383 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, "sampler", float3, "coord", float1, "lod"); |
| 384 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, "sampler", float4, "coord", float1, "lod"); |
| 385 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeLod", samplerCube, "sampler", float3, "coord", float1, "lod"); |
| 386 | } |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 387 | |
Nicolas Capens | 73f5bf6 | 2013-06-17 16:13:33 -0400 | [diff] [blame] | 388 | TType *sampler3D = new TType(EbtSampler3D, EbpUndefined, EvqGlobal, 1); |
| 389 | |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 390 | // |
| 391 | // Texture Functions for GLSL ES 3.0 |
| 392 | // |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 393 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "texture", sampler2D, "sampler", float2, "coord"); |
Nicolas Capens | 73f5bf6 | 2013-06-17 16:13:33 -0400 | [diff] [blame] | 394 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "texture", sampler3D, "sampler", float3, "coord"); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 395 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "texture", samplerCube, "sampler", float3, "coord"); |
| 396 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "textureProj", sampler2D, "sampler", float3, "coord"); |
| 397 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "textureProj", sampler2D, "sampler", float4, "coord"); |
Nicolas Capens | 73f5bf6 | 2013-06-17 16:13:33 -0400 | [diff] [blame] | 398 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "textureProj", sampler3D, "sampler", float4, "coord"); |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 399 | |
Nicolas Capens | 9363246 | 2013-06-17 14:10:38 -0400 | [diff] [blame] | 400 | TType *isampler2D = new TType(EbtISampler2D, EbpUndefined, EvqGlobal, 1); |
Nicolas Capens | 73f5bf6 | 2013-06-17 16:13:33 -0400 | [diff] [blame] | 401 | TType *isampler3D = new TType(EbtISampler3D, EbpUndefined, EvqGlobal, 1); |
Nicolas Capens | 9363246 | 2013-06-17 14:10:38 -0400 | [diff] [blame] | 402 | TType *isamplerCube = new TType(EbtISamplerCube, EbpUndefined, EvqGlobal, 1); |
| 403 | |
| 404 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "texture", isampler2D, "sampler", float2, "coord"); |
Nicolas Capens | 73f5bf6 | 2013-06-17 16:13:33 -0400 | [diff] [blame] | 405 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "texture", isampler3D, "sampler", float3, "coord"); |
Nicolas Capens | 9363246 | 2013-06-17 14:10:38 -0400 | [diff] [blame] | 406 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "texture", isamplerCube, "sampler", float3, "coord"); |
| 407 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "textureProj", isampler2D, "sampler", float3, "coord"); |
| 408 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "textureProj", isampler2D, "sampler", float4, "coord"); |
Nicolas Capens | 73f5bf6 | 2013-06-17 16:13:33 -0400 | [diff] [blame] | 409 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "textureProj", isampler3D, "sampler", float4, "coord"); |
Nicolas Capens | 9363246 | 2013-06-17 14:10:38 -0400 | [diff] [blame] | 410 | |
Nicolas Capens | 8613229 | 2013-06-17 15:50:23 -0400 | [diff] [blame] | 411 | TType *usampler2D = new TType(EbtUSampler2D, EbpUndefined, EvqGlobal, 1); |
Nicolas Capens | 73f5bf6 | 2013-06-17 16:13:33 -0400 | [diff] [blame] | 412 | TType *usampler3D = new TType(EbtUSampler3D, EbpUndefined, EvqGlobal, 1); |
Nicolas Capens | 8613229 | 2013-06-17 15:50:23 -0400 | [diff] [blame] | 413 | TType *usamplerCube = new TType(EbtUSamplerCube, EbpUndefined, EvqGlobal, 1); |
| 414 | TType *uint4 = new TType(EbtUInt, EbpUndefined, EvqGlobal, 4); |
| 415 | |
| 416 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "texture", usampler2D, "sampler", float2, "coord"); |
Nicolas Capens | 73f5bf6 | 2013-06-17 16:13:33 -0400 | [diff] [blame] | 417 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "texture", usampler3D, "sampler", float3, "coord"); |
Nicolas Capens | 8613229 | 2013-06-17 15:50:23 -0400 | [diff] [blame] | 418 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "texture", usamplerCube, "sampler", float3, "coord"); |
| 419 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "textureProj", usampler2D, "sampler", float3, "coord"); |
| 420 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "textureProj", usampler2D, "sampler", float4, "coord"); |
Nicolas Capens | 73f5bf6 | 2013-06-17 16:13:33 -0400 | [diff] [blame] | 421 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "textureProj", usampler3D, "sampler", float4, "coord"); |
Nicolas Capens | 8613229 | 2013-06-17 15:50:23 -0400 | [diff] [blame] | 422 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 423 | if(type == SH_FRAGMENT_SHADER) |
| 424 | { |
| 425 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "dFdx", float1, "p"); |
| 426 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "dFdx", float2, "p"); |
| 427 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "dFdx", float3, "p"); |
| 428 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "dFdx", float4, "p"); |
| 429 | |
| 430 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "dFdy", float1, "p"); |
| 431 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "dFdy", float2, "p"); |
| 432 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "dFdy", float3, "p"); |
| 433 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "dFdy", float4, "p"); |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 434 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 435 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "fwidth", float1, "p"); |
| 436 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "fwidth", float2, "p"); |
| 437 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "fwidth", float3, "p"); |
| 438 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "fwidth", float4, "p"); |
alokp@chromium.org | 0609889 | 2010-08-26 19:36:42 +0000 | [diff] [blame] | 439 | } |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 440 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 441 | // |
| 442 | // Depth range in window coordinates |
| 443 | // |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 444 | TTypeList *members = NewPoolTTypeList(); |
| 445 | TTypeLine near = {new TType(EbtFloat, EbpHigh, EvqGlobal, 1), 0}; |
| 446 | TTypeLine far = {new TType(EbtFloat, EbpHigh, EvqGlobal, 1), 0}; |
| 447 | TTypeLine diff = {new TType(EbtFloat, EbpHigh, EvqGlobal, 1), 0}; |
| 448 | near.type->setFieldName("near"); |
| 449 | far.type->setFieldName("far"); |
| 450 | diff.type->setFieldName("diff"); |
| 451 | members->push_back(near); |
| 452 | members->push_back(far); |
| 453 | members->push_back(diff); |
| 454 | TVariable *depthRangeParameters = new TVariable(NewPoolTString("gl_DepthRangeParameters"), TType(members, "gl_DepthRangeParameters"), true); |
| 455 | symbolTable.insert(COMMON_BUILTINS, *depthRangeParameters); |
| 456 | TVariable *depthRange = new TVariable(NewPoolTString("gl_DepthRange"), TType(members, "gl_DepthRangeParameters")); |
| 457 | depthRange->setQualifier(EvqUniform); |
| 458 | symbolTable.insert(COMMON_BUILTINS, *depthRange); |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 459 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 460 | // |
| 461 | // Implementation dependent built-in constants. |
| 462 | // |
| 463 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexAttribs", resources.MaxVertexAttribs); |
| 464 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexUniformVectors", resources.MaxVertexUniformVectors); |
| 465 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexTextureImageUnits", resources.MaxVertexTextureImageUnits); |
| 466 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxCombinedTextureImageUnits", resources.MaxCombinedTextureImageUnits); |
| 467 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxTextureImageUnits", resources.MaxTextureImageUnits); |
| 468 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxFragmentUniformVectors", resources.MaxFragmentUniformVectors); |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 469 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 470 | symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxVaryingVectors", resources.MaxVaryingVectors); |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 471 | |
| 472 | if (spec != SH_CSS_SHADERS_SPEC) |
shannon.woods%transgaming.com@gtempaccount.com | 5209de8 | 2013-04-13 03:41:53 +0000 | [diff] [blame] | 473 | { |
| 474 | TExtensionBehavior::const_iterator iter = extensionBehavior.find("GL_EXT_draw_buffers"); |
| 475 | const bool usingMRTExtension = (iter != extensionBehavior.end() && (iter->second == EBhEnable || iter->second == EBhRequire)); |
| 476 | const int maxDrawBuffers = (usingMRTExtension ? resources.MaxDrawBuffers : 1); |
| 477 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 478 | symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxDrawBuffers", maxDrawBuffers); |
shannon.woods%transgaming.com@gtempaccount.com | 5209de8 | 2013-04-13 03:41:53 +0000 | [diff] [blame] | 479 | } |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 480 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 481 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxVertexOutputVectors", resources.MaxVertexOutputVectors); |
| 482 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxFragmentInputVectors", resources.MaxFragmentInputVectors); |
| 483 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MinProgramTexelOffset", resources.MinProgramTexelOffset); |
| 484 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxProgramTexelOffset", resources.MaxProgramTexelOffset); |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 485 | } |
| 486 | |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 487 | void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec, |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 488 | const ShBuiltInResources &resources, |
| 489 | TSymbolTable &symbolTable) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 490 | { |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 491 | // |
| 492 | // First, insert some special built-in variables that are not in |
| 493 | // the built-in header files. |
| 494 | // |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 495 | switch(type) { |
| 496 | case SH_FRAGMENT_SHADER: |
shannonwoods@chromium.org | 1c84809 | 2013-05-30 00:02:34 +0000 | [diff] [blame] | 497 | symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_FragCoord"), TType(EbtFloat, EbpMedium, EvqFragCoord, 4))); |
| 498 | symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool, EbpUndefined, EvqFrontFacing, 1))); |
| 499 | 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] | 500 | |
| 501 | // |
| 502 | // In CSS Shaders, gl_FragColor, gl_FragData, and gl_MaxDrawBuffers are not available. |
| 503 | // Instead, css_MixColor and css_ColorMatrix are available. |
| 504 | // |
| 505 | if (spec != SH_CSS_SHADERS_SPEC) { |
shannonwoods@chromium.org | 1c84809 | 2013-05-30 00:02:34 +0000 | [diff] [blame] | 506 | symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EbpMedium, EvqFragColor, 4))); |
| 507 | symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqFragData, 4))); |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 508 | } else { |
shannonwoods@chromium.org | 1c84809 | 2013-05-30 00:02:34 +0000 | [diff] [blame] | 509 | symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("css_MixColor"), TType(EbtFloat, EbpMedium, EvqGlobal, 4))); |
shannonwoods@chromium.org | 09e0988 | 2013-05-30 00:18:25 +0000 | [diff] [blame] | 510 | 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] | 511 | } |
| 512 | |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 513 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 514 | |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 515 | case SH_VERTEX_SHADER: |
shannonwoods@chromium.org | 1c84809 | 2013-05-30 00:02:34 +0000 | [diff] [blame] | 516 | symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EbpHigh, EvqPosition, 4))); |
| 517 | symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EbpMedium, EvqPointSize, 1))); |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 518 | break; |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 519 | |
| 520 | default: assert(false && "Language not supported"); |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 521 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 522 | |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 523 | // |
| 524 | // Next, identify which built-ins from the already loaded headers have |
| 525 | // a mapping to an operator. Those that are not identified as such are |
| 526 | // expected to be resolved through a library of functions, versus as |
| 527 | // operations. |
| 528 | // |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 529 | symbolTable.relateToOperator(COMMON_BUILTINS, "matrixCompMult", EOpMul); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 530 | |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 531 | symbolTable.relateToOperator(COMMON_BUILTINS, "equal", EOpVectorEqual); |
| 532 | symbolTable.relateToOperator(COMMON_BUILTINS, "notEqual", EOpVectorNotEqual); |
| 533 | symbolTable.relateToOperator(COMMON_BUILTINS, "lessThan", EOpLessThan); |
| 534 | symbolTable.relateToOperator(COMMON_BUILTINS, "greaterThan", EOpGreaterThan); |
| 535 | symbolTable.relateToOperator(COMMON_BUILTINS, "lessThanEqual", EOpLessThanEqual); |
| 536 | symbolTable.relateToOperator(COMMON_BUILTINS, "greaterThanEqual", EOpGreaterThanEqual); |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 537 | |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 538 | symbolTable.relateToOperator(COMMON_BUILTINS, "radians", EOpRadians); |
| 539 | symbolTable.relateToOperator(COMMON_BUILTINS, "degrees", EOpDegrees); |
| 540 | symbolTable.relateToOperator(COMMON_BUILTINS, "sin", EOpSin); |
| 541 | symbolTable.relateToOperator(COMMON_BUILTINS, "cos", EOpCos); |
| 542 | symbolTable.relateToOperator(COMMON_BUILTINS, "tan", EOpTan); |
| 543 | symbolTable.relateToOperator(COMMON_BUILTINS, "asin", EOpAsin); |
| 544 | symbolTable.relateToOperator(COMMON_BUILTINS, "acos", EOpAcos); |
| 545 | symbolTable.relateToOperator(COMMON_BUILTINS, "atan", EOpAtan); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 546 | |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 547 | symbolTable.relateToOperator(COMMON_BUILTINS, "pow", EOpPow); |
| 548 | symbolTable.relateToOperator(COMMON_BUILTINS, "exp2", EOpExp2); |
| 549 | symbolTable.relateToOperator(COMMON_BUILTINS, "log", EOpLog); |
| 550 | symbolTable.relateToOperator(COMMON_BUILTINS, "exp", EOpExp); |
| 551 | symbolTable.relateToOperator(COMMON_BUILTINS, "log2", EOpLog2); |
| 552 | symbolTable.relateToOperator(COMMON_BUILTINS, "sqrt", EOpSqrt); |
| 553 | symbolTable.relateToOperator(COMMON_BUILTINS, "inversesqrt", EOpInverseSqrt); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 554 | |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 555 | symbolTable.relateToOperator(COMMON_BUILTINS, "abs", EOpAbs); |
| 556 | symbolTable.relateToOperator(COMMON_BUILTINS, "sign", EOpSign); |
| 557 | symbolTable.relateToOperator(COMMON_BUILTINS, "floor", EOpFloor); |
| 558 | symbolTable.relateToOperator(COMMON_BUILTINS, "ceil", EOpCeil); |
| 559 | symbolTable.relateToOperator(COMMON_BUILTINS, "fract", EOpFract); |
| 560 | symbolTable.relateToOperator(COMMON_BUILTINS, "mod", EOpMod); |
| 561 | symbolTable.relateToOperator(COMMON_BUILTINS, "min", EOpMin); |
| 562 | symbolTable.relateToOperator(COMMON_BUILTINS, "max", EOpMax); |
| 563 | symbolTable.relateToOperator(COMMON_BUILTINS, "clamp", EOpClamp); |
| 564 | symbolTable.relateToOperator(COMMON_BUILTINS, "mix", EOpMix); |
| 565 | symbolTable.relateToOperator(COMMON_BUILTINS, "step", EOpStep); |
| 566 | symbolTable.relateToOperator(COMMON_BUILTINS, "smoothstep", EOpSmoothStep); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 567 | |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 568 | symbolTable.relateToOperator(COMMON_BUILTINS, "length", EOpLength); |
| 569 | symbolTable.relateToOperator(COMMON_BUILTINS, "distance", EOpDistance); |
| 570 | symbolTable.relateToOperator(COMMON_BUILTINS, "dot", EOpDot); |
| 571 | symbolTable.relateToOperator(COMMON_BUILTINS, "cross", EOpCross); |
| 572 | symbolTable.relateToOperator(COMMON_BUILTINS, "normalize", EOpNormalize); |
| 573 | symbolTable.relateToOperator(COMMON_BUILTINS, "faceforward", EOpFaceForward); |
| 574 | symbolTable.relateToOperator(COMMON_BUILTINS, "reflect", EOpReflect); |
| 575 | symbolTable.relateToOperator(COMMON_BUILTINS, "refract", EOpRefract); |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 576 | |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 577 | symbolTable.relateToOperator(COMMON_BUILTINS, "any", EOpAny); |
| 578 | symbolTable.relateToOperator(COMMON_BUILTINS, "all", EOpAll); |
| 579 | symbolTable.relateToOperator(COMMON_BUILTINS, "not", EOpVectorLogicalNot); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 580 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 581 | // Map language-specific operators. |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 582 | switch(type) { |
| 583 | case SH_VERTEX_SHADER: |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 584 | break; |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 585 | case SH_FRAGMENT_SHADER: |
alokp@chromium.org | 0609889 | 2010-08-26 19:36:42 +0000 | [diff] [blame] | 586 | if (resources.OES_standard_derivatives) { |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 587 | symbolTable.relateToOperator(ESSL1_BUILTINS, "dFdx", EOpDFdx); |
| 588 | symbolTable.relateToOperator(ESSL1_BUILTINS, "dFdy", EOpDFdy); |
| 589 | symbolTable.relateToOperator(ESSL1_BUILTINS, "fwidth", EOpFwidth); |
alokp@chromium.org | 8815d7f | 2010-09-09 17:30:03 +0000 | [diff] [blame] | 590 | |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 591 | symbolTable.relateToExtension(ESSL1_BUILTINS, "dFdx", "GL_OES_standard_derivatives"); |
| 592 | symbolTable.relateToExtension(ESSL1_BUILTINS, "dFdy", "GL_OES_standard_derivatives"); |
| 593 | symbolTable.relateToExtension(ESSL1_BUILTINS, "fwidth", "GL_OES_standard_derivatives"); |
alokp@chromium.org | 0609889 | 2010-08-26 19:36:42 +0000 | [diff] [blame] | 594 | } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 595 | break; |
| 596 | default: break; |
| 597 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 598 | |
Nicolas Capens | f4cb0e1 | 2013-06-24 16:11:36 -0400 | [diff] [blame^] | 599 | symbolTable.relateToOperator(ESSL3_BUILTINS, "dFdx", EOpDFdx); |
| 600 | symbolTable.relateToOperator(ESSL3_BUILTINS, "dFdy", EOpDFdy); |
| 601 | symbolTable.relateToOperator(ESSL3_BUILTINS, "fwidth", EOpFwidth); |
| 602 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 603 | // Finally add resource-specific variables. |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 604 | switch(type) { |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 605 | case SH_FRAGMENT_SHADER: |
| 606 | if (spec != SH_CSS_SHADERS_SPEC) { |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 607 | // Set up gl_FragData. The array size. |
shannonwoods@chromium.org | 09e0988 | 2013-05-30 00:18:25 +0000 | [diff] [blame] | 608 | TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true); |
alokp@chromium.org | 94a86ad | 2010-08-25 20:02:11 +0000 | [diff] [blame] | 609 | fragData.setArraySize(resources.MaxDrawBuffers); |
shannonwoods@chromium.org | 1c84809 | 2013-05-30 00:02:34 +0000 | [diff] [blame] | 610 | symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragData"), fragData)); |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 611 | } |
| 612 | break; |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 613 | default: break; |
| 614 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 615 | } |
| 616 | |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 617 | void InitExtensionBehavior(const ShBuiltInResources& resources, |
alokp@chromium.org | ad771eb | 2010-09-07 17:36:23 +0000 | [diff] [blame] | 618 | TExtensionBehavior& extBehavior) |
| 619 | { |
| 620 | if (resources.OES_standard_derivatives) |
zmo@google.com | 09c323a | 2011-08-12 18:22:25 +0000 | [diff] [blame] | 621 | extBehavior["GL_OES_standard_derivatives"] = EBhUndefined; |
| 622 | if (resources.OES_EGL_image_external) |
| 623 | extBehavior["GL_OES_EGL_image_external"] = EBhUndefined; |
kbr@chromium.org | 205fef3 | 2011-11-22 20:50:02 +0000 | [diff] [blame] | 624 | if (resources.ARB_texture_rectangle) |
| 625 | extBehavior["GL_ARB_texture_rectangle"] = EBhUndefined; |
shannon.woods@transgaming.com | 550cd09 | 2013-02-28 23:19:54 +0000 | [diff] [blame] | 626 | if (resources.EXT_draw_buffers) |
| 627 | extBehavior["GL_EXT_draw_buffers"] = EBhUndefined; |
alokp@chromium.org | ad771eb | 2010-09-07 17:36:23 +0000 | [diff] [blame] | 628 | } |