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