chromium/third_party/angle/src/libANGLE/renderer/gl/formatutilsgl.cpp

//
// Copyright 2015 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.
//

// formatutilsgl.cpp: Queries for GL image formats and their translations to native
// GL formats.

#include "libANGLE/renderer/gl/formatutilsgl.h"

#include <limits>

#include "anglebase/no_destructor.h"
#include "common/string_utils.h"
#include "libANGLE/formatutils.h"
#include "platform/autogen/FeaturesGL_autogen.h"

namespace rx
{

namespace nativegl
{

SupportRequirement::SupportRequirement()
    :{}

SupportRequirement::SupportRequirement(const SupportRequirement &other) = default;

SupportRequirement &SupportRequirement::operator=(const SupportRequirement &other) = default;

SupportRequirement::~SupportRequirement() = default;

InternalFormat::InternalFormat() :{}

InternalFormat::InternalFormat(const InternalFormat &other) = default;

InternalFormat::~InternalFormat() {}

// supported = version || vertexExt
static inline SupportRequirement VersionOrExts(GLuint major,
                                               GLuint minor,
                                               const std::string &versionExt)
{}

// supported = requiredExt && (version || requiredWithoutVersionExt)
static inline SupportRequirement ExtAndVersionOrExt(const std::string &requiredExt,
                                                    GLuint major,
                                                    GLuint minor,
                                                    const std::string &requiredWithoutVersionExt)
{}

// supported = version
static inline SupportRequirement VersionOnly(GLuint major, GLuint minor)
{}

// supported = any one of sets in exts
static inline SupportRequirement ExtsOnly(const std::vector<std::string> &exts)
{}

// supported = ext
static inline SupportRequirement ExtsOnly(const std::string &ext)
{}

// supported = ext1 || ext2
static inline SupportRequirement ExtsOnly(const std::string &ext1, const std::string &ext2)
{}

// supported = true
static inline SupportRequirement AlwaysSupported()
{}

// supported = false
static inline SupportRequirement NeverSupported()
{}

struct InternalFormatInfo
{};

InternalFormatInfoPair;
InternalFormatInfoMap;

// A helper function to insert data into the format map with fewer characters.
static inline void InsertFormatMapping(InternalFormatInfoMap *map,
                                       GLenum internalFormat,
                                       const SupportRequirement &desktopTexture,
                                       const SupportRequirement &desktopFilter,
                                       const SupportRequirement &desktopRender,
                                       const SupportRequirement &esTexture,
                                       const SupportRequirement &esFilter,
                                       const SupportRequirement &esTextureAttachment,
                                       const SupportRequirement &esRenderbufferAttachment)
{}

// Note 1: This map is used to determine extensions support, which is based on checking support for
// sized formats (this is ANGLE implementation limitation - D3D backend supports only sized formats)
// In order to determine support for extensions which introduce unsized formats, this map would say
// that a corresponding sized format is supported, instead. Thus, if this map says that a sized
// format is supported, this means that either the actual sized format or a corresponding unsized
// format is supported by the native driver.
// For example, GL_EXT_texture_rg provides support for RED_EXT format with UNSIGNED_BYTE type.
// Therefore, DetermineRGTextureSupport checks for GL_R8 support. Therefore this map says that
// GL_R8 (and not RED_EXT) is supported if GL_EXT_texture_rg is available. GL_R8 itself
// is supported in ES3, thus the combined condition is VersionOrExts(3, 0, "GL_EXT_texture_rg").
//
// Note 2: Texture Attachment support is checked also by SupportsNativeRendering().
// Unsized formats appear in this map for this reason. The assumption is
// that SupportsNativeRendering() will not check sized formats in the ES2 frontend
// and the information in unsized formats is correct, and not merged like for sized formats.
// In the ES3 frontend, it could happen that SupportsNativeRendering() would be wrong,
// but this will be mitigated by fall back to CPU-readback in TextureGL::copySubTextureHelper().
//
// Note 3: Because creating renderbuffers with unsized formats is impossible,
// the value of renderbuffer support is actually correct for the sized formats.
//
// Note 4: To determine whether a format is filterable, one must check both "Filter" and "Texture"
// support, like it is done in GenerateTextureFormatCaps().
// On the other hand, "Texture Attachment" support formula is self-contained.
//
// TODO(ynovikov): http://anglebug.com/42261549 Verify support fields of BGRA, depth, stencil and
// compressed formats, and all formats for Desktop GL.
static InternalFormatInfoMap BuildInternalFormatInfoMap()
{}

static const InternalFormatInfoMap &GetInternalFormatMap()
{}

const InternalFormat &GetInternalFormatInfo(GLenum internalFormat, StandardGL standard)
{}

static bool IsLUMAFormat(GLenum format)
{}

static GLenum EmulateLUMAFormat(const GLenum format)
{}

static const gl::InternalFormat &EmulateLUMA(const gl::InternalFormat &internalFormat)
{}

static GLenum GetNativeInternalFormat(const FunctionsGL *functions,
                                      const angle::FeaturesGL &features,
                                      const gl::InternalFormat &internalFormat)
{}

static GLenum GetNativeFormat(const FunctionsGL *functions,
                              const angle::FeaturesGL &features,
                              GLenum format,
                              GLenum type)
{}

static GLenum GetNativeCompressedFormat(const FunctionsGL *functions,
                                        const angle::FeaturesGL &features,
                                        GLenum format)
{}

static GLenum GetNativeType(const FunctionsGL *functions,
                            const angle::FeaturesGL &features,
                            GLenum format,
                            GLenum type)
{}

static GLenum GetNativeReadType(const FunctionsGL *functions,
                                const angle::FeaturesGL &features,
                                GLenum type)
{}

static GLenum GetNativeReadFormat(const FunctionsGL *functions,
                                  const angle::FeaturesGL &features,
                                  GLenum attachmentReadFormat,
                                  GLenum format,
                                  GLenum type)
{}

TexImageFormat GetTexImageFormat(const FunctionsGL *functions,
                                 const angle::FeaturesGL &features,
                                 GLenum internalFormat,
                                 GLenum format,
                                 GLenum type)
{}

TexSubImageFormat GetTexSubImageFormat(const FunctionsGL *functions,
                                       const angle::FeaturesGL &features,
                                       GLenum format,
                                       GLenum type)
{}

CompressedTexImageFormat GetCompressedTexImageFormat(const FunctionsGL *functions,
                                                     const angle::FeaturesGL &features,
                                                     GLenum internalFormat)
{}

CompressedTexSubImageFormat GetCompressedSubTexImageFormat(const FunctionsGL *functions,
                                                           const angle::FeaturesGL &features,
                                                           GLenum format)
{}

CopyTexImageImageFormat GetCopyTexImageImageFormat(const FunctionsGL *functions,
                                                   const angle::FeaturesGL &features,
                                                   GLenum internalFormat,
                                                   GLenum framebufferType)
{}

TexStorageFormat GetTexStorageFormat(const FunctionsGL *functions,
                                     const angle::FeaturesGL &features,
                                     GLenum internalFormat)
{}

RenderbufferFormat GetRenderbufferFormat(const FunctionsGL *functions,
                                         const angle::FeaturesGL &features,
                                         GLenum internalFormat)
{}
ReadPixelsFormat GetReadPixelsFormat(const FunctionsGL *functions,
                                     const angle::FeaturesGL &features,
                                     GLenum attachmentReadFormat,
                                     GLenum format,
                                     GLenum type)
{}
}  // namespace nativegl

}  // namespace rx