1 : //
2 : // Copyright (c) 2002-2010 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.
5 : //
6 :
7 : #ifndef _BASICTYPES_INCLUDED_
8 : #define _BASICTYPES_INCLUDED_
9 :
10 : //
11 : // Precision qualifiers
12 : //
13 : enum TPrecision
14 : {
15 : // These need to be kept sorted
16 : EbpUndefined,
17 : EbpLow,
18 : EbpMedium,
19 : EbpHigh,
20 : };
21 :
22 0 : inline const char* getPrecisionString(TPrecision p)
23 : {
24 0 : switch(p)
25 : {
26 0 : case EbpHigh: return "highp"; break;
27 0 : case EbpMedium: return "mediump"; break;
28 0 : case EbpLow: return "lowp"; break;
29 0 : default: return "mediump"; break; // Safest fallback
30 : }
31 : }
32 :
33 : //
34 : // Basic type. Arrays, vectors, etc., are orthogonal to this.
35 : //
36 : enum TBasicType
37 : {
38 : EbtVoid,
39 : EbtFloat,
40 : EbtInt,
41 : EbtBool,
42 : EbtGuardSamplerBegin, // non type: see implementation of IsSampler()
43 : EbtSampler2D,
44 : EbtSamplerCube,
45 : EbtSamplerExternalOES, // Only valid if OES_EGL_image_external exists.
46 : EbtSampler2DRect, // Only valid if GL_ARB_texture_rectangle exists.
47 : EbtGuardSamplerEnd, // non type: see implementation of IsSampler()
48 : EbtStruct,
49 : EbtAddress, // should be deprecated??
50 : };
51 :
52 0 : inline const char* getBasicString(TBasicType t)
53 : {
54 0 : switch (t)
55 : {
56 0 : case EbtVoid: return "void"; break;
57 0 : case EbtFloat: return "float"; break;
58 0 : case EbtInt: return "int"; break;
59 0 : case EbtBool: return "bool"; break;
60 0 : case EbtSampler2D: return "sampler2D"; break;
61 0 : case EbtSamplerCube: return "samplerCube"; break;
62 0 : case EbtSamplerExternalOES: return "samplerExternalOES"; break;
63 0 : case EbtSampler2DRect: return "sampler2DRect"; break;
64 0 : case EbtStruct: return "structure"; break;
65 0 : default: return "unknown type";
66 : }
67 : }
68 :
69 0 : inline bool IsSampler(TBasicType type)
70 : {
71 0 : return type > EbtGuardSamplerBegin && type < EbtGuardSamplerEnd;
72 : }
73 :
74 : //
75 : // Qualifiers and built-ins. These are mainly used to see what can be read
76 : // or written, and by the machine dependent translator to know which registers
77 : // to allocate variables in. Since built-ins tend to go to different registers
78 : // than varying or uniform, it makes sense they are peers, not sub-classes.
79 : //
80 : enum TQualifier
81 : {
82 : EvqTemporary, // For temporaries (within a function), read/write
83 : EvqGlobal, // For globals read/write
84 : EvqConst, // User defined constants and non-output parameters in functions
85 : EvqAttribute, // Readonly
86 : EvqVaryingIn, // readonly, fragment shaders only
87 : EvqVaryingOut, // vertex shaders only read/write
88 : EvqInvariantVaryingIn, // readonly, fragment shaders only
89 : EvqInvariantVaryingOut, // vertex shaders only read/write
90 : EvqUniform, // Readonly, vertex and fragment
91 :
92 : // pack/unpack input and output
93 : EvqInput,
94 : EvqOutput,
95 :
96 : // parameters
97 : EvqIn,
98 : EvqOut,
99 : EvqInOut,
100 : EvqConstReadOnly,
101 :
102 : // built-ins written by vertex shader
103 : EvqPosition,
104 : EvqPointSize,
105 :
106 : // built-ins read by fragment shader
107 : EvqFragCoord,
108 : EvqFrontFacing,
109 : EvqPointCoord,
110 :
111 : // built-ins written by fragment shader
112 : EvqFragColor,
113 : EvqFragData,
114 :
115 : // end of list
116 : EvqLast,
117 : };
118 :
119 : //
120 : // This is just for debug print out, carried along with the definitions above.
121 : //
122 0 : inline const char* getQualifierString(TQualifier q)
123 : {
124 0 : switch(q)
125 : {
126 0 : case EvqTemporary: return "Temporary"; break;
127 0 : case EvqGlobal: return "Global"; break;
128 0 : case EvqConst: return "const"; break;
129 0 : case EvqConstReadOnly: return "const"; break;
130 0 : case EvqAttribute: return "attribute"; break;
131 0 : case EvqVaryingIn: return "varying"; break;
132 0 : case EvqVaryingOut: return "varying"; break;
133 0 : case EvqInvariantVaryingIn: return "invariant varying"; break;
134 0 : case EvqInvariantVaryingOut:return "invariant varying"; break;
135 0 : case EvqUniform: return "uniform"; break;
136 0 : case EvqIn: return "in"; break;
137 0 : case EvqOut: return "out"; break;
138 0 : case EvqInOut: return "inout"; break;
139 0 : case EvqInput: return "input"; break;
140 0 : case EvqOutput: return "output"; break;
141 0 : case EvqPosition: return "Position"; break;
142 0 : case EvqPointSize: return "PointSize"; break;
143 0 : case EvqFragCoord: return "FragCoord"; break;
144 0 : case EvqFrontFacing: return "FrontFacing"; break;
145 0 : case EvqFragColor: return "FragColor"; break;
146 0 : case EvqFragData: return "FragData"; break;
147 0 : default: return "unknown qualifier";
148 : }
149 : }
150 :
151 : #endif // _BASICTYPES_INCLUDED_
|