// // 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. //
GLuint bytes;
GLuint bytesShift; // Bit shift by this value to effectively divide/multiply by "bytes" in a // more optimal way bool specialInterpretation;
};
uint32_t GetPackedTypeInfo(GLenum type);
ANGLE_INLINE GLenum GetNonLinearFormat(const GLenum format)
{ switch (format)
{ case GL_BGRA8_EXT: return GL_BGRA8_SRGB_ANGLEX; case GL_RGBA8: return GL_SRGB8_ALPHA8; case GL_RGB8: case GL_BGRX8_ANGLEX: case GL_RGBX8_ANGLE: return GL_SRGB8; case GL_RGBA16F: return GL_RGBA16F; default: return GL_NONE;
}
}
ANGLE_INLINE bool ColorspaceFormatOverride(const EGLenum colorspace, GLenum *rendertargetformat)
{ // Override the rendertargetformat based on colorpsace switch (colorspace)
{ case EGL_GL_COLORSPACE_LINEAR: // linear colorspace no translation needed case EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT: // linear colorspace no translation needed case EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT: // linear colorspace no translation needed case EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT: // App, not the HW, will specify the // transfer function case EGL_GL_COLORSPACE_SCRGB_EXT: // App, not the HW, will specify the transfer function // No translation returntrue; case EGL_GL_COLORSPACE_SRGB_KHR: case EGL_GL_COLORSPACE_DISPLAY_P3_EXT:
{
GLenum nonLinearFormat = GetNonLinearFormat(*rendertargetformat); if (nonLinearFormat != GL_NONE)
{
*rendertargetformat = nonLinearFormat; returntrue;
} else
{ returnfalse;
}
} break; default:
UNREACHABLE(); returnfalse;
}
}
ANGLE_INLINE const Type GetTypeInfo(GLenum type)
{ return Type(GetPackedTypeInfo(type));
}
// This helpers use tricks based on the assumption that the type has certain values.
static_assert(static_cast<GLuint>(DrawElementsType::UnsignedByte) == 0, "Please update this code.");
static_assert(static_cast<GLuint>(DrawElementsType::UnsignedShort) == 1, "Please update this code.");
static_assert(static_cast<GLuint>(DrawElementsType::UnsignedInt) == 2, "Please update this code.");
ANGLE_INLINE GLuint GetDrawElementsTypeSize(DrawElementsType type)
{ return (1 << static_cast<GLuint>(type));
}
// Information about an OpenGL internal format. Can be keyed on the internalFormat and type // members. struct InternalFormat
{
InternalFormat();
InternalFormat(const InternalFormat &other);
InternalFormat &operator=(const InternalFormat &other);
// Support upload a portion of image? bool supportSubImage() const;
ANGLE_INLINE bool isChannelSizeCompatible(GLuint redSize,
GLuint greenSize,
GLuint blueSize,
GLuint alphaSize) const
{ // We only check for equality in all channel sizes return ((redSize == redBits) && (greenSize == greenBits) && (blueSize == blueBits) &&
(alphaSize == alphaBits));
}
// Return true if the format is a required renderbuffer format in the given version of the core // spec. Note that it isn't always clear whether all the rules that apply to core required // renderbuffer formats also apply to additional formats added by extensions. Because of this // extension formats are conservatively not included. bool isRequiredRenderbufferFormat(const Version &version) const;
// A "Format" wraps an InternalFormat struct, querying it from either a sized internal format or // unsized internal format and type. // TODO(geofflang): Remove this, it doesn't add any more information than the InternalFormat object. struct Format
{ // Sized types only. explicit Format(GLenum internalFormat);
// Strip sizing information from an internal format. Doesn't necessarily validate that the internal // format is valid.
GLenum GetUnsizedFormat(GLenum internalFormat);
// Return whether the compressed format requires whole image/mip level to be uploaded to texture. bool CompressedFormatRequiresWholeImage(GLenum internalFormat);
// In support of GetImage, check for LUMA formats and override with real format void MaybeOverrideLuminance(GLenum &format, GLenum &type, GLenum actualFormat, GLenum actualType);
// From the ESSL 3.00.4 spec: // Vertex shader inputs can only be float, floating-point vectors, matrices, signed and unsigned // integers and integer vectors. Vertex shader inputs cannot be arrays or structures.
ANGLE_INLINE bool IsS3TCFormat(const GLenum format)
{ switch (format)
{ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: returntrue;
default: returnfalse;
}
}
ANGLE_INLINE bool IsRGTCFormat(const GLenum format)
{ switch (format)
{ case GL_COMPRESSED_RED_RGTC1_EXT: case GL_COMPRESSED_SIGNED_RED_RGTC1_EXT: case GL_COMPRESSED_RED_GREEN_RGTC2_EXT: case GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: returntrue;
default: returnfalse;
}
}
ANGLE_INLINE bool IsBPTCFormat(const GLenum format)
{ switch (format)
{ case GL_COMPRESSED_RGBA_BPTC_UNORM_EXT: case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT: case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT: case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT: returntrue;
default: returnfalse;
}
}
ANGLE_INLINE bool IsASTC2DFormat(const GLenum format)
{ if ((format >= GL_COMPRESSED_RGBA_ASTC_4x4_KHR &&
format <= GL_COMPRESSED_RGBA_ASTC_12x12_KHR) ||
(format >= GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR &&
format <= GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR))
{ returntrue;
} returnfalse;
}
ANGLE_INLINE bool IsETC2EACFormat(const GLenum format)
{ // ES 3.1, Table 8.19 switch (format)
{ case GL_COMPRESSED_R11_EAC: case GL_COMPRESSED_SIGNED_R11_EAC: case GL_COMPRESSED_RG11_EAC: case GL_COMPRESSED_SIGNED_RG11_EAC: case GL_COMPRESSED_RGB8_ETC2: case GL_COMPRESSED_SRGB8_ETC2: case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: case GL_COMPRESSED_RGBA8_ETC2_EAC: case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: returntrue;
default: returnfalse;
}
}
ANGLE_INLINE bool IsPVRTC1Format(const GLenum format)
{ switch (format)
{ case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG: case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG: case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT: case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT: case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT: case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT: returntrue;
default: returnfalse;
}
}
ANGLE_INLINE bool IsBGRAFormat(const GLenum internalFormat)
{ switch (internalFormat)
{ case GL_BGRA8_EXT: case GL_BGRA4_ANGLEX: case GL_BGR5_A1_ANGLEX: case GL_BGRA8_SRGB_ANGLEX: case GL_BGRX8_ANGLEX: case GL_RGBX8_ANGLE: case GL_BGR565_ANGLEX: case GL_BGR10_A2_ANGLEX: returntrue;
default: returnfalse;
}
}
// Check if an internal format is ever valid in ES3. Makes no checks about support for a specific // context. bool ValidES3InternalFormat(GLenum internalFormat);
// Implemented in format_map_autogen.cpp bool ValidES3Format(GLenum format); bool ValidES3Type(GLenum type); bool ValidES3FormatCombination(GLenum format, GLenum type, GLenum internalFormat);
// Implemented in format_map_desktop.cpp bool ValidDesktopFormat(GLenum format); bool ValidDesktopType(GLenum type); bool ValidDesktopFormatCombination(GLenum format, GLenum type, GLenum internalFormat);
// Implemented in es3_copy_conversion_table_autogen.cpp bool ValidES3CopyConversion(GLenum textureFormat, GLenum framebufferFormat);
ANGLE_INLINE ComponentType GetVertexAttributeComponentType(bool pureInteger, VertexAttribType type)
{ if (pureInteger)
{ switch (type)
{ case VertexAttribType::Byte: case VertexAttribType::Short: case VertexAttribType::Int: return ComponentType::Int;
case VertexAttribType::UnsignedByte: case VertexAttribType::UnsignedShort: case VertexAttribType::UnsignedInt: return ComponentType::UnsignedInt;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.