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