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