#include "libANGLE/formatutils.h"
#include "anglebase/no_destructor.h"
#include "common/mathutil.h"
#include "gpu_info_util/SystemInfo.h"
#include "libANGLE/Context.h"
#include "libANGLE/Framebuffer.h"
usingnamespaceangle;
namespace gl
{
GLenum GetSizedFormatInternal(GLenum format, GLenum type);
namespace
{
bool CheckedMathResult(const CheckedNumeric<GLuint> &value, GLuint *resultOut)
{ … }
constexpr uint32_t PackTypeInfo(GLuint bytes, bool specialized)
{ … }
}
FormatType::FormatType() : … { … }
FormatType::FormatType(GLenum format_, GLenum type_) : … { … }
bool FormatType::operator<(const FormatType &other) const
{ … }
bool operator<(const Type &a, const Type &b)
{ … }
static bool AlwaysSupported(const Version &, const Extensions &)
{ … }
static bool NeverSupported(const Version &, const Extensions &)
{ … }
static bool RequireES1(const Version &clientVersion, const Extensions &extensions)
{ … }
template <GLuint minCoreGLMajorVersion, GLuint minCoreGLMinorVersion>
static bool RequireES(const Version &clientVersion, const Extensions &)
{ … }
template <ExtensionBool bool1>
static bool RequireExt(const Version &, const Extensions &extensions)
{ … }
template <GLuint minCoreGLMajorVersion, GLuint minCoreGLMinorVersion, ExtensionBool bool1>
static bool RequireESOrExt(const Version &clientVersion, const Extensions &extensions)
{ … }
template <GLuint minCoreGLMajorVersion,
GLuint minCoreGLMinorVersion,
ExtensionBool bool1,
ExtensionBool bool2>
static bool RequireESOrExtAndExt(const Version &clientVersion, const Extensions &extensions)
{ … }
template <GLuint minCoreGLMajorVersion,
GLuint minCoreGLMinorVersion,
ExtensionBool bool1,
ExtensionBool bool2>
static bool RequireESOrExtOrExt(const Version &clientVersion, const Extensions &extensions)
{ … }
template <ExtensionBool bool1, ExtensionBool bool2>
static bool RequireExtAndExt(const Version &, const Extensions &extensions)
{ … }
template <ExtensionBool bool1, ExtensionBool bool2>
static bool RequireExtOrExt(const Version &, const Extensions &extensions)
{ … }
template <ExtensionBool bool1, ExtensionBool bool2, ExtensionBool bool3>
static bool RequireExtOrExtOrExt(const Version &, const Extensions &extensions)
{ … }
static bool SizedRGSupport(const Version &clientVersion, const Extensions &extensions)
{ … }
static bool SizedHalfFloatOESRGSupport(const Version &clientVersion, const Extensions &extensions)
{ … }
static bool SizedHalfFloatOESRGTextureAttachmentSupport(const Version &clientVersion,
const Extensions &extensions)
{ … }
static bool SizedHalfFloatRGSupport(const Version &clientVersion, const Extensions &extensions)
{ … }
static bool SizedHalfFloatRGTextureAttachmentSupport(const Version &clientVersion,
const Extensions &extensions)
{ … }
static bool SizedHalfFloatRGRenderbufferSupport(const Version &clientVersion,
const Extensions &extensions)
{ … }
static bool SizedHalfFloatOESSupport(const Version &clientVersion, const Extensions &extensions)
{ … }
static bool SizedHalfFloatOESTextureAttachmentSupport(const Version &clientVersion,
const Extensions &extensions)
{ … }
static bool SizedHalfFloatSupport(const Version &clientVersion, const Extensions &extensions)
{ … }
static bool SizedHalfFloatFilterSupport(const Version &clientVersion, const Extensions &extensions)
{ … }
static bool SizedHalfFloatRGBTextureAttachmentSupport(const Version &clientVersion,
const Extensions &extensions)
{ … }
static bool SizedHalfFloatRGBRenderbufferSupport(const Version &clientVersion,
const Extensions &extensions)
{ … }
static bool SizedHalfFloatRGBATextureAttachmentSupport(const Version &clientVersion,
const Extensions &extensions)
{ … }
static bool SizedHalfFloatRGBARenderbufferSupport(const Version &clientVersion,
const Extensions &extensions)
{ … }
static bool SizedFloatRGSupport(const Version &clientVersion, const Extensions &extensions)
{ … }
static bool SizedFloatRGBSupport(const Version &clientVersion, const Extensions &extensions)
{ … }
static bool SizedFloatRGBASupport(const Version &clientVersion, const Extensions &extensions)
{ … }
static bool SizedFloatRGBARenderableSupport(const Version &clientVersion,
const Extensions &extensions)
{ … }
static bool Float32BlendableSupport(const Version &clientVersion, const Extensions &extensions)
{ … }
template <ExtensionBool bool1>
static bool ETC2EACSupport(const Version &clientVersion, const Extensions &extensions)
{ … }
InternalFormat::InternalFormat()
: … { … }
InternalFormat::InternalFormat(const InternalFormat &other) = default;
InternalFormat &InternalFormat::operator=(const InternalFormat &other) = default;
bool InternalFormat::isLUMA() const
{ … }
GLenum InternalFormat::getReadPixelsFormat(const Extensions &extensions) const
{ … }
GLenum InternalFormat::getReadPixelsType(const Version &version) const
{ … }
bool InternalFormat::supportSubImage() const
{ … }
bool InternalFormat::isRequiredRenderbufferFormat(const Version &version) const
{ … }
bool InternalFormat::isInt() const
{ … }
bool InternalFormat::isDepthOrStencil() const
{ … }
GLuint InternalFormat::getEGLConfigBufferSize() const
{ … }
Format::Format(GLenum internalFormat) : … { … }
Format::Format(const InternalFormat &internalFormat) : … { … }
Format::Format(GLenum internalFormat, GLenum type)
: … { … }
Format::Format(const Format &other) = default;
Format &Format::operator=(const Format &other) = default;
bool Format::valid() const
{ … }
bool Format::SameSized(const Format &a, const Format &b)
{ … }
static GLenum EquivalentBlitInternalFormat(GLenum internalformat)
{ … }
bool Format::EquivalentForBlit(const Format &a, const Format &b)
{ … }
Format Format::Invalid()
{ … }
std::ostream &operator<<(std::ostream &os, const Format &fmt)
{ … }
bool InternalFormat::operator==(const InternalFormat &other) const
{ … }
bool InternalFormat::operator!=(const InternalFormat &other) const
{ … }
void InsertFormatInfo(InternalFormatInfoMap *map, const InternalFormat &formatInfo)
{ … }
YuvFormatInfo::YuvFormatInfo(GLenum internalFormat, const Extents &yPlaneExtent)
{ … }
bool IsYuvFormat(GLenum format)
{ … }
uint32_t GetPlaneCount(GLenum format)
{ … }
uint32_t GetYPlaneBpp(GLenum format)
{ … }
uint32_t GetChromaPlaneBpp(GLenum format)
{ … }
void GetSubSampleFactor(GLenum format, int *horizontalSubsampleFactor, int *verticalSubsampleFactor)
{ … }
struct FormatBits
{ … };
template <GLuint red, GLuint green, GLuint blue, GLuint alpha, GLuint unused, GLuint shared>
constexpr FormatBits FB()
{ … }
void AddRGBAXFormat(InternalFormatInfoMap *map,
GLenum internalFormat,
bool sized,
const FormatBits &formatBits,
GLenum format,
GLenum type,
GLenum componentType,
bool srgb,
InternalFormat::SupportCheckFunction textureSupport,
InternalFormat::SupportCheckFunction filterSupport,
InternalFormat::SupportCheckFunction textureAttachmentSupport,
InternalFormat::SupportCheckFunction renderbufferSupport,
InternalFormat::SupportCheckFunction blendSupport)
{ … }
void AddRGBAFormat(InternalFormatInfoMap *map,
GLenum internalFormat,
bool sized,
GLuint red,
GLuint green,
GLuint blue,
GLuint alpha,
GLuint shared,
GLenum format,
GLenum type,
GLenum componentType,
bool srgb,
InternalFormat::SupportCheckFunction textureSupport,
InternalFormat::SupportCheckFunction filterSupport,
InternalFormat::SupportCheckFunction textureAttachmentSupport,
InternalFormat::SupportCheckFunction renderbufferSupport,
InternalFormat::SupportCheckFunction blendSupport)
{ … }
static void AddLUMAFormat(InternalFormatInfoMap *map,
GLenum internalFormat,
bool sized,
GLuint luminance,
GLuint alpha,
GLenum format,
GLenum type,
GLenum componentType,
InternalFormat::SupportCheckFunction textureSupport,
InternalFormat::SupportCheckFunction filterSupport,
InternalFormat::SupportCheckFunction textureAttachmentSupport,
InternalFormat::SupportCheckFunction renderbufferSupport,
InternalFormat::SupportCheckFunction blendSupport)
{ … }
void AddDepthStencilFormat(InternalFormatInfoMap *map,
GLenum internalFormat,
bool sized,
GLuint depthBits,
GLuint stencilBits,
GLuint unusedBits,
GLenum format,
GLenum type,
GLenum componentType,
InternalFormat::SupportCheckFunction textureSupport,
InternalFormat::SupportCheckFunction filterSupport,
InternalFormat::SupportCheckFunction textureAttachmentSupport,
InternalFormat::SupportCheckFunction renderbufferSupport,
InternalFormat::SupportCheckFunction blendSupport)
{ … }
void AddCompressedFormat(InternalFormatInfoMap *map,
GLenum internalFormat,
GLuint compressedBlockWidth,
GLuint compressedBlockHeight,
GLuint compressedBlockDepth,
GLuint compressedBlockSize,
GLuint componentCount,
bool srgb,
InternalFormat::SupportCheckFunction textureSupport,
InternalFormat::SupportCheckFunction filterSupport,
InternalFormat::SupportCheckFunction textureAttachmentSupport,
InternalFormat::SupportCheckFunction renderbufferSupport,
InternalFormat::SupportCheckFunction blendSupport)
{ … }
void AddPalettedFormat(InternalFormatInfoMap *map,
GLenum internalFormat,
GLuint paletteBits,
GLuint pixelBytes,
GLenum format,
GLuint componentCount,
InternalFormat::SupportCheckFunction textureSupport,
InternalFormat::SupportCheckFunction filterSupport,
InternalFormat::SupportCheckFunction textureAttachmentSupport,
InternalFormat::SupportCheckFunction renderbufferSupport,
InternalFormat::SupportCheckFunction blendSupport)
{ … }
void AddYUVFormat(InternalFormatInfoMap *map,
GLenum internalFormat,
bool sized,
GLuint cr,
GLuint y,
GLuint cb,
GLuint alpha,
GLuint shared,
GLenum format,
GLenum type,
GLenum componentType,
bool srgb,
InternalFormat::SupportCheckFunction textureSupport,
InternalFormat::SupportCheckFunction filterSupport,
InternalFormat::SupportCheckFunction textureAttachmentSupport,
InternalFormat::SupportCheckFunction renderbufferSupport,
InternalFormat::SupportCheckFunction blendSupport)
{ … }
static InternalFormatInfoMap BuildInternalFormatInfoMap()
{ … }
const InternalFormatInfoMap &GetInternalFormatMap()
{ … }
int GetAndroidHardwareBufferFormatFromChannelSizes(const egl::AttributeMap &attribMap)
{ … }
GLenum GetConfigColorBufferFormat(const egl::Config *config)
{ … }
GLenum GetConfigDepthStencilBufferFormat(const egl::Config *config)
{ … }
static FormatSet BuildAllSizedInternalFormatSet()
{ … }
uint32_t GetPackedTypeInfo(GLenum type)
{ … }
const InternalFormat &GetSizedInternalFormatInfo(GLenum internalFormat)
{ … }
const InternalFormat &GetInternalFormatInfo(GLenum internalFormat, GLenum type)
{ … }
GLuint InternalFormat::computePixelBytes(GLenum formatType) const
{ … }
bool InternalFormat::computeBufferRowLength(uint32_t width, uint32_t *resultOut) const
{ … }
bool InternalFormat::computeBufferImageHeight(uint32_t height, uint32_t *resultOut) const
{ … }
bool InternalFormat::computePalettedImageRowPitch(GLsizei width, GLuint *resultOut) const
{ … }
bool InternalFormat::computeRowPitch(GLenum formatType,
GLsizei width,
GLint alignment,
GLint rowLength,
GLuint *resultOut) const
{ … }
bool InternalFormat::computeDepthPitch(GLsizei height,
GLint imageHeight,
GLuint rowPitch,
GLuint *resultOut) const
{ … }
bool InternalFormat::computeDepthPitch(GLenum formatType,
GLsizei width,
GLsizei height,
GLint alignment,
GLint rowLength,
GLint imageHeight,
GLuint *resultOut) const
{ … }
bool InternalFormat::computeCompressedImageRowPitch(GLsizei width, GLuint *resultOut) const
{ … }
bool InternalFormat::computeCompressedImageDepthPitch(GLsizei height,
GLuint rowPitch,
GLuint *resultOut) const
{ … }
bool InternalFormat::computeCompressedImageSize(const Extents &size, GLuint *resultOut) const
{ … }
std::pair<GLuint, GLuint> InternalFormat::getCompressedImageMinBlocks() const
{ … }
bool InternalFormat::computeSkipBytes(GLenum formatType,
GLuint rowPitch,
GLuint depthPitch,
const PixelStoreStateBase &state,
bool is3D,
GLuint *resultOut) const
{ … }
bool InternalFormat::computePackUnpackEndByte(GLenum formatType,
const Extents &size,
const PixelStoreStateBase &state,
bool is3D,
GLuint *resultOut) const
{ … }
GLenum GetUnsizedFormat(GLenum internalFormat)
{ … }
bool CompressedFormatRequiresWholeImage(GLenum internalFormat)
{ … }
void MaybeOverrideLuminance(GLenum &format, GLenum &type, GLenum actualFormat, GLenum actualType)
{ … }
const FormatSet &GetAllSizedInternalFormats()
{ … }
AttributeType GetAttributeType(GLenum enumValue)
{ … }
angle::FormatID GetVertexFormatID(VertexAttribType type,
GLboolean normalized,
GLuint components,
bool pureInteger)
{ … }
angle::FormatID GetVertexFormatID(const VertexAttribute &attrib, VertexAttribType currentValueType)
{ … }
angle::FormatID GetCurrentValueFormatID(VertexAttribType currentValueType)
{ … }
const VertexFormat &GetVertexFormatFromID(angle::FormatID vertexFormatID)
{ … }
size_t GetVertexFormatSize(angle::FormatID vertexFormatID)
{ … }
angle::FormatID ConvertFormatSignedness(const angle::Format &format)
{ … }
bool ValidES3InternalFormat(GLenum internalFormat)
{ … }
VertexFormat::VertexFormat(GLenum typeIn,
GLboolean normalizedIn,
GLuint componentsIn,
bool pureIntegerIn)
: … { … }
}