blob: e88f7c463a7bfab6be7f6ce9dd9a6764387742bd [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
Arun Patole3e142e42015-02-19 09:40:39 +0530154 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "abs", int1);
155 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "abs", int2);
156 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "abs", int3);
157 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "abs", int4);
158
Nicolas Capens8f80e022013-07-11 11:20:50 -0400159 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sign", float1);
160 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sign", float2);
161 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sign", float3);
162 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sign", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000163
Arun Patole3e142e42015-02-19 09:40:39 +0530164 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "sign", int1);
165 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "sign", int2);
166 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "sign", int3);
167 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "sign", int4);
168
Nicolas Capens8f80e022013-07-11 11:20:50 -0400169 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "floor", float1);
170 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "floor", float2);
171 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "floor", float3);
172 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "floor", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000173
Nicolas Capens8f80e022013-07-11 11:20:50 -0400174 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "ceil", float1);
175 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "ceil", float2);
176 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "ceil", float3);
177 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "ceil", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000178
Nicolas Capens8f80e022013-07-11 11:20:50 -0400179 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "fract", float1);
180 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "fract", float2);
181 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "fract", float3);
182 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "fract", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000183
Nicolas Capens8f80e022013-07-11 11:20:50 -0400184 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "mod", float1, float1);
185 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mod", float2, float1);
186 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mod", float3, float1);
187 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mod", float4, float1);
188 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mod", float2, float2);
189 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mod", float3, float3);
190 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mod", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000191
Nicolas Capens8f80e022013-07-11 11:20:50 -0400192 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "min", float1, float1);
193 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "min", float2, float1);
194 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "min", float3, float1);
195 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "min", float4, float1);
196 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "min", float2, float2);
197 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "min", float3, float3);
198 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "min", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000199
Arun Patole42077bb2015-02-16 15:32:37 +0530200 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "min", int1, int1);
201 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "min", int2, int2);
202 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "min", int3, int3);
203 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "min", int4, int4);
204 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "min", int2, int1);
205 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "min", int3, int1);
206 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "min", int4, int1);
207
208 TType *uint1 = new TType(EbtUInt);
209 TType *uint2 = new TType(EbtUInt, 2);
210 TType *uint3 = new TType(EbtUInt, 3);
211 TType *uint4 = new TType(EbtUInt, 4);
212
213 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "min", uint1, uint1);
214 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "min", uint2, uint2);
215 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "min", uint3, uint3);
216 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "min", uint4, uint4);
217 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "min", uint2, uint1);
218 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "min", uint3, uint1);
219 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "min", uint4, uint1);
220
Nicolas Capens8f80e022013-07-11 11:20:50 -0400221 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "max", float1, float1);
222 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "max", float2, float1);
223 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "max", float3, float1);
224 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "max", float4, float1);
225 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "max", float2, float2);
226 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "max", float3, float3);
227 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "max", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000228
Arun Patole42077bb2015-02-16 15:32:37 +0530229 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "max", int1, int1);
230 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "max", int2, int2);
231 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "max", int3, int3);
232 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "max", int4, int4);
233 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "max", int2, int1);
234 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "max", int3, int1);
235 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "max", int4, int1);
236
237 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "max", uint1, uint1);
238 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "max", uint2, uint2);
239 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "max", uint3, uint3);
240 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "max", uint4, uint4);
241 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "max", uint2, uint1);
242 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "max", uint3, uint1);
243 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "max", uint4, uint1);
244
Nicolas Capens8f80e022013-07-11 11:20:50 -0400245 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "clamp", float1, float1, float1);
246 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "clamp", float2, float1, float1);
247 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "clamp", float3, float1, float1);
248 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "clamp", float4, float1, float1);
249 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "clamp", float2, float2, float2);
250 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "clamp", float3, float3, float3);
251 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "clamp", float4, float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000252
Arun Patole42077bb2015-02-16 15:32:37 +0530253 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "clamp", int1, int1, int1);
254 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "clamp", int2, int1, int1);
255 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "clamp", int3, int1, int1);
256 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "clamp", int4, int1, int1);
257 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "clamp", int2, int2, int2);
258 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "clamp", int3, int3, int3);
259 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "clamp", int4, int4, int4);
260
261 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "clamp", uint1, uint1, uint1);
262 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "clamp", uint2, uint1, uint1);
263 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "clamp", uint3, uint1, uint1);
264 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "clamp", uint4, uint1, uint1);
265 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "clamp", uint2, uint2, uint2);
266 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "clamp", uint3, uint3, uint3);
267 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "clamp", uint4, uint4, uint4);
268
Nicolas Capens8f80e022013-07-11 11:20:50 -0400269 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "mix", float1, float1, float1);
270 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mix", float2, float2, float1);
271 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mix", float3, float3, float1);
272 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mix", float4, float4, float1);
273 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mix", float2, float2, float2);
274 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mix", float3, float3, float3);
275 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mix", float4, float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000276
Nicolas Capens8f80e022013-07-11 11:20:50 -0400277 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "step", float1, float1);
278 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "step", float2, float2);
279 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "step", float3, float3);
280 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "step", float4, float4);
281 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "step", float1, float2);
282 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "step", float1, float3);
283 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "step", float1, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000284
Nicolas Capens8f80e022013-07-11 11:20:50 -0400285 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "smoothstep", float1, float1, float1);
286 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "smoothstep", float2, float2, float2);
287 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "smoothstep", float3, float3, float3);
288 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "smoothstep", float4, float4, float4);
289 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "smoothstep", float1, float1, float2);
290 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "smoothstep", float1, float1, float3);
291 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "smoothstep", float1, float1, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000292
Arun Patole0c1726e2015-02-18 14:35:02 +0530293 TType *bool1 = new TType(EbtBool);
294 TType *bool2 = new TType(EbtBool, 2);
295 TType *bool3 = new TType(EbtBool, 3);
296 TType *bool4 = new TType(EbtBool, 4);
297
298 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool1, "isnan", float1);
299 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "isnan", float2);
300 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "isnan", float3);
301 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "isnan", float4);
302
303 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool1, "isinf", float1);
304 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "isinf", float2);
305 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "isinf", float3);
306 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "isinf", float4);
307
Olli Etuahoe8d2c072015-01-08 16:33:54 +0200308 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "floatBitsToInt", float1);
309 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "floatBitsToInt", float2);
310 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "floatBitsToInt", float3);
311 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "floatBitsToInt", float4);
312
313 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "floatBitsToUint", float1);
314 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "floatBitsToUint", float2);
315 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "floatBitsToUint", float3);
316 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "floatBitsToUint", float4);
317
318 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "intBitsToFloat", int1);
319 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "intBitsToFloat", int2);
320 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "intBitsToFloat", int3);
321 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "intBitsToFloat", int4);
322
323 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "uintBitsToFloat", uint1);
324 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "uintBitsToFloat", uint2);
325 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "uintBitsToFloat", uint3);
326 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "uintBitsToFloat", uint4);
327
Olli Etuaho7700ff62015-01-15 12:16:29 +0200328 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "packSnorm2x16", float2);
329 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "packUnorm2x16", float2);
330 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "packHalf2x16", float2);
331 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "unpackSnorm2x16", uint1);
332 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "unpackUnorm2x16", uint1);
333 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "unpackHalf2x16", uint1);
334
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000335 //
336 // Geometric Functions.
337 //
Nicolas Capens8f80e022013-07-11 11:20:50 -0400338 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float1);
339 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float2);
340 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float3);
341 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000342
Nicolas Capens8f80e022013-07-11 11:20:50 -0400343 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float1, float1);
344 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float2, float2);
345 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float3, float3);
346 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000347
Nicolas Capens8f80e022013-07-11 11:20:50 -0400348 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float1, float1);
349 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float2, float2);
350 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float3, float3);
351 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000352
Nicolas Capens8f80e022013-07-11 11:20:50 -0400353 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "cross", float3, float3);
354 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "normalize", float1);
355 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "normalize", float2);
356 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "normalize", float3);
357 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "normalize", float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000358
Nicolas Capens8f80e022013-07-11 11:20:50 -0400359 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "faceforward", float1, float1, float1);
360 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "faceforward", float2, float2, float2);
361 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "faceforward", float3, float3, float3);
362 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "faceforward", float4, float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000363
Nicolas Capens8f80e022013-07-11 11:20:50 -0400364 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "reflect", float1, float1);
365 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "reflect", float2, float2);
366 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "reflect", float3, float3);
367 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "reflect", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000368
Nicolas Capens8f80e022013-07-11 11:20:50 -0400369 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "refract", float1, float1, float1);
370 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "refract", float2, float2, float1);
371 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "refract", float3, float3, float1);
372 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "refract", float4, float4, float1);
Nicolas Capens49a88872013-06-20 09:54:03 -0400373
Nicolas Capensc9508842014-02-14 17:48:50 -0500374 TType *mat2 = new TType(EbtFloat, 2, 2);
375 TType *mat3 = new TType(EbtFloat, 3, 3);
376 TType *mat4 = new TType(EbtFloat, 4, 4);
Olli Etuahoe39706d2014-12-30 16:40:36 +0200377 TType *mat2x3 = new TType(EbtFloat, 2, 3);
378 TType *mat3x2 = new TType(EbtFloat, 3, 2);
379 TType *mat2x4 = new TType(EbtFloat, 2, 4);
380 TType *mat4x2 = new TType(EbtFloat, 4, 2);
381 TType *mat3x4 = new TType(EbtFloat, 3, 4);
382 TType *mat4x3 = new TType(EbtFloat, 4, 3);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000383
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000384 //
385 // Matrix Functions.
386 //
Nicolas Capens8f80e022013-07-11 11:20:50 -0400387 symbolTable.insertBuiltIn(COMMON_BUILTINS, mat2, "matrixCompMult", mat2, mat2);
388 symbolTable.insertBuiltIn(COMMON_BUILTINS, mat3, "matrixCompMult", mat3, mat3);
389 symbolTable.insertBuiltIn(COMMON_BUILTINS, mat4, "matrixCompMult", mat4, mat4);
Olli Etuahoe39706d2014-12-30 16:40:36 +0200390 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2x3, "matrixCompMult", mat2x3, mat2x3);
391 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3x2, "matrixCompMult", mat3x2, mat3x2);
392 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2x4, "matrixCompMult", mat2x4, mat2x4);
393 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4x2, "matrixCompMult", mat4x2, mat4x2);
394 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3x4, "matrixCompMult", mat3x4, mat3x4);
395 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4x3, "matrixCompMult", mat4x3, mat4x3);
396
397 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2, "outerProduct", float2, float2);
398 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3, "outerProduct", float3, float3);
399 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4, "outerProduct", float4, float4);
400 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2x3, "outerProduct", float3, float2);
401 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3x2, "outerProduct", float2, float3);
402 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2x4, "outerProduct", float4, float2);
403 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4x2, "outerProduct", float2, float4);
404 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3x4, "outerProduct", float4, float3);
405 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4x3, "outerProduct", float3, float4);
406
407 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2, "transpose", mat2);
408 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3, "transpose", mat3);
409 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4, "transpose", mat4);
410 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2x3, "transpose", mat3x2);
411 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3x2, "transpose", mat2x3);
412 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2x4, "transpose", mat4x2);
413 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4x2, "transpose", mat2x4);
414 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3x4, "transpose", mat4x3);
415 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4x3, "transpose", mat3x4);
416
417 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "determinant", mat2);
418 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "determinant", mat3);
419 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "determinant", mat4);
Nicolas Capens49a88872013-06-20 09:54:03 -0400420
Olli Etuahoabf6dad2015-01-14 14:45:16 +0200421 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat2, "inverse", mat2);
422 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3, "inverse", mat3);
423 symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4, "inverse", mat4);
424
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000425 //
426 // Vector relational functions.
427 //
Nicolas Capens8f80e022013-07-11 11:20:50 -0400428 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThan", float2, float2);
429 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThan", float3, float3);
430 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThan", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000431
Nicolas Capens8f80e022013-07-11 11:20:50 -0400432 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThan", int2, int2);
433 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThan", int3, int3);
434 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThan", int4, int4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000435
Arun Patole2b455732015-02-17 20:24:59 +0530436 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "lessThan", uint2, uint2);
437 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "lessThan", uint3, uint3);
438 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "lessThan", uint4, uint4);
439
Nicolas Capens8f80e022013-07-11 11:20:50 -0400440 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThanEqual", float2, float2);
441 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThanEqual", float3, float3);
442 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThanEqual", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000443
Nicolas Capens8f80e022013-07-11 11:20:50 -0400444 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThanEqual", int2, int2);
445 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThanEqual", int3, int3);
446 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThanEqual", int4, int4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000447
Arun Patole2b455732015-02-17 20:24:59 +0530448 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "lessThanEqual", uint2, uint2);
449 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "lessThanEqual", uint3, uint3);
450 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "lessThanEqual", uint4, uint4);
451
Nicolas Capens8f80e022013-07-11 11:20:50 -0400452 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThan", float2, float2);
453 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThan", float3, float3);
454 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThan", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000455
Nicolas Capens8f80e022013-07-11 11:20:50 -0400456 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThan", int2, int2);
457 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThan", int3, int3);
458 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThan", int4, int4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000459
Arun Patole2b455732015-02-17 20:24:59 +0530460 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "greaterThan", uint2, uint2);
461 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "greaterThan", uint3, uint3);
462 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "greaterThan", uint4, uint4);
463
Nicolas Capens8f80e022013-07-11 11:20:50 -0400464 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThanEqual", float2, float2);
465 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThanEqual", float3, float3);
466 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThanEqual", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000467
Nicolas Capens8f80e022013-07-11 11:20:50 -0400468 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThanEqual", int2, int2);
469 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThanEqual", int3, int3);
470 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThanEqual", int4, int4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000471
Arun Patole2b455732015-02-17 20:24:59 +0530472 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "greaterThanEqual", uint2, uint2);
473 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "greaterThanEqual", uint3, uint3);
474 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "greaterThanEqual", uint4, uint4);
475
Nicolas Capens8f80e022013-07-11 11:20:50 -0400476 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", float2, float2);
477 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", float3, float3);
478 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000479
Nicolas Capens8f80e022013-07-11 11:20:50 -0400480 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", int2, int2);
481 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", int3, int3);
482 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", int4, int4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000483
Arun Patole2b455732015-02-17 20:24:59 +0530484 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "equal", uint2, uint2);
485 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "equal", uint3, uint3);
486 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "equal", uint4, uint4);
487
Nicolas Capens8f80e022013-07-11 11:20:50 -0400488 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", bool2, bool2);
489 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", bool3, bool3);
490 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", bool4, bool4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000491
Nicolas Capens8f80e022013-07-11 11:20:50 -0400492 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", float2, float2);
493 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", float3, float3);
494 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", float4, float4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000495
Nicolas Capens8f80e022013-07-11 11:20:50 -0400496 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", int2, int2);
497 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", int3, int3);
498 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", int4, int4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000499
Arun Patole2b455732015-02-17 20:24:59 +0530500 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "notEqual", uint2, uint2);
501 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "notEqual", uint3, uint3);
502 symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "notEqual", uint4, uint4);
503
Nicolas Capens8f80e022013-07-11 11:20:50 -0400504 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", bool2, bool2);
505 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", bool3, bool3);
506 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", bool4, bool4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000507
Nicolas Capens8f80e022013-07-11 11:20:50 -0400508 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool2);
509 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool3);
510 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000511
Nicolas Capens8f80e022013-07-11 11:20:50 -0400512 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool2);
513 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool3);
514 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000515
Nicolas Capens8f80e022013-07-11 11:20:50 -0400516 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "not", bool2);
517 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "not", bool3);
518 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "not", bool4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000519
Nicolas Capensc9508842014-02-14 17:48:50 -0500520 TType *sampler2D = new TType(EbtSampler2D);
521 TType *samplerCube = new TType(EbtSamplerCube);
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000522
523 //
524 // Texture Functions for GLSL ES 1.0
525 //
Nicolas Capens8f80e022013-07-11 11:20:50 -0400526 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, float2);
527 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float3);
528 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float4);
529 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, float3);
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000530
Nicolas Capens49a88872013-06-20 09:54:03 -0400531 if (resources.OES_EGL_image_external)
532 {
Nicolas Capensc9508842014-02-14 17:48:50 -0500533 TType *samplerExternalOES = new TType(EbtSamplerExternalOES);
Nicolas Capens49a88872013-06-20 09:54:03 -0400534
Nicolas Capens8f80e022013-07-11 11:20:50 -0400535 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", samplerExternalOES, float2);
536 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, float3);
537 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, float4);
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000538 }
539
Nicolas Capens49a88872013-06-20 09:54:03 -0400540 if (resources.ARB_texture_rectangle)
541 {
Nicolas Capensc9508842014-02-14 17:48:50 -0500542 TType *sampler2DRect = new TType(EbtSampler2DRect);
Nicolas Capens49a88872013-06-20 09:54:03 -0400543
Nicolas Capens8f80e022013-07-11 11:20:50 -0400544 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRect", sampler2DRect, float2);
545 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect, float3);
546 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect, float4);
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000547 }
548
Nicolas Capens46485082014-04-15 13:12:50 -0400549 if (resources.EXT_shader_texture_lod)
550 {
551 /* The *Grad* variants are new to both vertex and fragment shaders; the fragment
552 * shader specific pieces are added separately below.
553 */
554 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DGradEXT", sampler2D, float2, float2, float2);
555 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjGradEXT", sampler2D, float3, float2, float2);
556 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjGradEXT", sampler2D, float4, float2, float2);
557 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeGradEXT", samplerCube, float3, float3, float3);
558 }
559
Jamie Madill183bde52014-07-02 15:31:19 -0400560 if (type == GL_FRAGMENT_SHADER)
Nicolas Capens49a88872013-06-20 09:54:03 -0400561 {
Nicolas Capens8f80e022013-07-11 11:20:50 -0400562 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, float2, float1);
563 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float3, float1);
564 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, float4, float1);
565 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, float3, float1);
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000566
Nicolas Capens49a88872013-06-20 09:54:03 -0400567 if (resources.OES_standard_derivatives)
568 {
Nicolas Capens8f80e022013-07-11 11:20:50 -0400569 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "dFdx", float1);
570 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "dFdx", float2);
571 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "dFdx", float3);
572 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "dFdx", float4);
Nicolas Capens46485082014-04-15 13:12:50 -0400573
Nicolas Capens8f80e022013-07-11 11:20:50 -0400574 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "dFdy", float1);
575 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "dFdy", float2);
576 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "dFdy", float3);
577 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "dFdy", float4);
Nicolas Capens49a88872013-06-20 09:54:03 -0400578
Nicolas Capens8f80e022013-07-11 11:20:50 -0400579 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "fwidth", float1);
580 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "fwidth", float2);
581 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "fwidth", float3);
582 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "fwidth", float4);
Nicolas Capens49a88872013-06-20 09:54:03 -0400583 }
Nicolas Capens46485082014-04-15 13:12:50 -0400584
585 if (resources.EXT_shader_texture_lod)
586 {
587 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DLodEXT", sampler2D, float2, float1);
588 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLodEXT", sampler2D, float3, float1);
589 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLodEXT", sampler2D, float4, float1);
590 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeLodEXT", samplerCube, float3, float1);
591 }
Nicolas Capens49a88872013-06-20 09:54:03 -0400592 }
593
Jamie Madill183bde52014-07-02 15:31:19 -0400594 if(type == GL_VERTEX_SHADER)
Nicolas Capens49a88872013-06-20 09:54:03 -0400595 {
Nicolas Capens8f80e022013-07-11 11:20:50 -0400596 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DLod", sampler2D, float2, float1);
597 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, float3, float1);
598 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, float4, float1);
599 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeLod", samplerCube, float3, float1);
Nicolas Capens49a88872013-06-20 09:54:03 -0400600 }
shannonwoods@chromium.orgc6ac65f2013-05-30 00:02:50 +0000601
Nicolas Capens4fd5e4a2014-02-14 18:17:15 -0500602 TType *gvec4 = new TType(EbtGVec4);
603
604 TType *gsampler2D = new TType(EbtGSampler2D);
605 TType *gsamplerCube = new TType(EbtGSamplerCube);
606 TType *gsampler3D = new TType(EbtGSampler3D);
607 TType *gsampler2DArray = new TType(EbtGSampler2DArray);
Nicolas Capens73f5bf62013-06-17 16:13:33 -0400608
shannonwoods@chromium.orgc6ac65f2013-05-30 00:02:50 +0000609 //
610 // Texture Functions for GLSL ES 3.0
611 //
Nicolas Capens4fd5e4a2014-02-14 18:17:15 -0500612 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2D, float2);
613 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler3D, float3);
614 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsamplerCube, float3);
615 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2DArray, float3);
616 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float3);
617 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float4);
618 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler3D, float4);
619 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler2D, float2, float1);
620 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler3D, float3, float1);
621 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsamplerCube, float3, float1);
622 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLod", gsampler2DArray, float3, float1);
shannonwoods@chromium.orgc6ac65f2013-05-30 00:02:50 +0000623
Jamie Madill183bde52014-07-02 15:31:19 -0400624 if (type == GL_FRAGMENT_SHADER)
Nicolas Capens67a819f2013-07-09 12:08:58 -0400625 {
Nicolas Capens4fd5e4a2014-02-14 18:17:15 -0500626 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2D, float2, float1);
627 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler3D, float3, float1);
628 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsamplerCube, float3, float1);
629 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texture", gsampler2DArray, float3, float1);
630 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float3, float1);
631 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler2D, float4, float1);
632 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProj", gsampler3D, float4, float1);
Nicolas Capens67a819f2013-07-09 12:08:58 -0400633 }
634
Nicolas Capensc9508842014-02-14 17:48:50 -0500635 TType *sampler2DShadow = new TType(EbtSampler2DShadow);
636 TType *samplerCubeShadow = new TType(EbtSamplerCubeShadow);
637 TType *sampler2DArrayShadow = new TType(EbtSampler2DArrayShadow);
Nicolas Capens77c9d1a2013-07-11 11:10:34 -0400638
Nicolas Capens8f80e022013-07-11 11:20:50 -0400639 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DShadow, float3);
640 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", samplerCubeShadow, float4);
641 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DArrayShadow, float4);
642 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProj", sampler2DShadow, float4);
Jamie Madill16a1c072013-10-22 15:42:15 -0400643 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureLod", sampler2DShadow, float3, float1);
Nicolas Capens77c9d1a2013-07-11 11:10:34 -0400644
Jamie Madill183bde52014-07-02 15:31:19 -0400645 if (type == GL_FRAGMENT_SHADER)
Nicolas Capens77c9d1a2013-07-11 11:10:34 -0400646 {
Nicolas Capens8f80e022013-07-11 11:20:50 -0400647 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", sampler2DShadow, float3, float1);
648 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "texture", samplerCubeShadow, float4, float1);
Nicolas Capens8f80e022013-07-11 11:20:50 -0400649 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProj", sampler2DShadow, float4, float1);
Nicolas Capens77c9d1a2013-07-11 11:10:34 -0400650 }
651
Nicolas Capens4fd5e4a2014-02-14 18:17:15 -0500652 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", gsampler2D, int1);
653 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", gsampler3D, int1);
654 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", gsamplerCube, int1);
655 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", gsampler2DArray, int1);
Nicolas Capens8f80e022013-07-11 11:20:50 -0400656 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", sampler2DShadow, int1);
657 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", samplerCubeShadow, int1);
658 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", sampler2DArrayShadow, int1);
Nicolas Capens75fb4752013-07-10 15:14:47 -0400659
Jamie Madill183bde52014-07-02 15:31:19 -0400660 if(type == GL_FRAGMENT_SHADER)
Nicolas Capens49a88872013-06-20 09:54:03 -0400661 {
Nicolas Capens8f80e022013-07-11 11:20:50 -0400662 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "dFdx", float1);
663 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "dFdx", float2);
664 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "dFdx", float3);
665 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "dFdx", float4);
Nicolas Capens49a88872013-06-20 09:54:03 -0400666
Nicolas Capens8f80e022013-07-11 11:20:50 -0400667 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "dFdy", float1);
668 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "dFdy", float2);
669 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "dFdy", float3);
670 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "dFdy", float4);
shannonwoods@chromium.orgc6ac65f2013-05-30 00:02:50 +0000671
Nicolas Capens8f80e022013-07-11 11:20:50 -0400672 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "fwidth", float1);
673 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "fwidth", float2);
674 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "fwidth", float3);
675 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "fwidth", float4);
alokp@chromium.org06098892010-08-26 19:36:42 +0000676 }
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000677
Nicolas Capens4fd5e4a2014-02-14 18:17:15 -0500678 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2);
679 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler3D, float3, int3);
680 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureOffset", sampler2DShadow, float3, int2);
681 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2DArray, float3, int2);
682
Jamie Madill183bde52014-07-02 15:31:19 -0400683 if(type == GL_FRAGMENT_SHADER)
Nicolas Capens4fd5e4a2014-02-14 18:17:15 -0500684 {
685 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2, float1);
686 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler3D, float3, int3, float1);
687 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureOffset", sampler2DShadow, float3, int2, float1);
688 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2DArray, float3, int2, float1);
689 }
Nicolas Capens1fbc2872014-01-03 14:12:09 -0500690
Nicolas Capensdf86c6b2014-02-14 20:09:17 -0500691 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float3, int2);
692 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float4, int2);
693 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler3D, float4, int3);
694 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjOffset", sampler2DShadow, float4, int2);
695
Jamie Madill183bde52014-07-02 15:31:19 -0400696 if(type == GL_FRAGMENT_SHADER)
Nicolas Capensdf86c6b2014-02-14 20:09:17 -0500697 {
698 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float3, int2, float1);
699 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float4, int2, float1);
700 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler3D, float4, int3, float1);
701 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjOffset", sampler2DShadow, float4, int2, float1);
702 }
703
704 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler2D, float2, float1, int2);
705 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler3D, float3, float1, int3);
706 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureLodOffset", sampler2DShadow, float3, float1, int2);
707 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureLodOffset", gsampler2DArray, float3, float1, int2);
708
Nicolas Capens2adc2562014-02-14 23:50:59 -0500709 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler2D, float3, float1);
710 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler2D, float4, float1);
711 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLod", gsampler3D, float4, float1);
712 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjLod", sampler2DShadow, float4, float1);
713
714 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler2D, float3, float1, int2);
715 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler2D, float4, float1, int2);
716 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjLodOffset", gsampler3D, float4, float1, int3);
717 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjLodOffset", sampler2DShadow, float4, float1, int2);
718
Nicolas Capensfc014542014-02-18 14:47:13 -0500719 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler2D, int2, int1);
720 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler3D, int3, int1);
721 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetch", gsampler2DArray, int3, int1);
722
723 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler2D, int2, int1, int2);
724 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler3D, int3, int1, int3);
725 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "texelFetchOffset", gsampler2DArray, int3, int1, int2);
726
Nicolas Capensd11d5492014-02-19 17:06:10 -0500727 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler2D, float2, float2, float2);
728 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler3D, float3, float3, float3);
729 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsamplerCube, float3, float3, float3);
730 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", sampler2DShadow, float3, float2, float2);
731 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", samplerCubeShadow, float4, float3, float3);
732 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGrad", gsampler2DArray, float3, float2, float2);
733 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGrad", sampler2DArrayShadow, float4, float2, float2);
734
Nicolas Capensbf7db102014-02-19 17:20:28 -0500735 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler2D, float2, float2, float2, int2);
736 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler3D, float3, float3, float3, int3);
737 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGradOffset", sampler2DShadow, float3, float2, float2, int2);
738 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureGradOffset", gsampler2DArray, float3, float2, float2, int2);
739 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureGradOffset", sampler2DArrayShadow, float4, float2, float2, int2);
740
Nicolas Capensf7378e32014-02-19 17:29:32 -0500741 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler2D, float3, float2, float2);
742 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler2D, float4, float2, float2);
743 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGrad", gsampler3D, float4, float3, float3);
744 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjGrad", sampler2DShadow, float4, float2, float2);
745
746 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler2D, float3, float2, float2, int2);
747 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler2D, float4, float2, float2, int2);
748 symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjGradOffset", gsampler3D, float4, float3, float3, int3);
749 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjGradOffset", sampler2DShadow, float4, float2, float2, int2);
750
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000751 //
752 // Depth range in window coordinates
753 //
Jamie Madill98493dd2013-07-08 14:39:03 -0400754 TFieldList *fields = NewPoolTFieldList();
Jamie Madill37f77d22014-04-30 16:10:13 -0400755 TSourceLoc zeroSourceLoc = {0, 0, 0, 0};
Jamie Madill98493dd2013-07-08 14:39:03 -0400756 TField *near = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("near"), zeroSourceLoc);
757 TField *far = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("far"), zeroSourceLoc);
758 TField *diff = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("diff"), zeroSourceLoc);
759 fields->push_back(near);
760 fields->push_back(far);
761 fields->push_back(diff);
762 TStructure *depthRangeStruct = new TStructure(NewPoolTString("gl_DepthRangeParameters"), fields);
763 TVariable *depthRangeParameters = new TVariable(&depthRangeStruct->name(), depthRangeStruct, true);
Nicolas Capensadfffe42014-06-17 02:13:36 -0400764 symbolTable.insert(COMMON_BUILTINS, depthRangeParameters);
Jamie Madill98493dd2013-07-08 14:39:03 -0400765 TVariable *depthRange = new TVariable(NewPoolTString("gl_DepthRange"), TType(depthRangeStruct));
Nicolas Capens49a88872013-06-20 09:54:03 -0400766 depthRange->setQualifier(EvqUniform);
Nicolas Capensadfffe42014-06-17 02:13:36 -0400767 symbolTable.insert(COMMON_BUILTINS, depthRange);
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000768
Nicolas Capens49a88872013-06-20 09:54:03 -0400769 //
770 // Implementation dependent built-in constants.
771 //
772 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexAttribs", resources.MaxVertexAttribs);
773 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexUniformVectors", resources.MaxVertexUniformVectors);
774 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexTextureImageUnits", resources.MaxVertexTextureImageUnits);
775 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxCombinedTextureImageUnits", resources.MaxCombinedTextureImageUnits);
776 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxTextureImageUnits", resources.MaxTextureImageUnits);
777 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxFragmentUniformVectors", resources.MaxFragmentUniformVectors);
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000778
Nicolas Capens49a88872013-06-20 09:54:03 -0400779 symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxVaryingVectors", resources.MaxVaryingVectors);
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +0000780
781 if (spec != SH_CSS_SHADERS_SPEC)
shannon.woods%transgaming.com@gtempaccount.com5209de82013-04-13 03:41:53 +0000782 {
Jamie Madill455a6f52013-10-17 10:45:46 -0400783 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxDrawBuffers", resources.MaxDrawBuffers);
shannon.woods%transgaming.com@gtempaccount.com5209de82013-04-13 03:41:53 +0000784 }
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000785
Nicolas Capens49a88872013-06-20 09:54:03 -0400786 symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxVertexOutputVectors", resources.MaxVertexOutputVectors);
787 symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxFragmentInputVectors", resources.MaxFragmentInputVectors);
788 symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MinProgramTexelOffset", resources.MinProgramTexelOffset);
789 symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxProgramTexelOffset", resources.MaxProgramTexelOffset);
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000790}
791
Jamie Madill183bde52014-07-02 15:31:19 -0400792void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec,
Nicolas Capens49a88872013-06-20 09:54:03 -0400793 const ShBuiltInResources &resources,
794 TSymbolTable &symbolTable)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000795{
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000796 //
797 // First, insert some special built-in variables that are not in
798 // the built-in header files.
799 //
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000800 switch(type) {
Jamie Madill183bde52014-07-02 15:31:19 -0400801 case GL_FRAGMENT_SHADER:
Nicolas Capensadfffe42014-06-17 02:13:36 -0400802 symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FragCoord"), TType(EbtFloat, EbpMedium, EvqFragCoord, 4)));
803 symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool, EbpUndefined, EvqFrontFacing, 1)));
804 symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointCoord"), TType(EbtFloat, EbpMedium, EvqPointCoord, 2)));
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +0000805
806 //
807 // In CSS Shaders, gl_FragColor, gl_FragData, and gl_MaxDrawBuffers are not available.
808 // Instead, css_MixColor and css_ColorMatrix are available.
809 //
810 if (spec != SH_CSS_SHADERS_SPEC) {
Nicolas Capensadfffe42014-06-17 02:13:36 -0400811 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EbpMedium, EvqFragColor, 4)));
812 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqFragData, 4)));
Jamie Madill2aeb26a2013-07-08 14:02:55 -0400813 if (resources.EXT_frag_depth) {
Nicolas Capensadfffe42014-06-17 02:13:36 -0400814 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragDepthEXT"), TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepth, 1)));
Jamie Madill2aeb26a2013-07-08 14:02:55 -0400815 symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_FragDepthEXT", "GL_EXT_frag_depth");
816 }
Erik Dahlströmea7a2122014-11-17 16:15:57 +0100817 if (resources.EXT_shader_framebuffer_fetch)
818 {
819 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqLastFragData, 4)));
820 }
821 else if (resources.NV_shader_framebuffer_fetch)
822 {
823 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragColor"), TType(EbtFloat, EbpMedium, EvqLastFragColor, 4)));
824 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqLastFragData, 4)));
825 }
826 else if (resources.ARM_shader_framebuffer_fetch)
827 {
828 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragColorARM"), TType(EbtFloat, EbpMedium, EvqLastFragColor, 4)));
829 }
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +0000830 } else {
Nicolas Capensadfffe42014-06-17 02:13:36 -0400831 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("css_MixColor"), TType(EbtFloat, EbpMedium, EvqGlobal, 4)));
832 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("css_ColorMatrix"), TType(EbtFloat, EbpMedium, EvqGlobal, 4, 4)));
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +0000833 }
834
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000835 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000836
Jamie Madill183bde52014-07-02 15:31:19 -0400837 case GL_VERTEX_SHADER:
Nicolas Capensadfffe42014-06-17 02:13:36 -0400838 symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EbpHigh, EvqPosition, 4)));
839 symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EbpMedium, EvqPointSize, 1)));
Gregoire Payen de La Garanderieb3dced22015-01-12 14:54:55 +0000840 symbolTable.insert(ESSL3_BUILTINS, new TVariable(NewPoolTString("gl_InstanceID"), TType(EbtInt, EbpHigh, EvqInstanceID, 1)));
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000841 break;
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000842
843 default: assert(false && "Language not supported");
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000844 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000845
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000846 //
847 // Next, identify which built-ins from the already loaded headers have
848 // a mapping to an operator. Those that are not identified as such are
849 // expected to be resolved through a library of functions, versus as
850 // operations.
851 //
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000852 symbolTable.relateToOperator(COMMON_BUILTINS, "matrixCompMult", EOpMul);
Olli Etuahoe39706d2014-12-30 16:40:36 +0200853 symbolTable.relateToOperator(ESSL3_BUILTINS, "matrixCompMult", EOpMul);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000854
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000855 symbolTable.relateToOperator(COMMON_BUILTINS, "equal", EOpVectorEqual);
856 symbolTable.relateToOperator(COMMON_BUILTINS, "notEqual", EOpVectorNotEqual);
857 symbolTable.relateToOperator(COMMON_BUILTINS, "lessThan", EOpLessThan);
858 symbolTable.relateToOperator(COMMON_BUILTINS, "greaterThan", EOpGreaterThan);
859 symbolTable.relateToOperator(COMMON_BUILTINS, "lessThanEqual", EOpLessThanEqual);
860 symbolTable.relateToOperator(COMMON_BUILTINS, "greaterThanEqual", EOpGreaterThanEqual);
Arun Patole2b455732015-02-17 20:24:59 +0530861
862 symbolTable.relateToOperator(ESSL3_BUILTINS, "equal", EOpVectorEqual);
863 symbolTable.relateToOperator(ESSL3_BUILTINS, "notEqual", EOpVectorNotEqual);
864 symbolTable.relateToOperator(ESSL3_BUILTINS, "lessThan", EOpLessThan);
865 symbolTable.relateToOperator(ESSL3_BUILTINS, "greaterThan", EOpGreaterThan);
866 symbolTable.relateToOperator(ESSL3_BUILTINS, "lessThanEqual", EOpLessThanEqual);
867 symbolTable.relateToOperator(ESSL3_BUILTINS, "greaterThanEqual", EOpGreaterThanEqual);
868
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000869 symbolTable.relateToOperator(COMMON_BUILTINS, "radians", EOpRadians);
870 symbolTable.relateToOperator(COMMON_BUILTINS, "degrees", EOpDegrees);
871 symbolTable.relateToOperator(COMMON_BUILTINS, "sin", EOpSin);
872 symbolTable.relateToOperator(COMMON_BUILTINS, "cos", EOpCos);
873 symbolTable.relateToOperator(COMMON_BUILTINS, "tan", EOpTan);
874 symbolTable.relateToOperator(COMMON_BUILTINS, "asin", EOpAsin);
875 symbolTable.relateToOperator(COMMON_BUILTINS, "acos", EOpAcos);
876 symbolTable.relateToOperator(COMMON_BUILTINS, "atan", EOpAtan);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000877
Olli Etuaho5c9cd3d2014-12-18 13:04:25 +0200878 symbolTable.relateToOperator(ESSL3_BUILTINS, "sinh", EOpSinh);
879 symbolTable.relateToOperator(ESSL3_BUILTINS, "cosh", EOpCosh);
880 symbolTable.relateToOperator(ESSL3_BUILTINS, "tanh", EOpTanh);
881 symbolTable.relateToOperator(ESSL3_BUILTINS, "asinh", EOpAsinh);
882 symbolTable.relateToOperator(ESSL3_BUILTINS, "acosh", EOpAcosh);
883 symbolTable.relateToOperator(ESSL3_BUILTINS, "atanh", EOpAtanh);
884
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000885 symbolTable.relateToOperator(COMMON_BUILTINS, "pow", EOpPow);
886 symbolTable.relateToOperator(COMMON_BUILTINS, "exp2", EOpExp2);
887 symbolTable.relateToOperator(COMMON_BUILTINS, "log", EOpLog);
888 symbolTable.relateToOperator(COMMON_BUILTINS, "exp", EOpExp);
889 symbolTable.relateToOperator(COMMON_BUILTINS, "log2", EOpLog2);
890 symbolTable.relateToOperator(COMMON_BUILTINS, "sqrt", EOpSqrt);
891 symbolTable.relateToOperator(COMMON_BUILTINS, "inversesqrt", EOpInverseSqrt);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000892
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000893 symbolTable.relateToOperator(COMMON_BUILTINS, "abs", EOpAbs);
894 symbolTable.relateToOperator(COMMON_BUILTINS, "sign", EOpSign);
895 symbolTable.relateToOperator(COMMON_BUILTINS, "floor", EOpFloor);
896 symbolTable.relateToOperator(COMMON_BUILTINS, "ceil", EOpCeil);
897 symbolTable.relateToOperator(COMMON_BUILTINS, "fract", EOpFract);
898 symbolTable.relateToOperator(COMMON_BUILTINS, "mod", EOpMod);
899 symbolTable.relateToOperator(COMMON_BUILTINS, "min", EOpMin);
900 symbolTable.relateToOperator(COMMON_BUILTINS, "max", EOpMax);
901 symbolTable.relateToOperator(COMMON_BUILTINS, "clamp", EOpClamp);
902 symbolTable.relateToOperator(COMMON_BUILTINS, "mix", EOpMix);
903 symbolTable.relateToOperator(COMMON_BUILTINS, "step", EOpStep);
904 symbolTable.relateToOperator(COMMON_BUILTINS, "smoothstep", EOpSmoothStep);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000905
Arun Patole3e142e42015-02-19 09:40:39 +0530906 symbolTable.relateToOperator(ESSL3_BUILTINS, "abs", EOpAbs);
907 symbolTable.relateToOperator(ESSL3_BUILTINS, "sign", EOpSign);
Arun Patole42077bb2015-02-16 15:32:37 +0530908 symbolTable.relateToOperator(ESSL3_BUILTINS, "min", EOpMin);
909 symbolTable.relateToOperator(ESSL3_BUILTINS, "max", EOpMax);
910 symbolTable.relateToOperator(ESSL3_BUILTINS, "clamp", EOpClamp);
Arun Patole0c1726e2015-02-18 14:35:02 +0530911 symbolTable.relateToOperator(ESSL3_BUILTINS, "isnan", EOpIsNan);
912 symbolTable.relateToOperator(ESSL3_BUILTINS, "isinf", EOpIsInf);
Arun Patole42077bb2015-02-16 15:32:37 +0530913
Olli Etuahoe8d2c072015-01-08 16:33:54 +0200914 symbolTable.relateToOperator(ESSL3_BUILTINS, "floatBitsToInt", EOpFloatBitsToInt);
915 symbolTable.relateToOperator(ESSL3_BUILTINS, "floatBitsToUint", EOpFloatBitsToUint);
916 symbolTable.relateToOperator(ESSL3_BUILTINS, "intBitsToFloat", EOpIntBitsToFloat);
917 symbolTable.relateToOperator(ESSL3_BUILTINS, "uintBitsToFloat", EOpUintBitsToFloat);
918
Olli Etuaho7700ff62015-01-15 12:16:29 +0200919 symbolTable.relateToOperator(ESSL3_BUILTINS, "packSnorm2x16", EOpPackSnorm2x16);
920 symbolTable.relateToOperator(ESSL3_BUILTINS, "packUnorm2x16", EOpPackUnorm2x16);
921 symbolTable.relateToOperator(ESSL3_BUILTINS, "packHalf2x16", EOpPackHalf2x16);
922
923 symbolTable.relateToOperator(ESSL3_BUILTINS, "unpackSnorm2x16", EOpUnpackSnorm2x16);
924 symbolTable.relateToOperator(ESSL3_BUILTINS, "unpackUnorm2x16", EOpUnpackUnorm2x16);
925 symbolTable.relateToOperator(ESSL3_BUILTINS, "unpackHalf2x16", EOpUnpackHalf2x16);
926
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000927 symbolTable.relateToOperator(COMMON_BUILTINS, "length", EOpLength);
928 symbolTable.relateToOperator(COMMON_BUILTINS, "distance", EOpDistance);
929 symbolTable.relateToOperator(COMMON_BUILTINS, "dot", EOpDot);
930 symbolTable.relateToOperator(COMMON_BUILTINS, "cross", EOpCross);
931 symbolTable.relateToOperator(COMMON_BUILTINS, "normalize", EOpNormalize);
932 symbolTable.relateToOperator(COMMON_BUILTINS, "faceforward", EOpFaceForward);
933 symbolTable.relateToOperator(COMMON_BUILTINS, "reflect", EOpReflect);
934 symbolTable.relateToOperator(COMMON_BUILTINS, "refract", EOpRefract);
Nicolas Capens46485082014-04-15 13:12:50 -0400935
Olli Etuahoe39706d2014-12-30 16:40:36 +0200936 symbolTable.relateToOperator(ESSL3_BUILTINS, "outerProduct", EOpOuterProduct);
937 symbolTable.relateToOperator(ESSL3_BUILTINS, "transpose", EOpTranspose);
938 symbolTable.relateToOperator(ESSL3_BUILTINS, "determinant", EOpDeterminant);
Olli Etuahoabf6dad2015-01-14 14:45:16 +0200939 symbolTable.relateToOperator(ESSL3_BUILTINS, "inverse", EOpInverse);
Olli Etuahoe39706d2014-12-30 16:40:36 +0200940
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000941 symbolTable.relateToOperator(COMMON_BUILTINS, "any", EOpAny);
942 symbolTable.relateToOperator(COMMON_BUILTINS, "all", EOpAll);
943 symbolTable.relateToOperator(COMMON_BUILTINS, "not", EOpVectorLogicalNot);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000944
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000945 // Map language-specific operators.
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000946 switch(type) {
Jamie Madill183bde52014-07-02 15:31:19 -0400947 case GL_VERTEX_SHADER:
alokp@chromium.org58e54292010-08-24 21:40:03 +0000948 break;
Jamie Madill183bde52014-07-02 15:31:19 -0400949 case GL_FRAGMENT_SHADER:
Nicolas Capens46485082014-04-15 13:12:50 -0400950 if (resources.OES_standard_derivatives)
951 {
shannonwoods@chromium.orgc6ac65f2013-05-30 00:02:50 +0000952 symbolTable.relateToOperator(ESSL1_BUILTINS, "dFdx", EOpDFdx);
953 symbolTable.relateToOperator(ESSL1_BUILTINS, "dFdy", EOpDFdy);
954 symbolTable.relateToOperator(ESSL1_BUILTINS, "fwidth", EOpFwidth);
alokp@chromium.org8815d7f2010-09-09 17:30:03 +0000955
shannonwoods@chromium.orgc6ac65f2013-05-30 00:02:50 +0000956 symbolTable.relateToExtension(ESSL1_BUILTINS, "dFdx", "GL_OES_standard_derivatives");
957 symbolTable.relateToExtension(ESSL1_BUILTINS, "dFdy", "GL_OES_standard_derivatives");
958 symbolTable.relateToExtension(ESSL1_BUILTINS, "fwidth", "GL_OES_standard_derivatives");
alokp@chromium.org06098892010-08-26 19:36:42 +0000959 }
Nicolas Capens46485082014-04-15 13:12:50 -0400960 if (resources.EXT_shader_texture_lod)
961 {
962 symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DLodEXT", "GL_EXT_shader_texture_lod");
963 symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DProjLodEXT", "GL_EXT_shader_texture_lod");
964 symbolTable.relateToExtension(ESSL1_BUILTINS, "textureCubeLodEXT", "GL_EXT_shader_texture_lod");
965 }
Erik Dahlströmea7a2122014-11-17 16:15:57 +0100966 if (resources.NV_shader_framebuffer_fetch)
967 {
968 symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_LastFragColor", "GL_NV_shader_framebuffer_fetch");
969 }
970 else if (resources.ARM_shader_framebuffer_fetch)
971 {
972 symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_LastFragColorARM", "GL_ARM_shader_framebuffer_fetch");
973 }
alokp@chromium.org58e54292010-08-24 21:40:03 +0000974 break;
975 default: break;
976 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000977
Nicolas Capensf4cb0e12013-06-24 16:11:36 -0400978 symbolTable.relateToOperator(ESSL3_BUILTINS, "dFdx", EOpDFdx);
979 symbolTable.relateToOperator(ESSL3_BUILTINS, "dFdy", EOpDFdy);
980 symbolTable.relateToOperator(ESSL3_BUILTINS, "fwidth", EOpFwidth);
981
Nicolas Capens46485082014-04-15 13:12:50 -0400982 if (resources.EXT_shader_texture_lod)
983 {
984 symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DGradEXT", "GL_EXT_shader_texture_lod");
985 symbolTable.relateToExtension(ESSL1_BUILTINS, "texture2DProjGradEXT", "GL_EXT_shader_texture_lod");
986 symbolTable.relateToExtension(ESSL1_BUILTINS, "textureCubeGradEXT", "GL_EXT_shader_texture_lod");
987 }
988
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000989 // Finally add resource-specific variables.
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000990 switch(type) {
Jamie Madill183bde52014-07-02 15:31:19 -0400991 case GL_FRAGMENT_SHADER:
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +0000992 if (spec != SH_CSS_SHADERS_SPEC) {
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000993 // Set up gl_FragData. The array size.
shannonwoods@chromium.org09e09882013-05-30 00:18:25 +0000994 TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true);
alokp@chromium.org94a86ad2010-08-25 20:02:11 +0000995 fragData.setArraySize(resources.MaxDrawBuffers);
Nicolas Capensadfffe42014-06-17 02:13:36 -0400996 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData"), fragData));
Erik Dahlströmea7a2122014-11-17 16:15:57 +0100997
998 if (resources.EXT_shader_framebuffer_fetch || resources.NV_shader_framebuffer_fetch) {
999 // Set up gl_LastFragData. The array size.
1000 TType lastFragData(EbtFloat, EbpMedium, EvqLastFragData, 4, 1, true);
1001 lastFragData.setArraySize(resources.MaxDrawBuffers);
1002 symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_LastFragData"), lastFragData));
1003
1004 if (resources.EXT_shader_framebuffer_fetch)
1005 {
1006 symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_LastFragData", "GL_EXT_shader_framebuffer_fetch");
1007 }
1008 else if (resources.NV_shader_framebuffer_fetch)
1009 {
1010 symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_LastFragData", "GL_NV_shader_framebuffer_fetch");
1011 }
1012 }
daniel@transgaming.com0578f812010-05-17 09:58:39 +00001013 }
1014 break;
daniel@transgaming.com0578f812010-05-17 09:58:39 +00001015 default: break;
1016 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001017}
1018
alokp@chromium.org4888ceb2010-10-01 21:13:12 +00001019void InitExtensionBehavior(const ShBuiltInResources& resources,
alokp@chromium.orgad771eb2010-09-07 17:36:23 +00001020 TExtensionBehavior& extBehavior)
1021{
1022 if (resources.OES_standard_derivatives)
zmo@google.com09c323a2011-08-12 18:22:25 +00001023 extBehavior["GL_OES_standard_derivatives"] = EBhUndefined;
1024 if (resources.OES_EGL_image_external)
1025 extBehavior["GL_OES_EGL_image_external"] = EBhUndefined;
kbr@chromium.org205fef32011-11-22 20:50:02 +00001026 if (resources.ARB_texture_rectangle)
1027 extBehavior["GL_ARB_texture_rectangle"] = EBhUndefined;
shannon.woods@transgaming.com550cd092013-02-28 23:19:54 +00001028 if (resources.EXT_draw_buffers)
1029 extBehavior["GL_EXT_draw_buffers"] = EBhUndefined;
Jamie Madill2aeb26a2013-07-08 14:02:55 -04001030 if (resources.EXT_frag_depth)
1031 extBehavior["GL_EXT_frag_depth"] = EBhUndefined;
Nicolas Capens46485082014-04-15 13:12:50 -04001032 if (resources.EXT_shader_texture_lod)
1033 extBehavior["GL_EXT_shader_texture_lod"] = EBhUndefined;
Erik Dahlströmea7a2122014-11-17 16:15:57 +01001034 if (resources.EXT_shader_framebuffer_fetch)
1035 extBehavior["GL_EXT_shader_framebuffer_fetch"] = EBhUndefined;
1036 if (resources.NV_shader_framebuffer_fetch)
1037 extBehavior["GL_NV_shader_framebuffer_fetch"] = EBhUndefined;
1038 if (resources.ARM_shader_framebuffer_fetch)
1039 extBehavior["GL_ARM_shader_framebuffer_fetch"] = EBhUndefined;
alokp@chromium.orgad771eb2010-09-07 17:36:23 +00001040}
David Yen0fbd1282015-02-02 14:46:09 -08001041
1042void ResetExtensionBehavior(TExtensionBehavior &extBehavior)
1043{
1044 for (auto ext_iter = extBehavior.begin();
1045 ext_iter != extBehavior.end();
1046 ++ext_iter)
1047 {
1048 ext_iter->second = EBhUndefined;
1049 }
1050}