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