2 // Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
7 #ifndef _BASICTYPES_INCLUDED_
8 #define _BASICTYPES_INCLUDED_
13 // Precision qualifiers
17 // These need to be kept sorted
24 inline const char* getPrecisionString(TPrecision p)
28 case EbpHigh: return "highp"; break;
29 case EbpMedium: return "mediump"; break;
30 case EbpLow: return "lowp"; break;
31 default: return "mediump"; break; // Safest fallback
36 // Basic type. Arrays, vectors, etc., are orthogonal to this.
45 EbtGVec4, // non type: represents vec4, ivec4 and uvec4
46 EbtGuardSamplerBegin, // non type: see implementation of IsSampler()
51 EbtSamplerExternalOES, // Only valid if OES_EGL_image_external exists.
52 EbtSampler2DRect, // Only valid if GL_ARB_texture_rectangle exists.
63 EbtSampler2DArrayShadow,
64 EbtGuardSamplerEnd, // non type: see implementation of IsSampler()
65 EbtGSampler2D, // non type: represents sampler2D, isampler2D and usampler2D
66 EbtGSampler3D, // non type: represents sampler3D, isampler3D and usampler3D
67 EbtGSamplerCube, // non type: represents samplerCube, isamplerCube and usamplerCube
68 EbtGSampler2DArray, // non type: represents sampler2DArray, isampler2DArray and usampler2DArray
71 EbtAddress, // should be deprecated??
72 EbtInvariant // used as a type when qualifying a previously declared variable as being invariant
75 const char* getBasicString(TBasicType t);
77 inline bool IsSampler(TBasicType type)
79 return type > EbtGuardSamplerBegin && type < EbtGuardSamplerEnd;
82 inline bool IsIntegerSampler(TBasicType type)
89 case EbtISampler2DArray:
93 case EbtUSampler2DArray:
98 case EbtSamplerExternalOES:
99 case EbtSampler2DRect:
100 case EbtSampler2DArray:
101 case EbtSampler2DShadow:
102 case EbtSamplerCubeShadow:
103 case EbtSampler2DArrayShadow:
106 assert(!IsSampler(type));
112 inline bool IsSampler2D(TBasicType type)
119 case EbtSampler2DArray:
120 case EbtISampler2DArray:
121 case EbtUSampler2DArray:
122 case EbtSampler2DRect:
123 case EbtSamplerExternalOES:
124 case EbtSampler2DShadow:
125 case EbtSampler2DArrayShadow:
130 case EbtISamplerCube:
131 case EbtUSamplerCube:
133 case EbtSamplerCubeShadow:
136 assert(!IsSampler(type));
142 inline bool IsSamplerCube(TBasicType type)
147 case EbtISamplerCube:
148 case EbtUSamplerCube:
149 case EbtSamplerCubeShadow:
153 case EbtSamplerExternalOES:
154 case EbtSampler2DRect:
155 case EbtSampler2DArray:
158 case EbtISampler2DArray:
161 case EbtUSampler2DArray:
162 case EbtSampler2DShadow:
163 case EbtSampler2DArrayShadow:
166 assert(!IsSampler(type));
172 inline bool IsSampler3D(TBasicType type)
182 case EbtSamplerExternalOES:
183 case EbtSampler2DRect:
184 case EbtSampler2DArray:
186 case EbtISamplerCube:
187 case EbtISampler2DArray:
189 case EbtUSamplerCube:
190 case EbtUSampler2DArray:
191 case EbtSampler2DShadow:
192 case EbtSamplerCubeShadow:
193 case EbtSampler2DArrayShadow:
196 assert(!IsSampler(type));
202 inline bool IsSamplerArray(TBasicType type)
206 case EbtSampler2DArray:
207 case EbtISampler2DArray:
208 case EbtUSampler2DArray:
209 case EbtSampler2DArrayShadow:
214 case EbtSampler2DRect:
215 case EbtSamplerExternalOES:
219 case EbtISamplerCube:
220 case EbtUSamplerCube:
222 case EbtSampler2DShadow:
223 case EbtSamplerCubeShadow:
226 assert(!IsSampler(type));
232 inline bool IsShadowSampler(TBasicType type)
236 case EbtSampler2DShadow:
237 case EbtSamplerCubeShadow:
238 case EbtSampler2DArrayShadow:
242 case EbtISamplerCube:
243 case EbtISampler2DArray:
246 case EbtUSamplerCube:
247 case EbtUSampler2DArray:
251 case EbtSamplerExternalOES:
252 case EbtSampler2DRect:
253 case EbtSampler2DArray:
256 assert(!IsSampler(type));
262 inline bool SupportsPrecision(TBasicType type)
264 return type == EbtFloat || type == EbtInt || type == EbtUInt || IsSampler(type);
268 // Qualifiers and built-ins. These are mainly used to see what can be read
269 // or written, and by the machine dependent translator to know which registers
270 // to allocate variables in. Since built-ins tend to go to different registers
271 // than varying or uniform, it makes sense they are peers, not sub-classes.
275 EvqTemporary, // For temporaries (within a function), read/write
276 EvqGlobal, // For globals read/write
277 EvqInternal, // For internal use, not visible to the user
278 EvqConst, // User defined constants and non-output parameters in functions
279 EvqAttribute, // Readonly
280 EvqVaryingIn, // readonly, fragment shaders only
281 EvqVaryingOut, // vertex shaders only read/write
282 EvqInvariantVaryingIn, // readonly, fragment shaders only
283 EvqInvariantVaryingOut, // vertex shaders only read/write
284 EvqUniform, // Readonly, vertex and fragment
286 EvqVertexIn, // Vertex shader input
287 EvqFragmentOut, // Fragment shader output
288 EvqVertexOut, // Vertex shader output
289 EvqFragmentIn, // Fragment shader input
297 // built-ins written by vertex shader
301 // built-ins read by fragment shader
306 // built-ins written by fragment shader
311 // GLSL ES 3.0 vertex output and fragment input
312 EvqSmooth, // Incomplete qualifier, smooth is the default
313 EvqFlat, // Incomplete qualifier
314 EvqSmoothOut = EvqSmooth,
315 EvqFlatOut = EvqFlat,
316 EvqCentroidOut, // Implies smooth
319 EvqCentroidIn, // Implies smooth
325 enum TLayoutMatrixPacking
332 enum TLayoutBlockStorage
340 struct TLayoutQualifier
343 TLayoutMatrixPacking matrixPacking;
344 TLayoutBlockStorage blockStorage;
346 static TLayoutQualifier create()
348 TLayoutQualifier layoutQualifier;
350 layoutQualifier.location = -1;
351 layoutQualifier.matrixPacking = EmpUnspecified;
352 layoutQualifier.blockStorage = EbsUnspecified;
354 return layoutQualifier;
359 return location == -1 && matrixPacking == EmpUnspecified && blockStorage == EbsUnspecified;
364 // This is just for debug print out, carried along with the definitions above.
366 inline const char* getQualifierString(TQualifier q)
370 case EvqTemporary: return "Temporary"; break;
371 case EvqGlobal: return "Global"; break;
372 case EvqConst: return "const"; break;
373 case EvqConstReadOnly: return "const"; break;
374 case EvqAttribute: return "attribute"; break;
375 case EvqVaryingIn: return "varying"; break;
376 case EvqVaryingOut: return "varying"; break;
377 case EvqInvariantVaryingIn: return "invariant varying"; break;
378 case EvqInvariantVaryingOut:return "invariant varying"; break;
379 case EvqUniform: return "uniform"; break;
380 case EvqVertexIn: return "in"; break;
381 case EvqFragmentOut: return "out"; break;
382 case EvqVertexOut: return "out"; break;
383 case EvqFragmentIn: return "in"; break;
384 case EvqIn: return "in"; break;
385 case EvqOut: return "out"; break;
386 case EvqInOut: return "inout"; break;
387 case EvqPosition: return "Position"; break;
388 case EvqPointSize: return "PointSize"; break;
389 case EvqFragCoord: return "FragCoord"; break;
390 case EvqFrontFacing: return "FrontFacing"; break;
391 case EvqFragColor: return "FragColor"; break;
392 case EvqFragData: return "FragData"; break;
393 case EvqFragDepth: return "FragDepth"; break;
394 case EvqSmoothOut: return "smooth out"; break;
395 case EvqCentroidOut: return "centroid out"; break;
396 case EvqFlatOut: return "flat out"; break;
397 case EvqSmoothIn: return "smooth in"; break;
398 case EvqCentroidIn: return "centroid in"; break;
399 case EvqFlatIn: return "flat in"; break;
400 default: return "unknown qualifier";
404 inline const char* getMatrixPackingString(TLayoutMatrixPacking mpq)
408 case EmpUnspecified: return "mp_unspecified";
409 case EmpRowMajor: return "row_major";
410 case EmpColumnMajor: return "column_major";
411 default: return "unknown matrix packing";
415 inline const char* getBlockStorageString(TLayoutBlockStorage bsq)
419 case EbsUnspecified: return "bs_unspecified";
420 case EbsShared: return "shared";
421 case EbsPacked: return "packed";
422 case EbsStd140: return "std140";
423 default: return "unknown block storage";
427 inline const char* getInterpolationString(TQualifier q)
431 case EvqSmoothOut: return "smooth"; break;
432 case EvqCentroidOut: return "centroid"; break;
433 case EvqFlatOut: return "flat"; break;
434 case EvqSmoothIn: return "smooth"; break;
435 case EvqCentroidIn: return "centroid"; break;
436 case EvqFlatIn: return "flat"; break;
437 default: return "unknown interpolation";
441 #endif // _BASICTYPES_INCLUDED_