OSDN Git Service

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