Commit ed4d342e by Jamie Madill Committed by Commit Bot

Make the "FormatMap" a static switch.

This map lives in formatutils.cpp, and maps from a {format,type} to an internal format. Convert this into generated code. BUG=angleproject:1389 Change-Id: Ib12750d83d3f8cf8794d6668874cb025f856b5d4 Reviewed-on: https://chromium-review.googlesource.com/392207 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 168445c2
// GENERATED FILE - DO NOT EDIT.
// Generated by gen_format_map.py using data from format_map_data.json.
//
// Copyright 2016 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.
//
// format_map:
// Determining the sized internal format from a (format,type) pair.
#include "angle_gl.h"
#include "common/debug.h"
namespace gl
{
GLenum GetSizedFormatInternal(GLenum format, GLenum type)
{
switch (format)
{
case GL_ALPHA:
switch (type)
{
case GL_FLOAT:
return GL_ALPHA32F_EXT;
case GL_HALF_FLOAT:
return GL_ALPHA16F_EXT;
case GL_HALF_FLOAT_OES:
return GL_ALPHA16F_EXT;
case GL_UNSIGNED_BYTE:
return GL_ALPHA8_EXT;
default:
break;
}
break;
case GL_BGRA_EXT:
switch (type)
{
case GL_UNSIGNED_BYTE:
return GL_BGRA8_EXT;
case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
return GL_BGR5_A1_ANGLEX;
case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
return GL_BGRA4_ANGLEX;
case GL_UNSIGNED_SHORT_5_6_5:
return GL_BGR565_ANGLEX;
default:
break;
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
switch (type)
{
case GL_UNSIGNED_BYTE:
return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
default:
break;
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
switch (type)
{
case GL_UNSIGNED_BYTE:
return GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE;
default:
break;
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
switch (type)
{
case GL_UNSIGNED_BYTE:
return GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE;
default:
break;
}
break;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
switch (type)
{
case GL_UNSIGNED_BYTE:
return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
default:
break;
}
break;
case GL_DEPTH_COMPONENT:
switch (type)
{
case GL_FLOAT:
return GL_DEPTH_COMPONENT32F;
case GL_UNSIGNED_INT:
return GL_DEPTH_COMPONENT32_OES;
case GL_UNSIGNED_SHORT:
return GL_DEPTH_COMPONENT16;
default:
break;
}
break;
case GL_DEPTH_STENCIL:
switch (type)
{
case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
return GL_DEPTH32F_STENCIL8;
case GL_UNSIGNED_INT_24_8:
return GL_DEPTH24_STENCIL8;
default:
break;
}
break;
case GL_LUMINANCE:
switch (type)
{
case GL_FLOAT:
return GL_LUMINANCE32F_EXT;
case GL_HALF_FLOAT:
return GL_LUMINANCE16F_EXT;
case GL_HALF_FLOAT_OES:
return GL_LUMINANCE16F_EXT;
case GL_UNSIGNED_BYTE:
return GL_LUMINANCE8_EXT;
default:
break;
}
break;
case GL_LUMINANCE_ALPHA:
switch (type)
{
case GL_FLOAT:
return GL_LUMINANCE_ALPHA32F_EXT;
case GL_HALF_FLOAT:
return GL_LUMINANCE_ALPHA16F_EXT;
case GL_HALF_FLOAT_OES:
return GL_LUMINANCE_ALPHA16F_EXT;
case GL_UNSIGNED_BYTE:
return GL_LUMINANCE8_ALPHA8_EXT;
default:
break;
}
break;
case GL_RED:
switch (type)
{
case GL_BYTE:
return GL_R8_SNORM;
case GL_FLOAT:
return GL_R32F;
case GL_HALF_FLOAT:
return GL_R16F;
case GL_HALF_FLOAT_OES:
return GL_R16F;
case GL_SHORT:
return GL_R16_SNORM_EXT;
case GL_UNSIGNED_BYTE:
return GL_R8;
case GL_UNSIGNED_SHORT:
return GL_R16_EXT;
default:
break;
}
break;
case GL_RED_INTEGER:
switch (type)
{
case GL_BYTE:
return GL_R8I;
case GL_INT:
return GL_R32I;
case GL_SHORT:
return GL_R16I;
case GL_UNSIGNED_BYTE:
return GL_R8UI;
case GL_UNSIGNED_INT:
return GL_R32UI;
case GL_UNSIGNED_SHORT:
return GL_R16UI;
default:
break;
}
break;
case GL_RG:
switch (type)
{
case GL_BYTE:
return GL_RG8_SNORM;
case GL_FLOAT:
return GL_RG32F;
case GL_HALF_FLOAT:
return GL_RG16F;
case GL_HALF_FLOAT_OES:
return GL_RG16F;
case GL_SHORT:
return GL_RG16_SNORM_EXT;
case GL_UNSIGNED_BYTE:
return GL_RG8;
case GL_UNSIGNED_SHORT:
return GL_RG16_EXT;
default:
break;
}
break;
case GL_RGB:
switch (type)
{
case GL_BYTE:
return GL_RGB8_SNORM;
case GL_FLOAT:
return GL_RGB32F;
case GL_HALF_FLOAT:
return GL_RGB16F;
case GL_HALF_FLOAT_OES:
return GL_RGB16F;
case GL_SHORT:
return GL_RGB16_SNORM_EXT;
case GL_UNSIGNED_BYTE:
return GL_RGB8;
case GL_UNSIGNED_INT_10F_11F_11F_REV:
return GL_R11F_G11F_B10F;
case GL_UNSIGNED_INT_5_9_9_9_REV:
return GL_RGB9_E5;
case GL_UNSIGNED_SHORT:
return GL_RGB16_EXT;
case GL_UNSIGNED_SHORT_5_6_5:
return GL_RGB565;
default:
break;
}
break;
case GL_RGBA:
switch (type)
{
case GL_BYTE:
return GL_RGBA8_SNORM;
case GL_FLOAT:
return GL_RGBA32F;
case GL_HALF_FLOAT:
return GL_RGBA16F;
case GL_HALF_FLOAT_OES:
return GL_RGBA16F;
case GL_SHORT:
return GL_RGBA16_SNORM_EXT;
case GL_UNSIGNED_BYTE:
return GL_RGBA8;
case GL_UNSIGNED_INT_2_10_10_10_REV:
return GL_RGB10_A2;
case GL_UNSIGNED_SHORT:
return GL_RGBA16_EXT;
case GL_UNSIGNED_SHORT_4_4_4_4:
return GL_RGBA4;
case GL_UNSIGNED_SHORT_5_5_5_1:
return GL_RGB5_A1;
default:
break;
}
break;
case GL_RGBA_INTEGER:
switch (type)
{
case GL_BYTE:
return GL_RGBA8I;
case GL_INT:
return GL_RGBA32I;
case GL_SHORT:
return GL_RGBA16I;
case GL_UNSIGNED_BYTE:
return GL_RGBA8UI;
case GL_UNSIGNED_INT:
return GL_RGBA32UI;
case GL_UNSIGNED_INT_2_10_10_10_REV:
return GL_RGB10_A2UI;
case GL_UNSIGNED_SHORT:
return GL_RGBA16UI;
default:
break;
}
break;
case GL_RGB_INTEGER:
switch (type)
{
case GL_BYTE:
return GL_RGB8I;
case GL_INT:
return GL_RGB32I;
case GL_SHORT:
return GL_RGB16I;
case GL_UNSIGNED_BYTE:
return GL_RGB8UI;
case GL_UNSIGNED_INT:
return GL_RGB32UI;
case GL_UNSIGNED_SHORT:
return GL_RGB16UI;
default:
break;
}
break;
case GL_RG_INTEGER:
switch (type)
{
case GL_BYTE:
return GL_RG8I;
case GL_INT:
return GL_RG32I;
case GL_SHORT:
return GL_RG16I;
case GL_UNSIGNED_BYTE:
return GL_RG8UI;
case GL_UNSIGNED_INT:
return GL_RG32UI;
case GL_UNSIGNED_SHORT:
return GL_RG16UI;
default:
break;
}
break;
case GL_SRGB_ALPHA_EXT:
switch (type)
{
case GL_UNSIGNED_BYTE:
return GL_SRGB8_ALPHA8;
default:
break;
}
break;
case GL_SRGB_EXT:
switch (type)
{
case GL_UNSIGNED_BYTE:
return GL_SRGB8;
default:
break;
}
break;
case GL_STENCIL:
switch (type)
{
case GL_UNSIGNED_BYTE:
return GL_STENCIL_INDEX8;
default:
break;
}
break;
case GL_NONE:
return GL_NONE;
default:
break;
}
UNREACHABLE();
return GL_NONE;
}
} // namespace gl
{
"GL_RGBA": {
"GL_UNSIGNED_BYTE": "GL_RGBA8",
"GL_UNSIGNED_SHORT": "GL_RGBA16_EXT",
"GL_BYTE": "GL_RGBA8_SNORM",
"GL_SHORT": "GL_RGBA16_SNORM_EXT",
"GL_UNSIGNED_SHORT_4_4_4_4": "GL_RGBA4",
"GL_UNSIGNED_SHORT_5_5_5_1": "GL_RGB5_A1",
"GL_UNSIGNED_INT_2_10_10_10_REV": "GL_RGB10_A2",
"GL_FLOAT": "GL_RGBA32F",
"GL_HALF_FLOAT": "GL_RGBA16F",
"GL_HALF_FLOAT_OES": "GL_RGBA16F"
},
"GL_RGBA_INTEGER": {
"GL_UNSIGNED_BYTE": "GL_RGBA8UI",
"GL_BYTE": "GL_RGBA8I",
"GL_UNSIGNED_SHORT": "GL_RGBA16UI",
"GL_SHORT": "GL_RGBA16I",
"GL_UNSIGNED_INT": "GL_RGBA32UI",
"GL_INT": "GL_RGBA32I",
"GL_UNSIGNED_INT_2_10_10_10_REV": "GL_RGB10_A2UI"
},
"GL_RGB": {
"GL_UNSIGNED_BYTE": "GL_RGB8",
"GL_UNSIGNED_SHORT": "GL_RGB16_EXT",
"GL_BYTE": "GL_RGB8_SNORM",
"GL_SHORT": "GL_RGB16_SNORM_EXT",
"GL_UNSIGNED_SHORT_5_6_5": "GL_RGB565",
"GL_UNSIGNED_INT_10F_11F_11F_REV": "GL_R11F_G11F_B10F",
"GL_UNSIGNED_INT_5_9_9_9_REV": "GL_RGB9_E5",
"GL_FLOAT": "GL_RGB32F",
"GL_HALF_FLOAT": "GL_RGB16F",
"GL_HALF_FLOAT_OES": "GL_RGB16F"
},
"GL_RGB_INTEGER": {
"GL_UNSIGNED_BYTE": "GL_RGB8UI",
"GL_BYTE": "GL_RGB8I", "GL_UNSIGNED_SHORT": "GL_RGB16UI",
"GL_SHORT": "GL_RGB16I",
"GL_UNSIGNED_INT": "GL_RGB32UI",
"GL_INT": "GL_RGB32I"
},
"GL_RG": {
"GL_UNSIGNED_BYTE": "GL_RG8",
"GL_UNSIGNED_SHORT": "GL_RG16_EXT",
"GL_BYTE": "GL_RG8_SNORM",
"GL_SHORT": "GL_RG16_SNORM_EXT",
"GL_FLOAT": "GL_RG32F",
"GL_HALF_FLOAT": "GL_RG16F",
"GL_HALF_FLOAT_OES": "GL_RG16F"
},
"GL_RG_INTEGER": {
"GL_UNSIGNED_BYTE": "GL_RG8UI",
"GL_BYTE": "GL_RG8I",
"GL_UNSIGNED_SHORT": "GL_RG16UI",
"GL_SHORT": "GL_RG16I",
"GL_UNSIGNED_INT": "GL_RG32UI",
"GL_INT": "GL_RG32I"
},
"GL_RED": {
"GL_UNSIGNED_BYTE": "GL_R8",
"GL_UNSIGNED_SHORT": "GL_R16_EXT",
"GL_BYTE": "GL_R8_SNORM",
"GL_SHORT": "GL_R16_SNORM_EXT",
"GL_FLOAT": "GL_R32F",
"GL_HALF_FLOAT": "GL_R16F",
"GL_HALF_FLOAT_OES": "GL_R16F"
},
"GL_RED_INTEGER": {
"GL_UNSIGNED_BYTE": "GL_R8UI",
"GL_BYTE": "GL_R8I",
"GL_UNSIGNED_SHORT": "GL_R16UI",
"GL_SHORT": "GL_R16I",
"GL_UNSIGNED_INT": "GL_R32UI",
"GL_INT": "GL_R32I"
},
"GL_LUMINANCE_ALPHA": {
"GL_UNSIGNED_BYTE": "GL_LUMINANCE8_ALPHA8_EXT",
"GL_FLOAT": "GL_LUMINANCE_ALPHA32F_EXT",
"GL_HALF_FLOAT": "GL_LUMINANCE_ALPHA16F_EXT",
"GL_HALF_FLOAT_OES": "GL_LUMINANCE_ALPHA16F_EXT"
},
"GL_LUMINANCE": {
"GL_UNSIGNED_BYTE": "GL_LUMINANCE8_EXT",
"GL_FLOAT": "GL_LUMINANCE32F_EXT",
"GL_HALF_FLOAT": "GL_LUMINANCE16F_EXT",
"GL_HALF_FLOAT_OES": "GL_LUMINANCE16F_EXT"
},
"GL_ALPHA": {
"GL_UNSIGNED_BYTE": "GL_ALPHA8_EXT",
"GL_FLOAT": "GL_ALPHA32F_EXT",
"GL_HALF_FLOAT": "GL_ALPHA16F_EXT",
"GL_HALF_FLOAT_OES": "GL_ALPHA16F_EXT"
},
"GL_BGRA_EXT": {
"GL_UNSIGNED_BYTE": "GL_BGRA8_EXT",
"GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT": "GL_BGRA4_ANGLEX",
"GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT": "GL_BGR5_A1_ANGLEX",
"GL_UNSIGNED_SHORT_5_6_5": "GL_BGR565_ANGLEX"
},
"GL_SRGB_EXT": {
"GL_UNSIGNED_BYTE": "GL_SRGB8"
},
"GL_SRGB_ALPHA_EXT": {
"GL_UNSIGNED_BYTE": "GL_SRGB8_ALPHA8"
},
"GL_COMPRESSED_RGB_S3TC_DXT1_EXT": {
"GL_UNSIGNED_BYTE": "GL_COMPRESSED_RGB_S3TC_DXT1_EXT"
},
"GL_COMPRESSED_RGBA_S3TC_DXT1_EXT": {
"GL_UNSIGNED_BYTE": "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT"
},
"GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE": {
"GL_UNSIGNED_BYTE": "GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE"
},
"GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE": {
"GL_UNSIGNED_BYTE": "GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE"
},
"GL_DEPTH_COMPONENT": {
"GL_UNSIGNED_SHORT": "GL_DEPTH_COMPONENT16",
"GL_UNSIGNED_INT": "GL_DEPTH_COMPONENT32_OES",
"GL_FLOAT": "GL_DEPTH_COMPONENT32F"
},
"GL_STENCIL": {
"GL_UNSIGNED_BYTE": "GL_STENCIL_INDEX8"
},
"GL_DEPTH_STENCIL": {
"GL_UNSIGNED_INT_24_8": "GL_DEPTH24_STENCIL8",
"GL_FLOAT_32_UNSIGNED_INT_24_8_REV": "GL_DEPTH32F_STENCIL8"
}
}
...@@ -16,154 +16,13 @@ using namespace angle; ...@@ -16,154 +16,13 @@ using namespace angle;
namespace gl namespace gl
{ {
namespace
{
// ES2 requires that format is equal to internal format at all glTex*Image2D entry points and the implementation // 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 // can decide the true, sized, internal format. The ES2FormatMap determines the internal format for all valid
// format and type combinations. // format and type combinations.
GLenum GetSizedFormatInternal(GLenum format, GLenum type);
typedef std::pair<FormatType, GLenum> FormatPair; namespace
typedef std::map<FormatType, GLenum> FormatMap;
// A helper function to insert data into the format map with fewer characters.
void InsertFormatMapping(FormatMap *map, GLenum format, GLenum type, GLenum internalFormat)
{
map->insert(FormatPair(FormatType(format, type), internalFormat));
}
FormatMap BuildFormatMap()
{
FormatMap map;
// clang-format off
// | Format | Type | Internal format |
InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_BYTE, GL_RGBA8);
InsertFormatMapping(&map, GL_RGBA, GL_BYTE, GL_RGBA8_SNORM);
InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_RGBA4);
InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_RGB5_A1);
InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_RGB10_A2);
InsertFormatMapping(&map, GL_RGBA, GL_FLOAT, GL_RGBA32F);
InsertFormatMapping(&map, GL_RGBA, GL_HALF_FLOAT, GL_RGBA16F);
InsertFormatMapping(&map, GL_RGBA, GL_HALF_FLOAT_OES, GL_RGBA16F);
InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_RGBA8UI);
InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_BYTE, GL_RGBA8I);
InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_RGBA16UI);
InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_SHORT, GL_RGBA16I);
InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_RGBA32UI);
InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_INT, GL_RGBA32I);
InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_RGB10_A2UI);
InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_BYTE, GL_RGB8);
InsertFormatMapping(&map, GL_RGB, GL_BYTE, GL_RGB8_SNORM);
InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_RGB565);
InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_R11F_G11F_B10F);
InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_RGB9_E5);
InsertFormatMapping(&map, GL_RGB, GL_FLOAT, GL_RGB32F);
InsertFormatMapping(&map, GL_RGB, GL_HALF_FLOAT, GL_RGB16F);
InsertFormatMapping(&map, GL_RGB, GL_HALF_FLOAT_OES, GL_RGB16F);
InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_RGB8UI);
InsertFormatMapping(&map, GL_RGB_INTEGER, GL_BYTE, GL_RGB8I);
InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_RGB16UI);
InsertFormatMapping(&map, GL_RGB_INTEGER, GL_SHORT, GL_RGB16I);
InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_RGB32UI);
InsertFormatMapping(&map, GL_RGB_INTEGER, GL_INT, GL_RGB32I);
InsertFormatMapping(&map, GL_RG, GL_UNSIGNED_BYTE, GL_RG8);
InsertFormatMapping(&map, GL_RG, GL_BYTE, GL_RG8_SNORM);
InsertFormatMapping(&map, GL_RG, GL_FLOAT, GL_RG32F);
InsertFormatMapping(&map, GL_RG, GL_HALF_FLOAT, GL_RG16F);
InsertFormatMapping(&map, GL_RG, GL_HALF_FLOAT_OES, GL_RG16F);
InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_RG8UI);
InsertFormatMapping(&map, GL_RG_INTEGER, GL_BYTE, GL_RG8I);
InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_RG16UI);
InsertFormatMapping(&map, GL_RG_INTEGER, GL_SHORT, GL_RG16I);
InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_RG32UI);
InsertFormatMapping(&map, GL_RG_INTEGER, GL_INT, GL_RG32I);
InsertFormatMapping(&map, GL_RED, GL_UNSIGNED_BYTE, GL_R8);
InsertFormatMapping(&map, GL_RED, GL_BYTE, GL_R8_SNORM);
InsertFormatMapping(&map, GL_RED, GL_FLOAT, GL_R32F);
InsertFormatMapping(&map, GL_RED, GL_HALF_FLOAT, GL_R16F);
InsertFormatMapping(&map, GL_RED, GL_HALF_FLOAT_OES, GL_R16F);
InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_R8UI);
InsertFormatMapping(&map, GL_RED_INTEGER, GL_BYTE, GL_R8I);
InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_R16UI);
InsertFormatMapping(&map, GL_RED_INTEGER, GL_SHORT, GL_R16I);
InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_R32UI);
InsertFormatMapping(&map, GL_RED_INTEGER, GL_INT, GL_R32I);
InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_LUMINANCE8_ALPHA8_EXT);
InsertFormatMapping(&map, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_LUMINANCE8_EXT);
InsertFormatMapping(&map, GL_ALPHA, GL_UNSIGNED_BYTE, GL_ALPHA8_EXT);
InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_LUMINANCE_ALPHA32F_EXT);
InsertFormatMapping(&map, GL_LUMINANCE, GL_FLOAT, GL_LUMINANCE32F_EXT);
InsertFormatMapping(&map, GL_ALPHA, GL_FLOAT, GL_ALPHA32F_EXT);
InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, GL_LUMINANCE_ALPHA16F_EXT);
InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_LUMINANCE_ALPHA16F_EXT);
InsertFormatMapping(&map, GL_LUMINANCE, GL_HALF_FLOAT, GL_LUMINANCE16F_EXT);
InsertFormatMapping(&map, GL_LUMINANCE, GL_HALF_FLOAT_OES, GL_LUMINANCE16F_EXT);
InsertFormatMapping(&map, GL_ALPHA, GL_HALF_FLOAT, GL_ALPHA16F_EXT);
InsertFormatMapping(&map, GL_ALPHA, GL_HALF_FLOAT_OES, GL_ALPHA16F_EXT);
InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_BGRA8_EXT);
InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_BGRA4_ANGLEX);
InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_BGR5_A1_ANGLEX);
InsertFormatMapping(&map, GL_SRGB_EXT, GL_UNSIGNED_BYTE, GL_SRGB8);
InsertFormatMapping(&map, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, GL_SRGB8_ALPHA8);
InsertFormatMapping(&map, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGB_S3TC_DXT1_EXT);
InsertFormatMapping(&map, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
InsertFormatMapping(&map, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE);
InsertFormatMapping(&map, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE);
InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_DEPTH_COMPONENT16);
InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_DEPTH_COMPONENT32_OES);
InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_FLOAT, GL_DEPTH_COMPONENT32F);
InsertFormatMapping(&map, GL_STENCIL, GL_UNSIGNED_BYTE, GL_STENCIL_INDEX8);
InsertFormatMapping(&map, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH24_STENCIL8);
InsertFormatMapping(&map, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_DEPTH32F_STENCIL8);
// From GL_EXT_texture_norm16
InsertFormatMapping(&map, GL_RED, GL_UNSIGNED_SHORT, GL_R16_EXT);
InsertFormatMapping(&map, GL_RED, GL_SHORT, GL_R16_SNORM_EXT);
InsertFormatMapping(&map, GL_RG, GL_UNSIGNED_SHORT, GL_RG16_EXT);
InsertFormatMapping(&map, GL_RG, GL_SHORT, GL_RG16_SNORM_EXT);
InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_SHORT, GL_RGB16_EXT);
InsertFormatMapping(&map, GL_RGB, GL_SHORT, GL_RGB16_SNORM_EXT);
InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT, GL_RGBA16_EXT);
InsertFormatMapping(&map, GL_RGBA, GL_SHORT, GL_RGBA16_SNORM_EXT);
// clang-format on
return map;
}
GLenum GetSizedFormatInternal(GLenum format, GLenum type)
{ {
static const FormatMap formatMap = BuildFormatMap();
auto iter = formatMap.find(FormatType(format, type));
if (iter != formatMap.end())
{
return iter->second;
}
// TODO(jmadill): Fix this hack.
if (format == GL_BGRA_EXT && type == GL_UNSIGNED_SHORT_5_6_5)
return GL_BGR565_ANGLEX;
if (format == GL_NONE)
return GL_NONE;
UNREACHABLE();
return GL_NONE;
}
typedef std::pair<GLenum, InternalFormat> InternalFormatInfoPair; typedef std::pair<GLenum, InternalFormat> InternalFormatInfoPair;
typedef std::map<GLenum, InternalFormat> InternalFormatInfoMap; typedef std::map<GLenum, InternalFormat> InternalFormatInfoMap;
......
#!/usr/bin/python
# Copyright 2016 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.
#
# gen_format_map.py:
# Code generation for GL format map. The format map matches between
# {format,type} and internal format.
from datetime import date
import sys
sys.path.append('renderer')
import angle_format
template_cpp = """// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}.
//
// Copyright {copyright_year} 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.
//
// format_map:
// Determining the sized internal format from a (format,type) pair.
#include "angle_gl.h"
#include "common/debug.h"
namespace gl
{{
GLenum GetSizedFormatInternal(GLenum format, GLenum type)
{{
switch (format)
{{
{format_cases} case GL_NONE:
return GL_NONE;
default:
break;
}}
UNREACHABLE();
return GL_NONE;
}}
}} // namespace gl
"""
template_format_case = """ case {format}:
switch (type)
{{
{type_cases} default:
break;
}}
break;
"""
template_type_case = """ case {type}:
return {internal_format};
"""
def parse_type_case(type, internal_format):
return template_type_case.format(
type = type, internal_format = internal_format)
def parse_format_case(format, type_map):
type_cases = ""
for type, internal_format in sorted(type_map.iteritems()):
type_cases += parse_type_case(type, internal_format)
return template_format_case.format(
format = format, type_cases = type_cases)
input_script = 'format_map_data.json'
format_map = angle_format.load_json(input_script)
format_cases = ""
for format, type_map in sorted(format_map.iteritems()):
format_cases += parse_format_case(format, type_map)
with open('format_map_autogen.cpp', 'wt') as out_file:
output_cpp = template_cpp.format(
script_name = sys.argv[0],
data_source_name = input_script,
copyright_year = date.today().year,
format_cases = format_cases)
out_file.write(output_cpp)
out_file.close()
...@@ -153,6 +153,7 @@ ...@@ -153,6 +153,7 @@
'libANGLE/angletypes.h', 'libANGLE/angletypes.h',
'libANGLE/angletypes.inl', 'libANGLE/angletypes.inl',
'libANGLE/features.h', 'libANGLE/features.h',
'libANGLE/format_map_autogen.cpp',
'libANGLE/formatutils.cpp', 'libANGLE/formatutils.cpp',
'libANGLE/formatutils.h', 'libANGLE/formatutils.h',
'libANGLE/histogram_macros.h', 'libANGLE/histogram_macros.h',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment