• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (c) 2012-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 // angletypes.h : Defines a variety of structures and enum types that are used throughout libGLESv2
8 
9 #ifndef LIBGLESV2_ANGLETYPES_H_
10 #define LIBGLESV2_ANGLETYPES_H_
11 
12 #include "libGLESv2/constants.h"
13 #include "common/RefCountObject.h"
14 
15 namespace gl
16 {
17 class Buffer;
18 class ProgramBinary;
19 struct VertexAttribute;
20 struct VertexAttribCurrentValueData;
21 
22 enum SamplerType
23 {
24     SAMPLER_PIXEL,
25     SAMPLER_VERTEX
26 };
27 
28 template <typename T>
29 struct Color
30 {
31     T red;
32     T green;
33     T blue;
34     T alpha;
35 
ColorColor36     Color() : red(0), green(0), blue(0), alpha(0) { }
ColorColor37     Color(T r, T g, T b, T a) : red(r), green(g), blue(b), alpha(a) { }
38 };
39 
40 typedef Color<float> ColorF;
41 typedef Color<int> ColorI;
42 typedef Color<unsigned int> ColorUI;
43 
44 struct Rectangle
45 {
46     int x;
47     int y;
48     int width;
49     int height;
50 
RectangleRectangle51     Rectangle() : x(0), y(0), width(0), height(0) { }
RectangleRectangle52     Rectangle(int x_in, int y_in, int width_in, int height_in) : x(x_in), y(y_in), width(width_in), height(height_in) { }
53 };
54 
55 bool ClipRectangle(const Rectangle &source, const Rectangle &clip, Rectangle *intersection);
56 
57 struct Box
58 {
59     int x;
60     int y;
61     int z;
62     int width;
63     int height;
64     int depth;
65 
BoxBox66     Box() : x(0), y(0), z(0), width(0), height(0), depth(0) { }
BoxBox67     Box(int x_in, int y_in, int z_in, int width_in, int height_in, int depth_in) : x(x_in), y(y_in), z(z_in), width(width_in), height(height_in), depth(depth_in) { }
68 };
69 
70 struct Extents
71 {
72     int width;
73     int height;
74     int depth;
75 
ExtentsExtents76     Extents() : width(0), height(0), depth(0) { }
ExtentsExtents77     Extents(int width_, int height_, int depth_) : width(width_), height(height_), depth(depth_) { }
78 };
79 
80 struct RasterizerState
81 {
82     bool cullFace;
83     GLenum cullMode;
84     GLenum frontFace;
85 
86     bool polygonOffsetFill;
87     GLfloat polygonOffsetFactor;
88     GLfloat polygonOffsetUnits;
89 
90     bool pointDrawMode;
91     bool multiSample;
92 
93     bool rasterizerDiscard;
94 };
95 
96 struct BlendState
97 {
98     bool blend;
99     GLenum sourceBlendRGB;
100     GLenum destBlendRGB;
101     GLenum sourceBlendAlpha;
102     GLenum destBlendAlpha;
103     GLenum blendEquationRGB;
104     GLenum blendEquationAlpha;
105 
106     bool colorMaskRed;
107     bool colorMaskGreen;
108     bool colorMaskBlue;
109     bool colorMaskAlpha;
110 
111     bool sampleAlphaToCoverage;
112 
113     bool dither;
114 };
115 
116 struct DepthStencilState
117 {
118     bool depthTest;
119     GLenum depthFunc;
120     bool depthMask;
121 
122     bool stencilTest;
123     GLenum stencilFunc;
124     GLuint stencilMask;
125     GLenum stencilFail;
126     GLenum stencilPassDepthFail;
127     GLenum stencilPassDepthPass;
128     GLuint stencilWritemask;
129     GLenum stencilBackFunc;
130     GLuint stencilBackMask;
131     GLenum stencilBackFail;
132     GLenum stencilBackPassDepthFail;
133     GLenum stencilBackPassDepthPass;
134     GLuint stencilBackWritemask;
135 };
136 
137 struct SamplerState
138 {
139     SamplerState();
140 
141     GLenum minFilter;
142     GLenum magFilter;
143     GLenum wrapS;
144     GLenum wrapT;
145     GLenum wrapR;
146     float maxAnisotropy;
147 
148     GLint baseLevel;
149     GLint maxLevel;
150     GLfloat minLod;
151     GLfloat maxLod;
152 
153     GLenum compareMode;
154     GLenum compareFunc;
155 
156     GLenum swizzleRed;
157     GLenum swizzleGreen;
158     GLenum swizzleBlue;
159     GLenum swizzleAlpha;
160 
161     bool swizzleRequired() const;
162 };
163 
164 struct ClearParameters
165 {
166     bool clearColor[gl::IMPLEMENTATION_MAX_DRAW_BUFFERS];
167     ColorF colorFClearValue;
168     ColorI colorIClearValue;
169     ColorUI colorUIClearValue;
170     GLenum colorClearType;
171     bool colorMaskRed;
172     bool colorMaskGreen;
173     bool colorMaskBlue;
174     bool colorMaskAlpha;
175 
176     bool clearDepth;
177     float depthClearValue;
178 
179     bool clearStencil;
180     GLint stencilClearValue;
181     GLuint stencilWriteMask;
182 
183     bool scissorEnabled;
184     Rectangle scissor;
185 };
186 
187 struct PixelUnpackState
188 {
189     BindingPointer<Buffer> pixelBuffer;
190     GLint alignment;
191 
PixelUnpackStatePixelUnpackState192     PixelUnpackState()
193         : alignment(4)
194     {}
195 
PixelUnpackStatePixelUnpackState196     explicit PixelUnpackState(GLint alignmentIn)
197         : alignment(alignmentIn)
198     {}
199 };
200 
201 struct PixelPackState
202 {
203     BindingPointer<Buffer> pixelBuffer;
204     GLint alignment;
205     bool reverseRowOrder;
206 
PixelPackStatePixelPackState207     PixelPackState()
208         : alignment(4),
209           reverseRowOrder(false)
210     {}
211 
PixelPackStatePixelPackState212     explicit PixelPackState(GLint alignmentIn, bool reverseRowOrderIn)
213         : alignment(alignmentIn),
214           reverseRowOrder(reverseRowOrderIn)
215     {}
216 };
217 
218 struct VertexFormat
219 {
220     GLenum      mType;
221     GLboolean   mNormalized;
222     GLuint      mComponents;
223     bool        mPureInteger;
224 
225     VertexFormat();
226     VertexFormat(GLenum type, GLboolean normalized, GLuint components, bool pureInteger);
227     explicit VertexFormat(const VertexAttribute &attribute);
228     VertexFormat(const VertexAttribute &attribute, GLenum currentValueType);
229 
230     static void GetInputLayout(VertexFormat *inputLayout,
231                                ProgramBinary *programBinary,
232                                const VertexAttribute *attributes,
233                                const gl::VertexAttribCurrentValueData *currentValues);
234 
235     bool operator==(const VertexFormat &other) const;
236     bool operator!=(const VertexFormat &other) const;
237     bool operator<(const VertexFormat& other) const;
238 };
239 
240 }
241 
242 namespace rx
243 {
244 
245 enum VertexConversionType
246 {
247     VERTEX_CONVERT_NONE = 0,
248     VERTEX_CONVERT_CPU  = 1,
249     VERTEX_CONVERT_GPU  = 2,
250     VERTEX_CONVERT_BOTH = 3
251 };
252 
253 enum D3DWorkaroundType
254 {
255     ANGLE_D3D_WORKAROUND_NONE,
256     ANGLE_D3D_WORKAROUND_SKIP_OPTIMIZATION,
257     ANGLE_D3D_WORKAROUND_MAX_OPTIMIZATION
258 };
259 
260 }
261 
262 #endif // LIBGLESV2_ANGLETYPES_H_
263