blob: 345ecaceff26b2f4d85b39077d77a2c6ba452fd9 [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +00002// Copyright (c) 2002-2013 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//
8// Create strings that declare built-in definitions, add built-ins that
9// cannot be expressed in the files, and establish mappings between
10// built-in functions and operators.
11//
12
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000013#include "compiler/Initialize.h"
14
15#include "compiler/intermediate.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000016
Nicolas Capens49a88872013-06-20 09:54:03 -040017void InsertBuiltInFunctions(ShShaderType type, ShShaderSpec spec, const ShBuiltInResources &resources,
18 const TExtensionBehavior &extensionBehavior, TSymbolTable &symbolTable)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000019{
Nicolas Capens49a88872013-06-20 09:54:03 -040020 TType *float1 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 1);
21 TType *float2 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 2);
22 TType *float3 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 3);
23 TType *float4 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 4);
24
Nicolas Capens75fb4752013-07-10 15:14:47 -040025 TType *int1 = new TType(EbtInt, EbpUndefined, EvqGlobal, 1);
Nicolas Capens49a88872013-06-20 09:54:03 -040026 TType *int2 = new TType(EbtInt, EbpUndefined, EvqGlobal, 2);
27 TType *int3 = new TType(EbtInt, EbpUndefined, EvqGlobal, 3);
28 TType *int4 = new TType(EbtInt, EbpUndefined, EvqGlobal, 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 Capens49a88872013-06-20 09:54:03 -040033 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "radians", float1, "degrees");
34 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "radians", float2, "degrees");
35 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "radians", float3, "degrees");
36 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "radians", float4, "degrees");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000037
Nicolas Capens49a88872013-06-20 09:54:03 -040038 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "degrees", float1, "radians");
39 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "degrees", float2, "radians");
40 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "degrees", float3, "radians");
41 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "degrees", float4, "radians");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000042
Nicolas Capens49a88872013-06-20 09:54:03 -040043 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sin", float1, "angle");
44 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sin", float2, "angle");
45 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sin", float3, "angle");
46 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sin", float4, "angle");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000047
Nicolas Capens49a88872013-06-20 09:54:03 -040048 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "cos", float1, "angle");
49 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "cos", float2, "angle");
50 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "cos", float3, "angle");
51 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "cos", float4, "angle");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000052
Nicolas Capens49a88872013-06-20 09:54:03 -040053 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "tan", float1, "angle");
54 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "tan", float2, "angle");
55 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "tan", float3, "angle");
56 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "tan", float4, "angle");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000057
Nicolas Capens49a88872013-06-20 09:54:03 -040058 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "asin", float1, "x");
59 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "asin", float2, "x");
60 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "asin", float3, "x");
61 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "asin", float4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000062
Nicolas Capens49a88872013-06-20 09:54:03 -040063 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "acos", float1, "x");
64 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "acos", float2, "x");
65 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "acos", float3, "x");
66 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "acos", float4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000067
Nicolas Capens49a88872013-06-20 09:54:03 -040068 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "atan", float1, "y", float1, "x");
69 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "atan", float2, "y", float2, "x");
70 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "atan", float3, "y", float3, "x");
71 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "atan", float4, "y", float4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000072
Nicolas Capens49a88872013-06-20 09:54:03 -040073 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "atan", float1, "y_over_x");
74 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "atan", float2, "y_over_x");
75 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "atan", float3, "y_over_x");
76 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "atan", float4, "y_over_x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000077
alokp@chromium.orge4249f02010-07-26 18:13:52 +000078 //
79 // Exponential Functions.
80 //
Nicolas Capens49a88872013-06-20 09:54:03 -040081 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "pow", float1, "x", float1, "y");
82 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "pow", float2, "x", float2, "y");
83 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "pow", float3, "x", float3, "y");
84 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "pow", float4, "x", float4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000085
Nicolas Capens49a88872013-06-20 09:54:03 -040086 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "exp", float1, "x");
87 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "exp", float2, "x");
88 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "exp", float3, "x");
89 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "exp", float4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000090
Nicolas Capens49a88872013-06-20 09:54:03 -040091 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "log", float1, "x");
92 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "log", float2, "x");
93 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "log", float3, "x");
94 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "log", float4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000095
Nicolas Capens49a88872013-06-20 09:54:03 -040096 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "exp2", float1, "x");
97 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "exp2", float2, "x");
98 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "exp2", float3, "x");
99 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "exp2", float4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000100
Nicolas Capens49a88872013-06-20 09:54:03 -0400101 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "log2", float1, "x");
102 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "log2", float2, "x");
103 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "log2", float3, "x");
104 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "log2", float4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000105
Nicolas Capens49a88872013-06-20 09:54:03 -0400106 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sqrt", float1, "x");
107 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sqrt", float2, "x");
108 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sqrt", float3, "x");
109 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sqrt", float4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000110
Nicolas Capens49a88872013-06-20 09:54:03 -0400111 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "inversesqrt", float1, "x");
112 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "inversesqrt", float2, "x");
113 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "inversesqrt", float3, "x");
114 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "inversesqrt", float4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000115
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000116 //
117 // Common Functions.
118 //
Nicolas Capens49a88872013-06-20 09:54:03 -0400119 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "abs", float1, "x");
120 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "abs", float2, "x");
121 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "abs", float3, "x");
122 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "abs", float4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000123
Nicolas Capens49a88872013-06-20 09:54:03 -0400124 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sign", float1, "x");
125 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sign", float2, "x");
126 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sign", float3, "x");
127 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sign", float4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000128
Nicolas Capens49a88872013-06-20 09:54:03 -0400129 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "floor", float1, "x");
130 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "floor", float2, "x");
131 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "floor", float3, "x");
132 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "floor", float4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000133
Nicolas Capens49a88872013-06-20 09:54:03 -0400134 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "ceil", float1, "x");
135 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "ceil", float2, "x");
136 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "ceil", float3, "x");
137 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "ceil", float4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000138
Nicolas Capens49a88872013-06-20 09:54:03 -0400139 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "fract", float1, "x");
140 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "fract", float2, "x");
141 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "fract", float3, "x");
142 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "fract", float4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000143
Nicolas Capens49a88872013-06-20 09:54:03 -0400144 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "mod", float1, "x", float1, "y");
145 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mod", float2, "x", float1, "y");
146 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mod", float3, "x", float1, "y");
147 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mod", float4, "x", float1, "y");
148 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mod", float2, "x", float2, "y");
149 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mod", float3, "x", float3, "y");
150 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mod", float4, "x", float4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000151
Nicolas Capens49a88872013-06-20 09:54:03 -0400152 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "min", float1, "x", float1, "y");
153 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "min", float2, "x", float1, "y");
154 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "min", float3, "x", float1, "y");
155 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "min", float4, "x", float1, "y");
156 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "min", float2, "x", float2, "y");
157 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "min", float3, "x", float3, "y");
158 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "min", float4, "x", float4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000159
Nicolas Capens49a88872013-06-20 09:54:03 -0400160 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "max", float1, "x", float1, "y");
161 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "max", float2, "x", float1, "y");
162 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "max", float3, "x", float1, "y");
163 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "max", float4, "x", float1, "y");
164 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "max", float2, "x", float2, "y");
165 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "max", float3, "x", float3, "y");
166 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "max", float4, "x", float4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000167
Nicolas Capens49a88872013-06-20 09:54:03 -0400168 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "clamp", float1, "x", float1, "minVal", float1, "maxVal");
169 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "clamp", float2, "x", float1, "minVal", float1, "maxVal");
170 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "clamp", float3, "x", float1, "minVal", float1, "maxVal");
171 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "clamp", float4, "x", float1, "minVal", float1, "maxVal");
172 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "clamp", float2, "x", float2, "minVal", float2, "maxVal");
173 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "clamp", float3, "x", float3, "minVal", float3, "maxVal");
174 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "clamp", float4, "x", float4, "minVal", float4, "maxVal");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000175
Nicolas Capens49a88872013-06-20 09:54:03 -0400176 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "mix", float1, "x", float1, "y", float1, "a");
177 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mix", float2, "x", float2, "y", float1, "a");
178 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mix", float3, "x", float3, "y", float1, "a");
179 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mix", float4, "x", float4, "y", float1, "a");
180 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mix", float2, "x", float2, "y", float2, "a");
181 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mix", float3, "x", float3, "y", float3, "a");
182 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mix", float4, "x", float4, "y", float4, "a");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000183
Nicolas Capens49a88872013-06-20 09:54:03 -0400184 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "step", float1, "edge", float1, "x");
185 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "step", float2, "edge", float2, "x");
186 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "step", float3, "edge", float3, "x");
187 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "step", float4, "edge", float4, "x");
188 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "step", float1, "edge", float2, "x");
189 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "step", float1, "edge", float3, "x");
190 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "step", float1, "edge", float4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000191
Nicolas Capens49a88872013-06-20 09:54:03 -0400192 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "smoothstep", float1, "edge0", float1, "edge1", float1, "x");
193 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "smoothstep", float2, "edge0", float2, "edge1", float2, "x");
194 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "smoothstep", float3, "edge0", float3, "edge1", float3, "x");
195 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "smoothstep", float4, "edge0", float4, "edge1", float4, "x");
196 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "smoothstep", float1, "edge0", float1, "edge1", float2, "x");
197 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "smoothstep", float1, "edge0", float1, "edge1", float3, "x");
198 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "smoothstep", float1, "edge0", float1, "edge1", float4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000199
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000200 //
201 // Geometric Functions.
202 //
Nicolas Capens49a88872013-06-20 09:54:03 -0400203 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float1, "x");
204 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float2, "x");
205 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float3, "x");
206 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000207
Nicolas Capens49a88872013-06-20 09:54:03 -0400208 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float1, "p0", float1, "p1");
209 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float2, "p0", float2, "p1");
210 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float3, "p0", float3, "p1");
211 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float4, "p0", float4, "p1");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000212
Nicolas Capens49a88872013-06-20 09:54:03 -0400213 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float1, "x", float1, "y");
214 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float2, "x", float2, "y");
215 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float3, "x", float3, "y");
216 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float4, "x", float4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000217
Nicolas Capens49a88872013-06-20 09:54:03 -0400218 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "cross", float3, "x", float3, "y");
219 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "normalize", float1, "x");
220 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "normalize", float2, "x");
221 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "normalize", float3, "x");
222 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "normalize", float4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000223
Nicolas Capens49a88872013-06-20 09:54:03 -0400224 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "faceforward", float1, "N", float1, "I", float1, "Nref");
225 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "faceforward", float2, "N", float2, "I", float2, "Nref");
226 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "faceforward", float3, "N", float3, "I", float3, "Nref");
227 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "faceforward", float4, "N", float4, "I", float4, "Nref");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000228
Nicolas Capens49a88872013-06-20 09:54:03 -0400229 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "reflect", float1, "I", float1, "N");
230 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "reflect", float2, "I", float2, "N");
231 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "reflect", float3, "I", float3, "N");
232 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "reflect", float4, "I", float4, "N");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000233
Nicolas Capens49a88872013-06-20 09:54:03 -0400234 symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "refract", float1, "I", float1, "N", float1, "eta");
235 symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "refract", float2, "I", float2, "N", float1, "eta");
236 symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "refract", float3, "I", float3, "N", float1, "eta");
237 symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "refract", float4, "I", float4, "N", float1, "eta");
238
239 TType *mat2 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 2, 2);
240 TType *mat3 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 3, 3);
241 TType *mat4 = new TType(EbtFloat, EbpUndefined, EvqGlobal, 4, 4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000242
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000243 //
244 // Matrix Functions.
245 //
Nicolas Capens49a88872013-06-20 09:54:03 -0400246 symbolTable.insertBuiltIn(COMMON_BUILTINS, mat2, "matrixCompMult", mat2, "x", mat2, "y");
247 symbolTable.insertBuiltIn(COMMON_BUILTINS, mat3, "matrixCompMult", mat3, "x", mat3, "y");
248 symbolTable.insertBuiltIn(COMMON_BUILTINS, mat4, "matrixCompMult", mat4, "x", mat4, "y");
249
250 TType *bool1 = new TType(EbtBool, EbpUndefined, EvqGlobal, 1);
251 TType *bool2 = new TType(EbtBool, EbpUndefined, EvqGlobal, 2);
252 TType *bool3 = new TType(EbtBool, EbpUndefined, EvqGlobal, 3);
253 TType *bool4 = new TType(EbtBool, EbpUndefined, EvqGlobal, 4);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000254
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000255 //
256 // Vector relational functions.
257 //
Nicolas Capens49a88872013-06-20 09:54:03 -0400258 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThan", float2, "x", float2, "y");
259 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThan", float3, "x", float3, "y");
260 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThan", float4, "x", float4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000261
Nicolas Capens49a88872013-06-20 09:54:03 -0400262 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThan", int2, "x", int2, "y");
263 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThan", int3, "x", int3, "y");
264 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThan", int4, "x", int4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000265
Nicolas Capens49a88872013-06-20 09:54:03 -0400266 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThanEqual", float2, "x", float2, "y");
267 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThanEqual", float3, "x", float3, "y");
268 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThanEqual", float4, "x", float4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000269
Nicolas Capens49a88872013-06-20 09:54:03 -0400270 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThanEqual", int2, "x", int2, "y");
271 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThanEqual", int3, "x", int3, "y");
272 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThanEqual", int4, "x", int4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000273
Nicolas Capens49a88872013-06-20 09:54:03 -0400274 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThan", float2, "x", float2, "y");
275 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThan", float3, "x", float3, "y");
276 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThan", float4, "x", float4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000277
Nicolas Capens49a88872013-06-20 09:54:03 -0400278 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThan", int2, "x", int2, "y");
279 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThan", int3, "x", int3, "y");
280 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThan", int4, "x", int4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000281
Nicolas Capens49a88872013-06-20 09:54:03 -0400282 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThanEqual", float2, "x", float2, "y");
283 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThanEqual", float3, "x", float3, "y");
284 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThanEqual", float4, "x", float4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000285
Nicolas Capens49a88872013-06-20 09:54:03 -0400286 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThanEqual", int2, "x", int2, "y");
287 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThanEqual", int3, "x", int3, "y");
288 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThanEqual", int4, "x", int4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000289
Nicolas Capens49a88872013-06-20 09:54:03 -0400290 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", float2, "x", float2, "y");
291 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", float3, "x", float3, "y");
292 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", float4, "x", float4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000293
Nicolas Capens49a88872013-06-20 09:54:03 -0400294 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", int2, "x", int2, "y");
295 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", int3, "x", int3, "y");
296 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", int4, "x", int4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000297
Nicolas Capens49a88872013-06-20 09:54:03 -0400298 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", bool2, "x", bool2, "y");
299 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", bool3, "x", bool3, "y");
300 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", bool4, "x", bool4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000301
Nicolas Capens49a88872013-06-20 09:54:03 -0400302 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", float2, "x", float2, "y");
303 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", float3, "x", float3, "y");
304 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", float4, "x", float4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000305
Nicolas Capens49a88872013-06-20 09:54:03 -0400306 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", int2, "x", int2, "y");
307 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", int3, "x", int3, "y");
308 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", int4, "x", int4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000309
Nicolas Capens49a88872013-06-20 09:54:03 -0400310 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", bool2, "x", bool2, "y");
311 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", bool3, "x", bool3, "y");
312 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", bool4, "x", bool4, "y");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000313
Nicolas Capens49a88872013-06-20 09:54:03 -0400314 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool2, "x");
315 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool3, "x");
316 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000317
Nicolas Capens49a88872013-06-20 09:54:03 -0400318 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool2, "x");
319 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool3, "x");
320 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000321
Nicolas Capens49a88872013-06-20 09:54:03 -0400322 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "not", bool2, "x");
323 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "not", bool3, "x");
324 symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "not", bool4, "x");
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000325
Nicolas Capens49a88872013-06-20 09:54:03 -0400326 TType *sampler2D = new TType(EbtSampler2D, EbpUndefined, EvqGlobal, 1);
327 TType *samplerCube = new TType(EbtSamplerCube, EbpUndefined, EvqGlobal, 1);
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000328
329 //
330 // Texture Functions for GLSL ES 1.0
331 //
Nicolas Capens49a88872013-06-20 09:54:03 -0400332 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, "sampler", float2, "coord");
333 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, "sampler", float3, "coord");
334 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, "sampler", float4, "coord");
335 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, "sampler", float3, "coord");
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000336
Nicolas Capens49a88872013-06-20 09:54:03 -0400337 if (resources.OES_EGL_image_external)
338 {
339 TType *samplerExternalOES = new TType(EbtSamplerExternalOES, EbpUndefined, EvqGlobal, 1);
340
341 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", samplerExternalOES, "sampler", float2, "coord");
342 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, "sampler", float3, "coord");
343 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", samplerExternalOES, "sampler", float4, "coord");
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000344 }
345
Nicolas Capens49a88872013-06-20 09:54:03 -0400346 if (resources.ARB_texture_rectangle)
347 {
348 TType *sampler2DRect = new TType(EbtSampler2DRect, EbpUndefined, EvqGlobal, 1);
349
350 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRect", sampler2DRect, "sampler", float2, "coord");
351 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect, "sampler", float3, "coord");
352 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DRectProj", sampler2DRect, "sampler", float4, "coord");
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000353 }
354
Nicolas Capens67a819f2013-07-09 12:08:58 -0400355 if (type == SH_FRAGMENT_SHADER)
Nicolas Capens49a88872013-06-20 09:54:03 -0400356 {
357 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2D", sampler2D, "sampler", float2, "coord", float1, "bias");
358 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, "sampler", float3, "coord", float1, "bias");
359 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProj", sampler2D, "sampler", float4, "coord", float1, "bias");
360 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCube", samplerCube, "sampler", float3, "coord", float1, "bias");
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000361
Nicolas Capens49a88872013-06-20 09:54:03 -0400362 if (resources.OES_standard_derivatives)
363 {
364 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "dFdx", float1, "p");
365 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "dFdx", float2, "p");
366 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "dFdx", float3, "p");
367 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "dFdx", float4, "p");
368
369 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "dFdy", float1, "p");
370 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "dFdy", float2, "p");
371 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "dFdy", float3, "p");
372 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "dFdy", float4, "p");
373
374 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "fwidth", float1, "p");
375 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "fwidth", float2, "p");
376 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "fwidth", float3, "p");
377 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "fwidth", float4, "p");
378 }
379 }
380
381 if(type == SH_VERTEX_SHADER)
382 {
383 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DLod", sampler2D, "sampler", float2, "coord", float1, "lod");
384 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, "sampler", float3, "coord", float1, "lod");
385 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, "sampler", float4, "coord", float1, "lod");
386 symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "textureCubeLod", samplerCube, "sampler", float3, "coord", float1, "lod");
387 }
shannonwoods@chromium.orgc6ac65f2013-05-30 00:02:50 +0000388
Nicolas Capens73f5bf62013-06-17 16:13:33 -0400389 TType *sampler3D = new TType(EbtSampler3D, EbpUndefined, EvqGlobal, 1);
Nicolas Capenseceb50d2013-06-19 13:37:17 -0400390 TType *sampler2DArray = new TType(EbtSampler2DArray, EbpUndefined, EvqGlobal, 1);
Nicolas Capens73f5bf62013-06-17 16:13:33 -0400391
shannonwoods@chromium.orgc6ac65f2013-05-30 00:02:50 +0000392 //
393 // Texture Functions for GLSL ES 3.0
394 //
Nicolas Capens49a88872013-06-20 09:54:03 -0400395 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "texture", sampler2D, "sampler", float2, "coord");
Nicolas Capens73f5bf62013-06-17 16:13:33 -0400396 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "texture", sampler3D, "sampler", float3, "coord");
Nicolas Capens49a88872013-06-20 09:54:03 -0400397 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "texture", samplerCube, "sampler", float3, "coord");
Nicolas Capenseceb50d2013-06-19 13:37:17 -0400398 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "texture", sampler2DArray, "sampler", float3, "coord");
Nicolas Capens49a88872013-06-20 09:54:03 -0400399 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "textureProj", sampler2D, "sampler", float3, "coord");
400 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "textureProj", sampler2D, "sampler", float4, "coord");
Nicolas Capens73f5bf62013-06-17 16:13:33 -0400401 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "textureProj", sampler3D, "sampler", float4, "coord");
shannonwoods@chromium.orgc6ac65f2013-05-30 00:02:50 +0000402
Nicolas Capens67a819f2013-07-09 12:08:58 -0400403 if (type == SH_FRAGMENT_SHADER)
404 {
405 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "texture", sampler2D, "sampler", float2, "coord", float1, "bias");
406 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "texture", sampler3D, "sampler", float3, "coord", float1, "bias");
407 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "texture", samplerCube, "sampler", float3, "coord", float1, "bias");
408 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "texture", sampler2DArray, "sampler", float3, "coord", float1, "bias");
409 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "textureProj", sampler2D, "sampler", float3, "coord", float1, "bias");
410 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "textureProj", sampler2D, "sampler", float4, "coord", float1, "bias");
411 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "textureProj", sampler3D, "sampler", float4, "coord", float1, "bias");
412 }
413
Nicolas Capens93632462013-06-17 14:10:38 -0400414 TType *isampler2D = new TType(EbtISampler2D, EbpUndefined, EvqGlobal, 1);
Nicolas Capens73f5bf62013-06-17 16:13:33 -0400415 TType *isampler3D = new TType(EbtISampler3D, EbpUndefined, EvqGlobal, 1);
Nicolas Capens93632462013-06-17 14:10:38 -0400416 TType *isamplerCube = new TType(EbtISamplerCube, EbpUndefined, EvqGlobal, 1);
Nicolas Capenseceb50d2013-06-19 13:37:17 -0400417 TType *isampler2DArray = new TType(EbtISampler2DArray, EbpUndefined, EvqGlobal, 1);
Nicolas Capens93632462013-06-17 14:10:38 -0400418
419 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "texture", isampler2D, "sampler", float2, "coord");
Nicolas Capens73f5bf62013-06-17 16:13:33 -0400420 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "texture", isampler3D, "sampler", float3, "coord");
Nicolas Capens93632462013-06-17 14:10:38 -0400421 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "texture", isamplerCube, "sampler", float3, "coord");
Nicolas Capenseceb50d2013-06-19 13:37:17 -0400422 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "texture", isampler2DArray, "sampler", float3, "coord");
Nicolas Capens93632462013-06-17 14:10:38 -0400423 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "textureProj", isampler2D, "sampler", float3, "coord");
424 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "textureProj", isampler2D, "sampler", float4, "coord");
Nicolas Capens73f5bf62013-06-17 16:13:33 -0400425 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "textureProj", isampler3D, "sampler", float4, "coord");
Nicolas Capens93632462013-06-17 14:10:38 -0400426
Nicolas Capens67a819f2013-07-09 12:08:58 -0400427 if (type == SH_FRAGMENT_SHADER)
428 {
429 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "texture", isampler2D, "sampler", float2, "coord", float1, "bias");
430 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "texture", isampler3D, "sampler", float3, "coord", float1, "bias");
431 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "texture", isamplerCube, "sampler", float3, "coord", float1, "bias");
432 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "texture", isampler2DArray, "sampler", float3, "coord", float1, "bias");
433 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "textureProj", isampler2D, "sampler", float3, "coord", float1, "bias");
434 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "textureProj", isampler2D, "sampler", float4, "coord", float1, "bias");
435 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "textureProj", isampler3D, "sampler", float4, "coord", float1, "bias");
436 }
437
Nicolas Capens86132292013-06-17 15:50:23 -0400438 TType *usampler2D = new TType(EbtUSampler2D, EbpUndefined, EvqGlobal, 1);
Nicolas Capens73f5bf62013-06-17 16:13:33 -0400439 TType *usampler3D = new TType(EbtUSampler3D, EbpUndefined, EvqGlobal, 1);
Nicolas Capens86132292013-06-17 15:50:23 -0400440 TType *usamplerCube = new TType(EbtUSamplerCube, EbpUndefined, EvqGlobal, 1);
Nicolas Capenseceb50d2013-06-19 13:37:17 -0400441 TType *usampler2DArray = new TType(EbtUSampler2DArray, EbpUndefined, EvqGlobal, 1);
Nicolas Capens86132292013-06-17 15:50:23 -0400442 TType *uint4 = new TType(EbtUInt, EbpUndefined, EvqGlobal, 4);
443
444 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "texture", usampler2D, "sampler", float2, "coord");
Nicolas Capens73f5bf62013-06-17 16:13:33 -0400445 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "texture", usampler3D, "sampler", float3, "coord");
Nicolas Capens86132292013-06-17 15:50:23 -0400446 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "texture", usamplerCube, "sampler", float3, "coord");
Nicolas Capenseceb50d2013-06-19 13:37:17 -0400447 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "texture", usampler2DArray, "sampler", float3, "coord");
Nicolas Capens86132292013-06-17 15:50:23 -0400448 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "textureProj", usampler2D, "sampler", float3, "coord");
449 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "textureProj", usampler2D, "sampler", float4, "coord");
Nicolas Capens73f5bf62013-06-17 16:13:33 -0400450 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "textureProj", usampler3D, "sampler", float4, "coord");
Nicolas Capens86132292013-06-17 15:50:23 -0400451
Nicolas Capens67a819f2013-07-09 12:08:58 -0400452 if (type == SH_FRAGMENT_SHADER)
453 {
454 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "texture", usampler2D, "sampler", float2, "coord", float1, "bias");
455 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "texture", usampler3D, "sampler", float3, "coord", float1, "bias");
456 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "texture", usamplerCube, "sampler", float3, "coord", float1, "bias");
457 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "texture", usampler2DArray, "sampler", float3, "coord", float1, "bias");
458 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "textureProj", usampler2D, "sampler", float3, "coord", float1, "bias");
459 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "textureProj", usampler2D, "sampler", float4, "coord", float1, "bias");
460 symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "textureProj", usampler3D, "sampler", float4, "coord", float1, "bias");
461 }
462
Nicolas Capens75fb4752013-07-10 15:14:47 -0400463 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", sampler2D, "sampler", int1, "lod");
464 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", isampler2D, "sampler", int1, "lod");
465 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", usampler2D, "sampler", int1, "lod");
466 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", sampler3D, "sampler", int1, "lod");
467 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", isampler3D, "sampler", int1, "lod");
468 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", usampler3D, "sampler", int1, "lod");
469 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", samplerCube, "sampler", int1, "lod");
470 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", isamplerCube, "sampler", int1, "lod");
471 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", usamplerCube, "sampler", int1, "lod");
472 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", sampler2DArray, "sampler", int1, "lod");
473 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", isampler2DArray, "sampler", int1, "lod");
474 symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", usampler2DArray, "sampler", int1, "lod");
475
Nicolas Capens49a88872013-06-20 09:54:03 -0400476 if(type == SH_FRAGMENT_SHADER)
477 {
478 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "dFdx", float1, "p");
479 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "dFdx", float2, "p");
480 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "dFdx", float3, "p");
481 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "dFdx", float4, "p");
482
483 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "dFdy", float1, "p");
484 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "dFdy", float2, "p");
485 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "dFdy", float3, "p");
486 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "dFdy", float4, "p");
shannonwoods@chromium.orgc6ac65f2013-05-30 00:02:50 +0000487
Nicolas Capens49a88872013-06-20 09:54:03 -0400488 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "fwidth", float1, "p");
489 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "fwidth", float2, "p");
490 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "fwidth", float3, "p");
491 symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "fwidth", float4, "p");
alokp@chromium.org06098892010-08-26 19:36:42 +0000492 }
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000493
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000494 //
495 // Depth range in window coordinates
496 //
Jamie Madill98493dd2013-07-08 14:39:03 -0400497 TFieldList *fields = NewPoolTFieldList();
498 TSourceLoc zeroSourceLoc = {0};
499 TField *near = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("near"), zeroSourceLoc);
500 TField *far = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("far"), zeroSourceLoc);
501 TField *diff = new TField(new TType(EbtFloat, EbpHigh, EvqGlobal, 1), NewPoolTString("diff"), zeroSourceLoc);
502 fields->push_back(near);
503 fields->push_back(far);
504 fields->push_back(diff);
505 TStructure *depthRangeStruct = new TStructure(NewPoolTString("gl_DepthRangeParameters"), fields);
506 TVariable *depthRangeParameters = new TVariable(&depthRangeStruct->name(), depthRangeStruct, true);
Nicolas Capens49a88872013-06-20 09:54:03 -0400507 symbolTable.insert(COMMON_BUILTINS, *depthRangeParameters);
Jamie Madill98493dd2013-07-08 14:39:03 -0400508 TVariable *depthRange = new TVariable(NewPoolTString("gl_DepthRange"), TType(depthRangeStruct));
Nicolas Capens49a88872013-06-20 09:54:03 -0400509 depthRange->setQualifier(EvqUniform);
510 symbolTable.insert(COMMON_BUILTINS, *depthRange);
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000511
Nicolas Capens49a88872013-06-20 09:54:03 -0400512 //
513 // Implementation dependent built-in constants.
514 //
515 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexAttribs", resources.MaxVertexAttribs);
516 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexUniformVectors", resources.MaxVertexUniformVectors);
517 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxVertexTextureImageUnits", resources.MaxVertexTextureImageUnits);
518 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxCombinedTextureImageUnits", resources.MaxCombinedTextureImageUnits);
519 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxTextureImageUnits", resources.MaxTextureImageUnits);
520 symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxFragmentUniformVectors", resources.MaxFragmentUniformVectors);
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000521
Nicolas Capens49a88872013-06-20 09:54:03 -0400522 symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxVaryingVectors", resources.MaxVaryingVectors);
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +0000523
524 if (spec != SH_CSS_SHADERS_SPEC)
shannon.woods%transgaming.com@gtempaccount.com5209de82013-04-13 03:41:53 +0000525 {
526 TExtensionBehavior::const_iterator iter = extensionBehavior.find("GL_EXT_draw_buffers");
527 const bool usingMRTExtension = (iter != extensionBehavior.end() && (iter->second == EBhEnable || iter->second == EBhRequire));
528 const int maxDrawBuffers = (usingMRTExtension ? resources.MaxDrawBuffers : 1);
529
Nicolas Capens49a88872013-06-20 09:54:03 -0400530 symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxDrawBuffers", maxDrawBuffers);
shannon.woods%transgaming.com@gtempaccount.com5209de82013-04-13 03:41:53 +0000531 }
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000532
Nicolas Capens49a88872013-06-20 09:54:03 -0400533 symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxVertexOutputVectors", resources.MaxVertexOutputVectors);
534 symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxFragmentInputVectors", resources.MaxFragmentInputVectors);
535 symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MinProgramTexelOffset", resources.MinProgramTexelOffset);
536 symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxProgramTexelOffset", resources.MaxProgramTexelOffset);
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000537}
538
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000539void IdentifyBuiltIns(ShShaderType type, ShShaderSpec spec,
Nicolas Capens49a88872013-06-20 09:54:03 -0400540 const ShBuiltInResources &resources,
541 TSymbolTable &symbolTable)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000542{
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000543 //
544 // First, insert some special built-in variables that are not in
545 // the built-in header files.
546 //
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000547 switch(type) {
548 case SH_FRAGMENT_SHADER:
shannonwoods@chromium.org1c848092013-05-30 00:02:34 +0000549 symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_FragCoord"), TType(EbtFloat, EbpMedium, EvqFragCoord, 4)));
550 symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool, EbpUndefined, EvqFrontFacing, 1)));
551 symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_PointCoord"), TType(EbtFloat, EbpMedium, EvqPointCoord, 2)));
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +0000552
553 //
554 // In CSS Shaders, gl_FragColor, gl_FragData, and gl_MaxDrawBuffers are not available.
555 // Instead, css_MixColor and css_ColorMatrix are available.
556 //
557 if (spec != SH_CSS_SHADERS_SPEC) {
shannonwoods@chromium.org1c848092013-05-30 00:02:34 +0000558 symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EbpMedium, EvqFragColor, 4)));
559 symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragData[gl_MaxDrawBuffers]"), TType(EbtFloat, EbpMedium, EvqFragData, 4)));
Jamie Madill2aeb26a2013-07-08 14:02:55 -0400560 if (resources.EXT_frag_depth) {
561 symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragDepthEXT"), TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, EvqFragDepth, 1)));
562 symbolTable.relateToExtension(ESSL1_BUILTINS, "gl_FragDepthEXT", "GL_EXT_frag_depth");
563 }
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +0000564 } else {
shannonwoods@chromium.org1c848092013-05-30 00:02:34 +0000565 symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("css_MixColor"), TType(EbtFloat, EbpMedium, EvqGlobal, 4)));
shannonwoods@chromium.org09e09882013-05-30 00:18:25 +0000566 symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("css_ColorMatrix"), TType(EbtFloat, EbpMedium, EvqGlobal, 4, 4)));
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +0000567 }
568
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000569 break;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000570
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000571 case SH_VERTEX_SHADER:
shannonwoods@chromium.org1c848092013-05-30 00:02:34 +0000572 symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EbpHigh, EvqPosition, 4)));
573 symbolTable.insert(COMMON_BUILTINS, *new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EbpMedium, EvqPointSize, 1)));
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000574 break;
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000575
576 default: assert(false && "Language not supported");
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000577 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000578
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000579 //
580 // Next, identify which built-ins from the already loaded headers have
581 // a mapping to an operator. Those that are not identified as such are
582 // expected to be resolved through a library of functions, versus as
583 // operations.
584 //
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000585 symbolTable.relateToOperator(COMMON_BUILTINS, "matrixCompMult", EOpMul);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000586
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000587 symbolTable.relateToOperator(COMMON_BUILTINS, "equal", EOpVectorEqual);
588 symbolTable.relateToOperator(COMMON_BUILTINS, "notEqual", EOpVectorNotEqual);
589 symbolTable.relateToOperator(COMMON_BUILTINS, "lessThan", EOpLessThan);
590 symbolTable.relateToOperator(COMMON_BUILTINS, "greaterThan", EOpGreaterThan);
591 symbolTable.relateToOperator(COMMON_BUILTINS, "lessThanEqual", EOpLessThanEqual);
592 symbolTable.relateToOperator(COMMON_BUILTINS, "greaterThanEqual", EOpGreaterThanEqual);
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000593
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000594 symbolTable.relateToOperator(COMMON_BUILTINS, "radians", EOpRadians);
595 symbolTable.relateToOperator(COMMON_BUILTINS, "degrees", EOpDegrees);
596 symbolTable.relateToOperator(COMMON_BUILTINS, "sin", EOpSin);
597 symbolTable.relateToOperator(COMMON_BUILTINS, "cos", EOpCos);
598 symbolTable.relateToOperator(COMMON_BUILTINS, "tan", EOpTan);
599 symbolTable.relateToOperator(COMMON_BUILTINS, "asin", EOpAsin);
600 symbolTable.relateToOperator(COMMON_BUILTINS, "acos", EOpAcos);
601 symbolTable.relateToOperator(COMMON_BUILTINS, "atan", EOpAtan);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000602
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000603 symbolTable.relateToOperator(COMMON_BUILTINS, "pow", EOpPow);
604 symbolTable.relateToOperator(COMMON_BUILTINS, "exp2", EOpExp2);
605 symbolTable.relateToOperator(COMMON_BUILTINS, "log", EOpLog);
606 symbolTable.relateToOperator(COMMON_BUILTINS, "exp", EOpExp);
607 symbolTable.relateToOperator(COMMON_BUILTINS, "log2", EOpLog2);
608 symbolTable.relateToOperator(COMMON_BUILTINS, "sqrt", EOpSqrt);
609 symbolTable.relateToOperator(COMMON_BUILTINS, "inversesqrt", EOpInverseSqrt);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000610
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000611 symbolTable.relateToOperator(COMMON_BUILTINS, "abs", EOpAbs);
612 symbolTable.relateToOperator(COMMON_BUILTINS, "sign", EOpSign);
613 symbolTable.relateToOperator(COMMON_BUILTINS, "floor", EOpFloor);
614 symbolTable.relateToOperator(COMMON_BUILTINS, "ceil", EOpCeil);
615 symbolTable.relateToOperator(COMMON_BUILTINS, "fract", EOpFract);
616 symbolTable.relateToOperator(COMMON_BUILTINS, "mod", EOpMod);
617 symbolTable.relateToOperator(COMMON_BUILTINS, "min", EOpMin);
618 symbolTable.relateToOperator(COMMON_BUILTINS, "max", EOpMax);
619 symbolTable.relateToOperator(COMMON_BUILTINS, "clamp", EOpClamp);
620 symbolTable.relateToOperator(COMMON_BUILTINS, "mix", EOpMix);
621 symbolTable.relateToOperator(COMMON_BUILTINS, "step", EOpStep);
622 symbolTable.relateToOperator(COMMON_BUILTINS, "smoothstep", EOpSmoothStep);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000623
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000624 symbolTable.relateToOperator(COMMON_BUILTINS, "length", EOpLength);
625 symbolTable.relateToOperator(COMMON_BUILTINS, "distance", EOpDistance);
626 symbolTable.relateToOperator(COMMON_BUILTINS, "dot", EOpDot);
627 symbolTable.relateToOperator(COMMON_BUILTINS, "cross", EOpCross);
628 symbolTable.relateToOperator(COMMON_BUILTINS, "normalize", EOpNormalize);
629 symbolTable.relateToOperator(COMMON_BUILTINS, "faceforward", EOpFaceForward);
630 symbolTable.relateToOperator(COMMON_BUILTINS, "reflect", EOpReflect);
631 symbolTable.relateToOperator(COMMON_BUILTINS, "refract", EOpRefract);
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000632
shannonwoods@chromium.org89992b52013-05-30 00:02:20 +0000633 symbolTable.relateToOperator(COMMON_BUILTINS, "any", EOpAny);
634 symbolTable.relateToOperator(COMMON_BUILTINS, "all", EOpAll);
635 symbolTable.relateToOperator(COMMON_BUILTINS, "not", EOpVectorLogicalNot);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000636
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000637 // Map language-specific operators.
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000638 switch(type) {
639 case SH_VERTEX_SHADER:
alokp@chromium.org58e54292010-08-24 21:40:03 +0000640 break;
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000641 case SH_FRAGMENT_SHADER:
alokp@chromium.org06098892010-08-26 19:36:42 +0000642 if (resources.OES_standard_derivatives) {
shannonwoods@chromium.orgc6ac65f2013-05-30 00:02:50 +0000643 symbolTable.relateToOperator(ESSL1_BUILTINS, "dFdx", EOpDFdx);
644 symbolTable.relateToOperator(ESSL1_BUILTINS, "dFdy", EOpDFdy);
645 symbolTable.relateToOperator(ESSL1_BUILTINS, "fwidth", EOpFwidth);
alokp@chromium.org8815d7f2010-09-09 17:30:03 +0000646
shannonwoods@chromium.orgc6ac65f2013-05-30 00:02:50 +0000647 symbolTable.relateToExtension(ESSL1_BUILTINS, "dFdx", "GL_OES_standard_derivatives");
648 symbolTable.relateToExtension(ESSL1_BUILTINS, "dFdy", "GL_OES_standard_derivatives");
649 symbolTable.relateToExtension(ESSL1_BUILTINS, "fwidth", "GL_OES_standard_derivatives");
alokp@chromium.org06098892010-08-26 19:36:42 +0000650 }
alokp@chromium.org58e54292010-08-24 21:40:03 +0000651 break;
652 default: break;
653 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000654
Nicolas Capensf4cb0e12013-06-24 16:11:36 -0400655 symbolTable.relateToOperator(ESSL3_BUILTINS, "dFdx", EOpDFdx);
656 symbolTable.relateToOperator(ESSL3_BUILTINS, "dFdy", EOpDFdy);
657 symbolTable.relateToOperator(ESSL3_BUILTINS, "fwidth", EOpFwidth);
658
alokp@chromium.orge4249f02010-07-26 18:13:52 +0000659 // Finally add resource-specific variables.
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000660 switch(type) {
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +0000661 case SH_FRAGMENT_SHADER:
662 if (spec != SH_CSS_SHADERS_SPEC) {
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000663 // Set up gl_FragData. The array size.
shannonwoods@chromium.org09e09882013-05-30 00:18:25 +0000664 TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true);
alokp@chromium.org94a86ad2010-08-25 20:02:11 +0000665 fragData.setArraySize(resources.MaxDrawBuffers);
shannonwoods@chromium.org1c848092013-05-30 00:02:34 +0000666 symbolTable.insert(ESSL1_BUILTINS, *new TVariable(NewPoolTString("gl_FragData"), fragData));
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000667 }
668 break;
daniel@transgaming.com0578f812010-05-17 09:58:39 +0000669 default: break;
670 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000671}
672
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000673void InitExtensionBehavior(const ShBuiltInResources& resources,
alokp@chromium.orgad771eb2010-09-07 17:36:23 +0000674 TExtensionBehavior& extBehavior)
675{
676 if (resources.OES_standard_derivatives)
zmo@google.com09c323a2011-08-12 18:22:25 +0000677 extBehavior["GL_OES_standard_derivatives"] = EBhUndefined;
678 if (resources.OES_EGL_image_external)
679 extBehavior["GL_OES_EGL_image_external"] = EBhUndefined;
kbr@chromium.org205fef32011-11-22 20:50:02 +0000680 if (resources.ARB_texture_rectangle)
681 extBehavior["GL_ARB_texture_rectangle"] = EBhUndefined;
shannon.woods@transgaming.com550cd092013-02-28 23:19:54 +0000682 if (resources.EXT_draw_buffers)
683 extBehavior["GL_EXT_draw_buffers"] = EBhUndefined;
Jamie Madill2aeb26a2013-07-08 14:02:55 -0400684 if (resources.EXT_frag_depth)
685 extBehavior["GL_EXT_frag_depth"] = EBhUndefined;
alokp@chromium.orgad771eb2010-09-07 17:36:23 +0000686}