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