shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1 | // |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 2 | // Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved. |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 3 | // 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 Woods | 4d161ba | 2014-03-17 18:13:30 -0400 | [diff] [blame] | 9 | #include "common/mathutil.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 10 | #include "libANGLE/formatutils.h" |
| 11 | #include "libANGLE/Context.h" |
| 12 | #include "libANGLE/Framebuffer.h" |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 13 | |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 14 | using namespace angle; |
| 15 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 16 | namespace gl |
| 17 | { |
| 18 | |
| 19 | // ES2 requires that format is equal to internal format at all glTex*Image2D entry points and the implementation |
| 20 | // can decide the true, sized, internal format. The ES2FormatMap determines the internal format for all valid |
| 21 | // format and type combinations. |
| 22 | |
Jamie Madill | d2b50a0 | 2016-06-09 00:13:35 -0700 | [diff] [blame] | 23 | typedef std::pair<FormatType, GLenum> FormatPair; |
| 24 | typedef std::map<FormatType, GLenum> FormatMap; |
| 25 | |
| 26 | FormatType::FormatType() : format(GL_NONE), type(GL_NONE) |
| 27 | { |
| 28 | } |
| 29 | |
| 30 | FormatType::FormatType(GLenum format_, GLenum type_) : format(format_), type(type_) |
| 31 | { |
| 32 | } |
| 33 | |
| 34 | bool FormatType::operator<(const FormatType &other) const |
| 35 | { |
| 36 | if (format != other.format) |
| 37 | return format < other.format; |
| 38 | return type < other.type; |
| 39 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 40 | |
Jamie Madill | 89a0bf5 | 2013-09-18 14:36:24 -0400 | [diff] [blame] | 41 | // A helper function to insert data into the format map with fewer characters. |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 42 | static inline void InsertFormatMapping(FormatMap *map, GLenum format, GLenum type, GLenum internalFormat) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 43 | { |
Jamie Madill | d2b50a0 | 2016-06-09 00:13:35 -0700 | [diff] [blame] | 44 | map->insert(FormatPair(FormatType(format, type), internalFormat)); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 45 | } |
| 46 | |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 47 | FormatMap BuildFormatMap() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 48 | { |
| 49 | FormatMap map; |
| 50 | |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 51 | // | Format | Type | Internal format | |
| 52 | InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_BYTE, GL_RGBA8); |
| 53 | InsertFormatMapping(&map, GL_RGBA, GL_BYTE, GL_RGBA8_SNORM); |
| 54 | InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_RGBA4); |
| 55 | InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_RGB5_A1); |
| 56 | InsertFormatMapping(&map, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_RGB10_A2); |
| 57 | InsertFormatMapping(&map, GL_RGBA, GL_FLOAT, GL_RGBA32F); |
| 58 | InsertFormatMapping(&map, GL_RGBA, GL_HALF_FLOAT, GL_RGBA16F); |
| 59 | InsertFormatMapping(&map, GL_RGBA, GL_HALF_FLOAT_OES, GL_RGBA16F); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 60 | |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 61 | InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_RGBA8UI); |
| 62 | InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_BYTE, GL_RGBA8I); |
| 63 | InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_RGBA16UI); |
| 64 | InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_SHORT, GL_RGBA16I); |
| 65 | InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_RGBA32UI); |
| 66 | InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_INT, GL_RGBA32I); |
| 67 | InsertFormatMapping(&map, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_RGB10_A2UI); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 68 | |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 69 | InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_BYTE, GL_RGB8); |
| 70 | InsertFormatMapping(&map, GL_RGB, GL_BYTE, GL_RGB8_SNORM); |
| 71 | InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_RGB565); |
| 72 | InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_R11F_G11F_B10F); |
| 73 | InsertFormatMapping(&map, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_RGB9_E5); |
| 74 | InsertFormatMapping(&map, GL_RGB, GL_FLOAT, GL_RGB32F); |
| 75 | InsertFormatMapping(&map, GL_RGB, GL_HALF_FLOAT, GL_RGB16F); |
| 76 | InsertFormatMapping(&map, GL_RGB, GL_HALF_FLOAT_OES, GL_RGB16F); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 77 | |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 78 | InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_RGB8UI); |
| 79 | InsertFormatMapping(&map, GL_RGB_INTEGER, GL_BYTE, GL_RGB8I); |
| 80 | InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_RGB16UI); |
| 81 | InsertFormatMapping(&map, GL_RGB_INTEGER, GL_SHORT, GL_RGB16I); |
| 82 | InsertFormatMapping(&map, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_RGB32UI); |
| 83 | InsertFormatMapping(&map, GL_RGB_INTEGER, GL_INT, GL_RGB32I); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 84 | |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 85 | InsertFormatMapping(&map, GL_RG, GL_UNSIGNED_BYTE, GL_RG8); |
| 86 | InsertFormatMapping(&map, GL_RG, GL_BYTE, GL_RG8_SNORM); |
| 87 | InsertFormatMapping(&map, GL_RG, GL_FLOAT, GL_RG32F); |
| 88 | InsertFormatMapping(&map, GL_RG, GL_HALF_FLOAT, GL_RG16F); |
| 89 | InsertFormatMapping(&map, GL_RG, GL_HALF_FLOAT_OES, GL_RG16F); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 90 | |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 91 | InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_RG8UI); |
| 92 | InsertFormatMapping(&map, GL_RG_INTEGER, GL_BYTE, GL_RG8I); |
| 93 | InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_RG16UI); |
| 94 | InsertFormatMapping(&map, GL_RG_INTEGER, GL_SHORT, GL_RG16I); |
| 95 | InsertFormatMapping(&map, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_RG32UI); |
| 96 | InsertFormatMapping(&map, GL_RG_INTEGER, GL_INT, GL_RG32I); |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 97 | |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 98 | InsertFormatMapping(&map, GL_RED, GL_UNSIGNED_BYTE, GL_R8); |
| 99 | InsertFormatMapping(&map, GL_RED, GL_BYTE, GL_R8_SNORM); |
| 100 | InsertFormatMapping(&map, GL_RED, GL_FLOAT, GL_R32F); |
| 101 | InsertFormatMapping(&map, GL_RED, GL_HALF_FLOAT, GL_R16F); |
| 102 | InsertFormatMapping(&map, GL_RED, GL_HALF_FLOAT_OES, GL_R16F); |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 103 | |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 104 | InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_R8UI); |
| 105 | InsertFormatMapping(&map, GL_RED_INTEGER, GL_BYTE, GL_R8I); |
| 106 | InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_R16UI); |
| 107 | InsertFormatMapping(&map, GL_RED_INTEGER, GL_SHORT, GL_R16I); |
| 108 | InsertFormatMapping(&map, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_R32UI); |
| 109 | InsertFormatMapping(&map, GL_RED_INTEGER, GL_INT, GL_R32I); |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 110 | |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 111 | InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_LUMINANCE8_ALPHA8_EXT); |
| 112 | InsertFormatMapping(&map, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_LUMINANCE8_EXT); |
| 113 | InsertFormatMapping(&map, GL_ALPHA, GL_UNSIGNED_BYTE, GL_ALPHA8_EXT); |
| 114 | InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_LUMINANCE_ALPHA32F_EXT); |
| 115 | InsertFormatMapping(&map, GL_LUMINANCE, GL_FLOAT, GL_LUMINANCE32F_EXT); |
| 116 | InsertFormatMapping(&map, GL_ALPHA, GL_FLOAT, GL_ALPHA32F_EXT); |
| 117 | InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, GL_LUMINANCE_ALPHA16F_EXT); |
| 118 | InsertFormatMapping(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_LUMINANCE_ALPHA16F_EXT); |
| 119 | InsertFormatMapping(&map, GL_LUMINANCE, GL_HALF_FLOAT, GL_LUMINANCE16F_EXT); |
| 120 | InsertFormatMapping(&map, GL_LUMINANCE, GL_HALF_FLOAT_OES, GL_LUMINANCE16F_EXT); |
| 121 | InsertFormatMapping(&map, GL_ALPHA, GL_HALF_FLOAT, GL_ALPHA16F_EXT); |
| 122 | InsertFormatMapping(&map, GL_ALPHA, GL_HALF_FLOAT_OES, GL_ALPHA16F_EXT); |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 123 | |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 124 | InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_BGRA8_EXT); |
| 125 | InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, GL_BGRA4_ANGLEX); |
| 126 | InsertFormatMapping(&map, GL_BGRA_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, GL_BGR5_A1_ANGLEX); |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 127 | |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 128 | InsertFormatMapping(&map, GL_SRGB_EXT, GL_UNSIGNED_BYTE, GL_SRGB8); |
| 129 | InsertFormatMapping(&map, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, GL_SRGB8_ALPHA8); |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 130 | |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 131 | InsertFormatMapping(&map, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGB_S3TC_DXT1_EXT); |
| 132 | InsertFormatMapping(&map, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT); |
| 133 | InsertFormatMapping(&map, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE); |
| 134 | InsertFormatMapping(&map, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE); |
Geoff Lang | 05b0502 | 2014-06-11 15:31:45 -0400 | [diff] [blame] | 135 | |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 136 | InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_DEPTH_COMPONENT16); |
| 137 | InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_DEPTH_COMPONENT32_OES); |
| 138 | InsertFormatMapping(&map, GL_DEPTH_COMPONENT, GL_FLOAT, GL_DEPTH_COMPONENT32F); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 139 | |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 140 | InsertFormatMapping(&map, GL_STENCIL, GL_UNSIGNED_BYTE, GL_STENCIL_INDEX8); |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 141 | |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 142 | InsertFormatMapping(&map, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_DEPTH24_STENCIL8); |
| 143 | InsertFormatMapping(&map, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_DEPTH32F_STENCIL8); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 144 | |
| 145 | return map; |
| 146 | } |
| 147 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 148 | Type::Type() |
| 149 | : bytes(0), |
Olli Etuaho | 11ffe1b | 2015-03-24 17:28:18 +0200 | [diff] [blame] | 150 | bytesShift(0), |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 151 | specialInterpretation(false) |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 152 | { |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 153 | } |
| 154 | |
Olli Etuaho | 31f8f4f | 2015-03-25 16:03:57 +0200 | [diff] [blame] | 155 | static Type GenTypeInfo(GLuint bytes, bool specialInterpretation) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 156 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 157 | Type info; |
| 158 | info.bytes = bytes; |
Olli Etuaho | 11ffe1b | 2015-03-24 17:28:18 +0200 | [diff] [blame] | 159 | GLuint i = 0; |
| 160 | while ((1u << i) < bytes) |
| 161 | { |
| 162 | ++i; |
| 163 | } |
| 164 | info.bytesShift = i; |
| 165 | ASSERT((1u << info.bytesShift) == bytes); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 166 | info.specialInterpretation = specialInterpretation; |
Olli Etuaho | 31f8f4f | 2015-03-25 16:03:57 +0200 | [diff] [blame] | 167 | return info; |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 168 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 169 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 170 | bool operator<(const Type& a, const Type& b) |
| 171 | { |
| 172 | return memcmp(&a, &b, sizeof(Type)) < 0; |
| 173 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 174 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 175 | // Information about internal formats |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 176 | static bool AlwaysSupported(GLuint, const Extensions &) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 177 | { |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 178 | return true; |
| 179 | } |
| 180 | |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 181 | static bool NeverSupported(GLuint, const Extensions &) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 182 | { |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 183 | return false; |
| 184 | } |
| 185 | |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 186 | template <GLuint minCoreGLVersion> |
Geoff Lang | abce762 | 2014-09-19 16:13:00 -0400 | [diff] [blame] | 187 | static bool RequireES(GLuint clientVersion, const Extensions &) |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 188 | { |
| 189 | return clientVersion >= minCoreGLVersion; |
| 190 | } |
| 191 | |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 192 | // Pointer to a boolean memeber of the Extensions struct |
| 193 | typedef bool(Extensions::*ExtensionBool); |
| 194 | |
| 195 | // Check support for a single extension |
| 196 | template <ExtensionBool bool1> |
Geoff Lang | abce762 | 2014-09-19 16:13:00 -0400 | [diff] [blame] | 197 | static bool RequireExt(GLuint, const Extensions & extensions) |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 198 | { |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 199 | return extensions.*bool1; |
| 200 | } |
| 201 | |
| 202 | // Check for a minimum client version or a single extension |
| 203 | template <GLuint minCoreGLVersion, ExtensionBool bool1> |
Geoff Lang | abce762 | 2014-09-19 16:13:00 -0400 | [diff] [blame] | 204 | static bool RequireESOrExt(GLuint clientVersion, const Extensions &extensions) |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 205 | { |
| 206 | return clientVersion >= minCoreGLVersion || extensions.*bool1; |
| 207 | } |
| 208 | |
| 209 | // Check for a minimum client version or two extensions |
| 210 | template <GLuint minCoreGLVersion, ExtensionBool bool1, ExtensionBool bool2> |
Geoff Lang | abce762 | 2014-09-19 16:13:00 -0400 | [diff] [blame] | 211 | static bool RequireESOrExtAndExt(GLuint clientVersion, const Extensions &extensions) |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 212 | { |
Geoff Lang | abce762 | 2014-09-19 16:13:00 -0400 | [diff] [blame] | 213 | return clientVersion >= minCoreGLVersion || (extensions.*bool1 && extensions.*bool2); |
| 214 | } |
| 215 | |
| 216 | // Check for a minimum client version or at least one of two extensions |
| 217 | template <GLuint minCoreGLVersion, ExtensionBool bool1, ExtensionBool bool2> |
| 218 | static bool RequireESOrExtOrExt(GLuint clientVersion, const Extensions &extensions) |
| 219 | { |
| 220 | return clientVersion >= minCoreGLVersion || extensions.*bool1 || extensions.*bool2; |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | // Check support for two extensions |
| 224 | template <ExtensionBool bool1, ExtensionBool bool2> |
Geoff Lang | abce762 | 2014-09-19 16:13:00 -0400 | [diff] [blame] | 225 | static bool RequireExtAndExt(GLuint, const Extensions &extensions) |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 226 | { |
Geoff Lang | abce762 | 2014-09-19 16:13:00 -0400 | [diff] [blame] | 227 | return extensions.*bool1 && extensions.*bool2; |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 228 | } |
| 229 | |
Geoff Lang | 60ad73d | 2015-10-23 10:08:44 -0400 | [diff] [blame] | 230 | // Check support for either of two extensions |
| 231 | template <ExtensionBool bool1, ExtensionBool bool2> |
| 232 | static bool RequireExtOrExt(GLuint, const Extensions &extensions) |
| 233 | { |
| 234 | return extensions.*bool1 || extensions.*bool2; |
| 235 | } |
| 236 | |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 237 | // Special function for half float formats with three or four channels. |
| 238 | static bool HalfFloatSupport(GLuint clientVersion, const Extensions &extensions) |
| 239 | { |
| 240 | return clientVersion >= 3 || extensions.textureHalfFloat; |
| 241 | } |
| 242 | |
| 243 | static bool HalfFloatRenderableSupport(GLuint clientVersion, const Extensions &extensions) |
| 244 | { |
| 245 | return HalfFloatSupport(clientVersion, extensions) && extensions.colorBufferHalfFloat; |
| 246 | } |
| 247 | |
| 248 | // Special function for half float formats with one or two channels. |
| 249 | static bool HalfFloatSupportRG(GLuint clientVersion, const Extensions &extensions) |
| 250 | { |
| 251 | return clientVersion >= 3 || (extensions.textureHalfFloat && extensions.textureRG); |
| 252 | } |
| 253 | |
| 254 | static bool HalfFloatRenderableSupportRG(GLuint clientVersion, const Extensions &extensions) |
| 255 | { |
| 256 | return HalfFloatSupportRG(clientVersion, extensions) && extensions.colorBufferHalfFloat; |
| 257 | } |
| 258 | |
| 259 | // Special function for float formats with three or four channels. |
| 260 | static bool FloatSupport(GLuint clientVersion, const Extensions &extensions) |
| 261 | { |
| 262 | return clientVersion >= 3 || extensions.textureFloat; |
| 263 | } |
| 264 | |
| 265 | static bool FloatRenderableSupport(GLuint clientVersion, const Extensions &extensions) |
| 266 | { |
| 267 | // We don't expose colorBufferFloat in ES2, but we silently support rendering to float. |
| 268 | return FloatSupport(clientVersion, extensions) && |
| 269 | (extensions.colorBufferFloat || clientVersion == 2); |
| 270 | } |
| 271 | |
| 272 | // Special function for float formats with one or two channels. |
| 273 | static bool FloatSupportRG(GLuint clientVersion, const Extensions &extensions) |
| 274 | { |
| 275 | return clientVersion >= 3 || (extensions.textureFloat && extensions.textureRG); |
| 276 | } |
| 277 | |
| 278 | static bool FloatRenderableSupportRG(GLuint clientVersion, const Extensions &extensions) |
| 279 | { |
| 280 | // We don't expose colorBufferFloat in ES2, but we silently support rendering to float. |
| 281 | return FloatSupportRG(clientVersion, extensions) && |
| 282 | (extensions.colorBufferFloat || clientVersion == 2); |
| 283 | } |
| 284 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 285 | InternalFormat::InternalFormat() |
| 286 | : redBits(0), |
| 287 | greenBits(0), |
| 288 | blueBits(0), |
| 289 | luminanceBits(0), |
| 290 | alphaBits(0), |
| 291 | sharedBits(0), |
| 292 | depthBits(0), |
| 293 | stencilBits(0), |
| 294 | pixelBytes(0), |
| 295 | componentCount(0), |
Corentin Wallez | bc99bb6 | 2015-05-14 17:42:20 -0400 | [diff] [blame] | 296 | compressed(false), |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 297 | compressedBlockWidth(0), |
| 298 | compressedBlockHeight(0), |
| 299 | format(GL_NONE), |
| 300 | type(GL_NONE), |
| 301 | componentType(GL_NONE), |
| 302 | colorEncoding(GL_NONE), |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 303 | textureSupport(NeverSupported), |
| 304 | renderSupport(NeverSupported), |
| 305 | filterSupport(NeverSupported) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 306 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 307 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 308 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 309 | static InternalFormat UnsizedFormat(GLenum format, InternalFormat::SupportCheckFunction textureSupport, |
| 310 | InternalFormat::SupportCheckFunction renderSupport, |
| 311 | InternalFormat::SupportCheckFunction filterSupport) |
| 312 | { |
| 313 | InternalFormat formatInfo; |
| 314 | formatInfo.format = format; |
| 315 | formatInfo.textureSupport = textureSupport; |
| 316 | formatInfo.renderSupport = renderSupport; |
| 317 | formatInfo.filterSupport = filterSupport; |
| 318 | return formatInfo; |
| 319 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 320 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 321 | static InternalFormat RGBAFormat(GLuint red, GLuint green, GLuint blue, GLuint alpha, GLuint shared, |
| 322 | GLenum format, GLenum type, GLenum componentType, bool srgb, |
| 323 | InternalFormat::SupportCheckFunction textureSupport, |
| 324 | InternalFormat::SupportCheckFunction renderSupport, |
| 325 | InternalFormat::SupportCheckFunction filterSupport) |
| 326 | { |
| 327 | InternalFormat formatInfo; |
| 328 | formatInfo.redBits = red; |
| 329 | formatInfo.greenBits = green; |
| 330 | formatInfo.blueBits = blue; |
| 331 | formatInfo.alphaBits = alpha; |
| 332 | formatInfo.sharedBits = shared; |
| 333 | formatInfo.pixelBytes = (red + green + blue + alpha + shared) / 8; |
| 334 | formatInfo.componentCount = ((red > 0) ? 1 : 0) + ((green > 0) ? 1 : 0) + ((blue > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0); |
| 335 | formatInfo.format = format; |
| 336 | formatInfo.type = type; |
| 337 | formatInfo.componentType = componentType; |
| 338 | formatInfo.colorEncoding = (srgb ? GL_SRGB : GL_LINEAR); |
| 339 | formatInfo.textureSupport = textureSupport; |
| 340 | formatInfo.renderSupport = renderSupport; |
| 341 | formatInfo.filterSupport = filterSupport; |
| 342 | return formatInfo; |
| 343 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 344 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 345 | static InternalFormat LUMAFormat(GLuint luminance, GLuint alpha, GLenum format, GLenum type, GLenum componentType, |
| 346 | InternalFormat::SupportCheckFunction textureSupport, |
| 347 | InternalFormat::SupportCheckFunction renderSupport, |
| 348 | InternalFormat::SupportCheckFunction filterSupport) |
| 349 | { |
| 350 | InternalFormat formatInfo; |
| 351 | formatInfo.luminanceBits = luminance; |
| 352 | formatInfo.alphaBits = alpha; |
| 353 | formatInfo.pixelBytes = (luminance + alpha) / 8; |
| 354 | formatInfo.componentCount = ((luminance > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0); |
| 355 | formatInfo.format = format; |
| 356 | formatInfo.type = type; |
| 357 | formatInfo.componentType = componentType; |
| 358 | formatInfo.colorEncoding = GL_LINEAR; |
| 359 | formatInfo.textureSupport = textureSupport; |
| 360 | formatInfo.renderSupport = renderSupport; |
| 361 | formatInfo.filterSupport = filterSupport; |
| 362 | return formatInfo; |
| 363 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 364 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 365 | static InternalFormat DepthStencilFormat(GLuint depthBits, GLuint stencilBits, GLuint unusedBits, GLenum format, |
| 366 | GLenum type, GLenum componentType, InternalFormat::SupportCheckFunction textureSupport, |
| 367 | InternalFormat::SupportCheckFunction renderSupport, |
| 368 | InternalFormat::SupportCheckFunction filterSupport) |
| 369 | { |
| 370 | InternalFormat formatInfo; |
| 371 | formatInfo.depthBits = depthBits; |
| 372 | formatInfo.stencilBits = stencilBits; |
| 373 | formatInfo.pixelBytes = (depthBits + stencilBits + unusedBits) / 8; |
| 374 | formatInfo.componentCount = ((depthBits > 0) ? 1 : 0) + ((stencilBits > 0) ? 1 : 0); |
| 375 | formatInfo.format = format; |
| 376 | formatInfo.type = type; |
| 377 | formatInfo.componentType = componentType; |
| 378 | formatInfo.colorEncoding = GL_LINEAR; |
| 379 | formatInfo.textureSupport = textureSupport; |
| 380 | formatInfo.renderSupport = renderSupport; |
| 381 | formatInfo.filterSupport = filterSupport; |
| 382 | return formatInfo; |
| 383 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 384 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 385 | static InternalFormat CompressedFormat(GLuint compressedBlockWidth, GLuint compressedBlockHeight, GLuint compressedBlockSize, |
| 386 | GLuint componentCount, GLenum format, GLenum type, bool srgb, |
| 387 | InternalFormat::SupportCheckFunction textureSupport, |
| 388 | InternalFormat::SupportCheckFunction renderSupport, |
| 389 | InternalFormat::SupportCheckFunction filterSupport) |
| 390 | { |
| 391 | InternalFormat formatInfo; |
| 392 | formatInfo.compressedBlockWidth = compressedBlockWidth; |
| 393 | formatInfo.compressedBlockHeight = compressedBlockHeight; |
| 394 | formatInfo.pixelBytes = compressedBlockSize / 8; |
| 395 | formatInfo.componentCount = componentCount; |
| 396 | formatInfo.format = format; |
| 397 | formatInfo.type = type; |
| 398 | formatInfo.componentType = GL_UNSIGNED_NORMALIZED; |
| 399 | formatInfo.colorEncoding = (srgb ? GL_SRGB : GL_LINEAR); |
| 400 | formatInfo.compressed = true; |
| 401 | formatInfo.textureSupport = textureSupport; |
| 402 | formatInfo.renderSupport = renderSupport; |
| 403 | formatInfo.filterSupport = filterSupport; |
| 404 | return formatInfo; |
| 405 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 406 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 407 | typedef std::pair<GLenum, InternalFormat> InternalFormatInfoPair; |
| 408 | typedef std::map<GLenum, InternalFormat> InternalFormatInfoMap; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 409 | |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 410 | static InternalFormatInfoMap BuildInternalFormatInfoMap() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 411 | { |
| 412 | InternalFormatInfoMap map; |
| 413 | |
Geoff Lang | 9bbad18 | 2015-09-04 11:07:29 -0400 | [diff] [blame] | 414 | // clang-format off |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 415 | // From ES 3.0.1 spec, table 3.12 |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 416 | map.insert(InternalFormatInfoPair(GL_NONE, InternalFormat())); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 417 | |
Geoff Lang | abce762 | 2014-09-19 16:13:00 -0400 | [diff] [blame] | 418 | // | Internal format | | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Renderable | Filterable | |
| 419 | 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))); |
| 420 | map.insert(InternalFormatInfoPair(GL_R8_SNORM, RGBAFormat( 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported))); |
| 421 | 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))); |
| 422 | map.insert(InternalFormatInfoPair(GL_RG8_SNORM, RGBAFormat( 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported))); |
| 423 | 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))); |
| 424 | map.insert(InternalFormatInfoPair(GL_RGB8_SNORM, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported))); |
| 425 | 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))); |
| 426 | 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))); |
| 427 | 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))); |
| 428 | 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))); |
| 429 | map.insert(InternalFormatInfoPair(GL_RGBA8_SNORM, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3>, NeverSupported, AlwaysSupported))); |
| 430 | 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))); |
Geoff Lang | 9bbad18 | 2015-09-04 11:07:29 -0400 | [diff] [blame] | 431 | 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>, RequireES<3>, NeverSupported))); |
Geoff Lang | abce762 | 2014-09-19 16:13:00 -0400 | [diff] [blame] | 432 | 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))); |
| 433 | 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))); |
| 434 | 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))); |
| 435 | 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))); |
| 436 | map.insert(InternalFormatInfoPair(GL_R8I, RGBAFormat( 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported))); |
| 437 | 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))); |
| 438 | map.insert(InternalFormatInfoPair(GL_R16I, RGBAFormat(16, 0, 0, 0, 0, GL_RED_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported))); |
| 439 | 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))); |
| 440 | map.insert(InternalFormatInfoPair(GL_R32I, RGBAFormat(32, 0, 0, 0, 0, GL_RED_INTEGER, GL_INT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported))); |
| 441 | 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))); |
| 442 | map.insert(InternalFormatInfoPair(GL_RG8I, RGBAFormat( 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported))); |
| 443 | 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))); |
| 444 | map.insert(InternalFormatInfoPair(GL_RG16I, RGBAFormat(16, 16, 0, 0, 0, GL_RG_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported))); |
| 445 | 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))); |
| 446 | map.insert(InternalFormatInfoPair(GL_RG32I, RGBAFormat(32, 32, 0, 0, 0, GL_RG_INTEGER, GL_INT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported))); |
| 447 | 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))); |
| 448 | map.insert(InternalFormatInfoPair(GL_RGB8I, RGBAFormat( 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, NeverSupported, NeverSupported))); |
| 449 | 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))); |
| 450 | map.insert(InternalFormatInfoPair(GL_RGB16I, RGBAFormat(16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, NeverSupported, NeverSupported))); |
| 451 | 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))); |
| 452 | map.insert(InternalFormatInfoPair(GL_RGB32I, RGBAFormat(32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_INT, GL_INT, false, RequireES<3>, NeverSupported, NeverSupported))); |
| 453 | 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))); |
| 454 | map.insert(InternalFormatInfoPair(GL_RGBA8I, RGBAFormat( 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_BYTE, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported))); |
| 455 | 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))); |
| 456 | map.insert(InternalFormatInfoPair(GL_RGBA16I, RGBAFormat(16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_SHORT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported))); |
| 457 | 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))); |
| 458 | map.insert(InternalFormatInfoPair(GL_RGBA32I, RGBAFormat(32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, GL_INT, false, RequireES<3>, RequireES<3>, NeverSupported))); |
| 459 | 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.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 460 | |
Geoff Lang | abce762 | 2014-09-19 16:13:00 -0400 | [diff] [blame] | 461 | 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))); |
| 462 | 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))); |
| 463 | 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.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 464 | |
Jamie Madill | ec0b580 | 2016-07-04 13:11:59 -0400 | [diff] [blame] | 465 | // Special format which is not really supported, so always false for all supports. |
| 466 | map.insert(InternalFormatInfoPair(GL_BGR565_ANGLEX, RGBAFormat( 5, 6, 5, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported))); |
| 467 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 468 | // Floating point renderability and filtering is provided by OES_texture_float and OES_texture_half_float |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 469 | // | Internal format | | D |S | Format | Type | Comp | SRGB | Texture supported | Renderable | Filterable | |
| 470 | // | | | | | | | type | | | | | |
| 471 | map.insert(InternalFormatInfoPair(GL_R16F, RGBAFormat(16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT, GL_FLOAT, false, HalfFloatSupportRG, HalfFloatRenderableSupportRG, RequireExt<&Extensions::textureHalfFloatLinear>))); |
| 472 | map.insert(InternalFormatInfoPair(GL_RG16F, RGBAFormat(16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT, GL_FLOAT, false, HalfFloatSupportRG, HalfFloatRenderableSupportRG, RequireExt<&Extensions::textureHalfFloatLinear>))); |
| 473 | map.insert(InternalFormatInfoPair(GL_RGB16F, RGBAFormat(16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT, GL_FLOAT, false, HalfFloatSupport, HalfFloatRenderableSupport, RequireExt<&Extensions::textureHalfFloatLinear>))); |
| 474 | map.insert(InternalFormatInfoPair(GL_RGBA16F, RGBAFormat(16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT, GL_FLOAT, false, HalfFloatSupport, HalfFloatRenderableSupport, RequireExt<&Extensions::textureHalfFloatLinear>))); |
| 475 | map.insert(InternalFormatInfoPair(GL_R32F, RGBAFormat(32, 0, 0, 0, 0, GL_RED, GL_FLOAT, GL_FLOAT, false, FloatSupportRG, FloatRenderableSupportRG, RequireExt<&Extensions::textureFloatLinear> ))); |
| 476 | map.insert(InternalFormatInfoPair(GL_RG32F, RGBAFormat(32, 32, 0, 0, 0, GL_RG, GL_FLOAT, GL_FLOAT, false, FloatSupportRG, FloatRenderableSupportRG, RequireExt<&Extensions::textureFloatLinear> ))); |
| 477 | map.insert(InternalFormatInfoPair(GL_RGB32F, RGBAFormat(32, 32, 32, 0, 0, GL_RGB, GL_FLOAT, GL_FLOAT, false, FloatSupport, FloatRenderableSupport, RequireExt<&Extensions::textureFloatLinear> ))); |
| 478 | map.insert(InternalFormatInfoPair(GL_RGBA32F, RGBAFormat(32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT, GL_FLOAT, false, FloatSupport, FloatRenderableSupport, RequireExt<&Extensions::textureFloatLinear> ))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 479 | |
| 480 | // Depth stencil formats |
Geoff Lang | abce762 | 2014-09-19 16:13:00 -0400 | [diff] [blame] | 481 | // | Internal format | | D |S | X | Format | Type | Component type | Supported | Renderable | Filterable | |
| 482 | 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>))); |
| 483 | 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>))); |
| 484 | 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>))); |
Jamie Madill | f06e607 | 2015-12-01 10:44:16 -0500 | [diff] [blame] | 485 | map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT32_OES, DepthStencilFormat(32, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireExtOrExt<&Extensions::depthTextures, &Extensions::depth32>, RequireExtOrExt<&Extensions::depthTextures, &Extensions::depth32>, AlwaysSupported ))); |
Geoff Lang | abce762 | 2014-09-19 16:13:00 -0400 | [diff] [blame] | 486 | 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 ))); |
| 487 | 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 ))); |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 488 | // STENCIL_INDEX8 is special-cased, see around the bottom of the list. |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 489 | |
| 490 | // Luminance alpha formats |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 491 | // | Internal format | | L | A | Format | Type | Component type | Supported | Renderable | Filterable | |
Geoff Lang | abce762 | 2014-09-19 16:13:00 -0400 | [diff] [blame] | 492 | map.insert(InternalFormatInfoPair(GL_ALPHA8_EXT, LUMAFormat( 0, 8, GL_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, NeverSupported, AlwaysSupported))); |
| 493 | map.insert(InternalFormatInfoPair(GL_LUMINANCE8_EXT, LUMAFormat( 8, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, NeverSupported, AlwaysSupported))); |
| 494 | map.insert(InternalFormatInfoPair(GL_ALPHA32F_EXT, LUMAFormat( 0, 32, GL_ALPHA, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, NeverSupported, AlwaysSupported))); |
| 495 | map.insert(InternalFormatInfoPair(GL_LUMINANCE32F_EXT, LUMAFormat(32, 0, GL_LUMINANCE, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, NeverSupported, AlwaysSupported))); |
| 496 | map.insert(InternalFormatInfoPair(GL_ALPHA16F_EXT, LUMAFormat( 0, 16, GL_ALPHA, GL_HALF_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, NeverSupported, AlwaysSupported))); |
| 497 | map.insert(InternalFormatInfoPair(GL_LUMINANCE16F_EXT, LUMAFormat(16, 0, GL_LUMINANCE, GL_HALF_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, NeverSupported, AlwaysSupported))); |
| 498 | map.insert(InternalFormatInfoPair(GL_LUMINANCE8_ALPHA8_EXT, LUMAFormat( 8, 8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, NeverSupported, AlwaysSupported))); |
| 499 | map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA32F_EXT, LUMAFormat(32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, NeverSupported, AlwaysSupported))); |
| 500 | 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.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 501 | |
| 502 | // Unsized formats |
Geoff Lang | abce762 | 2014-09-19 16:13:00 -0400 | [diff] [blame] | 503 | // | Internal format | | Format | Supported | Renderable | Filterable | |
| 504 | map.insert(InternalFormatInfoPair(GL_ALPHA, UnsizedFormat(GL_ALPHA, RequireES<2>, NeverSupported, AlwaysSupported))); |
| 505 | map.insert(InternalFormatInfoPair(GL_LUMINANCE, UnsizedFormat(GL_LUMINANCE, RequireES<2>, NeverSupported, AlwaysSupported))); |
| 506 | map.insert(InternalFormatInfoPair(GL_LUMINANCE_ALPHA, UnsizedFormat(GL_LUMINANCE_ALPHA, RequireES<2>, NeverSupported, AlwaysSupported))); |
| 507 | map.insert(InternalFormatInfoPair(GL_RED, UnsizedFormat(GL_RED, RequireESOrExt<3, &Extensions::textureRG>, NeverSupported, AlwaysSupported))); |
| 508 | map.insert(InternalFormatInfoPair(GL_RG, UnsizedFormat(GL_RG, RequireESOrExt<3, &Extensions::textureRG>, NeverSupported, AlwaysSupported))); |
| 509 | map.insert(InternalFormatInfoPair(GL_RGB, UnsizedFormat(GL_RGB, RequireES<2>, RequireES<2>, AlwaysSupported))); |
| 510 | map.insert(InternalFormatInfoPair(GL_RGBA, UnsizedFormat(GL_RGBA, RequireES<2>, RequireES<2>, AlwaysSupported))); |
| 511 | map.insert(InternalFormatInfoPair(GL_RED_INTEGER, UnsizedFormat(GL_RED_INTEGER, RequireES<3>, NeverSupported, NeverSupported ))); |
| 512 | map.insert(InternalFormatInfoPair(GL_RG_INTEGER, UnsizedFormat(GL_RG_INTEGER, RequireES<3>, NeverSupported, NeverSupported ))); |
| 513 | map.insert(InternalFormatInfoPair(GL_RGB_INTEGER, UnsizedFormat(GL_RGB_INTEGER, RequireES<3>, NeverSupported, NeverSupported ))); |
| 514 | map.insert(InternalFormatInfoPair(GL_RGBA_INTEGER, UnsizedFormat(GL_RGBA_INTEGER, RequireES<3>, NeverSupported, NeverSupported ))); |
| 515 | map.insert(InternalFormatInfoPair(GL_BGRA_EXT, UnsizedFormat(GL_BGRA_EXT, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported))); |
| 516 | map.insert(InternalFormatInfoPair(GL_DEPTH_COMPONENT, UnsizedFormat(GL_DEPTH_COMPONENT, RequireES<2>, RequireES<2>, AlwaysSupported))); |
| 517 | map.insert(InternalFormatInfoPair(GL_DEPTH_STENCIL, UnsizedFormat(GL_DEPTH_STENCIL, RequireESOrExt<3, &Extensions::packedDepthStencil>, RequireESOrExt<3, &Extensions::packedDepthStencil>, AlwaysSupported))); |
| 518 | map.insert(InternalFormatInfoPair(GL_SRGB_EXT, UnsizedFormat(GL_RGB, RequireESOrExt<3, &Extensions::sRGB>, NeverSupported, AlwaysSupported))); |
| 519 | map.insert(InternalFormatInfoPair(GL_SRGB_ALPHA_EXT, UnsizedFormat(GL_RGBA, RequireESOrExt<3, &Extensions::sRGB>, RequireESOrExt<3, &Extensions::sRGB>, AlwaysSupported))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 520 | |
| 521 | // Compressed formats, From ES 3.0.1 spec, table 3.16 |
Geoff Lang | 0d8b724 | 2015-09-09 14:56:53 -0400 | [diff] [blame] | 522 | // | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable | |
| 523 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_R11_EAC, CompressedFormat(4, 4, 64, 1, GL_COMPRESSED_R11_EAC, GL_UNSIGNED_BYTE, false, RequireES<3>, NeverSupported, AlwaysSupported))); |
| 524 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SIGNED_R11_EAC, CompressedFormat(4, 4, 64, 1, GL_COMPRESSED_SIGNED_R11_EAC, GL_UNSIGNED_BYTE, false, RequireES<3>, NeverSupported, AlwaysSupported))); |
| 525 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RG11_EAC, CompressedFormat(4, 4, 128, 2, GL_COMPRESSED_RG11_EAC, GL_UNSIGNED_BYTE, false, RequireES<3>, NeverSupported, AlwaysSupported))); |
| 526 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SIGNED_RG11_EAC, CompressedFormat(4, 4, 128, 2, GL_COMPRESSED_SIGNED_RG11_EAC, GL_UNSIGNED_BYTE, false, RequireES<3>, NeverSupported, AlwaysSupported))); |
| 527 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB8_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB8_ETC2, GL_UNSIGNED_BYTE, false, RequireES<3>, NeverSupported, AlwaysSupported))); |
| 528 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_SRGB8_ETC2, GL_UNSIGNED_BYTE, true, RequireES<3>, NeverSupported, AlwaysSupported))); |
| 529 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, false, RequireES<3>, NeverSupported, AlwaysSupported))); |
| 530 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, true, RequireES<3>, NeverSupported, AlwaysSupported))); |
| 531 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA8_ETC2_EAC, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_RGBA8_ETC2_EAC, GL_UNSIGNED_BYTE, false, RequireES<3>, NeverSupported, AlwaysSupported))); |
| 532 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_UNSIGNED_BYTE, true, RequireES<3>, NeverSupported, AlwaysSupported))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 533 | |
| 534 | // From GL_EXT_texture_compression_dxt1 |
Geoff Lang | 6ea6f94 | 2015-09-11 13:11:22 -0400 | [diff] [blame] | 535 | // | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable | |
| 536 | 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))); |
| 537 | 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.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 538 | |
| 539 | // From GL_ANGLE_texture_compression_dxt3 |
Geoff Lang | 6ea6f94 | 2015-09-11 13:11:22 -0400 | [diff] [blame] | 540 | 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.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 541 | |
| 542 | // From GL_ANGLE_texture_compression_dxt5 |
Geoff Lang | 6ea6f94 | 2015-09-11 13:11:22 -0400 | [diff] [blame] | 543 | 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))); |
| 544 | |
| 545 | // From GL_OES_compressed_ETC1_RGB8_texture |
| 546 | map.insert(InternalFormatInfoPair(GL_ETC1_RGB8_OES, CompressedFormat(4, 4, 64, 3, GL_ETC1_RGB8_OES, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::compressedETC1RGB8Texture>, NeverSupported, AlwaysSupported))); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 547 | |
Geoff Lang | 60ad73d | 2015-10-23 10:08:44 -0400 | [diff] [blame] | 548 | // From KHR_texture_compression_astc_hdr |
| 549 | // | Internal format | | W | H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable | |
| 550 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_ASTC_4x4_KHR, CompressedFormat( 4, 4, 128, 4, GL_COMPRESSED_RGBA_ASTC_4x4_KHR, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 551 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_ASTC_5x4_KHR, CompressedFormat( 5, 4, 128, 4, GL_COMPRESSED_RGBA_ASTC_5x4_KHR, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 552 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_ASTC_5x5_KHR, CompressedFormat( 5, 5, 128, 4, GL_COMPRESSED_RGBA_ASTC_5x5_KHR, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 553 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_ASTC_6x5_KHR, CompressedFormat( 6, 5, 128, 4, GL_COMPRESSED_RGBA_ASTC_6x5_KHR, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 554 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_ASTC_6x6_KHR, CompressedFormat( 6, 6, 128, 4, GL_COMPRESSED_RGBA_ASTC_6x6_KHR, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 555 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_ASTC_8x5_KHR, CompressedFormat( 8, 5, 128, 4, GL_COMPRESSED_RGBA_ASTC_8x5_KHR, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 556 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_ASTC_8x6_KHR, CompressedFormat( 8, 6, 128, 4, GL_COMPRESSED_RGBA_ASTC_8x6_KHR, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 557 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_ASTC_8x8_KHR, CompressedFormat( 8, 8, 128, 4, GL_COMPRESSED_RGBA_ASTC_8x8_KHR, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 558 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_ASTC_10x5_KHR, CompressedFormat(10, 5, 128, 4, GL_COMPRESSED_RGBA_ASTC_10x5_KHR, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 559 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_ASTC_10x6_KHR, CompressedFormat(10, 6, 128, 4, GL_COMPRESSED_RGBA_ASTC_10x6_KHR, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 560 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_ASTC_10x8_KHR, CompressedFormat(10, 8, 128, 4, GL_COMPRESSED_RGBA_ASTC_10x8_KHR, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 561 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_ASTC_10x10_KHR, CompressedFormat(10, 10, 128, 4, GL_COMPRESSED_RGBA_ASTC_10x10_KHR, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 562 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_ASTC_12x10_KHR, CompressedFormat(12, 10, 128, 4, GL_COMPRESSED_RGBA_ASTC_12x10_KHR, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 563 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_ASTC_12x12_KHR, CompressedFormat(12, 12, 128, 4, GL_COMPRESSED_RGBA_ASTC_12x12_KHR, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 564 | |
| 565 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, CompressedFormat( 4, 4, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 566 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, CompressedFormat( 5, 4, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 567 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, CompressedFormat( 5, 5, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 568 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, CompressedFormat( 6, 5, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 569 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, CompressedFormat( 6, 6, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 570 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, CompressedFormat( 8, 5, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 571 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, CompressedFormat( 8, 6, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 572 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, CompressedFormat( 8, 8, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 573 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, CompressedFormat(10, 5, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 574 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, CompressedFormat(10, 6, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 575 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, CompressedFormat(10, 8, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 576 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, CompressedFormat(10, 10, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 577 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, CompressedFormat(12, 10, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 578 | map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, CompressedFormat(12, 12, 128, 4, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported))); |
| 579 | |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 580 | // For STENCIL_INDEX8 we chose a normalized component type for the following reasons: |
| 581 | // - Multisampled buffer are disallowed for non-normalized integer component types and we want to support it for STENCIL_INDEX8 |
| 582 | // - All other stencil formats (all depth-stencil) are either float or normalized |
| 583 | // - It affects only validation of internalformat in RenderbufferStorageMultisample. |
Jamie Madill | 6dd2843 | 2016-07-22 14:28:42 -0400 | [diff] [blame^] | 584 | // | Internal format | |D |S |X | Format | Type | Component type | Supported | Renderable | Filterable | |
| 585 | map.insert(InternalFormatInfoPair(GL_STENCIL_INDEX8, DepthStencilFormat(0, 8, 0, GL_STENCIL, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireES<2>, RequireES<2>, NeverSupported))); |
Minmin Gong | e3939b9 | 2015-12-01 15:36:51 -0800 | [diff] [blame] | 586 | |
| 587 | // From GL_ANGLE_lossy_etc_decode |
| 588 | map.insert(InternalFormatInfoPair(GL_ETC1_RGB8_LOSSY_DECODE_ANGLE, CompressedFormat(4, 4, 64, 3, GL_ETC1_RGB8_OES, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::lossyETCDecode>, NeverSupported, AlwaysSupported))); |
| 589 | |
Vincent Lang | 25ab451 | 2016-05-13 18:13:59 +0200 | [diff] [blame] | 590 | // From GL_EXT_texture_norm16 |
| 591 | // | Internal format | | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Renderable | Filterable | |
| 592 | map.insert(InternalFormatInfoPair(GL_R16_EXT, RGBAFormat(16, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, RequireExt<&Extensions::textureNorm16>, AlwaysSupported))); |
| 593 | map.insert(InternalFormatInfoPair(GL_R16_SNORM_EXT, RGBAFormat(16, 0, 0, 0, 0, GL_RED, GL_SHORT, GL_SIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, NeverSupported, AlwaysSupported))); |
| 594 | map.insert(InternalFormatInfoPair(GL_RG16_EXT, RGBAFormat(16, 16, 0, 0, 0, GL_RG, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, RequireExt<&Extensions::textureNorm16>, AlwaysSupported))); |
| 595 | map.insert(InternalFormatInfoPair(GL_RG16_SNORM_EXT, RGBAFormat(16, 16, 0, 0, 0, GL_RG, GL_SHORT, GL_SIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, NeverSupported, AlwaysSupported))); |
| 596 | map.insert(InternalFormatInfoPair(GL_RGB16_EXT, RGBAFormat(16, 16, 16, 0, 0, GL_RGB, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, NeverSupported, AlwaysSupported))); |
| 597 | map.insert(InternalFormatInfoPair(GL_RGB16_SNORM_EXT, RGBAFormat(16, 16, 16, 0, 0, GL_RGB, GL_SHORT, GL_SIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, NeverSupported, AlwaysSupported))); |
| 598 | map.insert(InternalFormatInfoPair(GL_RGBA16_EXT, RGBAFormat(16, 16, 16, 16, 0, GL_RGBA, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, RequireExt<&Extensions::textureNorm16>, AlwaysSupported))); |
| 599 | map.insert(InternalFormatInfoPair(GL_RGBA16_SNORM_EXT, RGBAFormat(16, 16, 16, 16, 0, GL_RGBA, GL_SHORT, GL_SIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, NeverSupported, AlwaysSupported))); |
| 600 | |
Geoff Lang | 9bbad18 | 2015-09-04 11:07:29 -0400 | [diff] [blame] | 601 | // clang-format on |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 602 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 603 | return map; |
| 604 | } |
| 605 | |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 606 | static const InternalFormatInfoMap &GetInternalFormatMap() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 607 | { |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 608 | static const InternalFormatInfoMap formatMap = BuildInternalFormatInfoMap(); |
| 609 | return formatMap; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 610 | } |
| 611 | |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 612 | static FormatSet BuildAllSizedInternalFormatSet() |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 613 | { |
| 614 | FormatSet result; |
| 615 | |
Jamie Madill | ec0b580 | 2016-07-04 13:11:59 -0400 | [diff] [blame] | 616 | for (auto iter : GetInternalFormatMap()) |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 617 | { |
Jamie Madill | ec0b580 | 2016-07-04 13:11:59 -0400 | [diff] [blame] | 618 | if (iter.second.pixelBytes > 0) |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 619 | { |
Jamie Madill | ec0b580 | 2016-07-04 13:11:59 -0400 | [diff] [blame] | 620 | // TODO(jmadill): Fix this hack. |
| 621 | if (iter.first == GL_BGR565_ANGLEX) |
| 622 | continue; |
| 623 | |
| 624 | result.insert(iter.first); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 625 | } |
| 626 | } |
| 627 | |
| 628 | return result; |
| 629 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 630 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 631 | const Type &GetTypeInfo(GLenum type) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 632 | { |
Olli Etuaho | 31f8f4f | 2015-03-25 16:03:57 +0200 | [diff] [blame] | 633 | switch (type) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 634 | { |
Olli Etuaho | 31f8f4f | 2015-03-25 16:03:57 +0200 | [diff] [blame] | 635 | case GL_UNSIGNED_BYTE: |
| 636 | case GL_BYTE: |
| 637 | { |
| 638 | static const Type info = GenTypeInfo(1, false); |
| 639 | return info; |
| 640 | } |
| 641 | case GL_UNSIGNED_SHORT: |
| 642 | case GL_SHORT: |
| 643 | case GL_HALF_FLOAT: |
| 644 | case GL_HALF_FLOAT_OES: |
| 645 | { |
| 646 | static const Type info = GenTypeInfo(2, false); |
| 647 | return info; |
| 648 | } |
| 649 | case GL_UNSIGNED_INT: |
| 650 | case GL_INT: |
| 651 | case GL_FLOAT: |
| 652 | { |
| 653 | static const Type info = GenTypeInfo(4, false); |
| 654 | return info; |
| 655 | } |
| 656 | case GL_UNSIGNED_SHORT_5_6_5: |
| 657 | case GL_UNSIGNED_SHORT_4_4_4_4: |
| 658 | case GL_UNSIGNED_SHORT_5_5_5_1: |
| 659 | case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: |
| 660 | case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: |
| 661 | { |
| 662 | static const Type info = GenTypeInfo(2, true); |
| 663 | return info; |
| 664 | } |
| 665 | case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 666 | case GL_UNSIGNED_INT_24_8: |
| 667 | case GL_UNSIGNED_INT_10F_11F_11F_REV: |
| 668 | case GL_UNSIGNED_INT_5_9_9_9_REV: |
| 669 | { |
| 670 | ASSERT(GL_UNSIGNED_INT_24_8_OES == GL_UNSIGNED_INT_24_8); |
| 671 | static const Type info = GenTypeInfo(4, true); |
| 672 | return info; |
| 673 | } |
| 674 | case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: |
| 675 | { |
| 676 | static const Type info = GenTypeInfo(8, true); |
| 677 | return info; |
| 678 | } |
| 679 | default: |
| 680 | { |
| 681 | static const Type defaultInfo; |
| 682 | return defaultInfo; |
| 683 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 684 | } |
| 685 | } |
| 686 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 687 | const InternalFormat &GetInternalFormatInfo(GLenum internalFormat) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 688 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 689 | const InternalFormatInfoMap &formatMap = GetInternalFormatMap(); |
Jamie Madill | ec0b580 | 2016-07-04 13:11:59 -0400 | [diff] [blame] | 690 | auto iter = formatMap.find(internalFormat); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 691 | if (iter != formatMap.end()) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 692 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 693 | return iter->second; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 694 | } |
| 695 | else |
| 696 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 697 | static const InternalFormat defaultInternalFormat; |
Jamie Madill | ec0b580 | 2016-07-04 13:11:59 -0400 | [diff] [blame] | 698 | UNREACHABLE(); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 699 | return defaultInternalFormat; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 700 | } |
| 701 | } |
| 702 | |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 703 | gl::ErrorOrResult<GLuint> InternalFormat::computeRowPitch(GLenum formatType, |
| 704 | GLsizei width, |
| 705 | GLint alignment, |
| 706 | GLint rowLength) const |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 707 | { |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 708 | // Compressed images do not use pack/unpack parameters. |
| 709 | if (compressed) |
| 710 | { |
| 711 | ASSERT(rowLength == 0); |
| 712 | return computeCompressedImageSize(formatType, gl::Extents(width, 1, 1)); |
| 713 | } |
| 714 | |
Geoff Lang | 3f23406 | 2016-07-13 15:35:45 -0400 | [diff] [blame] | 715 | const auto &typeInfo = GetTypeInfo(formatType); |
| 716 | CheckedNumeric<GLuint> checkedComponents(typeInfo.specialInterpretation ? 1u : componentCount); |
| 717 | CheckedNumeric<GLuint> checkedTypeBytes(typeInfo.bytes); |
| 718 | CheckedNumeric<GLuint> checkedWidth(rowLength > 0 ? rowLength : width); |
| 719 | CheckedNumeric<GLuint> checkedRowBytes = checkedWidth * checkedComponents * checkedTypeBytes; |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 720 | |
| 721 | ASSERT(alignment > 0 && isPow2(alignment)); |
| 722 | CheckedNumeric<GLuint> checkedAlignment(alignment); |
| 723 | auto aligned = rx::roundUp(checkedRowBytes, checkedAlignment); |
| 724 | ANGLE_TRY_CHECKED_MATH(aligned); |
| 725 | return aligned.ValueOrDie(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 726 | } |
| 727 | |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 728 | gl::ErrorOrResult<GLuint> InternalFormat::computeDepthPitch(GLenum formatType, |
| 729 | GLsizei width, |
| 730 | GLsizei height, |
| 731 | GLint alignment, |
| 732 | GLint rowLength, |
| 733 | GLint imageHeight) const |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 734 | { |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 735 | GLuint rows = |
| 736 | (imageHeight > 0 ? static_cast<GLuint>(imageHeight) : static_cast<GLuint>(height)); |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 737 | GLuint rowPitch = 0; |
| 738 | ANGLE_TRY_RESULT(computeRowPitch(formatType, width, alignment, rowLength), rowPitch); |
| 739 | |
| 740 | CheckedNumeric<GLuint> checkedRowPitch(rowPitch); |
| 741 | auto depthPitch = checkedRowPitch * rows; |
| 742 | ANGLE_TRY_CHECKED_MATH(depthPitch); |
| 743 | return depthPitch.ValueOrDie(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 744 | } |
| 745 | |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 746 | gl::ErrorOrResult<GLuint> InternalFormat::computeCompressedImageSize(GLenum formatType, |
| 747 | const gl::Extents &size) const |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 748 | { |
Jamie Madill | 513558d | 2016-06-02 13:04:11 -0400 | [diff] [blame] | 749 | CheckedNumeric<GLuint> checkedWidth(size.width); |
| 750 | CheckedNumeric<GLuint> checkedHeight(size.height); |
| 751 | CheckedNumeric<GLuint> checkedDepth(size.depth); |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 752 | CheckedNumeric<GLuint> checkedBlockWidth(compressedBlockWidth); |
| 753 | CheckedNumeric<GLuint> checkedBlockHeight(compressedBlockHeight); |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 754 | |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 755 | ASSERT(compressed); |
| 756 | auto numBlocksWide = (checkedWidth + checkedBlockWidth - 1u) / checkedBlockWidth; |
| 757 | auto numBlocksHigh = (checkedHeight + checkedBlockHeight - 1u) / checkedBlockHeight; |
| 758 | auto bytes = numBlocksWide * numBlocksHigh * pixelBytes * checkedDepth; |
| 759 | ANGLE_TRY_CHECKED_MATH(bytes); |
| 760 | return bytes.ValueOrDie(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 761 | } |
| 762 | |
Olli Etuaho | 989cac3 | 2016-06-08 16:18:49 -0700 | [diff] [blame] | 763 | gl::ErrorOrResult<GLuint> InternalFormat::computeSkipBytes(GLuint rowPitch, |
| 764 | GLuint depthPitch, |
| 765 | GLint skipImages, |
| 766 | GLint skipRows, |
| 767 | GLint skipPixels, |
| 768 | bool applySkipImages) const |
Minmin Gong | adff67b | 2015-10-14 10:34:45 -0400 | [diff] [blame] | 769 | { |
Olli Etuaho | 989cac3 | 2016-06-08 16:18:49 -0700 | [diff] [blame] | 770 | CheckedNumeric<GLuint> checkedRowPitch(rowPitch); |
| 771 | CheckedNumeric<GLuint> checkedDepthPitch(depthPitch); |
| 772 | CheckedNumeric<GLuint> checkedSkipImages(static_cast<GLuint>(skipImages)); |
| 773 | CheckedNumeric<GLuint> checkedSkipRows(static_cast<GLuint>(skipRows)); |
| 774 | CheckedNumeric<GLuint> checkedSkipPixels(static_cast<GLuint>(skipPixels)); |
| 775 | CheckedNumeric<GLuint> checkedPixelBytes(pixelBytes); |
| 776 | auto checkedSkipImagesBytes = checkedSkipImages * checkedDepthPitch; |
| 777 | if (!applySkipImages) |
| 778 | { |
| 779 | checkedSkipImagesBytes = 0; |
| 780 | } |
| 781 | auto skipBytes = checkedSkipImagesBytes + checkedSkipRows * checkedRowPitch + |
| 782 | checkedSkipPixels * checkedPixelBytes; |
| 783 | ANGLE_TRY_CHECKED_MATH(skipBytes); |
| 784 | return skipBytes.ValueOrDie(); |
Minmin Gong | adff67b | 2015-10-14 10:34:45 -0400 | [diff] [blame] | 785 | } |
| 786 | |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 787 | gl::ErrorOrResult<GLuint> InternalFormat::computeUnpackSize( |
| 788 | GLenum formatType, |
| 789 | const gl::Extents &size, |
| 790 | const gl::PixelUnpackState &unpack) const |
| 791 | { |
| 792 | // Compressed images do not use unpack parameters. |
| 793 | if (compressed) |
| 794 | { |
| 795 | return computeCompressedImageSize(formatType, size); |
| 796 | } |
| 797 | |
| 798 | base::CheckedNumeric<GLuint> checkedGroups(unpack.rowLength > 0 ? unpack.rowLength |
| 799 | : size.width); |
| 800 | base::CheckedNumeric<GLuint> checkedRows(unpack.imageHeight > 0 ? unpack.imageHeight |
| 801 | : size.height); |
| 802 | |
| 803 | // Compute the groups of all the layers in (0,depth-1) |
| 804 | auto layerGroups = checkedGroups * checkedRows * (size.depth - 1); |
| 805 | |
| 806 | // Compute the groups in the last layer (for non-3D textures, the only one) |
| 807 | auto lastLayerGroups = checkedGroups * (size.height - 1) + size.width; |
| 808 | |
| 809 | // The total size is the sum times the bytes per pixel. |
| 810 | auto totalSize = (layerGroups + lastLayerGroups) * pixelBytes; |
| 811 | |
| 812 | ANGLE_TRY_CHECKED_MATH(totalSize); |
| 813 | |
| 814 | return totalSize.ValueOrDie(); |
| 815 | } |
| 816 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 817 | GLenum GetSizedInternalFormat(GLenum internalFormat, GLenum type) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 818 | { |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 819 | const InternalFormat &formatInfo = GetInternalFormatInfo(internalFormat); |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 820 | if (formatInfo.pixelBytes > 0) |
| 821 | { |
| 822 | return internalFormat; |
| 823 | } |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 824 | |
| 825 | static const FormatMap formatMap = BuildFormatMap(); |
Jamie Madill | d2b50a0 | 2016-06-09 00:13:35 -0700 | [diff] [blame] | 826 | auto iter = formatMap.find(FormatType(internalFormat, type)); |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 827 | if (iter != formatMap.end()) |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 828 | { |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 829 | return iter->second; |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 830 | } |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 831 | |
| 832 | return GL_NONE; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 833 | } |
| 834 | |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 835 | const FormatSet &GetAllSizedInternalFormats() |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 836 | { |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 837 | static FormatSet formatSet = BuildAllSizedInternalFormatSet(); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 838 | return formatSet; |
| 839 | } |
| 840 | |
Jamie Madill | 09e2d93 | 2015-07-14 16:40:31 -0400 | [diff] [blame] | 841 | AttributeType GetAttributeType(GLenum enumValue) |
| 842 | { |
| 843 | switch (enumValue) |
| 844 | { |
| 845 | case GL_FLOAT: |
| 846 | return ATTRIBUTE_FLOAT; |
| 847 | case GL_FLOAT_VEC2: |
| 848 | return ATTRIBUTE_VEC2; |
| 849 | case GL_FLOAT_VEC3: |
| 850 | return ATTRIBUTE_VEC3; |
| 851 | case GL_FLOAT_VEC4: |
| 852 | return ATTRIBUTE_VEC4; |
| 853 | case GL_INT: |
| 854 | return ATTRIBUTE_INT; |
| 855 | case GL_INT_VEC2: |
| 856 | return ATTRIBUTE_IVEC2; |
| 857 | case GL_INT_VEC3: |
| 858 | return ATTRIBUTE_IVEC3; |
| 859 | case GL_INT_VEC4: |
| 860 | return ATTRIBUTE_IVEC4; |
| 861 | case GL_UNSIGNED_INT: |
| 862 | return ATTRIBUTE_UINT; |
| 863 | case GL_UNSIGNED_INT_VEC2: |
| 864 | return ATTRIBUTE_UVEC2; |
| 865 | case GL_UNSIGNED_INT_VEC3: |
| 866 | return ATTRIBUTE_UVEC3; |
| 867 | case GL_UNSIGNED_INT_VEC4: |
| 868 | return ATTRIBUTE_UVEC4; |
| 869 | case GL_FLOAT_MAT2: |
| 870 | return ATTRIBUTE_MAT2; |
| 871 | case GL_FLOAT_MAT3: |
| 872 | return ATTRIBUTE_MAT3; |
| 873 | case GL_FLOAT_MAT4: |
| 874 | return ATTRIBUTE_MAT4; |
| 875 | case GL_FLOAT_MAT2x3: |
| 876 | return ATTRIBUTE_MAT2x3; |
| 877 | case GL_FLOAT_MAT2x4: |
| 878 | return ATTRIBUTE_MAT2x4; |
| 879 | case GL_FLOAT_MAT3x2: |
| 880 | return ATTRIBUTE_MAT3x2; |
| 881 | case GL_FLOAT_MAT3x4: |
| 882 | return ATTRIBUTE_MAT3x4; |
| 883 | case GL_FLOAT_MAT4x2: |
| 884 | return ATTRIBUTE_MAT4x2; |
| 885 | case GL_FLOAT_MAT4x3: |
| 886 | return ATTRIBUTE_MAT4x3; |
| 887 | default: |
| 888 | UNREACHABLE(); |
| 889 | return ATTRIBUTE_FLOAT; |
| 890 | } |
| 891 | } |
| 892 | |
Jamie Madill | d3dfda2 | 2015-07-06 08:28:49 -0400 | [diff] [blame] | 893 | VertexFormatType GetVertexFormatType(GLenum type, GLboolean normalized, GLuint components, bool pureInteger) |
| 894 | { |
| 895 | switch (type) |
| 896 | { |
| 897 | case GL_BYTE: |
| 898 | switch (components) |
| 899 | { |
| 900 | case 1: |
| 901 | if (pureInteger) |
| 902 | return VERTEX_FORMAT_SBYTE1_INT; |
| 903 | if (normalized) |
| 904 | return VERTEX_FORMAT_SBYTE1_NORM; |
| 905 | return VERTEX_FORMAT_SBYTE1; |
| 906 | case 2: |
| 907 | if (pureInteger) |
| 908 | return VERTEX_FORMAT_SBYTE2_INT; |
| 909 | if (normalized) |
| 910 | return VERTEX_FORMAT_SBYTE2_NORM; |
| 911 | return VERTEX_FORMAT_SBYTE2; |
| 912 | case 3: |
| 913 | if (pureInteger) |
| 914 | return VERTEX_FORMAT_SBYTE3_INT; |
| 915 | if (normalized) |
| 916 | return VERTEX_FORMAT_SBYTE3_NORM; |
| 917 | return VERTEX_FORMAT_SBYTE3; |
| 918 | case 4: |
| 919 | if (pureInteger) |
| 920 | return VERTEX_FORMAT_SBYTE4_INT; |
| 921 | if (normalized) |
| 922 | return VERTEX_FORMAT_SBYTE4_NORM; |
| 923 | return VERTEX_FORMAT_SBYTE4; |
| 924 | default: |
| 925 | UNREACHABLE(); |
| 926 | break; |
| 927 | } |
| 928 | case GL_UNSIGNED_BYTE: |
| 929 | switch (components) |
| 930 | { |
| 931 | case 1: |
| 932 | if (pureInteger) |
| 933 | return VERTEX_FORMAT_UBYTE1_INT; |
| 934 | if (normalized) |
| 935 | return VERTEX_FORMAT_UBYTE1_NORM; |
| 936 | return VERTEX_FORMAT_UBYTE1; |
| 937 | case 2: |
| 938 | if (pureInteger) |
| 939 | return VERTEX_FORMAT_UBYTE2_INT; |
| 940 | if (normalized) |
| 941 | return VERTEX_FORMAT_UBYTE2_NORM; |
| 942 | return VERTEX_FORMAT_UBYTE2; |
| 943 | case 3: |
| 944 | if (pureInteger) |
| 945 | return VERTEX_FORMAT_UBYTE3_INT; |
| 946 | if (normalized) |
| 947 | return VERTEX_FORMAT_UBYTE3_NORM; |
| 948 | return VERTEX_FORMAT_UBYTE3; |
| 949 | case 4: |
| 950 | if (pureInteger) |
| 951 | return VERTEX_FORMAT_UBYTE4_INT; |
| 952 | if (normalized) |
| 953 | return VERTEX_FORMAT_UBYTE4_NORM; |
| 954 | return VERTEX_FORMAT_UBYTE4; |
| 955 | default: |
| 956 | UNREACHABLE(); |
| 957 | break; |
| 958 | } |
| 959 | case GL_SHORT: |
| 960 | switch (components) |
| 961 | { |
| 962 | case 1: |
| 963 | if (pureInteger) |
| 964 | return VERTEX_FORMAT_SSHORT1_INT; |
| 965 | if (normalized) |
| 966 | return VERTEX_FORMAT_SSHORT1_NORM; |
| 967 | return VERTEX_FORMAT_SSHORT1; |
| 968 | case 2: |
| 969 | if (pureInteger) |
| 970 | return VERTEX_FORMAT_SSHORT2_INT; |
| 971 | if (normalized) |
| 972 | return VERTEX_FORMAT_SSHORT2_NORM; |
| 973 | return VERTEX_FORMAT_SSHORT2; |
| 974 | case 3: |
| 975 | if (pureInteger) |
| 976 | return VERTEX_FORMAT_SSHORT3_INT; |
| 977 | if (normalized) |
| 978 | return VERTEX_FORMAT_SSHORT3_NORM; |
| 979 | return VERTEX_FORMAT_SSHORT3; |
| 980 | case 4: |
| 981 | if (pureInteger) |
| 982 | return VERTEX_FORMAT_SSHORT4_INT; |
| 983 | if (normalized) |
| 984 | return VERTEX_FORMAT_SSHORT4_NORM; |
| 985 | return VERTEX_FORMAT_SSHORT4; |
| 986 | default: |
| 987 | UNREACHABLE(); |
| 988 | break; |
| 989 | } |
| 990 | case GL_UNSIGNED_SHORT: |
| 991 | switch (components) |
| 992 | { |
| 993 | case 1: |
| 994 | if (pureInteger) |
| 995 | return VERTEX_FORMAT_USHORT1_INT; |
| 996 | if (normalized) |
| 997 | return VERTEX_FORMAT_USHORT1_NORM; |
| 998 | return VERTEX_FORMAT_USHORT1; |
| 999 | case 2: |
| 1000 | if (pureInteger) |
| 1001 | return VERTEX_FORMAT_USHORT2_INT; |
| 1002 | if (normalized) |
| 1003 | return VERTEX_FORMAT_USHORT2_NORM; |
| 1004 | return VERTEX_FORMAT_USHORT2; |
| 1005 | case 3: |
| 1006 | if (pureInteger) |
| 1007 | return VERTEX_FORMAT_USHORT3_INT; |
| 1008 | if (normalized) |
| 1009 | return VERTEX_FORMAT_USHORT3_NORM; |
| 1010 | return VERTEX_FORMAT_USHORT3; |
| 1011 | case 4: |
| 1012 | if (pureInteger) |
| 1013 | return VERTEX_FORMAT_USHORT4_INT; |
| 1014 | if (normalized) |
| 1015 | return VERTEX_FORMAT_USHORT4_NORM; |
| 1016 | return VERTEX_FORMAT_USHORT4; |
| 1017 | default: |
| 1018 | UNREACHABLE(); |
| 1019 | break; |
| 1020 | } |
| 1021 | case GL_INT: |
| 1022 | switch (components) |
| 1023 | { |
| 1024 | case 1: |
| 1025 | if (pureInteger) |
| 1026 | return VERTEX_FORMAT_SINT1_INT; |
| 1027 | if (normalized) |
| 1028 | return VERTEX_FORMAT_SINT1_NORM; |
| 1029 | return VERTEX_FORMAT_SINT1; |
| 1030 | case 2: |
| 1031 | if (pureInteger) |
| 1032 | return VERTEX_FORMAT_SINT2_INT; |
| 1033 | if (normalized) |
| 1034 | return VERTEX_FORMAT_SINT2_NORM; |
| 1035 | return VERTEX_FORMAT_SINT2; |
| 1036 | case 3: |
| 1037 | if (pureInteger) |
| 1038 | return VERTEX_FORMAT_SINT3_INT; |
| 1039 | if (normalized) |
| 1040 | return VERTEX_FORMAT_SINT3_NORM; |
| 1041 | return VERTEX_FORMAT_SINT3; |
| 1042 | case 4: |
| 1043 | if (pureInteger) |
| 1044 | return VERTEX_FORMAT_SINT4_INT; |
| 1045 | if (normalized) |
| 1046 | return VERTEX_FORMAT_SINT4_NORM; |
| 1047 | return VERTEX_FORMAT_SINT4; |
| 1048 | default: |
| 1049 | UNREACHABLE(); |
| 1050 | break; |
| 1051 | } |
| 1052 | case GL_UNSIGNED_INT: |
| 1053 | switch (components) |
| 1054 | { |
| 1055 | case 1: |
| 1056 | if (pureInteger) |
| 1057 | return VERTEX_FORMAT_UINT1_INT; |
| 1058 | if (normalized) |
| 1059 | return VERTEX_FORMAT_UINT1_NORM; |
| 1060 | return VERTEX_FORMAT_UINT1; |
| 1061 | case 2: |
| 1062 | if (pureInteger) |
| 1063 | return VERTEX_FORMAT_UINT2_INT; |
| 1064 | if (normalized) |
| 1065 | return VERTEX_FORMAT_UINT2_NORM; |
| 1066 | return VERTEX_FORMAT_UINT2; |
| 1067 | case 3: |
| 1068 | if (pureInteger) |
| 1069 | return VERTEX_FORMAT_UINT3_INT; |
| 1070 | if (normalized) |
| 1071 | return VERTEX_FORMAT_UINT3_NORM; |
| 1072 | return VERTEX_FORMAT_UINT3; |
| 1073 | case 4: |
| 1074 | if (pureInteger) |
| 1075 | return VERTEX_FORMAT_UINT4_INT; |
| 1076 | if (normalized) |
| 1077 | return VERTEX_FORMAT_UINT4_NORM; |
| 1078 | return VERTEX_FORMAT_UINT4; |
| 1079 | default: |
| 1080 | UNREACHABLE(); |
| 1081 | break; |
| 1082 | } |
| 1083 | case GL_FLOAT: |
| 1084 | switch (components) |
| 1085 | { |
| 1086 | case 1: |
| 1087 | return VERTEX_FORMAT_FLOAT1; |
| 1088 | case 2: |
| 1089 | return VERTEX_FORMAT_FLOAT2; |
| 1090 | case 3: |
| 1091 | return VERTEX_FORMAT_FLOAT3; |
| 1092 | case 4: |
| 1093 | return VERTEX_FORMAT_FLOAT4; |
| 1094 | default: |
| 1095 | UNREACHABLE(); |
| 1096 | break; |
| 1097 | } |
| 1098 | case GL_HALF_FLOAT: |
| 1099 | switch (components) |
| 1100 | { |
| 1101 | case 1: |
| 1102 | return VERTEX_FORMAT_HALF1; |
| 1103 | case 2: |
| 1104 | return VERTEX_FORMAT_HALF2; |
| 1105 | case 3: |
| 1106 | return VERTEX_FORMAT_HALF3; |
| 1107 | case 4: |
| 1108 | return VERTEX_FORMAT_HALF4; |
| 1109 | default: |
| 1110 | UNREACHABLE(); |
| 1111 | break; |
| 1112 | } |
| 1113 | case GL_FIXED: |
| 1114 | switch (components) |
| 1115 | { |
| 1116 | case 1: |
| 1117 | return VERTEX_FORMAT_FIXED1; |
| 1118 | case 2: |
| 1119 | return VERTEX_FORMAT_FIXED2; |
| 1120 | case 3: |
| 1121 | return VERTEX_FORMAT_FIXED3; |
| 1122 | case 4: |
| 1123 | return VERTEX_FORMAT_FIXED4; |
| 1124 | default: |
| 1125 | UNREACHABLE(); |
| 1126 | break; |
| 1127 | } |
| 1128 | case GL_INT_2_10_10_10_REV: |
| 1129 | if (pureInteger) |
| 1130 | return VERTEX_FORMAT_SINT210_INT; |
| 1131 | if (normalized) |
| 1132 | return VERTEX_FORMAT_SINT210_NORM; |
| 1133 | return VERTEX_FORMAT_SINT210; |
| 1134 | case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 1135 | if (pureInteger) |
| 1136 | return VERTEX_FORMAT_UINT210_INT; |
| 1137 | if (normalized) |
| 1138 | return VERTEX_FORMAT_UINT210_NORM; |
| 1139 | return VERTEX_FORMAT_UINT210; |
| 1140 | default: |
| 1141 | UNREACHABLE(); |
| 1142 | break; |
| 1143 | } |
| 1144 | return VERTEX_FORMAT_UBYTE1; |
| 1145 | } |
| 1146 | |
| 1147 | VertexFormatType GetVertexFormatType(const VertexAttribute &attrib) |
| 1148 | { |
| 1149 | return GetVertexFormatType(attrib.type, attrib.normalized, attrib.size, attrib.pureInteger); |
| 1150 | } |
| 1151 | |
| 1152 | VertexFormatType GetVertexFormatType(const VertexAttribute &attrib, GLenum currentValueType) |
| 1153 | { |
| 1154 | if (!attrib.enabled) |
| 1155 | { |
| 1156 | return GetVertexFormatType(currentValueType, GL_FALSE, 4, (currentValueType != GL_FLOAT)); |
| 1157 | } |
| 1158 | return GetVertexFormatType(attrib); |
| 1159 | } |
| 1160 | |
| 1161 | const VertexFormat &GetVertexFormatFromType(VertexFormatType vertexFormatType) |
| 1162 | { |
| 1163 | switch (vertexFormatType) |
| 1164 | { |
| 1165 | case VERTEX_FORMAT_SBYTE1: |
| 1166 | { |
| 1167 | static const VertexFormat format(GL_BYTE, GL_FALSE, 1, false); |
| 1168 | return format; |
| 1169 | } |
| 1170 | case VERTEX_FORMAT_SBYTE1_NORM: |
| 1171 | { |
| 1172 | static const VertexFormat format(GL_BYTE, GL_TRUE, 1, false); |
| 1173 | return format; |
| 1174 | } |
| 1175 | case VERTEX_FORMAT_SBYTE2: |
| 1176 | { |
| 1177 | static const VertexFormat format(GL_BYTE, GL_FALSE, 2, false); |
| 1178 | return format; |
| 1179 | } |
| 1180 | case VERTEX_FORMAT_SBYTE2_NORM: |
| 1181 | { |
| 1182 | static const VertexFormat format(GL_BYTE, GL_TRUE, 2, false); |
| 1183 | return format; |
| 1184 | } |
| 1185 | case VERTEX_FORMAT_SBYTE3: |
| 1186 | { |
| 1187 | static const VertexFormat format(GL_BYTE, GL_FALSE, 3, false); |
| 1188 | return format; |
| 1189 | } |
| 1190 | case VERTEX_FORMAT_SBYTE3_NORM: |
| 1191 | { |
| 1192 | static const VertexFormat format(GL_BYTE, GL_TRUE, 3, false); |
| 1193 | return format; |
| 1194 | } |
| 1195 | case VERTEX_FORMAT_SBYTE4: |
| 1196 | { |
| 1197 | static const VertexFormat format(GL_BYTE, GL_FALSE, 4, false); |
| 1198 | return format; |
| 1199 | } |
| 1200 | case VERTEX_FORMAT_SBYTE4_NORM: |
| 1201 | { |
| 1202 | static const VertexFormat format(GL_BYTE, GL_TRUE, 4, false); |
| 1203 | return format; |
| 1204 | } |
| 1205 | case VERTEX_FORMAT_UBYTE1: |
| 1206 | { |
| 1207 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 1, false); |
| 1208 | return format; |
| 1209 | } |
| 1210 | case VERTEX_FORMAT_UBYTE1_NORM: |
| 1211 | { |
| 1212 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 1, false); |
| 1213 | return format; |
| 1214 | } |
| 1215 | case VERTEX_FORMAT_UBYTE2: |
| 1216 | { |
| 1217 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 2, false); |
| 1218 | return format; |
| 1219 | } |
| 1220 | case VERTEX_FORMAT_UBYTE2_NORM: |
| 1221 | { |
| 1222 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 2, false); |
| 1223 | return format; |
| 1224 | } |
| 1225 | case VERTEX_FORMAT_UBYTE3: |
| 1226 | { |
| 1227 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 3, false); |
| 1228 | return format; |
| 1229 | } |
| 1230 | case VERTEX_FORMAT_UBYTE3_NORM: |
| 1231 | { |
| 1232 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 3, false); |
| 1233 | return format; |
| 1234 | } |
| 1235 | case VERTEX_FORMAT_UBYTE4: |
| 1236 | { |
| 1237 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 4, false); |
| 1238 | return format; |
| 1239 | } |
| 1240 | case VERTEX_FORMAT_UBYTE4_NORM: |
| 1241 | { |
| 1242 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 4, false); |
| 1243 | return format; |
| 1244 | } |
| 1245 | case VERTEX_FORMAT_SSHORT1: |
| 1246 | { |
| 1247 | static const VertexFormat format(GL_SHORT, GL_FALSE, 1, false); |
| 1248 | return format; |
| 1249 | } |
| 1250 | case VERTEX_FORMAT_SSHORT1_NORM: |
| 1251 | { |
| 1252 | static const VertexFormat format(GL_SHORT, GL_TRUE, 1, false); |
| 1253 | return format; |
| 1254 | } |
| 1255 | case VERTEX_FORMAT_SSHORT2: |
| 1256 | { |
| 1257 | static const VertexFormat format(GL_SHORT, GL_FALSE, 2, false); |
| 1258 | return format; |
| 1259 | } |
| 1260 | case VERTEX_FORMAT_SSHORT2_NORM: |
| 1261 | { |
| 1262 | static const VertexFormat format(GL_SHORT, GL_TRUE, 2, false); |
| 1263 | return format; |
| 1264 | } |
| 1265 | case VERTEX_FORMAT_SSHORT3: |
| 1266 | { |
| 1267 | static const VertexFormat format(GL_SHORT, GL_FALSE, 3, false); |
| 1268 | return format; |
| 1269 | } |
| 1270 | case VERTEX_FORMAT_SSHORT3_NORM: |
| 1271 | { |
| 1272 | static const VertexFormat format(GL_SHORT, GL_TRUE, 3, false); |
| 1273 | return format; |
| 1274 | } |
| 1275 | case VERTEX_FORMAT_SSHORT4: |
| 1276 | { |
| 1277 | static const VertexFormat format(GL_SHORT, GL_FALSE, 4, false); |
| 1278 | return format; |
| 1279 | } |
| 1280 | case VERTEX_FORMAT_SSHORT4_NORM: |
| 1281 | { |
| 1282 | static const VertexFormat format(GL_SHORT, GL_TRUE, 4, false); |
| 1283 | return format; |
| 1284 | } |
| 1285 | case VERTEX_FORMAT_USHORT1: |
| 1286 | { |
| 1287 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 1, false); |
| 1288 | return format; |
| 1289 | } |
| 1290 | case VERTEX_FORMAT_USHORT1_NORM: |
| 1291 | { |
| 1292 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 1, false); |
| 1293 | return format; |
| 1294 | } |
| 1295 | case VERTEX_FORMAT_USHORT2: |
| 1296 | { |
| 1297 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 2, false); |
| 1298 | return format; |
| 1299 | } |
| 1300 | case VERTEX_FORMAT_USHORT2_NORM: |
| 1301 | { |
| 1302 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 2, false); |
| 1303 | return format; |
| 1304 | } |
| 1305 | case VERTEX_FORMAT_USHORT3: |
| 1306 | { |
| 1307 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 3, false); |
| 1308 | return format; |
| 1309 | } |
| 1310 | case VERTEX_FORMAT_USHORT3_NORM: |
| 1311 | { |
| 1312 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 3, false); |
| 1313 | return format; |
| 1314 | } |
| 1315 | case VERTEX_FORMAT_USHORT4: |
| 1316 | { |
| 1317 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 4, false); |
| 1318 | return format; |
| 1319 | } |
| 1320 | case VERTEX_FORMAT_USHORT4_NORM: |
| 1321 | { |
| 1322 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 4, false); |
| 1323 | return format; |
| 1324 | } |
| 1325 | case VERTEX_FORMAT_SINT1: |
| 1326 | { |
| 1327 | static const VertexFormat format(GL_INT, GL_FALSE, 1, false); |
| 1328 | return format; |
| 1329 | } |
| 1330 | case VERTEX_FORMAT_SINT1_NORM: |
| 1331 | { |
| 1332 | static const VertexFormat format(GL_INT, GL_TRUE, 1, false); |
| 1333 | return format; |
| 1334 | } |
| 1335 | case VERTEX_FORMAT_SINT2: |
| 1336 | { |
| 1337 | static const VertexFormat format(GL_INT, GL_FALSE, 2, false); |
| 1338 | return format; |
| 1339 | } |
| 1340 | case VERTEX_FORMAT_SINT2_NORM: |
| 1341 | { |
| 1342 | static const VertexFormat format(GL_INT, GL_TRUE, 2, false); |
| 1343 | return format; |
| 1344 | } |
| 1345 | case VERTEX_FORMAT_SINT3: |
| 1346 | { |
| 1347 | static const VertexFormat format(GL_INT, GL_FALSE, 3, false); |
| 1348 | return format; |
| 1349 | } |
| 1350 | case VERTEX_FORMAT_SINT3_NORM: |
| 1351 | { |
| 1352 | static const VertexFormat format(GL_INT, GL_TRUE, 3, false); |
| 1353 | return format; |
| 1354 | } |
| 1355 | case VERTEX_FORMAT_SINT4: |
| 1356 | { |
| 1357 | static const VertexFormat format(GL_INT, GL_FALSE, 4, false); |
| 1358 | return format; |
| 1359 | } |
| 1360 | case VERTEX_FORMAT_SINT4_NORM: |
| 1361 | { |
| 1362 | static const VertexFormat format(GL_INT, GL_TRUE, 4, false); |
| 1363 | return format; |
| 1364 | } |
| 1365 | case VERTEX_FORMAT_UINT1: |
| 1366 | { |
| 1367 | static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 1, false); |
| 1368 | return format; |
| 1369 | } |
| 1370 | case VERTEX_FORMAT_UINT1_NORM: |
| 1371 | { |
| 1372 | static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 1, false); |
| 1373 | return format; |
| 1374 | } |
| 1375 | case VERTEX_FORMAT_UINT2: |
| 1376 | { |
| 1377 | static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 2, false); |
| 1378 | return format; |
| 1379 | } |
| 1380 | case VERTEX_FORMAT_UINT2_NORM: |
| 1381 | { |
| 1382 | static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 2, false); |
| 1383 | return format; |
| 1384 | } |
| 1385 | case VERTEX_FORMAT_UINT3: |
| 1386 | { |
| 1387 | static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 3, false); |
| 1388 | return format; |
| 1389 | } |
| 1390 | case VERTEX_FORMAT_UINT3_NORM: |
| 1391 | { |
| 1392 | static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 3, false); |
| 1393 | return format; |
| 1394 | } |
| 1395 | case VERTEX_FORMAT_UINT4: |
| 1396 | { |
| 1397 | static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 4, false); |
| 1398 | return format; |
| 1399 | } |
| 1400 | case VERTEX_FORMAT_UINT4_NORM: |
| 1401 | { |
| 1402 | static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 4, false); |
| 1403 | return format; |
| 1404 | } |
| 1405 | case VERTEX_FORMAT_SBYTE1_INT: |
| 1406 | { |
| 1407 | static const VertexFormat format(GL_BYTE, GL_FALSE, 1, true); |
| 1408 | return format; |
| 1409 | } |
| 1410 | case VERTEX_FORMAT_SBYTE2_INT: |
| 1411 | { |
| 1412 | static const VertexFormat format(GL_BYTE, GL_FALSE, 2, true); |
| 1413 | return format; |
| 1414 | } |
| 1415 | case VERTEX_FORMAT_SBYTE3_INT: |
| 1416 | { |
| 1417 | static const VertexFormat format(GL_BYTE, GL_FALSE, 3, true); |
| 1418 | return format; |
| 1419 | } |
| 1420 | case VERTEX_FORMAT_SBYTE4_INT: |
| 1421 | { |
| 1422 | static const VertexFormat format(GL_BYTE, GL_FALSE, 4, true); |
| 1423 | return format; |
| 1424 | } |
| 1425 | case VERTEX_FORMAT_UBYTE1_INT: |
| 1426 | { |
| 1427 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 1, true); |
| 1428 | return format; |
| 1429 | } |
| 1430 | case VERTEX_FORMAT_UBYTE2_INT: |
| 1431 | { |
| 1432 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 2, true); |
| 1433 | return format; |
| 1434 | } |
| 1435 | case VERTEX_FORMAT_UBYTE3_INT: |
| 1436 | { |
| 1437 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 3, true); |
| 1438 | return format; |
| 1439 | } |
| 1440 | case VERTEX_FORMAT_UBYTE4_INT: |
| 1441 | { |
| 1442 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 4, true); |
| 1443 | return format; |
| 1444 | } |
| 1445 | case VERTEX_FORMAT_SSHORT1_INT: |
| 1446 | { |
| 1447 | static const VertexFormat format(GL_SHORT, GL_FALSE, 1, true); |
| 1448 | return format; |
| 1449 | } |
| 1450 | case VERTEX_FORMAT_SSHORT2_INT: |
| 1451 | { |
| 1452 | static const VertexFormat format(GL_SHORT, GL_FALSE, 2, true); |
| 1453 | return format; |
| 1454 | } |
| 1455 | case VERTEX_FORMAT_SSHORT3_INT: |
| 1456 | { |
| 1457 | static const VertexFormat format(GL_SHORT, GL_FALSE, 3, true); |
| 1458 | return format; |
| 1459 | } |
| 1460 | case VERTEX_FORMAT_SSHORT4_INT: |
| 1461 | { |
| 1462 | static const VertexFormat format(GL_SHORT, GL_FALSE, 4, true); |
| 1463 | return format; |
| 1464 | } |
| 1465 | case VERTEX_FORMAT_USHORT1_INT: |
| 1466 | { |
| 1467 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 1, true); |
| 1468 | return format; |
| 1469 | } |
| 1470 | case VERTEX_FORMAT_USHORT2_INT: |
| 1471 | { |
| 1472 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 2, true); |
| 1473 | return format; |
| 1474 | } |
| 1475 | case VERTEX_FORMAT_USHORT3_INT: |
| 1476 | { |
| 1477 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 3, true); |
| 1478 | return format; |
| 1479 | } |
| 1480 | case VERTEX_FORMAT_USHORT4_INT: |
| 1481 | { |
| 1482 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 4, true); |
| 1483 | return format; |
| 1484 | } |
| 1485 | case VERTEX_FORMAT_SINT1_INT: |
| 1486 | { |
| 1487 | static const VertexFormat format(GL_INT, GL_FALSE, 1, true); |
| 1488 | return format; |
| 1489 | } |
| 1490 | case VERTEX_FORMAT_SINT2_INT: |
| 1491 | { |
| 1492 | static const VertexFormat format(GL_INT, GL_FALSE, 2, true); |
| 1493 | return format; |
| 1494 | } |
| 1495 | case VERTEX_FORMAT_SINT3_INT: |
| 1496 | { |
| 1497 | static const VertexFormat format(GL_INT, GL_FALSE, 3, true); |
| 1498 | return format; |
| 1499 | } |
| 1500 | case VERTEX_FORMAT_SINT4_INT: |
| 1501 | { |
| 1502 | static const VertexFormat format(GL_INT, GL_FALSE, 4, true); |
| 1503 | return format; |
| 1504 | } |
| 1505 | case VERTEX_FORMAT_UINT1_INT: |
| 1506 | { |
| 1507 | static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 1, true); |
| 1508 | return format; |
| 1509 | } |
| 1510 | case VERTEX_FORMAT_UINT2_INT: |
| 1511 | { |
| 1512 | static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 2, true); |
| 1513 | return format; |
| 1514 | } |
| 1515 | case VERTEX_FORMAT_UINT3_INT: |
| 1516 | { |
| 1517 | static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 3, true); |
| 1518 | return format; |
| 1519 | } |
| 1520 | case VERTEX_FORMAT_UINT4_INT: |
| 1521 | { |
| 1522 | static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 4, true); |
| 1523 | return format; |
| 1524 | } |
| 1525 | case VERTEX_FORMAT_FIXED1: |
| 1526 | { |
| 1527 | static const VertexFormat format(GL_FIXED, GL_FALSE, 1, false); |
| 1528 | return format; |
| 1529 | } |
| 1530 | case VERTEX_FORMAT_FIXED2: |
| 1531 | { |
| 1532 | static const VertexFormat format(GL_FIXED, GL_FALSE, 2, false); |
| 1533 | return format; |
| 1534 | } |
| 1535 | case VERTEX_FORMAT_FIXED3: |
| 1536 | { |
| 1537 | static const VertexFormat format(GL_FIXED, GL_FALSE, 3, false); |
| 1538 | return format; |
| 1539 | } |
| 1540 | case VERTEX_FORMAT_FIXED4: |
| 1541 | { |
| 1542 | static const VertexFormat format(GL_FIXED, GL_FALSE, 4, false); |
| 1543 | return format; |
| 1544 | } |
| 1545 | case VERTEX_FORMAT_HALF1: |
| 1546 | { |
| 1547 | static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 1, false); |
| 1548 | return format; |
| 1549 | } |
| 1550 | case VERTEX_FORMAT_HALF2: |
| 1551 | { |
| 1552 | static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 2, false); |
| 1553 | return format; |
| 1554 | } |
| 1555 | case VERTEX_FORMAT_HALF3: |
| 1556 | { |
| 1557 | static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 3, false); |
| 1558 | return format; |
| 1559 | } |
| 1560 | case VERTEX_FORMAT_HALF4: |
| 1561 | { |
| 1562 | static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 4, false); |
| 1563 | return format; |
| 1564 | } |
| 1565 | case VERTEX_FORMAT_FLOAT1: |
| 1566 | { |
| 1567 | static const VertexFormat format(GL_FLOAT, GL_FALSE, 1, false); |
| 1568 | return format; |
| 1569 | } |
| 1570 | case VERTEX_FORMAT_FLOAT2: |
| 1571 | { |
| 1572 | static const VertexFormat format(GL_FLOAT, GL_FALSE, 2, false); |
| 1573 | return format; |
| 1574 | } |
| 1575 | case VERTEX_FORMAT_FLOAT3: |
| 1576 | { |
| 1577 | static const VertexFormat format(GL_FLOAT, GL_FALSE, 3, false); |
| 1578 | return format; |
| 1579 | } |
| 1580 | case VERTEX_FORMAT_FLOAT4: |
| 1581 | { |
| 1582 | static const VertexFormat format(GL_FLOAT, GL_FALSE, 4, false); |
| 1583 | return format; |
| 1584 | } |
| 1585 | case VERTEX_FORMAT_SINT210: |
| 1586 | { |
| 1587 | static const VertexFormat format(GL_INT_2_10_10_10_REV, GL_FALSE, 4, false); |
| 1588 | return format; |
| 1589 | } |
| 1590 | case VERTEX_FORMAT_UINT210: |
| 1591 | { |
| 1592 | static const VertexFormat format(GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE, 4, false); |
| 1593 | return format; |
| 1594 | } |
| 1595 | case VERTEX_FORMAT_SINT210_NORM: |
| 1596 | { |
| 1597 | static const VertexFormat format(GL_INT_2_10_10_10_REV, GL_TRUE, 4, false); |
| 1598 | return format; |
| 1599 | } |
| 1600 | case VERTEX_FORMAT_UINT210_NORM: |
| 1601 | { |
| 1602 | static const VertexFormat format(GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 4, false); |
| 1603 | return format; |
| 1604 | } |
| 1605 | case VERTEX_FORMAT_SINT210_INT: |
| 1606 | { |
| 1607 | static const VertexFormat format(GL_INT_2_10_10_10_REV, GL_FALSE, 4, true); |
| 1608 | return format; |
| 1609 | } |
| 1610 | case VERTEX_FORMAT_UINT210_INT: |
| 1611 | { |
| 1612 | static const VertexFormat format(GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE, 4, true); |
| 1613 | return format; |
| 1614 | } |
| 1615 | default: |
| 1616 | { |
| 1617 | static const VertexFormat format(GL_NONE, GL_FALSE, 0, false); |
| 1618 | return format; |
| 1619 | } |
| 1620 | } |
| 1621 | } |
| 1622 | |
| 1623 | VertexFormat::VertexFormat(GLenum typeIn, GLboolean normalizedIn, GLuint componentsIn, bool pureIntegerIn) |
| 1624 | : type(typeIn), |
| 1625 | normalized(normalizedIn), |
| 1626 | components(componentsIn), |
| 1627 | pureInteger(pureIntegerIn) |
| 1628 | { |
| 1629 | // float -> !normalized |
| 1630 | ASSERT(!(type == GL_FLOAT || type == GL_HALF_FLOAT || type == GL_FIXED) || normalized == GL_FALSE); |
| 1631 | } |
| 1632 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1633 | } |