blob: 4d75f180fa6cc4282cd861837bf4941522e25f5a [file] [log] [blame]
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001//
Geoff Langcec35902014-04-16 10:52:36 -04002// Copyright (c) 2013-2014 The ANGLE Project Authors. All rights reserved.
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00003// 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 Madill6a6b09c2017-01-12 21:52:29 +00009#include "libANGLE/formatutils.h"
Yuly Novikovd73f8522017-01-13 17:48:57 -050010
11#include "common/mathutil.h"
Geoff Lang2b5420c2014-11-19 14:20:15 -050012#include "libANGLE/Context.h"
13#include "libANGLE/Framebuffer.h"
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000014
Jamie Madille2e406c2016-06-02 13:04:10 -040015using namespace angle;
16
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000017namespace gl
18{
19
Frank Henigman95fb2a12018-05-27 20:17:05 -040020// 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 Madilled4d3422016-10-03 15:45:35 -040023GLenum GetSizedFormatInternal(GLenum format, GLenum type);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000024
Jamie Madilled4d3422016-10-03 15:45:35 -040025namespace
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000026{
Geoff Langca271392017-04-05 12:30:00 -040027using InternalFormatInfoMap =
28 std::unordered_map<GLenum, std::unordered_map<GLenum, InternalFormat>>;
Jamie Madilla3944d42016-07-22 22:13:26 -040029
Jamie Madillca2ff382018-07-11 09:01:17 -040030bool CheckedMathResult(const CheckedNumeric<GLuint> &value, GLuint *resultOut)
31{
32 if (!value.IsValid())
33 {
34 return false;
35 }
36 else
37 {
38 *resultOut = value.ValueOrDie();
39 return true;
40 }
41}
Markus Tavenrath0d665132018-11-18 15:47:02 +010042
Markus Tavenrath0d665132018-11-18 15:47:02 +010043constexpr uint32_t PackTypeInfo(GLuint bytes, bool specialized)
44{
45 // static_assert within constexpr requires c++17
46 // static_assert(isPow2(bytes));
Jamie Madill3f0c4a52019-01-10 10:20:35 -050047 return bytes | (rx::Log2(bytes) << 8) | (specialized << 16);
Markus Tavenrath0d665132018-11-18 15:47:02 +010048}
49
Jamie Madilla3944d42016-07-22 22:13:26 -040050} // anonymous namespace
51
Markus Tavenrath0d665132018-11-18 15:47:02 +010052FormatType::FormatType() : format(GL_NONE), type(GL_NONE) {}
Jamie Madilla3944d42016-07-22 22:13:26 -040053
Markus Tavenrath0d665132018-11-18 15:47:02 +010054FormatType::FormatType(GLenum format_, GLenum type_) : format(format_), type(type_) {}
Jamie Madilla3944d42016-07-22 22:13:26 -040055
56bool FormatType::operator<(const FormatType &other) const
57{
58 if (format != other.format)
59 return format < other.format;
60 return type < other.type;
61}
62
Frank Henigman95fb2a12018-05-27 20:17:05 -040063bool operator<(const Type &a, const Type &b)
Geoff Lang5d601382014-07-22 15:14:06 -040064{
65 return memcmp(&a, &b, sizeof(Type)) < 0;
66}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000067
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000068// Information about internal formats
Geoff Langeb66a6e2016-10-31 13:06:12 -040069static bool AlwaysSupported(const Version &, const Extensions &)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000070{
Geoff Lang493daf52014-07-03 13:38:44 -040071 return true;
72}
73
Geoff Langeb66a6e2016-10-31 13:06:12 -040074static bool NeverSupported(const Version &, const Extensions &)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000075{
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +000076 return false;
77}
78
Geoff Langeb66a6e2016-10-31 13:06:12 -040079template <GLuint minCoreGLMajorVersion, GLuint minCoreGLMinorVersion>
80static bool RequireES(const Version &clientVersion, const Extensions &)
Geoff Lange4a492b2014-06-19 14:14:41 -040081{
Geoff Langeb66a6e2016-10-31 13:06:12 -040082 return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion);
Geoff Lange4a492b2014-06-19 14:14:41 -040083}
84
Geoff Langcec35902014-04-16 10:52:36 -040085// Pointer to a boolean memeber of the Extensions struct
86typedef bool(Extensions::*ExtensionBool);
87
88// Check support for a single extension
89template <ExtensionBool bool1>
Geoff Langeb66a6e2016-10-31 13:06:12 -040090static bool RequireExt(const Version &, const Extensions &extensions)
Geoff Langcec35902014-04-16 10:52:36 -040091{
Geoff Lange4a492b2014-06-19 14:14:41 -040092 return extensions.*bool1;
93}
94
95// Check for a minimum client version or a single extension
Geoff Langeb66a6e2016-10-31 13:06:12 -040096template <GLuint minCoreGLMajorVersion, GLuint minCoreGLMinorVersion, ExtensionBool bool1>
97static bool RequireESOrExt(const Version &clientVersion, const Extensions &extensions)
Geoff Lange4a492b2014-06-19 14:14:41 -040098{
Geoff Langeb66a6e2016-10-31 13:06:12 -040099 return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion) ||
100 extensions.*bool1;
Geoff Lange4a492b2014-06-19 14:14:41 -0400101}
102
103// Check for a minimum client version or two extensions
Geoff Langeb66a6e2016-10-31 13:06:12 -0400104template <GLuint minCoreGLMajorVersion,
105 GLuint minCoreGLMinorVersion,
106 ExtensionBool bool1,
107 ExtensionBool bool2>
108static bool RequireESOrExtAndExt(const Version &clientVersion, const Extensions &extensions)
Geoff Lange4a492b2014-06-19 14:14:41 -0400109{
Geoff Langeb66a6e2016-10-31 13:06:12 -0400110 return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion) ||
111 (extensions.*bool1 && extensions.*bool2);
Geoff Langabce7622014-09-19 16:13:00 -0400112}
113
114// Check for a minimum client version or at least one of two extensions
Geoff Langeb66a6e2016-10-31 13:06:12 -0400115template <GLuint minCoreGLMajorVersion,
116 GLuint minCoreGLMinorVersion,
117 ExtensionBool bool1,
118 ExtensionBool bool2>
119static bool RequireESOrExtOrExt(const Version &clientVersion, const Extensions &extensions)
Geoff Langabce7622014-09-19 16:13:00 -0400120{
Geoff Langeb66a6e2016-10-31 13:06:12 -0400121 return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion) ||
122 extensions.*bool1 || extensions.*bool2;
Geoff Langcec35902014-04-16 10:52:36 -0400123}
124
125// Check support for two extensions
126template <ExtensionBool bool1, ExtensionBool bool2>
Geoff Langeb66a6e2016-10-31 13:06:12 -0400127static bool RequireExtAndExt(const Version &, const Extensions &extensions)
Geoff Langcec35902014-04-16 10:52:36 -0400128{
Geoff Langabce7622014-09-19 16:13:00 -0400129 return extensions.*bool1 && extensions.*bool2;
Geoff Langcec35902014-04-16 10:52:36 -0400130}
131
Geoff Lang60ad73d2015-10-23 10:08:44 -0400132// Check support for either of two extensions
133template <ExtensionBool bool1, ExtensionBool bool2>
Geoff Langeb66a6e2016-10-31 13:06:12 -0400134static bool RequireExtOrExt(const Version &, const Extensions &extensions)
Geoff Lang60ad73d2015-10-23 10:08:44 -0400135{
136 return extensions.*bool1 || extensions.*bool2;
137}
138
Yuly Novikovd0828192018-06-15 15:51:07 -0400139// R8, RG8
140static bool SizedRGSupport(const Version &clientVersion, const Extensions &extensions)
Jamie Madillcd089732015-12-17 09:53:09 -0500141{
Yuly Novikovd0828192018-06-15 15:51:07 -0400142 return clientVersion >= Version(3, 0) || (extensions.textureStorage && extensions.textureRG);
Jamie Madillcd089732015-12-17 09:53:09 -0500143}
144
Yuly Novikovd0828192018-06-15 15:51:07 -0400145// R16F, RG16F with HALF_FLOAT_OES type
146static bool SizedHalfFloatOESRGSupport(const Version &clientVersion, const Extensions &extensions)
Jamie Madillcd089732015-12-17 09:53:09 -0500147{
Yuly Novikovd0828192018-06-15 15:51:07 -0400148 return extensions.textureStorage && extensions.textureHalfFloat && extensions.textureRG;
Jamie Madillcd089732015-12-17 09:53:09 -0500149}
150
Yuly Novikovd0828192018-06-15 15:51:07 -0400151static bool SizedHalfFloatOESRGTextureAttachmentSupport(const Version &clientVersion,
152 const Extensions &extensions)
Geoff Lang677bb6f2017-04-05 12:40:40 -0400153{
Yuly Novikovd0828192018-06-15 15:51:07 -0400154 return SizedHalfFloatOESRGSupport(clientVersion, extensions) && extensions.colorBufferHalfFloat;
Geoff Lang677bb6f2017-04-05 12:40:40 -0400155}
156
Yuly Novikovd0828192018-06-15 15:51:07 -0400157// R16F, RG16F with either HALF_FLOAT_OES or HALF_FLOAT types
158static bool SizedHalfFloatRGSupport(const Version &clientVersion, const Extensions &extensions)
Jamie Madillcd089732015-12-17 09:53:09 -0500159{
Yuly Novikovd0828192018-06-15 15:51:07 -0400160 // HALF_FLOAT
161 if (clientVersion >= Version(3, 0))
162 {
163 return true;
164 }
165 // HALF_FLOAT_OES
166 else
167 {
168 return SizedHalfFloatOESRGSupport(clientVersion, extensions);
169 }
Jamie Madillcd089732015-12-17 09:53:09 -0500170}
171
Yuly Novikovd0828192018-06-15 15:51:07 -0400172static bool SizedHalfFloatRGTextureAttachmentSupport(const Version &clientVersion,
173 const Extensions &extensions)
Jamie Madillcd089732015-12-17 09:53:09 -0500174{
Yuly Novikovd0828192018-06-15 15:51:07 -0400175 // HALF_FLOAT
176 if (clientVersion >= Version(3, 0))
177 {
178 return extensions.colorBufferFloat;
179 }
180 // HALF_FLOAT_OES
181 else
182 {
183 return SizedHalfFloatOESRGTextureAttachmentSupport(clientVersion, extensions);
184 }
Geoff Lang677bb6f2017-04-05 12:40:40 -0400185}
186
Yuly Novikovd0828192018-06-15 15:51:07 -0400187static bool SizedHalfFloatRGRenderbufferSupport(const Version &clientVersion,
188 const Extensions &extensions)
Geoff Lang677bb6f2017-04-05 12:40:40 -0400189{
Yuly Novikovd0828192018-06-15 15:51:07 -0400190 return (clientVersion >= Version(3, 0) ||
191 (extensions.textureHalfFloat && extensions.textureRG)) &&
192 (extensions.colorBufferFloat || extensions.colorBufferHalfFloat);
Geoff Lang677bb6f2017-04-05 12:40:40 -0400193}
194
Yuly Novikovd0828192018-06-15 15:51:07 -0400195// RGB16F, RGBA16F with HALF_FLOAT_OES type
196static bool SizedHalfFloatOESSupport(const Version &clientVersion, const Extensions &extensions)
Geoff Lang677bb6f2017-04-05 12:40:40 -0400197{
Yuly Novikovd0828192018-06-15 15:51:07 -0400198 return extensions.textureStorage && extensions.textureHalfFloat;
199}
200
201static bool SizedHalfFloatOESTextureAttachmentSupport(const Version &clientVersion,
202 const Extensions &extensions)
203{
204 return SizedHalfFloatOESSupport(clientVersion, extensions) && extensions.colorBufferHalfFloat;
205}
206
207// RGB16F, RGBA16F with either HALF_FLOAT_OES or HALF_FLOAT types
208static bool SizedHalfFloatSupport(const Version &clientVersion, const Extensions &extensions)
209{
210 // HALF_FLOAT
211 if (clientVersion >= Version(3, 0))
212 {
213 return true;
214 }
215 // HALF_FLOAT_OES
216 else
217 {
218 return SizedHalfFloatOESSupport(clientVersion, extensions);
219 }
220}
221
222static bool SizedHalfFloatFilterSupport(const Version &clientVersion, const Extensions &extensions)
223{
224 // HALF_FLOAT
225 if (clientVersion >= Version(3, 0))
226 {
227 return true;
228 }
229 // HALF_FLOAT_OES
230 else
231 {
232 return extensions.textureHalfFloatLinear;
233 }
234}
235
236static bool SizedHalfFloatRGBTextureAttachmentSupport(const Version &clientVersion,
237 const Extensions &extensions)
238{
239 // HALF_FLOAT
240 if (clientVersion >= Version(3, 0))
241 {
242 // It is unclear how EXT_color_buffer_half_float applies to ES3.0 and above, however,
243 // dEQP GLES3 es3fFboColorbufferTests.cpp verifies that texture attachment of GL_RGB16F
244 // is possible, so assume that all GLES implementations support it.
245 return extensions.colorBufferHalfFloat;
246 }
247 // HALF_FLOAT_OES
248 else
249 {
250 return SizedHalfFloatOESTextureAttachmentSupport(clientVersion, extensions);
251 }
252}
253
254static bool SizedHalfFloatRGBRenderbufferSupport(const Version &clientVersion,
255 const Extensions &extensions)
256{
257 return (clientVersion >= Version(3, 0) || extensions.textureHalfFloat) &&
Geoff Lang677bb6f2017-04-05 12:40:40 -0400258 extensions.colorBufferHalfFloat;
259}
260
Yuly Novikovd0828192018-06-15 15:51:07 -0400261static bool SizedHalfFloatRGBATextureAttachmentSupport(const Version &clientVersion,
262 const Extensions &extensions)
Geoff Lang677bb6f2017-04-05 12:40:40 -0400263{
Yuly Novikovd0828192018-06-15 15:51:07 -0400264 // HALF_FLOAT
265 if (clientVersion >= Version(3, 0))
266 {
267 return extensions.colorBufferFloat;
268 }
269 // HALF_FLOAT_OES
270 else
271 {
272 return SizedHalfFloatOESTextureAttachmentSupport(clientVersion, extensions);
273 }
Geoff Lang677bb6f2017-04-05 12:40:40 -0400274}
275
Yuly Novikovd0828192018-06-15 15:51:07 -0400276static bool SizedHalfFloatRGBARenderbufferSupport(const Version &clientVersion,
277 const Extensions &extensions)
Geoff Lang677bb6f2017-04-05 12:40:40 -0400278{
Yuly Novikovd0828192018-06-15 15:51:07 -0400279 return (clientVersion >= Version(3, 0) || extensions.textureHalfFloat) &&
280 (extensions.colorBufferFloat || extensions.colorBufferHalfFloat);
Jamie Madillcd089732015-12-17 09:53:09 -0500281}
282
Yuly Novikovd0828192018-06-15 15:51:07 -0400283// R32F, RG32F
284static bool SizedFloatRGSupport(const Version &clientVersion, const Extensions &extensions)
Jamie Madillcd089732015-12-17 09:53:09 -0500285{
Yuly Novikovd0828192018-06-15 15:51:07 -0400286 return clientVersion >= Version(3, 0) ||
287 (extensions.textureStorage && extensions.textureFloat && extensions.textureRG);
Jamie Madillcd089732015-12-17 09:53:09 -0500288}
289
Geoff Lang677bb6f2017-04-05 12:40:40 -0400290// RGB32F
Yuly Novikovd0828192018-06-15 15:51:07 -0400291static bool SizedFloatRGBSupport(const Version &clientVersion, const Extensions &extensions)
Jamie Madillcd089732015-12-17 09:53:09 -0500292{
Yuly Novikovd0828192018-06-15 15:51:07 -0400293 return clientVersion >= Version(3, 0) ||
294 (extensions.textureStorage && extensions.textureFloat) || extensions.colorBufferFloatRGB;
Geoff Lang677bb6f2017-04-05 12:40:40 -0400295}
296
297// RGBA32F
Yuly Novikovd0828192018-06-15 15:51:07 -0400298static bool SizedFloatRGBASupport(const Version &clientVersion, const Extensions &extensions)
Geoff Lang677bb6f2017-04-05 12:40:40 -0400299{
Yuly Novikovd0828192018-06-15 15:51:07 -0400300 return clientVersion >= Version(3, 0) ||
301 (extensions.textureStorage && extensions.textureFloat) ||
302 extensions.colorBufferFloatRGBA;
Geoff Lang677bb6f2017-04-05 12:40:40 -0400303}
304
Yuly Novikovd0828192018-06-15 15:51:07 -0400305static bool SizedFloatRGBATextureAttachmentSupport(const Version &clientVersion,
306 const Extensions &extensions)
Geoff Lang677bb6f2017-04-05 12:40:40 -0400307{
Yuly Novikovd0828192018-06-15 15:51:07 -0400308 return (extensions.colorBufferFloat || extensions.colorBufferFloatRGBA);
Jamie Madillcd089732015-12-17 09:53:09 -0500309}
310
Geoff Lang5d601382014-07-22 15:14:06 -0400311InternalFormat::InternalFormat()
Jamie Madilla3944d42016-07-22 22:13:26 -0400312 : internalFormat(GL_NONE),
Geoff Langca271392017-04-05 12:30:00 -0400313 sized(false),
314 sizedInternalFormat(GL_NONE),
Jamie Madilla3944d42016-07-22 22:13:26 -0400315 redBits(0),
Geoff Lang5d601382014-07-22 15:14:06 -0400316 greenBits(0),
317 blueBits(0),
318 luminanceBits(0),
319 alphaBits(0),
320 sharedBits(0),
321 depthBits(0),
322 stencilBits(0),
323 pixelBytes(0),
324 componentCount(0),
Corentin Wallezbc99bb62015-05-14 17:42:20 -0400325 compressed(false),
Geoff Lang5d601382014-07-22 15:14:06 -0400326 compressedBlockWidth(0),
327 compressedBlockHeight(0),
328 format(GL_NONE),
329 type(GL_NONE),
330 componentType(GL_NONE),
331 colorEncoding(GL_NONE),
Geoff Lang5d601382014-07-22 15:14:06 -0400332 textureSupport(NeverSupported),
Yuly Novikovf15f8862018-06-04 18:59:41 -0400333 filterSupport(NeverSupported),
334 textureAttachmentSupport(NeverSupported),
335 renderbufferSupport(NeverSupported)
Jamie Madillb980c562018-11-27 11:34:27 -0500336{}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000337
Jamie Madillacf2f3a2017-11-21 19:22:44 -0500338InternalFormat::InternalFormat(const InternalFormat &other) = default;
339
Jamie Madilla3944d42016-07-22 22:13:26 -0400340bool InternalFormat::isLUMA() const
341{
342 return ((redBits + greenBits + blueBits + depthBits + stencilBits) == 0 &&
343 (luminanceBits + alphaBits) > 0);
344}
345
Geoff Langf607c602016-09-21 11:46:48 -0400346GLenum InternalFormat::getReadPixelsFormat() const
347{
348 return format;
349}
350
Geoff Langc71ea662017-09-26 17:06:02 -0400351GLenum InternalFormat::getReadPixelsType(const Version &version) const
Geoff Langf607c602016-09-21 11:46:48 -0400352{
353 switch (type)
354 {
355 case GL_HALF_FLOAT:
Geoff Langc71ea662017-09-26 17:06:02 -0400356 case GL_HALF_FLOAT_OES:
357 if (version < Version(3, 0))
358 {
359 // The internal format may have a type of GL_HALF_FLOAT but when exposing this type
360 // as the IMPLEMENTATION_READ_TYPE, only HALF_FLOAT_OES is allowed by
361 // OES_texture_half_float. HALF_FLOAT becomes core in ES3 and is acceptable to use
362 // as an IMPLEMENTATION_READ_TYPE.
363 return GL_HALF_FLOAT_OES;
364 }
365 else
366 {
367 return GL_HALF_FLOAT;
368 }
Geoff Langf607c602016-09-21 11:46:48 -0400369
370 default:
371 return type;
372 }
373}
374
Olli Etuaho50c562d2017-06-06 14:43:30 +0300375bool InternalFormat::isRequiredRenderbufferFormat(const Version &version) const
376{
377 // GLES 3.0.5 section 4.4.2.2:
378 // "Implementations are required to support the same internal formats for renderbuffers as the
379 // required formats for textures enumerated in section 3.8.3.1, with the exception of the color
380 // formats labelled "texture-only"."
381 if (!sized || compressed)
382 {
383 return false;
384 }
385
386 // Luma formats.
387 if (isLUMA())
388 {
389 return false;
390 }
391
392 // Depth/stencil formats.
393 if (depthBits > 0 || stencilBits > 0)
394 {
395 // GLES 2.0.25 table 4.5.
396 // GLES 3.0.5 section 3.8.3.1.
397 // GLES 3.1 table 8.14.
398
399 // Required formats in all versions.
400 switch (internalFormat)
401 {
402 case GL_DEPTH_COMPONENT16:
403 case GL_STENCIL_INDEX8:
404 // Note that STENCIL_INDEX8 is not mentioned in GLES 3.0.5 section 3.8.3.1, but it
405 // is in section 4.4.2.2.
406 return true;
407 default:
408 break;
409 }
410 if (version.major < 3)
411 {
412 return false;
413 }
414 // Required formats in GLES 3.0 and up.
415 switch (internalFormat)
416 {
417 case GL_DEPTH_COMPONENT32F:
418 case GL_DEPTH_COMPONENT24:
419 case GL_DEPTH32F_STENCIL8:
420 case GL_DEPTH24_STENCIL8:
421 return true;
422 default:
423 return false;
424 }
425 }
426
427 // RGBA formats.
428 // GLES 2.0.25 table 4.5.
429 // GLES 3.0.5 section 3.8.3.1.
430 // GLES 3.1 table 8.13.
431
432 // Required formats in all versions.
433 switch (internalFormat)
434 {
435 case GL_RGBA4:
436 case GL_RGB5_A1:
437 case GL_RGB565:
438 return true;
439 default:
440 break;
441 }
442 if (version.major < 3)
443 {
444 return false;
445 }
446
447 if (format == GL_BGRA_EXT)
448 {
449 return false;
450 }
451
452 switch (componentType)
453 {
454 case GL_SIGNED_NORMALIZED:
455 case GL_FLOAT:
456 return false;
457 case GL_UNSIGNED_INT:
458 case GL_INT:
459 // Integer RGB formats are not required renderbuffer formats.
460 if (alphaBits == 0 && blueBits != 0)
461 {
462 return false;
463 }
464 // All integer R and RG formats are required.
465 // Integer RGBA formats including RGB10_A2_UI are required.
466 return true;
467 case GL_UNSIGNED_NORMALIZED:
468 if (internalFormat == GL_SRGB8)
469 {
470 return false;
471 }
472 return true;
473 default:
474 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -0500475#if !UNREACHABLE_IS_NORETURN
Olli Etuaho50c562d2017-06-06 14:43:30 +0300476 return false;
Nico Weberb5db2b42018-02-12 15:31:56 -0500477#endif
Olli Etuaho50c562d2017-06-06 14:43:30 +0300478 }
479}
480
Markus Tavenrath0d665132018-11-18 15:47:02 +0100481Format::Format(GLenum internalFormat) : Format(GetSizedInternalFormatInfo(internalFormat)) {}
Jamie Madilla3944d42016-07-22 22:13:26 -0400482
Markus Tavenrath0d665132018-11-18 15:47:02 +0100483Format::Format(const InternalFormat &internalFormat) : info(&internalFormat) {}
Jamie Madilla3944d42016-07-22 22:13:26 -0400484
Geoff Langca271392017-04-05 12:30:00 -0400485Format::Format(GLenum internalFormat, GLenum type)
486 : info(&GetInternalFormatInfo(internalFormat, type))
Jamie Madillb980c562018-11-27 11:34:27 -0500487{}
Jamie Madilla3944d42016-07-22 22:13:26 -0400488
489Format::Format(const Format &other) = default;
490Format &Format::operator=(const Format &other) = default;
491
Jamie Madilla3944d42016-07-22 22:13:26 -0400492bool Format::valid() const
493{
Geoff Langca271392017-04-05 12:30:00 -0400494 return info->internalFormat != GL_NONE;
Jamie Madilla3944d42016-07-22 22:13:26 -0400495}
496
497// static
498bool Format::SameSized(const Format &a, const Format &b)
499{
Geoff Langca271392017-04-05 12:30:00 -0400500 return a.info->sizedInternalFormat == b.info->sizedInternalFormat;
Jamie Madilla3944d42016-07-22 22:13:26 -0400501}
502
Kenneth Russell69382852017-07-21 16:38:44 -0400503static GLenum EquivalentBlitInternalFormat(GLenum internalformat)
504{
505 // BlitFramebuffer works if the color channels are identically
506 // sized, even if there is a swizzle (for example, blitting from a
507 // multisampled RGBA8 renderbuffer to a BGRA8 texture). This could
508 // be expanded and/or autogenerated if that is found necessary.
509 if (internalformat == GL_BGRA8_EXT)
510 return GL_RGBA8;
511 return internalformat;
512}
513
514// static
515bool Format::EquivalentForBlit(const Format &a, const Format &b)
516{
517 return (EquivalentBlitInternalFormat(a.info->sizedInternalFormat) ==
518 EquivalentBlitInternalFormat(b.info->sizedInternalFormat));
519}
520
Jamie Madilla3944d42016-07-22 22:13:26 -0400521// static
522Format Format::Invalid()
523{
Geoff Langca271392017-04-05 12:30:00 -0400524 static Format invalid(GL_NONE, GL_NONE);
Jamie Madilla3944d42016-07-22 22:13:26 -0400525 return invalid;
526}
527
Yuly Novikovd73f8522017-01-13 17:48:57 -0500528std::ostream &operator<<(std::ostream &os, const Format &fmt)
529{
530 // TODO(ynovikov): return string representation when available
Geoff Langb0e9ddb2018-05-23 11:30:04 -0400531 return FmtHex(os, fmt.info->sizedInternalFormat);
Yuly Novikovd73f8522017-01-13 17:48:57 -0500532}
533
Jamie Madilla3944d42016-07-22 22:13:26 -0400534bool InternalFormat::operator==(const InternalFormat &other) const
535{
Geoff Langca271392017-04-05 12:30:00 -0400536 // We assume all internal formats are unique if they have the same internal format and type
537 return internalFormat == other.internalFormat && type == other.type;
Jamie Madilla3944d42016-07-22 22:13:26 -0400538}
539
540bool InternalFormat::operator!=(const InternalFormat &other) const
541{
Geoff Langca271392017-04-05 12:30:00 -0400542 return !(*this == other);
Jamie Madilla3944d42016-07-22 22:13:26 -0400543}
544
Geoff Langca271392017-04-05 12:30:00 -0400545void InsertFormatInfo(InternalFormatInfoMap *map, const InternalFormat &formatInfo)
Geoff Lang5d601382014-07-22 15:14:06 -0400546{
Geoff Langca271392017-04-05 12:30:00 -0400547 ASSERT(!formatInfo.sized || (*map).count(formatInfo.internalFormat) == 0);
548 ASSERT((*map)[formatInfo.internalFormat].count(formatInfo.type) == 0);
549 (*map)[formatInfo.internalFormat][formatInfo.type] = formatInfo;
Geoff Lang5d601382014-07-22 15:14:06 -0400550}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000551
Jamie Madilla3944d42016-07-22 22:13:26 -0400552void AddRGBAFormat(InternalFormatInfoMap *map,
553 GLenum internalFormat,
Geoff Langca271392017-04-05 12:30:00 -0400554 bool sized,
Jamie Madilla3944d42016-07-22 22:13:26 -0400555 GLuint red,
556 GLuint green,
557 GLuint blue,
558 GLuint alpha,
559 GLuint shared,
560 GLenum format,
561 GLenum type,
562 GLenum componentType,
563 bool srgb,
564 InternalFormat::SupportCheckFunction textureSupport,
Yuly Novikovf15f8862018-06-04 18:59:41 -0400565 InternalFormat::SupportCheckFunction filterSupport,
566 InternalFormat::SupportCheckFunction textureAttachmentSupport,
567 InternalFormat::SupportCheckFunction renderbufferSupport)
Geoff Lang5d601382014-07-22 15:14:06 -0400568{
569 InternalFormat formatInfo;
Jamie Madilla3944d42016-07-22 22:13:26 -0400570 formatInfo.internalFormat = internalFormat;
Geoff Langca271392017-04-05 12:30:00 -0400571 formatInfo.sized = sized;
572 formatInfo.sizedInternalFormat =
573 sized ? internalFormat : GetSizedFormatInternal(internalFormat, type);
Frank Henigman95fb2a12018-05-27 20:17:05 -0400574 formatInfo.redBits = red;
575 formatInfo.greenBits = green;
576 formatInfo.blueBits = blue;
577 formatInfo.alphaBits = alpha;
Geoff Lang5d601382014-07-22 15:14:06 -0400578 formatInfo.sharedBits = shared;
579 formatInfo.pixelBytes = (red + green + blue + alpha + shared) / 8;
Geoff Langca271392017-04-05 12:30:00 -0400580 formatInfo.componentCount =
581 ((red > 0) ? 1 : 0) + ((green > 0) ? 1 : 0) + ((blue > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0);
Geoff Langcb8a9212018-06-28 12:30:36 -0400582 formatInfo.format = format;
583 formatInfo.type = type;
584 formatInfo.componentType = componentType;
585 formatInfo.colorEncoding = (srgb ? GL_SRGB : GL_LINEAR);
586 formatInfo.textureSupport = textureSupport;
Yuly Novikovf15f8862018-06-04 18:59:41 -0400587 formatInfo.filterSupport = filterSupport;
588 formatInfo.textureAttachmentSupport = textureAttachmentSupport;
589 formatInfo.renderbufferSupport = renderbufferSupport;
Geoff Langca271392017-04-05 12:30:00 -0400590
591 InsertFormatInfo(map, formatInfo);
Geoff Lang5d601382014-07-22 15:14:06 -0400592}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000593
Geoff Langca271392017-04-05 12:30:00 -0400594static void AddLUMAFormat(InternalFormatInfoMap *map,
595 GLenum internalFormat,
596 bool sized,
597 GLuint luminance,
598 GLuint alpha,
599 GLenum format,
600 GLenum type,
601 GLenum componentType,
602 InternalFormat::SupportCheckFunction textureSupport,
Yuly Novikovf15f8862018-06-04 18:59:41 -0400603 InternalFormat::SupportCheckFunction filterSupport,
604 InternalFormat::SupportCheckFunction textureAttachmentSupport,
605 InternalFormat::SupportCheckFunction renderbufferSupport)
Geoff Lang5d601382014-07-22 15:14:06 -0400606{
607 InternalFormat formatInfo;
Geoff Langca271392017-04-05 12:30:00 -0400608 formatInfo.internalFormat = internalFormat;
609 formatInfo.sized = sized;
610 formatInfo.sizedInternalFormat =
611 sized ? internalFormat : GetSizedFormatInternal(internalFormat, type);
Geoff Langcb8a9212018-06-28 12:30:36 -0400612 formatInfo.luminanceBits = luminance;
613 formatInfo.alphaBits = alpha;
614 formatInfo.pixelBytes = (luminance + alpha) / 8;
615 formatInfo.componentCount = ((luminance > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0);
616 formatInfo.format = format;
617 formatInfo.type = type;
618 formatInfo.componentType = componentType;
619 formatInfo.colorEncoding = GL_LINEAR;
620 formatInfo.textureSupport = textureSupport;
Yuly Novikovf15f8862018-06-04 18:59:41 -0400621 formatInfo.filterSupport = filterSupport;
622 formatInfo.textureAttachmentSupport = textureAttachmentSupport;
623 formatInfo.renderbufferSupport = renderbufferSupport;
Geoff Langca271392017-04-05 12:30:00 -0400624
625 InsertFormatInfo(map, formatInfo);
Geoff Lang5d601382014-07-22 15:14:06 -0400626}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000627
Jamie Madilla3944d42016-07-22 22:13:26 -0400628void AddDepthStencilFormat(InternalFormatInfoMap *map,
629 GLenum internalFormat,
Geoff Langca271392017-04-05 12:30:00 -0400630 bool sized,
Jamie Madilla3944d42016-07-22 22:13:26 -0400631 GLuint depthBits,
632 GLuint stencilBits,
633 GLuint unusedBits,
634 GLenum format,
635 GLenum type,
636 GLenum componentType,
637 InternalFormat::SupportCheckFunction textureSupport,
Yuly Novikovf15f8862018-06-04 18:59:41 -0400638 InternalFormat::SupportCheckFunction filterSupport,
639 InternalFormat::SupportCheckFunction textureAttachmentSupport,
640 InternalFormat::SupportCheckFunction renderbufferSupport)
Geoff Lang5d601382014-07-22 15:14:06 -0400641{
642 InternalFormat formatInfo;
Jamie Madilla3944d42016-07-22 22:13:26 -0400643 formatInfo.internalFormat = internalFormat;
Geoff Langca271392017-04-05 12:30:00 -0400644 formatInfo.sized = sized;
645 formatInfo.sizedInternalFormat =
646 sized ? internalFormat : GetSizedFormatInternal(internalFormat, type);
Geoff Langcb8a9212018-06-28 12:30:36 -0400647 formatInfo.depthBits = depthBits;
648 formatInfo.stencilBits = stencilBits;
649 formatInfo.pixelBytes = (depthBits + stencilBits + unusedBits) / 8;
650 formatInfo.componentCount = ((depthBits > 0) ? 1 : 0) + ((stencilBits > 0) ? 1 : 0);
651 formatInfo.format = format;
652 formatInfo.type = type;
653 formatInfo.componentType = componentType;
654 formatInfo.colorEncoding = GL_LINEAR;
655 formatInfo.textureSupport = textureSupport;
Yuly Novikovf15f8862018-06-04 18:59:41 -0400656 formatInfo.filterSupport = filterSupport;
657 formatInfo.textureAttachmentSupport = textureAttachmentSupport;
658 formatInfo.renderbufferSupport = renderbufferSupport;
Geoff Langca271392017-04-05 12:30:00 -0400659
660 InsertFormatInfo(map, formatInfo);
Geoff Lang5d601382014-07-22 15:14:06 -0400661}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000662
Geoff Langca271392017-04-05 12:30:00 -0400663void AddCompressedFormat(InternalFormatInfoMap *map,
664 GLenum internalFormat,
665 GLuint compressedBlockWidth,
666 GLuint compressedBlockHeight,
667 GLuint compressedBlockSize,
668 GLuint componentCount,
669 GLenum format,
670 GLenum type,
671 bool srgb,
672 InternalFormat::SupportCheckFunction textureSupport,
Yuly Novikovf15f8862018-06-04 18:59:41 -0400673 InternalFormat::SupportCheckFunction filterSupport,
674 InternalFormat::SupportCheckFunction textureAttachmentSupport,
675 InternalFormat::SupportCheckFunction renderbufferSupport)
Geoff Lang5d601382014-07-22 15:14:06 -0400676{
677 InternalFormat formatInfo;
Geoff Langcb8a9212018-06-28 12:30:36 -0400678 formatInfo.internalFormat = internalFormat;
679 formatInfo.sized = true;
680 formatInfo.sizedInternalFormat = internalFormat;
681 formatInfo.compressedBlockWidth = compressedBlockWidth;
682 formatInfo.compressedBlockHeight = compressedBlockHeight;
683 formatInfo.pixelBytes = compressedBlockSize / 8;
684 formatInfo.componentCount = componentCount;
685 formatInfo.format = format;
686 formatInfo.type = type;
687 formatInfo.componentType = GL_UNSIGNED_NORMALIZED;
688 formatInfo.colorEncoding = (srgb ? GL_SRGB : GL_LINEAR);
689 formatInfo.compressed = true;
690 formatInfo.textureSupport = textureSupport;
Yuly Novikovf15f8862018-06-04 18:59:41 -0400691 formatInfo.filterSupport = filterSupport;
692 formatInfo.textureAttachmentSupport = textureAttachmentSupport;
693 formatInfo.renderbufferSupport = renderbufferSupport;
Geoff Langca271392017-04-05 12:30:00 -0400694
695 InsertFormatInfo(map, formatInfo);
Geoff Lang5d601382014-07-22 15:14:06 -0400696}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000697
Yuly Novikovd0828192018-06-15 15:51:07 -0400698// Notes:
699// 1. "Texture supported" includes all the means by which texture can be created, however,
700// GL_EXT_texture_storage in ES2 is a special case, when only glTexStorage* is allowed.
701// The assumption is that ES2 validation will not check textureSupport for sized formats.
702//
703// 2. Sized half float types are a combination of GL_HALF_FLOAT and GL_HALF_FLOAT_OES support,
704// due to a limitation that only one type for sized formats is allowed.
705//
706// TODO(ynovikov): http://anglebug.com/2846 Verify support fields of BGRA, depth, stencil
707// and compressed formats. Perform texturable check as part of filterable and attachment checks.
Geoff Lange4a492b2014-06-19 14:14:41 -0400708static InternalFormatInfoMap BuildInternalFormatInfoMap()
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000709{
710 InternalFormatInfoMap map;
711
712 // From ES 3.0.1 spec, table 3.12
Geoff Langca271392017-04-05 12:30:00 -0400713 map[GL_NONE][GL_NONE] = InternalFormat();
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000714
Jamie Madilla3944d42016-07-22 22:13:26 -0400715 // clang-format off
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000716
Yuly Novikovd0828192018-06-15 15:51:07 -0400717 // | Internal format |sized| R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
718 AddRGBAFormat(&map, GL_R8, true, 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, SizedRGSupport, AlwaysSupported, SizedRGSupport, RequireESOrExt<3, 0, &Extensions::textureRG> );
719 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 );
720 AddRGBAFormat(&map, GL_RG8, true, 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, SizedRGSupport, AlwaysSupported, SizedRGSupport, RequireESOrExt<3, 0, &Extensions::textureRG> );
721 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 );
722 AddRGBAFormat(&map, GL_RGB8, true, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::textureStorage>, AlwaysSupported, RequireESOrExt<3, 0, &Extensions::textureStorage>, RequireESOrExt<3, 0, &Extensions::rgb8rgba8> );
723 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 );
724 AddRGBAFormat(&map, GL_RGB565, true, 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::textureStorage>, AlwaysSupported, RequireESOrExt<3, 0, &Extensions::textureStorage>, RequireES<2, 0> );
725 AddRGBAFormat(&map, GL_RGBA4, true, 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::textureStorage>, AlwaysSupported, RequireESOrExt<3, 0, &Extensions::textureStorage>, RequireES<2, 0> );
726 AddRGBAFormat(&map, GL_RGB5_A1, true, 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::textureStorage>, AlwaysSupported, RequireESOrExt<3, 0, &Extensions::textureStorage>, RequireES<2, 0> );
727 AddRGBAFormat(&map, GL_RGBA8, true, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::textureStorage>, AlwaysSupported, RequireESOrExt<3, 0, &Extensions::textureStorage>, RequireESOrExt<3, 0, &Extensions::rgb8rgba8> );
728 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 );
729 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> );
730 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> );
731 AddRGBAFormat(&map, GL_SRGB8, true, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireES<3, 0>, AlwaysSupported, NeverSupported, NeverSupported );
732 AddRGBAFormat(&map, GL_SRGB8_ALPHA8, true, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireES<3, 0>, AlwaysSupported, RequireES<3, 0>, RequireESOrExt<3, 0, &Extensions::sRGB> );
733 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> );
734 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 );
735 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> );
736 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> );
737 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> );
738 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> );
739 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> );
740 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> );
741 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> );
742 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> );
743 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> );
744 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> );
745 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> );
746 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> );
747 AddRGBAFormat(&map, GL_RGB8I, true, 8, 8, 8, 0, 0, GL_RGB_INTEGER, GL_BYTE, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported );
748 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 );
749 AddRGBAFormat(&map, GL_RGB16I, true, 16, 16, 16, 0, 0, GL_RGB_INTEGER, GL_SHORT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported );
750 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 );
751 AddRGBAFormat(&map, GL_RGB32I, true, 32, 32, 32, 0, 0, GL_RGB_INTEGER, GL_INT, GL_INT, false, RequireES<3, 0>, NeverSupported, NeverSupported, NeverSupported );
752 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 );
753 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> );
754 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> );
755 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> );
756 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> );
757 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> );
758 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 Madilla3944d42016-07-22 22:13:26 -0400759
Yuly Novikovd0828192018-06-15 15:51:07 -0400760 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>);
761 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>);
762 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.orgb8490f32013-05-30 00:08:00 +0000763
Olli Etuahoceffd202018-01-08 16:39:45 +0200764 // Special format that is used for D3D textures that are used within ANGLE via the
765 // EGL_ANGLE_d3d_texture_client_buffer extension. We don't allow uploading texture images with
766 // this format, but textures in this format can be created from D3D textures, and filtering them
767 // and rendering to them is allowed.
Yuly Novikovd0828192018-06-15 15:51:07 -0400768 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 Etuahoceffd202018-01-08 16:39:45 +0200769
Jamie Madillec0b5802016-07-04 13:11:59 -0400770 // Special format which is not really supported, so always false for all supports.
Yuly Novikovd0828192018-06-15 15:51:07 -0400771 AddRGBAFormat(&map, GL_BGRX8_ANGLEX, true, 8, 8, 8, 0, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported );
772 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 Madillec0b5802016-07-04 13:11:59 -0400773
Yuly Novikovd0828192018-06-15 15:51:07 -0400774 // Floating point formats
775 // | Internal format |sized| R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
776 // It's not possible to have two entries per sized format.
777 // E.g. for GL_RG16F, one with GL_HALF_FLOAT type and the other with GL_HALF_FLOAT_OES type.
778 // So, GL_HALF_FLOAT type formats conditions are merged with GL_HALF_FLOAT_OES type conditions.
779 AddRGBAFormat(&map, GL_R16F, true, 16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT, GL_FLOAT, false, SizedHalfFloatRGSupport, SizedHalfFloatFilterSupport, SizedHalfFloatRGTextureAttachmentSupport, SizedHalfFloatRGRenderbufferSupport );
780 AddRGBAFormat(&map, GL_RG16F, true, 16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT, GL_FLOAT, false, SizedHalfFloatRGSupport, SizedHalfFloatFilterSupport, SizedHalfFloatRGTextureAttachmentSupport, SizedHalfFloatRGRenderbufferSupport );
781 AddRGBAFormat(&map, GL_RGB16F, true, 16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT, GL_FLOAT, false, SizedHalfFloatSupport, SizedHalfFloatFilterSupport, SizedHalfFloatRGBTextureAttachmentSupport, SizedHalfFloatRGBRenderbufferSupport );
782 AddRGBAFormat(&map, GL_RGBA16F, true, 16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT, GL_FLOAT, false, SizedHalfFloatSupport, SizedHalfFloatFilterSupport, SizedHalfFloatRGBATextureAttachmentSupport, SizedHalfFloatRGBARenderbufferSupport );
783 AddRGBAFormat(&map, GL_R32F, true, 32, 0, 0, 0, 0, GL_RED, GL_FLOAT, GL_FLOAT, false, SizedFloatRGSupport, RequireExt<&Extensions::textureFloatLinear>, RequireExt<&Extensions::colorBufferFloat>, RequireExt<&Extensions::colorBufferFloat>);
784 AddRGBAFormat(&map, GL_RG32F, true, 32, 32, 0, 0, 0, GL_RG, GL_FLOAT, GL_FLOAT, false, SizedFloatRGSupport, RequireExt<&Extensions::textureFloatLinear>, RequireExt<&Extensions::colorBufferFloat>, RequireExt<&Extensions::colorBufferFloat>);
785 AddRGBAFormat(&map, GL_RGB32F, true, 32, 32, 32, 0, 0, GL_RGB, GL_FLOAT, GL_FLOAT, false, SizedFloatRGBSupport, RequireExt<&Extensions::textureFloatLinear>, RequireExt<&Extensions::colorBufferFloatRGB>, NeverSupported );
786 AddRGBAFormat(&map, GL_RGBA32F, true, 32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT, GL_FLOAT, false, SizedFloatRGBASupport, RequireExt<&Extensions::textureFloatLinear>, SizedFloatRGBATextureAttachmentSupport, RequireExt<&Extensions::colorBufferFloat>);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000787
788 // Depth stencil formats
Yuly Novikovf15f8862018-06-04 18:59:41 -0400789 // | Internal format |sized| D |S | X | Format | Type | Component type | Texture supported | Filterable | Texture attachment | Renderbuffer |
790 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> );
791 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> );
792 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> );
793 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> );
794 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>);
795 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 Walleze0902642014-11-04 12:32:15 -0800796 // STENCIL_INDEX8 is special-cased, see around the bottom of the list.
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000797
798 // Luminance alpha formats
Yuly Novikovd0828192018-06-15 15:51:07 -0400799 // | Internal format |sized| L | A | Format | Type | Component type | Texture supported | Filterable | Texture attachment | Renderbuffer |
800 AddLUMAFormat(&map, GL_ALPHA8_EXT, true, 0, 8, GL_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, AlwaysSupported, NeverSupported, NeverSupported);
801 AddLUMAFormat(&map, GL_LUMINANCE8_EXT, true, 8, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, AlwaysSupported, NeverSupported, NeverSupported);
802 AddLUMAFormat(&map, GL_LUMINANCE8_ALPHA8_EXT, true, 8, 8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorage>, AlwaysSupported, NeverSupported, NeverSupported);
803 AddLUMAFormat(&map, GL_ALPHA16F_EXT, true, 0, 16, GL_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, NeverSupported, NeverSupported);
804 AddLUMAFormat(&map, GL_LUMINANCE16F_EXT, true, 16, 0, GL_LUMINANCE, GL_HALF_FLOAT_OES, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, NeverSupported, NeverSupported);
805 AddLUMAFormat(&map, GL_LUMINANCE_ALPHA16F_EXT, true, 16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, NeverSupported, NeverSupported);
806 AddLUMAFormat(&map, GL_ALPHA32F_EXT, true, 0, 32, GL_ALPHA, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
807 AddLUMAFormat(&map, GL_LUMINANCE32F_EXT, true, 32, 0, GL_LUMINANCE, GL_FLOAT, GL_FLOAT, RequireExtAndExt<&Extensions::textureStorage, &Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
808 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.orgb8490f32013-05-30 00:08:00 +0000809
810 // Compressed formats, From ES 3.0.1 spec, table 3.16
Geoff Lang836674c2018-11-19 11:45:18 -0500811 // | Internal format |W |H | BS |CC| Format | Type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
812 AddCompressedFormat(&map, GL_COMPRESSED_R11_EAC, 4, 4, 64, 1, GL_RED, GL_UNSIGNED_BYTE, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedEACR11UnsignedTexture>, AlwaysSupported, NeverSupported, NeverSupported);
813 AddCompressedFormat(&map, GL_COMPRESSED_SIGNED_R11_EAC, 4, 4, 64, 1, GL_RED, GL_UNSIGNED_BYTE, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedEACR11SignedTexture>, AlwaysSupported, NeverSupported, NeverSupported);
814 AddCompressedFormat(&map, GL_COMPRESSED_RG11_EAC, 4, 4, 128, 2, GL_RG, GL_UNSIGNED_BYTE, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedEACRG11UnsignedTexture>, AlwaysSupported, NeverSupported, NeverSupported);
815 AddCompressedFormat(&map, GL_COMPRESSED_SIGNED_RG11_EAC, 4, 4, 128, 2, GL_RG, GL_UNSIGNED_BYTE, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedEACRG11SignedTexture>, AlwaysSupported, NeverSupported, NeverSupported);
816 AddCompressedFormat(&map, GL_COMPRESSED_RGB8_ETC2, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedETC2RGB8Texture>, AlwaysSupported, NeverSupported, NeverSupported);
817 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ETC2, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, true, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedETC2sRGB8Texture>, AlwaysSupported, NeverSupported, NeverSupported);
818 AddCompressedFormat(&map, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedETC2PunchthroughARGB8Texture>, AlwaysSupported, NeverSupported, NeverSupported);
819 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, true, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedETC2PunchthroughAsRGB8AlphaTexture>, AlwaysSupported, NeverSupported, NeverSupported);
820 AddCompressedFormat(&map, GL_COMPRESSED_RGBA8_ETC2_EAC, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedETC2RGBA8Texture>, AlwaysSupported, NeverSupported, NeverSupported);
821 AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureETC, &Extensions::compressedETC2sRGB8Alpha8Texture>, AlwaysSupported, NeverSupported, NeverSupported);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000822
823 // From GL_EXT_texture_compression_dxt1
Yuly Novikovf15f8862018-06-04 18:59:41 -0400824 // | Internal format |W |H | BS |CC| Format | Type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
825 AddCompressedFormat(&map, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionDXT1>, AlwaysSupported, NeverSupported, NeverSupported);
826 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.orgb8490f32013-05-30 00:08:00 +0000827
828 // From GL_ANGLE_texture_compression_dxt3
Yuly Novikovf15f8862018-06-04 18:59:41 -0400829 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.orgb8490f32013-05-30 00:08:00 +0000830
831 // From GL_ANGLE_texture_compression_dxt5
Yuly Novikovf15f8862018-06-04 18:59:41 -0400832 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 Lang6ea6f942015-09-11 13:11:22 -0400833
834 // From GL_OES_compressed_ETC1_RGB8_texture
Yuly Novikovf15f8862018-06-04 18:59:41 -0400835 AddCompressedFormat(&map, GL_ETC1_RGB8_OES, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::compressedETC1RGB8Texture>, AlwaysSupported, NeverSupported, NeverSupported);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000836
Kai Ninomiya02f075c2016-12-22 14:55:46 -0800837 // From GL_EXT_texture_compression_s3tc_srgb
Yuly Novikovf15f8862018-06-04 18:59:41 -0400838 // | Internal format |W |H | BS |CC| Format | Type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
839 AddCompressedFormat(&map, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::textureCompressionS3TCsRGB>, AlwaysSupported, NeverSupported, NeverSupported);
840 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);
841 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);
842 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 Ninomiya02f075c2016-12-22 14:55:46 -0800843
Geoff Lang60ad73d2015-10-23 10:08:44 -0400844 // From KHR_texture_compression_astc_hdr
Yuly Novikovf15f8862018-06-04 18:59:41 -0400845 // | Internal format | W | H | BS |CC| Format | Type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
846 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);
847 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);
848 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);
849 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);
850 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);
851 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);
852 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);
853 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);
854 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);
855 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);
856 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);
857 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);
858 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);
859 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 Lang60ad73d2015-10-23 10:08:44 -0400860
Yuly Novikovf15f8862018-06-04 18:59:41 -0400861 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);
862 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);
863 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);
864 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);
865 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);
866 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);
867 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);
868 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);
869 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);
870 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);
871 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);
872 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);
873 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);
874 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 Lang60ad73d2015-10-23 10:08:44 -0400875
Olli Etuahof2ed2992018-10-04 13:54:42 +0300876 // From EXT_texture_compression_bptc
877 // | Internal format | W | H | BS |CC| Format | Type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
878 AddCompressedFormat(&map, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionBPTC>, AlwaysSupported, NeverSupported, NeverSupported);
879 AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::textureCompressionBPTC>, AlwaysSupported, NeverSupported, NeverSupported);
880 AddCompressedFormat(&map, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, 4, 4, 128, 4, GL_RGB, GL_FLOAT, false, RequireExt<&Extensions::textureCompressionBPTC>, AlwaysSupported, NeverSupported, NeverSupported);
881 AddCompressedFormat(&map, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, 4, 4, 128, 4, GL_RGB, GL_FLOAT, false, RequireExt<&Extensions::textureCompressionBPTC>, AlwaysSupported, NeverSupported, NeverSupported);
882
Corentin Walleze0902642014-11-04 12:32:15 -0800883 // For STENCIL_INDEX8 we chose a normalized component type for the following reasons:
884 // - Multisampled buffer are disallowed for non-normalized integer component types and we want to support it for STENCIL_INDEX8
885 // - All other stencil formats (all depth-stencil) are either float or normalized
886 // - It affects only validation of internalformat in RenderbufferStorageMultisample.
Yuly Novikovf15f8862018-06-04 18:59:41 -0400887 // | Internal format |sized|D |S |X | Format | Type | Component type | Texture supported | Filterable | Texture attachment | Renderbuffer |
888 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 Gonge3939b92015-12-01 15:36:51 -0800889
890 // From GL_ANGLE_lossy_etc_decode
Yuly Novikovf15f8862018-06-04 18:59:41 -0400891 // | Internal format |W |H |BS |CC| Format | Type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
892 AddCompressedFormat(&map, GL_ETC1_RGB8_LOSSY_DECODE_ANGLE, 4, 4, 64, 3, GL_RGB, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::lossyETCDecode>, AlwaysSupported, NeverSupported, NeverSupported);
893 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);
894 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);
895 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);
896 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 Gonge3939b92015-12-01 15:36:51 -0800897
Vincent Lang25ab4512016-05-13 18:13:59 +0200898 // From GL_EXT_texture_norm16
Yuly Novikovf15f8862018-06-04 18:59:41 -0400899 // | Internal format |sized| R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
900 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>);
901 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 );
902 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>);
903 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 );
904 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 );
905 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 );
906 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>);
907 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 Lang25ab4512016-05-13 18:13:59 +0200908
Geoff Langca271392017-04-05 12:30:00 -0400909 // Unsized formats
Yuly Novikovd0828192018-06-15 15:51:07 -0400910 // | Internal format |sized | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
911 AddRGBAFormat(&map, GL_RED, false, 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureRG>, AlwaysSupported, RequireExt<&Extensions::textureRG>, NeverSupported);
912 AddRGBAFormat(&map, GL_RED, false, 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
913 AddRGBAFormat(&map, GL_RG, false, 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureRG>, AlwaysSupported, RequireExt<&Extensions::textureRG>, NeverSupported);
914 AddRGBAFormat(&map, GL_RG, false, 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
915 AddRGBAFormat(&map, GL_RGB, false, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported);
916 AddRGBAFormat(&map, GL_RGB, false, 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported);
917 AddRGBAFormat(&map, GL_RGB, false, 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
918 AddRGBAFormat(&map, GL_RGBA, false, 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported);
919 AddRGBAFormat(&map, GL_RGBA, false, 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported);
920 AddRGBAFormat(&map, GL_RGBA, false, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported);
921 AddRGBAFormat(&map, GL_RGBA, false, 10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
922 AddRGBAFormat(&map, GL_RGBA, false, 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
923 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);
924 AddRGBAFormat(&map, GL_SRGB_ALPHA_EXT, false, 8, 8, 8, 8, 0, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireExt<&Extensions::sRGB>, AlwaysSupported, RequireExt<&Extensions::sRGB>, NeverSupported);
925 AddRGBAFormat(&map, GL_BGRA_EXT, false, 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888>, NeverSupported);
Geoff Langca271392017-04-05 12:30:00 -0400926
927 // Unsized integer formats
Yuly Novikovf15f8862018-06-04 18:59:41 -0400928 // |Internal format |sized | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
929 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);
930 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);
931 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);
932 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);
933 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);
934 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);
935 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);
936 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);
937 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);
938 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);
939 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);
940 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);
941 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);
942 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);
943 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);
944 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);
945 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);
946 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);
947 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);
948 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);
949 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);
950 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);
951 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);
952 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);
953 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 Langca271392017-04-05 12:30:00 -0400954
955 // Unsized floating point formats
Yuly Novikovd0828192018-06-15 15:51:07 -0400956 // |Internal format |sized | R | G | B | A |S | Format | Type | Comp | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
957 AddRGBAFormat(&map, GL_RED, false, 16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT, GL_FLOAT, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
958 AddRGBAFormat(&map, GL_RG, false, 16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT, GL_FLOAT, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
959 AddRGBAFormat(&map, GL_RGB, false, 16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT, GL_FLOAT, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
960 AddRGBAFormat(&map, GL_RGBA, false, 16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT, GL_FLOAT, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
961 AddRGBAFormat(&map, GL_RED, false, 16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT_OES, GL_FLOAT, false, RequireExtAndExt<&Extensions::textureHalfFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureHalfFloatLinear>, NeverSupported, NeverSupported);
962 AddRGBAFormat(&map, GL_RG, false, 16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT_OES, GL_FLOAT, false, RequireExtAndExt<&Extensions::textureHalfFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureHalfFloatLinear>, NeverSupported, NeverSupported);
963 AddRGBAFormat(&map, GL_RGB, false, 16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT_OES, GL_FLOAT, false, RequireExt<&Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, NeverSupported, NeverSupported);
964 AddRGBAFormat(&map, GL_RGBA, false, 16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT_OES, GL_FLOAT, false, RequireExt<&Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, RequireExtAndExt<&Extensions::textureHalfFloat, &Extensions::colorBufferHalfFloat>, NeverSupported);
965 AddRGBAFormat(&map, GL_RED, false, 32, 0, 0, 0, 0, GL_RED, GL_FLOAT, GL_FLOAT, false, RequireExtAndExt<&Extensions::textureFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
966 AddRGBAFormat(&map, GL_RG, false, 32, 32, 0, 0, 0, GL_RG, GL_FLOAT, GL_FLOAT, false, RequireExtAndExt<&Extensions::textureFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
967 AddRGBAFormat(&map, GL_RGB, false, 32, 32, 32, 0, 0, GL_RGB, GL_FLOAT, GL_FLOAT, false, RequireExt<&Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
968 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);
969 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);
970 AddRGBAFormat(&map, GL_RGBA, false, 32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT, GL_FLOAT, false, RequireExt<&Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
Geoff Langca271392017-04-05 12:30:00 -0400971
972 // Unsized luminance alpha formats
Yuly Novikovf15f8862018-06-04 18:59:41 -0400973 // | Internal format |sized | L | A | Format | Type | Component type | Texture supported | Filterable | Texture attachment | Renderbuffer |
Yuly Novikovd0828192018-06-15 15:51:07 -0400974 AddLUMAFormat(&map, GL_ALPHA, false, 0, 8, GL_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported, AlwaysSupported, NeverSupported, NeverSupported);
975 AddLUMAFormat(&map, GL_LUMINANCE, false, 8, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported, AlwaysSupported, NeverSupported, NeverSupported);
976 AddLUMAFormat(&map, GL_LUMINANCE_ALPHA, false, 8, 8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, AlwaysSupported, AlwaysSupported, NeverSupported, NeverSupported);
Yuly Novikovf15f8862018-06-04 18:59:41 -0400977 AddLUMAFormat(&map, GL_ALPHA, false, 0, 16, GL_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT, RequireExt<&Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, NeverSupported, NeverSupported);
978 AddLUMAFormat(&map, GL_LUMINANCE, false, 16, 0, GL_LUMINANCE, GL_HALF_FLOAT_OES, GL_FLOAT, RequireExt<&Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, NeverSupported, NeverSupported);
979 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);
980 AddLUMAFormat(&map, GL_ALPHA, false, 0, 32, GL_ALPHA, GL_FLOAT, GL_FLOAT, RequireExt<&Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
981 AddLUMAFormat(&map, GL_LUMINANCE, false, 32, 0, GL_LUMINANCE, GL_FLOAT, GL_FLOAT, RequireExt<&Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
982 AddLUMAFormat(&map, GL_LUMINANCE_ALPHA, false, 32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT, GL_FLOAT, RequireExt<&Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
Geoff Langca271392017-04-05 12:30:00 -0400983
984 // Unsized depth stencil formats
Yuly Novikovf15f8862018-06-04 18:59:41 -0400985 // | Internal format |sized | D |S | X | Format | Type | Component type | Texture supported | Filterable | Texture attachment | Renderbuffer |
986 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> );
987 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> );
988 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> );
989 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>);
990 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>);
991 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 Lang9bbad182015-09-04 11:07:29 -0400992 // clang-format on
Corentin Walleze0902642014-11-04 12:32:15 -0800993
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000994 return map;
995}
996
Geoff Lange4a492b2014-06-19 14:14:41 -0400997static const InternalFormatInfoMap &GetInternalFormatMap()
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +0000998{
Geoff Lange4a492b2014-06-19 14:14:41 -0400999 static const InternalFormatInfoMap formatMap = BuildInternalFormatInfoMap();
1000 return formatMap;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001001}
1002
Geoff Lange4a492b2014-06-19 14:14:41 -04001003static FormatSet BuildAllSizedInternalFormatSet()
Geoff Langcec35902014-04-16 10:52:36 -04001004{
1005 FormatSet result;
1006
Geoff Langca271392017-04-05 12:30:00 -04001007 for (const auto &internalFormat : GetInternalFormatMap())
Geoff Langcec35902014-04-16 10:52:36 -04001008 {
Geoff Langca271392017-04-05 12:30:00 -04001009 for (const auto &type : internalFormat.second)
Geoff Langcec35902014-04-16 10:52:36 -04001010 {
Geoff Langca271392017-04-05 12:30:00 -04001011 if (type.second.sized)
1012 {
1013 // TODO(jmadill): Fix this hack.
1014 if (internalFormat.first == GL_BGR565_ANGLEX)
1015 continue;
Jamie Madillec0b5802016-07-04 13:11:59 -04001016
Geoff Langca271392017-04-05 12:30:00 -04001017 result.insert(internalFormat.first);
1018 }
Geoff Langcec35902014-04-16 10:52:36 -04001019 }
1020 }
1021
1022 return result;
1023}
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001024
Markus Tavenrath0d665132018-11-18 15:47:02 +01001025uint32_t GetPackedTypeInfo(GLenum type)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001026{
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001027 switch (type)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001028 {
Frank Henigman95fb2a12018-05-27 20:17:05 -04001029 case GL_UNSIGNED_BYTE:
1030 case GL_BYTE:
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001031 {
Markus Tavenrath0d665132018-11-18 15:47:02 +01001032 static constexpr uint32_t kPacked = PackTypeInfo(1, false);
1033 return kPacked;
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001034 }
Frank Henigman95fb2a12018-05-27 20:17:05 -04001035 case GL_UNSIGNED_SHORT:
1036 case GL_SHORT:
1037 case GL_HALF_FLOAT:
1038 case GL_HALF_FLOAT_OES:
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001039 {
Markus Tavenrath0d665132018-11-18 15:47:02 +01001040 static constexpr uint32_t kPacked = PackTypeInfo(2, false);
1041 return kPacked;
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001042 }
Frank Henigman95fb2a12018-05-27 20:17:05 -04001043 case GL_UNSIGNED_INT:
1044 case GL_INT:
1045 case GL_FLOAT:
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001046 {
Markus Tavenrath0d665132018-11-18 15:47:02 +01001047 static constexpr uint32_t kPacked = PackTypeInfo(4, false);
1048 return kPacked;
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001049 }
Frank Henigman95fb2a12018-05-27 20:17:05 -04001050 case GL_UNSIGNED_SHORT_5_6_5:
1051 case GL_UNSIGNED_SHORT_4_4_4_4:
1052 case GL_UNSIGNED_SHORT_5_5_5_1:
1053 case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
1054 case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001055 {
Markus Tavenrath0d665132018-11-18 15:47:02 +01001056 static constexpr uint32_t kPacked = PackTypeInfo(2, true);
1057 return kPacked;
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001058 }
Frank Henigman95fb2a12018-05-27 20:17:05 -04001059 case GL_UNSIGNED_INT_2_10_10_10_REV:
1060 case GL_UNSIGNED_INT_24_8:
1061 case GL_UNSIGNED_INT_10F_11F_11F_REV:
1062 case GL_UNSIGNED_INT_5_9_9_9_REV:
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001063 {
1064 ASSERT(GL_UNSIGNED_INT_24_8_OES == GL_UNSIGNED_INT_24_8);
Markus Tavenrath0d665132018-11-18 15:47:02 +01001065 static constexpr uint32_t kPacked = PackTypeInfo(4, true);
1066 return kPacked;
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001067 }
Frank Henigman95fb2a12018-05-27 20:17:05 -04001068 case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001069 {
Markus Tavenrath0d665132018-11-18 15:47:02 +01001070 static constexpr uint32_t kPacked = PackTypeInfo(8, true);
1071 return kPacked;
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001072 }
Frank Henigman95fb2a12018-05-27 20:17:05 -04001073 default:
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001074 {
Markus Tavenrath0d665132018-11-18 15:47:02 +01001075 return 0;
Olli Etuaho31f8f4f2015-03-25 16:03:57 +02001076 }
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001077 }
1078}
1079
Geoff Langca271392017-04-05 12:30:00 -04001080const InternalFormat &GetSizedInternalFormatInfo(GLenum internalFormat)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001081{
Geoff Langca271392017-04-05 12:30:00 -04001082 static const InternalFormat defaultInternalFormat;
Geoff Lang5d601382014-07-22 15:14:06 -04001083 const InternalFormatInfoMap &formatMap = GetInternalFormatMap();
Jamie Madillec0b5802016-07-04 13:11:59 -04001084 auto iter = formatMap.find(internalFormat);
Geoff Langca271392017-04-05 12:30:00 -04001085
1086 // Sized internal formats only have one type per entry
1087 if (iter == formatMap.end() || iter->second.size() != 1)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001088 {
Geoff Lang5d601382014-07-22 15:14:06 -04001089 return defaultInternalFormat;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001090 }
Geoff Langca271392017-04-05 12:30:00 -04001091
1092 const InternalFormat &internalFormatInfo = iter->second.begin()->second;
1093 if (!internalFormatInfo.sized)
1094 {
1095 return defaultInternalFormat;
1096 }
1097
1098 return internalFormatInfo;
1099}
1100
1101const InternalFormat &GetInternalFormatInfo(GLenum internalFormat, GLenum type)
1102{
1103 static const InternalFormat defaultInternalFormat;
1104 const InternalFormatInfoMap &formatMap = GetInternalFormatMap();
1105
1106 auto internalFormatIter = formatMap.find(internalFormat);
1107 if (internalFormatIter == formatMap.end())
1108 {
1109 return defaultInternalFormat;
1110 }
1111
1112 // If the internal format is sized, simply return it without the type check.
1113 if (internalFormatIter->second.size() == 1 && internalFormatIter->second.begin()->second.sized)
1114 {
1115 return internalFormatIter->second.begin()->second;
1116 }
1117
1118 auto typeIter = internalFormatIter->second.find(type);
1119 if (typeIter == internalFormatIter->second.end())
1120 {
1121 return defaultInternalFormat;
1122 }
1123
1124 return typeIter->second;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001125}
1126
Corentin Wallezc5cacd62016-09-14 14:50:24 -04001127GLuint InternalFormat::computePixelBytes(GLenum formatType) const
1128{
1129 const auto &typeInfo = GetTypeInfo(formatType);
1130 GLuint components = typeInfo.specialInterpretation ? 1u : componentCount;
1131 return components * typeInfo.bytes;
1132}
1133
Jamie Madillca2ff382018-07-11 09:01:17 -04001134bool InternalFormat::computeRowPitch(GLenum formatType,
1135 GLsizei width,
1136 GLint alignment,
1137 GLint rowLength,
1138 GLuint *resultOut) const
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001139{
Jamie Madill4b4cdff2016-06-06 13:53:38 -07001140 // Compressed images do not use pack/unpack parameters.
1141 if (compressed)
1142 {
1143 ASSERT(rowLength == 0);
Jamie Madillca2ff382018-07-11 09:01:17 -04001144 return computeCompressedImageSize(Extents(width, 1, 1), resultOut);
Jamie Madill4b4cdff2016-06-06 13:53:38 -07001145 }
1146
Geoff Lang3f234062016-07-13 15:35:45 -04001147 CheckedNumeric<GLuint> checkedWidth(rowLength > 0 ? rowLength : width);
Corentin Wallezc5cacd62016-09-14 14:50:24 -04001148 CheckedNumeric<GLuint> checkedRowBytes = checkedWidth * computePixelBytes(formatType);
Jamie Madill4b4cdff2016-06-06 13:53:38 -07001149
1150 ASSERT(alignment > 0 && isPow2(alignment));
1151 CheckedNumeric<GLuint> checkedAlignment(alignment);
1152 auto aligned = rx::roundUp(checkedRowBytes, checkedAlignment);
Jamie Madillca2ff382018-07-11 09:01:17 -04001153 return CheckedMathResult(aligned, resultOut);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001154}
1155
Jamie Madillca2ff382018-07-11 09:01:17 -04001156bool InternalFormat::computeDepthPitch(GLsizei height,
1157 GLint imageHeight,
1158 GLuint rowPitch,
1159 GLuint *resultOut) const
Corentin Wallez0e487192016-10-03 16:30:38 -04001160{
1161 GLuint rows =
1162 (imageHeight > 0 ? static_cast<GLuint>(imageHeight) : static_cast<GLuint>(height));
1163 CheckedNumeric<GLuint> checkedRowPitch(rowPitch);
1164
Jamie Madillca2ff382018-07-11 09:01:17 -04001165 return CheckedMathResult(checkedRowPitch * rows, resultOut);
Corentin Wallez0e487192016-10-03 16:30:38 -04001166}
1167
Jamie Madillca2ff382018-07-11 09:01:17 -04001168bool InternalFormat::computeDepthPitch(GLenum formatType,
1169 GLsizei width,
1170 GLsizei height,
1171 GLint alignment,
1172 GLint rowLength,
1173 GLint imageHeight,
1174 GLuint *resultOut) const
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001175{
Jamie Madille2e406c2016-06-02 13:04:10 -04001176 GLuint rowPitch = 0;
Jamie Madillca2ff382018-07-11 09:01:17 -04001177 if (!computeRowPitch(formatType, width, alignment, rowLength, &rowPitch))
1178 {
1179 return false;
1180 }
1181 return computeDepthPitch(height, imageHeight, rowPitch, resultOut);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001182}
1183
Jamie Madillca2ff382018-07-11 09:01:17 -04001184bool InternalFormat::computeCompressedImageSize(const Extents &size, GLuint *resultOut) const
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001185{
Jamie Madill513558d2016-06-02 13:04:11 -04001186 CheckedNumeric<GLuint> checkedWidth(size.width);
1187 CheckedNumeric<GLuint> checkedHeight(size.height);
1188 CheckedNumeric<GLuint> checkedDepth(size.depth);
Jamie Madill4b4cdff2016-06-06 13:53:38 -07001189 CheckedNumeric<GLuint> checkedBlockWidth(compressedBlockWidth);
1190 CheckedNumeric<GLuint> checkedBlockHeight(compressedBlockHeight);
Jamie Madille2e406c2016-06-02 13:04:10 -04001191
Jamie Madill4b4cdff2016-06-06 13:53:38 -07001192 ASSERT(compressed);
1193 auto numBlocksWide = (checkedWidth + checkedBlockWidth - 1u) / checkedBlockWidth;
1194 auto numBlocksHigh = (checkedHeight + checkedBlockHeight - 1u) / checkedBlockHeight;
1195 auto bytes = numBlocksWide * numBlocksHigh * pixelBytes * checkedDepth;
Jamie Madillca2ff382018-07-11 09:01:17 -04001196 return CheckedMathResult(bytes, resultOut);
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001197}
1198
Jamie Madillca2ff382018-07-11 09:01:17 -04001199bool InternalFormat::computeSkipBytes(GLenum formatType,
1200 GLuint rowPitch,
1201 GLuint depthPitch,
1202 const PixelStoreStateBase &state,
1203 bool is3D,
1204 GLuint *resultOut) const
Minmin Gongadff67b2015-10-14 10:34:45 -04001205{
Olli Etuaho989cac32016-06-08 16:18:49 -07001206 CheckedNumeric<GLuint> checkedRowPitch(rowPitch);
1207 CheckedNumeric<GLuint> checkedDepthPitch(depthPitch);
Corentin Wallez886de362016-09-27 10:49:35 -04001208 CheckedNumeric<GLuint> checkedSkipImages(static_cast<GLuint>(state.skipImages));
1209 CheckedNumeric<GLuint> checkedSkipRows(static_cast<GLuint>(state.skipRows));
1210 CheckedNumeric<GLuint> checkedSkipPixels(static_cast<GLuint>(state.skipPixels));
Jeff Gilbert31d3deb2018-05-18 18:32:16 -07001211 CheckedNumeric<GLuint> checkedPixelBytes(computePixelBytes(formatType));
Olli Etuaho989cac32016-06-08 16:18:49 -07001212 auto checkedSkipImagesBytes = checkedSkipImages * checkedDepthPitch;
Corentin Wallez886de362016-09-27 10:49:35 -04001213 if (!is3D)
Olli Etuaho989cac32016-06-08 16:18:49 -07001214 {
1215 checkedSkipImagesBytes = 0;
1216 }
1217 auto skipBytes = checkedSkipImagesBytes + checkedSkipRows * checkedRowPitch +
1218 checkedSkipPixels * checkedPixelBytes;
Jamie Madillca2ff382018-07-11 09:01:17 -04001219 return CheckedMathResult(skipBytes, resultOut);
Minmin Gongadff67b2015-10-14 10:34:45 -04001220}
1221
Jamie Madillca2ff382018-07-11 09:01:17 -04001222bool InternalFormat::computePackUnpackEndByte(GLenum formatType,
1223 const Extents &size,
1224 const PixelStoreStateBase &state,
1225 bool is3D,
1226 GLuint *resultOut) const
Corentin Wallezece7c5a2016-09-21 15:28:23 -04001227{
Corentin Wallez886de362016-09-27 10:49:35 -04001228 GLuint rowPitch = 0;
Jamie Madillca2ff382018-07-11 09:01:17 -04001229 if (!computeRowPitch(formatType, size.width, state.alignment, state.rowLength, &rowPitch))
Corentin Wallez0e487192016-10-03 16:30:38 -04001230 {
Jamie Madillca2ff382018-07-11 09:01:17 -04001231 return false;
Corentin Wallez0e487192016-10-03 16:30:38 -04001232 }
1233
Jamie Madillca2ff382018-07-11 09:01:17 -04001234 GLuint depthPitch = 0;
1235 if (is3D && !computeDepthPitch(size.height, state.imageHeight, rowPitch, &depthPitch))
1236 {
1237 return false;
1238 }
1239
1240 CheckedNumeric<GLuint> checkedCopyBytes(0);
Jamie Madill4b4cdff2016-06-06 13:53:38 -07001241 if (compressed)
1242 {
Jamie Madillca2ff382018-07-11 09:01:17 -04001243 GLuint copyBytes = 0;
1244 if (!computeCompressedImageSize(size, &copyBytes))
1245 {
1246 return false;
1247 }
1248 checkedCopyBytes = copyBytes;
Jamie Madill4b4cdff2016-06-06 13:53:38 -07001249 }
Corentin Wallez886de362016-09-27 10:49:35 -04001250 else if (size.height != 0 && (!is3D || size.depth != 0))
Corentin Wallezece7c5a2016-09-21 15:28:23 -04001251 {
Corentin Wallez886de362016-09-27 10:49:35 -04001252 CheckedNumeric<GLuint> bytes = computePixelBytes(formatType);
1253 checkedCopyBytes += size.width * bytes;
1254
1255 CheckedNumeric<GLuint> heightMinusOne = size.height - 1;
1256 checkedCopyBytes += heightMinusOne * rowPitch;
1257
1258 if (is3D)
1259 {
1260 CheckedNumeric<GLuint> depthMinusOne = size.depth - 1;
1261 checkedCopyBytes += depthMinusOne * depthPitch;
1262 }
Corentin Wallezece7c5a2016-09-21 15:28:23 -04001263 }
1264
Jamie Madillca2ff382018-07-11 09:01:17 -04001265 GLuint skipBytes = 0;
1266 if (!computeSkipBytes(formatType, rowPitch, depthPitch, state, is3D, &skipBytes))
1267 {
1268 return false;
1269 }
Corentin Wallezc5cacd62016-09-14 14:50:24 -04001270
Jamie Madillca2ff382018-07-11 09:01:17 -04001271 CheckedNumeric<GLuint> endByte = checkedCopyBytes + CheckedNumeric<GLuint>(skipBytes);
Corentin Wallezc5cacd62016-09-14 14:50:24 -04001272
Jamie Madillca2ff382018-07-11 09:01:17 -04001273 return CheckedMathResult(endByte, resultOut);
Corentin Wallezc5cacd62016-09-14 14:50:24 -04001274}
1275
Geoff Langca271392017-04-05 12:30:00 -04001276GLenum GetUnsizedFormat(GLenum internalFormat)
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001277{
Geoff Langca271392017-04-05 12:30:00 -04001278 auto sizedFormatInfo = GetSizedInternalFormatInfo(internalFormat);
1279 if (sizedFormatInfo.internalFormat != GL_NONE)
Geoff Lang051dbc72015-01-05 15:48:58 -05001280 {
Geoff Langca271392017-04-05 12:30:00 -04001281 return sizedFormatInfo.format;
Geoff Lang051dbc72015-01-05 15:48:58 -05001282 }
Geoff Langca271392017-04-05 12:30:00 -04001283
1284 return internalFormat;
shannonwoods@chromium.orgb8490f32013-05-30 00:08:00 +00001285}
1286
Geoff Lange4a492b2014-06-19 14:14:41 -04001287const FormatSet &GetAllSizedInternalFormats()
Geoff Langcec35902014-04-16 10:52:36 -04001288{
Geoff Lange4a492b2014-06-19 14:14:41 -04001289 static FormatSet formatSet = BuildAllSizedInternalFormatSet();
Geoff Langcec35902014-04-16 10:52:36 -04001290 return formatSet;
1291}
1292
Jamie Madill09e2d932015-07-14 16:40:31 -04001293AttributeType GetAttributeType(GLenum enumValue)
1294{
1295 switch (enumValue)
1296 {
1297 case GL_FLOAT:
1298 return ATTRIBUTE_FLOAT;
1299 case GL_FLOAT_VEC2:
1300 return ATTRIBUTE_VEC2;
1301 case GL_FLOAT_VEC3:
1302 return ATTRIBUTE_VEC3;
1303 case GL_FLOAT_VEC4:
1304 return ATTRIBUTE_VEC4;
1305 case GL_INT:
1306 return ATTRIBUTE_INT;
1307 case GL_INT_VEC2:
1308 return ATTRIBUTE_IVEC2;
1309 case GL_INT_VEC3:
1310 return ATTRIBUTE_IVEC3;
1311 case GL_INT_VEC4:
1312 return ATTRIBUTE_IVEC4;
1313 case GL_UNSIGNED_INT:
1314 return ATTRIBUTE_UINT;
1315 case GL_UNSIGNED_INT_VEC2:
1316 return ATTRIBUTE_UVEC2;
1317 case GL_UNSIGNED_INT_VEC3:
1318 return ATTRIBUTE_UVEC3;
1319 case GL_UNSIGNED_INT_VEC4:
1320 return ATTRIBUTE_UVEC4;
1321 case GL_FLOAT_MAT2:
1322 return ATTRIBUTE_MAT2;
1323 case GL_FLOAT_MAT3:
1324 return ATTRIBUTE_MAT3;
1325 case GL_FLOAT_MAT4:
1326 return ATTRIBUTE_MAT4;
1327 case GL_FLOAT_MAT2x3:
1328 return ATTRIBUTE_MAT2x3;
1329 case GL_FLOAT_MAT2x4:
1330 return ATTRIBUTE_MAT2x4;
1331 case GL_FLOAT_MAT3x2:
1332 return ATTRIBUTE_MAT3x2;
1333 case GL_FLOAT_MAT3x4:
1334 return ATTRIBUTE_MAT3x4;
1335 case GL_FLOAT_MAT4x2:
1336 return ATTRIBUTE_MAT4x2;
1337 case GL_FLOAT_MAT4x3:
1338 return ATTRIBUTE_MAT4x3;
1339 default:
1340 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001341#if !UNREACHABLE_IS_NORETURN
Jamie Madill09e2d932015-07-14 16:40:31 -04001342 return ATTRIBUTE_FLOAT;
Nico Weberb5db2b42018-02-12 15:31:56 -05001343#endif
Jamie Madill09e2d932015-07-14 16:40:31 -04001344 }
1345}
1346
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001347angle::FormatID GetVertexFormatID(VertexAttribType type,
Jamie Madillba365932018-07-18 17:23:46 -04001348 GLboolean normalized,
1349 GLuint components,
1350 bool pureInteger)
Jamie Madilld3dfda22015-07-06 08:28:49 -04001351{
1352 switch (type)
1353 {
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001354 case VertexAttribType::Byte:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001355 switch (components)
1356 {
1357 case 1:
1358 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001359 return angle::FormatID::R8_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001360 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001361 return angle::FormatID::R8_SNORM;
1362 return angle::FormatID::R8_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001363 case 2:
1364 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001365 return angle::FormatID::R8G8_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001366 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001367 return angle::FormatID::R8G8_SNORM;
1368 return angle::FormatID::R8G8_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001369 case 3:
1370 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001371 return angle::FormatID::R8G8B8_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001372 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001373 return angle::FormatID::R8G8B8_SNORM;
1374 return angle::FormatID::R8G8B8_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001375 case 4:
1376 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001377 return angle::FormatID::R8G8B8A8_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001378 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001379 return angle::FormatID::R8G8B8A8_SNORM;
1380 return angle::FormatID::R8G8B8A8_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001381 default:
1382 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001383#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001384 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001385#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001386 }
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001387 case VertexAttribType::UnsignedByte:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001388 switch (components)
1389 {
1390 case 1:
1391 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001392 return angle::FormatID::R8_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001393 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001394 return angle::FormatID::R8_UNORM;
1395 return angle::FormatID::R8_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001396 case 2:
1397 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001398 return angle::FormatID::R8G8_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001399 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001400 return angle::FormatID::R8G8_UNORM;
1401 return angle::FormatID::R8G8_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001402 case 3:
1403 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001404 return angle::FormatID::R8G8B8_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001405 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001406 return angle::FormatID::R8G8B8_UNORM;
1407 return angle::FormatID::R8G8B8_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001408 case 4:
1409 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001410 return angle::FormatID::R8G8B8A8_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001411 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001412 return angle::FormatID::R8G8B8A8_UNORM;
1413 return angle::FormatID::R8G8B8A8_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001414 default:
1415 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001416#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001417 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001418#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001419 }
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001420 case VertexAttribType::Short:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001421 switch (components)
1422 {
1423 case 1:
1424 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001425 return angle::FormatID::R16_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001426 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001427 return angle::FormatID::R16_SNORM;
1428 return angle::FormatID::R16_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001429 case 2:
1430 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001431 return angle::FormatID::R16G16_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001432 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001433 return angle::FormatID::R16G16_SNORM;
1434 return angle::FormatID::R16G16_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001435 case 3:
1436 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001437 return angle::FormatID::R16G16B16_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001438 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001439 return angle::FormatID::R16G16B16_SNORM;
1440 return angle::FormatID::R16G16B16_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001441 case 4:
1442 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001443 return angle::FormatID::R16G16B16A16_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001444 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001445 return angle::FormatID::R16G16B16A16_SNORM;
1446 return angle::FormatID::R16G16B16A16_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001447 default:
1448 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001449#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001450 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001451#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001452 }
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001453 case VertexAttribType::UnsignedShort:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001454 switch (components)
1455 {
1456 case 1:
1457 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001458 return angle::FormatID::R16_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001459 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001460 return angle::FormatID::R16_UNORM;
1461 return angle::FormatID::R16_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001462 case 2:
1463 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001464 return angle::FormatID::R16G16_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001465 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001466 return angle::FormatID::R16G16_UNORM;
1467 return angle::FormatID::R16G16_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001468 case 3:
1469 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001470 return angle::FormatID::R16G16B16_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001471 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001472 return angle::FormatID::R16G16B16_UNORM;
1473 return angle::FormatID::R16G16B16_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001474 case 4:
1475 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001476 return angle::FormatID::R16G16B16A16_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001477 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001478 return angle::FormatID::R16G16B16A16_UNORM;
1479 return angle::FormatID::R16G16B16A16_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001480 default:
1481 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001482#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001483 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001484#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001485 }
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001486 case VertexAttribType::Int:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001487 switch (components)
1488 {
1489 case 1:
1490 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001491 return angle::FormatID::R32_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001492 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001493 return angle::FormatID::R32_SNORM;
1494 return angle::FormatID::R32_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001495 case 2:
1496 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001497 return angle::FormatID::R32G32_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001498 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001499 return angle::FormatID::R32G32_SNORM;
1500 return angle::FormatID::R32G32_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001501 case 3:
1502 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001503 return angle::FormatID::R32G32B32_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001504 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001505 return angle::FormatID::R32G32B32_SNORM;
1506 return angle::FormatID::R32G32B32_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001507 case 4:
1508 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001509 return angle::FormatID::R32G32B32A32_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001510 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001511 return angle::FormatID::R32G32B32A32_SNORM;
1512 return angle::FormatID::R32G32B32A32_SSCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001513 default:
1514 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001515#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001516 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001517#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001518 }
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001519 case VertexAttribType::UnsignedInt:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001520 switch (components)
1521 {
1522 case 1:
1523 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001524 return angle::FormatID::R32_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001525 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001526 return angle::FormatID::R32_UNORM;
1527 return angle::FormatID::R32_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001528 case 2:
1529 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001530 return angle::FormatID::R32G32_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001531 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001532 return angle::FormatID::R32G32_UNORM;
1533 return angle::FormatID::R32G32_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001534 case 3:
1535 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001536 return angle::FormatID::R32G32B32_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001537 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001538 return angle::FormatID::R32G32B32_UNORM;
1539 return angle::FormatID::R32G32B32_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001540 case 4:
1541 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001542 return angle::FormatID::R32G32B32A32_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001543 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001544 return angle::FormatID::R32G32B32A32_UNORM;
1545 return angle::FormatID::R32G32B32A32_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001546 default:
1547 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001548#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001549 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001550#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001551 }
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001552 case VertexAttribType::Float:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001553 switch (components)
1554 {
1555 case 1:
Jamie Madillba365932018-07-18 17:23:46 -04001556 return angle::FormatID::R32_FLOAT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001557 case 2:
Jamie Madillba365932018-07-18 17:23:46 -04001558 return angle::FormatID::R32G32_FLOAT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001559 case 3:
Jamie Madillba365932018-07-18 17:23:46 -04001560 return angle::FormatID::R32G32B32_FLOAT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001561 case 4:
Jamie Madillba365932018-07-18 17:23:46 -04001562 return angle::FormatID::R32G32B32A32_FLOAT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001563 default:
1564 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001565#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001566 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001567#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001568 }
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001569 case VertexAttribType::HalfFloat:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001570 switch (components)
1571 {
1572 case 1:
Jamie Madillba365932018-07-18 17:23:46 -04001573 return angle::FormatID::R16_FLOAT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001574 case 2:
Jamie Madillba365932018-07-18 17:23:46 -04001575 return angle::FormatID::R16G16_FLOAT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001576 case 3:
Jamie Madillba365932018-07-18 17:23:46 -04001577 return angle::FormatID::R16G16B16_FLOAT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001578 case 4:
Jamie Madillba365932018-07-18 17:23:46 -04001579 return angle::FormatID::R16G16B16A16_FLOAT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001580 default:
1581 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001582#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001583 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001584#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001585 }
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001586 case VertexAttribType::Fixed:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001587 switch (components)
1588 {
1589 case 1:
Jamie Madillba365932018-07-18 17:23:46 -04001590 return angle::FormatID::R32_FIXED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001591 case 2:
Jamie Madillba365932018-07-18 17:23:46 -04001592 return angle::FormatID::R32G32_FIXED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001593 case 3:
Jamie Madillba365932018-07-18 17:23:46 -04001594 return angle::FormatID::R32G32B32_FIXED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001595 case 4:
Jamie Madillba365932018-07-18 17:23:46 -04001596 return angle::FormatID::R32G32B32A32_FIXED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001597 default:
1598 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001599#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001600 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001601#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001602 }
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001603 case VertexAttribType::Int2101010:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001604 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001605 return angle::FormatID::R10G10B10A2_SINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001606 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001607 return angle::FormatID::R10G10B10A2_SNORM;
1608 return angle::FormatID::R10G10B10A2_SSCALED;
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001609 case VertexAttribType::UnsignedInt2101010:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001610 if (pureInteger)
Jamie Madillba365932018-07-18 17:23:46 -04001611 return angle::FormatID::R10G10B10A2_UINT;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001612 if (normalized)
Jamie Madillba365932018-07-18 17:23:46 -04001613 return angle::FormatID::R10G10B10A2_UNORM;
1614 return angle::FormatID::R10G10B10A2_USCALED;
Jamie Madilld3dfda22015-07-06 08:28:49 -04001615 default:
1616 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05001617#if !UNREACHABLE_IS_NORETURN
Jamie Madillba365932018-07-18 17:23:46 -04001618 return angle::FormatID::NONE;
Nico Weberb5db2b42018-02-12 15:31:56 -05001619#endif
Jamie Madilld3dfda22015-07-06 08:28:49 -04001620 }
Jamie Madilld3dfda22015-07-06 08:28:49 -04001621}
1622
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001623angle::FormatID GetVertexFormatID(const VertexAttribute &attrib, VertexAttribType currentValueType)
Jamie Madilld3dfda22015-07-06 08:28:49 -04001624{
1625 if (!attrib.enabled)
1626 {
Jamie Madilldd34b3b2019-01-16 09:59:54 -05001627 return GetVertexFormatID(currentValueType, GL_FALSE, 4,
1628 (currentValueType != VertexAttribType::Float));
Jamie Madilld3dfda22015-07-06 08:28:49 -04001629 }
Frank Henigmand633b152018-10-04 23:34:31 -04001630 return GetVertexFormatID(attrib);
Jamie Madilld3dfda22015-07-06 08:28:49 -04001631}
1632
Frank Henigmand633b152018-10-04 23:34:31 -04001633const VertexFormat &GetVertexFormatFromID(angle::FormatID vertexFormatID)
Jamie Madilld3dfda22015-07-06 08:28:49 -04001634{
Frank Henigmand633b152018-10-04 23:34:31 -04001635 switch (vertexFormatID)
Jamie Madilld3dfda22015-07-06 08:28:49 -04001636 {
Frank Henigmand633b152018-10-04 23:34:31 -04001637 case angle::FormatID::R8_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001638 {
1639 static const VertexFormat format(GL_BYTE, GL_FALSE, 1, false);
1640 return format;
1641 }
Frank Henigmand633b152018-10-04 23:34:31 -04001642 case angle::FormatID::R8_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001643 {
1644 static const VertexFormat format(GL_BYTE, GL_TRUE, 1, false);
1645 return format;
1646 }
Frank Henigmand633b152018-10-04 23:34:31 -04001647 case angle::FormatID::R8G8_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001648 {
1649 static const VertexFormat format(GL_BYTE, GL_FALSE, 2, false);
1650 return format;
1651 }
Frank Henigmand633b152018-10-04 23:34:31 -04001652 case angle::FormatID::R8G8_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001653 {
1654 static const VertexFormat format(GL_BYTE, GL_TRUE, 2, false);
1655 return format;
1656 }
Frank Henigmand633b152018-10-04 23:34:31 -04001657 case angle::FormatID::R8G8B8_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001658 {
1659 static const VertexFormat format(GL_BYTE, GL_FALSE, 3, false);
1660 return format;
1661 }
Frank Henigmand633b152018-10-04 23:34:31 -04001662 case angle::FormatID::R8G8B8_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001663 {
1664 static const VertexFormat format(GL_BYTE, GL_TRUE, 3, false);
1665 return format;
1666 }
Frank Henigmand633b152018-10-04 23:34:31 -04001667 case angle::FormatID::R8G8B8A8_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001668 {
1669 static const VertexFormat format(GL_BYTE, GL_FALSE, 4, false);
1670 return format;
1671 }
Frank Henigmand633b152018-10-04 23:34:31 -04001672 case angle::FormatID::R8G8B8A8_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001673 {
1674 static const VertexFormat format(GL_BYTE, GL_TRUE, 4, false);
1675 return format;
1676 }
Frank Henigmand633b152018-10-04 23:34:31 -04001677 case angle::FormatID::R8_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001678 {
1679 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 1, false);
1680 return format;
1681 }
Frank Henigmand633b152018-10-04 23:34:31 -04001682 case angle::FormatID::R8_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001683 {
1684 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 1, false);
1685 return format;
1686 }
Frank Henigmand633b152018-10-04 23:34:31 -04001687 case angle::FormatID::R8G8_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001688 {
1689 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 2, false);
1690 return format;
1691 }
Frank Henigmand633b152018-10-04 23:34:31 -04001692 case angle::FormatID::R8G8_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001693 {
1694 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 2, false);
1695 return format;
1696 }
Frank Henigmand633b152018-10-04 23:34:31 -04001697 case angle::FormatID::R8G8B8_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001698 {
1699 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 3, false);
1700 return format;
1701 }
Frank Henigmand633b152018-10-04 23:34:31 -04001702 case angle::FormatID::R8G8B8_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001703 {
1704 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 3, false);
1705 return format;
1706 }
Frank Henigmand633b152018-10-04 23:34:31 -04001707 case angle::FormatID::R8G8B8A8_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001708 {
1709 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 4, false);
1710 return format;
1711 }
Frank Henigmand633b152018-10-04 23:34:31 -04001712 case angle::FormatID::R8G8B8A8_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001713 {
1714 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 4, false);
1715 return format;
1716 }
Frank Henigmand633b152018-10-04 23:34:31 -04001717 case angle::FormatID::R16_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001718 {
1719 static const VertexFormat format(GL_SHORT, GL_FALSE, 1, false);
1720 return format;
1721 }
Frank Henigmand633b152018-10-04 23:34:31 -04001722 case angle::FormatID::R16_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001723 {
1724 static const VertexFormat format(GL_SHORT, GL_TRUE, 1, false);
1725 return format;
1726 }
Frank Henigmand633b152018-10-04 23:34:31 -04001727 case angle::FormatID::R16G16_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001728 {
1729 static const VertexFormat format(GL_SHORT, GL_FALSE, 2, false);
1730 return format;
1731 }
Frank Henigmand633b152018-10-04 23:34:31 -04001732 case angle::FormatID::R16G16_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001733 {
1734 static const VertexFormat format(GL_SHORT, GL_TRUE, 2, false);
1735 return format;
1736 }
Frank Henigmand633b152018-10-04 23:34:31 -04001737 case angle::FormatID::R16G16B16_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001738 {
1739 static const VertexFormat format(GL_SHORT, GL_FALSE, 3, false);
1740 return format;
1741 }
Frank Henigmand633b152018-10-04 23:34:31 -04001742 case angle::FormatID::R16G16B16_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001743 {
1744 static const VertexFormat format(GL_SHORT, GL_TRUE, 3, false);
1745 return format;
1746 }
Frank Henigmand633b152018-10-04 23:34:31 -04001747 case angle::FormatID::R16G16B16A16_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001748 {
1749 static const VertexFormat format(GL_SHORT, GL_FALSE, 4, false);
1750 return format;
1751 }
Frank Henigmand633b152018-10-04 23:34:31 -04001752 case angle::FormatID::R16G16B16A16_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001753 {
1754 static const VertexFormat format(GL_SHORT, GL_TRUE, 4, false);
1755 return format;
1756 }
Frank Henigmand633b152018-10-04 23:34:31 -04001757 case angle::FormatID::R16_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001758 {
1759 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 1, false);
1760 return format;
1761 }
Frank Henigmand633b152018-10-04 23:34:31 -04001762 case angle::FormatID::R16_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001763 {
1764 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 1, false);
1765 return format;
1766 }
Frank Henigmand633b152018-10-04 23:34:31 -04001767 case angle::FormatID::R16G16_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001768 {
1769 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 2, false);
1770 return format;
1771 }
Frank Henigmand633b152018-10-04 23:34:31 -04001772 case angle::FormatID::R16G16_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001773 {
1774 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 2, false);
1775 return format;
1776 }
Frank Henigmand633b152018-10-04 23:34:31 -04001777 case angle::FormatID::R16G16B16_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001778 {
1779 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 3, false);
1780 return format;
1781 }
Frank Henigmand633b152018-10-04 23:34:31 -04001782 case angle::FormatID::R16G16B16_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001783 {
1784 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 3, false);
1785 return format;
1786 }
Frank Henigmand633b152018-10-04 23:34:31 -04001787 case angle::FormatID::R16G16B16A16_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001788 {
1789 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 4, false);
1790 return format;
1791 }
Frank Henigmand633b152018-10-04 23:34:31 -04001792 case angle::FormatID::R16G16B16A16_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001793 {
1794 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 4, false);
1795 return format;
1796 }
Frank Henigmand633b152018-10-04 23:34:31 -04001797 case angle::FormatID::R32_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001798 {
1799 static const VertexFormat format(GL_INT, GL_FALSE, 1, false);
1800 return format;
1801 }
Frank Henigmand633b152018-10-04 23:34:31 -04001802 case angle::FormatID::R32_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001803 {
1804 static const VertexFormat format(GL_INT, GL_TRUE, 1, false);
1805 return format;
1806 }
Frank Henigmand633b152018-10-04 23:34:31 -04001807 case angle::FormatID::R32G32_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001808 {
1809 static const VertexFormat format(GL_INT, GL_FALSE, 2, false);
1810 return format;
1811 }
Frank Henigmand633b152018-10-04 23:34:31 -04001812 case angle::FormatID::R32G32_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001813 {
1814 static const VertexFormat format(GL_INT, GL_TRUE, 2, false);
1815 return format;
1816 }
Frank Henigmand633b152018-10-04 23:34:31 -04001817 case angle::FormatID::R32G32B32_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001818 {
1819 static const VertexFormat format(GL_INT, GL_FALSE, 3, false);
1820 return format;
1821 }
Frank Henigmand633b152018-10-04 23:34:31 -04001822 case angle::FormatID::R32G32B32_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001823 {
1824 static const VertexFormat format(GL_INT, GL_TRUE, 3, false);
1825 return format;
1826 }
Frank Henigmand633b152018-10-04 23:34:31 -04001827 case angle::FormatID::R32G32B32A32_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001828 {
1829 static const VertexFormat format(GL_INT, GL_FALSE, 4, false);
1830 return format;
1831 }
Frank Henigmand633b152018-10-04 23:34:31 -04001832 case angle::FormatID::R32G32B32A32_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001833 {
1834 static const VertexFormat format(GL_INT, GL_TRUE, 4, false);
1835 return format;
1836 }
Frank Henigmand633b152018-10-04 23:34:31 -04001837 case angle::FormatID::R32_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001838 {
1839 static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 1, false);
1840 return format;
1841 }
Frank Henigmand633b152018-10-04 23:34:31 -04001842 case angle::FormatID::R32_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001843 {
1844 static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 1, false);
1845 return format;
1846 }
Frank Henigmand633b152018-10-04 23:34:31 -04001847 case angle::FormatID::R32G32_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001848 {
1849 static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 2, false);
1850 return format;
1851 }
Frank Henigmand633b152018-10-04 23:34:31 -04001852 case angle::FormatID::R32G32_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001853 {
1854 static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 2, false);
1855 return format;
1856 }
Frank Henigmand633b152018-10-04 23:34:31 -04001857 case angle::FormatID::R32G32B32_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001858 {
1859 static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 3, false);
1860 return format;
1861 }
Frank Henigmand633b152018-10-04 23:34:31 -04001862 case angle::FormatID::R32G32B32_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001863 {
1864 static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 3, false);
1865 return format;
1866 }
Frank Henigmand633b152018-10-04 23:34:31 -04001867 case angle::FormatID::R32G32B32A32_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001868 {
1869 static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 4, false);
1870 return format;
1871 }
Frank Henigmand633b152018-10-04 23:34:31 -04001872 case angle::FormatID::R32G32B32A32_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001873 {
1874 static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 4, false);
1875 return format;
1876 }
Frank Henigmand633b152018-10-04 23:34:31 -04001877 case angle::FormatID::R8_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001878 {
1879 static const VertexFormat format(GL_BYTE, GL_FALSE, 1, true);
1880 return format;
1881 }
Frank Henigmand633b152018-10-04 23:34:31 -04001882 case angle::FormatID::R8G8_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001883 {
1884 static const VertexFormat format(GL_BYTE, GL_FALSE, 2, true);
1885 return format;
1886 }
Frank Henigmand633b152018-10-04 23:34:31 -04001887 case angle::FormatID::R8G8B8_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001888 {
1889 static const VertexFormat format(GL_BYTE, GL_FALSE, 3, true);
1890 return format;
1891 }
Frank Henigmand633b152018-10-04 23:34:31 -04001892 case angle::FormatID::R8G8B8A8_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001893 {
1894 static const VertexFormat format(GL_BYTE, GL_FALSE, 4, true);
1895 return format;
1896 }
Frank Henigmand633b152018-10-04 23:34:31 -04001897 case angle::FormatID::R8_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001898 {
1899 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 1, true);
1900 return format;
1901 }
Frank Henigmand633b152018-10-04 23:34:31 -04001902 case angle::FormatID::R8G8_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001903 {
1904 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 2, true);
1905 return format;
1906 }
Frank Henigmand633b152018-10-04 23:34:31 -04001907 case angle::FormatID::R8G8B8_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001908 {
1909 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 3, true);
1910 return format;
1911 }
Frank Henigmand633b152018-10-04 23:34:31 -04001912 case angle::FormatID::R8G8B8A8_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001913 {
1914 static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 4, true);
1915 return format;
1916 }
Frank Henigmand633b152018-10-04 23:34:31 -04001917 case angle::FormatID::R16_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001918 {
1919 static const VertexFormat format(GL_SHORT, GL_FALSE, 1, true);
1920 return format;
1921 }
Frank Henigmand633b152018-10-04 23:34:31 -04001922 case angle::FormatID::R16G16_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001923 {
1924 static const VertexFormat format(GL_SHORT, GL_FALSE, 2, true);
1925 return format;
1926 }
Frank Henigmand633b152018-10-04 23:34:31 -04001927 case angle::FormatID::R16G16B16_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001928 {
1929 static const VertexFormat format(GL_SHORT, GL_FALSE, 3, true);
1930 return format;
1931 }
Frank Henigmand633b152018-10-04 23:34:31 -04001932 case angle::FormatID::R16G16B16A16_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001933 {
1934 static const VertexFormat format(GL_SHORT, GL_FALSE, 4, true);
1935 return format;
1936 }
Frank Henigmand633b152018-10-04 23:34:31 -04001937 case angle::FormatID::R16_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001938 {
1939 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 1, true);
1940 return format;
1941 }
Frank Henigmand633b152018-10-04 23:34:31 -04001942 case angle::FormatID::R16G16_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001943 {
1944 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 2, true);
1945 return format;
1946 }
Frank Henigmand633b152018-10-04 23:34:31 -04001947 case angle::FormatID::R16G16B16_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001948 {
1949 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 3, true);
1950 return format;
1951 }
Frank Henigmand633b152018-10-04 23:34:31 -04001952 case angle::FormatID::R16G16B16A16_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001953 {
1954 static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 4, true);
1955 return format;
1956 }
Frank Henigmand633b152018-10-04 23:34:31 -04001957 case angle::FormatID::R32_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001958 {
1959 static const VertexFormat format(GL_INT, GL_FALSE, 1, true);
1960 return format;
1961 }
Frank Henigmand633b152018-10-04 23:34:31 -04001962 case angle::FormatID::R32G32_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001963 {
1964 static const VertexFormat format(GL_INT, GL_FALSE, 2, true);
1965 return format;
1966 }
Frank Henigmand633b152018-10-04 23:34:31 -04001967 case angle::FormatID::R32G32B32_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001968 {
1969 static const VertexFormat format(GL_INT, GL_FALSE, 3, true);
1970 return format;
1971 }
Frank Henigmand633b152018-10-04 23:34:31 -04001972 case angle::FormatID::R32G32B32A32_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001973 {
1974 static const VertexFormat format(GL_INT, GL_FALSE, 4, true);
1975 return format;
1976 }
Frank Henigmand633b152018-10-04 23:34:31 -04001977 case angle::FormatID::R32_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001978 {
1979 static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 1, true);
1980 return format;
1981 }
Frank Henigmand633b152018-10-04 23:34:31 -04001982 case angle::FormatID::R32G32_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001983 {
1984 static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 2, true);
1985 return format;
1986 }
Frank Henigmand633b152018-10-04 23:34:31 -04001987 case angle::FormatID::R32G32B32_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001988 {
1989 static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 3, true);
1990 return format;
1991 }
Frank Henigmand633b152018-10-04 23:34:31 -04001992 case angle::FormatID::R32G32B32A32_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001993 {
1994 static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 4, true);
1995 return format;
1996 }
Frank Henigmand633b152018-10-04 23:34:31 -04001997 case angle::FormatID::R32_FIXED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04001998 {
1999 static const VertexFormat format(GL_FIXED, GL_FALSE, 1, false);
2000 return format;
2001 }
Frank Henigmand633b152018-10-04 23:34:31 -04002002 case angle::FormatID::R32G32_FIXED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002003 {
2004 static const VertexFormat format(GL_FIXED, GL_FALSE, 2, false);
2005 return format;
2006 }
Frank Henigmand633b152018-10-04 23:34:31 -04002007 case angle::FormatID::R32G32B32_FIXED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002008 {
2009 static const VertexFormat format(GL_FIXED, GL_FALSE, 3, false);
2010 return format;
2011 }
Frank Henigmand633b152018-10-04 23:34:31 -04002012 case angle::FormatID::R32G32B32A32_FIXED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002013 {
2014 static const VertexFormat format(GL_FIXED, GL_FALSE, 4, false);
2015 return format;
2016 }
Frank Henigmand633b152018-10-04 23:34:31 -04002017 case angle::FormatID::R16_FLOAT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002018 {
2019 static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 1, false);
2020 return format;
2021 }
Frank Henigmand633b152018-10-04 23:34:31 -04002022 case angle::FormatID::R16G16_FLOAT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002023 {
2024 static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 2, false);
2025 return format;
2026 }
Frank Henigmand633b152018-10-04 23:34:31 -04002027 case angle::FormatID::R16G16B16_FLOAT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002028 {
2029 static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 3, false);
2030 return format;
2031 }
Frank Henigmand633b152018-10-04 23:34:31 -04002032 case angle::FormatID::R16G16B16A16_FLOAT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002033 {
2034 static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 4, false);
2035 return format;
2036 }
Frank Henigmand633b152018-10-04 23:34:31 -04002037 case angle::FormatID::R32_FLOAT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002038 {
2039 static const VertexFormat format(GL_FLOAT, GL_FALSE, 1, false);
2040 return format;
2041 }
Frank Henigmand633b152018-10-04 23:34:31 -04002042 case angle::FormatID::R32G32_FLOAT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002043 {
2044 static const VertexFormat format(GL_FLOAT, GL_FALSE, 2, false);
2045 return format;
2046 }
Frank Henigmand633b152018-10-04 23:34:31 -04002047 case angle::FormatID::R32G32B32_FLOAT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002048 {
2049 static const VertexFormat format(GL_FLOAT, GL_FALSE, 3, false);
2050 return format;
2051 }
Frank Henigmand633b152018-10-04 23:34:31 -04002052 case angle::FormatID::R32G32B32A32_FLOAT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002053 {
2054 static const VertexFormat format(GL_FLOAT, GL_FALSE, 4, false);
2055 return format;
2056 }
Frank Henigmand633b152018-10-04 23:34:31 -04002057 case angle::FormatID::R10G10B10A2_SSCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002058 {
2059 static const VertexFormat format(GL_INT_2_10_10_10_REV, GL_FALSE, 4, false);
2060 return format;
2061 }
Frank Henigmand633b152018-10-04 23:34:31 -04002062 case angle::FormatID::R10G10B10A2_USCALED:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002063 {
2064 static const VertexFormat format(GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE, 4, false);
2065 return format;
2066 }
Frank Henigmand633b152018-10-04 23:34:31 -04002067 case angle::FormatID::R10G10B10A2_SNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002068 {
2069 static const VertexFormat format(GL_INT_2_10_10_10_REV, GL_TRUE, 4, false);
2070 return format;
2071 }
Frank Henigmand633b152018-10-04 23:34:31 -04002072 case angle::FormatID::R10G10B10A2_UNORM:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002073 {
2074 static const VertexFormat format(GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 4, false);
2075 return format;
2076 }
Frank Henigmand633b152018-10-04 23:34:31 -04002077 case angle::FormatID::R10G10B10A2_SINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002078 {
2079 static const VertexFormat format(GL_INT_2_10_10_10_REV, GL_FALSE, 4, true);
2080 return format;
2081 }
Frank Henigmand633b152018-10-04 23:34:31 -04002082 case angle::FormatID::R10G10B10A2_UINT:
Jamie Madilld3dfda22015-07-06 08:28:49 -04002083 {
2084 static const VertexFormat format(GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE, 4, true);
2085 return format;
2086 }
2087 default:
2088 {
2089 static const VertexFormat format(GL_NONE, GL_FALSE, 0, false);
2090 return format;
2091 }
2092 }
2093}
2094
Frank Henigmand633b152018-10-04 23:34:31 -04002095size_t GetVertexFormatSize(angle::FormatID vertexFormatID)
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002096{
Frank Henigmand633b152018-10-04 23:34:31 -04002097 switch (vertexFormatID)
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002098 {
Frank Henigmand633b152018-10-04 23:34:31 -04002099 case angle::FormatID::R8_SSCALED:
2100 case angle::FormatID::R8_SNORM:
2101 case angle::FormatID::R8_USCALED:
2102 case angle::FormatID::R8_UNORM:
2103 case angle::FormatID::R8_SINT:
2104 case angle::FormatID::R8_UINT:
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002105 return 1;
2106
Frank Henigmand633b152018-10-04 23:34:31 -04002107 case angle::FormatID::R8G8_SSCALED:
2108 case angle::FormatID::R8G8_SNORM:
2109 case angle::FormatID::R8G8_USCALED:
2110 case angle::FormatID::R8G8_UNORM:
2111 case angle::FormatID::R8G8_SINT:
2112 case angle::FormatID::R8G8_UINT:
2113 case angle::FormatID::R16_SSCALED:
2114 case angle::FormatID::R16_SNORM:
2115 case angle::FormatID::R16_USCALED:
2116 case angle::FormatID::R16_UNORM:
2117 case angle::FormatID::R16_SINT:
2118 case angle::FormatID::R16_UINT:
2119 case angle::FormatID::R16_FLOAT:
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002120 return 2;
2121
Frank Henigmand633b152018-10-04 23:34:31 -04002122 case angle::FormatID::R8G8B8_SSCALED:
2123 case angle::FormatID::R8G8B8_SNORM:
2124 case angle::FormatID::R8G8B8_USCALED:
2125 case angle::FormatID::R8G8B8_UNORM:
2126 case angle::FormatID::R8G8B8_SINT:
2127 case angle::FormatID::R8G8B8_UINT:
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002128 return 3;
2129
Frank Henigmand633b152018-10-04 23:34:31 -04002130 case angle::FormatID::R8G8B8A8_SSCALED:
2131 case angle::FormatID::R8G8B8A8_SNORM:
2132 case angle::FormatID::R8G8B8A8_USCALED:
2133 case angle::FormatID::R8G8B8A8_UNORM:
2134 case angle::FormatID::R8G8B8A8_SINT:
2135 case angle::FormatID::R8G8B8A8_UINT:
2136 case angle::FormatID::R16G16_SSCALED:
2137 case angle::FormatID::R16G16_SNORM:
2138 case angle::FormatID::R16G16_USCALED:
2139 case angle::FormatID::R16G16_UNORM:
2140 case angle::FormatID::R16G16_SINT:
2141 case angle::FormatID::R16G16_UINT:
2142 case angle::FormatID::R32_SSCALED:
2143 case angle::FormatID::R32_SNORM:
2144 case angle::FormatID::R32_USCALED:
2145 case angle::FormatID::R32_UNORM:
2146 case angle::FormatID::R32_SINT:
2147 case angle::FormatID::R32_UINT:
2148 case angle::FormatID::R16G16_FLOAT:
2149 case angle::FormatID::R32_FIXED:
2150 case angle::FormatID::R32_FLOAT:
2151 case angle::FormatID::R10G10B10A2_SSCALED:
2152 case angle::FormatID::R10G10B10A2_USCALED:
2153 case angle::FormatID::R10G10B10A2_SNORM:
2154 case angle::FormatID::R10G10B10A2_UNORM:
2155 case angle::FormatID::R10G10B10A2_SINT:
2156 case angle::FormatID::R10G10B10A2_UINT:
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002157 return 4;
2158
Frank Henigmand633b152018-10-04 23:34:31 -04002159 case angle::FormatID::R16G16B16_SSCALED:
2160 case angle::FormatID::R16G16B16_SNORM:
2161 case angle::FormatID::R16G16B16_USCALED:
2162 case angle::FormatID::R16G16B16_UNORM:
2163 case angle::FormatID::R16G16B16_SINT:
2164 case angle::FormatID::R16G16B16_UINT:
2165 case angle::FormatID::R16G16B16_FLOAT:
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002166 return 6;
2167
Frank Henigmand633b152018-10-04 23:34:31 -04002168 case angle::FormatID::R16G16B16A16_SSCALED:
2169 case angle::FormatID::R16G16B16A16_SNORM:
2170 case angle::FormatID::R16G16B16A16_USCALED:
2171 case angle::FormatID::R16G16B16A16_UNORM:
2172 case angle::FormatID::R16G16B16A16_SINT:
2173 case angle::FormatID::R16G16B16A16_UINT:
2174 case angle::FormatID::R32G32_SSCALED:
2175 case angle::FormatID::R32G32_SNORM:
2176 case angle::FormatID::R32G32_USCALED:
2177 case angle::FormatID::R32G32_UNORM:
2178 case angle::FormatID::R32G32_SINT:
2179 case angle::FormatID::R32G32_UINT:
2180 case angle::FormatID::R16G16B16A16_FLOAT:
2181 case angle::FormatID::R32G32_FIXED:
2182 case angle::FormatID::R32G32_FLOAT:
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002183 return 8;
2184
Frank Henigmand633b152018-10-04 23:34:31 -04002185 case angle::FormatID::R32G32B32_SSCALED:
2186 case angle::FormatID::R32G32B32_SNORM:
2187 case angle::FormatID::R32G32B32_USCALED:
2188 case angle::FormatID::R32G32B32_UNORM:
2189 case angle::FormatID::R32G32B32_SINT:
2190 case angle::FormatID::R32G32B32_UINT:
2191 case angle::FormatID::R32G32B32_FIXED:
2192 case angle::FormatID::R32G32B32_FLOAT:
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002193 return 12;
2194
Frank Henigmand633b152018-10-04 23:34:31 -04002195 case angle::FormatID::R32G32B32A32_SSCALED:
2196 case angle::FormatID::R32G32B32A32_SNORM:
2197 case angle::FormatID::R32G32B32A32_USCALED:
2198 case angle::FormatID::R32G32B32A32_UNORM:
2199 case angle::FormatID::R32G32B32A32_SINT:
2200 case angle::FormatID::R32G32B32A32_UINT:
2201 case angle::FormatID::R32G32B32A32_FIXED:
2202 case angle::FormatID::R32G32B32A32_FLOAT:
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002203 return 16;
2204
Frank Henigmand633b152018-10-04 23:34:31 -04002205 case angle::FormatID::NONE:
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002206 default:
2207 UNREACHABLE();
Nico Weberb5db2b42018-02-12 15:31:56 -05002208#if !UNREACHABLE_IS_NORETURN
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002209 return 0;
Nico Weberb5db2b42018-02-12 15:31:56 -05002210#endif
Corentin Wallez0c7baf12016-12-19 15:43:10 -05002211 }
2212}
2213
Geoff Lang6d1ccf02017-04-24 14:09:58 -04002214bool ValidES3InternalFormat(GLenum internalFormat)
2215{
2216 const InternalFormatInfoMap &formatMap = GetInternalFormatMap();
2217 return internalFormat != GL_NONE && formatMap.find(internalFormat) != formatMap.end();
2218}
2219
Frank Henigman95fb2a12018-05-27 20:17:05 -04002220VertexFormat::VertexFormat(GLenum typeIn,
2221 GLboolean normalizedIn,
2222 GLuint componentsIn,
2223 bool pureIntegerIn)
2224 : type(typeIn), normalized(normalizedIn), components(componentsIn), pureInteger(pureIntegerIn)
Jamie Madilld3dfda22015-07-06 08:28:49 -04002225{
2226 // float -> !normalized
Frank Henigman95fb2a12018-05-27 20:17:05 -04002227 ASSERT(!(type == GL_FLOAT || type == GL_HALF_FLOAT || type == GL_FIXED) ||
2228 normalized == GL_FALSE);
Jamie Madilld3dfda22015-07-06 08:28:49 -04002229}
Markus Tavenrath0d665132018-11-18 15:47:02 +01002230} // namespace gl