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 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 78 | // |
| 79 | // Exponential Functions. |
| 80 | // |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 81 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "pow", float1, float1); |
| 82 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "pow", float2, float2); |
| 83 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "pow", float3, float3); |
| 84 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "pow", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 85 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 86 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "exp", float1); |
| 87 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "exp", float2); |
| 88 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "exp", float3); |
| 89 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "exp", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 90 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 91 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "log", float1); |
| 92 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "log", float2); |
| 93 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "log", float3); |
| 94 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "log", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 95 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 96 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "exp2", float1); |
| 97 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "exp2", float2); |
| 98 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "exp2", float3); |
| 99 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "exp2", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 100 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 101 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "log2", float1); |
| 102 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "log2", float2); |
| 103 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "log2", float3); |
| 104 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "log2", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 105 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 106 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sqrt", float1); |
| 107 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sqrt", float2); |
| 108 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sqrt", float3); |
| 109 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sqrt", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 110 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 111 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "inversesqrt", float1); |
| 112 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "inversesqrt", float2); |
| 113 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "inversesqrt", float3); |
| 114 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "inversesqrt", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 115 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 116 | // |
| 117 | // Common Functions. |
| 118 | // |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 119 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "abs", float1); |
| 120 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "abs", float2); |
| 121 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "abs", float3); |
| 122 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "abs", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 123 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 124 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sign", float1); |
| 125 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sign", float2); |
| 126 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sign", float3); |
| 127 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sign", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 128 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 129 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "floor", float1); |
| 130 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "floor", float2); |
| 131 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "floor", float3); |
| 132 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "floor", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 133 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 134 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "ceil", float1); |
| 135 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "ceil", float2); |
| 136 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "ceil", float3); |
| 137 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "ceil", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 138 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 139 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "fract", float1); |
| 140 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "fract", float2); |
| 141 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "fract", float3); |
| 142 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "fract", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 143 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 144 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "mod", float1, float1); |
| 145 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mod", float2, float1); |
| 146 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mod", float3, float1); |
| 147 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mod", float4, float1); |
| 148 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mod", float2, float2); |
| 149 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mod", float3, float3); |
| 150 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mod", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 151 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 152 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "min", float1, float1); |
| 153 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "min", float2, float1); |
| 154 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "min", float3, float1); |
| 155 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "min", float4, float1); |
| 156 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "min", float2, float2); |
| 157 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "min", float3, float3); |
| 158 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "min", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 159 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 160 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "max", float1, float1); |
| 161 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "max", float2, float1); |
| 162 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "max", float3, float1); |
| 163 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "max", float4, float1); |
| 164 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "max", float2, float2); |
| 165 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "max", float3, float3); |
| 166 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "max", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 167 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 168 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "clamp", float1, float1, float1); |
| 169 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "clamp", float2, float1, float1); |
| 170 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "clamp", float3, float1, float1); |
| 171 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "clamp", float4, float1, float1); |
| 172 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "clamp", float2, float2, float2); |
| 173 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "clamp", float3, float3, float3); |
| 174 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "clamp", float4, float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 175 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 176 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "mix", float1, float1, float1); |
| 177 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mix", float2, float2, float1); |
| 178 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mix", float3, float3, float1); |
| 179 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mix", float4, float4, float1); |
| 180 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mix", float2, float2, float2); |
| 181 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mix", float3, float3, float3); |
| 182 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mix", float4, float4, 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, "step", float1, float1); |
| 185 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "step", float2, float2); |
| 186 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "step", float3, float3); |
| 187 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "step", float4, float4); |
| 188 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "step", float1, float2); |
| 189 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "step", float1, float3); |
| 190 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "step", float1, 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, "smoothstep", float1, float1, float1); |
| 193 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "smoothstep", float2, float2, float2); |
| 194 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "smoothstep", float3, float3, float3); |
| 195 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "smoothstep", float4, float4, float4); |
| 196 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "smoothstep", float1, float1, float2); |
| 197 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "smoothstep", float1, float1, float3); |
| 198 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "smoothstep", float1, float1, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 199 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 200 | // |
| 201 | // Geometric Functions. |
| 202 | // |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 203 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float1); |
| 204 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float2); |
| 205 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float3); |
| 206 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 207 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 208 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float1, float1); |
| 209 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float2, float2); |
| 210 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float3, float3); |
| 211 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 212 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 213 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float1, float1); |
| 214 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float2, float2); |
| 215 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float3, float3); |
| 216 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 217 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 218 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "cross", float3, float3); |
| 219 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "normalize", float1); |
| 220 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "normalize", float2); |
| 221 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "normalize", float3); |
| 222 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "normalize", float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 223 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 224 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "faceforward", float1, float1, float1); |
| 225 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "faceforward", float2, float2, float2); |
| 226 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "faceforward", float3, float3, float3); |
| 227 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "faceforward", float4, float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 228 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 229 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "reflect", float1, float1); |
| 230 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "reflect", float2, float2); |
| 231 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "reflect", float3, float3); |
| 232 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "reflect", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 233 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 234 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "refract", float1, float1, float1); |
| 235 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "refract", float2, float2, float1); |
| 236 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "refract", float3, float3, float1); |
| 237 | symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "refract", float4, float4, float1); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 238 | |
Nicolas Capens | c950884 | 2014-02-14 17:48:50 -0500 | [diff] [blame] | 239 | TType *mat2 = new TType(EbtFloat, 2, 2); |
| 240 | TType *mat3 = new TType(EbtFloat, 3, 3); |
| 241 | TType *mat4 = new TType(EbtFloat, 4, 4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 242 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 243 | // |
| 244 | // Matrix Functions. |
| 245 | // |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 246 | symbolTable.insertBuiltIn(COMMON_BUILTINS, mat2, "matrixCompMult", mat2, mat2); |
| 247 | symbolTable.insertBuiltIn(COMMON_BUILTINS, mat3, "matrixCompMult", mat3, mat3); |
| 248 | symbolTable.insertBuiltIn(COMMON_BUILTINS, mat4, "matrixCompMult", mat4, mat4); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 249 | |
Nicolas Capens | c950884 | 2014-02-14 17:48:50 -0500 | [diff] [blame] | 250 | TType *bool1 = new TType(EbtBool); |
| 251 | TType *bool2 = new TType(EbtBool, 2); |
| 252 | TType *bool3 = new TType(EbtBool, 3); |
| 253 | TType *bool4 = new TType(EbtBool, 4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 254 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 255 | // |
| 256 | // Vector relational functions. |
| 257 | // |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 258 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThan", float2, float2); |
| 259 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThan", float3, float3); |
| 260 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThan", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 261 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 262 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThan", int2, int2); |
| 263 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThan", int3, int3); |
| 264 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThan", int4, int4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 265 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 266 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThanEqual", float2, float2); |
| 267 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThanEqual", float3, float3); |
| 268 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThanEqual", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 269 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 270 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThanEqual", int2, int2); |
| 271 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThanEqual", int3, int3); |
| 272 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThanEqual", int4, int4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 273 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 274 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThan", float2, float2); |
| 275 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThan", float3, float3); |
| 276 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThan", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 277 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 278 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThan", int2, int2); |
| 279 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThan", int3, int3); |
| 280 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThan", int4, int4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 281 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 282 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThanEqual", float2, float2); |
| 283 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThanEqual", float3, float3); |
| 284 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThanEqual", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 285 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 286 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThanEqual", int2, int2); |
| 287 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThanEqual", int3, int3); |
| 288 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThanEqual", int4, int4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 289 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 290 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", float2, float2); |
| 291 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", float3, float3); |
| 292 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 293 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 294 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", int2, int2); |
| 295 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", int3, int3); |
| 296 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", int4, int4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 297 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 298 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", bool2, bool2); |
| 299 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", bool3, bool3); |
| 300 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", bool4, bool4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 301 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 302 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", float2, float2); |
| 303 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", float3, float3); |
| 304 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", float4, float4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 305 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 306 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", int2, int2); |
| 307 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", int3, int3); |
| 308 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", int4, int4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 309 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 310 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", bool2, bool2); |
| 311 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", bool3, bool3); |
| 312 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", bool4, bool4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 313 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 314 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool2); |
| 315 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool3); |
| 316 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 317 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 318 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool2); |
| 319 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool3); |
| 320 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 321 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 322 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "not", bool2); |
| 323 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "not", bool3); |
| 324 | symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "not", bool4); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 325 | |
Nicolas Capens | c950884 | 2014-02-14 17:48:50 -0500 | [diff] [blame] | 326 | TType *sampler2D = new TType(EbtSampler2D); |
| 327 | TType *samplerCube = new TType(EbtSamplerCube); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 328 | |
| 329 | // |
| 330 | // Texture Functions for GLSL ES 1.0 |
| 331 | // |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 332 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, float2); |
| 333 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float3); |
| 334 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float4); |
| 335 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, float3); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 336 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 337 | if (resources.OES_EGL_image_external) |
| 338 | { |
Nicolas Capens | c950884 | 2014-02-14 17:48:50 -0500 | [diff] [blame] | 339 | TType *samplerExternalOES = new TType(EbtSamplerExternalOES); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 340 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 341 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", samplerExternalOES, float2); |
| 342 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, float3); |
| 343 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, float4); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 344 | } |
| 345 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 346 | if (resources.ARB_texture_rectangle) |
| 347 | { |
Nicolas Capens | c950884 | 2014-02-14 17:48:50 -0500 | [diff] [blame] | 348 | TType *sampler2DRect = new TType(EbtSampler2DRect); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 349 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 350 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRect", sampler2DRect, float2); |
| 351 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect, float3); |
| 352 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect, float4); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 353 | } |
| 354 | |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 355 | if (resources.EXT_shader_texture_lod) |
| 356 | { |
| 357 | /* The *Grad* variants are new to both vertex and fragment shaders; the fragment |
| 358 | * shader specific pieces are added separately below. |
| 359 | */ |
| 360 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DGradEXT", sampler2D, float2, float2, float2); |
| 361 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjGradEXT", sampler2D, float3, float2, float2); |
| 362 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjGradEXT", sampler2D, float4, float2, float2); |
| 363 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeGradEXT", samplerCube, float3, float3, float3); |
| 364 | } |
| 365 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 366 | if (type == GL_FRAGMENT_SHADER) |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 367 | { |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 368 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, float2, float1); |
| 369 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float3, float1); |
| 370 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float4, float1); |
| 371 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, float3, float1); |
shannonwoods@chromium.org | 2ac0be9 | 2013-05-30 00:02:27 +0000 | [diff] [blame] | 372 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 373 | if (resources.OES_standard_derivatives) |
| 374 | { |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 375 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "dFdx", float1); |
| 376 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "dFdx", float2); |
| 377 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "dFdx", float3); |
| 378 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "dFdx", float4); |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 379 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 380 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "dFdy", float1); |
| 381 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "dFdy", float2); |
| 382 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "dFdy", float3); |
| 383 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "dFdy", float4); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 384 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 385 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "fwidth", float1); |
| 386 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "fwidth", float2); |
| 387 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "fwidth", float3); |
| 388 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "fwidth", float4); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 389 | } |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 390 | |
| 391 | if (resources.EXT_shader_texture_lod) |
| 392 | { |
| 393 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DLodEXT", sampler2D, float2, float1); |
| 394 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLodEXT", sampler2D, float3, float1); |
| 395 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLodEXT", sampler2D, float4, float1); |
| 396 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeLodEXT", samplerCube, float3, float1); |
| 397 | } |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 398 | } |
| 399 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 400 | if(type == GL_VERTEX_SHADER) |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 401 | { |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 402 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DLod", sampler2D, float2, float1); |
| 403 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, float3, float1); |
| 404 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, float4, float1); |
| 405 | symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeLod", samplerCube, float3, float1); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 406 | } |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 407 | |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 408 | TType *gvec4 = new TType(EbtGVec4); |
| 409 | |
| 410 | TType *gsampler2D = new TType(EbtGSampler2D); |
| 411 | TType *gsamplerCube = new TType(EbtGSamplerCube); |
| 412 | TType *gsampler3D = new TType(EbtGSampler3D); |
| 413 | TType *gsampler2DArray = new TType(EbtGSampler2DArray); |
Nicolas Capens | 73f5bf6 | 2013-06-17 16:13:33 -0400 | [diff] [blame] | 414 | |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 415 | // |
| 416 | // Texture Functions for GLSL ES 3.0 |
| 417 | // |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 418 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2D, float2); |
| 419 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler3D, float3); |
| 420 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsamplerCube, float3); |
| 421 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2DArray, float3); |
| 422 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float3); |
| 423 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float4); |
| 424 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler3D, float4); |
| 425 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler2D, float2, float1); |
| 426 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler3D, float3, float1); |
| 427 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsamplerCube, float3, float1); |
| 428 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler2DArray, float3, float1); |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 429 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 430 | if (type == GL_FRAGMENT_SHADER) |
Nicolas Capens | 67a819f | 2013-07-09 12:08:58 -0400 | [diff] [blame] | 431 | { |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 432 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2D, float2, float1); |
| 433 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler3D, float3, float1); |
| 434 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsamplerCube, float3, float1); |
| 435 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2DArray, float3, float1); |
| 436 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float3, float1); |
| 437 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float4, float1); |
| 438 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler3D, float4, float1); |
Nicolas Capens | 67a819f | 2013-07-09 12:08:58 -0400 | [diff] [blame] | 439 | } |
| 440 | |
Nicolas Capens | c950884 | 2014-02-14 17:48:50 -0500 | [diff] [blame] | 441 | TType *sampler2DShadow = new TType(EbtSampler2DShadow); |
| 442 | TType *samplerCubeShadow = new TType(EbtSamplerCubeShadow); |
| 443 | TType *sampler2DArrayShadow = new TType(EbtSampler2DArrayShadow); |
Nicolas Capens | 77c9d1a | 2013-07-11 11:10:34 -0400 | [diff] [blame] | 444 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 445 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DShadow, float3); |
| 446 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", samplerCubeShadow, float4); |
| 447 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DArrayShadow, float4); |
| 448 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProj", sampler2DShadow, float4); |
Jamie Madill | 16a1c07 | 2013-10-22 15:42:15 -0400 | [diff] [blame] | 449 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureLod", sampler2DShadow, float3, float1); |
Nicolas Capens | 77c9d1a | 2013-07-11 11:10:34 -0400 | [diff] [blame] | 450 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 451 | if (type == GL_FRAGMENT_SHADER) |
Nicolas Capens | 77c9d1a | 2013-07-11 11:10:34 -0400 | [diff] [blame] | 452 | { |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 453 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DShadow, float3, float1); |
| 454 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", samplerCubeShadow, float4, float1); |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 455 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProj", sampler2DShadow, float4, float1); |
Nicolas Capens | 77c9d1a | 2013-07-11 11:10:34 -0400 | [diff] [blame] | 456 | } |
| 457 | |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 458 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", gsampler2D, int1); |
| 459 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", gsampler3D, int1); |
| 460 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", gsamplerCube, int1); |
| 461 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", gsampler2DArray, int1); |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 462 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", sampler2DShadow, int1); |
| 463 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", samplerCubeShadow, int1); |
| 464 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", sampler2DArrayShadow, int1); |
Nicolas Capens | 75fb475 | 2013-07-10 15:14:47 -0400 | [diff] [blame] | 465 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 466 | if(type == GL_FRAGMENT_SHADER) |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 467 | { |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 468 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "dFdx", float1); |
| 469 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "dFdx", float2); |
| 470 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "dFdx", float3); |
| 471 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "dFdx", float4); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 472 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 473 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "dFdy", float1); |
| 474 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "dFdy", float2); |
| 475 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "dFdy", float3); |
| 476 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "dFdy", float4); |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 477 | |
Nicolas Capens | 8f80e02 | 2013-07-11 11:20:50 -0400 | [diff] [blame] | 478 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "fwidth", float1); |
| 479 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "fwidth", float2); |
| 480 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "fwidth", float3); |
| 481 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "fwidth", float4); |
alokp@chromium.org | 0609889 | 2010-08-26 19:36:42 +0000 | [diff] [blame] | 482 | } |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 483 | |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 484 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2); |
| 485 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler3D, float3, int3); |
| 486 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureOffset", sampler2DShadow, float3, int2); |
| 487 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2DArray, float3, int2); |
| 488 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 489 | if(type == GL_FRAGMENT_SHADER) |
Nicolas Capens | 4fd5e4a | 2014-02-14 18:17:15 -0500 | [diff] [blame] | 490 | { |
| 491 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2, float1); |
| 492 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler3D, float3, int3, float1); |
| 493 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureOffset", sampler2DShadow, float3, int2, float1); |
| 494 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2DArray, float3, int2, float1); |
| 495 | } |
Nicolas Capens | 1fbc287 | 2014-01-03 14:12:09 -0500 | [diff] [blame] | 496 | |
Nicolas Capens | df86c6b | 2014-02-14 20:09:17 -0500 | [diff] [blame] | 497 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float3, int2); |
| 498 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float4, int2); |
| 499 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler3D, float4, int3); |
| 500 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjOffset", sampler2DShadow, float4, int2); |
| 501 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 502 | if(type == GL_FRAGMENT_SHADER) |
Nicolas Capens | df86c6b | 2014-02-14 20:09:17 -0500 | [diff] [blame] | 503 | { |
| 504 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float3, int2, float1); |
| 505 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float4, int2, float1); |
| 506 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler3D, float4, int3, float1); |
| 507 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjOffset", sampler2DShadow, float4, int2, float1); |
| 508 | } |
| 509 | |
| 510 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler2D, float2, float1, int2); |
| 511 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler3D, float3, float1, int3); |
| 512 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureLodOffset", sampler2DShadow, float3, float1, int2); |
| 513 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler2DArray, float3, float1, int2); |
| 514 | |
Nicolas Capens | 2adc256 | 2014-02-14 23:50:59 -0500 | [diff] [blame] | 515 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler2D, float3, float1); |
| 516 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler2D, float4, float1); |
| 517 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler3D, float4, float1); |
| 518 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjLod", sampler2DShadow, float4, float1); |
| 519 | |
| 520 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler2D, float3, float1, int2); |
| 521 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler2D, float4, float1, int2); |
| 522 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler3D, float4, float1, int3); |
| 523 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjLodOffset", sampler2DShadow, float4, float1, int2); |
| 524 | |
Nicolas Capens | fc01454 | 2014-02-18 14:47:13 -0500 | [diff] [blame] | 525 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler2D, int2, int1); |
| 526 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler3D, int3, int1); |
| 527 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler2DArray, int3, int1); |
| 528 | |
| 529 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler2D, int2, int1, int2); |
| 530 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler3D, int3, int1, int3); |
| 531 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler2DArray, int3, int1, int2); |
| 532 | |
Nicolas Capens | d11d549 | 2014-02-19 17:06:10 -0500 | [diff] [blame] | 533 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler2D, float2, float2, float2); |
| 534 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler3D, float3, float3, float3); |
| 535 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsamplerCube, float3, float3, float3); |
| 536 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", sampler2DShadow, float3, float2, float2); |
| 537 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", samplerCubeShadow, float4, float3, float3); |
| 538 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler2DArray, float3, float2, float2); |
| 539 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", sampler2DArrayShadow, float4, float2, float2); |
| 540 | |
Nicolas Capens | bf7db10 | 2014-02-19 17:20:28 -0500 | [diff] [blame] | 541 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler2D, float2, float2, float2, int2); |
| 542 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler3D, float3, float3, float3, int3); |
| 543 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGradOffset", sampler2DShadow, float3, float2, float2, int2); |
| 544 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler2DArray, float3, float2, float2, int2); |
| 545 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGradOffset", sampler2DArrayShadow, float4, float2, float2, int2); |
| 546 | |
Nicolas Capens | f7378e3 | 2014-02-19 17:29:32 -0500 | [diff] [blame] | 547 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler2D, float3, float2, float2); |
| 548 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler2D, float4, float2, float2); |
| 549 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler3D, float4, float3, float3); |
| 550 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjGrad", sampler2DShadow, float4, float2, float2); |
| 551 | |
| 552 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler2D, float3, float2, float2, int2); |
| 553 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler2D, float4, float2, float2, int2); |
| 554 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler3D, float4, float3, float3, int3); |
| 555 | symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjGradOffset", sampler2DShadow, float4, float2, float2, int2); |
| 556 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 557 | // |
| 558 | // Depth range in window coordinates |
| 559 | // |
Jamie Madill | 98493dd | 2013-07-08 14:39:03 -0400 | [diff] [blame] | 560 | TFieldList *fields = NewPoolTFieldList(); |
Jamie Madill | 37f77d2 | 2014-04-30 16:10:13 -0400 | [diff] [blame] | 561 | TSourceLoc zeroSourceLoc = {0, 0, 0, 0}; |
Jamie Madill | 98493dd | 2013-07-08 14:39:03 -0400 | [diff] [blame] | 562 | TField *near = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("near"), zeroSourceLoc); |
| 563 | TField *far = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("far"), zeroSourceLoc); |
| 564 | TField *diff = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("diff"), zeroSourceLoc); |
| 565 | fields->push_back(near); |
| 566 | fields->push_back(far); |
| 567 | fields->push_back(diff); |
| 568 | TStructure *depthRangeStruct = new TStructure(NewPoolTString("gl_DepthRangeParameters"), fields); |
| 569 | TVariable *depthRangeParameters = new TVariable(&depthRangeStruct->name(), depthRangeStruct, true); |
Nicolas Capens | adfffe4 | 2014-06-17 02:13:36 -0400 | [diff] [blame] | 570 | symbolTable.insert(COMMON_BUILTINS, depthRangeParameters); |
Jamie Madill | 98493dd | 2013-07-08 14:39:03 -0400 | [diff] [blame] | 571 | TVariable *depthRange = new TVariable(NewPoolTString("gl_DepthRange"), TType(depthRangeStruct)); |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 572 | depthRange->setQualifier(EvqUniform); |
Nicolas Capens | adfffe4 | 2014-06-17 02:13:36 -0400 | [diff] [blame] | 573 | symbolTable.insert(COMMON_BUILTINS, depthRange); |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 574 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 575 | // |
| 576 | // Implementation dependent built-in constants. |
| 577 | // |
| 578 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexAttribs", resources.MaxVertexAttribs); |
| 579 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexUniformVectors", resources.MaxVertexUniformVectors); |
| 580 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexTextureImageUnits", resources.MaxVertexTextureImageUnits); |
| 581 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxCombinedTextureImageUnits", resources.MaxCombinedTextureImageUnits); |
| 582 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxTextureImageUnits", resources.MaxTextureImageUnits); |
| 583 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxFragmentUniformVectors", resources.MaxFragmentUniformVectors); |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 584 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 585 | symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxVaryingVectors", resources.MaxVaryingVectors); |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 586 | |
| 587 | if (spec != SH_CSS_SHADERS_SPEC) |
shannon.woods%transgaming.com@gtempaccount.com | 5209de8 | 2013-04-13 03:41:53 +0000 | [diff] [blame] | 588 | { |
Jamie Madill | 455a6f5 | 2013-10-17 10:45:46 -0400 | [diff] [blame] | 589 | symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxDrawBuffers", resources.MaxDrawBuffers); |
shannon.woods%transgaming.com@gtempaccount.com | 5209de8 | 2013-04-13 03:41:53 +0000 | [diff] [blame] | 590 | } |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 591 | |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 592 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxVertexOutputVectors", resources.MaxVertexOutputVectors); |
| 593 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxFragmentInputVectors", resources.MaxFragmentInputVectors); |
| 594 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MinProgramTexelOffset", resources.MinProgramTexelOffset); |
| 595 | symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxProgramTexelOffset", resources.MaxProgramTexelOffset); |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 596 | } |
| 597 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 598 | void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec, |
Nicolas Capens | 49a8887 | 2013-06-20 09:54:03 -0400 | [diff] [blame] | 599 | const ShBuiltInResources &resources, |
| 600 | TSymbolTable &symbolTable) |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 601 | { |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 602 | // |
| 603 | // First, insert some special built-in variables that are not in |
| 604 | // the built-in header files. |
| 605 | // |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 606 | switch(type) { |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 607 | case GL_FRAGMENT_SHADER: |
Nicolas Capens | adfffe4 | 2014-06-17 02:13:36 -0400 | [diff] [blame] | 608 | symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FragCoord"), TType(EbtFloat, EbpMedium, EvqFragCoord, 4))); |
| 609 | symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool, EbpUndefined, EvqFrontFacing, 1))); |
| 610 | 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] | 611 | |
| 612 | // |
| 613 | // In CSS Shaders, gl_FragColor, gl_FragData, and gl_MaxDrawBuffers are not available. |
| 614 | // Instead, css_MixColor and css_ColorMatrix are available. |
| 615 | // |
| 616 | if (spec != SH_CSS_SHADERS_SPEC) { |
Nicolas Capens | adfffe4 | 2014-06-17 02:13:36 -0400 | [diff] [blame] | 617 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EbpMedium, EvqFragColor, 4))); |
| 618 | 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] | 619 | if (resources.EXT_frag_depth) { |
Nicolas Capens | adfffe4 | 2014-06-17 02:13:36 -0400 | [diff] [blame] | 620 | 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] | 621 | symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_FragDepthEXT", "GL_EXT_frag_depth"); |
| 622 | } |
Erik Dahlström | ea7a212 | 2014-11-17 16:15:57 +0100 | [diff] [blame] | 623 | if (resources.EXT_shader_framebuffer_fetch) |
| 624 | { |
| 625 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqLastFragData, 4))); |
| 626 | } |
| 627 | else if (resources.NV_shader_framebuffer_fetch) |
| 628 | { |
| 629 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragColor"), TType(EbtFloat, EbpMedium, EvqLastFragColor, 4))); |
| 630 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqLastFragData, 4))); |
| 631 | } |
| 632 | else if (resources.ARM_shader_framebuffer_fetch) |
| 633 | { |
| 634 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragColorARM"), TType(EbtFloat, EbpMedium, EvqLastFragColor, 4))); |
| 635 | } |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 636 | } else { |
Nicolas Capens | adfffe4 | 2014-06-17 02:13:36 -0400 | [diff] [blame] | 637 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("css_MixColor"), TType(EbtFloat, EbpMedium, EvqGlobal, 4))); |
| 638 | 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] | 639 | } |
| 640 | |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 641 | break; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 642 | |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 643 | case GL_VERTEX_SHADER: |
Nicolas Capens | adfffe4 | 2014-06-17 02:13:36 -0400 | [diff] [blame] | 644 | symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EbpHigh, EvqPosition, 4))); |
| 645 | 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] | 646 | break; |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 647 | |
| 648 | default: assert(false && "Language not supported"); |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 649 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 650 | |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 651 | // |
| 652 | // Next, identify which built-ins from the already loaded headers have |
| 653 | // a mapping to an operator. Those that are not identified as such are |
| 654 | // expected to be resolved through a library of functions, versus as |
| 655 | // operations. |
| 656 | // |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 657 | symbolTable.relateToOperator(COMMON_BUILTINS, "matrixCompMult", EOpMul); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 658 | |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 659 | symbolTable.relateToOperator(COMMON_BUILTINS, "equal", EOpVectorEqual); |
| 660 | symbolTable.relateToOperator(COMMON_BUILTINS, "notEqual", EOpVectorNotEqual); |
| 661 | symbolTable.relateToOperator(COMMON_BUILTINS, "lessThan", EOpLessThan); |
| 662 | symbolTable.relateToOperator(COMMON_BUILTINS, "greaterThan", EOpGreaterThan); |
| 663 | symbolTable.relateToOperator(COMMON_BUILTINS, "lessThanEqual", EOpLessThanEqual); |
| 664 | symbolTable.relateToOperator(COMMON_BUILTINS, "greaterThanEqual", EOpGreaterThanEqual); |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 665 | |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 666 | symbolTable.relateToOperator(COMMON_BUILTINS, "radians", EOpRadians); |
| 667 | symbolTable.relateToOperator(COMMON_BUILTINS, "degrees", EOpDegrees); |
| 668 | symbolTable.relateToOperator(COMMON_BUILTINS, "sin", EOpSin); |
| 669 | symbolTable.relateToOperator(COMMON_BUILTINS, "cos", EOpCos); |
| 670 | symbolTable.relateToOperator(COMMON_BUILTINS, "tan", EOpTan); |
| 671 | symbolTable.relateToOperator(COMMON_BUILTINS, "asin", EOpAsin); |
| 672 | symbolTable.relateToOperator(COMMON_BUILTINS, "acos", EOpAcos); |
| 673 | symbolTable.relateToOperator(COMMON_BUILTINS, "atan", EOpAtan); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 674 | |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 675 | symbolTable.relateToOperator(COMMON_BUILTINS, "pow", EOpPow); |
| 676 | symbolTable.relateToOperator(COMMON_BUILTINS, "exp2", EOpExp2); |
| 677 | symbolTable.relateToOperator(COMMON_BUILTINS, "log", EOpLog); |
| 678 | symbolTable.relateToOperator(COMMON_BUILTINS, "exp", EOpExp); |
| 679 | symbolTable.relateToOperator(COMMON_BUILTINS, "log2", EOpLog2); |
| 680 | symbolTable.relateToOperator(COMMON_BUILTINS, "sqrt", EOpSqrt); |
| 681 | symbolTable.relateToOperator(COMMON_BUILTINS, "inversesqrt", EOpInverseSqrt); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 682 | |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 683 | symbolTable.relateToOperator(COMMON_BUILTINS, "abs", EOpAbs); |
| 684 | symbolTable.relateToOperator(COMMON_BUILTINS, "sign", EOpSign); |
| 685 | symbolTable.relateToOperator(COMMON_BUILTINS, "floor", EOpFloor); |
| 686 | symbolTable.relateToOperator(COMMON_BUILTINS, "ceil", EOpCeil); |
| 687 | symbolTable.relateToOperator(COMMON_BUILTINS, "fract", EOpFract); |
| 688 | symbolTable.relateToOperator(COMMON_BUILTINS, "mod", EOpMod); |
| 689 | symbolTable.relateToOperator(COMMON_BUILTINS, "min", EOpMin); |
| 690 | symbolTable.relateToOperator(COMMON_BUILTINS, "max", EOpMax); |
| 691 | symbolTable.relateToOperator(COMMON_BUILTINS, "clamp", EOpClamp); |
| 692 | symbolTable.relateToOperator(COMMON_BUILTINS, "mix", EOpMix); |
| 693 | symbolTable.relateToOperator(COMMON_BUILTINS, "step", EOpStep); |
| 694 | symbolTable.relateToOperator(COMMON_BUILTINS, "smoothstep", EOpSmoothStep); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 695 | |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 696 | symbolTable.relateToOperator(COMMON_BUILTINS, "length", EOpLength); |
| 697 | symbolTable.relateToOperator(COMMON_BUILTINS, "distance", EOpDistance); |
| 698 | symbolTable.relateToOperator(COMMON_BUILTINS, "dot", EOpDot); |
| 699 | symbolTable.relateToOperator(COMMON_BUILTINS, "cross", EOpCross); |
| 700 | symbolTable.relateToOperator(COMMON_BUILTINS, "normalize", EOpNormalize); |
| 701 | symbolTable.relateToOperator(COMMON_BUILTINS, "faceforward", EOpFaceForward); |
| 702 | symbolTable.relateToOperator(COMMON_BUILTINS, "reflect", EOpReflect); |
| 703 | symbolTable.relateToOperator(COMMON_BUILTINS, "refract", EOpRefract); |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 704 | |
shannonwoods@chromium.org | 89992b5 | 2013-05-30 00:02:20 +0000 | [diff] [blame] | 705 | symbolTable.relateToOperator(COMMON_BUILTINS, "any", EOpAny); |
| 706 | symbolTable.relateToOperator(COMMON_BUILTINS, "all", EOpAll); |
| 707 | symbolTable.relateToOperator(COMMON_BUILTINS, "not", EOpVectorLogicalNot); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 708 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 709 | // Map language-specific operators. |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 710 | switch(type) { |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 711 | case GL_VERTEX_SHADER: |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 712 | break; |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 713 | case GL_FRAGMENT_SHADER: |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 714 | if (resources.OES_standard_derivatives) |
| 715 | { |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 716 | symbolTable.relateToOperator(ESSL1_BUILTINS, "dFdx", EOpDFdx); |
| 717 | symbolTable.relateToOperator(ESSL1_BUILTINS, "dFdy", EOpDFdy); |
| 718 | symbolTable.relateToOperator(ESSL1_BUILTINS, "fwidth", EOpFwidth); |
alokp@chromium.org | 8815d7f | 2010-09-09 17:30:03 +0000 | [diff] [blame] | 719 | |
shannonwoods@chromium.org | c6ac65f | 2013-05-30 00:02:50 +0000 | [diff] [blame] | 720 | symbolTable.relateToExtension(ESSL1_BUILTINS, "dFdx", "GL_OES_standard_derivatives"); |
| 721 | symbolTable.relateToExtension(ESSL1_BUILTINS, "dFdy", "GL_OES_standard_derivatives"); |
| 722 | symbolTable.relateToExtension(ESSL1_BUILTINS, "fwidth", "GL_OES_standard_derivatives"); |
alokp@chromium.org | 0609889 | 2010-08-26 19:36:42 +0000 | [diff] [blame] | 723 | } |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 724 | if (resources.EXT_shader_texture_lod) |
| 725 | { |
| 726 | symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DLodEXT", "GL_EXT_shader_texture_lod"); |
| 727 | symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DProjLodEXT", "GL_EXT_shader_texture_lod"); |
| 728 | symbolTable.relateToExtension(ESSL1_BUILTINS, "textureCubeLodEXT", "GL_EXT_shader_texture_lod"); |
| 729 | } |
Erik Dahlström | ea7a212 | 2014-11-17 16:15:57 +0100 | [diff] [blame] | 730 | if (resources.NV_shader_framebuffer_fetch) |
| 731 | { |
| 732 | symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_LastFragColor", "GL_NV_shader_framebuffer_fetch"); |
| 733 | } |
| 734 | else if (resources.ARM_shader_framebuffer_fetch) |
| 735 | { |
| 736 | symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_LastFragColorARM", "GL_ARM_shader_framebuffer_fetch"); |
| 737 | } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 738 | break; |
| 739 | default: break; |
| 740 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 741 | |
Nicolas Capens | f4cb0e1 | 2013-06-24 16:11:36 -0400 | [diff] [blame] | 742 | symbolTable.relateToOperator(ESSL3_BUILTINS, "dFdx", EOpDFdx); |
| 743 | symbolTable.relateToOperator(ESSL3_BUILTINS, "dFdy", EOpDFdy); |
| 744 | symbolTable.relateToOperator(ESSL3_BUILTINS, "fwidth", EOpFwidth); |
| 745 | |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 746 | if (resources.EXT_shader_texture_lod) |
| 747 | { |
| 748 | symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DGradEXT", "GL_EXT_shader_texture_lod"); |
| 749 | symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DProjGradEXT", "GL_EXT_shader_texture_lod"); |
| 750 | symbolTable.relateToExtension(ESSL1_BUILTINS, "textureCubeGradEXT", "GL_EXT_shader_texture_lod"); |
| 751 | } |
| 752 | |
alokp@chromium.org | e4249f0 | 2010-07-26 18:13:52 +0000 | [diff] [blame] | 753 | // Finally add resource-specific variables. |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 754 | switch(type) { |
Jamie Madill | 183bde5 | 2014-07-02 15:31:19 -0400 | [diff] [blame] | 755 | case GL_FRAGMENT_SHADER: |
maxvujovic@gmail.com | 430f5e0 | 2012-06-08 17:47:59 +0000 | [diff] [blame] | 756 | if (spec != SH_CSS_SHADERS_SPEC) { |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 757 | // Set up gl_FragData. The array size. |
shannonwoods@chromium.org | 09e0988 | 2013-05-30 00:18:25 +0000 | [diff] [blame] | 758 | TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true); |
alokp@chromium.org | 94a86ad | 2010-08-25 20:02:11 +0000 | [diff] [blame] | 759 | fragData.setArraySize(resources.MaxDrawBuffers); |
Nicolas Capens | adfffe4 | 2014-06-17 02:13:36 -0400 | [diff] [blame] | 760 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData"), fragData)); |
Erik Dahlström | ea7a212 | 2014-11-17 16:15:57 +0100 | [diff] [blame] | 761 | |
| 762 | if (resources.EXT_shader_framebuffer_fetch || resources.NV_shader_framebuffer_fetch) { |
| 763 | // Set up gl_LastFragData. The array size. |
| 764 | TType lastFragData(EbtFloat, EbpMedium, EvqLastFragData, 4, 1, true); |
| 765 | lastFragData.setArraySize(resources.MaxDrawBuffers); |
| 766 | symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragData"), lastFragData)); |
| 767 | |
| 768 | if (resources.EXT_shader_framebuffer_fetch) |
| 769 | { |
| 770 | symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_LastFragData", "GL_EXT_shader_framebuffer_fetch"); |
| 771 | } |
| 772 | else if (resources.NV_shader_framebuffer_fetch) |
| 773 | { |
| 774 | symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_LastFragData", "GL_NV_shader_framebuffer_fetch"); |
| 775 | } |
| 776 | } |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 777 | } |
| 778 | break; |
daniel@transgaming.com | 0578f81 | 2010-05-17 09:58:39 +0000 | [diff] [blame] | 779 | default: break; |
| 780 | } |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 781 | } |
| 782 | |
alokp@chromium.org | 4888ceb | 2010-10-01 21:13:12 +0000 | [diff] [blame] | 783 | void InitExtensionBehavior(const ShBuiltInResources& resources, |
alokp@chromium.org | ad771eb | 2010-09-07 17:36:23 +0000 | [diff] [blame] | 784 | TExtensionBehavior& extBehavior) |
| 785 | { |
| 786 | if (resources.OES_standard_derivatives) |
zmo@google.com | 09c323a | 2011-08-12 18:22:25 +0000 | [diff] [blame] | 787 | extBehavior["GL_OES_standard_derivatives"] = EBhUndefined; |
| 788 | if (resources.OES_EGL_image_external) |
| 789 | extBehavior["GL_OES_EGL_image_external"] = EBhUndefined; |
kbr@chromium.org | 205fef3 | 2011-11-22 20:50:02 +0000 | [diff] [blame] | 790 | if (resources.ARB_texture_rectangle) |
| 791 | extBehavior["GL_ARB_texture_rectangle"] = EBhUndefined; |
shannon.woods@transgaming.com | 550cd09 | 2013-02-28 23:19:54 +0000 | [diff] [blame] | 792 | if (resources.EXT_draw_buffers) |
| 793 | extBehavior["GL_EXT_draw_buffers"] = EBhUndefined; |
Jamie Madill | 2aeb26a | 2013-07-08 14:02:55 -0400 | [diff] [blame] | 794 | if (resources.EXT_frag_depth) |
| 795 | extBehavior["GL_EXT_frag_depth"] = EBhUndefined; |
Nicolas Capens | 4648508 | 2014-04-15 13:12:50 -0400 | [diff] [blame] | 796 | if (resources.EXT_shader_texture_lod) |
| 797 | extBehavior["GL_EXT_shader_texture_lod"] = EBhUndefined; |
Erik Dahlström | ea7a212 | 2014-11-17 16:15:57 +0100 | [diff] [blame] | 798 | if (resources.EXT_shader_framebuffer_fetch) |
| 799 | extBehavior["GL_EXT_shader_framebuffer_fetch"] = EBhUndefined; |
| 800 | if (resources.NV_shader_framebuffer_fetch) |
| 801 | extBehavior["GL_NV_shader_framebuffer_fetch"] = EBhUndefined; |
| 802 | if (resources.ARM_shader_framebuffer_fetch) |
| 803 | extBehavior["GL_ARM_shader_framebuffer_fetch"] = EBhUndefined; |
alokp@chromium.org | ad771eb | 2010-09-07 17:36:23 +0000 | [diff] [blame] | 804 | } |