blob: 8674d5337fc557820493713208a2b190aa1116a7 [file] [log] [blame]
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001//
Geoff Langcec35902014-04-16 10:52:36 -04002// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved.
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// formatutils.cpp: Queries for GL image formats.
8
Shannon Woods4d161ba2014-03-17 18:13:30 -04009#include "common/mathutil.h"
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000010#include "libGLESv2/formatutils.h"
11#include "libGLESv2/Context.h"
Shannon Woods4d161ba2014-03-17 18:13:30 -040012#include "libGLESv2/Framebuffer.h"
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000013#include "libGLESv2/renderer/Renderer.h"
Geoff Langfe28ca02013-06-04 10:10:48 -040014#include "libGLESv2/renderer/imageformats.h"
15#include "libGLESv2/renderer/copyimage.h"
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000016
17namespace gl
18{
19
20// ES2 requires that format is equal to internal format at all glTex*Image2D entry points and the implementation
21// can decide the true, sized, internal format. The ES2FormatMap determines the internal format for all valid
22// format and type combinations.
23
Geoff Lang5d601382014-07-22 15:14:06 -040024FormatType::FormatType()
25 : internalFormat(GL_NONE),
26 colorWriteFunction(NULL)
Geoff Langfe28ca02013-06-04 10:10:48 -040027{
Geoff Lang5d601382014-07-22 15:14:06 -040028}
Geoff Langfe28ca02013-06-04 10:10:48 -040029
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000030typedef std::pair<GLenum, GLenum> FormatTypePair;
Geoff Lang5d601382014-07-22 15:14:06 -040031typedef std::pair<FormatTypePair, FormatType> FormatPair;
32typedef std::map<FormatTypePair, FormatType> FormatMap;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000033
Jamie Madill89a0bf52013-09-18 14:36:24 -040034// A helper function to insert data into the format map with fewer characters.
Geoff Lang005df412013-10-16 14:12:50 -040035static inline void InsertFormatMapping(FormatMap *map, GLenum format, GLenum type, GLenum internalFormat, ColorWriteFunction writeFunc)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000036{
Geoff Lang5d601382014-07-22 15:14:06 -040037 FormatType info;
38 info.internalFormat = internalFormat;
39 info.colorWriteFunction = writeFunc;
40 map->insert(FormatPair(FormatTypePair(format, type), info));
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000041}
42
Geoff Lange4a492b2014-06-19 14:14:41 -040043FormatMap BuildFormatMap()
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000044{
45 FormatMap map;
46
Geoff Langfe28ca02013-06-04 10:10:48 -040047 using namespace rx;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000048
Geoff Langfe28ca02013-06-04 10:10:48 -040049 // | Format | Type | Internal format | Color write function |
50 InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_BYTE, GL_RGBA8, WriteColor<R8G8B8A8, GLfloat> );
51 InsertFormatMapping(&map, GL_RGBA, GL_BYTE, GL_RGBA8_SNORM, WriteColor<R8G8B8A8S, GLfloat> );
52 InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_RGBA4, WriteColor<R4G4B4A4, GLfloat> );
53 InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_RGB5_A1, WriteColor<R5G5B5A1, GLfloat> );
54 InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_RGB10_A2, WriteColor<R10G10B10A2, GLfloat> );
55 InsertFormatMapping(&map, GL_RGBA, GL_FLOAT, GL_RGBA32F, WriteColor<R32G32B32A32F, GLfloat>);
56 InsertFormatMapping(&map, GL_RGBA, GL_HALF_FLOAT, GL_RGBA16F, WriteColor<R16G16B16A16F, GLfloat>);
Geoff Lange4a492b2014-06-19 14:14:41 -040057 InsertFormatMapping(&map, GL_RGBA, GL_HALF_FLOAT_OES, GL_RGBA16F, WriteColor<R16G16B16A16F, GLfloat>);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000058
Geoff Langfe28ca02013-06-04 10:10:48 -040059 InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_RGBA8UI, WriteColor<R8G8B8A8, GLuint> );
60 InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_BYTE, GL_RGBA8I, WriteColor<R8G8B8A8S, GLint> );
61 InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_RGBA16UI, WriteColor<R16G16B16A16, GLuint> );
62 InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_SHORT, GL_RGBA16I, WriteColor<R16G16B16A16S, GLint> );
63 InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_RGBA32UI, WriteColor<R32G32B32A32, GLuint> );
64 InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_INT, GL_RGBA32I, WriteColor<R32G32B32A32S, GLint> );
Jamie Madill18a44702013-09-09 16:24:04 -040065 InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_RGB10_A2UI, WriteColor<R10G10B10A2, GLuint> );
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000066
Geoff Langfe28ca02013-06-04 10:10:48 -040067 InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_BYTE, GL_RGB8, WriteColor<R8G8B8, GLfloat> );
68 InsertFormatMapping(&map, GL_RGB, GL_BYTE, GL_RGB8_SNORM, WriteColor<R8G8B8S, GLfloat> );
69 InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_RGB565, WriteColor<R5G6B5, GLfloat> );
70 InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_R11F_G11F_B10F, WriteColor<R11G11B10F, GLfloat> );
71 InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_RGB9_E5, WriteColor<R9G9B9E5, GLfloat> );
72 InsertFormatMapping(&map, GL_RGB, GL_FLOAT, GL_RGB32F, WriteColor<R32G32B32F, GLfloat> );
73 InsertFormatMapping(&map, GL_RGB, GL_HALF_FLOAT, GL_RGB16F, WriteColor<R16G16B16F, GLfloat> );
Geoff Lange4a492b2014-06-19 14:14:41 -040074 InsertFormatMapping(&map, GL_RGB, GL_HALF_FLOAT_OES, GL_RGB16F, WriteColor<R16G16B16F, GLfloat> );
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000075
Geoff Langfe28ca02013-06-04 10:10:48 -040076 InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_RGB8UI, WriteColor<R8G8B8, GLuint> );
77 InsertFormatMapping(&map, GL_RGB_INTEGER, GL_BYTE, GL_RGB8I, WriteColor<R8G8B8S, GLint> );
78 InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_RGB16UI, WriteColor<R16G16B16, GLuint> );
79 InsertFormatMapping(&map, GL_RGB_INTEGER, GL_SHORT, GL_RGB16I, WriteColor<R16G16B16S, GLint> );
80 InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_RGB32UI, WriteColor<R32G32B32, GLuint> );
81 InsertFormatMapping(&map, GL_RGB_INTEGER, GL_INT, GL_RGB32I, WriteColor<R32G32B32S, GLint> );
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000082
Geoff Langfe28ca02013-06-04 10:10:48 -040083 InsertFormatMapping(&map, GL_RG, GL_UNSIGNED_BYTE, GL_RG8, WriteColor<R8G8, GLfloat> );
84 InsertFormatMapping(&map, GL_RG, GL_BYTE, GL_RG8_SNORM, WriteColor<R8G8S, GLfloat> );
85 InsertFormatMapping(&map, GL_RG, GL_FLOAT, GL_RG32F, WriteColor<R32G32F, GLfloat> );
86 InsertFormatMapping(&map, GL_RG, GL_HALF_FLOAT, GL_RG16F, WriteColor<R16G16F, GLfloat> );
Geoff Lange4a492b2014-06-19 14:14:41 -040087 InsertFormatMapping(&map, GL_RG, GL_HALF_FLOAT_OES, GL_RG16F, WriteColor<R16G16F, GLfloat> );
Geoff Langfe28ca02013-06-04 10:10:48 -040088
89 InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_RG8UI, WriteColor<R8G8, GLuint> );
90 InsertFormatMapping(&map, GL_RG_INTEGER, GL_BYTE, GL_RG8I, WriteColor<R8G8S, GLint> );
91 InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_RG16UI, WriteColor<R16G16, GLuint> );
92 InsertFormatMapping(&map, GL_RG_INTEGER, GL_SHORT, GL_RG16I, WriteColor<R16G16S, GLint> );
93 InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_RG32UI, WriteColor<R32G32, GLuint> );
94 InsertFormatMapping(&map, GL_RG_INTEGER, GL_INT, GL_RG32I, WriteColor<R32G32S, GLint> );
95
96 InsertFormatMapping(&map, GL_RED, GL_UNSIGNED_BYTE, GL_R8, WriteColor<R8, GLfloat> );
97 InsertFormatMapping(&map, GL_RED, GL_BYTE, GL_R8_SNORM, WriteColor<R8S, GLfloat> );
98 InsertFormatMapping(&map, GL_RED, GL_FLOAT, GL_R32F, WriteColor<R32F, GLfloat> );
99 InsertFormatMapping(&map, GL_RED, GL_HALF_FLOAT, GL_R16F, WriteColor<R16F, GLfloat> );
Geoff Lange4a492b2014-06-19 14:14:41 -0400100 InsertFormatMapping(&map, GL_RED, GL_HALF_FLOAT_OES, GL_R16F, WriteColor<R16F, GLfloat> );
Geoff Langfe28ca02013-06-04 10:10:48 -0400101
102 InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_R8UI, WriteColor<R8, GLuint> );
103 InsertFormatMapping(&map, GL_RED_INTEGER, GL_BYTE, GL_R8I, WriteColor<R8S, GLint> );
104 InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_R16UI, WriteColor<R16, GLuint> );
105 InsertFormatMapping(&map, GL_RED_INTEGER, GL_SHORT, GL_R16I, WriteColor<R16S, GLint> );
106 InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_R32UI, WriteColor<R32, GLuint> );
107 InsertFormatMapping(&map, GL_RED_INTEGER, GL_INT, GL_R32I, WriteColor<R32S, GLint> );
108
109 InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_LUMINANCE8_ALPHA8_EXT, WriteColor<L8A8, GLfloat> );
110 InsertFormatMapping(&map, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_LUMINANCE8_EXT, WriteColor<L8, GLfloat> );
111 InsertFormatMapping(&map, GL_ALPHA, GL_UNSIGNED_BYTE, GL_ALPHA8_EXT, WriteColor<A8, GLfloat> );
112 InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_LUMINANCE_ALPHA32F_EXT, WriteColor<L32A32F, GLfloat> );
113 InsertFormatMapping(&map, GL_LUMINANCE, GL_FLOAT, GL_LUMINANCE32F_EXT, WriteColor<L32F, GLfloat> );
114 InsertFormatMapping(&map, GL_ALPHA, GL_FLOAT, GL_ALPHA32F_EXT, WriteColor<A32F, GLfloat> );
115 InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, GL_LUMINANCE_ALPHA16F_EXT, WriteColor<L16A16F, GLfloat> );
Geoff Lange4a492b2014-06-19 14:14:41 -0400116 InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_LUMINANCE_ALPHA16F_EXT, WriteColor<L16A16F, GLfloat> );
Geoff Langfe28ca02013-06-04 10:10:48 -0400117 InsertFormatMapping(&map, GL_LUMINANCE, GL_HALF_FLOAT, GL_LUMINANCE16F_EXT, WriteColor<L16F, GLfloat> );
Geoff Lange4a492b2014-06-19 14:14:41 -0400118 InsertFormatMapping(&map, GL_LUMINANCE, GL_HALF_FLOAT_OES, GL_LUMINANCE16F_EXT, WriteColor<L16F, GLfloat> );
Geoff Langfe28ca02013-06-04 10:10:48 -0400119 InsertFormatMapping(&map, GL_ALPHA, GL_HALF_FLOAT, GL_ALPHA16F_EXT, WriteColor<A16F, GLfloat> );
Geoff Lange4a492b2014-06-19 14:14:41 -0400120 InsertFormatMapping(&map, GL_ALPHA, GL_HALF_FLOAT_OES, GL_ALPHA16F_EXT, WriteColor<A16F, GLfloat> );
Geoff Langfe28ca02013-06-04 10:10:48 -0400121
122 InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_BGRA8_EXT, WriteColor<B8G8R8A8, GLfloat> );
123 InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_BGRA4_ANGLEX, WriteColor<B4G4R4A4, GLfloat> );
124 InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_BGR5_A1_ANGLEX, WriteColor<B5G5R5A1, GLfloat> );
125
Geoff Lang05b05022014-06-11 15:31:45 -0400126 InsertFormatMapping(&map, GL_SRGB_EXT, GL_UNSIGNED_BYTE, GL_SRGB8, WriteColor<R8G8B8, GLfloat> );
127 InsertFormatMapping(&map, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, GL_SRGB8_ALPHA8, WriteColor<R8G8B8A8, GLfloat> );
128
Geoff Langcec35902014-04-16 10:52:36 -0400129 InsertFormatMapping(&map, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, NULL );
130 InsertFormatMapping(&map, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, NULL );
131 InsertFormatMapping(&map, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, NULL );
132 InsertFormatMapping(&map, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, NULL );
133
Geoff Langfe28ca02013-06-04 10:10:48 -0400134 InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_DEPTH_COMPONENT16, NULL );
Geoff Lange4a492b2014-06-19 14:14:41 -0400135 InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_DEPTH_COMPONENT32_OES, NULL );
Geoff Langfe28ca02013-06-04 10:10:48 -0400136 InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_FLOAT, GL_DEPTH_COMPONENT32F, NULL );
137
Geoff Lange4a492b2014-06-19 14:14:41 -0400138 InsertFormatMapping(&map, GL_STENCIL, GL_UNSIGNED_BYTE, GL_STENCIL_INDEX8, NULL );
139
Geoff Langfe28ca02013-06-04 10:10:48 -0400140 InsertFormatMapping(&map, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH24_STENCIL8, NULL );
141 InsertFormatMapping(&map, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_DEPTH32F_STENCIL8, NULL );
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000142
143 return map;
144}
145
Geoff Lang5d601382014-07-22 15:14:06 -0400146Type::Type()
147 : bytes(0),
148 specialInterpretation(false)
Geoff Langfe28ca02013-06-04 10:10:48 -0400149{
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000150}
151
152// Map of sizes of input types
Geoff Lang5d601382014-07-22 15:14:06 -0400153typedef std::pair<GLenum, Type> TypeInfoPair;
154typedef std::map<GLenum, Type> TypeInfoMap;
155
156static inline void InsertTypeInfo(TypeInfoMap *map, GLenum type, GLuint bytes, bool specialInterpretation)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000157{
Geoff Lang5d601382014-07-22 15:14:06 -0400158 Type info;
159 info.bytes = bytes;
160 info.specialInterpretation = specialInterpretation;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000161
Geoff Lang5d601382014-07-22 15:14:06 -0400162 map->insert(std::make_pair(type, info));
163}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000164
Geoff Lang5d601382014-07-22 15:14:06 -0400165bool operator<(const Type& a, const Type& b)
166{
167 return memcmp(&a, &b, sizeof(Type)) < 0;
168}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000169
Geoff Lang18591b72013-06-07 12:00:15 -0400170static TypeInfoMap BuildTypeInfoMap()
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000171{
172 TypeInfoMap map;
173
Geoff Lang5d601382014-07-22 15:14:06 -0400174 InsertTypeInfo(&map, GL_UNSIGNED_BYTE, 1, false);
175 InsertTypeInfo(&map, GL_BYTE, 1, false);
176 InsertTypeInfo(&map, GL_UNSIGNED_SHORT, 2, false);
177 InsertTypeInfo(&map, GL_SHORT, 2, false);
178 InsertTypeInfo(&map, GL_UNSIGNED_INT, 4, false);
179 InsertTypeInfo(&map, GL_INT, 4, false);
180 InsertTypeInfo(&map, GL_HALF_FLOAT, 2, false);
181 InsertTypeInfo(&map, GL_HALF_FLOAT_OES, 2, false);
182 InsertTypeInfo(&map, GL_FLOAT, 4, false);
183 InsertTypeInfo(&map, GL_UNSIGNED_SHORT_5_6_5, 2, true );
184 InsertTypeInfo(&map, GL_UNSIGNED_SHORT_4_4_4_4, 2, true );
185 InsertTypeInfo(&map, GL_UNSIGNED_SHORT_5_5_5_1, 2, true );
186 InsertTypeInfo(&map, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, 2, true );
187 InsertTypeInfo(&map, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, 2, true );
188 InsertTypeInfo(&map, GL_UNSIGNED_INT_2_10_10_10_REV, 4, true );
189 InsertTypeInfo(&map, GL_UNSIGNED_INT_24_8, 4, true );
190 InsertTypeInfo(&map, GL_UNSIGNED_INT_10F_11F_11F_REV, 4, true );
191 InsertTypeInfo(&map, GL_UNSIGNED_INT_5_9_9_9_REV, 4, true );
192 InsertTypeInfo(&map, GL_UNSIGNED_INT_24_8_OES, 4, true );
193 InsertTypeInfo(&map, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, 8, true );
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000194
195 return map;
196}
197
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000198// Information about internal formats
Geoff Lang493daf52014-07-03 13:38:44 -0400199static bool AlwaysSupported(GLuint, const Extensions &)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000200{
Geoff Lang493daf52014-07-03 13:38:44 -0400201 return true;
202}
203
204static bool UnimplementedSupport(GLuint, const Extensions &)
205{
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000206 return false;
207}
208
Geoff Lang493daf52014-07-03 13:38:44 -0400209static bool NeverSupported(GLuint, const Extensions &)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000210{
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000211 return false;
212}
213
Geoff Lange4a492b2014-06-19 14:14:41 -0400214template <GLuint minCoreGLVersion>
Geoff Langabce7622014-09-19 16:13:00 -0400215static bool RequireES(GLuint clientVersion, const Extensions &)
Geoff Lange4a492b2014-06-19 14:14:41 -0400216{
217 return clientVersion >= minCoreGLVersion;
218}
219
Geoff Langcec35902014-04-16 10:52:36 -0400220// Pointer to a boolean memeber of the Extensions struct
221typedef bool(Extensions::*ExtensionBool);
222
223// Check support for a single extension
224template <ExtensionBool bool1>
Geoff Langabce7622014-09-19 16:13:00 -0400225static bool RequireExt(GLuint, const Extensions & extensions)
Geoff Langcec35902014-04-16 10:52:36 -0400226{
Geoff Lange4a492b2014-06-19 14:14:41 -0400227 return extensions.*bool1;
228}
229
230// Check for a minimum client version or a single extension
231template <GLuint minCoreGLVersion, ExtensionBool bool1>
Geoff Langabce7622014-09-19 16:13:00 -0400232static bool RequireESOrExt(GLuint clientVersion, const Extensions &extensions)
Geoff Lange4a492b2014-06-19 14:14:41 -0400233{
234 return clientVersion >= minCoreGLVersion || extensions.*bool1;
235}
236
237// Check for a minimum client version or two extensions
238template <GLuint minCoreGLVersion, ExtensionBool bool1, ExtensionBool bool2>
Geoff Langabce7622014-09-19 16:13:00 -0400239static bool RequireESOrExtAndExt(GLuint clientVersion, const Extensions &extensions)
Geoff Lange4a492b2014-06-19 14:14:41 -0400240{
Geoff Langabce7622014-09-19 16:13:00 -0400241 return clientVersion >= minCoreGLVersion || (extensions.*bool1 && extensions.*bool2);
242}
243
244// Check for a minimum client version or at least one of two extensions
245template <GLuint minCoreGLVersion, ExtensionBool bool1, ExtensionBool bool2>
246static bool RequireESOrExtOrExt(GLuint clientVersion, const Extensions &extensions)
247{
248 return clientVersion >= minCoreGLVersion || extensions.*bool1 || extensions.*bool2;
Geoff Langcec35902014-04-16 10:52:36 -0400249}
250
251// Check support for two extensions
252template <ExtensionBool bool1, ExtensionBool bool2>
Geoff Langabce7622014-09-19 16:13:00 -0400253static bool RequireExtAndExt(GLuint, const Extensions &extensions)
Geoff Langcec35902014-04-16 10:52:36 -0400254{
Geoff Langabce7622014-09-19 16:13:00 -0400255 return extensions.*bool1 && extensions.*bool2;
Geoff Langcec35902014-04-16 10:52:36 -0400256}
257
Geoff Lang5d601382014-07-22 15:14:06 -0400258InternalFormat::InternalFormat()
259 : redBits(0),
260 greenBits(0),
261 blueBits(0),
262 luminanceBits(0),
263 alphaBits(0),
264 sharedBits(0),
265 depthBits(0),
266 stencilBits(0),
267 pixelBytes(0),
268 componentCount(0),
269 compressedBlockWidth(0),
270 compressedBlockHeight(0),
271 format(GL_NONE),
272 type(GL_NONE),
273 componentType(GL_NONE),
274 colorEncoding(GL_NONE),
275 compressed(false),
276 textureSupport(NeverSupported),
277 renderSupport(NeverSupported),
278 filterSupport(NeverSupported)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000279{
Geoff Lang5d601382014-07-22 15:14:06 -0400280}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000281
Geoff Lang5d601382014-07-22 15:14:06 -0400282static InternalFormat UnsizedFormat(GLenum format, InternalFormat::SupportCheckFunction textureSupport,
283 InternalFormat::SupportCheckFunction renderSupport,
284 InternalFormat::SupportCheckFunction filterSupport)
285{
286 InternalFormat formatInfo;
287 formatInfo.format = format;
288 formatInfo.textureSupport = textureSupport;
289 formatInfo.renderSupport = renderSupport;
290 formatInfo.filterSupport = filterSupport;
291 return formatInfo;
292}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000293
Geoff Lang5d601382014-07-22 15:14:06 -0400294static InternalFormat RGBAFormat(GLuint red, GLuint green, GLuint blue, GLuint alpha, GLuint shared,
295 GLenum format, GLenum type, GLenum componentType, bool srgb,
296 InternalFormat::SupportCheckFunction textureSupport,
297 InternalFormat::SupportCheckFunction renderSupport,
298 InternalFormat::SupportCheckFunction filterSupport)
299{
300 InternalFormat formatInfo;
301 formatInfo.redBits = red;
302 formatInfo.greenBits = green;
303 formatInfo.blueBits = blue;
304 formatInfo.alphaBits = alpha;
305 formatInfo.sharedBits = shared;
306 formatInfo.pixelBytes = (red + green + blue + alpha + shared) / 8;
307 formatInfo.componentCount = ((red > 0) ? 1 : 0) + ((green > 0) ? 1 : 0) + ((blue > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0);
308 formatInfo.format = format;
309 formatInfo.type = type;
310 formatInfo.componentType = componentType;
311 formatInfo.colorEncoding = (srgb ? GL_SRGB : GL_LINEAR);
312 formatInfo.textureSupport = textureSupport;
313 formatInfo.renderSupport = renderSupport;
314 formatInfo.filterSupport = filterSupport;
315 return formatInfo;
316}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000317
Geoff Lang5d601382014-07-22 15:14:06 -0400318static InternalFormat LUMAFormat(GLuint luminance, GLuint alpha, GLenum format, GLenum type, GLenum componentType,
319 InternalFormat::SupportCheckFunction textureSupport,
320 InternalFormat::SupportCheckFunction renderSupport,
321 InternalFormat::SupportCheckFunction filterSupport)
322{
323 InternalFormat formatInfo;
324 formatInfo.luminanceBits = luminance;
325 formatInfo.alphaBits = alpha;
326 formatInfo.pixelBytes = (luminance + alpha) / 8;
327 formatInfo.componentCount = ((luminance > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0);
328 formatInfo.format = format;
329 formatInfo.type = type;
330 formatInfo.componentType = componentType;
331 formatInfo.colorEncoding = GL_LINEAR;
332 formatInfo.textureSupport = textureSupport;
333 formatInfo.renderSupport = renderSupport;
334 formatInfo.filterSupport = filterSupport;
335 return formatInfo;
336}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000337
Geoff Lang5d601382014-07-22 15:14:06 -0400338static InternalFormat DepthStencilFormat(GLuint depthBits, GLuint stencilBits, GLuint unusedBits, GLenum format,
339 GLenum type, GLenum componentType, InternalFormat::SupportCheckFunction textureSupport,
340 InternalFormat::SupportCheckFunction renderSupport,
341 InternalFormat::SupportCheckFunction filterSupport)
342{
343 InternalFormat formatInfo;
344 formatInfo.depthBits = depthBits;
345 formatInfo.stencilBits = stencilBits;
346 formatInfo.pixelBytes = (depthBits + stencilBits + unusedBits) / 8;
347 formatInfo.componentCount = ((depthBits > 0) ? 1 : 0) + ((stencilBits > 0) ? 1 : 0);
348 formatInfo.format = format;
349 formatInfo.type = type;
350 formatInfo.componentType = componentType;
351 formatInfo.colorEncoding = GL_LINEAR;
352 formatInfo.textureSupport = textureSupport;
353 formatInfo.renderSupport = renderSupport;
354 formatInfo.filterSupport = filterSupport;
355 return formatInfo;
356}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000357
Geoff Lang5d601382014-07-22 15:14:06 -0400358static InternalFormat CompressedFormat(GLuint compressedBlockWidth, GLuint compressedBlockHeight, GLuint compressedBlockSize,
359 GLuint componentCount, GLenum format, GLenum type, bool srgb,
360 InternalFormat::SupportCheckFunction textureSupport,
361 InternalFormat::SupportCheckFunction renderSupport,
362 InternalFormat::SupportCheckFunction filterSupport)
363{
364 InternalFormat formatInfo;
365 formatInfo.compressedBlockWidth = compressedBlockWidth;
366 formatInfo.compressedBlockHeight = compressedBlockHeight;
367 formatInfo.pixelBytes = compressedBlockSize / 8;
368 formatInfo.componentCount = componentCount;
369 formatInfo.format = format;
370 formatInfo.type = type;
371 formatInfo.componentType = GL_UNSIGNED_NORMALIZED;
372 formatInfo.colorEncoding = (srgb ? GL_SRGB : GL_LINEAR);
373 formatInfo.compressed = true;
374 formatInfo.textureSupport = textureSupport;
375 formatInfo.renderSupport = renderSupport;
376 formatInfo.filterSupport = filterSupport;
377 return formatInfo;
378}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000379
Geoff Lang5d601382014-07-22 15:14:06 -0400380typedef std::pair<GLenum, InternalFormat> InternalFormatInfoPair;
381typedef std::map<GLenum, InternalFormat> InternalFormatInfoMap;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000382
Geoff Lange4a492b2014-06-19 14:14:41 -0400383static InternalFormatInfoMap BuildInternalFormatInfoMap()
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000384{
385 InternalFormatInfoMap map;
386
387 // From ES 3.0.1 spec, table 3.12
Geoff Lang5d601382014-07-22 15:14:06 -0400388 map.insert(InternalFormatInfoPair(GL_NONE, InternalFormat()));
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000389
Geoff Langabce7622014-09-19 16:13:00 -0400390 // | Internal format | | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Renderable | Filterable |
391 map.insert(InternalFormatInfoPair(GL_R8, RGBAFormat( 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, &Extensions::textureRG>, RequireESOrExt<3, &Extensions::textureRG>, AlwaysSupported)));
392 map.insert(InternalFormatInfoPair(GL_R8_SNORM, RGBAFormat( 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported)));
393 map.insert(InternalFormatInfoPair(GL_RG8, RGBAFormat( 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, &Extensions::textureRG>, RequireESOrExt<3, &Extensions::textureRG>, AlwaysSupported)));
394 map.insert(InternalFormatInfoPair(GL_RG8_SNORM, RGBAFormat( 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported)));
395 map.insert(InternalFormatInfoPair(GL_RGB8, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, &Extensions::rgb8rgba8>, RequireESOrExt<3, &Extensions::rgb8rgba8>, AlwaysSupported)));
396 map.insert(InternalFormatInfoPair(GL_RGB8_SNORM, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported)));
397 map.insert(InternalFormatInfoPair(GL_RGB565, RGBAFormat( 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, RequireES<2>, RequireES<2>, AlwaysSupported)));
398 map.insert(InternalFormatInfoPair(GL_RGBA4, RGBAFormat( 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, RequireES<2>, RequireES<2>, AlwaysSupported)));
399 map.insert(InternalFormatInfoPair(GL_RGB5_A1, RGBAFormat( 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, RequireES<2>, RequireES<2>, AlwaysSupported)));
400 map.insert(InternalFormatInfoPair(GL_RGBA8, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, &Extensions::rgb8rgba8>, RequireESOrExt<3, &Extensions::rgb8rgba8>, AlwaysSupported)));
401 map.insert(InternalFormatInfoPair(GL_RGBA8_SNORM, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported)));
402 map.insert(InternalFormatInfoPair(GL_RGB10_A2, RGBAFormat(10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireES<3>, RequireES<3>, AlwaysSupported)));
403 map.insert(InternalFormatInfoPair(GL_RGB10_A2UI, RGBAFormat(10, 10, 10, 2, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
404 map.insert(InternalFormatInfoPair(GL_SRGB8, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireESOrExt<3, &Extensions::sRGB>, NeverSupported, AlwaysSupported)));
405 map.insert(InternalFormatInfoPair(GL_SRGB8_ALPHA8, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireESOrExt<3, &Extensions::sRGB>, RequireESOrExt<3, &Extensions::sRGB>, AlwaysSupported)));
406 map.insert(InternalFormatInfoPair(GL_R11F_G11F_B10F, RGBAFormat(11, 11, 10, 0, 0, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_FLOAT, false, RequireES<3>, RequireExt<&Extensions::colorBufferFloat>, AlwaysSupported)));
407 map.insert(InternalFormatInfoPair(GL_RGB9_E5, RGBAFormat( 9, 9, 9, 0, 5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT, false, RequireES<3>, NeverSupported, AlwaysSupported)));
408 map.insert(InternalFormatInfoPair(GL_R8I, RGBAFormat( 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
409 map.insert(InternalFormatInfoPair(GL_R8UI, RGBAFormat( 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
410 map.insert(InternalFormatInfoPair(GL_R16I, RGBAFormat(16, 0, 0, 0, 0, GL_RED_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
411 map.insert(InternalFormatInfoPair(GL_R16UI, RGBAFormat(16, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
412 map.insert(InternalFormatInfoPair(GL_R32I, RGBAFormat(32, 0, 0, 0, 0, GL_RED_INTEGER, GL_INT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
413 map.insert(InternalFormatInfoPair(GL_R32UI, RGBAFormat(32, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
414 map.insert(InternalFormatInfoPair(GL_RG8I, RGBAFormat( 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
415 map.insert(InternalFormatInfoPair(GL_RG8UI, RGBAFormat( 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
416 map.insert(InternalFormatInfoPair(GL_RG16I, RGBAFormat(16, 16, 0, 0, 0, GL_RG_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
417 map.insert(InternalFormatInfoPair(GL_RG16UI, RGBAFormat(16, 16, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
418 map.insert(InternalFormatInfoPair(GL_RG32I, RGBAFormat(32, 32, 0, 0, 0, GL_RG_INTEGER, GL_INT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
419 map.insert(InternalFormatInfoPair(GL_RG32UI, RGBAFormat(32, 32, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
420 map.insert(InternalFormatInfoPair(GL_RGB8I, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
421 map.insert(InternalFormatInfoPair(GL_RGB8UI, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
422 map.insert(InternalFormatInfoPair(GL_RGB16I, RGBAFormat(16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
423 map.insert(InternalFormatInfoPair(GL_RGB16UI, RGBAFormat(16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
424 map.insert(InternalFormatInfoPair(GL_RGB32I, RGBAFormat(32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_INT, GL_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
425 map.insert(InternalFormatInfoPair(GL_RGB32UI, RGBAFormat(32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3>, NeverSupported, NeverSupported)));
426 map.insert(InternalFormatInfoPair(GL_RGBA8I, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
427 map.insert(InternalFormatInfoPair(GL_RGBA8UI, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
428 map.insert(InternalFormatInfoPair(GL_RGBA16I, RGBAFormat(16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
429 map.insert(InternalFormatInfoPair(GL_RGBA16UI, RGBAFormat(16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
430 map.insert(InternalFormatInfoPair(GL_RGBA32I, RGBAFormat(32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
431 map.insert(InternalFormatInfoPair(GL_RGBA32UI, RGBAFormat(32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3>, RequireES<3>, NeverSupported)));
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000432
Geoff Langabce7622014-09-19 16:13:00 -0400433 map.insert(InternalFormatInfoPair(GL_BGRA8_EXT, RGBAFormat( 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported)));
434 map.insert(InternalFormatInfoPair(GL_BGRA4_ANGLEX, RGBAFormat( 4, 4, 4, 4, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported)));
435 map.insert(InternalFormatInfoPair(GL_BGR5_A1_ANGLEX, RGBAFormat( 5, 5, 5, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported)));
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000436
437 // Floating point renderability and filtering is provided by OES_texture_float and OES_texture_half_float
Geoff Langabce7622014-09-19 16:13:00 -0400438 // | Internal format | | D |S | Format | Type | Comp | SRGB | Texture supported | Renderable | Filterable |
439 // | | | | | | | type | | | | |
440 map.insert(InternalFormatInfoPair(GL_R16F, RGBAFormat(16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT, GL_FLOAT, false, RequireESOrExtAndExt<3, &Extensions::textureHalfFloat, &Extensions::textureRG>, RequireESOrExtAndExt<3, &Extensions::textureHalfFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureHalfFloatLinear>)));
441 map.insert(InternalFormatInfoPair(GL_RG16F, RGBAFormat(16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT, GL_FLOAT, false, RequireESOrExtAndExt<3, &Extensions::textureHalfFloat, &Extensions::textureRG>, RequireESOrExtAndExt<3, &Extensions::textureHalfFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureHalfFloatLinear>)));
442 map.insert(InternalFormatInfoPair(GL_RGB16F, RGBAFormat(16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT, GL_FLOAT, false, RequireESOrExt<3, &Extensions::textureHalfFloat>, RequireESOrExt<3, &Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>)));
443 map.insert(InternalFormatInfoPair(GL_RGBA16F, RGBAFormat(16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT, GL_FLOAT, false, RequireESOrExt<3, &Extensions::textureHalfFloat>, RequireESOrExt<3, &Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>)));
444 map.insert(InternalFormatInfoPair(GL_R32F, RGBAFormat(32, 0, 0, 0, 0, GL_RED, GL_FLOAT, GL_FLOAT, false, RequireESOrExtAndExt<3, &Extensions::textureFloat, &Extensions::textureRG>, RequireESOrExtAndExt<3, &Extensions::textureFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureFloatLinear> )));
445 map.insert(InternalFormatInfoPair(GL_RG32F, RGBAFormat(32, 32, 0, 0, 0, GL_RG, GL_FLOAT, GL_FLOAT, false, RequireESOrExtAndExt<3, &Extensions::textureFloat, &Extensions::textureRG>, RequireESOrExtAndExt<3, &Extensions::textureFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureFloatLinear> )));
446 map.insert(InternalFormatInfoPair(GL_RGB32F, RGBAFormat(32, 32, 32, 0, 0, GL_RGB, GL_FLOAT, GL_FLOAT, false, RequireESOrExt<3, &Extensions::textureFloat>, RequireESOrExt<3, &Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear> )));
447 map.insert(InternalFormatInfoPair(GL_RGBA32F, RGBAFormat(32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT, GL_FLOAT, false, RequireESOrExt<3, &Extensions::textureFloat>, RequireESOrExt<3, &Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear> )));
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000448
449 // Depth stencil formats
Geoff Langabce7622014-09-19 16:13:00 -0400450 // | Internal format | | D |S | X | Format | Type | Component type | Supported | Renderable | Filterable |
451 map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT16, DepthStencilFormat(16, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, RequireES<2>, RequireES<2>, RequireESOrExt<3, &Extensions::depthTextures>)));
452 map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT24, DepthStencilFormat(24, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireES<3>, RequireES<3>, RequireESOrExt<3, &Extensions::depthTextures>)));
453 map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32F, DepthStencilFormat(32, 0, 0, GL_DEPTH_COMPONENT, GL_FLOAT, GL_FLOAT, RequireES<3>, RequireES<3>, RequireESOrExt<3, &Extensions::depthTextures>)));
454 map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32_OES, DepthStencilFormat(32, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::depthTextures>, RequireExt<&Extensions::depthTextures>, AlwaysSupported )));
455 map.insert(InternalFormatInfoPair(GL_DEPTH24_STENCIL8, DepthStencilFormat(24, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_UNSIGNED_NORMALIZED, RequireESOrExt<3, &Extensions::depthTextures>, RequireESOrExtOrExt<3, &Extensions::depthTextures, &Extensions::packedDepthStencil>, AlwaysSupported )));
456 map.insert(InternalFormatInfoPair(GL_DEPTH32F_STENCIL8, DepthStencilFormat(32, 8, 24, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_FLOAT, RequireES<3>, RequireES<3>, AlwaysSupported )));
457 map.insert(InternalFormatInfoPair(GL_STENCIL_INDEX8, DepthStencilFormat( 0, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, RequireES<2>, RequireES<2>, NeverSupported )));
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000458
459 // Luminance alpha formats
Geoff Lang5d601382014-07-22 15:14:06 -0400460 // | Internal format | | L | A | Format | Type | Component type | Supported | Renderable | Filterable |
Geoff Langabce7622014-09-19 16:13:00 -0400461 map.insert(InternalFormatInfoPair(GL_ALPHA8_EXT, LUMAFormat( 0, 8, GL_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, NeverSupported, AlwaysSupported)));
462 map.insert(InternalFormatInfoPair(GL_LUMINANCE8_EXT, LUMAFormat( 8, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, NeverSupported, AlwaysSupported)));
463 map.insert(InternalFormatInfoPair(GL_ALPHA32F_EXT, LUMAFormat( 0, 32, GL_ALPHA, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, NeverSupported, AlwaysSupported)));
464 map.insert(InternalFormatInfoPair(GL_LUMINANCE32F_EXT, LUMAFormat(32, 0, GL_LUMINANCE, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, NeverSupported, AlwaysSupported)));
465 map.insert(InternalFormatInfoPair(GL_ALPHA16F_EXT, LUMAFormat( 0, 16, GL_ALPHA, GL_HALF_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, NeverSupported, AlwaysSupported)));
466 map.insert(InternalFormatInfoPair(GL_LUMINANCE16F_EXT, LUMAFormat(16, 0, GL_LUMINANCE, GL_HALF_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, NeverSupported, AlwaysSupported)));
467 map.insert(InternalFormatInfoPair(GL_LUMINANCE8_ALPHA8_EXT, LUMAFormat( 8, 8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, NeverSupported, AlwaysSupported)));
468 map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA32F_EXT, LUMAFormat(32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, NeverSupported, AlwaysSupported)));
469 map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA16F_EXT, LUMAFormat(16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, NeverSupported, AlwaysSupported)));
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000470
471 // Unsized formats
Geoff Langabce7622014-09-19 16:13:00 -0400472 // | Internal format | | Format | Supported | Renderable | Filterable |
473 map.insert(InternalFormatInfoPair(GL_ALPHA, UnsizedFormat(GL_ALPHA, RequireES<2>, NeverSupported, AlwaysSupported)));
474 map.insert(InternalFormatInfoPair(GL_LUMINANCE, UnsizedFormat(GL_LUMINANCE, RequireES<2>, NeverSupported, AlwaysSupported)));
475 map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA, UnsizedFormat(GL_LUMINANCE_ALPHA, RequireES<2>, NeverSupported, AlwaysSupported)));
476 map.insert(InternalFormatInfoPair(GL_RED, UnsizedFormat(GL_RED, RequireESOrExt<3, &Extensions::textureRG>, NeverSupported, AlwaysSupported)));
477 map.insert(InternalFormatInfoPair(GL_RG, UnsizedFormat(GL_RG, RequireESOrExt<3, &Extensions::textureRG>, NeverSupported, AlwaysSupported)));
478 map.insert(InternalFormatInfoPair(GL_RGB, UnsizedFormat(GL_RGB, RequireES<2>, RequireES<2>, AlwaysSupported)));
479 map.insert(InternalFormatInfoPair(GL_RGBA, UnsizedFormat(GL_RGBA, RequireES<2>, RequireES<2>, AlwaysSupported)));
480 map.insert(InternalFormatInfoPair(GL_RED_INTEGER, UnsizedFormat(GL_RED_INTEGER, RequireES<3>, NeverSupported, NeverSupported )));
481 map.insert(InternalFormatInfoPair(GL_RG_INTEGER, UnsizedFormat(GL_RG_INTEGER, RequireES<3>, NeverSupported, NeverSupported )));
482 map.insert(InternalFormatInfoPair(GL_RGB_INTEGER, UnsizedFormat(GL_RGB_INTEGER, RequireES<3>, NeverSupported, NeverSupported )));
483 map.insert(InternalFormatInfoPair(GL_RGBA_INTEGER, UnsizedFormat(GL_RGBA_INTEGER, RequireES<3>, NeverSupported, NeverSupported )));
484 map.insert(InternalFormatInfoPair(GL_BGRA_EXT, UnsizedFormat(GL_BGRA_EXT, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported)));
485 map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT, UnsizedFormat(GL_DEPTH_COMPONENT, RequireES<2>, RequireES<2>, AlwaysSupported)));
486 map.insert(InternalFormatInfoPair(GL_DEPTH_STENCIL, UnsizedFormat(GL_DEPTH_STENCIL, RequireESOrExt<3, &Extensions::packedDepthStencil>, RequireESOrExt<3, &Extensions::packedDepthStencil>, AlwaysSupported)));
487 map.insert(InternalFormatInfoPair(GL_SRGB_EXT, UnsizedFormat(GL_RGB, RequireESOrExt<3, &Extensions::sRGB>, NeverSupported, AlwaysSupported)));
488 map.insert(InternalFormatInfoPair(GL_SRGB_ALPHA_EXT, UnsizedFormat(GL_RGBA, RequireESOrExt<3, &Extensions::sRGB>, RequireESOrExt<3, &Extensions::sRGB>, AlwaysSupported)));
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000489
490 // Compressed formats, From ES 3.0.1 spec, table 3.16
Geoff Lang5d601382014-07-22 15:14:06 -0400491 // | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable |
492 map.insert(InternalFormatInfoPair(GL_COMPRESSED_R11_EAC, CompressedFormat(4, 4, 64, 1, GL_COMPRESSED_R11_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
493 map.insert(InternalFormatInfoPair(GL_COMPRESSED_SIGNED_R11_EAC, CompressedFormat(4, 4, 64, 1, GL_COMPRESSED_SIGNED_R11_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
494 map.insert(InternalFormatInfoPair(GL_COMPRESSED_RG11_EAC, CompressedFormat(4, 4, 128, 2, GL_COMPRESSED_RG11_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
495 map.insert(InternalFormatInfoPair(GL_COMPRESSED_SIGNED_RG11_EAC, CompressedFormat(4, 4, 128, 2, GL_COMPRESSED_SIGNED_RG11_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
496 map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB8_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB8_ETC2, GL_UNSIGNED_BYTE, false, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
497 map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_SRGB8_ETC2, GL_UNSIGNED_BYTE, true, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
498 map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, false, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
499 map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, true, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
500 map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA8_ETC2_EAC, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, GL_UNSIGNED_BYTE, false, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
501 map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_UNSIGNED_BYTE, true, UnimplementedSupport, UnimplementedSupport, UnimplementedSupport)));
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000502
503 // From GL_EXT_texture_compression_dxt1
Geoff Langabce7622014-09-19 16:13:00 -0400504 // | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable |
505 map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT1>, NeverSupported, AlwaysSupported)));
506 map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, CompressedFormat(4, 4, 64, 4, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT1>, NeverSupported, AlwaysSupported)));
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000507
508 // From GL_ANGLE_texture_compression_dxt3
Geoff Langabce7622014-09-19 16:13:00 -0400509 map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT5>, NeverSupported, AlwaysSupported)));
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000510
511 // From GL_ANGLE_texture_compression_dxt5
Geoff Langabce7622014-09-19 16:13:00 -0400512 map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT5>, NeverSupported, AlwaysSupported)));
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000513
514 return map;
515}
516
Geoff Lange4a492b2014-06-19 14:14:41 -0400517static const InternalFormatInfoMap &GetInternalFormatMap()
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000518{
Geoff Lange4a492b2014-06-19 14:14:41 -0400519 static const InternalFormatInfoMap formatMap = BuildInternalFormatInfoMap();
520 return formatMap;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000521}
522
Geoff Lange4a492b2014-06-19 14:14:41 -0400523static FormatSet BuildAllSizedInternalFormatSet()
Geoff Langcec35902014-04-16 10:52:36 -0400524{
525 FormatSet result;
526
Geoff Lange4a492b2014-06-19 14:14:41 -0400527 const InternalFormatInfoMap &formats = GetInternalFormatMap();
Geoff Langcec35902014-04-16 10:52:36 -0400528 for (InternalFormatInfoMap::const_iterator i = formats.begin(); i != formats.end(); i++)
529 {
Geoff Lang5d601382014-07-22 15:14:06 -0400530 if (i->second.pixelBytes > 0)
Geoff Langcec35902014-04-16 10:52:36 -0400531 {
532 result.insert(i->first);
533 }
534 }
535
536 return result;
537}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000538
Geoff Lang5d601382014-07-22 15:14:06 -0400539const FormatType &GetFormatTypeInfo(GLenum format, GLenum type)
Shannon Woods4d161ba2014-03-17 18:13:30 -0400540{
Geoff Lang5d601382014-07-22 15:14:06 -0400541 static const FormatMap formatMap = BuildFormatMap();
542 FormatMap::const_iterator iter = formatMap.find(FormatTypePair(format, type));
543 if (iter != formatMap.end())
Shannon Woods4d161ba2014-03-17 18:13:30 -0400544 {
Geoff Lang5d601382014-07-22 15:14:06 -0400545 return iter->second;
Shannon Woods4d161ba2014-03-17 18:13:30 -0400546 }
547 else
548 {
Geoff Lang5d601382014-07-22 15:14:06 -0400549 static const FormatType defaultInfo;
550 return defaultInfo;
Shannon Woods4d161ba2014-03-17 18:13:30 -0400551 }
Shannon Woods4d161ba2014-03-17 18:13:30 -0400552}
553
Geoff Lang5d601382014-07-22 15:14:06 -0400554const Type &GetTypeInfo(GLenum type)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000555{
Geoff Lang5d601382014-07-22 15:14:06 -0400556 static const TypeInfoMap infoMap = BuildTypeInfoMap();
557 TypeInfoMap::const_iterator iter = infoMap.find(type);
558 if (iter != infoMap.end())
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000559 {
Geoff Lang5d601382014-07-22 15:14:06 -0400560 return iter->second;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000561 }
562 else
563 {
Geoff Lang5d601382014-07-22 15:14:06 -0400564 static const Type defaultInfo;
565 return defaultInfo;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000566 }
567}
568
Geoff Lang5d601382014-07-22 15:14:06 -0400569const InternalFormat &GetInternalFormatInfo(GLenum internalFormat)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000570{
Geoff Lang5d601382014-07-22 15:14:06 -0400571 const InternalFormatInfoMap &formatMap = GetInternalFormatMap();
572 InternalFormatInfoMap::const_iterator iter = formatMap.find(internalFormat);
573 if (iter != formatMap.end())
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000574 {
Geoff Lang5d601382014-07-22 15:14:06 -0400575 return iter->second;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000576 }
577 else
578 {
Geoff Lang5d601382014-07-22 15:14:06 -0400579 static const InternalFormat defaultInternalFormat;
580 return defaultInternalFormat;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000581 }
582}
583
Geoff Lang5d601382014-07-22 15:14:06 -0400584GLuint InternalFormat::computeRowPitch(GLenum type, GLsizei width, GLint alignment) const
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000585{
586 ASSERT(alignment > 0 && isPow2(alignment));
Geoff Lang5d601382014-07-22 15:14:06 -0400587 return rx::roundUp(computeBlockSize(type, width, 1), static_cast<GLuint>(alignment));
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000588}
589
Geoff Lang5d601382014-07-22 15:14:06 -0400590GLuint InternalFormat::computeDepthPitch(GLenum type, GLsizei width, GLsizei height, GLint alignment) const
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000591{
Geoff Lang5d601382014-07-22 15:14:06 -0400592 return computeRowPitch(type, width, alignment) * height;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000593}
594
Geoff Lang5d601382014-07-22 15:14:06 -0400595GLuint InternalFormat::computeBlockSize(GLenum type, GLsizei width, GLsizei height) const
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000596{
Geoff Lang5d601382014-07-22 15:14:06 -0400597 if (compressed)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000598 {
Geoff Lang5d601382014-07-22 15:14:06 -0400599 GLsizei numBlocksWide = (width + compressedBlockWidth - 1) / compressedBlockWidth;
600 GLsizei numBlocksHight = (height + compressedBlockHeight - 1) / compressedBlockHeight;
601 return (pixelBytes * numBlocksWide * numBlocksHight);
602 }
603 else
604 {
605 const Type &typeInfo = GetTypeInfo(type);
606 if (typeInfo.specialInterpretation)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000607 {
Geoff Lang5d601382014-07-22 15:14:06 -0400608 return typeInfo.bytes * width * height;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000609 }
610 else
611 {
Geoff Lang5d601382014-07-22 15:14:06 -0400612 return componentCount * typeInfo.bytes * width * height;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000613 }
614 }
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000615}
616
Geoff Lang5d601382014-07-22 15:14:06 -0400617GLenum GetSizedInternalFormat(GLenum internalFormat, GLenum type)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000618{
Geoff Lang5d601382014-07-22 15:14:06 -0400619 const InternalFormat& formatInfo = GetInternalFormatInfo(internalFormat);
620 return (formatInfo.pixelBytes > 0) ? internalFormat : GetFormatTypeInfo(internalFormat, type).internalFormat;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000621}
622
Geoff Lange4a492b2014-06-19 14:14:41 -0400623const FormatSet &GetAllSizedInternalFormats()
Geoff Langcec35902014-04-16 10:52:36 -0400624{
Geoff Lange4a492b2014-06-19 14:14:41 -0400625 static FormatSet formatSet = BuildAllSizedInternalFormatSet();
Geoff Langcec35902014-04-16 10:52:36 -0400626 return formatSet;
627}
628
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000629}