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 class VertexAttribute; 20 struct VertexAttribCurrentValueData; 21 22 enum TextureType 23 { 24 TEXTURE_2D, 25 TEXTURE_CUBE, 26 TEXTURE_3D, 27 TEXTURE_2D_ARRAY, 28 29 TEXTURE_TYPE_COUNT, 30 TEXTURE_UNKNOWN 31 }; 32 33 enum SamplerType 34 { 35 SAMPLER_PIXEL, 36 SAMPLER_VERTEX 37 }; 38 39 template <typename T> 40 struct Color 41 { 42 T red; 43 T green; 44 T blue; 45 T alpha; 46 ColorColor47 Color() : red(0), green(0), blue(0), alpha(0) { } ColorColor48 Color(T r, T g, T b, T a) : red(r), green(g), blue(b), alpha(a) { } 49 }; 50 51 typedef Color<float> ColorF; 52 typedef Color<int> ColorI; 53 typedef Color<unsigned int> ColorUI; 54 55 struct Rectangle 56 { 57 int x; 58 int y; 59 int width; 60 int height; 61 RectangleRectangle62 Rectangle() : x(0), y(0), width(0), height(0) { } RectangleRectangle63 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) { } 64 }; 65 66 bool ClipRectangle(const Rectangle &source, const Rectangle &clip, Rectangle *intersection); 67 68 struct Box 69 { 70 int x; 71 int y; 72 int z; 73 int width; 74 int height; 75 int depth; 76 BoxBox77 Box() : x(0), y(0), z(0), width(0), height(0), depth(0) { } BoxBox78 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) { } 79 }; 80 81 struct Extents 82 { 83 int width; 84 int height; 85 int depth; 86 ExtentsExtents87 Extents() : width(0), height(0), depth(0) { } ExtentsExtents88 Extents(int width_, int height_, int depth_) : width(width_), height(height_), depth(depth_) { } 89 }; 90 91 struct RasterizerState 92 { 93 bool cullFace; 94 GLenum cullMode; 95 GLenum frontFace; 96 97 bool polygonOffsetFill; 98 GLfloat polygonOffsetFactor; 99 GLfloat polygonOffsetUnits; 100 101 bool pointDrawMode; 102 bool multiSample; 103 104 bool rasterizerDiscard; 105 }; 106 107 struct BlendState 108 { 109 bool blend; 110 GLenum sourceBlendRGB; 111 GLenum destBlendRGB; 112 GLenum sourceBlendAlpha; 113 GLenum destBlendAlpha; 114 GLenum blendEquationRGB; 115 GLenum blendEquationAlpha; 116 117 bool colorMaskRed; 118 bool colorMaskGreen; 119 bool colorMaskBlue; 120 bool colorMaskAlpha; 121 122 bool sampleAlphaToCoverage; 123 124 bool dither; 125 }; 126 127 struct DepthStencilState 128 { 129 bool depthTest; 130 GLenum depthFunc; 131 bool depthMask; 132 133 bool stencilTest; 134 GLenum stencilFunc; 135 GLuint stencilMask; 136 GLenum stencilFail; 137 GLenum stencilPassDepthFail; 138 GLenum stencilPassDepthPass; 139 GLuint stencilWritemask; 140 GLenum stencilBackFunc; 141 GLuint stencilBackMask; 142 GLenum stencilBackFail; 143 GLenum stencilBackPassDepthFail; 144 GLenum stencilBackPassDepthPass; 145 GLuint stencilBackWritemask; 146 }; 147 148 struct SamplerState 149 { 150 GLenum minFilter; 151 GLenum magFilter; 152 GLenum wrapS; 153 GLenum wrapT; 154 GLenum wrapR; 155 float maxAnisotropy; 156 157 GLint baseLevel; 158 GLint maxLevel; 159 GLfloat minLod; 160 GLfloat maxLod; 161 162 GLenum compareMode; 163 GLenum compareFunc; 164 165 GLenum swizzleRed; 166 GLenum swizzleGreen; 167 GLenum swizzleBlue; 168 GLenum swizzleAlpha; 169 170 bool swizzleRequired() const; 171 }; 172 173 struct ClearParameters 174 { 175 bool clearColor[gl::IMPLEMENTATION_MAX_DRAW_BUFFERS]; 176 ColorF colorFClearValue; 177 ColorI colorIClearValue; 178 ColorUI colorUIClearValue; 179 GLenum colorClearType; 180 bool colorMaskRed; 181 bool colorMaskGreen; 182 bool colorMaskBlue; 183 bool colorMaskAlpha; 184 185 bool clearDepth; 186 float depthClearValue; 187 188 bool clearStencil; 189 GLint stencilClearValue; 190 GLuint stencilWriteMask; 191 192 bool scissorEnabled; 193 Rectangle scissor; 194 }; 195 196 struct PixelUnpackState 197 { 198 BindingPointer<Buffer> pixelBuffer; 199 GLint alignment; 200 PixelUnpackStatePixelUnpackState201 PixelUnpackState() 202 : alignment(4) 203 {} 204 PixelUnpackStatePixelUnpackState205 explicit PixelUnpackState(GLint alignmentIn) 206 : alignment(alignmentIn) 207 {} 208 }; 209 210 struct PixelPackState 211 { 212 BindingPointer<Buffer> pixelBuffer; 213 GLint alignment; 214 bool reverseRowOrder; 215 PixelPackStatePixelPackState216 PixelPackState() 217 : alignment(4), 218 reverseRowOrder(false) 219 {} 220 PixelPackStatePixelPackState221 explicit PixelPackState(GLint alignmentIn, bool reverseRowOrderIn) 222 : alignment(alignmentIn), 223 reverseRowOrder(reverseRowOrderIn) 224 {} 225 }; 226 227 struct VertexFormat 228 { 229 GLenum mType; 230 GLboolean mNormalized; 231 GLuint mComponents; 232 bool mPureInteger; 233 234 VertexFormat(); 235 VertexFormat(GLenum type, GLboolean normalized, GLuint components, bool pureInteger); 236 explicit VertexFormat(const VertexAttribute &attribute); 237 VertexFormat(const VertexAttribute &attribute, GLenum currentValueType); 238 239 static void GetInputLayout(VertexFormat *inputLayout, 240 ProgramBinary *programBinary, 241 const VertexAttribute *attributes, 242 const gl::VertexAttribCurrentValueData *currentValues); 243 244 bool operator==(const VertexFormat &other) const; 245 bool operator!=(const VertexFormat &other) const; 246 bool operator<(const VertexFormat& other) const; 247 }; 248 249 } 250 251 namespace rx 252 { 253 254 enum VertexConversionType 255 { 256 VERTEX_CONVERT_NONE = 0, 257 VERTEX_CONVERT_CPU = 1, 258 VERTEX_CONVERT_GPU = 2, 259 VERTEX_CONVERT_BOTH = 3 260 }; 261 262 enum D3DWorkaroundType 263 { 264 ANGLE_D3D_WORKAROUND_NONE, 265 ANGLE_D3D_WORKAROUND_SKIP_OPTIMIZATION, 266 ANGLE_D3D_WORKAROUND_MAX_OPTIMIZATION 267 }; 268 269 } 270 271 #endif // LIBGLESV2_ANGLETYPES_H_ 272