diff options
Diffstat (limited to 'src/3rdparty/angle/src/libANGLE/angletypes.h')
-rw-r--r-- | src/3rdparty/angle/src/libANGLE/angletypes.h | 181 |
1 files changed, 135 insertions, 46 deletions
diff --git a/src/3rdparty/angle/src/libANGLE/angletypes.h b/src/3rdparty/angle/src/libANGLE/angletypes.h index e4e08b5512..c29ad06bd2 100644 --- a/src/3rdparty/angle/src/libANGLE/angletypes.h +++ b/src/3rdparty/angle/src/libANGLE/angletypes.h @@ -13,7 +13,8 @@ #include "libANGLE/RefCountObject.h" #include <stdint.h> -#include <float.h> + +#include <bitset> namespace gl { @@ -23,6 +24,20 @@ class Program; struct VertexAttribute; struct VertexAttribCurrentValueData; +enum PrimitiveType +{ + PRIMITIVE_POINTS, + PRIMITIVE_LINES, + PRIMITIVE_LINE_STRIP, + PRIMITIVE_LINE_LOOP, + PRIMITIVE_TRIANGLES, + PRIMITIVE_TRIANGLE_STRIP, + PRIMITIVE_TRIANGLE_FAN, + PRIMITIVE_TYPE_MAX, +}; + +PrimitiveType GetPrimitiveType(GLenum drawMode); + enum SamplerType { SAMPLER_PIXEL, @@ -42,19 +57,10 @@ struct Color }; template <typename T> -bool operator==(const Color<T> &a, const Color<T> &b) -{ - return a.red == b.red && - a.green == b.green && - a.blue == b.blue && - a.alpha == b.alpha; -} +bool operator==(const Color<T> &a, const Color<T> &b); template <typename T> -bool operator!=(const Color<T> &a, const Color<T> &b) -{ - return !(a == b); -} +bool operator!=(const Color<T> &a, const Color<T> &b); typedef Color<float> ColorF; typedef Color<int> ColorI; @@ -62,13 +68,21 @@ typedef Color<unsigned int> ColorUI; struct Rectangle { + Rectangle() : x(0), y(0), width(0), height(0) {} + 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) + { + } + + int x0() const { return x; } + int y0() const { return y; } + int x1() const { return x + width; } + int y1() const { return y + height; } + int x; int y; int width; int height; - - Rectangle() : x(0), y(0), width(0), height(0) { } - 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) { } }; bool operator==(const Rectangle &a, const Rectangle &b); @@ -98,6 +112,9 @@ struct Extents bool empty() const { return (width * height * depth) == 0; } }; +bool operator==(const Extents &lhs, const Extents &rhs); +bool operator!=(const Extents &lhs, const Extents &rhs); + struct Box { int x; @@ -172,36 +189,58 @@ struct DepthStencilState GLuint stencilBackWritemask; }; +// State from Table 6.10 (state per sampler object) struct SamplerState { SamplerState(); GLenum minFilter; GLenum magFilter; + GLenum wrapS; GLenum wrapT; GLenum wrapR; + + // From EXT_texture_filter_anisotropic float maxAnisotropy; - GLint baseLevel; - GLint maxLevel; GLfloat minLod; GLfloat maxLod; GLenum compareMode; GLenum compareFunc; +}; + +bool operator==(const SamplerState &a, const SamplerState &b); +bool operator!=(const SamplerState &a, const SamplerState &b); + +// State from Table 6.9 (state per texture object) in the OpenGL ES 3.0.2 spec. +struct TextureState +{ + TextureState(); GLenum swizzleRed; GLenum swizzleGreen; GLenum swizzleBlue; GLenum swizzleAlpha; - bool swizzleRequired() const; + SamplerState samplerState; + + GLuint baseLevel; + GLuint maxLevel; - bool operator==(const SamplerState &other) const; - bool operator!=(const SamplerState &other) const; + bool immutableFormat; + GLuint immutableLevels; + + // From GL_ANGLE_texture_usage + GLenum usage; + + bool swizzleRequired() const; }; +bool operator==(const TextureState &a, const TextureState &b); +bool operator!=(const TextureState &a, const TextureState &b); + struct PixelUnpackState { BindingPointer<Buffer> pixelBuffer; @@ -257,54 +296,56 @@ struct PixelPackState {} }; -struct VertexFormat -{ - GLenum mType; - GLboolean mNormalized; - GLuint mComponents; - bool mPureInteger; - - VertexFormat(); - VertexFormat(GLenum type, GLboolean normalized, GLuint components, bool pureInteger); - explicit VertexFormat(const VertexAttribute &attribute); - VertexFormat(const VertexAttribute &attribute, GLenum currentValueType); - - static void GetInputLayout(VertexFormat *inputLayout, - Program *program, - const State& currentValues); - - bool operator==(const VertexFormat &other) const; - bool operator!=(const VertexFormat &other) const; - bool operator<(const VertexFormat& other) const; -}; +// Used in Program and VertexArray. +typedef std::bitset<MAX_VERTEX_ATTRIBS> AttributesMask; +// Use in Program +typedef std::bitset<IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS> UniformBlockBindingMask; } namespace rx { - enum VendorID : uint32_t { - VENDOR_ID_AMD = 0x1002, - VENDOR_ID_INTEL = 0x8086, - VENDOR_ID_NVIDIA = 0x10DE, + VENDOR_ID_UNKNOWN = 0x0, + VENDOR_ID_AMD = 0x1002, + VENDOR_ID_INTEL = 0x8086, + VENDOR_ID_NVIDIA = 0x10DE, }; +// A macro that determines whether an object has a given runtime type. +#if defined(__clang__) +#if __has_feature(cxx_rtti) +#define ANGLE_HAS_DYNAMIC_CAST 1 +#endif +#elif !defined(NDEBUG) && (!defined(_MSC_VER) || defined(_CPPRTTI)) && (!defined(__GNUC__) || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) || defined(__GXX_RTTI)) +#define ANGLE_HAS_DYNAMIC_CAST 1 +#endif + +#ifdef ANGLE_HAS_DYNAMIC_CAST +#define ANGLE_HAS_DYNAMIC_TYPE(type, obj) (dynamic_cast<type >(obj) != nullptr) +#undef ANGLE_HAS_DYNAMIC_CAST +#else +#define ANGLE_HAS_DYNAMIC_TYPE(type, obj) (obj != nullptr) +#endif + // Downcast a base implementation object (EG TextureImpl to TextureD3D) template <typename DestT, typename SrcT> inline DestT *GetAs(SrcT *src) { - ASSERT(HAS_DYNAMIC_TYPE(DestT*, src)); + ASSERT(ANGLE_HAS_DYNAMIC_TYPE(DestT*, src)); return static_cast<DestT*>(src); } template <typename DestT, typename SrcT> inline const DestT *GetAs(const SrcT *src) { - ASSERT(HAS_DYNAMIC_TYPE(const DestT*, src)); + ASSERT(ANGLE_HAS_DYNAMIC_TYPE(const DestT*, src)); return static_cast<const DestT*>(src); } +#undef ANGLE_HAS_DYNAMIC_TYPE + // Downcast a GL object to an Impl (EG gl::Texture to rx::TextureD3D) template <typename DestT, typename SrcT> inline DestT *GetImplAs(SrcT *src) @@ -320,4 +361,52 @@ inline const DestT *GetImplAs(const SrcT *src) } +#include "angletypes.inl" + +namespace angle +{ +// Zero-based for better array indexing +enum FramebufferBinding +{ + FramebufferBindingRead = 0, + FramebufferBindingDraw, + FramebufferBindingSingletonMax, + FramebufferBindingBoth = FramebufferBindingSingletonMax, + FramebufferBindingMax, + FramebufferBindingUnknown = FramebufferBindingMax, +}; + +inline FramebufferBinding EnumToFramebufferBinding(GLenum enumValue) +{ + switch (enumValue) + { + case GL_READ_FRAMEBUFFER: + return FramebufferBindingRead; + case GL_DRAW_FRAMEBUFFER: + return FramebufferBindingDraw; + case GL_FRAMEBUFFER: + return FramebufferBindingBoth; + default: + UNREACHABLE(); + return FramebufferBindingUnknown; + } +} + +inline GLenum FramebufferBindingToEnum(FramebufferBinding binding) +{ + switch (binding) + { + case FramebufferBindingRead: + return GL_READ_FRAMEBUFFER; + case FramebufferBindingDraw: + return GL_DRAW_FRAMEBUFFER; + case FramebufferBindingBoth: + return GL_FRAMEBUFFER; + default: + UNREACHABLE(); + return GL_NONE; + } +} +} + #endif // LIBANGLE_ANGLETYPES_H_ |