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