diff options
Diffstat (limited to 'src/3rdparty/angle/src/libANGLE/angletypes.h')
-rw-r--r-- | src/3rdparty/angle/src/libANGLE/angletypes.h | 307 |
1 files changed, 191 insertions, 116 deletions
diff --git a/src/3rdparty/angle/src/libANGLE/angletypes.h b/src/3rdparty/angle/src/libANGLE/angletypes.h index c29ad06bd2..4f364b090a 100644 --- a/src/3rdparty/angle/src/libANGLE/angletypes.h +++ b/src/3rdparty/angle/src/libANGLE/angletypes.h @@ -9,20 +9,22 @@ #ifndef LIBANGLE_ANGLETYPES_H_ #define LIBANGLE_ANGLETYPES_H_ +#include "common/bitset_utils.h" #include "libANGLE/Constants.h" +#include "libANGLE/Error.h" +#include "libANGLE/PackedGLEnums.h" #include "libANGLE/RefCountObject.h" #include <stdint.h> #include <bitset> +#include <map> +#include <unordered_map> namespace gl { class Buffer; -class State; -class Program; -struct VertexAttribute; -struct VertexAttribCurrentValueData; +class Texture; enum PrimitiveType { @@ -41,31 +43,19 @@ PrimitiveType GetPrimitiveType(GLenum drawMode); enum SamplerType { SAMPLER_PIXEL, - SAMPLER_VERTEX + SAMPLER_VERTEX, + SAMPLER_COMPUTE }; -template <typename T> -struct Color +enum ShaderType { - T red; - T green; - T blue; - T alpha; - - Color() : red(0), green(0), blue(0), alpha(0) { } - Color(T r, T g, T b, T a) : red(r), green(g), blue(b), alpha(a) { } + SHADER_VERTEX, + SHADER_FRAGMENT, + SHADER_GEOMETRY, + SHADER_COMPUTE, + SHADER_TYPE_MAX }; -template <typename T> -bool operator==(const Color<T> &a, const Color<T> &b); - -template <typename T> -bool operator!=(const Color<T> &a, const Color<T> &b); - -typedef Color<float> ColorF; -typedef Color<int> ColorI; -typedef Color<unsigned int> ColorUI; - struct Rectangle { Rectangle() : x(0), y(0), width(0), height(0) {} @@ -100,6 +90,9 @@ struct Offset Offset(int x_in, int y_in, int z_in) : x(x_in), y(y_in), z(z_in) { } }; +bool operator==(const Offset &a, const Offset &b); +bool operator!=(const Offset &a, const Offset &b); + struct Extents { int width; @@ -109,6 +102,9 @@ struct Extents Extents() : width(0), height(0), depth(0) { } Extents(int width_, int height_, int depth_) : width(width_), height(height_), depth(depth_) { } + Extents(const Extents &other) = default; + Extents &operator=(const Extents &other) = default; + bool empty() const { return (width * height * depth) == 0; } }; @@ -131,11 +127,13 @@ struct Box bool operator!=(const Box &other) const; }; - -struct RasterizerState +struct RasterizerState final { + // This will zero-initialize the struct, including padding. + RasterizerState(); + bool cullFace; - GLenum cullMode; + CullFaceMode cullMode; GLenum frontFace; bool polygonOffsetFill; @@ -148,8 +146,15 @@ struct RasterizerState bool rasterizerDiscard; }; -struct BlendState +bool operator==(const RasterizerState &a, const RasterizerState &b); +bool operator!=(const RasterizerState &a, const RasterizerState &b); + +struct BlendState final { + // This will zero-initialize the struct, including padding. + BlendState(); + BlendState(const BlendState &other); + bool blend; GLenum sourceBlendRGB; GLenum destBlendRGB; @@ -168,8 +173,15 @@ struct BlendState bool dither; }; -struct DepthStencilState +bool operator==(const BlendState &a, const BlendState &b); +bool operator!=(const BlendState &a, const BlendState &b); + +struct DepthStencilState final { + // This will zero-initialize the struct, including padding. + DepthStencilState(); + DepthStencilState(const DepthStencilState &other); + bool depthTest; GLenum depthFunc; bool depthMask; @@ -189,10 +201,17 @@ struct DepthStencilState GLuint stencilBackWritemask; }; +bool operator==(const DepthStencilState &a, const DepthStencilState &b); +bool operator!=(const DepthStencilState &a, const DepthStencilState &b); + // State from Table 6.10 (state per sampler object) -struct SamplerState +struct SamplerState final { + // This will zero-initialize the struct, including padding. SamplerState(); + SamplerState(const SamplerState &other); + + static SamplerState CreateDefaultForTarget(GLenum target); GLenum minFilter; GLenum magFilter; @@ -209,110 +228,92 @@ struct SamplerState GLenum compareMode; GLenum compareFunc; + + GLenum sRGBDecode; }; 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 +struct DrawArraysIndirectCommand { - TextureState(); - - GLenum swizzleRed; - GLenum swizzleGreen; - GLenum swizzleBlue; - GLenum swizzleAlpha; - - SamplerState samplerState; - - GLuint baseLevel; - GLuint maxLevel; - - bool immutableFormat; - GLuint immutableLevels; + GLuint count; + GLuint instanceCount; + GLuint first; + GLuint baseInstance; +}; +static_assert(sizeof(DrawArraysIndirectCommand) == 16, + "Unexpected size of DrawArraysIndirectCommand"); - // From GL_ANGLE_texture_usage - GLenum usage; +struct DrawElementsIndirectCommand +{ + GLuint count; + GLuint primCount; + GLuint firstIndex; + GLint baseVertex; + GLuint baseInstance; +}; +static_assert(sizeof(DrawElementsIndirectCommand) == 20, + "Unexpected size of DrawElementsIndirectCommand"); - bool swizzleRequired() const; +struct ImageUnit +{ + ImageUnit(); + ImageUnit(const ImageUnit &other); + ~ImageUnit(); + + BindingPointer<Texture> texture; + GLint level; + GLboolean layered; + GLint layer; + GLenum access; + GLenum format; }; -bool operator==(const TextureState &a, const TextureState &b); -bool operator!=(const TextureState &a, const TextureState &b); +struct PixelStoreStateBase +{ + GLint alignment = 4; + GLint rowLength = 0; + GLint skipRows = 0; + GLint skipPixels = 0; + GLint imageHeight = 0; + GLint skipImages = 0; +}; -struct PixelUnpackState +struct PixelUnpackState : PixelStoreStateBase { - BindingPointer<Buffer> pixelBuffer; - GLint alignment; - GLint rowLength; - GLint skipRows; - GLint skipPixels; - GLint imageHeight; - GLint skipImages; - - PixelUnpackState() - : alignment(4), - rowLength(0), - skipRows(0), - skipPixels(0), - imageHeight(0), - skipImages(0) - {} - - PixelUnpackState(GLint alignmentIn, GLint rowLengthIn) - : alignment(alignmentIn), - rowLength(rowLengthIn), - skipRows(0), - skipPixels(0), - imageHeight(0), - skipImages(0) - {} }; -struct PixelPackState +struct PixelPackState : PixelStoreStateBase { - BindingPointer<Buffer> pixelBuffer; - GLint alignment; - bool reverseRowOrder; - GLint rowLength; - GLint skipRows; - GLint skipPixels; - - PixelPackState() - : alignment(4), - reverseRowOrder(false), - rowLength(0), - skipRows(0), - skipPixels(0) - {} - - explicit PixelPackState(GLint alignmentIn, bool reverseRowOrderIn) - : alignment(alignmentIn), - reverseRowOrder(reverseRowOrderIn), - rowLength(0), - skipRows(0), - skipPixels(0) - {} + bool reverseRowOrder = false; }; // Used in Program and VertexArray. -typedef std::bitset<MAX_VERTEX_ATTRIBS> AttributesMask; +using AttributesMask = angle::BitSet<MAX_VERTEX_ATTRIBS>; -// Use in Program -typedef std::bitset<IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS> UniformBlockBindingMask; -} +// Used in Program +using UniformBlockBindingMask = angle::BitSet<IMPLEMENTATION_MAX_COMBINED_SHADER_UNIFORM_BUFFERS>; + +// Used in Framebuffer +using DrawBufferMask = angle::BitSet<IMPLEMENTATION_MAX_DRAW_BUFFERS>; + +using ContextID = uintptr_t; + +constexpr size_t CUBE_FACE_COUNT = 6; + +using TextureMap = std::map<GLenum, BindingPointer<Texture>>; + +template <typename T> +using AttachmentArray = std::array<T, IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS>; + +template <typename T> +using DrawBuffersArray = std::array<T, IMPLEMENTATION_MAX_DRAW_BUFFERS>; + +} // namespace gl namespace rx { -enum VendorID : uint32_t -{ - 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) @@ -354,12 +355,12 @@ inline DestT *GetImplAs(SrcT *src) } template <typename DestT, typename SrcT> -inline const DestT *GetImplAs(const SrcT *src) +inline DestT *SafeGetImplAs(SrcT *src) { - return GetAs<const DestT>(src->getImplementation()); + return src != nullptr ? GetAs<DestT>(src->getImplementation()) : nullptr; } -} +} // namespace rx #include "angletypes.inl" @@ -407,6 +408,80 @@ inline GLenum FramebufferBindingToEnum(FramebufferBinding binding) return GL_NONE; } } -} + +template <typename ObjT, typename ContextT> +class DestroyThenDelete +{ + public: + DestroyThenDelete(const ContextT *context) : mContext(context) {} + + void operator()(ObjT *obj) + { + ANGLE_SWALLOW_ERR(obj->onDestroy(mContext)); + delete obj; + } + + private: + const ContextT *mContext; +}; + +// Helper class for wrapping an onDestroy function. +template <typename ObjT, typename DeleterT> +class UniqueObjectPointerBase : angle::NonCopyable +{ + public: + template <typename ContextT> + UniqueObjectPointerBase(const ContextT *context) : mObject(nullptr), mDeleter(context) + { + } + + template <typename ContextT> + UniqueObjectPointerBase(ObjT *obj, const ContextT *context) : mObject(obj), mDeleter(context) + { + } + + ~UniqueObjectPointerBase() + { + if (mObject) + { + mDeleter(mObject); + } + } + + ObjT *operator->() const { return mObject; } + + ObjT *release() + { + auto obj = mObject; + mObject = nullptr; + return obj; + } + + ObjT *get() const { return mObject; } + + void reset(ObjT *obj) + { + if (mObject) + { + mDeleter(mObject); + } + mObject = obj; + } + + private: + ObjT *mObject; + DeleterT mDeleter; +}; + +template <typename ObjT, typename ContextT> +using UniqueObjectPointer = UniqueObjectPointerBase<ObjT, DestroyThenDelete<ObjT, ContextT>>; + +} // namespace angle + +namespace gl +{ +class ContextState; + +} // namespace gl #endif // LIBANGLE_ANGLETYPES_H_ |