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