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 | |
Jamie Madill | 6a6b09c | 2017-01-12 21:52:29 +0000 | [diff] [blame] | 9 | #include "libANGLE/formatutils.h" |
Yuly Novikov | d73f852 | 2017-01-13 17:48:57 -0500 | [diff] [blame] | 10 | |
| 11 | #include "common/mathutil.h" |
Geoff Lang | 2b5420c | 2014-11-19 14:20:15 -0500 | [diff] [blame] | 12 | #include "libANGLE/Context.h" |
| 13 | #include "libANGLE/Framebuffer.h" |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 14 | |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 15 | using namespace angle; |
| 16 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 17 | namespace gl |
| 18 | { |
| 19 | |
| 20 | // ES2 requires that format is equal to internal format at all glTex*Image2D entry points and the implementation |
| 21 | // can decide the true, sized, internal format. The ES2FormatMap determines the internal format for all valid |
| 22 | // format and type combinations. |
Jamie Madill | ed4d342 | 2016-10-03 15:45:35 -0400 | [diff] [blame] | 23 | GLenum GetSizedFormatInternal(GLenum format, GLenum type); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 24 | |
Jamie Madill | ed4d342 | 2016-10-03 15:45:35 -0400 | [diff] [blame] | 25 | namespace |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 26 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 27 | using InternalFormatInfoMap = |
| 28 | std::unordered_map<GLenum, std::unordered_map<GLenum, InternalFormat>>; |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 29 | |
| 30 | } // anonymous namespace |
| 31 | |
| 32 | FormatType::FormatType() : format(GL_NONE), type(GL_NONE) |
| 33 | { |
| 34 | } |
| 35 | |
| 36 | FormatType::FormatType(GLenum format_, GLenum type_) : format(format_), type(type_) |
| 37 | { |
| 38 | } |
| 39 | |
| 40 | bool FormatType::operator<(const FormatType &other) const |
| 41 | { |
| 42 | if (format != other.format) |
| 43 | return format < other.format; |
| 44 | return type < other.type; |
| 45 | } |
| 46 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 47 | Type::Type() |
| 48 | : bytes(0), |
Olli Etuaho | 11ffe1b | 2015-03-24 17:28:18 +0200 | [diff] [blame] | 49 | bytesShift(0), |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 50 | specialInterpretation(false) |
Geoff Lang | fe28ca0 | 2013-06-04 10:10:48 -0400 | [diff] [blame] | 51 | { |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 52 | } |
| 53 | |
Olli Etuaho | 31f8f4f | 2015-03-25 16:03:57 +0200 | [diff] [blame] | 54 | static Type GenTypeInfo(GLuint bytes, bool specialInterpretation) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 55 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 56 | Type info; |
| 57 | info.bytes = bytes; |
Olli Etuaho | 11ffe1b | 2015-03-24 17:28:18 +0200 | [diff] [blame] | 58 | GLuint i = 0; |
| 59 | while ((1u << i) < bytes) |
| 60 | { |
| 61 | ++i; |
| 62 | } |
| 63 | info.bytesShift = i; |
| 64 | ASSERT((1u << info.bytesShift) == bytes); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 65 | info.specialInterpretation = specialInterpretation; |
Olli Etuaho | 31f8f4f | 2015-03-25 16:03:57 +0200 | [diff] [blame] | 66 | return info; |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 67 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 68 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 69 | bool operator<(const Type& a, const Type& b) |
| 70 | { |
| 71 | return memcmp(&a, &b, sizeof(Type)) < 0; |
| 72 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 73 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 74 | // Information about internal formats |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 75 | static bool AlwaysSupported(const Version &, const Extensions &) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 76 | { |
Geoff Lang | 493daf5 | 2014-07-03 13:38:44 -0400 | [diff] [blame] | 77 | return true; |
| 78 | } |
| 79 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 80 | static bool NeverSupported(const Version &, const Extensions &) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 81 | { |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 82 | return false; |
| 83 | } |
| 84 | |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 85 | template <GLuint minCoreGLMajorVersion, GLuint minCoreGLMinorVersion> |
| 86 | static bool RequireES(const Version &clientVersion, const Extensions &) |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 87 | { |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 88 | return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion); |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 89 | } |
| 90 | |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 91 | // Pointer to a boolean memeber of the Extensions struct |
| 92 | typedef bool(Extensions::*ExtensionBool); |
| 93 | |
| 94 | // Check support for a single extension |
| 95 | template <ExtensionBool bool1> |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 96 | static bool RequireExt(const Version &, const Extensions &extensions) |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 97 | { |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 98 | return extensions.*bool1; |
| 99 | } |
| 100 | |
| 101 | // Check for a minimum client version or a single extension |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 102 | template <GLuint minCoreGLMajorVersion, GLuint minCoreGLMinorVersion, ExtensionBool bool1> |
| 103 | static bool RequireESOrExt(const Version &clientVersion, const Extensions &extensions) |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 104 | { |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 105 | return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion) || |
| 106 | extensions.*bool1; |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | // Check for a minimum client version or two extensions |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 110 | template <GLuint minCoreGLMajorVersion, |
| 111 | GLuint minCoreGLMinorVersion, |
| 112 | ExtensionBool bool1, |
| 113 | ExtensionBool bool2> |
| 114 | static bool RequireESOrExtAndExt(const Version &clientVersion, const Extensions &extensions) |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 115 | { |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 116 | return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion) || |
| 117 | (extensions.*bool1 && extensions.*bool2); |
Geoff Lang | abce762 | 2014-09-19 16:13:00 -0400 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | // Check for a minimum client version or at least one of two extensions |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 121 | template <GLuint minCoreGLMajorVersion, |
| 122 | GLuint minCoreGLMinorVersion, |
| 123 | ExtensionBool bool1, |
| 124 | ExtensionBool bool2> |
| 125 | static bool RequireESOrExtOrExt(const Version &clientVersion, const Extensions &extensions) |
Geoff Lang | abce762 | 2014-09-19 16:13:00 -0400 | [diff] [blame] | 126 | { |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 127 | return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion) || |
| 128 | extensions.*bool1 || extensions.*bool2; |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | // Check support for two extensions |
| 132 | template <ExtensionBool bool1, ExtensionBool bool2> |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 133 | static bool RequireExtAndExt(const Version &, const Extensions &extensions) |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 134 | { |
Geoff Lang | abce762 | 2014-09-19 16:13:00 -0400 | [diff] [blame] | 135 | return extensions.*bool1 && extensions.*bool2; |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 136 | } |
| 137 | |
Geoff Lang | 60ad73d | 2015-10-23 10:08:44 -0400 | [diff] [blame] | 138 | // Check support for either of two extensions |
| 139 | template <ExtensionBool bool1, ExtensionBool bool2> |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 140 | static bool RequireExtOrExt(const Version &, const Extensions &extensions) |
Geoff Lang | 60ad73d | 2015-10-23 10:08:44 -0400 | [diff] [blame] | 141 | { |
| 142 | return extensions.*bool1 || extensions.*bool2; |
| 143 | } |
| 144 | |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 145 | // Special function for half float formats with three or four channels. |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 146 | static bool HalfFloatSupport(const Version &clientVersion, const Extensions &extensions) |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 147 | { |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 148 | return clientVersion >= Version(3, 0) || extensions.textureHalfFloat; |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 149 | } |
| 150 | |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 151 | static bool HalfFloatRGBRenderableSupport(const Version &clientVersion, |
| 152 | const Extensions &extensions) |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 153 | { |
| 154 | return HalfFloatSupport(clientVersion, extensions) && extensions.colorBufferHalfFloat; |
| 155 | } |
| 156 | |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 157 | static bool HalfFloatRGBARenderableSupport(const Version &clientVersion, |
| 158 | const Extensions &extensions) |
| 159 | { |
| 160 | return HalfFloatSupport(clientVersion, extensions) && |
| 161 | (extensions.colorBufferHalfFloat || extensions.colorBufferFloat); |
| 162 | } |
| 163 | |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 164 | // Special function for half float formats with one or two channels. |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 165 | |
| 166 | // R16F, RG16F |
| 167 | static bool HalfFloatRGSupport(const Version &clientVersion, const Extensions &extensions) |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 168 | { |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 169 | return clientVersion >= Version(3, 0) || (extensions.textureHalfFloat && extensions.textureRG); |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 170 | } |
| 171 | |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 172 | // R16F, RG16F |
| 173 | static bool HalfFloatRGRenderableSupport(const Version &clientVersion, const Extensions &extensions) |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 174 | { |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 175 | // It's unclear if EXT_color_buffer_half_float gives renderability to non-OES half float |
| 176 | // textures |
| 177 | return HalfFloatRGSupport(clientVersion, extensions) && |
| 178 | (extensions.colorBufferHalfFloat || extensions.colorBufferFloat); |
| 179 | } |
| 180 | |
| 181 | // RED + HALF_FLOAT_OES, RG + HALF_FLOAT_OES |
| 182 | static bool UnsizedHalfFloatOESRGSupport(const Version &, const Extensions &extensions) |
| 183 | { |
| 184 | return extensions.textureHalfFloat && extensions.textureRG; |
| 185 | } |
| 186 | |
| 187 | // RED + HALF_FLOAT_OES, RG + HALF_FLOAT_OES |
| 188 | static bool UnsizedHalfFloatOESRGRenderableSupport(const Version &clientVersion, |
| 189 | const Extensions &extensions) |
| 190 | { |
| 191 | return UnsizedHalfFloatOESRGSupport(clientVersion, extensions) && |
| 192 | extensions.colorBufferHalfFloat; |
| 193 | } |
| 194 | |
| 195 | // RGB + HALF_FLOAT_OES, RGBA + HALF_FLOAT_OES |
| 196 | static bool UnsizedHalfFloatOESSupport(const Version &clientVersion, const Extensions &extensions) |
| 197 | { |
| 198 | return extensions.textureHalfFloat; |
| 199 | } |
| 200 | |
| 201 | // RGB + HALF_FLOAT_OES, RGBA + HALF_FLOAT_OES |
| 202 | static bool UnsizedHalfFloatOESRenderableSupport(const Version &clientVersion, |
| 203 | const Extensions &extensions) |
| 204 | { |
| 205 | return UnsizedHalfFloatOESSupport(clientVersion, extensions) && extensions.colorBufferHalfFloat; |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | // Special function for float formats with three or four channels. |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 209 | |
| 210 | // RGB32F, RGBA32F |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 211 | static bool FloatSupport(const Version &clientVersion, const Extensions &extensions) |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 212 | { |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 213 | return clientVersion >= Version(3, 0) || extensions.textureFloat; |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 214 | } |
| 215 | |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 216 | // RGB32F |
| 217 | static bool FloatRGBRenderableSupport(const Version &clientVersion, const Extensions &extensions) |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 218 | { |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 219 | return FloatSupport(clientVersion, extensions) && extensions.colorBufferFloatRGB; |
| 220 | } |
| 221 | |
| 222 | // RGBA32F |
| 223 | static bool FloatRGBARenderableSupport(const Version &clientVersion, const Extensions &extensions) |
| 224 | { |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 225 | return FloatSupport(clientVersion, extensions) && |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 226 | (extensions.colorBufferFloat || extensions.colorBufferFloatRGBA); |
| 227 | } |
| 228 | |
| 229 | // RGB + FLOAT, RGBA + FLOAT |
| 230 | static bool UnsizedFloatSupport(const Version &clientVersion, const Extensions &extensions) |
| 231 | { |
| 232 | return extensions.textureFloat; |
| 233 | } |
| 234 | |
| 235 | // RGB + FLOAT |
| 236 | static bool UnsizedFloatRGBRenderableSupport(const Version &clientVersion, |
| 237 | const Extensions &extensions) |
| 238 | { |
| 239 | return UnsizedFloatSupport(clientVersion, extensions) && extensions.colorBufferFloatRGB; |
| 240 | } |
| 241 | |
| 242 | // RGBA + FLOAT |
| 243 | static bool UnsizedFloatRGBARenderableSupport(const Version &clientVersion, |
| 244 | const Extensions &extensions) |
| 245 | { |
| 246 | return UnsizedFloatSupport(clientVersion, extensions) && |
| 247 | (extensions.colorBufferFloatRGBA || extensions.colorBufferFloat); |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | // Special function for float formats with one or two channels. |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 251 | |
| 252 | // R32F, RG32F |
| 253 | static bool FloatRGSupport(const Version &clientVersion, const Extensions &extensions) |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 254 | { |
Geoff Lang | eb66a6e | 2016-10-31 13:06:12 -0400 | [diff] [blame] | 255 | return clientVersion >= Version(3, 0) || (extensions.textureFloat && extensions.textureRG); |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 256 | } |
| 257 | |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 258 | // R32F, RG32F |
| 259 | static bool FloatRGRenderableSupport(const Version &clientVersion, const Extensions &extensions) |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 260 | { |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 261 | return FloatRGSupport(clientVersion, extensions) && extensions.colorBufferFloat; |
| 262 | } |
| 263 | |
| 264 | // RED + FLOAT, RG + FLOAT |
| 265 | static bool UnsizedFloatRGSupport(const Version &clientVersion, const Extensions &extensions) |
| 266 | { |
| 267 | return extensions.textureFloat && extensions.textureRG; |
| 268 | } |
| 269 | |
| 270 | // RED + FLOAT, RG + FLOAT |
| 271 | static bool UnsizedFloatRGRenderableSupport(const Version &clientVersion, |
| 272 | const Extensions &extensions) |
| 273 | { |
| 274 | return FloatRGSupport(clientVersion, extensions) && extensions.colorBufferFloat; |
Jamie Madill | cd08973 | 2015-12-17 09:53:09 -0500 | [diff] [blame] | 275 | } |
| 276 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 277 | InternalFormat::InternalFormat() |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 278 | : internalFormat(GL_NONE), |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 279 | sized(false), |
| 280 | sizedInternalFormat(GL_NONE), |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 281 | redBits(0), |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 282 | greenBits(0), |
| 283 | blueBits(0), |
| 284 | luminanceBits(0), |
| 285 | alphaBits(0), |
| 286 | sharedBits(0), |
| 287 | depthBits(0), |
| 288 | stencilBits(0), |
| 289 | pixelBytes(0), |
| 290 | componentCount(0), |
Corentin Wallez | bc99bb6 | 2015-05-14 17:42:20 -0400 | [diff] [blame] | 291 | compressed(false), |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 292 | compressedBlockWidth(0), |
| 293 | compressedBlockHeight(0), |
| 294 | format(GL_NONE), |
| 295 | type(GL_NONE), |
| 296 | componentType(GL_NONE), |
| 297 | colorEncoding(GL_NONE), |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 298 | textureSupport(NeverSupported), |
| 299 | renderSupport(NeverSupported), |
| 300 | filterSupport(NeverSupported) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 301 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 302 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 303 | |
Jamie Madill | acf2f3a | 2017-11-21 19:22:44 -0500 | [diff] [blame] | 304 | InternalFormat::InternalFormat(const InternalFormat &other) = default; |
| 305 | |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 306 | bool InternalFormat::isLUMA() const |
| 307 | { |
| 308 | return ((redBits + greenBits + blueBits + depthBits + stencilBits) == 0 && |
| 309 | (luminanceBits + alphaBits) > 0); |
| 310 | } |
| 311 | |
Geoff Lang | f607c60 | 2016-09-21 11:46:48 -0400 | [diff] [blame] | 312 | GLenum InternalFormat::getReadPixelsFormat() const |
| 313 | { |
| 314 | return format; |
| 315 | } |
| 316 | |
Geoff Lang | c71ea66 | 2017-09-26 17:06:02 -0400 | [diff] [blame] | 317 | GLenum InternalFormat::getReadPixelsType(const Version &version) const |
Geoff Lang | f607c60 | 2016-09-21 11:46:48 -0400 | [diff] [blame] | 318 | { |
| 319 | switch (type) |
| 320 | { |
| 321 | case GL_HALF_FLOAT: |
Geoff Lang | c71ea66 | 2017-09-26 17:06:02 -0400 | [diff] [blame] | 322 | case GL_HALF_FLOAT_OES: |
| 323 | if (version < Version(3, 0)) |
| 324 | { |
| 325 | // The internal format may have a type of GL_HALF_FLOAT but when exposing this type |
| 326 | // as the IMPLEMENTATION_READ_TYPE, only HALF_FLOAT_OES is allowed by |
| 327 | // OES_texture_half_float. HALF_FLOAT becomes core in ES3 and is acceptable to use |
| 328 | // as an IMPLEMENTATION_READ_TYPE. |
| 329 | return GL_HALF_FLOAT_OES; |
| 330 | } |
| 331 | else |
| 332 | { |
| 333 | return GL_HALF_FLOAT; |
| 334 | } |
Geoff Lang | f607c60 | 2016-09-21 11:46:48 -0400 | [diff] [blame] | 335 | |
| 336 | default: |
| 337 | return type; |
| 338 | } |
| 339 | } |
| 340 | |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 341 | bool InternalFormat::isRequiredRenderbufferFormat(const Version &version) const |
| 342 | { |
| 343 | // GLES 3.0.5 section 4.4.2.2: |
| 344 | // "Implementations are required to support the same internal formats for renderbuffers as the |
| 345 | // required formats for textures enumerated in section 3.8.3.1, with the exception of the color |
| 346 | // formats labelled "texture-only"." |
| 347 | if (!sized || compressed) |
| 348 | { |
| 349 | return false; |
| 350 | } |
| 351 | |
| 352 | // Luma formats. |
| 353 | if (isLUMA()) |
| 354 | { |
| 355 | return false; |
| 356 | } |
| 357 | |
| 358 | // Depth/stencil formats. |
| 359 | if (depthBits > 0 || stencilBits > 0) |
| 360 | { |
| 361 | // GLES 2.0.25 table 4.5. |
| 362 | // GLES 3.0.5 section 3.8.3.1. |
| 363 | // GLES 3.1 table 8.14. |
| 364 | |
| 365 | // Required formats in all versions. |
| 366 | switch (internalFormat) |
| 367 | { |
| 368 | case GL_DEPTH_COMPONENT16: |
| 369 | case GL_STENCIL_INDEX8: |
| 370 | // Note that STENCIL_INDEX8 is not mentioned in GLES 3.0.5 section 3.8.3.1, but it |
| 371 | // is in section 4.4.2.2. |
| 372 | return true; |
| 373 | default: |
| 374 | break; |
| 375 | } |
| 376 | if (version.major < 3) |
| 377 | { |
| 378 | return false; |
| 379 | } |
| 380 | // Required formats in GLES 3.0 and up. |
| 381 | switch (internalFormat) |
| 382 | { |
| 383 | case GL_DEPTH_COMPONENT32F: |
| 384 | case GL_DEPTH_COMPONENT24: |
| 385 | case GL_DEPTH32F_STENCIL8: |
| 386 | case GL_DEPTH24_STENCIL8: |
| 387 | return true; |
| 388 | default: |
| 389 | return false; |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | // RGBA formats. |
| 394 | // GLES 2.0.25 table 4.5. |
| 395 | // GLES 3.0.5 section 3.8.3.1. |
| 396 | // GLES 3.1 table 8.13. |
| 397 | |
| 398 | // Required formats in all versions. |
| 399 | switch (internalFormat) |
| 400 | { |
| 401 | case GL_RGBA4: |
| 402 | case GL_RGB5_A1: |
| 403 | case GL_RGB565: |
| 404 | return true; |
| 405 | default: |
| 406 | break; |
| 407 | } |
| 408 | if (version.major < 3) |
| 409 | { |
| 410 | return false; |
| 411 | } |
| 412 | |
| 413 | if (format == GL_BGRA_EXT) |
| 414 | { |
| 415 | return false; |
| 416 | } |
| 417 | |
| 418 | switch (componentType) |
| 419 | { |
| 420 | case GL_SIGNED_NORMALIZED: |
| 421 | case GL_FLOAT: |
| 422 | return false; |
| 423 | case GL_UNSIGNED_INT: |
| 424 | case GL_INT: |
| 425 | // Integer RGB formats are not required renderbuffer formats. |
| 426 | if (alphaBits == 0 && blueBits != 0) |
| 427 | { |
| 428 | return false; |
| 429 | } |
| 430 | // All integer R and RG formats are required. |
| 431 | // Integer RGBA formats including RGB10_A2_UI are required. |
| 432 | return true; |
| 433 | case GL_UNSIGNED_NORMALIZED: |
| 434 | if (internalFormat == GL_SRGB8) |
| 435 | { |
| 436 | return false; |
| 437 | } |
| 438 | return true; |
| 439 | default: |
| 440 | UNREACHABLE(); |
Nico Weber | b5db2b4 | 2018-02-12 15:31:56 -0500 | [diff] [blame] | 441 | #if !UNREACHABLE_IS_NORETURN |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 442 | return false; |
Nico Weber | b5db2b4 | 2018-02-12 15:31:56 -0500 | [diff] [blame] | 443 | #endif |
Olli Etuaho | 50c562d | 2017-06-06 14:43:30 +0300 | [diff] [blame] | 444 | } |
| 445 | } |
| 446 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 447 | Format::Format(GLenum internalFormat) : Format(GetSizedInternalFormatInfo(internalFormat)) |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 448 | { |
| 449 | } |
| 450 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 451 | Format::Format(const InternalFormat &internalFormat) : info(&internalFormat) |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 452 | { |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 453 | } |
| 454 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 455 | Format::Format(GLenum internalFormat, GLenum type) |
| 456 | : info(&GetInternalFormatInfo(internalFormat, type)) |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 457 | { |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | Format::Format(const Format &other) = default; |
| 461 | Format &Format::operator=(const Format &other) = default; |
| 462 | |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 463 | bool Format::valid() const |
| 464 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 465 | return info->internalFormat != GL_NONE; |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | // static |
| 469 | bool Format::SameSized(const Format &a, const Format &b) |
| 470 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 471 | return a.info->sizedInternalFormat == b.info->sizedInternalFormat; |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 472 | } |
| 473 | |
Kenneth Russell | 6938285 | 2017-07-21 16:38:44 -0400 | [diff] [blame] | 474 | static GLenum EquivalentBlitInternalFormat(GLenum internalformat) |
| 475 | { |
| 476 | // BlitFramebuffer works if the color channels are identically |
| 477 | // sized, even if there is a swizzle (for example, blitting from a |
| 478 | // multisampled RGBA8 renderbuffer to a BGRA8 texture). This could |
| 479 | // be expanded and/or autogenerated if that is found necessary. |
| 480 | if (internalformat == GL_BGRA8_EXT) |
| 481 | return GL_RGBA8; |
| 482 | return internalformat; |
| 483 | } |
| 484 | |
| 485 | // static |
| 486 | bool Format::EquivalentForBlit(const Format &a, const Format &b) |
| 487 | { |
| 488 | return (EquivalentBlitInternalFormat(a.info->sizedInternalFormat) == |
| 489 | EquivalentBlitInternalFormat(b.info->sizedInternalFormat)); |
| 490 | } |
| 491 | |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 492 | // static |
| 493 | Format Format::Invalid() |
| 494 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 495 | static Format invalid(GL_NONE, GL_NONE); |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 496 | return invalid; |
| 497 | } |
| 498 | |
Yuly Novikov | d73f852 | 2017-01-13 17:48:57 -0500 | [diff] [blame] | 499 | std::ostream &operator<<(std::ostream &os, const Format &fmt) |
| 500 | { |
| 501 | // TODO(ynovikov): return string representation when available |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 502 | return FmtHexShort(os, fmt.info->sizedInternalFormat); |
Yuly Novikov | d73f852 | 2017-01-13 17:48:57 -0500 | [diff] [blame] | 503 | } |
| 504 | |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 505 | bool InternalFormat::operator==(const InternalFormat &other) const |
| 506 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 507 | // We assume all internal formats are unique if they have the same internal format and type |
| 508 | return internalFormat == other.internalFormat && type == other.type; |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 509 | } |
| 510 | |
| 511 | bool InternalFormat::operator!=(const InternalFormat &other) const |
| 512 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 513 | return !(*this == other); |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 514 | } |
| 515 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 516 | void InsertFormatInfo(InternalFormatInfoMap *map, const InternalFormat &formatInfo) |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 517 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 518 | ASSERT(!formatInfo.sized || (*map).count(formatInfo.internalFormat) == 0); |
| 519 | ASSERT((*map)[formatInfo.internalFormat].count(formatInfo.type) == 0); |
| 520 | (*map)[formatInfo.internalFormat][formatInfo.type] = formatInfo; |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 521 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 522 | |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 523 | void AddRGBAFormat(InternalFormatInfoMap *map, |
| 524 | GLenum internalFormat, |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 525 | bool sized, |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 526 | GLuint red, |
| 527 | GLuint green, |
| 528 | GLuint blue, |
| 529 | GLuint alpha, |
| 530 | GLuint shared, |
| 531 | GLenum format, |
| 532 | GLenum type, |
| 533 | GLenum componentType, |
| 534 | bool srgb, |
| 535 | InternalFormat::SupportCheckFunction textureSupport, |
| 536 | InternalFormat::SupportCheckFunction renderSupport, |
| 537 | InternalFormat::SupportCheckFunction filterSupport) |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 538 | { |
| 539 | InternalFormat formatInfo; |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 540 | formatInfo.internalFormat = internalFormat; |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 541 | formatInfo.sized = sized; |
| 542 | formatInfo.sizedInternalFormat = |
| 543 | sized ? internalFormat : GetSizedFormatInternal(internalFormat, type); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 544 | formatInfo.redBits = red; |
| 545 | formatInfo.greenBits = green; |
| 546 | formatInfo.blueBits = blue; |
| 547 | formatInfo.alphaBits = alpha; |
| 548 | formatInfo.sharedBits = shared; |
| 549 | formatInfo.pixelBytes = (red + green + blue + alpha + shared) / 8; |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 550 | formatInfo.componentCount = |
| 551 | ((red > 0) ? 1 : 0) + ((green > 0) ? 1 : 0) + ((blue > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 552 | formatInfo.format = format; |
| 553 | formatInfo.type = type; |
| 554 | formatInfo.componentType = componentType; |
| 555 | formatInfo.colorEncoding = (srgb ? GL_SRGB : GL_LINEAR); |
| 556 | formatInfo.textureSupport = textureSupport; |
| 557 | formatInfo.renderSupport = renderSupport; |
| 558 | formatInfo.filterSupport = filterSupport; |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 559 | |
| 560 | InsertFormatInfo(map, formatInfo); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 561 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 562 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 563 | static void AddLUMAFormat(InternalFormatInfoMap *map, |
| 564 | GLenum internalFormat, |
| 565 | bool sized, |
| 566 | GLuint luminance, |
| 567 | GLuint alpha, |
| 568 | GLenum format, |
| 569 | GLenum type, |
| 570 | GLenum componentType, |
| 571 | InternalFormat::SupportCheckFunction textureSupport, |
| 572 | InternalFormat::SupportCheckFunction renderSupport, |
| 573 | InternalFormat::SupportCheckFunction filterSupport) |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 574 | { |
| 575 | InternalFormat formatInfo; |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 576 | formatInfo.internalFormat = internalFormat; |
| 577 | formatInfo.sized = sized; |
| 578 | formatInfo.sizedInternalFormat = |
| 579 | sized ? internalFormat : GetSizedFormatInternal(internalFormat, type); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 580 | formatInfo.luminanceBits = luminance; |
| 581 | formatInfo.alphaBits = alpha; |
| 582 | formatInfo.pixelBytes = (luminance + alpha) / 8; |
| 583 | formatInfo.componentCount = ((luminance > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0); |
| 584 | formatInfo.format = format; |
| 585 | formatInfo.type = type; |
| 586 | formatInfo.componentType = componentType; |
| 587 | formatInfo.colorEncoding = GL_LINEAR; |
| 588 | formatInfo.textureSupport = textureSupport; |
| 589 | formatInfo.renderSupport = renderSupport; |
| 590 | formatInfo.filterSupport = filterSupport; |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 591 | |
| 592 | InsertFormatInfo(map, formatInfo); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 593 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 594 | |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 595 | void AddDepthStencilFormat(InternalFormatInfoMap *map, |
| 596 | GLenum internalFormat, |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 597 | bool sized, |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 598 | GLuint depthBits, |
| 599 | GLuint stencilBits, |
| 600 | GLuint unusedBits, |
| 601 | GLenum format, |
| 602 | GLenum type, |
| 603 | GLenum componentType, |
| 604 | InternalFormat::SupportCheckFunction textureSupport, |
| 605 | InternalFormat::SupportCheckFunction renderSupport, |
| 606 | InternalFormat::SupportCheckFunction filterSupport) |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 607 | { |
| 608 | InternalFormat formatInfo; |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 609 | formatInfo.internalFormat = internalFormat; |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 610 | formatInfo.sized = sized; |
| 611 | formatInfo.sizedInternalFormat = |
| 612 | sized ? internalFormat : GetSizedFormatInternal(internalFormat, type); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 613 | formatInfo.depthBits = depthBits; |
| 614 | formatInfo.stencilBits = stencilBits; |
| 615 | formatInfo.pixelBytes = (depthBits + stencilBits + unusedBits) / 8; |
| 616 | formatInfo.componentCount = ((depthBits > 0) ? 1 : 0) + ((stencilBits > 0) ? 1 : 0); |
| 617 | formatInfo.format = format; |
| 618 | formatInfo.type = type; |
| 619 | formatInfo.componentType = componentType; |
| 620 | formatInfo.colorEncoding = GL_LINEAR; |
| 621 | formatInfo.textureSupport = textureSupport; |
| 622 | formatInfo.renderSupport = renderSupport; |
| 623 | formatInfo.filterSupport = filterSupport; |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 624 | |
| 625 | InsertFormatInfo(map, formatInfo); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 626 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 627 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 628 | void AddCompressedFormat(InternalFormatInfoMap *map, |
| 629 | GLenum internalFormat, |
| 630 | GLuint compressedBlockWidth, |
| 631 | GLuint compressedBlockHeight, |
| 632 | GLuint compressedBlockSize, |
| 633 | GLuint componentCount, |
| 634 | GLenum format, |
| 635 | GLenum type, |
| 636 | bool srgb, |
| 637 | InternalFormat::SupportCheckFunction textureSupport, |
| 638 | InternalFormat::SupportCheckFunction renderSupport, |
| 639 | InternalFormat::SupportCheckFunction filterSupport) |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 640 | { |
| 641 | InternalFormat formatInfo; |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 642 | formatInfo.internalFormat = internalFormat; |
| 643 | formatInfo.sized = true; |
| 644 | formatInfo.sizedInternalFormat = internalFormat; |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 645 | formatInfo.compressedBlockWidth = compressedBlockWidth; |
| 646 | formatInfo.compressedBlockHeight = compressedBlockHeight; |
| 647 | formatInfo.pixelBytes = compressedBlockSize / 8; |
| 648 | formatInfo.componentCount = componentCount; |
| 649 | formatInfo.format = format; |
| 650 | formatInfo.type = type; |
| 651 | formatInfo.componentType = GL_UNSIGNED_NORMALIZED; |
| 652 | formatInfo.colorEncoding = (srgb ? GL_SRGB : GL_LINEAR); |
| 653 | formatInfo.compressed = true; |
| 654 | formatInfo.textureSupport = textureSupport; |
| 655 | formatInfo.renderSupport = renderSupport; |
| 656 | formatInfo.filterSupport = filterSupport; |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 657 | |
| 658 | InsertFormatInfo(map, formatInfo); |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 659 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 660 | |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 661 | static InternalFormatInfoMap BuildInternalFormatInfoMap() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 662 | { |
| 663 | InternalFormatInfoMap map; |
| 664 | |
| 665 | // From ES 3.0.1 spec, table 3.12 |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 666 | map[GL_NONE][GL_NONE] = InternalFormat(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 667 | |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 668 | // clang-format off |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 669 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 670 | // | Internal format |sized| R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Renderable | Filterable | |
| 671 | AddRGBAFormat(&map, GL_R8, true, 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::textureRG>, RequireESOrExt<3, 0, &Extensions::textureRG>, AlwaysSupported); |
| 672 | AddRGBAFormat(&map, GL_R8_SNORM, true, 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3, 0>, NeverSupported, AlwaysSupported); |
| 673 | AddRGBAFormat(&map, GL_RG8, true, 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::textureRG>, RequireESOrExt<3, 0, &Extensions::textureRG>, AlwaysSupported); |
| 674 | AddRGBAFormat(&map, GL_RG8_SNORM, true, 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3, 0>, NeverSupported, AlwaysSupported); |
| 675 | AddRGBAFormat(&map, GL_RGB8, true, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::rgb8rgba8>, RequireESOrExt<3, 0, &Extensions::rgb8rgba8>, AlwaysSupported); |
| 676 | AddRGBAFormat(&map, GL_RGB8_SNORM, true, 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3, 0>, NeverSupported, AlwaysSupported); |
| 677 | AddRGBAFormat(&map, GL_RGB565, true, 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, RequireES<2, 0>, RequireES<2, 0>, AlwaysSupported); |
| 678 | AddRGBAFormat(&map, GL_RGBA4, true, 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, RequireES<2, 0>, RequireES<2, 0>, AlwaysSupported); |
| 679 | AddRGBAFormat(&map, GL_RGB5_A1, true, 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, RequireES<2, 0>, RequireES<2, 0>, AlwaysSupported); |
| 680 | AddRGBAFormat(&map, GL_RGBA8, true, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::rgb8rgba8>, RequireESOrExt<3, 0, &Extensions::rgb8rgba8>, AlwaysSupported); |
| 681 | AddRGBAFormat(&map, GL_RGBA8_SNORM, true, 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, RequireES<3, 0>, NeverSupported, AlwaysSupported); |
| 682 | AddRGBAFormat(&map, GL_RGB10_A2, true, 10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireES<3, 0>, RequireES<3, 0>, AlwaysSupported); |
| 683 | AddRGBAFormat(&map, GL_RGB10_A2UI, true, 10, 10, 10, 2, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
| 684 | AddRGBAFormat(&map, GL_SRGB8, true, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireESOrExt<3, 0, &Extensions::sRGB>, NeverSupported, AlwaysSupported); |
| 685 | AddRGBAFormat(&map, GL_SRGB8_ALPHA8, true, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireESOrExt<3, 0, &Extensions::sRGB>, RequireESOrExt<3, 0, &Extensions::sRGB>, AlwaysSupported); |
| 686 | AddRGBAFormat(&map, GL_RGB9_E5, true, 9, 9, 9, 0, 5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT, false, RequireES<3, 0>, NeverSupported, AlwaysSupported); |
| 687 | AddRGBAFormat(&map, GL_R8I, true, 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
| 688 | AddRGBAFormat(&map, GL_R8UI, true, 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
| 689 | AddRGBAFormat(&map, GL_R16I, true, 16, 0, 0, 0, 0, GL_RED_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
| 690 | AddRGBAFormat(&map, GL_R16UI, true, 16, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
| 691 | AddRGBAFormat(&map, GL_R32I, true, 32, 0, 0, 0, 0, GL_RED_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
| 692 | AddRGBAFormat(&map, GL_R32UI, true, 32, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
| 693 | AddRGBAFormat(&map, GL_RG8I, true, 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
| 694 | AddRGBAFormat(&map, GL_RG8UI, true, 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
| 695 | AddRGBAFormat(&map, GL_RG16I, true, 16, 16, 0, 0, 0, GL_RG_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
| 696 | AddRGBAFormat(&map, GL_RG16UI, true, 16, 16, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
| 697 | AddRGBAFormat(&map, GL_RG32I, true, 32, 32, 0, 0, 0, GL_RG_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
| 698 | AddRGBAFormat(&map, GL_R11F_G11F_B10F, true, 11, 11, 10, 0, 0, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_FLOAT, false, RequireES<3, 0>, RequireExt<&Extensions::colorBufferFloat>, AlwaysSupported); |
| 699 | AddRGBAFormat(&map, GL_RG32UI, true, 32, 32, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
| 700 | AddRGBAFormat(&map, GL_RGB8I, true, 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 701 | AddRGBAFormat(&map, GL_RGB8UI, true, 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 702 | AddRGBAFormat(&map, GL_RGB16I, true, 16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 703 | AddRGBAFormat(&map, GL_RGB16UI, true, 16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 704 | AddRGBAFormat(&map, GL_RGB32I, true, 32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 705 | AddRGBAFormat(&map, GL_RGB32UI, true, 32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 706 | AddRGBAFormat(&map, GL_RGBA8I, true, 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
| 707 | AddRGBAFormat(&map, GL_RGBA8UI, true, 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
| 708 | AddRGBAFormat(&map, GL_RGBA16I, true, 16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
| 709 | AddRGBAFormat(&map, GL_RGBA16UI, true, 16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
| 710 | AddRGBAFormat(&map, GL_RGBA32I, true, 32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
| 711 | AddRGBAFormat(&map, GL_RGBA32UI, true, 32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, RequireES<3, 0>, NeverSupported); |
Jamie Madill | a3944d4 | 2016-07-22 22:13:26 -0400 | [diff] [blame] | 712 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 713 | AddRGBAFormat(&map, GL_BGRA8_EXT, true, 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported); |
| 714 | AddRGBAFormat(&map, GL_BGRA4_ANGLEX, true, 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); |
| 715 | AddRGBAFormat(&map, GL_BGR5_A1_ANGLEX, true, 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] | 716 | |
Olli Etuaho | ceffd20 | 2018-01-08 16:39:45 +0200 | [diff] [blame] | 717 | // Special format that is used for D3D textures that are used within ANGLE via the |
| 718 | // EGL_ANGLE_d3d_texture_client_buffer extension. We don't allow uploading texture images with |
| 719 | // this format, but textures in this format can be created from D3D textures, and filtering them |
| 720 | // and rendering to them is allowed. |
| 721 | AddRGBAFormat(&map, GL_BGRA8_SRGB_ANGLEX, true, 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, NeverSupported, AlwaysSupported, AlwaysSupported); |
| 722 | |
Jamie Madill | ec0b580 | 2016-07-04 13:11:59 -0400 | [diff] [blame] | 723 | // Special format which is not really supported, so always false for all supports. |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 724 | AddRGBAFormat(&map, GL_BGR565_ANGLEX, true, 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] | 725 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 726 | // Floating point renderability and filtering is provided by OES_texture_float and OES_texture_half_float |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 727 | // | Internal format |sized| D |S | Format | Type | Comp | SRGB | Texture supported | Renderable | Filterable | |
| 728 | // | | | | | | | type | | | | | |
| 729 | AddRGBAFormat(&map, GL_R16F, true, 16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT, GL_FLOAT, false, HalfFloatRGSupport, HalfFloatRGRenderableSupport, RequireESOrExt<3, 0, &Extensions::textureHalfFloatLinear>); |
| 730 | AddRGBAFormat(&map, GL_RG16F, true, 16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT, GL_FLOAT, false, HalfFloatRGSupport, HalfFloatRGRenderableSupport, RequireESOrExt<3, 0, &Extensions::textureHalfFloatLinear>); |
| 731 | AddRGBAFormat(&map, GL_RGB16F, true, 16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT, GL_FLOAT, false, HalfFloatSupport, HalfFloatRGBRenderableSupport, RequireESOrExt<3, 0, &Extensions::textureHalfFloatLinear>); |
| 732 | AddRGBAFormat(&map, GL_RGBA16F, true, 16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT, GL_FLOAT, false, HalfFloatSupport, HalfFloatRGBARenderableSupport, RequireESOrExt<3, 0, &Extensions::textureHalfFloatLinear>); |
| 733 | AddRGBAFormat(&map, GL_R32F, true, 32, 0, 0, 0, 0, GL_RED, GL_FLOAT, GL_FLOAT, false, FloatRGSupport, FloatRGRenderableSupport, RequireExt<&Extensions::textureFloatLinear> ); |
| 734 | AddRGBAFormat(&map, GL_RG32F, true, 32, 32, 0, 0, 0, GL_RG, GL_FLOAT, GL_FLOAT, false, FloatRGSupport, FloatRGRenderableSupport, RequireExt<&Extensions::textureFloatLinear> ); |
| 735 | AddRGBAFormat(&map, GL_RGB32F, true, 32, 32, 32, 0, 0, GL_RGB, GL_FLOAT, GL_FLOAT, false, FloatSupport, FloatRGBRenderableSupport, RequireExt<&Extensions::textureFloatLinear> ); |
| 736 | AddRGBAFormat(&map, GL_RGBA32F, true, 32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT, GL_FLOAT, false, FloatSupport, FloatRGBARenderableSupport, RequireExt<&Extensions::textureFloatLinear> ); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 737 | |
| 738 | // Depth stencil formats |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 739 | // | Internal format |sized| D |S | X | Format | Type | Component type | Supported | Renderable | Filterable | |
| 740 | AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT16, true, 16, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, RequireES<2, 0>, RequireES<2, 0>, RequireESOrExt<3, 0, &Extensions::depthTextures>); |
| 741 | AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT24, true, 24, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireES<3, 0>, RequireES<3, 0>, RequireESOrExt<3, 0, &Extensions::depthTextures>); |
| 742 | AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT32F, true, 32, 0, 0, GL_DEPTH_COMPONENT, GL_FLOAT, GL_FLOAT, RequireES<3, 0>, RequireES<3, 0>, RequireESOrExt<3, 0, &Extensions::depthTextures>); |
| 743 | AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT32_OES, true, 32, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireExtOrExt<&Extensions::depthTextures, &Extensions::depth32>, RequireExtOrExt<&Extensions::depthTextures, &Extensions::depth32>, AlwaysSupported ); |
| 744 | AddDepthStencilFormat(&map, GL_DEPTH24_STENCIL8, true, 24, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_UNSIGNED_NORMALIZED, RequireESOrExt<3, 0, &Extensions::depthTextures>, RequireESOrExtOrExt<3, 0, &Extensions::depthTextures, &Extensions::packedDepthStencil>, AlwaysSupported ); |
| 745 | AddDepthStencilFormat(&map, GL_DEPTH32F_STENCIL8, true, 32, 8, 24, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_FLOAT, RequireES<3, 0>, RequireES<3, 0>, AlwaysSupported ); |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 746 | // 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] | 747 | |
| 748 | // Luminance alpha formats |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 749 | // | Internal format |sized| L | A | Format | Type | Component type | Supported | Renderable | Filterable | |
| 750 | AddLUMAFormat(&map, GL_ALPHA8_EXT, true, 0, 8, GL_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, NeverSupported, AlwaysSupported); |
| 751 | AddLUMAFormat(&map, GL_LUMINANCE8_EXT, true, 8, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, NeverSupported, AlwaysSupported); |
| 752 | AddLUMAFormat(&map, GL_LUMINANCE8_ALPHA8_EXT, true, 8, 8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, NeverSupported, AlwaysSupported); |
| 753 | AddLUMAFormat(&map, GL_ALPHA16F_EXT, true, 0, 16, GL_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, NeverSupported, RequireESOrExt<3, 0, &Extensions::textureHalfFloatLinear>); |
| 754 | AddLUMAFormat(&map, GL_LUMINANCE16F_EXT, true, 16, 0, GL_LUMINANCE, GL_HALF_FLOAT_OES, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, NeverSupported, RequireESOrExt<3, 0, &Extensions::textureHalfFloatLinear>); |
| 755 | AddLUMAFormat(&map, GL_LUMINANCE_ALPHA16F_EXT, true, 16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, NeverSupported, RequireESOrExt<3, 0, &Extensions::textureHalfFloatLinear>); |
| 756 | AddLUMAFormat(&map, GL_ALPHA32F_EXT, true, 0, 32, GL_ALPHA, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, NeverSupported, RequireExt<&Extensions::textureFloatLinear>); |
| 757 | AddLUMAFormat(&map, GL_LUMINANCE32F_EXT, true, 32, 0, GL_LUMINANCE, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, NeverSupported, RequireExt<&Extensions::textureFloatLinear>); |
| 758 | AddLUMAFormat(&map, GL_LUMINANCE_ALPHA32F_EXT, true, 32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, NeverSupported, RequireExt<&Extensions::textureFloatLinear>); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 759 | |
| 760 | // Compressed formats, From ES 3.0.1 spec, table 3.16 |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 761 | // | Internal format |W |H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable | |
| 762 | AddCompressedFormat(&map, GL_COMPRESSED_R11_EAC, 4, 4, 64, 1, GL_RED, GL_UNSIGNED_BYTE, false, RequireES<3, 0>, NeverSupported, AlwaysSupported); |
| 763 | AddCompressedFormat(&map, GL_COMPRESSED_SIGNED_R11_EAC, 4, 4, 64, 1, GL_RED, GL_UNSIGNED_BYTE, false, RequireES<3, 0>, NeverSupported, AlwaysSupported); |
| 764 | AddCompressedFormat(&map, GL_COMPRESSED_RG11_EAC, 4, 4, 128, 2, GL_RG, GL_UNSIGNED_BYTE, false, RequireES<3, 0>, NeverSupported, AlwaysSupported); |
| 765 | AddCompressedFormat(&map, GL_COMPRESSED_SIGNED_RG11_EAC, 4, 4, 128, 2, GL_RG, GL_UNSIGNED_BYTE, false, RequireES<3, 0>, NeverSupported, AlwaysSupported); |
| 766 | AddCompressedFormat(&map, GL_COMPRESSED_RGB8_ETC2, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, false, RequireES<3, 0>, NeverSupported, AlwaysSupported); |
| 767 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ETC2, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, true, RequireES<3, 0>, NeverSupported, AlwaysSupported); |
| 768 | AddCompressedFormat(&map, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, false, RequireES<3, 0>, NeverSupported, AlwaysSupported); |
| 769 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, true, RequireES<3, 0>, NeverSupported, AlwaysSupported); |
| 770 | AddCompressedFormat(&map, GL_COMPRESSED_RGBA8_ETC2_EAC, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireES<3, 0>, NeverSupported, AlwaysSupported); |
| 771 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireES<3, 0>, NeverSupported, AlwaysSupported); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 772 | |
| 773 | // From GL_EXT_texture_compression_dxt1 |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 774 | // | Internal format |W |H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable | |
| 775 | AddCompressedFormat(&map, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT1>, NeverSupported, AlwaysSupported); |
| 776 | AddCompressedFormat(&map, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 4, 4, 64, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT1>, NeverSupported, AlwaysSupported); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 777 | |
| 778 | // From GL_ANGLE_texture_compression_dxt3 |
Geoff Lang | 86f8116 | 2017-10-30 15:10:45 -0400 | [diff] [blame] | 779 | AddCompressedFormat(&map, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT3>, NeverSupported, AlwaysSupported); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 780 | |
| 781 | // From GL_ANGLE_texture_compression_dxt5 |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 782 | AddCompressedFormat(&map, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT5>, NeverSupported, AlwaysSupported); |
Geoff Lang | 6ea6f94 | 2015-09-11 13:11:22 -0400 | [diff] [blame] | 783 | |
| 784 | // From GL_OES_compressed_ETC1_RGB8_texture |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 785 | AddCompressedFormat(&map, GL_ETC1_RGB8_OES, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::compressedETC1RGB8Texture>, NeverSupported, AlwaysSupported); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 786 | |
Kai Ninomiya | 02f075c | 2016-12-22 14:55:46 -0800 | [diff] [blame] | 787 | // From GL_EXT_texture_compression_s3tc_srgb |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 788 | // | Internal format |W |H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable | |
| 789 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::textureCompressionS3TCsRGB>, NeverSupported, AlwaysSupported); |
| 790 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, 4, 4, 64, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::textureCompressionS3TCsRGB>, NeverSupported, AlwaysSupported); |
| 791 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::textureCompressionS3TCsRGB>, NeverSupported, AlwaysSupported); |
| 792 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::textureCompressionS3TCsRGB>, NeverSupported, AlwaysSupported); |
Kai Ninomiya | 02f075c | 2016-12-22 14:55:46 -0800 | [diff] [blame] | 793 | |
Geoff Lang | 60ad73d | 2015-10-23 10:08:44 -0400 | [diff] [blame] | 794 | // From KHR_texture_compression_astc_hdr |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 795 | // | Internal format | W | H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable | |
| 796 | AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_4x4_KHR, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 797 | AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_5x4_KHR, 5, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 798 | AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_5x5_KHR, 5, 5, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 799 | AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_6x5_KHR, 6, 5, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 800 | AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_6x6_KHR, 6, 6, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 801 | AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_8x5_KHR, 8, 5, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 802 | AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_8x6_KHR, 8, 6, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 803 | AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_8x8_KHR, 8, 8, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 804 | AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_10x5_KHR, 10, 5, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 805 | AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_10x6_KHR, 10, 6, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 806 | AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_10x8_KHR, 10, 8, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 807 | AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_10x10_KHR, 10, 10, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 808 | AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_12x10_KHR, 12, 10, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 809 | AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_12x12_KHR, 12, 12, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
Geoff Lang | 60ad73d | 2015-10-23 10:08:44 -0400 | [diff] [blame] | 810 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 811 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 812 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, 5, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 813 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, 5, 5, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 814 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, 6, 5, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 815 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, 6, 6, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 816 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, 8, 5, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 817 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, 8, 6, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 818 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, 8, 8, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 819 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, 10, 5, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 820 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, 10, 6, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 821 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, 10, 8, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 822 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, 10, 10, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 823 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, 12, 10, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
| 824 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, 12, 12, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported); |
Geoff Lang | 60ad73d | 2015-10-23 10:08:44 -0400 | [diff] [blame] | 825 | |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 826 | // For STENCIL_INDEX8 we chose a normalized component type for the following reasons: |
| 827 | // - Multisampled buffer are disallowed for non-normalized integer component types and we want to support it for STENCIL_INDEX8 |
| 828 | // - All other stencil formats (all depth-stencil) are either float or normalized |
| 829 | // - It affects only validation of internalformat in RenderbufferStorageMultisample. |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 830 | // | Internal format |sized|D |S |X | Format | Type | Component type | Supported | Renderable | Filterable | |
| 831 | AddDepthStencilFormat(&map, GL_STENCIL_INDEX8, true, 0, 8, 0, GL_STENCIL, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireES<2, 0>, RequireES<2, 0>, NeverSupported); |
Minmin Gong | e3939b9 | 2015-12-01 15:36:51 -0800 | [diff] [blame] | 832 | |
| 833 | // From GL_ANGLE_lossy_etc_decode |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 834 | // | Internal format |W |H |BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable | |
| 835 | AddCompressedFormat(&map, GL_ETC1_RGB8_LOSSY_DECODE_ANGLE, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::lossyETCDecode>, NeverSupported, AlwaysSupported); |
| 836 | AddCompressedFormat(&map, GL_COMPRESSED_RGB8_LOSSY_DECODE_ETC2_ANGLE, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::lossyETCDecode>, NeverSupported, AlwaysSupported); |
| 837 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_LOSSY_DECODE_ETC2_ANGLE, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::lossyETCDecode>, NeverSupported, AlwaysSupported); |
| 838 | AddCompressedFormat(&map, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE, 4, 4, 64, 3, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::lossyETCDecode>, NeverSupported, AlwaysSupported); |
| 839 | AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE, 4, 4, 64, 3, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::lossyETCDecode>, NeverSupported, AlwaysSupported); |
Minmin Gong | e3939b9 | 2015-12-01 15:36:51 -0800 | [diff] [blame] | 840 | |
Vincent Lang | 25ab451 | 2016-05-13 18:13:59 +0200 | [diff] [blame] | 841 | // From GL_EXT_texture_norm16 |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 842 | // | Internal format |sized| R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Renderable | Filterable | |
| 843 | AddRGBAFormat(&map, GL_R16_EXT, true, 16, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, RequireExt<&Extensions::textureNorm16>, AlwaysSupported); |
| 844 | AddRGBAFormat(&map, GL_R16_SNORM_EXT, true, 16, 0, 0, 0, 0, GL_RED, GL_SHORT, GL_SIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, NeverSupported, AlwaysSupported); |
| 845 | AddRGBAFormat(&map, GL_RG16_EXT, true, 16, 16, 0, 0, 0, GL_RG, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, RequireExt<&Extensions::textureNorm16>, AlwaysSupported); |
| 846 | AddRGBAFormat(&map, GL_RG16_SNORM_EXT, true, 16, 16, 0, 0, 0, GL_RG, GL_SHORT, GL_SIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, NeverSupported, AlwaysSupported); |
| 847 | AddRGBAFormat(&map, GL_RGB16_EXT, true, 16, 16, 16, 0, 0, GL_RGB, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, NeverSupported, AlwaysSupported); |
| 848 | AddRGBAFormat(&map, GL_RGB16_SNORM_EXT, true, 16, 16, 16, 0, 0, GL_RGB, GL_SHORT, GL_SIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, NeverSupported, AlwaysSupported); |
| 849 | AddRGBAFormat(&map, GL_RGBA16_EXT, true, 16, 16, 16, 16, 0, GL_RGBA, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, RequireExt<&Extensions::textureNorm16>, AlwaysSupported); |
| 850 | AddRGBAFormat(&map, GL_RGBA16_SNORM_EXT, true, 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] | 851 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 852 | // Unsized formats |
| 853 | // | Internal format |sized | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Renderable | Filterable | |
Geoff Lang | 8d4db1f | 2017-06-02 14:32:01 -0400 | [diff] [blame] | 854 | AddRGBAFormat(&map, GL_RED, false, 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureRG>, AlwaysSupported, AlwaysSupported); |
Geoff Lang | dbcced8 | 2017-06-06 15:55:54 -0400 | [diff] [blame] | 855 | AddRGBAFormat(&map, GL_RED, false, 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported ); |
Geoff Lang | 8d4db1f | 2017-06-02 14:32:01 -0400 | [diff] [blame] | 856 | AddRGBAFormat(&map, GL_RG, false, 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureRG>, AlwaysSupported, AlwaysSupported); |
Geoff Lang | dbcced8 | 2017-06-06 15:55:54 -0400 | [diff] [blame] | 857 | AddRGBAFormat(&map, GL_RG, false, 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported ); |
Geoff Lang | d84a00b | 2017-10-27 17:27:26 -0400 | [diff] [blame] | 858 | AddRGBAFormat(&map, GL_RGB, false, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireES<2, 0>, AlwaysSupported, AlwaysSupported); |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 859 | AddRGBAFormat(&map, GL_RGB, false, 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, RequireES<2, 0>, RequireES<2, 0>, AlwaysSupported); |
Geoff Lang | dbcced8 | 2017-06-06 15:55:54 -0400 | [diff] [blame] | 860 | AddRGBAFormat(&map, GL_RGB, false, 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported ); |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 861 | AddRGBAFormat(&map, GL_RGBA, false, 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, RequireES<2, 0>, RequireES<2, 0>, AlwaysSupported); |
| 862 | AddRGBAFormat(&map, GL_RGBA, false, 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, RequireES<2, 0>, RequireES<2, 0>, AlwaysSupported); |
| 863 | AddRGBAFormat(&map, GL_RGBA, false, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireES<2, 0>, RequireES<2, 0>, AlwaysSupported); |
| 864 | AddRGBAFormat(&map, GL_RGBA, false, 10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireES<2, 0>, RequireES<2, 0>, AlwaysSupported); |
Geoff Lang | dbcced8 | 2017-06-06 15:55:54 -0400 | [diff] [blame] | 865 | AddRGBAFormat(&map, GL_RGBA, false, 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported ); |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 866 | AddRGBAFormat(&map, GL_SRGB, false, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireExt<&Extensions::sRGB>, NeverSupported, AlwaysSupported); |
| 867 | AddRGBAFormat(&map, GL_SRGB_ALPHA_EXT, false, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireExt<&Extensions::sRGB>, RequireExt<&Extensions::sRGB>, AlwaysSupported); |
| 868 | |
| 869 | AddRGBAFormat(&map, GL_BGRA_EXT, false, 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported); |
| 870 | |
| 871 | // Unsized integer formats |
| 872 | // |Internal format |sized | R | G | B | A |S | Format | Type | Component type | SRGB | Texture | Renderable | Filterable | |
| 873 | AddRGBAFormat(&map, GL_RED_INTEGER, false, 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 874 | AddRGBAFormat(&map, GL_RED_INTEGER, false, 8, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 875 | AddRGBAFormat(&map, GL_RED_INTEGER, false, 16, 0, 0, 0, 0, GL_RED_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 876 | AddRGBAFormat(&map, GL_RED_INTEGER, false, 16, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 877 | AddRGBAFormat(&map, GL_RED_INTEGER, false, 32, 0, 0, 0, 0, GL_RED_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 878 | AddRGBAFormat(&map, GL_RED_INTEGER, false, 32, 0, 0, 0, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 879 | AddRGBAFormat(&map, GL_RG_INTEGER, false, 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 880 | AddRGBAFormat(&map, GL_RG_INTEGER, false, 8, 8, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 881 | AddRGBAFormat(&map, GL_RG_INTEGER, false, 16, 16, 0, 0, 0, GL_RG_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 882 | AddRGBAFormat(&map, GL_RG_INTEGER, false, 16, 16, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 883 | AddRGBAFormat(&map, GL_RG_INTEGER, false, 32, 32, 0, 0, 0, GL_RG_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 884 | AddRGBAFormat(&map, GL_RG_INTEGER, false, 32, 32, 0, 0, 0, GL_RG_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 885 | AddRGBAFormat(&map, GL_RGB_INTEGER, false, 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 886 | AddRGBAFormat(&map, GL_RGB_INTEGER, false, 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 887 | AddRGBAFormat(&map, GL_RGB_INTEGER, false, 16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 888 | AddRGBAFormat(&map, GL_RGB_INTEGER, false, 16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 889 | AddRGBAFormat(&map, GL_RGB_INTEGER, false, 32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 890 | AddRGBAFormat(&map, GL_RGB_INTEGER, false, 32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 891 | AddRGBAFormat(&map, GL_RGBA_INTEGER, false, 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 892 | AddRGBAFormat(&map, GL_RGBA_INTEGER, false, 8, 8, 8, 8, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 893 | AddRGBAFormat(&map, GL_RGBA_INTEGER, false, 16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 894 | AddRGBAFormat(&map, GL_RGBA_INTEGER, false, 16, 16, 16, 16, 0, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 895 | AddRGBAFormat(&map, GL_RGBA_INTEGER, false, 32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 896 | AddRGBAFormat(&map, GL_RGBA_INTEGER, false, 32, 32, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 897 | AddRGBAFormat(&map, GL_RGBA_INTEGER, false, 10, 10, 10, 2, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported); |
| 898 | |
| 899 | // Unsized floating point formats |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 900 | // |Internal format |sized | R | G | B | A |S | Format | Type | Comp | SRGB | Texture supported | Renderable | Filterable | |
| 901 | AddRGBAFormat(&map, GL_RED, false, 16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT, GL_FLOAT, false, NeverSupported, NeverSupported, NeverSupported ); |
| 902 | AddRGBAFormat(&map, GL_RG, false, 16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT, GL_FLOAT, false, NeverSupported, NeverSupported, NeverSupported ); |
| 903 | AddRGBAFormat(&map, GL_RGB, false, 16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT, GL_FLOAT, false, NeverSupported, NeverSupported, NeverSupported ); |
| 904 | AddRGBAFormat(&map, GL_RGBA, false, 16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT, GL_FLOAT, false, NeverSupported, NeverSupported, NeverSupported ); |
| 905 | AddRGBAFormat(&map, GL_RED, false, 16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT_OES, GL_FLOAT, false, UnsizedHalfFloatOESRGSupport, UnsizedHalfFloatOESRGRenderableSupport, RequireESOrExt<3, 0, &Extensions::textureHalfFloatLinear>); |
| 906 | AddRGBAFormat(&map, GL_RG, false, 16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT_OES, GL_FLOAT, false, UnsizedHalfFloatOESRGSupport, UnsizedHalfFloatOESRGRenderableSupport, RequireESOrExt<3, 0, &Extensions::textureHalfFloatLinear>); |
| 907 | AddRGBAFormat(&map, GL_RGB, false, 16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT_OES, GL_FLOAT, false, UnsizedHalfFloatOESSupport, UnsizedHalfFloatOESRenderableSupport, RequireESOrExt<3, 0, &Extensions::textureHalfFloatLinear>); |
| 908 | AddRGBAFormat(&map, GL_RGBA, false, 16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT_OES, GL_FLOAT, false, UnsizedHalfFloatOESSupport, UnsizedHalfFloatOESRenderableSupport, RequireESOrExt<3, 0, &Extensions::textureHalfFloatLinear>); |
| 909 | AddRGBAFormat(&map, GL_RED, false, 32, 0, 0, 0, 0, GL_RED, GL_FLOAT, GL_FLOAT, false, UnsizedFloatRGSupport, UnsizedFloatRGRenderableSupport, RequireExt<&Extensions::textureFloatLinear> ); |
| 910 | AddRGBAFormat(&map, GL_RG, false, 32, 32, 0, 0, 0, GL_RG, GL_FLOAT, GL_FLOAT, false, UnsizedFloatRGSupport, UnsizedFloatRGRenderableSupport, RequireExt<&Extensions::textureFloatLinear> ); |
| 911 | AddRGBAFormat(&map, GL_RGB, false, 32, 32, 32, 0, 0, GL_RGB, GL_FLOAT, GL_FLOAT, false, UnsizedFloatSupport, UnsizedFloatRGBRenderableSupport, RequireExt<&Extensions::textureFloatLinear> ); |
Geoff Lang | dbcced8 | 2017-06-06 15:55:54 -0400 | [diff] [blame] | 912 | AddRGBAFormat(&map, GL_RGB, false, 9, 9, 9, 0, 5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, GL_FLOAT, false, NeverSupported, NeverSupported, NeverSupported ); |
| 913 | AddRGBAFormat(&map, GL_RGB, false, 11, 11, 10, 0, 0, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, GL_FLOAT, false, NeverSupported, NeverSupported, NeverSupported ); |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 914 | AddRGBAFormat(&map, GL_RGBA, false, 32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT, GL_FLOAT, false, UnsizedFloatSupport, UnsizedFloatRGBARenderableSupport, RequireExt<&Extensions::textureFloatLinear> ); |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 915 | |
| 916 | // Unsized luminance alpha formats |
Geoff Lang | 677bb6f | 2017-04-05 12:40:40 -0400 | [diff] [blame] | 917 | // | Internal format |sized | L | A | Format | Type | Component type | Supported | Renderable | Filterable | |
| 918 | AddLUMAFormat(&map, GL_ALPHA, false, 0, 8, GL_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireES<2, 0>, NeverSupported, AlwaysSupported ); |
| 919 | AddLUMAFormat(&map, GL_LUMINANCE, false, 8, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireES<2, 0>, NeverSupported, AlwaysSupported ); |
| 920 | AddLUMAFormat(&map, GL_LUMINANCE_ALPHA, false, 8, 8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireES<2, 0>, NeverSupported, AlwaysSupported ); |
| 921 | AddLUMAFormat(&map, GL_ALPHA, false, 0, 16, GL_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT, RequireExt<&Extensions::textureHalfFloat>, NeverSupported, RequireExt<&Extensions::textureHalfFloatLinear>); |
| 922 | AddLUMAFormat(&map, GL_LUMINANCE, false, 16, 0, GL_LUMINANCE, GL_HALF_FLOAT_OES, GL_FLOAT, RequireExt<&Extensions::textureHalfFloat>, NeverSupported, RequireExt<&Extensions::textureHalfFloatLinear>); |
| 923 | AddLUMAFormat(&map, GL_LUMINANCE_ALPHA ,false, 16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT, RequireExt<&Extensions::textureHalfFloat>, NeverSupported, RequireExt<&Extensions::textureHalfFloatLinear>); |
| 924 | AddLUMAFormat(&map, GL_ALPHA, false, 0, 32, GL_ALPHA, GL_FLOAT, GL_FLOAT, RequireExt<&Extensions::textureFloat>, NeverSupported, RequireExt<&Extensions::textureFloatLinear> ); |
| 925 | AddLUMAFormat(&map, GL_LUMINANCE, false, 32, 0, GL_LUMINANCE, GL_FLOAT, GL_FLOAT, RequireExt<&Extensions::textureFloat>, NeverSupported, RequireExt<&Extensions::textureFloatLinear> ); |
| 926 | AddLUMAFormat(&map, GL_LUMINANCE_ALPHA, false, 32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_FLOAT, RequireExt<&Extensions::textureFloat>, NeverSupported, RequireExt<&Extensions::textureFloatLinear> ); |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 927 | |
| 928 | // Unsized depth stencil formats |
| 929 | // | Internal format |sized | D |S | X | Format | Type | Component type | Supported | Renderable | Filterable | |
| 930 | AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT, false, 16, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, RequireES<2, 0>, RequireES<2, 0>, AlwaysSupported); |
| 931 | AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT, false, 24, 0, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, GL_UNSIGNED_NORMALIZED, RequireES<2, 0>, RequireES<2, 0>, AlwaysSupported); |
| 932 | AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT, false, 32, 0, 0, GL_DEPTH_COMPONENT, GL_FLOAT, GL_FLOAT, RequireES<2, 0>, RequireES<2, 0>, AlwaysSupported); |
| 933 | AddDepthStencilFormat(&map, GL_DEPTH_STENCIL, false, 24, 8, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, GL_UNSIGNED_NORMALIZED, RequireESOrExt<3, 0, &Extensions::packedDepthStencil>, RequireESOrExt<3, 0, &Extensions::packedDepthStencil>, AlwaysSupported); |
| 934 | AddDepthStencilFormat(&map, GL_DEPTH_STENCIL, false, 32, 8, 24, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, GL_FLOAT, RequireESOrExt<3, 0, &Extensions::packedDepthStencil>, RequireESOrExt<3, 0, &Extensions::packedDepthStencil>, AlwaysSupported); |
| 935 | AddDepthStencilFormat(&map, GL_STENCIL, false, 0, 8, 0, GL_STENCIL, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireES<2, 0>, RequireES<2, 0>, NeverSupported); |
Geoff Lang | 9bbad18 | 2015-09-04 11:07:29 -0400 | [diff] [blame] | 936 | // clang-format on |
Corentin Wallez | e090264 | 2014-11-04 12:32:15 -0800 | [diff] [blame] | 937 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 938 | return map; |
| 939 | } |
| 940 | |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 941 | static const InternalFormatInfoMap &GetInternalFormatMap() |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 942 | { |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 943 | static const InternalFormatInfoMap formatMap = BuildInternalFormatInfoMap(); |
| 944 | return formatMap; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 945 | } |
| 946 | |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 947 | static FormatSet BuildAllSizedInternalFormatSet() |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 948 | { |
| 949 | FormatSet result; |
| 950 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 951 | for (const auto &internalFormat : GetInternalFormatMap()) |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 952 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 953 | for (const auto &type : internalFormat.second) |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 954 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 955 | if (type.second.sized) |
| 956 | { |
| 957 | // TODO(jmadill): Fix this hack. |
| 958 | if (internalFormat.first == GL_BGR565_ANGLEX) |
| 959 | continue; |
Jamie Madill | ec0b580 | 2016-07-04 13:11:59 -0400 | [diff] [blame] | 960 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 961 | result.insert(internalFormat.first); |
| 962 | } |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 963 | } |
| 964 | } |
| 965 | |
| 966 | return result; |
| 967 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 968 | |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 969 | const Type &GetTypeInfo(GLenum type) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 970 | { |
Olli Etuaho | 31f8f4f | 2015-03-25 16:03:57 +0200 | [diff] [blame] | 971 | switch (type) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 972 | { |
Olli Etuaho | 31f8f4f | 2015-03-25 16:03:57 +0200 | [diff] [blame] | 973 | case GL_UNSIGNED_BYTE: |
| 974 | case GL_BYTE: |
| 975 | { |
| 976 | static const Type info = GenTypeInfo(1, false); |
| 977 | return info; |
| 978 | } |
| 979 | case GL_UNSIGNED_SHORT: |
| 980 | case GL_SHORT: |
| 981 | case GL_HALF_FLOAT: |
| 982 | case GL_HALF_FLOAT_OES: |
| 983 | { |
| 984 | static const Type info = GenTypeInfo(2, false); |
| 985 | return info; |
| 986 | } |
| 987 | case GL_UNSIGNED_INT: |
| 988 | case GL_INT: |
| 989 | case GL_FLOAT: |
| 990 | { |
| 991 | static const Type info = GenTypeInfo(4, false); |
| 992 | return info; |
| 993 | } |
| 994 | case GL_UNSIGNED_SHORT_5_6_5: |
| 995 | case GL_UNSIGNED_SHORT_4_4_4_4: |
| 996 | case GL_UNSIGNED_SHORT_5_5_5_1: |
| 997 | case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT: |
| 998 | case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT: |
| 999 | { |
| 1000 | static const Type info = GenTypeInfo(2, true); |
| 1001 | return info; |
| 1002 | } |
| 1003 | case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 1004 | case GL_UNSIGNED_INT_24_8: |
| 1005 | case GL_UNSIGNED_INT_10F_11F_11F_REV: |
| 1006 | case GL_UNSIGNED_INT_5_9_9_9_REV: |
| 1007 | { |
| 1008 | ASSERT(GL_UNSIGNED_INT_24_8_OES == GL_UNSIGNED_INT_24_8); |
| 1009 | static const Type info = GenTypeInfo(4, true); |
| 1010 | return info; |
| 1011 | } |
| 1012 | case GL_FLOAT_32_UNSIGNED_INT_24_8_REV: |
| 1013 | { |
| 1014 | static const Type info = GenTypeInfo(8, true); |
| 1015 | return info; |
| 1016 | } |
| 1017 | default: |
| 1018 | { |
| 1019 | static const Type defaultInfo; |
| 1020 | return defaultInfo; |
| 1021 | } |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1022 | } |
| 1023 | } |
| 1024 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 1025 | const InternalFormat &GetSizedInternalFormatInfo(GLenum internalFormat) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1026 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 1027 | static const InternalFormat defaultInternalFormat; |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 1028 | const InternalFormatInfoMap &formatMap = GetInternalFormatMap(); |
Jamie Madill | ec0b580 | 2016-07-04 13:11:59 -0400 | [diff] [blame] | 1029 | auto iter = formatMap.find(internalFormat); |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 1030 | |
| 1031 | // Sized internal formats only have one type per entry |
| 1032 | if (iter == formatMap.end() || iter->second.size() != 1) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1033 | { |
Geoff Lang | 5d60138 | 2014-07-22 15:14:06 -0400 | [diff] [blame] | 1034 | return defaultInternalFormat; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1035 | } |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 1036 | |
| 1037 | const InternalFormat &internalFormatInfo = iter->second.begin()->second; |
| 1038 | if (!internalFormatInfo.sized) |
| 1039 | { |
| 1040 | return defaultInternalFormat; |
| 1041 | } |
| 1042 | |
| 1043 | return internalFormatInfo; |
| 1044 | } |
| 1045 | |
| 1046 | const InternalFormat &GetInternalFormatInfo(GLenum internalFormat, GLenum type) |
| 1047 | { |
| 1048 | static const InternalFormat defaultInternalFormat; |
| 1049 | const InternalFormatInfoMap &formatMap = GetInternalFormatMap(); |
| 1050 | |
| 1051 | auto internalFormatIter = formatMap.find(internalFormat); |
| 1052 | if (internalFormatIter == formatMap.end()) |
| 1053 | { |
| 1054 | return defaultInternalFormat; |
| 1055 | } |
| 1056 | |
| 1057 | // If the internal format is sized, simply return it without the type check. |
| 1058 | if (internalFormatIter->second.size() == 1 && internalFormatIter->second.begin()->second.sized) |
| 1059 | { |
| 1060 | return internalFormatIter->second.begin()->second; |
| 1061 | } |
| 1062 | |
| 1063 | auto typeIter = internalFormatIter->second.find(type); |
| 1064 | if (typeIter == internalFormatIter->second.end()) |
| 1065 | { |
| 1066 | return defaultInternalFormat; |
| 1067 | } |
| 1068 | |
| 1069 | return typeIter->second; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1070 | } |
| 1071 | |
Corentin Wallez | c5cacd6 | 2016-09-14 14:50:24 -0400 | [diff] [blame] | 1072 | GLuint InternalFormat::computePixelBytes(GLenum formatType) const |
| 1073 | { |
| 1074 | const auto &typeInfo = GetTypeInfo(formatType); |
| 1075 | GLuint components = typeInfo.specialInterpretation ? 1u : componentCount; |
| 1076 | return components * typeInfo.bytes; |
| 1077 | } |
| 1078 | |
Corentin Wallez | 886de36 | 2016-09-27 10:49:35 -0400 | [diff] [blame] | 1079 | ErrorOrResult<GLuint> InternalFormat::computeRowPitch(GLenum formatType, |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 1080 | GLsizei width, |
| 1081 | GLint alignment, |
| 1082 | GLint rowLength) const |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1083 | { |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 1084 | // Compressed images do not use pack/unpack parameters. |
| 1085 | if (compressed) |
| 1086 | { |
| 1087 | ASSERT(rowLength == 0); |
Jeff Gilbert | 4859035 | 2017-11-07 16:03:38 -0800 | [diff] [blame] | 1088 | return computeCompressedImageSize(Extents(width, 1, 1)); |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 1089 | } |
| 1090 | |
Geoff Lang | 3f23406 | 2016-07-13 15:35:45 -0400 | [diff] [blame] | 1091 | CheckedNumeric<GLuint> checkedWidth(rowLength > 0 ? rowLength : width); |
Corentin Wallez | c5cacd6 | 2016-09-14 14:50:24 -0400 | [diff] [blame] | 1092 | CheckedNumeric<GLuint> checkedRowBytes = checkedWidth * computePixelBytes(formatType); |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 1093 | |
| 1094 | ASSERT(alignment > 0 && isPow2(alignment)); |
| 1095 | CheckedNumeric<GLuint> checkedAlignment(alignment); |
| 1096 | auto aligned = rx::roundUp(checkedRowBytes, checkedAlignment); |
| 1097 | ANGLE_TRY_CHECKED_MATH(aligned); |
| 1098 | return aligned.ValueOrDie(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1099 | } |
| 1100 | |
Corentin Wallez | 0e48719 | 2016-10-03 16:30:38 -0400 | [diff] [blame] | 1101 | ErrorOrResult<GLuint> InternalFormat::computeDepthPitch(GLsizei height, |
| 1102 | GLint imageHeight, |
| 1103 | GLuint rowPitch) const |
| 1104 | { |
| 1105 | GLuint rows = |
| 1106 | (imageHeight > 0 ? static_cast<GLuint>(imageHeight) : static_cast<GLuint>(height)); |
| 1107 | CheckedNumeric<GLuint> checkedRowPitch(rowPitch); |
| 1108 | |
| 1109 | auto depthPitch = checkedRowPitch * rows; |
| 1110 | ANGLE_TRY_CHECKED_MATH(depthPitch); |
| 1111 | return depthPitch.ValueOrDie(); |
| 1112 | } |
| 1113 | |
Corentin Wallez | 886de36 | 2016-09-27 10:49:35 -0400 | [diff] [blame] | 1114 | ErrorOrResult<GLuint> InternalFormat::computeDepthPitch(GLenum formatType, |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 1115 | GLsizei width, |
| 1116 | GLsizei height, |
| 1117 | GLint alignment, |
| 1118 | GLint rowLength, |
| 1119 | GLint imageHeight) const |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1120 | { |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 1121 | GLuint rowPitch = 0; |
| 1122 | ANGLE_TRY_RESULT(computeRowPitch(formatType, width, alignment, rowLength), rowPitch); |
Corentin Wallez | 0e48719 | 2016-10-03 16:30:38 -0400 | [diff] [blame] | 1123 | return computeDepthPitch(height, imageHeight, rowPitch); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1124 | } |
| 1125 | |
Jeff Gilbert | 4859035 | 2017-11-07 16:03:38 -0800 | [diff] [blame] | 1126 | ErrorOrResult<GLuint> InternalFormat::computeCompressedImageSize(const Extents &size) const |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1127 | { |
Jamie Madill | 513558d | 2016-06-02 13:04:11 -0400 | [diff] [blame] | 1128 | CheckedNumeric<GLuint> checkedWidth(size.width); |
| 1129 | CheckedNumeric<GLuint> checkedHeight(size.height); |
| 1130 | CheckedNumeric<GLuint> checkedDepth(size.depth); |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 1131 | CheckedNumeric<GLuint> checkedBlockWidth(compressedBlockWidth); |
| 1132 | CheckedNumeric<GLuint> checkedBlockHeight(compressedBlockHeight); |
Jamie Madill | e2e406c | 2016-06-02 13:04:10 -0400 | [diff] [blame] | 1133 | |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 1134 | ASSERT(compressed); |
| 1135 | auto numBlocksWide = (checkedWidth + checkedBlockWidth - 1u) / checkedBlockWidth; |
| 1136 | auto numBlocksHigh = (checkedHeight + checkedBlockHeight - 1u) / checkedBlockHeight; |
| 1137 | auto bytes = numBlocksWide * numBlocksHigh * pixelBytes * checkedDepth; |
| 1138 | ANGLE_TRY_CHECKED_MATH(bytes); |
| 1139 | return bytes.ValueOrDie(); |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1140 | } |
| 1141 | |
Corentin Wallez | 886de36 | 2016-09-27 10:49:35 -0400 | [diff] [blame] | 1142 | ErrorOrResult<GLuint> InternalFormat::computeSkipBytes(GLuint rowPitch, |
Olli Etuaho | 989cac3 | 2016-06-08 16:18:49 -0700 | [diff] [blame] | 1143 | GLuint depthPitch, |
Corentin Wallez | 886de36 | 2016-09-27 10:49:35 -0400 | [diff] [blame] | 1144 | const PixelStoreStateBase &state, |
| 1145 | bool is3D) const |
Minmin Gong | adff67b | 2015-10-14 10:34:45 -0400 | [diff] [blame] | 1146 | { |
Olli Etuaho | 989cac3 | 2016-06-08 16:18:49 -0700 | [diff] [blame] | 1147 | CheckedNumeric<GLuint> checkedRowPitch(rowPitch); |
| 1148 | CheckedNumeric<GLuint> checkedDepthPitch(depthPitch); |
Corentin Wallez | 886de36 | 2016-09-27 10:49:35 -0400 | [diff] [blame] | 1149 | CheckedNumeric<GLuint> checkedSkipImages(static_cast<GLuint>(state.skipImages)); |
| 1150 | CheckedNumeric<GLuint> checkedSkipRows(static_cast<GLuint>(state.skipRows)); |
| 1151 | CheckedNumeric<GLuint> checkedSkipPixels(static_cast<GLuint>(state.skipPixels)); |
Olli Etuaho | 989cac3 | 2016-06-08 16:18:49 -0700 | [diff] [blame] | 1152 | CheckedNumeric<GLuint> checkedPixelBytes(pixelBytes); |
| 1153 | auto checkedSkipImagesBytes = checkedSkipImages * checkedDepthPitch; |
Corentin Wallez | 886de36 | 2016-09-27 10:49:35 -0400 | [diff] [blame] | 1154 | if (!is3D) |
Olli Etuaho | 989cac3 | 2016-06-08 16:18:49 -0700 | [diff] [blame] | 1155 | { |
| 1156 | checkedSkipImagesBytes = 0; |
| 1157 | } |
| 1158 | auto skipBytes = checkedSkipImagesBytes + checkedSkipRows * checkedRowPitch + |
| 1159 | checkedSkipPixels * checkedPixelBytes; |
| 1160 | ANGLE_TRY_CHECKED_MATH(skipBytes); |
| 1161 | return skipBytes.ValueOrDie(); |
Minmin Gong | adff67b | 2015-10-14 10:34:45 -0400 | [diff] [blame] | 1162 | } |
| 1163 | |
Corentin Wallez | 886de36 | 2016-09-27 10:49:35 -0400 | [diff] [blame] | 1164 | ErrorOrResult<GLuint> InternalFormat::computePackUnpackEndByte( |
| 1165 | GLenum formatType, |
| 1166 | const Extents &size, |
| 1167 | const PixelStoreStateBase &state, |
| 1168 | bool is3D) const |
Corentin Wallez | ece7c5a | 2016-09-21 15:28:23 -0400 | [diff] [blame] | 1169 | { |
Corentin Wallez | 886de36 | 2016-09-27 10:49:35 -0400 | [diff] [blame] | 1170 | GLuint rowPitch = 0; |
| 1171 | ANGLE_TRY_RESULT(computeRowPitch(formatType, size.width, state.alignment, state.rowLength), |
Corentin Wallez | ece7c5a | 2016-09-21 15:28:23 -0400 | [diff] [blame] | 1172 | rowPitch); |
| 1173 | |
Corentin Wallez | 0e48719 | 2016-10-03 16:30:38 -0400 | [diff] [blame] | 1174 | GLuint depthPitch = 0; |
| 1175 | if (is3D) |
| 1176 | { |
| 1177 | ANGLE_TRY_RESULT(computeDepthPitch(size.height, state.imageHeight, rowPitch), depthPitch); |
| 1178 | } |
| 1179 | |
Corentin Wallez | 886de36 | 2016-09-27 10:49:35 -0400 | [diff] [blame] | 1180 | CheckedNumeric<GLuint> checkedCopyBytes = 0; |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 1181 | if (compressed) |
| 1182 | { |
Jeff Gilbert | 4859035 | 2017-11-07 16:03:38 -0800 | [diff] [blame] | 1183 | ANGLE_TRY_RESULT(computeCompressedImageSize(size), checkedCopyBytes); |
Jamie Madill | 4b4cdff | 2016-06-06 13:53:38 -0700 | [diff] [blame] | 1184 | } |
Corentin Wallez | 886de36 | 2016-09-27 10:49:35 -0400 | [diff] [blame] | 1185 | else if (size.height != 0 && (!is3D || size.depth != 0)) |
Corentin Wallez | ece7c5a | 2016-09-21 15:28:23 -0400 | [diff] [blame] | 1186 | { |
Corentin Wallez | 886de36 | 2016-09-27 10:49:35 -0400 | [diff] [blame] | 1187 | CheckedNumeric<GLuint> bytes = computePixelBytes(formatType); |
| 1188 | checkedCopyBytes += size.width * bytes; |
| 1189 | |
| 1190 | CheckedNumeric<GLuint> heightMinusOne = size.height - 1; |
| 1191 | checkedCopyBytes += heightMinusOne * rowPitch; |
| 1192 | |
| 1193 | if (is3D) |
| 1194 | { |
| 1195 | CheckedNumeric<GLuint> depthMinusOne = size.depth - 1; |
| 1196 | checkedCopyBytes += depthMinusOne * depthPitch; |
| 1197 | } |
Corentin Wallez | ece7c5a | 2016-09-21 15:28:23 -0400 | [diff] [blame] | 1198 | } |
| 1199 | |
Corentin Wallez | 886de36 | 2016-09-27 10:49:35 -0400 | [diff] [blame] | 1200 | CheckedNumeric<GLuint> checkedSkipBytes = 0; |
| 1201 | ANGLE_TRY_RESULT(computeSkipBytes(rowPitch, depthPitch, state, is3D), checkedSkipBytes); |
Corentin Wallez | c5cacd6 | 2016-09-14 14:50:24 -0400 | [diff] [blame] | 1202 | |
| 1203 | CheckedNumeric<GLuint> endByte = checkedCopyBytes + checkedSkipBytes; |
| 1204 | |
| 1205 | ANGLE_TRY_CHECKED_MATH(endByte); |
| 1206 | return endByte.ValueOrDie(); |
| 1207 | } |
| 1208 | |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 1209 | GLenum GetUnsizedFormat(GLenum internalFormat) |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1210 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 1211 | auto sizedFormatInfo = GetSizedInternalFormatInfo(internalFormat); |
| 1212 | if (sizedFormatInfo.internalFormat != GL_NONE) |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 1213 | { |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 1214 | return sizedFormatInfo.format; |
Geoff Lang | 051dbc7 | 2015-01-05 15:48:58 -0500 | [diff] [blame] | 1215 | } |
Geoff Lang | ca27139 | 2017-04-05 12:30:00 -0400 | [diff] [blame] | 1216 | |
| 1217 | return internalFormat; |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 1218 | } |
| 1219 | |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 1220 | const FormatSet &GetAllSizedInternalFormats() |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 1221 | { |
Geoff Lang | e4a492b | 2014-06-19 14:14:41 -0400 | [diff] [blame] | 1222 | static FormatSet formatSet = BuildAllSizedInternalFormatSet(); |
Geoff Lang | cec3590 | 2014-04-16 10:52:36 -0400 | [diff] [blame] | 1223 | return formatSet; |
| 1224 | } |
| 1225 | |
Jamie Madill | 09e2d93 | 2015-07-14 16:40:31 -0400 | [diff] [blame] | 1226 | AttributeType GetAttributeType(GLenum enumValue) |
| 1227 | { |
| 1228 | switch (enumValue) |
| 1229 | { |
| 1230 | case GL_FLOAT: |
| 1231 | return ATTRIBUTE_FLOAT; |
| 1232 | case GL_FLOAT_VEC2: |
| 1233 | return ATTRIBUTE_VEC2; |
| 1234 | case GL_FLOAT_VEC3: |
| 1235 | return ATTRIBUTE_VEC3; |
| 1236 | case GL_FLOAT_VEC4: |
| 1237 | return ATTRIBUTE_VEC4; |
| 1238 | case GL_INT: |
| 1239 | return ATTRIBUTE_INT; |
| 1240 | case GL_INT_VEC2: |
| 1241 | return ATTRIBUTE_IVEC2; |
| 1242 | case GL_INT_VEC3: |
| 1243 | return ATTRIBUTE_IVEC3; |
| 1244 | case GL_INT_VEC4: |
| 1245 | return ATTRIBUTE_IVEC4; |
| 1246 | case GL_UNSIGNED_INT: |
| 1247 | return ATTRIBUTE_UINT; |
| 1248 | case GL_UNSIGNED_INT_VEC2: |
| 1249 | return ATTRIBUTE_UVEC2; |
| 1250 | case GL_UNSIGNED_INT_VEC3: |
| 1251 | return ATTRIBUTE_UVEC3; |
| 1252 | case GL_UNSIGNED_INT_VEC4: |
| 1253 | return ATTRIBUTE_UVEC4; |
| 1254 | case GL_FLOAT_MAT2: |
| 1255 | return ATTRIBUTE_MAT2; |
| 1256 | case GL_FLOAT_MAT3: |
| 1257 | return ATTRIBUTE_MAT3; |
| 1258 | case GL_FLOAT_MAT4: |
| 1259 | return ATTRIBUTE_MAT4; |
| 1260 | case GL_FLOAT_MAT2x3: |
| 1261 | return ATTRIBUTE_MAT2x3; |
| 1262 | case GL_FLOAT_MAT2x4: |
| 1263 | return ATTRIBUTE_MAT2x4; |
| 1264 | case GL_FLOAT_MAT3x2: |
| 1265 | return ATTRIBUTE_MAT3x2; |
| 1266 | case GL_FLOAT_MAT3x4: |
| 1267 | return ATTRIBUTE_MAT3x4; |
| 1268 | case GL_FLOAT_MAT4x2: |
| 1269 | return ATTRIBUTE_MAT4x2; |
| 1270 | case GL_FLOAT_MAT4x3: |
| 1271 | return ATTRIBUTE_MAT4x3; |
| 1272 | default: |
| 1273 | UNREACHABLE(); |
Nico Weber | b5db2b4 | 2018-02-12 15:31:56 -0500 | [diff] [blame] | 1274 | #if !UNREACHABLE_IS_NORETURN |
Jamie Madill | 09e2d93 | 2015-07-14 16:40:31 -0400 | [diff] [blame] | 1275 | return ATTRIBUTE_FLOAT; |
Nico Weber | b5db2b4 | 2018-02-12 15:31:56 -0500 | [diff] [blame] | 1276 | #endif |
Jamie Madill | 09e2d93 | 2015-07-14 16:40:31 -0400 | [diff] [blame] | 1277 | } |
| 1278 | } |
| 1279 | |
Jamie Madill | d3dfda2 | 2015-07-06 08:28:49 -0400 | [diff] [blame] | 1280 | VertexFormatType GetVertexFormatType(GLenum type, GLboolean normalized, GLuint components, bool pureInteger) |
| 1281 | { |
| 1282 | switch (type) |
| 1283 | { |
| 1284 | case GL_BYTE: |
| 1285 | switch (components) |
| 1286 | { |
| 1287 | case 1: |
| 1288 | if (pureInteger) |
| 1289 | return VERTEX_FORMAT_SBYTE1_INT; |
| 1290 | if (normalized) |
| 1291 | return VERTEX_FORMAT_SBYTE1_NORM; |
| 1292 | return VERTEX_FORMAT_SBYTE1; |
| 1293 | case 2: |
| 1294 | if (pureInteger) |
| 1295 | return VERTEX_FORMAT_SBYTE2_INT; |
| 1296 | if (normalized) |
| 1297 | return VERTEX_FORMAT_SBYTE2_NORM; |
| 1298 | return VERTEX_FORMAT_SBYTE2; |
| 1299 | case 3: |
| 1300 | if (pureInteger) |
| 1301 | return VERTEX_FORMAT_SBYTE3_INT; |
| 1302 | if (normalized) |
| 1303 | return VERTEX_FORMAT_SBYTE3_NORM; |
| 1304 | return VERTEX_FORMAT_SBYTE3; |
| 1305 | case 4: |
| 1306 | if (pureInteger) |
| 1307 | return VERTEX_FORMAT_SBYTE4_INT; |
| 1308 | if (normalized) |
| 1309 | return VERTEX_FORMAT_SBYTE4_NORM; |
| 1310 | return VERTEX_FORMAT_SBYTE4; |
| 1311 | default: |
| 1312 | UNREACHABLE(); |
Nico Weber | b5db2b4 | 2018-02-12 15:31:56 -0500 | [diff] [blame] | 1313 | #if !UNREACHABLE_IS_NORETURN |
| 1314 | return VERTEX_FORMAT_INVALID; |
| 1315 | #endif |
Jamie Madill | d3dfda2 | 2015-07-06 08:28:49 -0400 | [diff] [blame] | 1316 | } |
| 1317 | case GL_UNSIGNED_BYTE: |
| 1318 | switch (components) |
| 1319 | { |
| 1320 | case 1: |
| 1321 | if (pureInteger) |
| 1322 | return VERTEX_FORMAT_UBYTE1_INT; |
| 1323 | if (normalized) |
| 1324 | return VERTEX_FORMAT_UBYTE1_NORM; |
| 1325 | return VERTEX_FORMAT_UBYTE1; |
| 1326 | case 2: |
| 1327 | if (pureInteger) |
| 1328 | return VERTEX_FORMAT_UBYTE2_INT; |
| 1329 | if (normalized) |
| 1330 | return VERTEX_FORMAT_UBYTE2_NORM; |
| 1331 | return VERTEX_FORMAT_UBYTE2; |
| 1332 | case 3: |
| 1333 | if (pureInteger) |
| 1334 | return VERTEX_FORMAT_UBYTE3_INT; |
| 1335 | if (normalized) |
| 1336 | return VERTEX_FORMAT_UBYTE3_NORM; |
| 1337 | return VERTEX_FORMAT_UBYTE3; |
| 1338 | case 4: |
| 1339 | if (pureInteger) |
| 1340 | return VERTEX_FORMAT_UBYTE4_INT; |
| 1341 | if (normalized) |
| 1342 | return VERTEX_FORMAT_UBYTE4_NORM; |
| 1343 | return VERTEX_FORMAT_UBYTE4; |
| 1344 | default: |
| 1345 | UNREACHABLE(); |
Nico Weber | b5db2b4 | 2018-02-12 15:31:56 -0500 | [diff] [blame] | 1346 | #if !UNREACHABLE_IS_NORETURN |
| 1347 | return VERTEX_FORMAT_INVALID; |
| 1348 | #endif |
Jamie Madill | d3dfda2 | 2015-07-06 08:28:49 -0400 | [diff] [blame] | 1349 | } |
| 1350 | case GL_SHORT: |
| 1351 | switch (components) |
| 1352 | { |
| 1353 | case 1: |
| 1354 | if (pureInteger) |
| 1355 | return VERTEX_FORMAT_SSHORT1_INT; |
| 1356 | if (normalized) |
| 1357 | return VERTEX_FORMAT_SSHORT1_NORM; |
| 1358 | return VERTEX_FORMAT_SSHORT1; |
| 1359 | case 2: |
| 1360 | if (pureInteger) |
| 1361 | return VERTEX_FORMAT_SSHORT2_INT; |
| 1362 | if (normalized) |
| 1363 | return VERTEX_FORMAT_SSHORT2_NORM; |
| 1364 | return VERTEX_FORMAT_SSHORT2; |
| 1365 | case 3: |
| 1366 | if (pureInteger) |
| 1367 | return VERTEX_FORMAT_SSHORT3_INT; |
| 1368 | if (normalized) |
| 1369 | return VERTEX_FORMAT_SSHORT3_NORM; |
| 1370 | return VERTEX_FORMAT_SSHORT3; |
| 1371 | case 4: |
| 1372 | if (pureInteger) |
| 1373 | return VERTEX_FORMAT_SSHORT4_INT; |
| 1374 | if (normalized) |
| 1375 | return VERTEX_FORMAT_SSHORT4_NORM; |
| 1376 | return VERTEX_FORMAT_SSHORT4; |
| 1377 | default: |
| 1378 | UNREACHABLE(); |
Nico Weber | b5db2b4 | 2018-02-12 15:31:56 -0500 | [diff] [blame] | 1379 | #if !UNREACHABLE_IS_NORETURN |
| 1380 | return VERTEX_FORMAT_INVALID; |
| 1381 | #endif |
Jamie Madill | d3dfda2 | 2015-07-06 08:28:49 -0400 | [diff] [blame] | 1382 | } |
| 1383 | case GL_UNSIGNED_SHORT: |
| 1384 | switch (components) |
| 1385 | { |
| 1386 | case 1: |
| 1387 | if (pureInteger) |
| 1388 | return VERTEX_FORMAT_USHORT1_INT; |
| 1389 | if (normalized) |
| 1390 | return VERTEX_FORMAT_USHORT1_NORM; |
| 1391 | return VERTEX_FORMAT_USHORT1; |
| 1392 | case 2: |
| 1393 | if (pureInteger) |
| 1394 | return VERTEX_FORMAT_USHORT2_INT; |
| 1395 | if (normalized) |
| 1396 | return VERTEX_FORMAT_USHORT2_NORM; |
| 1397 | return VERTEX_FORMAT_USHORT2; |
| 1398 | case 3: |
| 1399 | if (pureInteger) |
| 1400 | return VERTEX_FORMAT_USHORT3_INT; |
| 1401 | if (normalized) |
| 1402 | return VERTEX_FORMAT_USHORT3_NORM; |
| 1403 | return VERTEX_FORMAT_USHORT3; |
| 1404 | case 4: |
| 1405 | if (pureInteger) |
| 1406 | return VERTEX_FORMAT_USHORT4_INT; |
| 1407 | if (normalized) |
| 1408 | return VERTEX_FORMAT_USHORT4_NORM; |
| 1409 | return VERTEX_FORMAT_USHORT4; |
| 1410 | default: |
| 1411 | UNREACHABLE(); |
Nico Weber | b5db2b4 | 2018-02-12 15:31:56 -0500 | [diff] [blame] | 1412 | #if !UNREACHABLE_IS_NORETURN |
| 1413 | return VERTEX_FORMAT_INVALID; |
| 1414 | #endif |
Jamie Madill | d3dfda2 | 2015-07-06 08:28:49 -0400 | [diff] [blame] | 1415 | } |
| 1416 | case GL_INT: |
| 1417 | switch (components) |
| 1418 | { |
| 1419 | case 1: |
| 1420 | if (pureInteger) |
| 1421 | return VERTEX_FORMAT_SINT1_INT; |
| 1422 | if (normalized) |
| 1423 | return VERTEX_FORMAT_SINT1_NORM; |
| 1424 | return VERTEX_FORMAT_SINT1; |
| 1425 | case 2: |
| 1426 | if (pureInteger) |
| 1427 | return VERTEX_FORMAT_SINT2_INT; |
| 1428 | if (normalized) |
| 1429 | return VERTEX_FORMAT_SINT2_NORM; |
| 1430 | return VERTEX_FORMAT_SINT2; |
| 1431 | case 3: |
| 1432 | if (pureInteger) |
| 1433 | return VERTEX_FORMAT_SINT3_INT; |
| 1434 | if (normalized) |
| 1435 | return VERTEX_FORMAT_SINT3_NORM; |
| 1436 | return VERTEX_FORMAT_SINT3; |
| 1437 | case 4: |
| 1438 | if (pureInteger) |
| 1439 | return VERTEX_FORMAT_SINT4_INT; |
| 1440 | if (normalized) |
| 1441 | return VERTEX_FORMAT_SINT4_NORM; |
| 1442 | return VERTEX_FORMAT_SINT4; |
| 1443 | default: |
| 1444 | UNREACHABLE(); |
Nico Weber | b5db2b4 | 2018-02-12 15:31:56 -0500 | [diff] [blame] | 1445 | #if !UNREACHABLE_IS_NORETURN |
| 1446 | return VERTEX_FORMAT_INVALID; |
| 1447 | #endif |
Jamie Madill | d3dfda2 | 2015-07-06 08:28:49 -0400 | [diff] [blame] | 1448 | } |
| 1449 | case GL_UNSIGNED_INT: |
| 1450 | switch (components) |
| 1451 | { |
| 1452 | case 1: |
| 1453 | if (pureInteger) |
| 1454 | return VERTEX_FORMAT_UINT1_INT; |
| 1455 | if (normalized) |
| 1456 | return VERTEX_FORMAT_UINT1_NORM; |
| 1457 | return VERTEX_FORMAT_UINT1; |
| 1458 | case 2: |
| 1459 | if (pureInteger) |
| 1460 | return VERTEX_FORMAT_UINT2_INT; |
| 1461 | if (normalized) |
| 1462 | return VERTEX_FORMAT_UINT2_NORM; |
| 1463 | return VERTEX_FORMAT_UINT2; |
| 1464 | case 3: |
| 1465 | if (pureInteger) |
| 1466 | return VERTEX_FORMAT_UINT3_INT; |
| 1467 | if (normalized) |
| 1468 | return VERTEX_FORMAT_UINT3_NORM; |
| 1469 | return VERTEX_FORMAT_UINT3; |
| 1470 | case 4: |
| 1471 | if (pureInteger) |
| 1472 | return VERTEX_FORMAT_UINT4_INT; |
| 1473 | if (normalized) |
| 1474 | return VERTEX_FORMAT_UINT4_NORM; |
| 1475 | return VERTEX_FORMAT_UINT4; |
| 1476 | default: |
| 1477 | UNREACHABLE(); |
Nico Weber | b5db2b4 | 2018-02-12 15:31:56 -0500 | [diff] [blame] | 1478 | #if !UNREACHABLE_IS_NORETURN |
| 1479 | return VERTEX_FORMAT_INVALID; |
| 1480 | #endif |
Jamie Madill | d3dfda2 | 2015-07-06 08:28:49 -0400 | [diff] [blame] | 1481 | } |
| 1482 | case GL_FLOAT: |
| 1483 | switch (components) |
| 1484 | { |
| 1485 | case 1: |
| 1486 | return VERTEX_FORMAT_FLOAT1; |
| 1487 | case 2: |
| 1488 | return VERTEX_FORMAT_FLOAT2; |
| 1489 | case 3: |
| 1490 | return VERTEX_FORMAT_FLOAT3; |
| 1491 | case 4: |
| 1492 | return VERTEX_FORMAT_FLOAT4; |
| 1493 | default: |
| 1494 | UNREACHABLE(); |
Nico Weber | b5db2b4 | 2018-02-12 15:31:56 -0500 | [diff] [blame] | 1495 | #if !UNREACHABLE_IS_NORETURN |
| 1496 | return VERTEX_FORMAT_INVALID; |
| 1497 | #endif |
Jamie Madill | d3dfda2 | 2015-07-06 08:28:49 -0400 | [diff] [blame] | 1498 | } |
| 1499 | case GL_HALF_FLOAT: |
| 1500 | switch (components) |
| 1501 | { |
| 1502 | case 1: |
| 1503 | return VERTEX_FORMAT_HALF1; |
| 1504 | case 2: |
| 1505 | return VERTEX_FORMAT_HALF2; |
| 1506 | case 3: |
| 1507 | return VERTEX_FORMAT_HALF3; |
| 1508 | case 4: |
| 1509 | return VERTEX_FORMAT_HALF4; |
| 1510 | default: |
| 1511 | UNREACHABLE(); |
Nico Weber | b5db2b4 | 2018-02-12 15:31:56 -0500 | [diff] [blame] | 1512 | #if !UNREACHABLE_IS_NORETURN |
| 1513 | return VERTEX_FORMAT_INVALID; |
| 1514 | #endif |
Jamie Madill | d3dfda2 | 2015-07-06 08:28:49 -0400 | [diff] [blame] | 1515 | } |
| 1516 | case GL_FIXED: |
| 1517 | switch (components) |
| 1518 | { |
| 1519 | case 1: |
| 1520 | return VERTEX_FORMAT_FIXED1; |
| 1521 | case 2: |
| 1522 | return VERTEX_FORMAT_FIXED2; |
| 1523 | case 3: |
| 1524 | return VERTEX_FORMAT_FIXED3; |
| 1525 | case 4: |
| 1526 | return VERTEX_FORMAT_FIXED4; |
| 1527 | default: |
| 1528 | UNREACHABLE(); |
Nico Weber | b5db2b4 | 2018-02-12 15:31:56 -0500 | [diff] [blame] | 1529 | #if !UNREACHABLE_IS_NORETURN |
| 1530 | return VERTEX_FORMAT_INVALID; |
| 1531 | #endif |
Jamie Madill | d3dfda2 | 2015-07-06 08:28:49 -0400 | [diff] [blame] | 1532 | } |
| 1533 | case GL_INT_2_10_10_10_REV: |
| 1534 | if (pureInteger) |
| 1535 | return VERTEX_FORMAT_SINT210_INT; |
| 1536 | if (normalized) |
| 1537 | return VERTEX_FORMAT_SINT210_NORM; |
| 1538 | return VERTEX_FORMAT_SINT210; |
| 1539 | case GL_UNSIGNED_INT_2_10_10_10_REV: |
| 1540 | if (pureInteger) |
| 1541 | return VERTEX_FORMAT_UINT210_INT; |
| 1542 | if (normalized) |
| 1543 | return VERTEX_FORMAT_UINT210_NORM; |
| 1544 | return VERTEX_FORMAT_UINT210; |
| 1545 | default: |
| 1546 | UNREACHABLE(); |
Nico Weber | b5db2b4 | 2018-02-12 15:31:56 -0500 | [diff] [blame] | 1547 | #if !UNREACHABLE_IS_NORETURN |
| 1548 | return VERTEX_FORMAT_INVALID; |
| 1549 | #endif |
Jamie Madill | d3dfda2 | 2015-07-06 08:28:49 -0400 | [diff] [blame] | 1550 | } |
Jamie Madill | d3dfda2 | 2015-07-06 08:28:49 -0400 | [diff] [blame] | 1551 | } |
| 1552 | |
| 1553 | VertexFormatType GetVertexFormatType(const VertexAttribute &attrib) |
| 1554 | { |
| 1555 | return GetVertexFormatType(attrib.type, attrib.normalized, attrib.size, attrib.pureInteger); |
| 1556 | } |
| 1557 | |
| 1558 | VertexFormatType GetVertexFormatType(const VertexAttribute &attrib, GLenum currentValueType) |
| 1559 | { |
| 1560 | if (!attrib.enabled) |
| 1561 | { |
| 1562 | return GetVertexFormatType(currentValueType, GL_FALSE, 4, (currentValueType != GL_FLOAT)); |
| 1563 | } |
| 1564 | return GetVertexFormatType(attrib); |
| 1565 | } |
| 1566 | |
| 1567 | const VertexFormat &GetVertexFormatFromType(VertexFormatType vertexFormatType) |
| 1568 | { |
| 1569 | switch (vertexFormatType) |
| 1570 | { |
| 1571 | case VERTEX_FORMAT_SBYTE1: |
| 1572 | { |
| 1573 | static const VertexFormat format(GL_BYTE, GL_FALSE, 1, false); |
| 1574 | return format; |
| 1575 | } |
| 1576 | case VERTEX_FORMAT_SBYTE1_NORM: |
| 1577 | { |
| 1578 | static const VertexFormat format(GL_BYTE, GL_TRUE, 1, false); |
| 1579 | return format; |
| 1580 | } |
| 1581 | case VERTEX_FORMAT_SBYTE2: |
| 1582 | { |
| 1583 | static const VertexFormat format(GL_BYTE, GL_FALSE, 2, false); |
| 1584 | return format; |
| 1585 | } |
| 1586 | case VERTEX_FORMAT_SBYTE2_NORM: |
| 1587 | { |
| 1588 | static const VertexFormat format(GL_BYTE, GL_TRUE, 2, false); |
| 1589 | return format; |
| 1590 | } |
| 1591 | case VERTEX_FORMAT_SBYTE3: |
| 1592 | { |
| 1593 | static const VertexFormat format(GL_BYTE, GL_FALSE, 3, false); |
| 1594 | return format; |
| 1595 | } |
| 1596 | case VERTEX_FORMAT_SBYTE3_NORM: |
| 1597 | { |
| 1598 | static const VertexFormat format(GL_BYTE, GL_TRUE, 3, false); |
| 1599 | return format; |
| 1600 | } |
| 1601 | case VERTEX_FORMAT_SBYTE4: |
| 1602 | { |
| 1603 | static const VertexFormat format(GL_BYTE, GL_FALSE, 4, false); |
| 1604 | return format; |
| 1605 | } |
| 1606 | case VERTEX_FORMAT_SBYTE4_NORM: |
| 1607 | { |
| 1608 | static const VertexFormat format(GL_BYTE, GL_TRUE, 4, false); |
| 1609 | return format; |
| 1610 | } |
| 1611 | case VERTEX_FORMAT_UBYTE1: |
| 1612 | { |
| 1613 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 1, false); |
| 1614 | return format; |
| 1615 | } |
| 1616 | case VERTEX_FORMAT_UBYTE1_NORM: |
| 1617 | { |
| 1618 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 1, false); |
| 1619 | return format; |
| 1620 | } |
| 1621 | case VERTEX_FORMAT_UBYTE2: |
| 1622 | { |
| 1623 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 2, false); |
| 1624 | return format; |
| 1625 | } |
| 1626 | case VERTEX_FORMAT_UBYTE2_NORM: |
| 1627 | { |
| 1628 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 2, false); |
| 1629 | return format; |
| 1630 | } |
| 1631 | case VERTEX_FORMAT_UBYTE3: |
| 1632 | { |
| 1633 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 3, false); |
| 1634 | return format; |
| 1635 | } |
| 1636 | case VERTEX_FORMAT_UBYTE3_NORM: |
| 1637 | { |
| 1638 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 3, false); |
| 1639 | return format; |
| 1640 | } |
| 1641 | case VERTEX_FORMAT_UBYTE4: |
| 1642 | { |
| 1643 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 4, false); |
| 1644 | return format; |
| 1645 | } |
| 1646 | case VERTEX_FORMAT_UBYTE4_NORM: |
| 1647 | { |
| 1648 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 4, false); |
| 1649 | return format; |
| 1650 | } |
| 1651 | case VERTEX_FORMAT_SSHORT1: |
| 1652 | { |
| 1653 | static const VertexFormat format(GL_SHORT, GL_FALSE, 1, false); |
| 1654 | return format; |
| 1655 | } |
| 1656 | case VERTEX_FORMAT_SSHORT1_NORM: |
| 1657 | { |
| 1658 | static const VertexFormat format(GL_SHORT, GL_TRUE, 1, false); |
| 1659 | return format; |
| 1660 | } |
| 1661 | case VERTEX_FORMAT_SSHORT2: |
| 1662 | { |
| 1663 | static const VertexFormat format(GL_SHORT, GL_FALSE, 2, false); |
| 1664 | return format; |
| 1665 | } |
| 1666 | case VERTEX_FORMAT_SSHORT2_NORM: |
| 1667 | { |
| 1668 | static const VertexFormat format(GL_SHORT, GL_TRUE, 2, false); |
| 1669 | return format; |
| 1670 | } |
| 1671 | case VERTEX_FORMAT_SSHORT3: |
| 1672 | { |
| 1673 | static const VertexFormat format(GL_SHORT, GL_FALSE, 3, false); |
| 1674 | return format; |
| 1675 | } |
| 1676 | case VERTEX_FORMAT_SSHORT3_NORM: |
| 1677 | { |
| 1678 | static const VertexFormat format(GL_SHORT, GL_TRUE, 3, false); |
| 1679 | return format; |
| 1680 | } |
| 1681 | case VERTEX_FORMAT_SSHORT4: |
| 1682 | { |
| 1683 | static const VertexFormat format(GL_SHORT, GL_FALSE, 4, false); |
| 1684 | return format; |
| 1685 | } |
| 1686 | case VERTEX_FORMAT_SSHORT4_NORM: |
| 1687 | { |
| 1688 | static const VertexFormat format(GL_SHORT, GL_TRUE, 4, false); |
| 1689 | return format; |
| 1690 | } |
| 1691 | case VERTEX_FORMAT_USHORT1: |
| 1692 | { |
| 1693 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 1, false); |
| 1694 | return format; |
| 1695 | } |
| 1696 | case VERTEX_FORMAT_USHORT1_NORM: |
| 1697 | { |
| 1698 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 1, false); |
| 1699 | return format; |
| 1700 | } |
| 1701 | case VERTEX_FORMAT_USHORT2: |
| 1702 | { |
| 1703 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 2, false); |
| 1704 | return format; |
| 1705 | } |
| 1706 | case VERTEX_FORMAT_USHORT2_NORM: |
| 1707 | { |
| 1708 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 2, false); |
| 1709 | return format; |
| 1710 | } |
| 1711 | case VERTEX_FORMAT_USHORT3: |
| 1712 | { |
| 1713 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 3, false); |
| 1714 | return format; |
| 1715 | } |
| 1716 | case VERTEX_FORMAT_USHORT3_NORM: |
| 1717 | { |
| 1718 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 3, false); |
| 1719 | return format; |
| 1720 | } |
| 1721 | case VERTEX_FORMAT_USHORT4: |
| 1722 | { |
| 1723 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 4, false); |
| 1724 | return format; |
| 1725 | } |
| 1726 | case VERTEX_FORMAT_USHORT4_NORM: |
| 1727 | { |
| 1728 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 4, false); |
| 1729 | return format; |
| 1730 | } |
| 1731 | case VERTEX_FORMAT_SINT1: |
| 1732 | { |
| 1733 | static const VertexFormat format(GL_INT, GL_FALSE, 1, false); |
| 1734 | return format; |
| 1735 | } |
| 1736 | case VERTEX_FORMAT_SINT1_NORM: |
| 1737 | { |
| 1738 | static const VertexFormat format(GL_INT, GL_TRUE, 1, false); |
| 1739 | return format; |
| 1740 | } |
| 1741 | case VERTEX_FORMAT_SINT2: |
| 1742 | { |
| 1743 | static const VertexFormat format(GL_INT, GL_FALSE, 2, false); |
| 1744 | return format; |
| 1745 | } |
| 1746 | case VERTEX_FORMAT_SINT2_NORM: |
| 1747 | { |
| 1748 | static const VertexFormat format(GL_INT, GL_TRUE, 2, false); |
| 1749 | return format; |
| 1750 | } |
| 1751 | case VERTEX_FORMAT_SINT3: |
| 1752 | { |
| 1753 | static const VertexFormat format(GL_INT, GL_FALSE, 3, false); |
| 1754 | return format; |
| 1755 | } |
| 1756 | case VERTEX_FORMAT_SINT3_NORM: |
| 1757 | { |
| 1758 | static const VertexFormat format(GL_INT, GL_TRUE, 3, false); |
| 1759 | return format; |
| 1760 | } |
| 1761 | case VERTEX_FORMAT_SINT4: |
| 1762 | { |
| 1763 | static const VertexFormat format(GL_INT, GL_FALSE, 4, false); |
| 1764 | return format; |
| 1765 | } |
| 1766 | case VERTEX_FORMAT_SINT4_NORM: |
| 1767 | { |
| 1768 | static const VertexFormat format(GL_INT, GL_TRUE, 4, false); |
| 1769 | return format; |
| 1770 | } |
| 1771 | case VERTEX_FORMAT_UINT1: |
| 1772 | { |
| 1773 | static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 1, false); |
| 1774 | return format; |
| 1775 | } |
| 1776 | case VERTEX_FORMAT_UINT1_NORM: |
| 1777 | { |
| 1778 | static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 1, false); |
| 1779 | return format; |
| 1780 | } |
| 1781 | case VERTEX_FORMAT_UINT2: |
| 1782 | { |
| 1783 | static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 2, false); |
| 1784 | return format; |
| 1785 | } |
| 1786 | case VERTEX_FORMAT_UINT2_NORM: |
| 1787 | { |
| 1788 | static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 2, false); |
| 1789 | return format; |
| 1790 | } |
| 1791 | case VERTEX_FORMAT_UINT3: |
| 1792 | { |
| 1793 | static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 3, false); |
| 1794 | return format; |
| 1795 | } |
| 1796 | case VERTEX_FORMAT_UINT3_NORM: |
| 1797 | { |
| 1798 | static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 3, false); |
| 1799 | return format; |
| 1800 | } |
| 1801 | case VERTEX_FORMAT_UINT4: |
| 1802 | { |
| 1803 | static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 4, false); |
| 1804 | return format; |
| 1805 | } |
| 1806 | case VERTEX_FORMAT_UINT4_NORM: |
| 1807 | { |
| 1808 | static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 4, false); |
| 1809 | return format; |
| 1810 | } |
| 1811 | case VERTEX_FORMAT_SBYTE1_INT: |
| 1812 | { |
| 1813 | static const VertexFormat format(GL_BYTE, GL_FALSE, 1, true); |
| 1814 | return format; |
| 1815 | } |
| 1816 | case VERTEX_FORMAT_SBYTE2_INT: |
| 1817 | { |
| 1818 | static const VertexFormat format(GL_BYTE, GL_FALSE, 2, true); |
| 1819 | return format; |
| 1820 | } |
| 1821 | case VERTEX_FORMAT_SBYTE3_INT: |
| 1822 | { |
| 1823 | static const VertexFormat format(GL_BYTE, GL_FALSE, 3, true); |
| 1824 | return format; |
| 1825 | } |
| 1826 | case VERTEX_FORMAT_SBYTE4_INT: |
| 1827 | { |
| 1828 | static const VertexFormat format(GL_BYTE, GL_FALSE, 4, true); |
| 1829 | return format; |
| 1830 | } |
| 1831 | case VERTEX_FORMAT_UBYTE1_INT: |
| 1832 | { |
| 1833 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 1, true); |
| 1834 | return format; |
| 1835 | } |
| 1836 | case VERTEX_FORMAT_UBYTE2_INT: |
| 1837 | { |
| 1838 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 2, true); |
| 1839 | return format; |
| 1840 | } |
| 1841 | case VERTEX_FORMAT_UBYTE3_INT: |
| 1842 | { |
| 1843 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 3, true); |
| 1844 | return format; |
| 1845 | } |
| 1846 | case VERTEX_FORMAT_UBYTE4_INT: |
| 1847 | { |
| 1848 | static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 4, true); |
| 1849 | return format; |
| 1850 | } |
| 1851 | case VERTEX_FORMAT_SSHORT1_INT: |
| 1852 | { |
| 1853 | static const VertexFormat format(GL_SHORT, GL_FALSE, 1, true); |
| 1854 | return format; |
| 1855 | } |
| 1856 | case VERTEX_FORMAT_SSHORT2_INT: |
| 1857 | { |
| 1858 | static const VertexFormat format(GL_SHORT, GL_FALSE, 2, true); |
| 1859 | return format; |
| 1860 | } |
| 1861 | case VERTEX_FORMAT_SSHORT3_INT: |
| 1862 | { |
| 1863 | static const VertexFormat format(GL_SHORT, GL_FALSE, 3, true); |
| 1864 | return format; |
| 1865 | } |
| 1866 | case VERTEX_FORMAT_SSHORT4_INT: |
| 1867 | { |
| 1868 | static const VertexFormat format(GL_SHORT, GL_FALSE, 4, true); |
| 1869 | return format; |
| 1870 | } |
| 1871 | case VERTEX_FORMAT_USHORT1_INT: |
| 1872 | { |
| 1873 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 1, true); |
| 1874 | return format; |
| 1875 | } |
| 1876 | case VERTEX_FORMAT_USHORT2_INT: |
| 1877 | { |
| 1878 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 2, true); |
| 1879 | return format; |
| 1880 | } |
| 1881 | case VERTEX_FORMAT_USHORT3_INT: |
| 1882 | { |
| 1883 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 3, true); |
| 1884 | return format; |
| 1885 | } |
| 1886 | case VERTEX_FORMAT_USHORT4_INT: |
| 1887 | { |
| 1888 | static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 4, true); |
| 1889 | return format; |
| 1890 | } |
| 1891 | case VERTEX_FORMAT_SINT1_INT: |
| 1892 | { |
| 1893 | static const VertexFormat format(GL_INT, GL_FALSE, 1, true); |
| 1894 | return format; |
| 1895 | } |
| 1896 | case VERTEX_FORMAT_SINT2_INT: |
| 1897 | { |
| 1898 | static const VertexFormat format(GL_INT, GL_FALSE, 2, true); |
| 1899 | return format; |
| 1900 | } |
| 1901 | case VERTEX_FORMAT_SINT3_INT: |
| 1902 | { |
| 1903 | static const VertexFormat format(GL_INT, GL_FALSE, 3, true); |
| 1904 | return format; |
| 1905 | } |
| 1906 | case VERTEX_FORMAT_SINT4_INT: |
| 1907 | { |
| 1908 | static const VertexFormat format(GL_INT, GL_FALSE, 4, true); |
| 1909 | return format; |
| 1910 | } |
| 1911 | case VERTEX_FORMAT_UINT1_INT: |
| 1912 | { |
| 1913 | static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 1, true); |
| 1914 | return format; |
| 1915 | } |
| 1916 | case VERTEX_FORMAT_UINT2_INT: |
| 1917 | { |
| 1918 | static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 2, true); |
| 1919 | return format; |
| 1920 | } |
| 1921 | case VERTEX_FORMAT_UINT3_INT: |
| 1922 | { |
| 1923 | static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 3, true); |
| 1924 | return format; |
| 1925 | } |
| 1926 | case VERTEX_FORMAT_UINT4_INT: |
| 1927 | { |
| 1928 | static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 4, true); |
| 1929 | return format; |
| 1930 | } |
| 1931 | case VERTEX_FORMAT_FIXED1: |
| 1932 | { |
| 1933 | static const VertexFormat format(GL_FIXED, GL_FALSE, 1, false); |
| 1934 | return format; |
| 1935 | } |
| 1936 | case VERTEX_FORMAT_FIXED2: |
| 1937 | { |
| 1938 | static const VertexFormat format(GL_FIXED, GL_FALSE, 2, false); |
| 1939 | return format; |
| 1940 | } |
| 1941 | case VERTEX_FORMAT_FIXED3: |
| 1942 | { |
| 1943 | static const VertexFormat format(GL_FIXED, GL_FALSE, 3, false); |
| 1944 | return format; |
| 1945 | } |
| 1946 | case VERTEX_FORMAT_FIXED4: |
| 1947 | { |
| 1948 | static const VertexFormat format(GL_FIXED, GL_FALSE, 4, false); |
| 1949 | return format; |
| 1950 | } |
| 1951 | case VERTEX_FORMAT_HALF1: |
| 1952 | { |
| 1953 | static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 1, false); |
| 1954 | return format; |
| 1955 | } |
| 1956 | case VERTEX_FORMAT_HALF2: |
| 1957 | { |
| 1958 | static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 2, false); |
| 1959 | return format; |
| 1960 | } |
| 1961 | case VERTEX_FORMAT_HALF3: |
| 1962 | { |
| 1963 | static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 3, false); |
| 1964 | return format; |
| 1965 | } |
| 1966 | case VERTEX_FORMAT_HALF4: |
| 1967 | { |
| 1968 | static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 4, false); |
| 1969 | return format; |
| 1970 | } |
| 1971 | case VERTEX_FORMAT_FLOAT1: |
| 1972 | { |
| 1973 | static const VertexFormat format(GL_FLOAT, GL_FALSE, 1, false); |
| 1974 | return format; |
| 1975 | } |
| 1976 | case VERTEX_FORMAT_FLOAT2: |
| 1977 | { |
| 1978 | static const VertexFormat format(GL_FLOAT, GL_FALSE, 2, false); |
| 1979 | return format; |
| 1980 | } |
| 1981 | case VERTEX_FORMAT_FLOAT3: |
| 1982 | { |
| 1983 | static const VertexFormat format(GL_FLOAT, GL_FALSE, 3, false); |
| 1984 | return format; |
| 1985 | } |
| 1986 | case VERTEX_FORMAT_FLOAT4: |
| 1987 | { |
| 1988 | static const VertexFormat format(GL_FLOAT, GL_FALSE, 4, false); |
| 1989 | return format; |
| 1990 | } |
| 1991 | case VERTEX_FORMAT_SINT210: |
| 1992 | { |
| 1993 | static const VertexFormat format(GL_INT_2_10_10_10_REV, GL_FALSE, 4, false); |
| 1994 | return format; |
| 1995 | } |
| 1996 | case VERTEX_FORMAT_UINT210: |
| 1997 | { |
| 1998 | static const VertexFormat format(GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE, 4, false); |
| 1999 | return format; |
| 2000 | } |
| 2001 | case VERTEX_FORMAT_SINT210_NORM: |
| 2002 | { |
| 2003 | static const VertexFormat format(GL_INT_2_10_10_10_REV, GL_TRUE, 4, false); |
| 2004 | return format; |
| 2005 | } |
| 2006 | case VERTEX_FORMAT_UINT210_NORM: |
| 2007 | { |
| 2008 | static const VertexFormat format(GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 4, false); |
| 2009 | return format; |
| 2010 | } |
| 2011 | case VERTEX_FORMAT_SINT210_INT: |
| 2012 | { |
| 2013 | static const VertexFormat format(GL_INT_2_10_10_10_REV, GL_FALSE, 4, true); |
| 2014 | return format; |
| 2015 | } |
| 2016 | case VERTEX_FORMAT_UINT210_INT: |
| 2017 | { |
| 2018 | static const VertexFormat format(GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE, 4, true); |
| 2019 | return format; |
| 2020 | } |
| 2021 | default: |
| 2022 | { |
| 2023 | static const VertexFormat format(GL_NONE, GL_FALSE, 0, false); |
| 2024 | return format; |
| 2025 | } |
| 2026 | } |
| 2027 | } |
| 2028 | |
Corentin Wallez | 0c7baf1 | 2016-12-19 15:43:10 -0500 | [diff] [blame] | 2029 | size_t GetVertexFormatTypeSize(VertexFormatType vertexFormatType) |
| 2030 | { |
| 2031 | switch (vertexFormatType) |
| 2032 | { |
| 2033 | case VERTEX_FORMAT_SBYTE1: |
| 2034 | case VERTEX_FORMAT_SBYTE1_NORM: |
| 2035 | case VERTEX_FORMAT_UBYTE1: |
| 2036 | case VERTEX_FORMAT_UBYTE1_NORM: |
| 2037 | case VERTEX_FORMAT_SBYTE1_INT: |
| 2038 | case VERTEX_FORMAT_UBYTE1_INT: |
| 2039 | return 1; |
| 2040 | |
| 2041 | case VERTEX_FORMAT_SBYTE2: |
| 2042 | case VERTEX_FORMAT_SBYTE2_NORM: |
| 2043 | case VERTEX_FORMAT_UBYTE2: |
| 2044 | case VERTEX_FORMAT_UBYTE2_NORM: |
| 2045 | case VERTEX_FORMAT_SBYTE2_INT: |
| 2046 | case VERTEX_FORMAT_UBYTE2_INT: |
| 2047 | case VERTEX_FORMAT_SSHORT1: |
| 2048 | case VERTEX_FORMAT_SSHORT1_NORM: |
| 2049 | case VERTEX_FORMAT_USHORT1: |
| 2050 | case VERTEX_FORMAT_USHORT1_NORM: |
| 2051 | case VERTEX_FORMAT_SSHORT1_INT: |
| 2052 | case VERTEX_FORMAT_USHORT1_INT: |
| 2053 | case VERTEX_FORMAT_HALF1: |
| 2054 | return 2; |
| 2055 | |
| 2056 | case VERTEX_FORMAT_SBYTE3: |
| 2057 | case VERTEX_FORMAT_SBYTE3_NORM: |
| 2058 | case VERTEX_FORMAT_UBYTE3: |
| 2059 | case VERTEX_FORMAT_UBYTE3_NORM: |
| 2060 | case VERTEX_FORMAT_SBYTE3_INT: |
| 2061 | case VERTEX_FORMAT_UBYTE3_INT: |
| 2062 | return 3; |
| 2063 | |
| 2064 | case VERTEX_FORMAT_SBYTE4: |
| 2065 | case VERTEX_FORMAT_SBYTE4_NORM: |
| 2066 | case VERTEX_FORMAT_UBYTE4: |
| 2067 | case VERTEX_FORMAT_UBYTE4_NORM: |
| 2068 | case VERTEX_FORMAT_SBYTE4_INT: |
| 2069 | case VERTEX_FORMAT_UBYTE4_INT: |
| 2070 | case VERTEX_FORMAT_SSHORT2: |
| 2071 | case VERTEX_FORMAT_SSHORT2_NORM: |
| 2072 | case VERTEX_FORMAT_USHORT2: |
| 2073 | case VERTEX_FORMAT_USHORT2_NORM: |
| 2074 | case VERTEX_FORMAT_SSHORT2_INT: |
| 2075 | case VERTEX_FORMAT_USHORT2_INT: |
| 2076 | case VERTEX_FORMAT_SINT1: |
| 2077 | case VERTEX_FORMAT_SINT1_NORM: |
| 2078 | case VERTEX_FORMAT_UINT1: |
| 2079 | case VERTEX_FORMAT_UINT1_NORM: |
| 2080 | case VERTEX_FORMAT_SINT1_INT: |
| 2081 | case VERTEX_FORMAT_UINT1_INT: |
| 2082 | case VERTEX_FORMAT_HALF2: |
| 2083 | case VERTEX_FORMAT_FIXED1: |
| 2084 | case VERTEX_FORMAT_FLOAT1: |
| 2085 | case VERTEX_FORMAT_SINT210: |
| 2086 | case VERTEX_FORMAT_UINT210: |
| 2087 | case VERTEX_FORMAT_SINT210_NORM: |
| 2088 | case VERTEX_FORMAT_UINT210_NORM: |
| 2089 | case VERTEX_FORMAT_SINT210_INT: |
| 2090 | case VERTEX_FORMAT_UINT210_INT: |
| 2091 | return 4; |
| 2092 | |
| 2093 | case VERTEX_FORMAT_SSHORT3: |
| 2094 | case VERTEX_FORMAT_SSHORT3_NORM: |
| 2095 | case VERTEX_FORMAT_USHORT3: |
| 2096 | case VERTEX_FORMAT_USHORT3_NORM: |
| 2097 | case VERTEX_FORMAT_SSHORT3_INT: |
| 2098 | case VERTEX_FORMAT_USHORT3_INT: |
| 2099 | case VERTEX_FORMAT_HALF3: |
| 2100 | return 6; |
| 2101 | |
| 2102 | case VERTEX_FORMAT_SSHORT4: |
| 2103 | case VERTEX_FORMAT_SSHORT4_NORM: |
| 2104 | case VERTEX_FORMAT_USHORT4: |
| 2105 | case VERTEX_FORMAT_USHORT4_NORM: |
| 2106 | case VERTEX_FORMAT_SSHORT4_INT: |
| 2107 | case VERTEX_FORMAT_USHORT4_INT: |
| 2108 | case VERTEX_FORMAT_SINT2: |
| 2109 | case VERTEX_FORMAT_SINT2_NORM: |
| 2110 | case VERTEX_FORMAT_UINT2: |
| 2111 | case VERTEX_FORMAT_UINT2_NORM: |
| 2112 | case VERTEX_FORMAT_SINT2_INT: |
| 2113 | case VERTEX_FORMAT_UINT2_INT: |
| 2114 | case VERTEX_FORMAT_HALF4: |
| 2115 | case VERTEX_FORMAT_FIXED2: |
| 2116 | case VERTEX_FORMAT_FLOAT2: |
| 2117 | return 8; |
| 2118 | |
| 2119 | case VERTEX_FORMAT_SINT3: |
| 2120 | case VERTEX_FORMAT_SINT3_NORM: |
| 2121 | case VERTEX_FORMAT_UINT3: |
| 2122 | case VERTEX_FORMAT_UINT3_NORM: |
| 2123 | case VERTEX_FORMAT_SINT3_INT: |
| 2124 | case VERTEX_FORMAT_UINT3_INT: |
| 2125 | case VERTEX_FORMAT_FIXED3: |
| 2126 | case VERTEX_FORMAT_FLOAT3: |
| 2127 | return 12; |
| 2128 | |
| 2129 | case VERTEX_FORMAT_SINT4: |
| 2130 | case VERTEX_FORMAT_SINT4_NORM: |
| 2131 | case VERTEX_FORMAT_UINT4: |
| 2132 | case VERTEX_FORMAT_UINT4_NORM: |
| 2133 | case VERTEX_FORMAT_SINT4_INT: |
| 2134 | case VERTEX_FORMAT_UINT4_INT: |
| 2135 | case VERTEX_FORMAT_FIXED4: |
| 2136 | case VERTEX_FORMAT_FLOAT4: |
| 2137 | return 16; |
| 2138 | |
| 2139 | case VERTEX_FORMAT_INVALID: |
| 2140 | default: |
| 2141 | UNREACHABLE(); |
Nico Weber | b5db2b4 | 2018-02-12 15:31:56 -0500 | [diff] [blame] | 2142 | #if !UNREACHABLE_IS_NORETURN |
Corentin Wallez | 0c7baf1 | 2016-12-19 15:43:10 -0500 | [diff] [blame] | 2143 | return 0; |
Nico Weber | b5db2b4 | 2018-02-12 15:31:56 -0500 | [diff] [blame] | 2144 | #endif |
Corentin Wallez | 0c7baf1 | 2016-12-19 15:43:10 -0500 | [diff] [blame] | 2145 | } |
| 2146 | } |
| 2147 | |
Geoff Lang | 6d1ccf0 | 2017-04-24 14:09:58 -0400 | [diff] [blame] | 2148 | bool ValidES3InternalFormat(GLenum internalFormat) |
| 2149 | { |
| 2150 | const InternalFormatInfoMap &formatMap = GetInternalFormatMap(); |
| 2151 | return internalFormat != GL_NONE && formatMap.find(internalFormat) != formatMap.end(); |
| 2152 | } |
| 2153 | |
Jamie Madill | d3dfda2 | 2015-07-06 08:28:49 -0400 | [diff] [blame] | 2154 | VertexFormat::VertexFormat(GLenum typeIn, GLboolean normalizedIn, GLuint componentsIn, bool pureIntegerIn) |
| 2155 | : type(typeIn), |
| 2156 | normalized(normalizedIn), |
| 2157 | components(componentsIn), |
| 2158 | pureInteger(pureIntegerIn) |
| 2159 | { |
| 2160 | // float -> !normalized |
| 2161 | ASSERT(!(type == GL_FLOAT || type == GL_HALF_FLOAT || type == GL_FIXED) || normalized == GL_FALSE); |
| 2162 | } |
| 2163 | |
shannonwoods@chromium.org | b8490f3 | 2013-05-30 00:08:00 +0000 | [diff] [blame] | 2164 | } |