blob: 8300be64958f5c2ca73baa3b4d731e04e2bbdaf8 [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
Nicolas Capens1fbc2872014-01-03 14:12:09 -05002// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003// 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 Capens4fd5e4a2014-02-14 18:17:15 -05008// Create symbols that declare built-in definitions, add built-ins that
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00009// cannot be expressed in the files, and establish mappings between
10// built-in functions and operators.
11//
12
Geoff Lang17732822013-08-29 13:46:49 -040013#include "compiler/translator/Initialize.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000014
Jamie Madillb1a85f42014-08-19 15:23:24 -040015#include "compiler/translator/IntermNode.h"
Jamie Madill183bde52014-07-02 15:31:19 -040016#include "angle_gl.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000017
Jamie Madill183bde52014-07-02 15:31:19 -040018void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInResources &resources, TSymbolTable &symbolTable)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000019{
Nicolas Capensc9508842014-02-14 17:48:50 -050020 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 Capens49a88872013-06-20 09:54:03 -040024
Nicolas Capensc9508842014-02-14 17:48:50 -050025 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.orge4249f02010-07-26 18:13:52 +000029
daniel@transgaming.com0578f812010-05-17 09:58:39 +000030 //
alokp@chromium.orge4249f02010-07-26 18:13:52 +000031 // Angle and Trigonometric Functions.
daniel@transgaming.com0578f812010-05-17 09:58:39 +000032 //
Nicolas Capens8f80e022013-07-11 11:20:50 -040033 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.com4f39fd92010-03-08 20:26:45 +000037
Nicolas Capens8f80e022013-07-11 11:20:50 -040038 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.com4f39fd92010-03-08 20:26:45 +000042
Nicolas Capens8f80e022013-07-11 11:20:50 -040043 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.com4f39fd92010-03-08 20:26:45 +000047
Nicolas Capens8f80e022013-07-11 11:20:50 -040048 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.com4f39fd92010-03-08 20:26:45 +000052
Nicolas Capens8f80e022013-07-11 11:20:50 -040053 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.com4f39fd92010-03-08 20:26:45 +000057
Nicolas Capens8f80e022013-07-11 11:20:50 -040058 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.com4f39fd92010-03-08 20:26:45 +000062
Nicolas Capens8f80e022013-07-11 11:20:50 -040063 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.com4f39fd92010-03-08 20:26:45 +000067
Nicolas Capens8f80e022013-07-11 11:20:50 -040068 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.com4f39fd92010-03-08 20:26:45 +000072
Nicolas Capens8f80e022013-07-11 11:20:50 -040073 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.com4f39fd92010-03-08 20:26:45 +000077
Olli Etuaho5c9cd3d2014-12-18 13:04:25 +020078 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "sinh", float1);
79 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "sinh", float2);
80 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "sinh", float3);
81 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "sinh", float4);
82
83 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "cosh", float1);
84 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "cosh", float2);
85 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "cosh", float3);
86 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "cosh", float4);
87
88 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "tanh", float1);
89 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "tanh", float2);
90 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "tanh", float3);
91 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "tanh", float4);
92
93 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "asinh", float1);
94 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "asinh", float2);
95 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "asinh", float3);
96 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "asinh", float4);
97
98 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "acosh", float1);
99 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "acosh", float2);
100 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "acosh", float3);
101 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "acosh", float4);
102
103 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "atanh", float1);
104 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "atanh", float2);
105 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "atanh", float3);
106 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "atanh", float4);
107
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000108 //
109 // Exponential Functions.
110 //
Nicolas Capens8f80e022013-07-11 11:20:50 -0400111 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "pow", float1, float1);
112 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "pow", float2, float2);
113 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "pow", float3, float3);
114 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "pow", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000115
Nicolas Capens8f80e022013-07-11 11:20:50 -0400116 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "exp", float1);
117 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "exp", float2);
118 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "exp", float3);
119 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "exp", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000120
Nicolas Capens8f80e022013-07-11 11:20:50 -0400121 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "log", float1);
122 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "log", float2);
123 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "log", float3);
124 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "log", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000125
Nicolas Capens8f80e022013-07-11 11:20:50 -0400126 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "exp2", float1);
127 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "exp2", float2);
128 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "exp2", float3);
129 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "exp2", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000130
Nicolas Capens8f80e022013-07-11 11:20:50 -0400131 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "log2", float1);
132 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "log2", float2);
133 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "log2", float3);
134 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "log2", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000135
Nicolas Capens8f80e022013-07-11 11:20:50 -0400136 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sqrt", float1);
137 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sqrt", float2);
138 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sqrt", float3);
139 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sqrt", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000140
Nicolas Capens8f80e022013-07-11 11:20:50 -0400141 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "inversesqrt", float1);
142 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "inversesqrt", float2);
143 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "inversesqrt", float3);
144 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "inversesqrt", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000145
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000146 //
147 // Common Functions.
148 //
Nicolas Capens8f80e022013-07-11 11:20:50 -0400149 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "abs", float1);
150 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "abs", float2);
151 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "abs", float3);
152 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "abs", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000153
Nicolas Capens8f80e022013-07-11 11:20:50 -0400154 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sign", float1);
155 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sign", float2);
156 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sign", float3);
157 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sign", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000158
Nicolas Capens8f80e022013-07-11 11:20:50 -0400159 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "floor", float1);
160 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "floor", float2);
161 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "floor", float3);
162 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "floor", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000163
Nicolas Capens8f80e022013-07-11 11:20:50 -0400164 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "ceil", float1);
165 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "ceil", float2);
166 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "ceil", float3);
167 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "ceil", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000168
Nicolas Capens8f80e022013-07-11 11:20:50 -0400169 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "fract", float1);
170 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "fract", float2);
171 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "fract", float3);
172 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "fract", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000173
Nicolas Capens8f80e022013-07-11 11:20:50 -0400174 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "mod", float1, float1);
175 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mod", float2, float1);
176 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mod", float3, float1);
177 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mod", float4, float1);
178 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mod", float2, float2);
179 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mod", float3, float3);
180 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mod", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000181
Nicolas Capens8f80e022013-07-11 11:20:50 -0400182 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "min", float1, float1);
183 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "min", float2, float1);
184 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "min", float3, float1);
185 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "min", float4, float1);
186 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "min", float2, float2);
187 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "min", float3, float3);
188 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "min", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000189
Arun Patole42077bb2015-02-16 15:32:37 +0530190 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "min", int1, int1);
191 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "min", int2, int2);
192 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "min", int3, int3);
193 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "min", int4, int4);
194 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "min", int2, int1);
195 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "min", int3, int1);
196 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "min", int4, int1);
197
198 TType *uint1 = new TType(EbtUInt);
199 TType *uint2 = new TType(EbtUInt, 2);
200 TType *uint3 = new TType(EbtUInt, 3);
201 TType *uint4 = new TType(EbtUInt, 4);
202
203 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "min", uint1, uint1);
204 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "min", uint2, uint2);
205 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "min", uint3, uint3);
206 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "min", uint4, uint4);
207 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "min", uint2, uint1);
208 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "min", uint3, uint1);
209 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "min", uint4, uint1);
210
Nicolas Capens8f80e022013-07-11 11:20:50 -0400211 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "max", float1, float1);
212 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "max", float2, float1);
213 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "max", float3, float1);
214 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "max", float4, float1);
215 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "max", float2, float2);
216 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "max", float3, float3);
217 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "max", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000218
Arun Patole42077bb2015-02-16 15:32:37 +0530219 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "max", int1, int1);
220 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "max", int2, int2);
221 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "max", int3, int3);
222 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "max", int4, int4);
223 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "max", int2, int1);
224 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "max", int3, int1);
225 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "max", int4, int1);
226
227 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "max", uint1, uint1);
228 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "max", uint2, uint2);
229 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "max", uint3, uint3);
230 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "max", uint4, uint4);
231 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "max", uint2, uint1);
232 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "max", uint3, uint1);
233 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "max", uint4, uint1);
234
Nicolas Capens8f80e022013-07-11 11:20:50 -0400235 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "clamp", float1, float1, float1);
236 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "clamp", float2, float1, float1);
237 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "clamp", float3, float1, float1);
238 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "clamp", float4, float1, float1);
239 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "clamp", float2, float2, float2);
240 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "clamp", float3, float3, float3);
241 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "clamp", float4, float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000242
Arun Patole42077bb2015-02-16 15:32:37 +0530243 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "clamp", int1, int1, int1);
244 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "clamp", int2, int1, int1);
245 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "clamp", int3, int1, int1);
246 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "clamp", int4, int1, int1);
247 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "clamp", int2, int2, int2);
248 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "clamp", int3, int3, int3);
249 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "clamp", int4, int4, int4);
250
251 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "clamp", uint1, uint1, uint1);
252 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "clamp", uint2, uint1, uint1);
253 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "clamp", uint3, uint1, uint1);
254 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "clamp", uint4, uint1, uint1);
255 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "clamp", uint2, uint2, uint2);
256 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "clamp", uint3, uint3, uint3);
257 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "clamp", uint4, uint4, uint4);
258
Nicolas Capens8f80e022013-07-11 11:20:50 -0400259 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "mix", float1, float1, float1);
260 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mix", float2, float2, float1);
261 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mix", float3, float3, float1);
262 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mix", float4, float4, float1);
263 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mix", float2, float2, float2);
264 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mix", float3, float3, float3);
265 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mix", float4, float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000266
Nicolas Capens8f80e022013-07-11 11:20:50 -0400267 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "step", float1, float1);
268 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "step", float2, float2);
269 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "step", float3, float3);
270 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "step", float4, float4);
271 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "step", float1, float2);
272 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "step", float1, float3);
273 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "step", float1, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000274
Nicolas Capens8f80e022013-07-11 11:20:50 -0400275 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "smoothstep", float1, float1, float1);
276 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "smoothstep", float2, float2, float2);
277 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "smoothstep", float3, float3, float3);
278 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "smoothstep", float4, float4, float4);
279 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "smoothstep", float1, float1, float2);
280 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "smoothstep", float1, float1, float3);
281 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "smoothstep", float1, float1, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000282
Arun Patole0c1726e2015-02-18 14:35:02 +0530283 TType *bool1 = new TType(EbtBool);
284 TType *bool2 = new TType(EbtBool, 2);
285 TType *bool3 = new TType(EbtBool, 3);
286 TType *bool4 = new TType(EbtBool, 4);
287
288 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool1, "isnan", float1);
289 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "isnan", float2);
290 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "isnan", float3);
291 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "isnan", float4);
292
293 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool1, "isinf", float1);
294 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "isinf", float2);
295 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "isinf", float3);
296 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "isinf", float4);
297
Olli Etuahoe8d2c072015-01-08 16:33:54 +0200298 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "floatBitsToInt", float1);
299 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "floatBitsToInt", float2);
300 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "floatBitsToInt", float3);
301 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "floatBitsToInt", float4);
302
303 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "floatBitsToUint", float1);
304 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "floatBitsToUint", float2);
305 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "floatBitsToUint", float3);
306 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "floatBitsToUint", float4);
307
308 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "intBitsToFloat", int1);
309 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "intBitsToFloat", int2);
310 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "intBitsToFloat", int3);
311 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "intBitsToFloat", int4);
312
313 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "uintBitsToFloat", uint1);
314 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "uintBitsToFloat", uint2);
315 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "uintBitsToFloat", uint3);
316 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "uintBitsToFloat", uint4);
317
Olli Etuaho7700ff62015-01-15 12:16:29 +0200318 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "packSnorm2x16", float2);
319 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "packUnorm2x16", float2);
320 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "packHalf2x16", float2);
321 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "unpackSnorm2x16", uint1);
322 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "unpackUnorm2x16", uint1);
323 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "unpackHalf2x16", uint1);
324
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000325 //
326 // Geometric Functions.
327 //
Nicolas Capens8f80e022013-07-11 11:20:50 -0400328 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float1);
329 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float2);
330 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float3);
331 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000332
Nicolas Capens8f80e022013-07-11 11:20:50 -0400333 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float1, float1);
334 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float2, float2);
335 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float3, float3);
336 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000337
Nicolas Capens8f80e022013-07-11 11:20:50 -0400338 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float1, float1);
339 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float2, float2);
340 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float3, float3);
341 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000342
Nicolas Capens8f80e022013-07-11 11:20:50 -0400343 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "cross", float3, float3);
344 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "normalize", float1);
345 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "normalize", float2);
346 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "normalize", float3);
347 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "normalize", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000348
Nicolas Capens8f80e022013-07-11 11:20:50 -0400349 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "faceforward", float1, float1, float1);
350 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "faceforward", float2, float2, float2);
351 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "faceforward", float3, float3, float3);
352 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "faceforward", float4, float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000353
Nicolas Capens8f80e022013-07-11 11:20:50 -0400354 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "reflect", float1, float1);
355 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "reflect", float2, float2);
356 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "reflect", float3, float3);
357 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "reflect", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000358
Nicolas Capens8f80e022013-07-11 11:20:50 -0400359 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "refract", float1, float1, float1);
360 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "refract", float2, float2, float1);
361 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "refract", float3, float3, float1);
362 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "refract", float4, float4, float1);
Nicolas Capens49a88872013-06-20 09:54:03 -0400363
Nicolas Capensc9508842014-02-14 17:48:50 -0500364 TType *mat2 = new TType(EbtFloat, 2, 2);
365 TType *mat3 = new TType(EbtFloat, 3, 3);
366 TType *mat4 = new TType(EbtFloat, 4, 4);
Olli Etuahoe39706d2014-12-30 16:40:36 +0200367 TType *mat2x3 = new TType(EbtFloat, 2, 3);
368 TType *mat3x2 = new TType(EbtFloat, 3, 2);
369 TType *mat2x4 = new TType(EbtFloat, 2, 4);
370 TType *mat4x2 = new TType(EbtFloat, 4, 2);
371 TType *mat3x4 = new TType(EbtFloat, 3, 4);
372 TType *mat4x3 = new TType(EbtFloat, 4, 3);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000373
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000374 //
375 // Matrix Functions.
376 //
Nicolas Capens8f80e022013-07-11 11:20:50 -0400377 symbolTable.insertBuiltIn(COMMON_BUILTINS, mat2, "matrixCompMult", mat2, mat2);
378 symbolTable.insertBuiltIn(COMMON_BUILTINS, mat3, "matrixCompMult", mat3, mat3);
379 symbolTable.insertBuiltIn(COMMON_BUILTINS, mat4, "matrixCompMult", mat4, mat4);
Olli Etuahoe39706d2014-12-30 16:40:36 +0200380 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2x3, "matrixCompMult", mat2x3, mat2x3);
381 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3x2, "matrixCompMult", mat3x2, mat3x2);
382 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2x4, "matrixCompMult", mat2x4, mat2x4);
383 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4x2, "matrixCompMult", mat4x2, mat4x2);
384 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3x4, "matrixCompMult", mat3x4, mat3x4);
385 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4x3, "matrixCompMult", mat4x3, mat4x3);
386
387 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2, "outerProduct", float2, float2);
388 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3, "outerProduct", float3, float3);
389 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4, "outerProduct", float4, float4);
390 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2x3, "outerProduct", float3, float2);
391 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3x2, "outerProduct", float2, float3);
392 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2x4, "outerProduct", float4, float2);
393 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4x2, "outerProduct", float2, float4);
394 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3x4, "outerProduct", float4, float3);
395 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4x3, "outerProduct", float3, float4);
396
397 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2, "transpose", mat2);
398 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3, "transpose", mat3);
399 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4, "transpose", mat4);
400 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2x3, "transpose", mat3x2);
401 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3x2, "transpose", mat2x3);
402 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2x4, "transpose", mat4x2);
403 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4x2, "transpose", mat2x4);
404 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3x4, "transpose", mat4x3);
405 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4x3, "transpose", mat3x4);
406
407 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "determinant", mat2);
408 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "determinant", mat3);
409 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "determinant", mat4);
Nicolas Capens49a88872013-06-20 09:54:03 -0400410
Olli Etuahoabf6dad2015-01-14 14:45:16 +0200411 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2, "inverse", mat2);
412 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3, "inverse", mat3);
413 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4, "inverse", mat4);
414
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000415 //
416 // Vector relational functions.
417 //
Nicolas Capens8f80e022013-07-11 11:20:50 -0400418 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThan", float2, float2);
419 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThan", float3, float3);
420 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThan", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000421
Nicolas Capens8f80e022013-07-11 11:20:50 -0400422 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThan", int2, int2);
423 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThan", int3, int3);
424 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThan", int4, int4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000425
Arun Patole2b455732015-02-17 20:24:59 +0530426 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "lessThan", uint2, uint2);
427 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "lessThan", uint3, uint3);
428 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "lessThan", uint4, uint4);
429
Nicolas Capens8f80e022013-07-11 11:20:50 -0400430 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThanEqual", float2, float2);
431 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThanEqual", float3, float3);
432 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThanEqual", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000433
Nicolas Capens8f80e022013-07-11 11:20:50 -0400434 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThanEqual", int2, int2);
435 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThanEqual", int3, int3);
436 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThanEqual", int4, int4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000437
Arun Patole2b455732015-02-17 20:24:59 +0530438 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "lessThanEqual", uint2, uint2);
439 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "lessThanEqual", uint3, uint3);
440 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "lessThanEqual", uint4, uint4);
441
Nicolas Capens8f80e022013-07-11 11:20:50 -0400442 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThan", float2, float2);
443 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThan", float3, float3);
444 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThan", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000445
Nicolas Capens8f80e022013-07-11 11:20:50 -0400446 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThan", int2, int2);
447 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThan", int3, int3);
448 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThan", int4, int4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000449
Arun Patole2b455732015-02-17 20:24:59 +0530450 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "greaterThan", uint2, uint2);
451 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "greaterThan", uint3, uint3);
452 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "greaterThan", uint4, uint4);
453
Nicolas Capens8f80e022013-07-11 11:20:50 -0400454 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThanEqual", float2, float2);
455 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThanEqual", float3, float3);
456 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThanEqual", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000457
Nicolas Capens8f80e022013-07-11 11:20:50 -0400458 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThanEqual", int2, int2);
459 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThanEqual", int3, int3);
460 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThanEqual", int4, int4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000461
Arun Patole2b455732015-02-17 20:24:59 +0530462 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "greaterThanEqual", uint2, uint2);
463 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "greaterThanEqual", uint3, uint3);
464 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "greaterThanEqual", uint4, uint4);
465
Nicolas Capens8f80e022013-07-11 11:20:50 -0400466 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", float2, float2);
467 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", float3, float3);
468 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000469
Nicolas Capens8f80e022013-07-11 11:20:50 -0400470 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", int2, int2);
471 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", int3, int3);
472 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", int4, int4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000473
Arun Patole2b455732015-02-17 20:24:59 +0530474 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "equal", uint2, uint2);
475 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "equal", uint3, uint3);
476 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "equal", uint4, uint4);
477
Nicolas Capens8f80e022013-07-11 11:20:50 -0400478 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", bool2, bool2);
479 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", bool3, bool3);
480 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", bool4, bool4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000481
Nicolas Capens8f80e022013-07-11 11:20:50 -0400482 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", float2, float2);
483 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", float3, float3);
484 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000485
Nicolas Capens8f80e022013-07-11 11:20:50 -0400486 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", int2, int2);
487 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", int3, int3);
488 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", int4, int4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000489
Arun Patole2b455732015-02-17 20:24:59 +0530490 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "notEqual", uint2, uint2);
491 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "notEqual", uint3, uint3);
492 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "notEqual", uint4, uint4);
493
Nicolas Capens8f80e022013-07-11 11:20:50 -0400494 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", bool2, bool2);
495 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", bool3, bool3);
496 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", bool4, bool4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000497
Nicolas Capens8f80e022013-07-11 11:20:50 -0400498 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool2);
499 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool3);
500 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000501
Nicolas Capens8f80e022013-07-11 11:20:50 -0400502 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool2);
503 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool3);
504 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000505
Nicolas Capens8f80e022013-07-11 11:20:50 -0400506 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "not", bool2);
507 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "not", bool3);
508 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "not", bool4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000509
Nicolas Capensc9508842014-02-14 17:48:50 -0500510 TType *sampler2D = new TType(EbtSampler2D);
511 TType *samplerCube = new TType(EbtSamplerCube);
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000512
513 //
514 // Texture Functions for GLSL ES 1.0
515 //
Nicolas Capens8f80e022013-07-11 11:20:50 -0400516 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, float2);
517 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float3);
518 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float4);
519 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, float3);
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000520
Nicolas Capens49a88872013-06-20 09:54:03 -0400521 if (resources.OES_EGL_image_external)
522 {
Nicolas Capensc9508842014-02-14 17:48:50 -0500523 TType *samplerExternalOES = new TType(EbtSamplerExternalOES);
Nicolas Capens49a88872013-06-20 09:54:03 -0400524
Nicolas Capens8f80e022013-07-11 11:20:50 -0400525 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", samplerExternalOES, float2);
526 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, float3);
527 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, float4);
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000528 }
529
Nicolas Capens49a88872013-06-20 09:54:03 -0400530 if (resources.ARB_texture_rectangle)
531 {
Nicolas Capensc9508842014-02-14 17:48:50 -0500532 TType *sampler2DRect = new TType(EbtSampler2DRect);
Nicolas Capens49a88872013-06-20 09:54:03 -0400533
Nicolas Capens8f80e022013-07-11 11:20:50 -0400534 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRect", sampler2DRect, float2);
535 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect, float3);
536 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect, float4);
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000537 }
538
Nicolas Capens46485082014-04-15 13:12:50 -0400539 if (resources.EXT_shader_texture_lod)
540 {
541 /* The *Grad* variants are new to both vertex and fragment shaders; the fragment
542 * shader specific pieces are added separately below.
543 */
544 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DGradEXT", sampler2D, float2, float2, float2);
545 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjGradEXT", sampler2D, float3, float2, float2);
546 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjGradEXT", sampler2D, float4, float2, float2);
547 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeGradEXT", samplerCube, float3, float3, float3);
548 }
549
Jamie Madill183bde52014-07-02 15:31:19 -0400550 if (type == GL_FRAGMENT_SHADER)
Nicolas Capens49a88872013-06-20 09:54:03 -0400551 {
Nicolas Capens8f80e022013-07-11 11:20:50 -0400552 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, float2, float1);
553 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float3, float1);
554 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float4, float1);
555 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, float3, float1);
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000556
Nicolas Capens49a88872013-06-20 09:54:03 -0400557 if (resources.OES_standard_derivatives)
558 {
Nicolas Capens8f80e022013-07-11 11:20:50 -0400559 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "dFdx", float1);
560 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "dFdx", float2);
561 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "dFdx", float3);
562 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "dFdx", float4);
Nicolas Capens46485082014-04-15 13:12:50 -0400563
Nicolas Capens8f80e022013-07-11 11:20:50 -0400564 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "dFdy", float1);
565 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "dFdy", float2);
566 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "dFdy", float3);
567 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "dFdy", float4);
Nicolas Capens49a88872013-06-20 09:54:03 -0400568
Nicolas Capens8f80e022013-07-11 11:20:50 -0400569 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "fwidth", float1);
570 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "fwidth", float2);
571 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "fwidth", float3);
572 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "fwidth", float4);
Nicolas Capens49a88872013-06-20 09:54:03 -0400573 }
Nicolas Capens46485082014-04-15 13:12:50 -0400574
575 if (resources.EXT_shader_texture_lod)
576 {
577 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DLodEXT", sampler2D, float2, float1);
578 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLodEXT", sampler2D, float3, float1);
579 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLodEXT", sampler2D, float4, float1);
580 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeLodEXT", samplerCube, float3, float1);
581 }
Nicolas Capens49a88872013-06-20 09:54:03 -0400582 }
583
Jamie Madill183bde52014-07-02 15:31:19 -0400584 if(type == GL_VERTEX_SHADER)
Nicolas Capens49a88872013-06-20 09:54:03 -0400585 {
Nicolas Capens8f80e022013-07-11 11:20:50 -0400586 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DLod", sampler2D, float2, float1);
587 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, float3, float1);
588 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, float4, float1);
589 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeLod", samplerCube, float3, float1);
Nicolas Capens49a88872013-06-20 09:54:03 -0400590 }
shannonwoods@chromium.orgc6ac65f2013-05-30 00:02:50 +0000591
Nicolas Capens4fd5e4a2014-02-14 18:17:15 -0500592 TType *gvec4 = new TType(EbtGVec4);
593
594 TType *gsampler2D = new TType(EbtGSampler2D);
595 TType *gsamplerCube = new TType(EbtGSamplerCube);
596 TType *gsampler3D = new TType(EbtGSampler3D);
597 TType *gsampler2DArray = new TType(EbtGSampler2DArray);
Nicolas Capens73f5bf62013-06-17 16:13:33 -0400598
shannonwoods@chromium.orgc6ac65f2013-05-30 00:02:50 +0000599 //
600 // Texture Functions for GLSL ES 3.0
601 //
Nicolas Capens4fd5e4a2014-02-14 18:17:15 -0500602 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2D, float2);
603 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler3D, float3);
604 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsamplerCube, float3);
605 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2DArray, float3);
606 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float3);
607 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float4);
608 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler3D, float4);
609 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler2D, float2, float1);
610 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler3D, float3, float1);
611 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsamplerCube, float3, float1);
612 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler2DArray, float3, float1);
shannonwoods@chromium.orgc6ac65f2013-05-30 00:02:50 +0000613
Jamie Madill183bde52014-07-02 15:31:19 -0400614 if (type == GL_FRAGMENT_SHADER)
Nicolas Capens67a819f2013-07-09 12:08:58 -0400615 {
Nicolas Capens4fd5e4a2014-02-14 18:17:15 -0500616 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2D, float2, float1);
617 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler3D, float3, float1);
618 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsamplerCube, float3, float1);
619 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2DArray, float3, float1);
620 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float3, float1);
621 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float4, float1);
622 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler3D, float4, float1);
Nicolas Capens67a819f2013-07-09 12:08:58 -0400623 }
624
Nicolas Capensc9508842014-02-14 17:48:50 -0500625 TType *sampler2DShadow = new TType(EbtSampler2DShadow);
626 TType *samplerCubeShadow = new TType(EbtSamplerCubeShadow);
627 TType *sampler2DArrayShadow = new TType(EbtSampler2DArrayShadow);
Nicolas Capens77c9d1a2013-07-11 11:10:34 -0400628
Nicolas Capens8f80e022013-07-11 11:20:50 -0400629 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DShadow, float3);
630 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", samplerCubeShadow, float4);
631 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DArrayShadow, float4);
632 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProj", sampler2DShadow, float4);
Jamie Madill16a1c072013-10-22 15:42:15 -0400633 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureLod", sampler2DShadow, float3, float1);
Nicolas Capens77c9d1a2013-07-11 11:10:34 -0400634
Jamie Madill183bde52014-07-02 15:31:19 -0400635 if (type == GL_FRAGMENT_SHADER)
Nicolas Capens77c9d1a2013-07-11 11:10:34 -0400636 {
Nicolas Capens8f80e022013-07-11 11:20:50 -0400637 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DShadow, float3, float1);
638 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", samplerCubeShadow, float4, float1);
Nicolas Capens8f80e022013-07-11 11:20:50 -0400639 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProj", sampler2DShadow, float4, float1);
Nicolas Capens77c9d1a2013-07-11 11:10:34 -0400640 }
641
Nicolas Capens4fd5e4a2014-02-14 18:17:15 -0500642 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", gsampler2D, int1);
643 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", gsampler3D, int1);
644 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", gsamplerCube, int1);
645 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", gsampler2DArray, int1);
Nicolas Capens8f80e022013-07-11 11:20:50 -0400646 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", sampler2DShadow, int1);
647 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", samplerCubeShadow, int1);
648 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", sampler2DArrayShadow, int1);
Nicolas Capens75fb4752013-07-10 15:14:47 -0400649
Jamie Madill183bde52014-07-02 15:31:19 -0400650 if(type == GL_FRAGMENT_SHADER)
Nicolas Capens49a88872013-06-20 09:54:03 -0400651 {
Nicolas Capens8f80e022013-07-11 11:20:50 -0400652 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "dFdx", float1);
653 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "dFdx", float2);
654 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "dFdx", float3);
655 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "dFdx", float4);
Nicolas Capens49a88872013-06-20 09:54:03 -0400656
Nicolas Capens8f80e022013-07-11 11:20:50 -0400657 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "dFdy", float1);
658 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "dFdy", float2);
659 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "dFdy", float3);
660 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "dFdy", float4);
shannonwoods@chromium.orgc6ac65f2013-05-30 00:02:50 +0000661
Nicolas Capens8f80e022013-07-11 11:20:50 -0400662 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "fwidth", float1);
663 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "fwidth", float2);
664 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "fwidth", float3);
665 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "fwidth", float4);
alokp@chromium.org06098892010-08-26 19:36:42 +0000666 }
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000667
Nicolas Capens4fd5e4a2014-02-14 18:17:15 -0500668 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2);
669 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler3D, float3, int3);
670 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureOffset", sampler2DShadow, float3, int2);
671 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2DArray, float3, int2);
672
Jamie Madill183bde52014-07-02 15:31:19 -0400673 if(type == GL_FRAGMENT_SHADER)
Nicolas Capens4fd5e4a2014-02-14 18:17:15 -0500674 {
675 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2, float1);
676 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler3D, float3, int3, float1);
677 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureOffset", sampler2DShadow, float3, int2, float1);
678 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2DArray, float3, int2, float1);
679 }
Nicolas Capens1fbc2872014-01-03 14:12:09 -0500680
Nicolas Capensdf86c6b2014-02-14 20:09:17 -0500681 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float3, int2);
682 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float4, int2);
683 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler3D, float4, int3);
684 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjOffset", sampler2DShadow, float4, int2);
685
Jamie Madill183bde52014-07-02 15:31:19 -0400686 if(type == GL_FRAGMENT_SHADER)
Nicolas Capensdf86c6b2014-02-14 20:09:17 -0500687 {
688 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float3, int2, float1);
689 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float4, int2, float1);
690 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler3D, float4, int3, float1);
691 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjOffset", sampler2DShadow, float4, int2, float1);
692 }
693
694 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler2D, float2, float1, int2);
695 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler3D, float3, float1, int3);
696 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureLodOffset", sampler2DShadow, float3, float1, int2);
697 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler2DArray, float3, float1, int2);
698
Nicolas Capens2adc2562014-02-14 23:50:59 -0500699 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler2D, float3, float1);
700 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler2D, float4, float1);
701 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler3D, float4, float1);
702 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjLod", sampler2DShadow, float4, float1);
703
704 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler2D, float3, float1, int2);
705 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler2D, float4, float1, int2);
706 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler3D, float4, float1, int3);
707 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjLodOffset", sampler2DShadow, float4, float1, int2);
708
Nicolas Capensfc014542014-02-18 14:47:13 -0500709 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler2D, int2, int1);
710 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler3D, int3, int1);
711 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler2DArray, int3, int1);
712
713 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler2D, int2, int1, int2);
714 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler3D, int3, int1, int3);
715 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler2DArray, int3, int1, int2);
716
Nicolas Capensd11d5492014-02-19 17:06:10 -0500717 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler2D, float2, float2, float2);
718 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler3D, float3, float3, float3);
719 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsamplerCube, float3, float3, float3);
720 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", sampler2DShadow, float3, float2, float2);
721 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", samplerCubeShadow, float4, float3, float3);
722 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler2DArray, float3, float2, float2);
723 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", sampler2DArrayShadow, float4, float2, float2);
724
Nicolas Capensbf7db102014-02-19 17:20:28 -0500725 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler2D, float2, float2, float2, int2);
726 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler3D, float3, float3, float3, int3);
727 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGradOffset", sampler2DShadow, float3, float2, float2, int2);
728 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler2DArray, float3, float2, float2, int2);
729 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGradOffset", sampler2DArrayShadow, float4, float2, float2, int2);
730
Nicolas Capensf7378e32014-02-19 17:29:32 -0500731 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler2D, float3, float2, float2);
732 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler2D, float4, float2, float2);
733 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler3D, float4, float3, float3);
734 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjGrad", sampler2DShadow, float4, float2, float2);
735
736 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler2D, float3, float2, float2, int2);
737 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler2D, float4, float2, float2, int2);
738 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler3D, float4, float3, float3, int3);
739 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjGradOffset", sampler2DShadow, float4, float2, float2, int2);
740
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000741 //
742 // Depth range in window coordinates
743 //
Jamie Madill98493dd2013-07-08 14:39:03 -0400744 TFieldList *fields = NewPoolTFieldList();
Jamie Madill37f77d22014-04-30 16:10:13 -0400745 TSourceLoc zeroSourceLoc = {0, 0, 0, 0};
Jamie Madill98493dd2013-07-08 14:39:03 -0400746 TField *near = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("near"), zeroSourceLoc);
747 TField *far = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("far"), zeroSourceLoc);
748 TField *diff = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("diff"), zeroSourceLoc);
749 fields->push_back(near);
750 fields->push_back(far);
751 fields->push_back(diff);
752 TStructure *depthRangeStruct = new TStructure(NewPoolTString("gl_DepthRangeParameters"), fields);
753 TVariable *depthRangeParameters = new TVariable(&depthRangeStruct->name(), depthRangeStruct, true);
Nicolas Capensadfffe42014-06-17 02:13:36 -0400754 symbolTable.insert(COMMON_BUILTINS, depthRangeParameters);
Jamie Madill98493dd2013-07-08 14:39:03 -0400755 TVariable *depthRange = new TVariable(NewPoolTString("gl_DepthRange"), TType(depthRangeStruct));
Nicolas Capens49a88872013-06-20 09:54:03 -0400756 depthRange->setQualifier(EvqUniform);
Nicolas Capensadfffe42014-06-17 02:13:36 -0400757 symbolTable.insert(COMMON_BUILTINS, depthRange);
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000758
Nicolas Capens49a88872013-06-20 09:54:03 -0400759 //
760 // Implementation dependent built-in constants.
761 //
762 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexAttribs", resources.MaxVertexAttribs);
763 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexUniformVectors", resources.MaxVertexUniformVectors);
764 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexTextureImageUnits", resources.MaxVertexTextureImageUnits);
765 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxCombinedTextureImageUnits", resources.MaxCombinedTextureImageUnits);
766 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxTextureImageUnits", resources.MaxTextureImageUnits);
767 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxFragmentUniformVectors", resources.MaxFragmentUniformVectors);
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000768
Nicolas Capens49a88872013-06-20 09:54:03 -0400769 symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxVaryingVectors", resources.MaxVaryingVectors);
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +0000770
771 if (spec != SH_CSS_SHADERS_SPEC)
shannon.woods%transgaming.com@gtempaccount.com5209de82013-04-13 03:41:53 +0000772 {
Jamie Madill455a6f52013-10-17 10:45:46 -0400773 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxDrawBuffers", resources.MaxDrawBuffers);
shannon.woods%transgaming.com@gtempaccount.com5209de82013-04-13 03:41:53 +0000774 }
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000775
Nicolas Capens49a88872013-06-20 09:54:03 -0400776 symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxVertexOutputVectors", resources.MaxVertexOutputVectors);
777 symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxFragmentInputVectors", resources.MaxFragmentInputVectors);
778 symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MinProgramTexelOffset", resources.MinProgramTexelOffset);
779 symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxProgramTexelOffset", resources.MaxProgramTexelOffset);
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000780}
781
Jamie Madill183bde52014-07-02 15:31:19 -0400782void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec,
Nicolas Capens49a88872013-06-20 09:54:03 -0400783 const ShBuiltInResources &resources,
784 TSymbolTable &symbolTable)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000785{
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000786 //
787 // First, insert some special built-in variables that are not in
788 // the built-in header files.
789 //
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000790 switch(type) {
Jamie Madill183bde52014-07-02 15:31:19 -0400791 case GL_FRAGMENT_SHADER:
Nicolas Capensadfffe42014-06-17 02:13:36 -0400792 symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FragCoord"), TType(EbtFloat, EbpMedium, EvqFragCoord, 4)));
793 symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool, EbpUndefined, EvqFrontFacing, 1)));
794 symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointCoord"), TType(EbtFloat, EbpMedium, EvqPointCoord, 2)));
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +0000795
796 //
797 // In CSS Shaders, gl_FragColor, gl_FragData, and gl_MaxDrawBuffers are not available.
798 // Instead, css_MixColor and css_ColorMatrix are available.
799 //
800 if (spec != SH_CSS_SHADERS_SPEC) {
Nicolas Capensadfffe42014-06-17 02:13:36 -0400801 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EbpMedium, EvqFragColor, 4)));
802 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqFragData, 4)));
Jamie Madill2aeb26a2013-07-08 14:02:55 -0400803 if (resources.EXT_frag_depth) {
Nicolas Capensadfffe42014-06-17 02:13:36 -0400804 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragDepthEXT"), TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepth, 1)));
Jamie Madill2aeb26a2013-07-08 14:02:55 -0400805 symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_FragDepthEXT", "GL_EXT_frag_depth");
806 }
Erik Dahlströmea7a2122014-11-17 16:15:57 +0100807 if (resources.EXT_shader_framebuffer_fetch)
808 {
809 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqLastFragData, 4)));
810 }
811 else if (resources.NV_shader_framebuffer_fetch)
812 {
813 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragColor"), TType(EbtFloat, EbpMedium, EvqLastFragColor, 4)));
814 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqLastFragData, 4)));
815 }
816 else if (resources.ARM_shader_framebuffer_fetch)
817 {
818 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragColorARM"), TType(EbtFloat, EbpMedium, EvqLastFragColor, 4)));
819 }
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +0000820 } else {
Nicolas Capensadfffe42014-06-17 02:13:36 -0400821 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("css_MixColor"), TType(EbtFloat, EbpMedium, EvqGlobal, 4)));
822 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("css_ColorMatrix"), TType(EbtFloat, EbpMedium, EvqGlobal, 4, 4)));
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +0000823 }
824
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000825 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000826
Jamie Madill183bde52014-07-02 15:31:19 -0400827 case GL_VERTEX_SHADER:
Nicolas Capensadfffe42014-06-17 02:13:36 -0400828 symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EbpHigh, EvqPosition, 4)));
829 symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EbpMedium, EvqPointSize, 1)));
Gregoire Payen de La Garanderieb3dced22015-01-12 14:54:55 +0000830 symbolTable.insert(ESSL3_BUILTINS, new TVariable(NewPoolTString("gl_InstanceID"), TType(EbtInt, EbpHigh, EvqInstanceID, 1)));
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000831 break;
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000832
833 default: assert(false && "Language not supported");
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000834 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000835
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000836 //
837 // Next, identify which built-ins from the already loaded headers have
838 // a mapping to an operator. Those that are not identified as such are
839 // expected to be resolved through a library of functions, versus as
840 // operations.
841 //
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000842 symbolTable.relateToOperator(COMMON_BUILTINS, "matrixCompMult", EOpMul);
Olli Etuahoe39706d2014-12-30 16:40:36 +0200843 symbolTable.relateToOperator(ESSL3_BUILTINS, "matrixCompMult", EOpMul);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000844
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000845 symbolTable.relateToOperator(COMMON_BUILTINS, "equal", EOpVectorEqual);
846 symbolTable.relateToOperator(COMMON_BUILTINS, "notEqual", EOpVectorNotEqual);
847 symbolTable.relateToOperator(COMMON_BUILTINS, "lessThan", EOpLessThan);
848 symbolTable.relateToOperator(COMMON_BUILTINS, "greaterThan", EOpGreaterThan);
849 symbolTable.relateToOperator(COMMON_BUILTINS, "lessThanEqual", EOpLessThanEqual);
850 symbolTable.relateToOperator(COMMON_BUILTINS, "greaterThanEqual", EOpGreaterThanEqual);
Arun Patole2b455732015-02-17 20:24:59 +0530851
852 symbolTable.relateToOperator(ESSL3_BUILTINS, "equal", EOpVectorEqual);
853 symbolTable.relateToOperator(ESSL3_BUILTINS, "notEqual", EOpVectorNotEqual);
854 symbolTable.relateToOperator(ESSL3_BUILTINS, "lessThan", EOpLessThan);
855 symbolTable.relateToOperator(ESSL3_BUILTINS, "greaterThan", EOpGreaterThan);
856 symbolTable.relateToOperator(ESSL3_BUILTINS, "lessThanEqual", EOpLessThanEqual);
857 symbolTable.relateToOperator(ESSL3_BUILTINS, "greaterThanEqual", EOpGreaterThanEqual);
858
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000859 symbolTable.relateToOperator(COMMON_BUILTINS, "radians", EOpRadians);
860 symbolTable.relateToOperator(COMMON_BUILTINS, "degrees", EOpDegrees);
861 symbolTable.relateToOperator(COMMON_BUILTINS, "sin", EOpSin);
862 symbolTable.relateToOperator(COMMON_BUILTINS, "cos", EOpCos);
863 symbolTable.relateToOperator(COMMON_BUILTINS, "tan", EOpTan);
864 symbolTable.relateToOperator(COMMON_BUILTINS, "asin", EOpAsin);
865 symbolTable.relateToOperator(COMMON_BUILTINS, "acos", EOpAcos);
866 symbolTable.relateToOperator(COMMON_BUILTINS, "atan", EOpAtan);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000867
Olli Etuaho5c9cd3d2014-12-18 13:04:25 +0200868 symbolTable.relateToOperator(ESSL3_BUILTINS, "sinh", EOpSinh);
869 symbolTable.relateToOperator(ESSL3_BUILTINS, "cosh", EOpCosh);
870 symbolTable.relateToOperator(ESSL3_BUILTINS, "tanh", EOpTanh);
871 symbolTable.relateToOperator(ESSL3_BUILTINS, "asinh", EOpAsinh);
872 symbolTable.relateToOperator(ESSL3_BUILTINS, "acosh", EOpAcosh);
873 symbolTable.relateToOperator(ESSL3_BUILTINS, "atanh", EOpAtanh);
874
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000875 symbolTable.relateToOperator(COMMON_BUILTINS, "pow", EOpPow);
876 symbolTable.relateToOperator(COMMON_BUILTINS, "exp2", EOpExp2);
877 symbolTable.relateToOperator(COMMON_BUILTINS, "log", EOpLog);
878 symbolTable.relateToOperator(COMMON_BUILTINS, "exp", EOpExp);
879 symbolTable.relateToOperator(COMMON_BUILTINS, "log2", EOpLog2);
880 symbolTable.relateToOperator(COMMON_BUILTINS, "sqrt", EOpSqrt);
881 symbolTable.relateToOperator(COMMON_BUILTINS, "inversesqrt", EOpInverseSqrt);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000882
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000883 symbolTable.relateToOperator(COMMON_BUILTINS, "abs", EOpAbs);
884 symbolTable.relateToOperator(COMMON_BUILTINS, "sign", EOpSign);
885 symbolTable.relateToOperator(COMMON_BUILTINS, "floor", EOpFloor);
886 symbolTable.relateToOperator(COMMON_BUILTINS, "ceil", EOpCeil);
887 symbolTable.relateToOperator(COMMON_BUILTINS, "fract", EOpFract);
888 symbolTable.relateToOperator(COMMON_BUILTINS, "mod", EOpMod);
889 symbolTable.relateToOperator(COMMON_BUILTINS, "min", EOpMin);
890 symbolTable.relateToOperator(COMMON_BUILTINS, "max", EOpMax);
891 symbolTable.relateToOperator(COMMON_BUILTINS, "clamp", EOpClamp);
892 symbolTable.relateToOperator(COMMON_BUILTINS, "mix", EOpMix);
893 symbolTable.relateToOperator(COMMON_BUILTINS, "step", EOpStep);
894 symbolTable.relateToOperator(COMMON_BUILTINS, "smoothstep", EOpSmoothStep);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000895
Arun Patole42077bb2015-02-16 15:32:37 +0530896 symbolTable.relateToOperator(ESSL3_BUILTINS, "min", EOpMin);
897 symbolTable.relateToOperator(ESSL3_BUILTINS, "max", EOpMax);
898 symbolTable.relateToOperator(ESSL3_BUILTINS, "clamp", EOpClamp);
Arun Patole0c1726e2015-02-18 14:35:02 +0530899 symbolTable.relateToOperator(ESSL3_BUILTINS, "isnan", EOpIsNan);
900 symbolTable.relateToOperator(ESSL3_BUILTINS, "isinf", EOpIsInf);
Arun Patole42077bb2015-02-16 15:32:37 +0530901
Olli Etuahoe8d2c072015-01-08 16:33:54 +0200902 symbolTable.relateToOperator(ESSL3_BUILTINS, "floatBitsToInt", EOpFloatBitsToInt);
903 symbolTable.relateToOperator(ESSL3_BUILTINS, "floatBitsToUint", EOpFloatBitsToUint);
904 symbolTable.relateToOperator(ESSL3_BUILTINS, "intBitsToFloat", EOpIntBitsToFloat);
905 symbolTable.relateToOperator(ESSL3_BUILTINS, "uintBitsToFloat", EOpUintBitsToFloat);
906
Olli Etuaho7700ff62015-01-15 12:16:29 +0200907 symbolTable.relateToOperator(ESSL3_BUILTINS, "packSnorm2x16", EOpPackSnorm2x16);
908 symbolTable.relateToOperator(ESSL3_BUILTINS, "packUnorm2x16", EOpPackUnorm2x16);
909 symbolTable.relateToOperator(ESSL3_BUILTINS, "packHalf2x16", EOpPackHalf2x16);
910
911 symbolTable.relateToOperator(ESSL3_BUILTINS, "unpackSnorm2x16", EOpUnpackSnorm2x16);
912 symbolTable.relateToOperator(ESSL3_BUILTINS, "unpackUnorm2x16", EOpUnpackUnorm2x16);
913 symbolTable.relateToOperator(ESSL3_BUILTINS, "unpackHalf2x16", EOpUnpackHalf2x16);
914
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000915 symbolTable.relateToOperator(COMMON_BUILTINS, "length", EOpLength);
916 symbolTable.relateToOperator(COMMON_BUILTINS, "distance", EOpDistance);
917 symbolTable.relateToOperator(COMMON_BUILTINS, "dot", EOpDot);
918 symbolTable.relateToOperator(COMMON_BUILTINS, "cross", EOpCross);
919 symbolTable.relateToOperator(COMMON_BUILTINS, "normalize", EOpNormalize);
920 symbolTable.relateToOperator(COMMON_BUILTINS, "faceforward", EOpFaceForward);
921 symbolTable.relateToOperator(COMMON_BUILTINS, "reflect", EOpReflect);
922 symbolTable.relateToOperator(COMMON_BUILTINS, "refract", EOpRefract);
Nicolas Capens46485082014-04-15 13:12:50 -0400923
Olli Etuahoe39706d2014-12-30 16:40:36 +0200924 symbolTable.relateToOperator(ESSL3_BUILTINS, "outerProduct", EOpOuterProduct);
925 symbolTable.relateToOperator(ESSL3_BUILTINS, "transpose", EOpTranspose);
926 symbolTable.relateToOperator(ESSL3_BUILTINS, "determinant", EOpDeterminant);
Olli Etuahoabf6dad2015-01-14 14:45:16 +0200927 symbolTable.relateToOperator(ESSL3_BUILTINS, "inverse", EOpInverse);
Olli Etuahoe39706d2014-12-30 16:40:36 +0200928
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000929 symbolTable.relateToOperator(COMMON_BUILTINS, "any", EOpAny);
930 symbolTable.relateToOperator(COMMON_BUILTINS, "all", EOpAll);
931 symbolTable.relateToOperator(COMMON_BUILTINS, "not", EOpVectorLogicalNot);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000932
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000933 // Map language-specific operators.
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000934 switch(type) {
Jamie Madill183bde52014-07-02 15:31:19 -0400935 case GL_VERTEX_SHADER:
alokp@chromium.org58e54292010-08-24 21:40:03 +0000936 break;
Jamie Madill183bde52014-07-02 15:31:19 -0400937 case GL_FRAGMENT_SHADER:
Nicolas Capens46485082014-04-15 13:12:50 -0400938 if (resources.OES_standard_derivatives)
939 {
shannonwoods@chromium.orgc6ac65f2013-05-30 00:02:50 +0000940 symbolTable.relateToOperator(ESSL1_BUILTINS, "dFdx", EOpDFdx);
941 symbolTable.relateToOperator(ESSL1_BUILTINS, "dFdy", EOpDFdy);
942 symbolTable.relateToOperator(ESSL1_BUILTINS, "fwidth", EOpFwidth);
alokp@chromium.org8815d7f2010-09-09 17:30:03 +0000943
shannonwoods@chromium.orgc6ac65f2013-05-30 00:02:50 +0000944 symbolTable.relateToExtension(ESSL1_BUILTINS, "dFdx", "GL_OES_standard_derivatives");
945 symbolTable.relateToExtension(ESSL1_BUILTINS, "dFdy", "GL_OES_standard_derivatives");
946 symbolTable.relateToExtension(ESSL1_BUILTINS, "fwidth", "GL_OES_standard_derivatives");
alokp@chromium.org06098892010-08-26 19:36:42 +0000947 }
Nicolas Capens46485082014-04-15 13:12:50 -0400948 if (resources.EXT_shader_texture_lod)
949 {
950 symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DLodEXT", "GL_EXT_shader_texture_lod");
951 symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DProjLodEXT", "GL_EXT_shader_texture_lod");
952 symbolTable.relateToExtension(ESSL1_BUILTINS, "textureCubeLodEXT", "GL_EXT_shader_texture_lod");
953 }
Erik Dahlströmea7a2122014-11-17 16:15:57 +0100954 if (resources.NV_shader_framebuffer_fetch)
955 {
956 symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_LastFragColor", "GL_NV_shader_framebuffer_fetch");
957 }
958 else if (resources.ARM_shader_framebuffer_fetch)
959 {
960 symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_LastFragColorARM", "GL_ARM_shader_framebuffer_fetch");
961 }
alokp@chromium.org58e54292010-08-24 21:40:03 +0000962 break;
963 default: break;
964 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000965
Nicolas Capensf4cb0e12013-06-24 16:11:36 -0400966 symbolTable.relateToOperator(ESSL3_BUILTINS, "dFdx", EOpDFdx);
967 symbolTable.relateToOperator(ESSL3_BUILTINS, "dFdy", EOpDFdy);
968 symbolTable.relateToOperator(ESSL3_BUILTINS, "fwidth", EOpFwidth);
969
Nicolas Capens46485082014-04-15 13:12:50 -0400970 if (resources.EXT_shader_texture_lod)
971 {
972 symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DGradEXT", "GL_EXT_shader_texture_lod");
973 symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DProjGradEXT", "GL_EXT_shader_texture_lod");
974 symbolTable.relateToExtension(ESSL1_BUILTINS, "textureCubeGradEXT", "GL_EXT_shader_texture_lod");
975 }
976
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000977 // Finally add resource-specific variables.
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000978 switch(type) {
Jamie Madill183bde52014-07-02 15:31:19 -0400979 case GL_FRAGMENT_SHADER:
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +0000980 if (spec != SH_CSS_SHADERS_SPEC) {
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000981 // Set up gl_FragData. The array size.
shannonwoods@chromium.org09e09882013-05-30 00:18:25 +0000982 TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true);
alokp@chromium.org94a86ad2010-08-25 20:02:11 +0000983 fragData.setArraySize(resources.MaxDrawBuffers);
Nicolas Capensadfffe42014-06-17 02:13:36 -0400984 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData"), fragData));
Erik Dahlströmea7a2122014-11-17 16:15:57 +0100985
986 if (resources.EXT_shader_framebuffer_fetch || resources.NV_shader_framebuffer_fetch) {
987 // Set up gl_LastFragData. The array size.
988 TType lastFragData(EbtFloat, EbpMedium, EvqLastFragData, 4, 1, true);
989 lastFragData.setArraySize(resources.MaxDrawBuffers);
990 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragData"), lastFragData));
991
992 if (resources.EXT_shader_framebuffer_fetch)
993 {
994 symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_LastFragData", "GL_EXT_shader_framebuffer_fetch");
995 }
996 else if (resources.NV_shader_framebuffer_fetch)
997 {
998 symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_LastFragData", "GL_NV_shader_framebuffer_fetch");
999 }
1000 }
daniel@transgaming.com0578f812010-05-17 09:58:39 +00001001 }
1002 break;
daniel@transgaming.com0578f812010-05-17 09:58:39 +00001003 default: break;
1004 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001005}
1006
alokp@chromium.org4888ceb2010-10-01 21:13:12 +00001007void InitExtensionBehavior(const ShBuiltInResources& resources,
alokp@chromium.orgad771eb2010-09-07 17:36:23 +00001008 TExtensionBehavior& extBehavior)
1009{
1010 if (resources.OES_standard_derivatives)
zmo@google.com09c323a2011-08-12 18:22:25 +00001011 extBehavior["GL_OES_standard_derivatives"] = EBhUndefined;
1012 if (resources.OES_EGL_image_external)
1013 extBehavior["GL_OES_EGL_image_external"] = EBhUndefined;
kbr@chromium.org205fef32011-11-22 20:50:02 +00001014 if (resources.ARB_texture_rectangle)
1015 extBehavior["GL_ARB_texture_rectangle"] = EBhUndefined;
shannon.woods@transgaming.com550cd092013-02-28 23:19:54 +00001016 if (resources.EXT_draw_buffers)
1017 extBehavior["GL_EXT_draw_buffers"] = EBhUndefined;
Jamie Madill2aeb26a2013-07-08 14:02:55 -04001018 if (resources.EXT_frag_depth)
1019 extBehavior["GL_EXT_frag_depth"] = EBhUndefined;
Nicolas Capens46485082014-04-15 13:12:50 -04001020 if (resources.EXT_shader_texture_lod)
1021 extBehavior["GL_EXT_shader_texture_lod"] = EBhUndefined;
Erik Dahlströmea7a2122014-11-17 16:15:57 +01001022 if (resources.EXT_shader_framebuffer_fetch)
1023 extBehavior["GL_EXT_shader_framebuffer_fetch"] = EBhUndefined;
1024 if (resources.NV_shader_framebuffer_fetch)
1025 extBehavior["GL_NV_shader_framebuffer_fetch"] = EBhUndefined;
1026 if (resources.ARM_shader_framebuffer_fetch)
1027 extBehavior["GL_ARM_shader_framebuffer_fetch"] = EBhUndefined;
alokp@chromium.orgad771eb2010-09-07 17:36:23 +00001028}
David Yen0fbd1282015-02-02 14:46:09 -08001029
1030void ResetExtensionBehavior(TExtensionBehavior &extBehavior)
1031{
1032 for (auto ext_iter = extBehavior.begin();
1033 ext_iter != extBehavior.end();
1034 ++ext_iter)
1035 {
1036 ext_iter->second = EBhUndefined;
1037 }
1038}