chromium/third_party/angle/src/libANGLE/formatutils.cpp

//
// Copyright 2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//

// formatutils.cpp: Queries for GL image formats.

#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
{

// ES2 requires that format is equal to internal format at all glTex*Image2D entry points and the
// implementation can decide the true, sized, internal format. The ES2FormatMap determines the
// internal format for all valid format and type combinations.
GLenum GetSizedFormatInternal(GLenum format, GLenum type);

namespace
{
bool CheckedMathResult(const CheckedNumeric<GLuint> &value, GLuint *resultOut)
{}

constexpr uint32_t PackTypeInfo(GLuint bytes, bool specialized)
{}

}  // anonymous namespace

FormatType::FormatType() :{}

FormatType::FormatType(GLenum format_, GLenum type_) :{}

bool FormatType::operator<(const FormatType &other) const
{}

bool operator<(const Type &a, const Type &b)
{}

// Information about internal formats
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 &)
{}

// Check support for a single extension
template <ExtensionBool bool1>
static bool RequireExt(const Version &, const Extensions &extensions)
{}

// Check for a minimum client version or a single extension
template <GLuint minCoreGLMajorVersion, GLuint minCoreGLMinorVersion, ExtensionBool bool1>
static bool RequireESOrExt(const Version &clientVersion, const Extensions &extensions)
{}

// Check for a minimum client version or two extensions
template <GLuint minCoreGLMajorVersion,
          GLuint minCoreGLMinorVersion,
          ExtensionBool bool1,
          ExtensionBool bool2>
static bool RequireESOrExtAndExt(const Version &clientVersion, const Extensions &extensions)
{}

// Check for a minimum client version or at least one of two extensions
template <GLuint minCoreGLMajorVersion,
          GLuint minCoreGLMinorVersion,
          ExtensionBool bool1,
          ExtensionBool bool2>
static bool RequireESOrExtOrExt(const Version &clientVersion, const Extensions &extensions)
{}

// Check support for two extensions
template <ExtensionBool bool1, ExtensionBool bool2>
static bool RequireExtAndExt(const Version &, const Extensions &extensions)
{}

// Check support for either of two extensions
template <ExtensionBool bool1, ExtensionBool bool2>
static bool RequireExtOrExt(const Version &, const Extensions &extensions)
{}

// Check support for any of three extensions
template <ExtensionBool bool1, ExtensionBool bool2, ExtensionBool bool3>
static bool RequireExtOrExtOrExt(const Version &, const Extensions &extensions)
{}

// R8, RG8
static bool SizedRGSupport(const Version &clientVersion, const Extensions &extensions)
{}

// R16F, RG16F with HALF_FLOAT_OES type
static bool SizedHalfFloatOESRGSupport(const Version &clientVersion, const Extensions &extensions)
{}

static bool SizedHalfFloatOESRGTextureAttachmentSupport(const Version &clientVersion,
                                                        const Extensions &extensions)
{}

// R16F, RG16F with either HALF_FLOAT_OES or HALF_FLOAT types
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)
{}

// RGB16F, RGBA16F with HALF_FLOAT_OES type
static bool SizedHalfFloatOESSupport(const Version &clientVersion, const Extensions &extensions)
{}

static bool SizedHalfFloatOESTextureAttachmentSupport(const Version &clientVersion,
                                                      const Extensions &extensions)
{}

// RGB16F, RGBA16F with either HALF_FLOAT_OES or HALF_FLOAT types
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)
{}

// R32F, RG32F
static bool SizedFloatRGSupport(const Version &clientVersion, const Extensions &extensions)
{}

// RGB32F
static bool SizedFloatRGBSupport(const Version &clientVersion, const Extensions &extensions)
{}

// RGBA32F
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
{}

// static
bool Format::SameSized(const Format &a, const Format &b)
{}

static GLenum EquivalentBlitInternalFormat(GLenum internalformat)
{}

// static
bool Format::EquivalentForBlit(const Format &a, const Format &b)
{}

// static
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 implementation
YuvFormatInfo::YuvFormatInfo(GLenum internalFormat, const Extents &yPlaneExtent)
{}

// YUV format related helpers
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)
{}

// Notes:
// 1. "Texture supported" includes all the means by which texture can be created, however,
//    GL_EXT_texture_storage in ES2 is a special case, when only glTexStorage* is allowed.
//    The assumption is that ES2 validation will not check textureSupport for sized formats.
//
// 2. Sized half float types are a combination of GL_HALF_FLOAT and GL_HALF_FLOAT_OES support,
//    due to a limitation that only one type for sized formats is allowed.
//
// TODO(ynovikov): http://anglebug.com/42261549 Verify support fields of BGRA, depth, stencil
// and compressed formats. Perform texturable check as part of filterable and attachment checks.
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)
    :{}
}  // namespace gl