initial import
[vuplus_webkit] / Source / ThirdParty / ANGLE / src / compiler / BaseTypes.h
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 inline const char* getPrecisionString(TPrecision p)
23 {
24     switch(p)
25     {
26     case EbpHigh:               return "highp";         break;
27     case EbpMedium:             return "mediump";       break;
28     case EbpLow:                return "lowp";          break;
29     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     EbtGuardSamplerEnd,    // non type:  see implementation of IsSampler()
46     EbtStruct,
47     EbtAddress,            // should be deprecated??
48 };
49
50 inline const char* getBasicString(TBasicType t)
51 {
52     switch (t)
53     {
54     case EbtVoid:              return "void";              break;
55     case EbtFloat:             return "float";             break;
56     case EbtInt:               return "int";               break;
57     case EbtBool:              return "bool";              break;
58     case EbtSampler2D:         return "sampler2D";         break;
59     case EbtSamplerCube:       return "samplerCube";       break;
60     case EbtStruct:            return "structure";         break;
61     default:                   return "unknown type";
62     }
63 }
64
65 inline bool IsSampler(TBasicType type)
66 {
67     return type > EbtGuardSamplerBegin && type < EbtGuardSamplerEnd;
68 }
69
70 //
71 // Qualifiers and built-ins.  These are mainly used to see what can be read
72 // or written, and by the machine dependent translator to know which registers
73 // to allocate variables in.  Since built-ins tend to go to different registers
74 // than varying or uniform, it makes sense they are peers, not sub-classes.
75 //
76 enum TQualifier
77 {
78     EvqTemporary,     // For temporaries (within a function), read/write
79     EvqGlobal,        // For globals read/write
80     EvqConst,         // User defined constants and non-output parameters in functions
81     EvqAttribute,     // Readonly
82     EvqVaryingIn,     // readonly, fragment shaders only
83     EvqVaryingOut,    // vertex shaders only  read/write
84     EvqInvariantVaryingIn,     // readonly, fragment shaders only
85     EvqInvariantVaryingOut,    // vertex shaders only  read/write
86     EvqUniform,       // Readonly, vertex and fragment
87
88     // pack/unpack input and output
89     EvqInput,
90     EvqOutput,
91
92     // parameters
93     EvqIn,
94     EvqOut,
95     EvqInOut,
96     EvqConstReadOnly,
97
98     // built-ins written by vertex shader
99     EvqPosition,
100     EvqPointSize,
101
102     // built-ins read by fragment shader
103     EvqFragCoord,
104     EvqFrontFacing,
105     EvqPointCoord,
106
107     // built-ins written by fragment shader
108     EvqFragColor,
109     EvqFragData,
110
111     // end of list
112     EvqLast,
113 };
114
115 //
116 // This is just for debug print out, carried along with the definitions above.
117 //
118 inline const char* getQualifierString(TQualifier q)
119 {
120     switch(q)
121     {
122     case EvqTemporary:      return "Temporary";      break;
123     case EvqGlobal:         return "Global";         break;
124     case EvqConst:          return "const";          break;
125     case EvqConstReadOnly:  return "const";          break;
126     case EvqAttribute:      return "attribute";      break;
127     case EvqVaryingIn:      return "varying";        break;
128     case EvqVaryingOut:     return "varying";        break;
129     case EvqInvariantVaryingIn: return "invariant varying";     break;
130     case EvqInvariantVaryingOut:return "invariant varying";     break;
131     case EvqUniform:        return "uniform";        break;
132     case EvqIn:             return "in";             break;
133     case EvqOut:            return "out";            break;
134     case EvqInOut:          return "inout";          break;
135     case EvqInput:          return "input";          break;
136     case EvqOutput:         return "output";         break;
137     case EvqPosition:       return "Position";       break;
138     case EvqPointSize:      return "PointSize";      break;
139     case EvqFragCoord:      return "FragCoord";      break;
140     case EvqFrontFacing:    return "FrontFacing";    break;
141     case EvqFragColor:      return "FragColor";      break;
142     case EvqFragData:       return "FragData";      break;
143     default:                return "unknown qualifier";
144     }
145 }
146
147 #endif // _BASICTYPES_INCLUDED_