• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "gpu_info_util/SystemInfo.h"
14 #include "libANGLE/Context.h"
15 #include "libANGLE/Framebuffer.h"
16 
17 using namespace angle;
18 
19 namespace gl
20 {
21 
22 // ES2 requires that format is equal to internal format at all glTex*Image2D entry points and the
23 // implementation can decide the true, sized, internal format. The ES2FormatMap determines the
24 // internal format for all valid format and type combinations.
25 GLenum GetSizedFormatInternal(GLenum format, GLenum type);
26 
27 namespace
28 {
CheckedMathResult(const CheckedNumeric<GLuint> & value,GLuint * resultOut)29 bool CheckedMathResult(const CheckedNumeric<GLuint> &value, GLuint *resultOut)
30 {
31     if (!value.IsValid())
32     {
33         return false;
34     }
35     else
36     {
37         *resultOut = value.ValueOrDie();
38         return true;
39     }
40 }
41 
PackTypeInfo(GLuint bytes,bool specialized)42 constexpr uint32_t PackTypeInfo(GLuint bytes, bool specialized)
43 {
44     // static_assert within constexpr requires c++17
45     // static_assert(isPow2(bytes));
46     return bytes | (rx::Log2(bytes) << 8) | (specialized << 16);
47 }
48 
49 }  // anonymous namespace
50 
FormatType()51 FormatType::FormatType() : format(GL_NONE), type(GL_NONE) {}
52 
FormatType(GLenum format_,GLenum type_)53 FormatType::FormatType(GLenum format_, GLenum type_) : format(format_), type(type_) {}
54 
operator <(const FormatType & other) const55 bool FormatType::operator<(const FormatType &other) const
56 {
57     if (format != other.format)
58         return format < other.format;
59     return type < other.type;
60 }
61 
operator <(const Type & a,const Type & b)62 bool operator<(const Type &a, const Type &b)
63 {
64     return memcmp(&a, &b, sizeof(Type)) < 0;
65 }
66 
67 // Information about internal formats
AlwaysSupported(const Version &,const Extensions &)68 static bool AlwaysSupported(const Version &, const Extensions &)
69 {
70     return true;
71 }
72 
NeverSupported(const Version &,const Extensions &)73 static bool NeverSupported(const Version &, const Extensions &)
74 {
75     return false;
76 }
77 
78 template <GLuint minCoreGLMajorVersion, GLuint minCoreGLMinorVersion>
RequireES(const Version & clientVersion,const Extensions &)79 static bool RequireES(const Version &clientVersion, const Extensions &)
80 {
81     return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion);
82 }
83 
84 // Check support for a single extension
85 template <ExtensionBool bool1>
RequireExt(const Version &,const Extensions & extensions)86 static bool RequireExt(const Version &, const Extensions &extensions)
87 {
88     return extensions.*bool1;
89 }
90 
91 // Check for a minimum client version or a single extension
92 template <GLuint minCoreGLMajorVersion, GLuint minCoreGLMinorVersion, ExtensionBool bool1>
RequireESOrExt(const Version & clientVersion,const Extensions & extensions)93 static bool RequireESOrExt(const Version &clientVersion, const Extensions &extensions)
94 {
95     return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion) ||
96            extensions.*bool1;
97 }
98 
99 // Check for a minimum client version or two extensions
100 template <GLuint minCoreGLMajorVersion,
101           GLuint minCoreGLMinorVersion,
102           ExtensionBool bool1,
103           ExtensionBool bool2>
RequireESOrExtAndExt(const Version & clientVersion,const Extensions & extensions)104 static bool RequireESOrExtAndExt(const Version &clientVersion, const Extensions &extensions)
105 {
106     return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion) ||
107            (extensions.*bool1 && extensions.*bool2);
108 }
109 
110 // Check for a minimum client version or at least one of two extensions
111 template <GLuint minCoreGLMajorVersion,
112           GLuint minCoreGLMinorVersion,
113           ExtensionBool bool1,
114           ExtensionBool bool2>
RequireESOrExtOrExt(const Version & clientVersion,const Extensions & extensions)115 static bool RequireESOrExtOrExt(const Version &clientVersion, const Extensions &extensions)
116 {
117     return clientVersion >= Version(minCoreGLMajorVersion, minCoreGLMinorVersion) ||
118            extensions.*bool1 || extensions.*bool2;
119 }
120 
121 // Check support for two extensions
122 template <ExtensionBool bool1, ExtensionBool bool2>
RequireExtAndExt(const Version &,const Extensions & extensions)123 static bool RequireExtAndExt(const Version &, const Extensions &extensions)
124 {
125     return extensions.*bool1 && extensions.*bool2;
126 }
127 
128 // Check support for either of two extensions
129 template <ExtensionBool bool1, ExtensionBool bool2>
RequireExtOrExt(const Version &,const Extensions & extensions)130 static bool RequireExtOrExt(const Version &, const Extensions &extensions)
131 {
132     return extensions.*bool1 || extensions.*bool2;
133 }
134 
135 // Check support for any of three extensions
136 template <ExtensionBool bool1, ExtensionBool bool2, ExtensionBool bool3>
RequireExtOrExtOrExt(const Version &,const Extensions & extensions)137 static bool RequireExtOrExtOrExt(const Version &, const Extensions &extensions)
138 {
139     return extensions.*bool1 || extensions.*bool2 || extensions.*bool3;
140 }
141 
142 // R8, RG8
SizedRGSupport(const Version & clientVersion,const Extensions & extensions)143 static bool SizedRGSupport(const Version &clientVersion, const Extensions &extensions)
144 {
145     return clientVersion >= Version(3, 0) ||
146            (extensions.textureStorageEXT && extensions.textureRgEXT);
147 }
148 
149 // R16F, RG16F with HALF_FLOAT_OES type
SizedHalfFloatOESRGSupport(const Version & clientVersion,const Extensions & extensions)150 static bool SizedHalfFloatOESRGSupport(const Version &clientVersion, const Extensions &extensions)
151 {
152     return extensions.textureStorageEXT && extensions.textureHalfFloatOES &&
153            extensions.textureRgEXT;
154 }
155 
SizedHalfFloatOESRGTextureAttachmentSupport(const Version & clientVersion,const Extensions & extensions)156 static bool SizedHalfFloatOESRGTextureAttachmentSupport(const Version &clientVersion,
157                                                         const Extensions &extensions)
158 {
159     return SizedHalfFloatOESRGSupport(clientVersion, extensions) &&
160            extensions.colorBufferHalfFloatEXT;
161 }
162 
163 // R16F, RG16F with either HALF_FLOAT_OES or HALF_FLOAT types
SizedHalfFloatRGSupport(const Version & clientVersion,const Extensions & extensions)164 static bool SizedHalfFloatRGSupport(const Version &clientVersion, const Extensions &extensions)
165 {
166     // HALF_FLOAT
167     if (clientVersion >= Version(3, 0))
168     {
169         return true;
170     }
171     // HALF_FLOAT_OES
172     else
173     {
174         return SizedHalfFloatOESRGSupport(clientVersion, extensions);
175     }
176 }
177 
SizedHalfFloatRGTextureAttachmentSupport(const Version & clientVersion,const Extensions & extensions)178 static bool SizedHalfFloatRGTextureAttachmentSupport(const Version &clientVersion,
179                                                      const Extensions &extensions)
180 {
181     // HALF_FLOAT
182     if (clientVersion >= Version(3, 0))
183     {
184         // WebGL 2 supports EXT_color_buffer_half_float.
185         return extensions.colorBufferFloatEXT ||
186                (extensions.webglCompatibilityANGLE && extensions.colorBufferHalfFloatEXT);
187     }
188     // HALF_FLOAT_OES
189     else
190     {
191         return SizedHalfFloatOESRGTextureAttachmentSupport(clientVersion, extensions);
192     }
193 }
194 
SizedHalfFloatRGRenderbufferSupport(const Version & clientVersion,const Extensions & extensions)195 static bool SizedHalfFloatRGRenderbufferSupport(const Version &clientVersion,
196                                                 const Extensions &extensions)
197 {
198     return (clientVersion >= Version(3, 0) ||
199             (extensions.textureHalfFloatOES && extensions.textureRgEXT)) &&
200            (extensions.colorBufferFloatEXT || extensions.colorBufferHalfFloatEXT);
201 }
202 
203 // RGB16F, RGBA16F with HALF_FLOAT_OES type
SizedHalfFloatOESSupport(const Version & clientVersion,const Extensions & extensions)204 static bool SizedHalfFloatOESSupport(const Version &clientVersion, const Extensions &extensions)
205 {
206     return extensions.textureStorageEXT && extensions.textureHalfFloatOES;
207 }
208 
SizedHalfFloatOESTextureAttachmentSupport(const Version & clientVersion,const Extensions & extensions)209 static bool SizedHalfFloatOESTextureAttachmentSupport(const Version &clientVersion,
210                                                       const Extensions &extensions)
211 {
212     return SizedHalfFloatOESSupport(clientVersion, extensions) &&
213            extensions.colorBufferHalfFloatEXT;
214 }
215 
216 // RGB16F, RGBA16F with either HALF_FLOAT_OES or HALF_FLOAT types
SizedHalfFloatSupport(const Version & clientVersion,const Extensions & extensions)217 static bool SizedHalfFloatSupport(const Version &clientVersion, const Extensions &extensions)
218 {
219     // HALF_FLOAT
220     if (clientVersion >= Version(3, 0))
221     {
222         return true;
223     }
224     // HALF_FLOAT_OES
225     else
226     {
227         return SizedHalfFloatOESSupport(clientVersion, extensions);
228     }
229 }
230 
SizedHalfFloatFilterSupport(const Version & clientVersion,const Extensions & extensions)231 static bool SizedHalfFloatFilterSupport(const Version &clientVersion, const Extensions &extensions)
232 {
233     // HALF_FLOAT
234     if (clientVersion >= Version(3, 0))
235     {
236         return true;
237     }
238     // HALF_FLOAT_OES
239     else
240     {
241         return extensions.textureHalfFloatLinearOES;
242     }
243 }
244 
SizedHalfFloatRGBTextureAttachmentSupport(const Version & clientVersion,const Extensions & extensions)245 static bool SizedHalfFloatRGBTextureAttachmentSupport(const Version &clientVersion,
246                                                       const Extensions &extensions)
247 {
248     // HALF_FLOAT
249     if (clientVersion >= Version(3, 0))
250     {
251         // It is unclear how EXT_color_buffer_half_float applies to ES3.0 and above, however,
252         // dEQP GLES3 es3fFboColorbufferTests.cpp verifies that texture attachment of GL_RGB16F
253         // is possible, so assume that all GLES implementations support it.
254         // The WebGL version of the extension explicitly forbids RGB formats.
255         return extensions.colorBufferHalfFloatEXT && !extensions.webglCompatibilityANGLE;
256     }
257     // HALF_FLOAT_OES
258     else
259     {
260         return SizedHalfFloatOESTextureAttachmentSupport(clientVersion, extensions);
261     }
262 }
263 
SizedHalfFloatRGBRenderbufferSupport(const Version & clientVersion,const Extensions & extensions)264 static bool SizedHalfFloatRGBRenderbufferSupport(const Version &clientVersion,
265                                                  const Extensions &extensions)
266 {
267     return !extensions.webglCompatibilityANGLE &&
268            ((clientVersion >= Version(3, 0) || extensions.textureHalfFloatOES) &&
269             extensions.colorBufferHalfFloatEXT);
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         // WebGL 2 supports EXT_color_buffer_half_float.
279         return extensions.colorBufferFloatEXT ||
280                (extensions.webglCompatibilityANGLE && extensions.colorBufferHalfFloatEXT);
281     }
282     // HALF_FLOAT_OES
283     else
284     {
285         return SizedHalfFloatOESTextureAttachmentSupport(clientVersion, extensions);
286     }
287 }
288 
SizedHalfFloatRGBARenderbufferSupport(const Version & clientVersion,const Extensions & extensions)289 static bool SizedHalfFloatRGBARenderbufferSupport(const Version &clientVersion,
290                                                   const Extensions &extensions)
291 {
292     return (clientVersion >= Version(3, 0) || extensions.textureHalfFloatOES) &&
293            (extensions.colorBufferFloatEXT || extensions.colorBufferHalfFloatEXT);
294 }
295 
296 // R32F, RG32F
SizedFloatRGSupport(const Version & clientVersion,const Extensions & extensions)297 static bool SizedFloatRGSupport(const Version &clientVersion, const Extensions &extensions)
298 {
299     return clientVersion >= Version(3, 0) ||
300            (extensions.textureStorageEXT && extensions.textureFloatOES && extensions.textureRgEXT);
301 }
302 
303 // RGB32F
SizedFloatRGBSupport(const Version & clientVersion,const Extensions & extensions)304 static bool SizedFloatRGBSupport(const Version &clientVersion, const Extensions &extensions)
305 {
306     return clientVersion >= Version(3, 0) ||
307            (extensions.textureStorageEXT && extensions.textureFloatOES) ||
308            extensions.colorBufferFloatRgbCHROMIUM;
309 }
310 
311 // RGBA32F
SizedFloatRGBASupport(const Version & clientVersion,const Extensions & extensions)312 static bool SizedFloatRGBASupport(const Version &clientVersion, const Extensions &extensions)
313 {
314     return clientVersion >= Version(3, 0) ||
315            (extensions.textureStorageEXT && extensions.textureFloatOES) ||
316            extensions.colorBufferFloatRgbaCHROMIUM;
317 }
318 
SizedFloatRGBARenderableSupport(const Version & clientVersion,const Extensions & extensions)319 static bool SizedFloatRGBARenderableSupport(const Version &clientVersion,
320                                             const Extensions &extensions)
321 {
322     // This logic is the same for both Renderbuffers and TextureAttachment.
323     return extensions.colorBufferFloatRgbaCHROMIUM ||  // ES2
324            extensions.colorBufferFloatEXT;             // ES3
325 }
326 
Float32BlendableSupport(const Version & clientVersion,const Extensions & extensions)327 static bool Float32BlendableSupport(const Version &clientVersion, const Extensions &extensions)
328 {
329     // EXT_float_blend may be exposed on ES2 client contexts. Ensure that RGBA32F is renderable.
330     return (extensions.colorBufferFloatRgbaCHROMIUM || extensions.colorBufferFloatEXT) &&
331            extensions.floatBlendEXT;
332 }
333 
InternalFormat()334 InternalFormat::InternalFormat()
335     : internalFormat(GL_NONE),
336       sized(false),
337       sizedInternalFormat(GL_NONE),
338       redBits(0),
339       greenBits(0),
340       blueBits(0),
341       luminanceBits(0),
342       alphaBits(0),
343       sharedBits(0),
344       depthBits(0),
345       stencilBits(0),
346       pixelBytes(0),
347       componentCount(0),
348       compressed(false),
349       compressedBlockWidth(0),
350       compressedBlockHeight(0),
351       compressedBlockDepth(0),
352       format(GL_NONE),
353       type(GL_NONE),
354       componentType(GL_NONE),
355       colorEncoding(GL_NONE),
356       textureSupport(NeverSupported),
357       filterSupport(NeverSupported),
358       textureAttachmentSupport(NeverSupported),
359       renderbufferSupport(NeverSupported),
360       blendSupport(NeverSupported)
361 {}
362 
363 InternalFormat::InternalFormat(const InternalFormat &other) = default;
364 
365 InternalFormat &InternalFormat::operator=(const InternalFormat &other) = default;
366 
isLUMA() const367 bool InternalFormat::isLUMA() const
368 {
369     return ((redBits + greenBits + blueBits + depthBits + stencilBits) == 0 &&
370             (luminanceBits + alphaBits) > 0);
371 }
372 
getReadPixelsFormat(const Extensions & extensions) const373 GLenum InternalFormat::getReadPixelsFormat(const Extensions &extensions) const
374 {
375     switch (format)
376     {
377         case GL_BGRA_EXT:
378             // BGRA textures may be enabled but calling glReadPixels with BGRA is disallowed without
379             // GL_EXT_texture_format_BGRA8888.  Read as RGBA instead.
380             if (!extensions.readFormatBgraEXT)
381             {
382                 return GL_RGBA;
383             }
384             return GL_BGRA_EXT;
385 
386         default:
387             return format;
388     }
389 }
390 
getReadPixelsType(const Version & version) const391 GLenum InternalFormat::getReadPixelsType(const Version &version) const
392 {
393     switch (type)
394     {
395         case GL_HALF_FLOAT:
396         case GL_HALF_FLOAT_OES:
397             if (version < Version(3, 0))
398             {
399                 // The internal format may have a type of GL_HALF_FLOAT but when exposing this type
400                 // as the IMPLEMENTATION_READ_TYPE, only HALF_FLOAT_OES is allowed by
401                 // OES_texture_half_float.  HALF_FLOAT becomes core in ES3 and is acceptable to use
402                 // as an IMPLEMENTATION_READ_TYPE.
403                 return GL_HALF_FLOAT_OES;
404             }
405             return GL_HALF_FLOAT;
406 
407         default:
408             return type;
409     }
410 }
411 
supportSubImage() const412 bool InternalFormat::supportSubImage() const
413 {
414     return !CompressedFormatRequiresWholeImage(internalFormat);
415 }
416 
isRequiredRenderbufferFormat(const Version & version) const417 bool InternalFormat::isRequiredRenderbufferFormat(const Version &version) const
418 {
419     // GLES 3.0.5 section 4.4.2.2:
420     // "Implementations are required to support the same internal formats for renderbuffers as the
421     // required formats for textures enumerated in section 3.8.3.1, with the exception of the color
422     // formats labelled "texture-only"."
423     if (!sized || compressed)
424     {
425         return false;
426     }
427 
428     // Luma formats.
429     if (isLUMA())
430     {
431         return false;
432     }
433 
434     // Depth/stencil formats.
435     if (depthBits > 0 || stencilBits > 0)
436     {
437         // GLES 2.0.25 table 4.5.
438         // GLES 3.0.5 section 3.8.3.1.
439         // GLES 3.1 table 8.14.
440 
441         // Required formats in all versions.
442         switch (internalFormat)
443         {
444             case GL_DEPTH_COMPONENT16:
445             case GL_STENCIL_INDEX8:
446                 // Note that STENCIL_INDEX8 is not mentioned in GLES 3.0.5 section 3.8.3.1, but it
447                 // is in section 4.4.2.2.
448                 return true;
449             default:
450                 break;
451         }
452         if (version.major < 3)
453         {
454             return false;
455         }
456         // Required formats in GLES 3.0 and up.
457         switch (internalFormat)
458         {
459             case GL_DEPTH_COMPONENT32F:
460             case GL_DEPTH_COMPONENT24:
461             case GL_DEPTH32F_STENCIL8:
462             case GL_DEPTH24_STENCIL8:
463                 return true;
464             default:
465                 return false;
466         }
467     }
468 
469     // RGBA formats.
470     // GLES 2.0.25 table 4.5.
471     // GLES 3.0.5 section 3.8.3.1.
472     // GLES 3.1 table 8.13.
473 
474     // Required formats in all versions.
475     switch (internalFormat)
476     {
477         case GL_RGBA4:
478         case GL_RGB5_A1:
479         case GL_RGB565:
480             return true;
481         default:
482             break;
483     }
484     if (version.major < 3)
485     {
486         return false;
487     }
488 
489     if (format == GL_BGRA_EXT)
490     {
491         return false;
492     }
493 
494     switch (componentType)
495     {
496         case GL_SIGNED_NORMALIZED:
497         case GL_FLOAT:
498             return false;
499         case GL_UNSIGNED_INT:
500         case GL_INT:
501             // Integer RGB formats are not required renderbuffer formats.
502             if (alphaBits == 0 && blueBits != 0)
503             {
504                 return false;
505             }
506             // All integer R and RG formats are required.
507             // Integer RGBA formats including RGB10_A2_UI are required.
508             return true;
509         case GL_UNSIGNED_NORMALIZED:
510             if (internalFormat == GL_SRGB8)
511             {
512                 return false;
513             }
514             return true;
515         default:
516             UNREACHABLE();
517 #if !UNREACHABLE_IS_NORETURN
518             return false;
519 #endif
520     }
521 }
522 
isInt() const523 bool InternalFormat::isInt() const
524 {
525     return componentType == GL_INT || componentType == GL_UNSIGNED_INT;
526 }
527 
isDepthOrStencil() const528 bool InternalFormat::isDepthOrStencil() const
529 {
530     return depthBits != 0 || stencilBits != 0;
531 }
532 
Format(GLenum internalFormat)533 Format::Format(GLenum internalFormat) : Format(GetSizedInternalFormatInfo(internalFormat)) {}
534 
Format(const InternalFormat & internalFormat)535 Format::Format(const InternalFormat &internalFormat) : info(&internalFormat) {}
536 
Format(GLenum internalFormat,GLenum type)537 Format::Format(GLenum internalFormat, GLenum type)
538     : info(&GetInternalFormatInfo(internalFormat, type))
539 {}
540 
541 Format::Format(const Format &other) = default;
542 Format &Format::operator=(const Format &other) = default;
543 
valid() const544 bool Format::valid() const
545 {
546     return info->internalFormat != GL_NONE;
547 }
548 
549 // static
SameSized(const Format & a,const Format & b)550 bool Format::SameSized(const Format &a, const Format &b)
551 {
552     return a.info->sizedInternalFormat == b.info->sizedInternalFormat;
553 }
554 
EquivalentBlitInternalFormat(GLenum internalformat)555 static GLenum EquivalentBlitInternalFormat(GLenum internalformat)
556 {
557     // BlitFramebuffer works if the color channels are identically
558     // sized, even if there is a swizzle (for example, blitting from a
559     // multisampled RGBA8 renderbuffer to a BGRA8 texture). This could
560     // be expanded and/or autogenerated if that is found necessary.
561     if (internalformat == GL_BGRA8_EXT)
562     {
563         return GL_RGBA8;
564     }
565 
566     // GL_ANGLE_rgbx_internal_format: Treat RGBX8 as RGB8, since the X channel is ignored.
567     if (internalformat == GL_RGBX8_ANGLE)
568     {
569         return GL_RGB8;
570     }
571 
572     return internalformat;
573 }
574 
575 // static
EquivalentForBlit(const Format & a,const Format & b)576 bool Format::EquivalentForBlit(const Format &a, const Format &b)
577 {
578     return (EquivalentBlitInternalFormat(a.info->sizedInternalFormat) ==
579             EquivalentBlitInternalFormat(b.info->sizedInternalFormat));
580 }
581 
582 // static
Invalid()583 Format Format::Invalid()
584 {
585     static Format invalid(GL_NONE, GL_NONE);
586     return invalid;
587 }
588 
operator <<(std::ostream & os,const Format & fmt)589 std::ostream &operator<<(std::ostream &os, const Format &fmt)
590 {
591     // TODO(ynovikov): return string representation when available
592     return FmtHex(os, fmt.info->sizedInternalFormat);
593 }
594 
operator ==(const InternalFormat & other) const595 bool InternalFormat::operator==(const InternalFormat &other) const
596 {
597     // We assume all internal formats are unique if they have the same internal format and type
598     return internalFormat == other.internalFormat && type == other.type;
599 }
600 
operator !=(const InternalFormat & other) const601 bool InternalFormat::operator!=(const InternalFormat &other) const
602 {
603     return !(*this == other);
604 }
605 
InsertFormatInfo(InternalFormatInfoMap * map,const InternalFormat & formatInfo)606 void InsertFormatInfo(InternalFormatInfoMap *map, const InternalFormat &formatInfo)
607 {
608     ASSERT(!formatInfo.sized || (*map).count(formatInfo.internalFormat) == 0);
609     ASSERT((*map)[formatInfo.internalFormat].count(formatInfo.type) == 0);
610     (*map)[formatInfo.internalFormat][formatInfo.type] = formatInfo;
611 }
612 
613 // YuvFormatInfo implementation
YuvFormatInfo(GLenum internalFormat,const Extents & yPlaneExtent)614 YuvFormatInfo::YuvFormatInfo(GLenum internalFormat, const Extents &yPlaneExtent)
615 {
616     ASSERT(gl::IsYuvFormat(internalFormat));
617     ASSERT((gl::GetPlaneCount(internalFormat) > 0) && (gl::GetPlaneCount(internalFormat) <= 3));
618 
619     glInternalFormat = internalFormat;
620     planeCount       = gl::GetPlaneCount(internalFormat);
621 
622     // Chroma planes of a YUV format can be subsampled
623     int horizontalSubsampleFactor = 0;
624     int verticalSubsampleFactor   = 0;
625     gl::GetSubSampleFactor(internalFormat, &horizontalSubsampleFactor, &verticalSubsampleFactor);
626 
627     // Compute plane Bpp
628     planeBpp[0] = gl::GetYPlaneBpp(internalFormat);
629     planeBpp[1] = gl::GetChromaPlaneBpp(internalFormat);
630     planeBpp[2] = (planeCount > 2) ? planeBpp[1] : 0;
631 
632     // Compute plane extent
633     planeExtent[0] = yPlaneExtent;
634     planeExtent[1] = {(yPlaneExtent.width / horizontalSubsampleFactor),
635                       (yPlaneExtent.height / verticalSubsampleFactor), yPlaneExtent.depth};
636     planeExtent[2] = (planeCount > 2) ? planeExtent[1] : Extents();
637 
638     // Compute plane pitch
639     planePitch[0] = planeExtent[0].width * planeBpp[0];
640     planePitch[1] = planeExtent[1].width * planeBpp[1];
641     planePitch[2] = planeExtent[2].width * planeBpp[2];
642 
643     // Compute plane size
644     planeSize[0] = planePitch[0] * planeExtent[0].height;
645     planeSize[1] = planePitch[1] * planeExtent[1].height;
646     planeSize[2] = planePitch[2] * planeExtent[2].height;
647 
648     // Compute plane offset
649     planeOffset[0] = 0;
650     planeOffset[1] = planeSize[0];
651     planeOffset[2] = planeSize[0] + planeSize[1];
652 }
653 
654 // YUV format related helpers
IsYuvFormat(GLenum format)655 bool IsYuvFormat(GLenum format)
656 {
657     switch (format)
658     {
659         case GL_G8_B8R8_2PLANE_420_UNORM_ANGLE:
660         case GL_G8_B8_R8_3PLANE_420_UNORM_ANGLE:
661         case GL_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_ANGLE:
662         case GL_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_ANGLE:
663         case GL_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_ANGLE:
664         case GL_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_ANGLE:
665         case GL_G16_B16R16_2PLANE_420_UNORM_ANGLE:
666         case GL_G16_B16_R16_3PLANE_420_UNORM_ANGLE:
667             return true;
668         default:
669             return false;
670     }
671 }
672 
GetPlaneCount(GLenum format)673 uint32_t GetPlaneCount(GLenum format)
674 {
675     switch (format)
676     {
677         case GL_G8_B8R8_2PLANE_420_UNORM_ANGLE:
678         case GL_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_ANGLE:
679         case GL_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_ANGLE:
680         case GL_G16_B16R16_2PLANE_420_UNORM_ANGLE:
681             return 2;
682         case GL_G8_B8_R8_3PLANE_420_UNORM_ANGLE:
683         case GL_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_ANGLE:
684         case GL_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_ANGLE:
685         case GL_G16_B16_R16_3PLANE_420_UNORM_ANGLE:
686             return 3;
687         default:
688             UNREACHABLE();
689             return 0;
690     }
691 }
692 
GetYPlaneBpp(GLenum format)693 uint32_t GetYPlaneBpp(GLenum format)
694 {
695     switch (format)
696     {
697         case GL_G8_B8R8_2PLANE_420_UNORM_ANGLE:
698         case GL_G8_B8_R8_3PLANE_420_UNORM_ANGLE:
699             return 1;
700         case GL_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_ANGLE:
701         case GL_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_ANGLE:
702         case GL_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_ANGLE:
703         case GL_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_ANGLE:
704         case GL_G16_B16R16_2PLANE_420_UNORM_ANGLE:
705         case GL_G16_B16_R16_3PLANE_420_UNORM_ANGLE:
706             return 2;
707         default:
708             UNREACHABLE();
709             return 0;
710     }
711 }
712 
GetChromaPlaneBpp(GLenum format)713 uint32_t GetChromaPlaneBpp(GLenum format)
714 {
715     // 2 plane 420 YUV formats have CbCr channels interleaved.
716     // 3 plane 420 YUV formats have separate Cb and Cr planes.
717     switch (format)
718     {
719         case GL_G8_B8_R8_3PLANE_420_UNORM_ANGLE:
720             return 1;
721         case GL_G8_B8R8_2PLANE_420_UNORM_ANGLE:
722         case GL_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_ANGLE:
723         case GL_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_ANGLE:
724         case GL_G16_B16_R16_3PLANE_420_UNORM_ANGLE:
725             return 2;
726         case GL_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_ANGLE:
727         case GL_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_ANGLE:
728         case GL_G16_B16R16_2PLANE_420_UNORM_ANGLE:
729             return 4;
730         default:
731             UNREACHABLE();
732             return 0;
733     }
734 }
735 
GetSubSampleFactor(GLenum format,int * horizontalSubsampleFactor,int * verticalSubsampleFactor)736 void GetSubSampleFactor(GLenum format, int *horizontalSubsampleFactor, int *verticalSubsampleFactor)
737 {
738     ASSERT(horizontalSubsampleFactor && verticalSubsampleFactor);
739 
740     switch (format)
741     {
742         case GL_G8_B8R8_2PLANE_420_UNORM_ANGLE:
743         case GL_G8_B8_R8_3PLANE_420_UNORM_ANGLE:
744         case GL_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_ANGLE:
745         case GL_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_ANGLE:
746         case GL_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_ANGLE:
747         case GL_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_ANGLE:
748         case GL_G16_B16R16_2PLANE_420_UNORM_ANGLE:
749         case GL_G16_B16_R16_3PLANE_420_UNORM_ANGLE:
750             *horizontalSubsampleFactor = 2;
751             *verticalSubsampleFactor   = 2;
752             break;
753         default:
754             UNREACHABLE();
755             break;
756     }
757 }
758 
759 struct FormatBits
760 {
pixelBytesgl::FormatBits761     constexpr GLuint pixelBytes() const
762     {
763         return (red + green + blue + alpha + shared + unused) / 8;
764     }
componentCountgl::FormatBits765     constexpr GLuint componentCount() const
766     {
767         return ((red > 0) ? 1 : 0) + ((green > 0) ? 1 : 0) + ((blue > 0) ? 1 : 0) +
768                ((alpha > 0) ? 1 : 0);
769     }
validgl::FormatBits770     constexpr bool valid() const
771     {
772         return ((red + green + blue + alpha + shared + unused) % 8) == 0;
773     }
774 
775     GLuint red;
776     GLuint green;
777     GLuint blue;
778     GLuint alpha;
779     GLuint unused;
780     GLuint shared;
781 };
782 
783 template <GLuint red, GLuint green, GLuint blue, GLuint alpha, GLuint unused, GLuint shared>
FB()784 constexpr FormatBits FB()
785 {
786     constexpr FormatBits formatBits = {red, green, blue, alpha, unused, shared};
787     static_assert(formatBits.valid(), "Invalid FormatBits");
788     return formatBits;
789 }
790 
AddRGBAXFormat(InternalFormatInfoMap * map,GLenum internalFormat,bool sized,const FormatBits & formatBits,GLenum format,GLenum type,GLenum componentType,bool srgb,InternalFormat::SupportCheckFunction textureSupport,InternalFormat::SupportCheckFunction filterSupport,InternalFormat::SupportCheckFunction textureAttachmentSupport,InternalFormat::SupportCheckFunction renderbufferSupport,InternalFormat::SupportCheckFunction blendSupport)791 void AddRGBAXFormat(InternalFormatInfoMap *map,
792                     GLenum internalFormat,
793                     bool sized,
794                     const FormatBits &formatBits,
795                     GLenum format,
796                     GLenum type,
797                     GLenum componentType,
798                     bool srgb,
799                     InternalFormat::SupportCheckFunction textureSupport,
800                     InternalFormat::SupportCheckFunction filterSupport,
801                     InternalFormat::SupportCheckFunction textureAttachmentSupport,
802                     InternalFormat::SupportCheckFunction renderbufferSupport,
803                     InternalFormat::SupportCheckFunction blendSupport)
804 {
805     ASSERT(formatBits.valid());
806 
807     InternalFormat formatInfo;
808     formatInfo.internalFormat = internalFormat;
809     formatInfo.sized          = sized;
810     formatInfo.sizedInternalFormat =
811         sized ? internalFormat : GetSizedFormatInternal(internalFormat, type);
812     formatInfo.redBits                  = formatBits.red;
813     formatInfo.greenBits                = formatBits.green;
814     formatInfo.blueBits                 = formatBits.blue;
815     formatInfo.alphaBits                = formatBits.alpha;
816     formatInfo.sharedBits               = formatBits.shared;
817     formatInfo.pixelBytes               = formatBits.pixelBytes();
818     formatInfo.componentCount           = formatBits.componentCount();
819     formatInfo.format                   = format;
820     formatInfo.type                     = type;
821     formatInfo.componentType            = componentType;
822     formatInfo.colorEncoding            = (srgb ? GL_SRGB : GL_LINEAR);
823     formatInfo.textureSupport           = textureSupport;
824     formatInfo.filterSupport            = filterSupport;
825     formatInfo.textureAttachmentSupport = textureAttachmentSupport;
826     formatInfo.renderbufferSupport      = renderbufferSupport;
827     formatInfo.blendSupport             = blendSupport;
828 
829     InsertFormatInfo(map, formatInfo);
830 }
831 
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)832 void AddRGBAFormat(InternalFormatInfoMap *map,
833                    GLenum internalFormat,
834                    bool sized,
835                    GLuint red,
836                    GLuint green,
837                    GLuint blue,
838                    GLuint alpha,
839                    GLuint shared,
840                    GLenum format,
841                    GLenum type,
842                    GLenum componentType,
843                    bool srgb,
844                    InternalFormat::SupportCheckFunction textureSupport,
845                    InternalFormat::SupportCheckFunction filterSupport,
846                    InternalFormat::SupportCheckFunction textureAttachmentSupport,
847                    InternalFormat::SupportCheckFunction renderbufferSupport,
848                    InternalFormat::SupportCheckFunction blendSupport)
849 {
850     return AddRGBAXFormat(map, internalFormat, sized, {red, green, blue, alpha, 0, shared}, format,
851                           type, componentType, srgb, textureSupport, filterSupport,
852                           textureAttachmentSupport, renderbufferSupport, blendSupport);
853 }
854 
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)855 static void AddLUMAFormat(InternalFormatInfoMap *map,
856                           GLenum internalFormat,
857                           bool sized,
858                           GLuint luminance,
859                           GLuint alpha,
860                           GLenum format,
861                           GLenum type,
862                           GLenum componentType,
863                           InternalFormat::SupportCheckFunction textureSupport,
864                           InternalFormat::SupportCheckFunction filterSupport,
865                           InternalFormat::SupportCheckFunction textureAttachmentSupport,
866                           InternalFormat::SupportCheckFunction renderbufferSupport,
867                           InternalFormat::SupportCheckFunction blendSupport)
868 {
869     InternalFormat formatInfo;
870     formatInfo.internalFormat = internalFormat;
871     formatInfo.sized          = sized;
872     formatInfo.sizedInternalFormat =
873         sized ? internalFormat : GetSizedFormatInternal(internalFormat, type);
874     formatInfo.luminanceBits            = luminance;
875     formatInfo.alphaBits                = alpha;
876     formatInfo.pixelBytes               = (luminance + alpha) / 8;
877     formatInfo.componentCount           = ((luminance > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0);
878     formatInfo.format                   = format;
879     formatInfo.type                     = type;
880     formatInfo.componentType            = componentType;
881     formatInfo.colorEncoding            = GL_LINEAR;
882     formatInfo.textureSupport           = textureSupport;
883     formatInfo.filterSupport            = filterSupport;
884     formatInfo.textureAttachmentSupport = textureAttachmentSupport;
885     formatInfo.renderbufferSupport      = renderbufferSupport;
886     formatInfo.blendSupport             = blendSupport;
887 
888     InsertFormatInfo(map, formatInfo);
889 }
890 
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)891 void AddDepthStencilFormat(InternalFormatInfoMap *map,
892                            GLenum internalFormat,
893                            bool sized,
894                            GLuint depthBits,
895                            GLuint stencilBits,
896                            GLuint unusedBits,
897                            GLenum format,
898                            GLenum type,
899                            GLenum componentType,
900                            InternalFormat::SupportCheckFunction textureSupport,
901                            InternalFormat::SupportCheckFunction filterSupport,
902                            InternalFormat::SupportCheckFunction textureAttachmentSupport,
903                            InternalFormat::SupportCheckFunction renderbufferSupport,
904                            InternalFormat::SupportCheckFunction blendSupport)
905 {
906     InternalFormat formatInfo;
907     formatInfo.internalFormat = internalFormat;
908     formatInfo.sized          = sized;
909     formatInfo.sizedInternalFormat =
910         sized ? internalFormat : GetSizedFormatInternal(internalFormat, type);
911     formatInfo.depthBits                = depthBits;
912     formatInfo.stencilBits              = stencilBits;
913     formatInfo.pixelBytes               = (depthBits + stencilBits + unusedBits) / 8;
914     formatInfo.componentCount           = ((depthBits > 0) ? 1 : 0) + ((stencilBits > 0) ? 1 : 0);
915     formatInfo.format                   = format;
916     formatInfo.type                     = type;
917     formatInfo.componentType            = componentType;
918     formatInfo.colorEncoding            = GL_LINEAR;
919     formatInfo.textureSupport           = textureSupport;
920     formatInfo.filterSupport            = filterSupport;
921     formatInfo.textureAttachmentSupport = textureAttachmentSupport;
922     formatInfo.renderbufferSupport      = renderbufferSupport;
923     formatInfo.blendSupport             = blendSupport;
924 
925     InsertFormatInfo(map, formatInfo);
926 }
927 
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)928 void AddCompressedFormat(InternalFormatInfoMap *map,
929                          GLenum internalFormat,
930                          GLuint compressedBlockWidth,
931                          GLuint compressedBlockHeight,
932                          GLuint compressedBlockDepth,
933                          GLuint compressedBlockSize,
934                          GLuint componentCount,
935                          bool srgb,
936                          InternalFormat::SupportCheckFunction textureSupport,
937                          InternalFormat::SupportCheckFunction filterSupport,
938                          InternalFormat::SupportCheckFunction textureAttachmentSupport,
939                          InternalFormat::SupportCheckFunction renderbufferSupport,
940                          InternalFormat::SupportCheckFunction blendSupport)
941 {
942     InternalFormat formatInfo;
943     formatInfo.internalFormat           = internalFormat;
944     formatInfo.sized                    = true;
945     formatInfo.sizedInternalFormat      = internalFormat;
946     formatInfo.compressedBlockWidth     = compressedBlockWidth;
947     formatInfo.compressedBlockHeight    = compressedBlockHeight;
948     formatInfo.compressedBlockDepth     = compressedBlockDepth;
949     formatInfo.pixelBytes               = compressedBlockSize / 8;
950     formatInfo.componentCount           = componentCount;
951     formatInfo.format                   = internalFormat;
952     formatInfo.type                     = GL_UNSIGNED_BYTE;
953     formatInfo.componentType            = GL_UNSIGNED_NORMALIZED;
954     formatInfo.colorEncoding            = (srgb ? GL_SRGB : GL_LINEAR);
955     formatInfo.compressed               = true;
956     formatInfo.textureSupport           = textureSupport;
957     formatInfo.filterSupport            = filterSupport;
958     formatInfo.textureAttachmentSupport = textureAttachmentSupport;
959     formatInfo.renderbufferSupport      = renderbufferSupport;
960     formatInfo.blendSupport             = blendSupport;
961 
962     InsertFormatInfo(map, formatInfo);
963 }
964 
AddYUVFormat(InternalFormatInfoMap * map,GLenum internalFormat,bool sized,GLuint cr,GLuint y,GLuint cb,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)965 void AddYUVFormat(InternalFormatInfoMap *map,
966                   GLenum internalFormat,
967                   bool sized,
968                   GLuint cr,
969                   GLuint y,
970                   GLuint cb,
971                   GLuint alpha,
972                   GLuint shared,
973                   GLenum format,
974                   GLenum type,
975                   GLenum componentType,
976                   bool srgb,
977                   InternalFormat::SupportCheckFunction textureSupport,
978                   InternalFormat::SupportCheckFunction filterSupport,
979                   InternalFormat::SupportCheckFunction textureAttachmentSupport,
980                   InternalFormat::SupportCheckFunction renderbufferSupport,
981                   InternalFormat::SupportCheckFunction blendSupport)
982 {
983     ASSERT(sized);
984 
985     InternalFormat formatInfo;
986     formatInfo.internalFormat      = internalFormat;
987     formatInfo.sized               = sized;
988     formatInfo.sizedInternalFormat = internalFormat;
989     formatInfo.redBits             = cr;
990     formatInfo.greenBits           = y;
991     formatInfo.blueBits            = cb;
992     formatInfo.alphaBits           = alpha;
993     formatInfo.sharedBits          = shared;
994     formatInfo.pixelBytes          = (cr + y + cb + alpha + shared) / 8;
995     formatInfo.componentCount =
996         ((cr > 0) ? 1 : 0) + ((y > 0) ? 1 : 0) + ((cb > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0);
997     formatInfo.format                   = format;
998     formatInfo.type                     = type;
999     formatInfo.componentType            = componentType;
1000     formatInfo.colorEncoding            = (srgb ? GL_SRGB : GL_LINEAR);
1001     formatInfo.textureSupport           = textureSupport;
1002     formatInfo.filterSupport            = filterSupport;
1003     formatInfo.textureAttachmentSupport = textureAttachmentSupport;
1004     formatInfo.renderbufferSupport      = renderbufferSupport;
1005     formatInfo.blendSupport             = blendSupport;
1006 
1007     InsertFormatInfo(map, formatInfo);
1008 }
1009 
1010 // Notes:
1011 // 1. "Texture supported" includes all the means by which texture can be created, however,
1012 //    GL_EXT_texture_storage in ES2 is a special case, when only glTexStorage* is allowed.
1013 //    The assumption is that ES2 validation will not check textureSupport for sized formats.
1014 //
1015 // 2. Sized half float types are a combination of GL_HALF_FLOAT and GL_HALF_FLOAT_OES support,
1016 //    due to a limitation that only one type for sized formats is allowed.
1017 //
1018 // TODO(ynovikov): http://anglebug.com/2846 Verify support fields of BGRA, depth, stencil
1019 // and compressed formats. Perform texturable check as part of filterable and attachment checks.
BuildInternalFormatInfoMap()1020 static InternalFormatInfoMap BuildInternalFormatInfoMap()
1021 {
1022     InternalFormatInfoMap map;
1023 
1024     // From ES 3.0.1 spec, table 3.12
1025     map[GL_NONE][GL_NONE] = InternalFormat();
1026 
1027     // clang-format off
1028 
1029     //                 | Internal format     |sized| R | G | B | A |S | Format         | Type                             | Component type        | SRGB | Texture supported                                | Filterable     | Texture attachment                               | Renderbuffer                                   | Blend
1030     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::textureRgEXT>, RequireESOrExt<3, 0, &Extensions::textureRgEXT>);
1031     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);
1032     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::textureRgEXT>, RequireESOrExt<3, 0, &Extensions::textureRgEXT>);
1033     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);
1034     AddRGBAFormat(&map, GL_RGB8,              true,  8,  8,  8,  0, 0, GL_RGB,          GL_UNSIGNED_BYTE,                  GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::textureStorageEXT>, AlwaysSupported, RequireESOrExt<3, 0, &Extensions::textureStorageEXT>, RequireESOrExt<3, 0, &Extensions::rgb8Rgba8OES>,    RequireESOrExt<3, 0, &Extensions::rgb8Rgba8OES>);
1035     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);
1036     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::textureStorageEXT>, AlwaysSupported, RequireESOrExt<3, 0, &Extensions::textureStorageEXT>, RequireES<2, 0>,                                    RequireES<2, 0>);
1037     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::textureStorageEXT>, AlwaysSupported, RequireESOrExt<3, 0, &Extensions::textureStorageEXT>, RequireES<2, 0>,                                    RequireES<2, 0>);
1038     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::textureStorageEXT>, AlwaysSupported, RequireESOrExt<3, 0, &Extensions::textureStorageEXT>, RequireES<2, 0>,                                    RequireES<2, 0>);
1039     AddRGBAFormat(&map, GL_RGBA8,             true,  8,  8,  8,  8, 0, GL_RGBA,         GL_UNSIGNED_BYTE,                  GL_UNSIGNED_NORMALIZED, false, RequireESOrExt<3, 0, &Extensions::textureStorageEXT>, AlwaysSupported, RequireESOrExt<3, 0, &Extensions::textureStorageEXT>, RequireESOrExt<3, 0, &Extensions::rgb8Rgba8OES>,    RequireESOrExt<3, 0, &Extensions::rgb8Rgba8OES>);
1040     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);
1041     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);
1042     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);
1043     AddRGBAFormat(&map, GL_SRGB8_ALPHA8,      true,  8,  8,  8,  8, 0, GL_RGBA,         GL_UNSIGNED_BYTE,                  GL_UNSIGNED_NORMALIZED, true,  RequireESOrExt<3, 0, &Extensions::sRGBEXT>,           AlwaysSupported, RequireES<3, 0>,                                         RequireESOrExt<3, 0, &Extensions::sRGBEXT>,      RequireESOrExt<3, 0, &Extensions::sRGBEXT>);
1044     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::colorBufferFloatEXT>,            RequireExt<&Extensions::colorBufferFloatEXT>,    RequireExt<&Extensions::colorBufferFloatEXT>);
1045     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);
1046     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);
1047     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);
1048     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);
1049     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);
1050     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);
1051     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);
1052     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);
1053     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);
1054     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);
1055     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);
1056     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);
1057     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);
1058     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);
1059     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);
1060     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);
1061     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);
1062     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);
1063     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);
1064     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);
1065     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);
1066     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);
1067     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);
1068     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);
1069     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);
1070 
1071     AddRGBAFormat(&map, GL_BGRA8_EXT,         true,  8,  8,  8,  8, 0, GL_BGRA_EXT,     GL_UNSIGNED_BYTE,                  GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888EXT>,    AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888EXT>,    RequireExt<&Extensions::textureFormatBGRA8888EXT>, RequireExt<&Extensions::textureFormatBGRA8888EXT>);
1072     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::textureFormatBGRA8888EXT>,    AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888EXT>,    RequireExt<&Extensions::textureFormatBGRA8888EXT>, RequireExt<&Extensions::textureFormatBGRA8888EXT>);
1073     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::textureFormatBGRA8888EXT>,    AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888EXT>,    RequireExt<&Extensions::textureFormatBGRA8888EXT>, RequireExt<&Extensions::textureFormatBGRA8888EXT>);
1074 
1075     // Special format that is used for D3D textures that are used within ANGLE via the
1076     // EGL_ANGLE_d3d_texture_client_buffer extension. We don't allow uploading texture images with
1077     // this format, but textures in this format can be created from D3D textures, and filtering them
1078     // and rendering to them is allowed.
1079     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);
1080 
1081     // Special format which is not really supported, so always false for all supports.
1082     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);
1083     AddRGBAFormat(&map, GL_BGR565_ANGLEX,     true,  5,  6,  5,  0, 0, GL_BGRA_EXT,     GL_UNSIGNED_SHORT_5_6_5,           GL_UNSIGNED_NORMALIZED, false, NeverSupported,                                    NeverSupported,  NeverSupported,                                    NeverSupported,                                NeverSupported);
1084     AddRGBAFormat(&map, GL_BGR10_A2_ANGLEX,   true, 10, 10, 10,  2, 0, GL_BGRA_EXT,     GL_UNSIGNED_INT_2_10_10_10_REV,    GL_UNSIGNED_NORMALIZED, false, NeverSupported,                                    NeverSupported,  NeverSupported,                                    NeverSupported,                                NeverSupported);
1085 
1086     // Special format to emulate RGB8 with RGBA8 within ANGLE.
1087     AddRGBAFormat(&map, GL_RGBX8_ANGLE,      true,  8,  8,  8,  0, 0, GL_RGBA,         GL_UNSIGNED_BYTE,                  GL_UNSIGNED_NORMALIZED, false, AlwaysSupported,                                    NeverSupported,  AlwaysSupported,                                    AlwaysSupported,                                NeverSupported);
1088 
1089     // This format is supported on ES 2.0 with two extensions, so keep it out-of-line to not widen the table above even more.
1090     //                 | Internal format     |sized| R | G | B | A |S | Format         | Type                             | Component type        | SRGB | Texture supported                                                                            | Filterable     | Texture attachment                               | Renderbuffer                                   | Blend
1091     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, RequireESOrExtAndExt<3, 0, &Extensions::textureStorageEXT, &Extensions::textureType2101010REVEXT>,  AlwaysSupported, RequireES<3, 0>,                                   RequireES<3, 0>,                                 RequireES<3, 0>);
1092 
1093     // Floating point formats
1094     //                 | Internal format |sized| R | G | B | A |S | Format | Type             | Component type | SRGB | Texture supported         | Filterable                                    | Texture attachment                          | Renderbuffer                            | Blend
1095     // It's not possible to have two entries per sized format.
1096     // E.g. for GL_RG16F, one with GL_HALF_FLOAT type and the other with GL_HALF_FLOAT_OES type.
1097     // So, GL_HALF_FLOAT type formats conditions are merged with GL_HALF_FLOAT_OES type conditions.
1098     AddRGBAFormat(&map, GL_R16F,          true, 16,  0,  0,  0, 0, GL_RED,  GL_HALF_FLOAT,     GL_FLOAT,        false, SizedHalfFloatRGSupport,    SizedHalfFloatFilterSupport,                    SizedHalfFloatRGTextureAttachmentSupport,     SizedHalfFloatRGRenderbufferSupport,       SizedHalfFloatRGRenderbufferSupport);
1099     AddRGBAFormat(&map, GL_RG16F,         true, 16, 16,  0,  0, 0, GL_RG,   GL_HALF_FLOAT,     GL_FLOAT,        false, SizedHalfFloatRGSupport,    SizedHalfFloatFilterSupport,                    SizedHalfFloatRGTextureAttachmentSupport,     SizedHalfFloatRGRenderbufferSupport,       SizedHalfFloatRGRenderbufferSupport);
1100     AddRGBAFormat(&map, GL_RGB16F,        true, 16, 16, 16,  0, 0, GL_RGB,  GL_HALF_FLOAT,     GL_FLOAT,        false, SizedHalfFloatSupport,      SizedHalfFloatFilterSupport,                    SizedHalfFloatRGBTextureAttachmentSupport,    SizedHalfFloatRGBRenderbufferSupport,      SizedHalfFloatRGBRenderbufferSupport);
1101     AddRGBAFormat(&map, GL_RGBA16F,       true, 16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT,     GL_FLOAT,        false, SizedHalfFloatSupport,      SizedHalfFloatFilterSupport,                    SizedHalfFloatRGBATextureAttachmentSupport,   SizedHalfFloatRGBARenderbufferSupport,     SizedHalfFloatRGBARenderbufferSupport);
1102     AddRGBAFormat(&map, GL_R32F,          true, 32,  0,  0,  0, 0, GL_RED,  GL_FLOAT,          GL_FLOAT,        false, SizedFloatRGSupport,        RequireExt<&Extensions::textureFloatLinearOES>, RequireExt<&Extensions::colorBufferFloatEXT>,    RequireExt<&Extensions::colorBufferFloatEXT>, Float32BlendableSupport);
1103     AddRGBAFormat(&map, GL_RG32F,         true, 32, 32,  0,  0, 0, GL_RG,   GL_FLOAT,          GL_FLOAT,        false, SizedFloatRGSupport,        RequireExt<&Extensions::textureFloatLinearOES>, RequireExt<&Extensions::colorBufferFloatEXT>,    RequireExt<&Extensions::colorBufferFloatEXT>, Float32BlendableSupport);
1104     AddRGBAFormat(&map, GL_RGB32F,        true, 32, 32, 32,  0, 0, GL_RGB,  GL_FLOAT,          GL_FLOAT,        false, SizedFloatRGBSupport,       RequireExt<&Extensions::textureFloatLinearOES>, RequireExt<&Extensions::colorBufferFloatRgbCHROMIUM>, NeverSupported,                            NeverSupported);
1105     AddRGBAFormat(&map, GL_RGBA32F,       true, 32, 32, 32, 32, 0, GL_RGBA, GL_FLOAT,          GL_FLOAT,        false, SizedFloatRGBASupport,      RequireExt<&Extensions::textureFloatLinearOES>, SizedFloatRGBARenderableSupport,              SizedFloatRGBARenderableSupport,           Float32BlendableSupport);
1106 
1107     // ANGLE Depth stencil formats
1108     //                         | Internal format         |sized| D |S | X | Format            | Type                             | Component type        | Texture supported                                                                            | Filterable                                                                             | Texture attachment                                                                           | Renderbuffer                                                                                              | Blend
1109     AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT16,     true, 16, 0,  0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT,                 GL_UNSIGNED_NORMALIZED, RequireESOrExtOrExt<3, 0, &Extensions::depthTextureANGLE, &Extensions::depthTextureOES>,       RequireESOrExtOrExt<3, 0, &Extensions::depthTextureANGLE, &Extensions::depthTextureOES>, RequireES<1, 0>,                                                                               RequireES<1, 0>,                                                                                             RequireES<1, 0>);
1110     AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT24,     true, 24, 0,  8, 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>);
1111     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>);
1112     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>);
1113     AddDepthStencilFormat(&map, GL_DEPTH24_STENCIL8,      true, 24, 8,  0, GL_DEPTH_STENCIL,   GL_UNSIGNED_INT_24_8,              GL_UNSIGNED_NORMALIZED, RequireESOrExtOrExt<3, 0, &Extensions::depthTextureANGLE, &Extensions::packedDepthStencilOES>, AlwaysSupported,                                                                         RequireESOrExtOrExt<3, 0, &Extensions::depthTextureANGLE, &Extensions::packedDepthStencilOES>, RequireESOrExtOrExt<3, 0, &Extensions::depthTextureANGLE, &Extensions::packedDepthStencilOES>,               RequireESOrExtOrExt<3, 0, &Extensions::depthTextureANGLE, &Extensions::packedDepthStencilOES>);
1114     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>);
1115     // STENCIL_INDEX8 is special-cased, see around the bottom of the list.
1116 
1117     // Luminance alpha formats
1118     //                | Internal format           |sized| L | A | Format            | Type             | Component type        | Texture supported                                                           | Filterable                                     | Texture attachment | Renderbuffer | Blend
1119     AddLUMAFormat(&map, GL_ALPHA8_EXT,             true,  0,  8, GL_ALPHA,           GL_UNSIGNED_BYTE,  GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorageEXT>,                                      AlwaysSupported,                                 NeverSupported,      NeverSupported, NeverSupported);
1120     AddLUMAFormat(&map, GL_LUMINANCE8_EXT,         true,  8,  0, GL_LUMINANCE,       GL_UNSIGNED_BYTE,  GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorageEXT>,                                      AlwaysSupported,                                 NeverSupported,      NeverSupported, NeverSupported);
1121     AddLUMAFormat(&map, GL_LUMINANCE8_ALPHA8_EXT,  true,  8,  8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE,  GL_UNSIGNED_NORMALIZED, RequireExt<&Extensions::textureStorageEXT>,                                      AlwaysSupported,                                 NeverSupported,      NeverSupported, NeverSupported);
1122     AddLUMAFormat(&map, GL_ALPHA16F_EXT,           true,  0, 16, GL_ALPHA,           GL_HALF_FLOAT_OES, GL_FLOAT,               RequireExtAndExt<&Extensions::textureStorageEXT, &Extensions::textureHalfFloatOES>, RequireExt<&Extensions::textureHalfFloatLinearOES>, NeverSupported,      NeverSupported, NeverSupported);
1123     AddLUMAFormat(&map, GL_LUMINANCE16F_EXT,       true, 16,  0, GL_LUMINANCE,       GL_HALF_FLOAT_OES, GL_FLOAT,               RequireExtAndExt<&Extensions::textureStorageEXT, &Extensions::textureHalfFloatOES>, RequireExt<&Extensions::textureHalfFloatLinearOES>, NeverSupported,      NeverSupported, NeverSupported);
1124     AddLUMAFormat(&map, GL_LUMINANCE_ALPHA16F_EXT, true, 16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT,               RequireExtAndExt<&Extensions::textureStorageEXT, &Extensions::textureHalfFloatOES>, RequireExt<&Extensions::textureHalfFloatLinearOES>, NeverSupported,      NeverSupported, NeverSupported);
1125     AddLUMAFormat(&map, GL_ALPHA32F_EXT,           true,  0, 32, GL_ALPHA,           GL_FLOAT,          GL_FLOAT,               RequireExtAndExt<&Extensions::textureStorageEXT, &Extensions::textureFloatOES>,  RequireExt<&Extensions::textureFloatLinearOES>,  NeverSupported,      NeverSupported, NeverSupported);
1126     AddLUMAFormat(&map, GL_LUMINANCE32F_EXT,       true, 32,  0, GL_LUMINANCE,       GL_FLOAT,          GL_FLOAT,               RequireExtAndExt<&Extensions::textureStorageEXT, &Extensions::textureFloatOES>,  RequireExt<&Extensions::textureFloatLinearOES>,  NeverSupported,      NeverSupported, NeverSupported);
1127     AddLUMAFormat(&map, GL_LUMINANCE_ALPHA32F_EXT, true, 32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT,          GL_FLOAT,               RequireExtAndExt<&Extensions::textureStorageEXT, &Extensions::textureFloatOES>,  RequireExt<&Extensions::textureFloatLinearOES>,  NeverSupported,      NeverSupported, NeverSupported);
1128 
1129     // Compressed formats, From ES 3.0.1 spec, table 3.16
1130     //                       | Internal format                             |W |H |D | BS |CC| SRGB | Texture supported                                                                                                         | Filterable     | Texture attachment | Renderbuffer  | Blend
1131     AddCompressedFormat(&map, GL_COMPRESSED_R11_EAC,                        4, 4, 1,  64, 1, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureEtcANGLE, &Extensions::compressedEACR11UnsignedTextureOES>,              AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1132     AddCompressedFormat(&map, GL_COMPRESSED_SIGNED_R11_EAC,                 4, 4, 1,  64, 1, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureEtcANGLE, &Extensions::compressedEACR11SignedTextureOES>,                AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1133     AddCompressedFormat(&map, GL_COMPRESSED_RG11_EAC,                       4, 4, 1, 128, 2, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureEtcANGLE, &Extensions::compressedEACRG11UnsignedTextureOES>,             AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1134     AddCompressedFormat(&map, GL_COMPRESSED_SIGNED_RG11_EAC,                4, 4, 1, 128, 2, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureEtcANGLE, &Extensions::compressedEACRG11SignedTextureOES>,               AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1135     AddCompressedFormat(&map, GL_COMPRESSED_RGB8_ETC2,                      4, 4, 1,  64, 3, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureEtcANGLE, &Extensions::compressedETC2RGB8TextureOES>,                    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1136     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ETC2,                     4, 4, 1,  64, 3, true,  RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureEtcANGLE, &Extensions::compressedETC2SRGB8TextureOES>,                   AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1137     AddCompressedFormat(&map, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,  4, 4, 1,  64, 3, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureEtcANGLE, &Extensions::compressedETC2PunchthroughARGBA8TextureOES>,       AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1138     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, 4, 4, 1,  64, 3, true,  RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureEtcANGLE, &Extensions::compressedETC2PunchthroughASRGB8AlphaTextureOES>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1139     AddCompressedFormat(&map, GL_COMPRESSED_RGBA8_ETC2_EAC,                 4, 4, 1, 128, 4, false, RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureEtcANGLE, &Extensions::compressedETC2RGBA8TextureOES>,                   AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1140     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,          4, 4, 1, 128, 4, true,  RequireESOrExtOrExt<3, 0, &Extensions::compressedTextureEtcANGLE, &Extensions::compressedETC2SRGB8Alpha8TextureOES>,             AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1141 
1142     // From GL_EXT_texture_compression_dxt1
1143     //                       | Internal format                   |W |H |D | BS |CC| SRGB | Texture supported                                    | Filterable     | Texture attachment | Renderbuffer  | Blend
1144     AddCompressedFormat(&map, GL_COMPRESSED_RGB_S3TC_DXT1_EXT,    4, 4, 1,  64, 3, false, RequireExt<&Extensions::textureCompressionDxt1EXT>,       AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1145     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,   4, 4, 1,  64, 4, false, RequireExt<&Extensions::textureCompressionDxt1EXT>,       AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1146 
1147     // From GL_ANGLE_texture_compression_dxt3
1148     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, 4, 4, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionDxt3ANGLE>,       AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1149 
1150     // From GL_ANGLE_texture_compression_dxt5
1151     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, 4, 4, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionDxt5ANGLE>,       AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1152 
1153     // From GL_OES_compressed_ETC1_RGB8_texture
1154     AddCompressedFormat(&map, GL_ETC1_RGB8_OES,                   4, 4, 1,  64, 3, false, RequireExt<&Extensions::compressedETC1RGB8TextureOES>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1155 
1156     // From GL_EXT_texture_compression_s3tc_srgb
1157     //                       | Internal format                       |W |H |D | BS |CC|SRGB | Texture supported                                 | Filterable     | Texture attachment | Renderbuffer  | Blend
1158     AddCompressedFormat(&map, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT,       4, 4, 1,  64, 3, true, RequireExt<&Extensions::textureCompressionS3tcSrgbEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1159     AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, 4, 4, 1,  64, 4, true, RequireExt<&Extensions::textureCompressionS3tcSrgbEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1160     AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, 4, 4, 1, 128, 4, true, RequireExt<&Extensions::textureCompressionS3tcSrgbEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1161     AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, 4, 4, 1, 128, 4, true, RequireExt<&Extensions::textureCompressionS3tcSrgbEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1162 
1163     // From GL_KHR_texture_compression_astc_ldr and KHR_texture_compression_astc_hdr and GL_OES_texture_compression_astc
1164     //                       | Internal format                          | W | H |D | BS |CC| SRGB | Texture supported                                    | Filterable     | Texture attachment | Renderbuffer  | Blend
1165     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_4x4_KHR,            4,  4, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1166     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_5x4_KHR,            5,  4, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1167     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_5x5_KHR,            5,  5, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1168     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_6x5_KHR,            6,  5, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1169     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_6x6_KHR,            6,  6, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1170     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_8x5_KHR,            8,  5, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1171     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_8x6_KHR,            8,  6, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1172     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_8x8_KHR,            8,  8, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1173     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_10x5_KHR,          10,  5, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1174     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_10x6_KHR,          10,  6, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1175     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_10x8_KHR,          10,  8, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1176     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_10x10_KHR,         10, 10, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1177     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_12x10_KHR,         12, 10, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1178     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_12x12_KHR,         12, 12, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1179 
1180     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,    4,  4, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1181     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,    5,  4, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1182     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,    5,  5, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1183     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,    6,  5, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1184     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,    6,  6, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1185     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,    8,  5, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1186     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,    8,  6, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1187     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,    8,  8, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1188     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,  10,  5, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1189     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,  10,  6, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1190     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,  10,  8, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1191     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, 10, 10, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1192     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, 12, 10, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1193     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, 12, 12, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcLdrKHR>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1194 
1195     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_3x3x3_OES,          3,  3, 3, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1196     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_4x3x3_OES,          4,  3, 3, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1197     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_4x4x3_OES,          4,  4, 3, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1198     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_4x4x4_OES,          4,  4, 4, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1199     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_5x4x4_OES,          5,  4, 4, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1200     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_5x5x4_OES,          5,  5, 4, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1201     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_5x5x5_OES,          5,  5, 5, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1202     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_6x5x5_OES,          6,  5, 5, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1203     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_6x6x5_OES,          6,  6, 5, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1204     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_ASTC_6x6x6_OES,          6,  6, 6, 128, 4, false, RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1205 
1206     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES,  3,  3, 3, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1207     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES,  4,  3, 3, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1208     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES,  4,  4, 3, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1209     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES,  4,  4, 4, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1210     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES,  5,  4, 4, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1211     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES,  5,  5, 4, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1212     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES,  5,  5, 5, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1213     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES,  6,  5, 5, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1214     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES,  6,  6, 5, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1215     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES,  6,  6, 6, 128, 4, true,  RequireExt<&Extensions::textureCompressionAstcOES>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1216 
1217     // From EXT_texture_compression_rgtc
1218     //                       | Internal format                        | W | H |D | BS |CC| SRGB | Texture supported                              | Filterable     | Texture attachment | Renderbuffer  | Blend
1219     AddCompressedFormat(&map, GL_COMPRESSED_RED_RGTC1_EXT,              4,  4, 1,  64, 1, false, RequireExt<&Extensions::textureCompressionRgtcEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1220     AddCompressedFormat(&map, GL_COMPRESSED_SIGNED_RED_RGTC1_EXT,       4,  4, 1,  64, 1, false, RequireExt<&Extensions::textureCompressionRgtcEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1221     AddCompressedFormat(&map, GL_COMPRESSED_RED_GREEN_RGTC2_EXT,        4,  4, 1, 128, 2, false, RequireExt<&Extensions::textureCompressionRgtcEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1222     AddCompressedFormat(&map, GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT, 4,  4, 1, 128, 2, false, RequireExt<&Extensions::textureCompressionRgtcEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1223 
1224     // From EXT_texture_compression_bptc
1225     //                       | Internal format                         | W | H |D | BS |CC| SRGB | Texture supported                              | Filterable     | Texture attachment | Renderbuffer  | Blend
1226     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,         4,  4, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionBptcEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1227     AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,   4,  4, 1, 128, 4, true,  RequireExt<&Extensions::textureCompressionBptcEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1228     AddCompressedFormat(&map, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,   4,  4, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionBptcEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1229     AddCompressedFormat(&map, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, 4,  4, 1, 128, 4, false, RequireExt<&Extensions::textureCompressionBptcEXT>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1230 
1231     // From GL_IMG_texture_compression_pvrtc
1232     //                       | Internal format                       | W | H | D | BS |CC| SRGB | Texture supported                                 | Filterable     | Texture attachment | Renderbuffer  | Blend
1233     AddCompressedFormat(&map, GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,      4,  4,  1,  64,  3, false, RequireExt<&Extensions::textureCompressionPvrtcIMG>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1234     AddCompressedFormat(&map, GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,      8,  4,  1,  64,  3, false, RequireExt<&Extensions::textureCompressionPvrtcIMG>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1235     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,     4,  4,  1,  64,  4, false, RequireExt<&Extensions::textureCompressionPvrtcIMG>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1236     AddCompressedFormat(&map, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,     8,  4,  1,  64,  4, false, RequireExt<&Extensions::textureCompressionPvrtcIMG>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1237 
1238     // From GL_EXT_pvrtc_sRGB
1239     //                       | Internal format                             | W | H | D | BS |CC| SRGB | Texture supported                                                                               | Filterable     | Texture attachment | Renderbuffer  | Blend
1240     AddCompressedFormat(&map, GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT,           8,  4,  1,  64,  3, true, RequireExtAndExt<&Extensions::textureCompressionPvrtcIMG, &Extensions::pvrtcSRGBEXT>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1241     AddCompressedFormat(&map, GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT,           4,  4,  1,  64,  3, true, RequireExtAndExt<&Extensions::textureCompressionPvrtcIMG, &Extensions::pvrtcSRGBEXT>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1242     AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT,     8,  4,  1,  64,  4, true, RequireExtAndExt<&Extensions::textureCompressionPvrtcIMG, &Extensions::pvrtcSRGBEXT>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1243     AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT,     4,  4,  1,  64,  4, true, RequireExtAndExt<&Extensions::textureCompressionPvrtcIMG, &Extensions::pvrtcSRGBEXT>,    AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1244 
1245     // For STENCIL_INDEX8 we chose a normalized component type for the following reasons:
1246     // - Multisampled buffer are disallowed for non-normalized integer component types and we want to support it for STENCIL_INDEX8
1247     // - All other stencil formats (all depth-stencil) are either float or normalized
1248     // - It affects only validation of internalformat in RenderbufferStorageMultisample.
1249     //                         | Internal format  |sized|D |S |X | Format          | Type            | Component type        | Texture supported                               | Filterable    | Texture attachment                              | Renderbuffer   | Blend
1250     AddDepthStencilFormat(&map, GL_STENCIL_INDEX8, true, 0, 8, 0, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, RequireESOrExt<1, 0, &Extensions::textureStencil8OES>, NeverSupported, RequireESOrExt<1, 0, &Extensions::textureStencil8OES>, RequireES<1, 0>, RequireES<1, 0>);
1251 
1252     // From GL_ANGLE_lossy_etc_decode
1253     //                       | Internal format                                                |W |H |D |BS |CC| SRGB | Texture supported                      | Filterable     | Texture attachment | Renderbuffer  | Blend
1254     AddCompressedFormat(&map, GL_ETC1_RGB8_LOSSY_DECODE_ANGLE,                                 4, 4, 1, 64, 3, false, RequireExt<&Extensions::lossyEtcDecodeANGLE>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1255     AddCompressedFormat(&map, GL_COMPRESSED_RGB8_LOSSY_DECODE_ETC2_ANGLE,                      4, 4, 1, 64, 3, false, RequireExt<&Extensions::lossyEtcDecodeANGLE>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1256     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_LOSSY_DECODE_ETC2_ANGLE,                     4, 4, 1, 64, 3, true,  RequireExt<&Extensions::lossyEtcDecodeANGLE>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1257     AddCompressedFormat(&map, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE,  4, 4, 1, 64, 3, false, RequireExt<&Extensions::lossyEtcDecodeANGLE>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1258     AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE, 4, 4, 1, 64, 3, true,  RequireExt<&Extensions::lossyEtcDecodeANGLE>, AlwaysSupported, NeverSupported,      NeverSupported, NeverSupported);
1259 
1260     // From GL_EXT_texture_norm16
1261     //                 | Internal format    |sized| R | G | B | A |S | Format | Type             | Component type        | SRGB | Texture supported                     | Filterable     | Texture attachment                    | Renderbuffer                          | Blend
1262     AddRGBAFormat(&map, GL_R16_EXT,          true, 16,  0,  0,  0, 0, GL_RED,  GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16EXT>, AlwaysSupported, RequireExt<&Extensions::textureNorm16EXT>, RequireExt<&Extensions::textureNorm16EXT>, RequireExt<&Extensions::textureNorm16EXT>);
1263     AddRGBAFormat(&map, GL_R16_SNORM_EXT,    true, 16,  0,  0,  0, 0, GL_RED,  GL_SHORT,          GL_SIGNED_NORMALIZED,   false, RequireExt<&Extensions::textureNorm16EXT>, AlwaysSupported, NeverSupported,                         NeverSupported,                         NeverSupported);
1264     AddRGBAFormat(&map, GL_RG16_EXT,         true, 16, 16,  0,  0, 0, GL_RG,   GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16EXT>, AlwaysSupported, RequireExt<&Extensions::textureNorm16EXT>, RequireExt<&Extensions::textureNorm16EXT>, RequireExt<&Extensions::textureNorm16EXT>);
1265     AddRGBAFormat(&map, GL_RG16_SNORM_EXT,   true, 16, 16,  0,  0, 0, GL_RG,   GL_SHORT,          GL_SIGNED_NORMALIZED,   false, RequireExt<&Extensions::textureNorm16EXT>, AlwaysSupported, NeverSupported,                         NeverSupported,                         NeverSupported);
1266     AddRGBAFormat(&map, GL_RGB16_EXT,        true, 16, 16, 16,  0, 0, GL_RGB,  GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16EXT>, AlwaysSupported, NeverSupported,                         NeverSupported,                         NeverSupported);
1267     AddRGBAFormat(&map, GL_RGB16_SNORM_EXT,  true, 16, 16, 16,  0, 0, GL_RGB,  GL_SHORT,          GL_SIGNED_NORMALIZED,   false, RequireExt<&Extensions::textureNorm16EXT>, AlwaysSupported, NeverSupported,                         NeverSupported,                         NeverSupported);
1268     AddRGBAFormat(&map, GL_RGBA16_EXT,       true, 16, 16, 16, 16, 0, GL_RGBA, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16EXT>, AlwaysSupported, RequireExt<&Extensions::textureNorm16EXT>, RequireExt<&Extensions::textureNorm16EXT>, RequireExt<&Extensions::textureNorm16EXT>);
1269     AddRGBAFormat(&map, GL_RGBA16_SNORM_EXT, true, 16, 16, 16, 16, 0, GL_RGBA, GL_SHORT,          GL_SIGNED_NORMALIZED,   false, RequireExt<&Extensions::textureNorm16EXT>, AlwaysSupported, NeverSupported,                         NeverSupported,                         NeverSupported);
1270 
1271     // From EXT_texture_sRGB_R8
1272     //                 | Internal format    |sized| R | G | B | A |S | Format | Type             | Component type        | SRGB | Texture supported                     | Filterable     | Texture attachment                    | Renderbuffer                          | Blend
1273     AddRGBAFormat(&map, GL_SR8_EXT,          true,  8,  0,  0,  0, 0, GL_RED,  GL_UNSIGNED_BYTE,  GL_UNSIGNED_NORMALIZED, true,  RequireExt<&Extensions::textureSRGBR8EXT>,     AlwaysSupported, NeverSupported,                         NeverSupported,                         NeverSupported);
1274 
1275     // From EXT_texture_sRGB_RG8
1276     //                 | Internal format    |sized| R | G | B | A |S | Format | Type             | Component type        | SRGB | Texture supported                     | Filterable     | Texture attachment                    | Renderbuffer                          | Blend
1277     AddRGBAFormat(&map, GL_SRG8_EXT,         true,  8,  8,  0,  0, 0, GL_RG,   GL_UNSIGNED_BYTE,  GL_UNSIGNED_NORMALIZED, true,  RequireExt<&Extensions::textureSRGBRG8EXT>,    AlwaysSupported, NeverSupported,                         NeverSupported,                         NeverSupported);
1278 
1279     // Unsized formats
1280     //                  | Internal format  |sized |    R | G | B | A |S |X   | Format           | Type                          | Component type        | SRGB | Texture supported                                  | Filterable     | Texture attachment                               | Renderbuffer  | Blend
1281     AddRGBAXFormat(&map, GL_RED,            false, FB< 8,  0,  0,  0, 0, 0>(), GL_RED,            GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureRgEXT>,               AlwaysSupported, RequireExt<&Extensions::textureRgEXT>,             NeverSupported, NeverSupported);
1282     AddRGBAXFormat(&map, GL_RED,            false, FB< 8,  0,  0,  0, 0, 0>(), GL_RED,            GL_BYTE,                        GL_SIGNED_NORMALIZED,   false, NeverSupported,                                      NeverSupported,  NeverSupported,                                    NeverSupported, NeverSupported);
1283     AddRGBAXFormat(&map, GL_RED,            false, FB<16,  0,  0,  0, 0, 0>(), GL_RED,            GL_UNSIGNED_SHORT,              GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16EXT>,           AlwaysSupported, RequireExt<&Extensions::textureNorm16EXT>,         NeverSupported, NeverSupported);
1284     AddRGBAXFormat(&map, GL_RG,             false, FB< 8,  8,  0,  0, 0, 0>(), GL_RG,             GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureRgEXT>,               AlwaysSupported, RequireExt<&Extensions::textureRgEXT>,             NeverSupported, NeverSupported);
1285     AddRGBAXFormat(&map, GL_RG,             false, FB< 8,  8,  0,  0, 0, 0>(), GL_RG,             GL_BYTE,                        GL_SIGNED_NORMALIZED,   false, NeverSupported,                                      NeverSupported,  NeverSupported,                                    NeverSupported, NeverSupported);
1286     AddRGBAXFormat(&map, GL_RG,             false, FB<16, 16,  0,  0, 0, 0>(), GL_RG,             GL_UNSIGNED_SHORT,              GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16EXT>,           AlwaysSupported, RequireExt<&Extensions::textureNorm16EXT>,         NeverSupported, NeverSupported);
1287     AddRGBAXFormat(&map, GL_RGB,            false, FB< 8,  8,  8,  0, 0, 0>(), GL_RGB,            GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, false, AlwaysSupported,                                     AlwaysSupported, RequireESOrExt<2, 0, &Extensions::framebufferObjectOES>,                                NeverSupported, NeverSupported);
1288     AddRGBAXFormat(&map, GL_RGB,            false, FB< 5,  6,  5,  0, 0, 0>(), GL_RGB,            GL_UNSIGNED_SHORT_5_6_5,        GL_UNSIGNED_NORMALIZED, false, AlwaysSupported,                                     AlwaysSupported, RequireESOrExt<2, 0, &Extensions::framebufferObjectOES>,                                NeverSupported, NeverSupported);
1289     AddRGBAXFormat(&map, GL_RGB,            false, FB< 8,  8,  8,  0, 0, 0>(), GL_RGB,            GL_BYTE,                        GL_SIGNED_NORMALIZED,   false, NeverSupported,                                      NeverSupported,  NeverSupported,                                    NeverSupported, NeverSupported);
1290     AddRGBAXFormat(&map, GL_RGB,            false, FB<10, 10, 10,  0, 0, 2>(), GL_RGB,            GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureType2101010REVEXT>, AlwaysSupported, NeverSupported,                                    NeverSupported, NeverSupported);
1291     AddRGBAXFormat(&map, GL_RGBA,           false, FB< 4,  4,  4,  4, 0, 0>(), GL_RGBA,           GL_UNSIGNED_SHORT_4_4_4_4,      GL_UNSIGNED_NORMALIZED, false, AlwaysSupported,                                     AlwaysSupported, RequireESOrExt<2, 0, &Extensions::framebufferObjectOES>,                                NeverSupported, NeverSupported);
1292     AddRGBAXFormat(&map, GL_RGBA,           false, FB< 5,  5,  5,  1, 0, 0>(), GL_RGBA,           GL_UNSIGNED_SHORT_5_5_5_1,      GL_UNSIGNED_NORMALIZED, false, AlwaysSupported,                                     AlwaysSupported, RequireESOrExt<2, 0, &Extensions::framebufferObjectOES>,                                NeverSupported, NeverSupported);
1293     AddRGBAXFormat(&map, GL_RGBA,           false, FB< 8,  8,  8,  8, 0, 0>(), GL_RGBA,           GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, false, AlwaysSupported,                                     AlwaysSupported, RequireESOrExt<2, 0, &Extensions::framebufferObjectOES>,                                NeverSupported, NeverSupported);
1294     AddRGBAXFormat(&map, GL_RGBA,           false, FB<16, 16, 16, 16, 0, 0>(), GL_RGBA,           GL_UNSIGNED_SHORT,              GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16EXT>,           AlwaysSupported, RequireExt<&Extensions::textureNorm16EXT>,         NeverSupported, NeverSupported);
1295     AddRGBAXFormat(&map, GL_RGBA,           false, FB<10, 10, 10,  2, 0, 0>(), GL_RGBA,           GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureType2101010REVEXT>, AlwaysSupported, NeverSupported,                                    NeverSupported, NeverSupported);
1296     AddRGBAXFormat(&map, GL_RGBA,           false, FB< 8,  8,  8,  8, 0, 0>(), GL_RGBA,           GL_BYTE,                        GL_SIGNED_NORMALIZED,   false, NeverSupported,                                      NeverSupported,  NeverSupported,                                    NeverSupported, NeverSupported);
1297     AddRGBAXFormat(&map, GL_SRGB,           false, FB< 8,  8,  8,  0, 0, 0>(), GL_SRGB,           GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, true,  RequireExt<&Extensions::sRGBEXT>,                    AlwaysSupported, NeverSupported,                                    NeverSupported, NeverSupported);
1298     AddRGBAXFormat(&map, GL_SRGB_ALPHA_EXT, false, FB< 8,  8,  8,  8, 0, 0>(), GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, true,  RequireExt<&Extensions::sRGBEXT>,                    AlwaysSupported, RequireExt<&Extensions::sRGBEXT>,                  NeverSupported, NeverSupported);
1299 #if (defined(ANGLE_PLATFORM_IOS) && !defined(ANGLE_PLATFORM_MACCATALYST)) || (defined(ANGLE_PLATFORM_MACCATALYST) && defined(ANGLE_CPU_ARM64))
1300     angle::SystemInfo info;
1301     if (angle::GetSystemInfo(&info))
1302     {
1303         if (info.needsEAGLOnMac)
1304         {
1305             // Using OpenGLES.framework.
1306             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);
1307         }
1308         else
1309         {
1310             // Using OpenGL.framework.
1311             AddRGBAFormat(&map, GL_BGRA_EXT,       false,  8,  8,  8,  8, 0, GL_BGRA_EXT,       GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888EXT>,   AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888EXT>, NeverSupported, NeverSupported);
1312         }
1313     }
1314 #else
1315     AddRGBAFormat(&map, GL_BGRA_EXT,       false,  8,  8,  8,  8, 0, GL_BGRA_EXT,       GL_UNSIGNED_BYTE,               GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888EXT>,   AlwaysSupported, RequireExt<&Extensions::textureFormatBGRA8888EXT>, NeverSupported, NeverSupported);
1316 #endif
1317 
1318     // Unsized integer formats
1319     //                 |Internal format |sized | R | G | B | A |S | Format         | Type                          | Component type | SRGB | Texture supported | Filterable    | Texture attachment | Renderbuffer  | Blend
1320     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);
1321     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);
1322     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);
1323     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);
1324     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);
1325     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);
1326     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);
1327     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);
1328     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);
1329     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);
1330     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);
1331     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);
1332     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);
1333     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);
1334     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);
1335     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);
1336     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);
1337     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);
1338     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);
1339     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);
1340     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);
1341     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);
1342     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);
1343     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);
1344     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);
1345 
1346     // Unsized floating point formats
1347     //                 |Internal format |sized | R | G | B | A |S | Format | Type                           | Comp    | SRGB | Texture supported                                                         | Filterable                                     | Texture attachment                             | Renderbuffer  | Blend
1348     AddRGBAFormat(&map, GL_RED,          false, 16,  0,  0,  0, 0, GL_RED,  GL_HALF_FLOAT,                   GL_FLOAT, false, NeverSupported,                                                             NeverSupported,                                  NeverSupported,                                  NeverSupported, NeverSupported);
1349     AddRGBAFormat(&map, GL_RG,           false, 16, 16,  0,  0, 0, GL_RG,   GL_HALF_FLOAT,                   GL_FLOAT, false, NeverSupported,                                                             NeverSupported,                                  NeverSupported,                                  NeverSupported, NeverSupported);
1350     AddRGBAFormat(&map, GL_RGB,          false, 16, 16, 16,  0, 0, GL_RGB,  GL_HALF_FLOAT,                   GL_FLOAT, false, NeverSupported,                                                             NeverSupported,                                  NeverSupported,                                  NeverSupported, NeverSupported);
1351     AddRGBAFormat(&map, GL_RGBA,         false, 16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT,                   GL_FLOAT, false, NeverSupported,                                                             NeverSupported,                                  NeverSupported,                                  NeverSupported, NeverSupported);
1352     AddRGBAFormat(&map, GL_RED,          false, 16,  0,  0,  0, 0, GL_RED,  GL_HALF_FLOAT_OES,               GL_FLOAT, false, RequireExtAndExt<&Extensions::textureHalfFloatOES, &Extensions::textureRgEXT>,    RequireExt<&Extensions::textureHalfFloatLinearOES>, AlwaysSupported,                                 NeverSupported, NeverSupported);
1353     AddRGBAFormat(&map, GL_RG,           false, 16, 16,  0,  0, 0, GL_RG,   GL_HALF_FLOAT_OES,               GL_FLOAT, false, RequireExtAndExt<&Extensions::textureHalfFloatOES, &Extensions::textureRgEXT>,    RequireExt<&Extensions::textureHalfFloatLinearOES>, AlwaysSupported,                                 NeverSupported, NeverSupported);
1354     AddRGBAFormat(&map, GL_RGB,          false, 16, 16, 16,  0, 0, GL_RGB,  GL_HALF_FLOAT_OES,               GL_FLOAT, false, RequireExt<&Extensions::textureHalfFloatOES>,                                  RequireExt<&Extensions::textureHalfFloatLinearOES>, RequireExt<&Extensions::colorBufferHalfFloatEXT>,   NeverSupported, NeverSupported);
1355     AddRGBAFormat(&map, GL_RGBA,         false, 16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT_OES,               GL_FLOAT, false, RequireExt<&Extensions::textureHalfFloatOES>,                                  RequireExt<&Extensions::textureHalfFloatLinearOES>, RequireExt<&Extensions::colorBufferHalfFloatEXT>,   NeverSupported, NeverSupported);
1356     AddRGBAFormat(&map, GL_RED,          false, 32,  0,  0,  0, 0, GL_RED,  GL_FLOAT,                        GL_FLOAT, false, RequireExtAndExt<&Extensions::textureFloatOES, &Extensions::textureRgEXT>,     RequireExt<&Extensions::textureFloatLinearOES>,  AlwaysSupported,                                 NeverSupported, NeverSupported);
1357     AddRGBAFormat(&map, GL_RG,           false, 32, 32,  0,  0, 0, GL_RG,   GL_FLOAT,                        GL_FLOAT, false, RequireExtAndExt<&Extensions::textureFloatOES, &Extensions::textureRgEXT>,     RequireExt<&Extensions::textureFloatLinearOES>,  AlwaysSupported,                                 NeverSupported, NeverSupported);
1358     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);
1359     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);
1360     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);
1361     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);
1362 
1363     // Unsized luminance alpha formats
1364     //                 | Internal format   |sized | L | A | Format            | Type             | Component type        | Texture supported                        | Filterable                                     | Texture attachment | Renderbuffer  | Blend
1365     AddLUMAFormat(&map, GL_ALPHA,           false,  0,  8, GL_ALPHA,           GL_UNSIGNED_BYTE,  GL_UNSIGNED_NORMALIZED, AlwaysSupported,                           AlwaysSupported,                                 NeverSupported,      NeverSupported, NeverSupported);
1366     AddLUMAFormat(&map, GL_LUMINANCE,       false,  8,  0, GL_LUMINANCE,       GL_UNSIGNED_BYTE,  GL_UNSIGNED_NORMALIZED, AlwaysSupported,                           AlwaysSupported,                                 NeverSupported,      NeverSupported, NeverSupported);
1367     AddLUMAFormat(&map, GL_LUMINANCE_ALPHA, false,  8,  8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE,  GL_UNSIGNED_NORMALIZED, AlwaysSupported,                           AlwaysSupported,                                 NeverSupported,      NeverSupported, NeverSupported);
1368     AddLUMAFormat(&map, GL_ALPHA,           false,  0, 16, GL_ALPHA,           GL_HALF_FLOAT_OES, GL_FLOAT,               RequireExt<&Extensions::textureHalfFloatOES>, RequireExt<&Extensions::textureHalfFloatLinearOES>, NeverSupported,      NeverSupported, NeverSupported);
1369     AddLUMAFormat(&map, GL_LUMINANCE,       false, 16,  0, GL_LUMINANCE,       GL_HALF_FLOAT_OES, GL_FLOAT,               RequireExt<&Extensions::textureHalfFloatOES>, RequireExt<&Extensions::textureHalfFloatLinearOES>, NeverSupported,      NeverSupported, NeverSupported);
1370     AddLUMAFormat(&map, GL_LUMINANCE_ALPHA, false, 16, 16, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, GL_FLOAT,               RequireExt<&Extensions::textureHalfFloatOES>, RequireExt<&Extensions::textureHalfFloatLinearOES>, NeverSupported,      NeverSupported, NeverSupported);
1371     AddLUMAFormat(&map, GL_ALPHA,           false,  0, 32, GL_ALPHA,           GL_FLOAT,          GL_FLOAT,               RequireExt<&Extensions::textureFloatOES>,  RequireExt<&Extensions::textureFloatLinearOES>,  NeverSupported,      NeverSupported, NeverSupported);
1372     AddLUMAFormat(&map, GL_LUMINANCE,       false, 32,  0, GL_LUMINANCE,       GL_FLOAT,          GL_FLOAT,               RequireExt<&Extensions::textureFloatOES>,  RequireExt<&Extensions::textureFloatLinearOES>,  NeverSupported,      NeverSupported, NeverSupported);
1373     AddLUMAFormat(&map, GL_LUMINANCE_ALPHA, false, 32, 32, GL_LUMINANCE_ALPHA, GL_FLOAT,          GL_FLOAT,               RequireExt<&Extensions::textureFloatOES>,  RequireExt<&Extensions::textureFloatLinearOES>,  NeverSupported,      NeverSupported, NeverSupported);
1374 
1375     // Unsized depth stencil formats
1376     //                         | Internal format   |sized | D |S | X | Format            | Type                             | Component type        | Texture supported                                       | Filterable     | Texture attachment                                                                  | Renderbuffer                                                                       | Blend
1377     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>);
1378     AddDepthStencilFormat(&map, GL_DEPTH_COMPONENT, false, 24, 0,  8, 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>);
1379     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>);
1380     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>);
1381     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>);
1382     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>);
1383     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>);
1384     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>);
1385 
1386     // Non-standard YUV formats
1387     //                 | Internal format                             | sized | Cr | Y | Cb | A | S | Format                              | Type            | Comp                  | SRGB | Texture supported                                       | Filterable                                              | Texture attachment                                      | Renderbuffer  | Blend
1388     AddYUVFormat(&map,  GL_G8_B8R8_2PLANE_420_UNORM_ANGLE,            true,   8,   8,  8,   0,  0,  GL_G8_B8R8_2PLANE_420_UNORM_ANGLE,    GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::yuvInternalFormatANGLE>,          RequireExt<&Extensions::yuvInternalFormatANGLE>,          RequireExt<&Extensions::yuvInternalFormatANGLE>,          NeverSupported, NeverSupported);
1389     AddYUVFormat(&map,  GL_G8_B8_R8_3PLANE_420_UNORM_ANGLE,           true,   8,   8,  8,   0,  0,  GL_G8_B8_R8_3PLANE_420_UNORM_ANGLE,   GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::yuvInternalFormatANGLE>,          RequireExt<&Extensions::yuvInternalFormatANGLE>,          RequireExt<&Extensions::yuvInternalFormatANGLE>,          NeverSupported, NeverSupported);
1390 
1391 #if defined(ANGLE_PLATFORM_LINUX)
1392     // From GL_OES_required_internalformat
1393     // The |shared| bit shouldn't be 2. But given this hits assertion when bits
1394     // are checked, it's fine to have this bit set as 2 as a workaround.
1395     AddRGBAFormat(&map, GL_RGB10_EXT,        true, 10, 10, 10, 0, 2, GL_RGB, GL_UNSIGNED_INT_2_10_10_10_REV,    GL_UNSIGNED_NORMALIZED,        false, RequireES<1, 0>,                                      NeverSupported,  RequireES<1, 0>,                                         RequireES<1, 0>,                                 NeverSupported);
1396 #endif
1397     // clang-format on
1398 
1399     return map;
1400 }
1401 
GetInternalFormatMap()1402 const InternalFormatInfoMap &GetInternalFormatMap()
1403 {
1404     static const angle::base::NoDestructor<InternalFormatInfoMap> formatMap(
1405         BuildInternalFormatInfoMap());
1406     return *formatMap;
1407 }
1408 
GetAndroidHardwareBufferFormatFromChannelSizes(const egl::AttributeMap & attribMap)1409 int GetAndroidHardwareBufferFormatFromChannelSizes(const egl::AttributeMap &attribMap)
1410 {
1411     // Retrieve channel size from attribute map. The default value should be 0, per spec.
1412     GLuint redSize   = static_cast<GLuint>(attribMap.getAsInt(EGL_RED_SIZE, 0));
1413     GLuint greenSize = static_cast<GLuint>(attribMap.getAsInt(EGL_GREEN_SIZE, 0));
1414     GLuint blueSize  = static_cast<GLuint>(attribMap.getAsInt(EGL_BLUE_SIZE, 0));
1415     GLuint alphaSize = static_cast<GLuint>(attribMap.getAsInt(EGL_ALPHA_SIZE, 0));
1416 
1417     GLenum glInternalFormat = 0;
1418     for (GLenum sizedInternalFormat : angle::android::kSupportedSizedInternalFormats)
1419     {
1420         const gl::InternalFormat &internalFormat = GetSizedInternalFormatInfo(sizedInternalFormat);
1421         ASSERT(internalFormat.internalFormat != GL_NONE && internalFormat.sized);
1422 
1423         if (internalFormat.isChannelSizeCompatible(redSize, greenSize, blueSize, alphaSize))
1424         {
1425             glInternalFormat = sizedInternalFormat;
1426             break;
1427         }
1428     }
1429 
1430     return (glInternalFormat != 0)
1431                ? angle::android::GLInternalFormatToNativePixelFormat(glInternalFormat)
1432                : 0;
1433 }
1434 
GetConfigColorBufferFormat(const egl::Config * config)1435 GLenum GetConfigColorBufferFormat(const egl::Config *config)
1436 {
1437     GLenum componentType = GL_NONE;
1438     switch (config->colorComponentType)
1439     {
1440         case EGL_COLOR_COMPONENT_TYPE_FIXED_EXT:
1441             componentType = GL_UNSIGNED_NORMALIZED;
1442             break;
1443         case EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT:
1444             componentType = GL_FLOAT;
1445             break;
1446         default:
1447             UNREACHABLE();
1448             return GL_NONE;
1449     }
1450 
1451     GLenum colorEncoding = GL_LINEAR;
1452 
1453     for (GLenum sizedInternalFormat : GetAllSizedInternalFormats())
1454     {
1455         const gl::InternalFormat &internalFormat = GetSizedInternalFormatInfo(sizedInternalFormat);
1456 
1457         if (internalFormat.componentType == componentType &&
1458             internalFormat.colorEncoding == colorEncoding &&
1459             internalFormat.isChannelSizeCompatible(config->redSize, config->greenSize,
1460                                                    config->blueSize, config->alphaSize))
1461         {
1462             return sizedInternalFormat;
1463         }
1464     }
1465 
1466     // Only expect to get here if there is no color bits in the config
1467     ASSERT(config->redSize == 0 && config->greenSize == 0 && config->blueSize == 0 &&
1468            config->alphaSize == 0);
1469     return GL_NONE;
1470 }
1471 
GetConfigDepthStencilBufferFormat(const egl::Config * config)1472 GLenum GetConfigDepthStencilBufferFormat(const egl::Config *config)
1473 {
1474     GLenum componentType = GL_UNSIGNED_NORMALIZED;
1475 
1476     for (GLenum sizedInternalFormat : GetAllSizedInternalFormats())
1477     {
1478         const gl::InternalFormat &internalFormat = GetSizedInternalFormatInfo(sizedInternalFormat);
1479 
1480         if (internalFormat.componentType == componentType &&
1481             static_cast<EGLint>(internalFormat.depthBits) == config->depthSize &&
1482             static_cast<EGLint>(internalFormat.stencilBits) == config->stencilSize)
1483         {
1484             return sizedInternalFormat;
1485         }
1486     }
1487 
1488     // Only expect to get here if there is no depth or stencil bits in the config
1489     ASSERT(config->depthSize == 0 && config->stencilSize == 0);
1490     return GL_NONE;
1491 }
1492 
BuildAllSizedInternalFormatSet()1493 static FormatSet BuildAllSizedInternalFormatSet()
1494 {
1495     FormatSet result;
1496 
1497     for (const auto &internalFormat : GetInternalFormatMap())
1498     {
1499         for (const auto &type : internalFormat.second)
1500         {
1501             if (type.second.sized)
1502             {
1503                 // TODO(jmadill): Fix this hack.
1504                 if (internalFormat.first == GL_BGR565_ANGLEX)
1505                     continue;
1506 
1507                 result.insert(internalFormat.first);
1508             }
1509         }
1510     }
1511 
1512     return result;
1513 }
1514 
GetPackedTypeInfo(GLenum type)1515 uint32_t GetPackedTypeInfo(GLenum type)
1516 {
1517     switch (type)
1518     {
1519         case GL_UNSIGNED_BYTE:
1520         case GL_BYTE:
1521         {
1522             static constexpr uint32_t kPacked = PackTypeInfo(1, false);
1523             return kPacked;
1524         }
1525         case GL_UNSIGNED_SHORT:
1526         case GL_SHORT:
1527         case GL_HALF_FLOAT:
1528         case GL_HALF_FLOAT_OES:
1529         {
1530             static constexpr uint32_t kPacked = PackTypeInfo(2, false);
1531             return kPacked;
1532         }
1533         case GL_UNSIGNED_INT:
1534         case GL_INT:
1535         case GL_FLOAT:
1536         {
1537             static constexpr uint32_t kPacked = PackTypeInfo(4, false);
1538             return kPacked;
1539         }
1540         case GL_UNSIGNED_SHORT_5_6_5:
1541         case GL_UNSIGNED_SHORT_4_4_4_4:
1542         case GL_UNSIGNED_SHORT_5_5_5_1:
1543         case GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT:
1544         case GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT:
1545         {
1546             static constexpr uint32_t kPacked = PackTypeInfo(2, true);
1547             return kPacked;
1548         }
1549         case GL_UNSIGNED_INT_2_10_10_10_REV:
1550         case GL_UNSIGNED_INT_24_8:
1551         case GL_UNSIGNED_INT_10F_11F_11F_REV:
1552         case GL_UNSIGNED_INT_5_9_9_9_REV:
1553         {
1554             ASSERT(GL_UNSIGNED_INT_24_8_OES == GL_UNSIGNED_INT_24_8);
1555             static constexpr uint32_t kPacked = PackTypeInfo(4, true);
1556             return kPacked;
1557         }
1558         case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:
1559         {
1560             static constexpr uint32_t kPacked = PackTypeInfo(8, true);
1561             return kPacked;
1562         }
1563         default:
1564         {
1565             return 0;
1566         }
1567     }
1568 }
1569 
GetSizedInternalFormatInfo(GLenum internalFormat)1570 const InternalFormat &GetSizedInternalFormatInfo(GLenum internalFormat)
1571 {
1572     static const InternalFormat defaultInternalFormat;
1573     const InternalFormatInfoMap &formatMap = GetInternalFormatMap();
1574     auto iter                              = formatMap.find(internalFormat);
1575 
1576     // Sized internal formats only have one type per entry
1577     if (iter == formatMap.end() || iter->second.size() != 1)
1578     {
1579         return defaultInternalFormat;
1580     }
1581 
1582     const InternalFormat &internalFormatInfo = iter->second.begin()->second;
1583     if (!internalFormatInfo.sized)
1584     {
1585         return defaultInternalFormat;
1586     }
1587 
1588     return internalFormatInfo;
1589 }
1590 
GetInternalFormatInfo(GLenum internalFormat,GLenum type)1591 const InternalFormat &GetInternalFormatInfo(GLenum internalFormat, GLenum type)
1592 {
1593     static const InternalFormat defaultInternalFormat;
1594     const InternalFormatInfoMap &formatMap = GetInternalFormatMap();
1595 
1596     auto internalFormatIter = formatMap.find(internalFormat);
1597     if (internalFormatIter == formatMap.end())
1598     {
1599         return defaultInternalFormat;
1600     }
1601 
1602     // If the internal format is sized, simply return it without the type check.
1603     if (internalFormatIter->second.size() == 1 && internalFormatIter->second.begin()->second.sized)
1604     {
1605         return internalFormatIter->second.begin()->second;
1606     }
1607 
1608     auto typeIter = internalFormatIter->second.find(type);
1609     if (typeIter == internalFormatIter->second.end())
1610     {
1611         return defaultInternalFormat;
1612     }
1613 
1614     return typeIter->second;
1615 }
1616 
computePixelBytes(GLenum formatType) const1617 GLuint InternalFormat::computePixelBytes(GLenum formatType) const
1618 {
1619     const auto &typeInfo = GetTypeInfo(formatType);
1620     GLuint components    = typeInfo.specialInterpretation ? 1u : componentCount;
1621     return components * typeInfo.bytes;
1622 }
1623 
computeBufferRowLength(uint32_t width,uint32_t * resultOut) const1624 bool InternalFormat::computeBufferRowLength(uint32_t width, uint32_t *resultOut) const
1625 {
1626     CheckedNumeric<GLuint> checkedWidth(width);
1627 
1628     if (compressed)
1629     {
1630         angle::CheckedNumeric<uint32_t> checkedRowLength =
1631             rx::CheckedRoundUp<uint32_t>(width, compressedBlockWidth);
1632 
1633         return CheckedMathResult(checkedRowLength, resultOut);
1634     }
1635 
1636     return CheckedMathResult(checkedWidth, resultOut);
1637 }
1638 
computeBufferImageHeight(uint32_t height,uint32_t * resultOut) const1639 bool InternalFormat::computeBufferImageHeight(uint32_t height, uint32_t *resultOut) const
1640 {
1641     CheckedNumeric<GLuint> checkedHeight(height);
1642 
1643     if (compressed)
1644     {
1645         angle::CheckedNumeric<uint32_t> checkedImageHeight =
1646             rx::CheckedRoundUp<uint32_t>(height, compressedBlockHeight);
1647 
1648         return CheckedMathResult(checkedImageHeight, resultOut);
1649     }
1650 
1651     return CheckedMathResult(checkedHeight, resultOut);
1652 }
1653 
computeRowPitch(GLenum formatType,GLsizei width,GLint alignment,GLint rowLength,GLuint * resultOut) const1654 bool InternalFormat::computeRowPitch(GLenum formatType,
1655                                      GLsizei width,
1656                                      GLint alignment,
1657                                      GLint rowLength,
1658                                      GLuint *resultOut) const
1659 {
1660     // Compressed images do not use pack/unpack parameters (rowLength).
1661     if (compressed)
1662     {
1663         return computeCompressedImageSize(Extents(width, 1, 1), resultOut);
1664     }
1665 
1666     CheckedNumeric<GLuint> checkedWidth(rowLength > 0 ? rowLength : width);
1667     CheckedNumeric<GLuint> checkedRowBytes = checkedWidth * computePixelBytes(formatType);
1668 
1669     ASSERT(alignment > 0 && isPow2(alignment));
1670     CheckedNumeric<GLuint> checkedAlignment(alignment);
1671     auto aligned = rx::roundUp(checkedRowBytes, checkedAlignment);
1672     return CheckedMathResult(aligned, resultOut);
1673 }
1674 
computeDepthPitch(GLsizei height,GLint imageHeight,GLuint rowPitch,GLuint * resultOut) const1675 bool InternalFormat::computeDepthPitch(GLsizei height,
1676                                        GLint imageHeight,
1677                                        GLuint rowPitch,
1678                                        GLuint *resultOut) const
1679 {
1680     // Compressed images do not use pack/unpack parameters (imageHeight).
1681     CheckedNumeric<GLuint> pixelsHeight(!compressed && (imageHeight > 0)
1682                                             ? static_cast<GLuint>(imageHeight)
1683                                             : static_cast<GLuint>(height));
1684 
1685     CheckedNumeric<GLuint> rowCount;
1686     if (compressed)
1687     {
1688         CheckedNumeric<GLuint> checkedBlockHeight(compressedBlockHeight);
1689         rowCount = (pixelsHeight + checkedBlockHeight - 1u) / checkedBlockHeight;
1690     }
1691     else
1692     {
1693         rowCount = pixelsHeight;
1694     }
1695 
1696     CheckedNumeric<GLuint> checkedRowPitch(rowPitch);
1697 
1698     return CheckedMathResult(checkedRowPitch * rowCount, resultOut);
1699 }
1700 
computeDepthPitch(GLenum formatType,GLsizei width,GLsizei height,GLint alignment,GLint rowLength,GLint imageHeight,GLuint * resultOut) const1701 bool InternalFormat::computeDepthPitch(GLenum formatType,
1702                                        GLsizei width,
1703                                        GLsizei height,
1704                                        GLint alignment,
1705                                        GLint rowLength,
1706                                        GLint imageHeight,
1707                                        GLuint *resultOut) const
1708 {
1709     GLuint rowPitch = 0;
1710     if (!computeRowPitch(formatType, width, alignment, rowLength, &rowPitch))
1711     {
1712         return false;
1713     }
1714     return computeDepthPitch(height, imageHeight, rowPitch, resultOut);
1715 }
1716 
computeCompressedImageSize(const Extents & size,GLuint * resultOut) const1717 bool InternalFormat::computeCompressedImageSize(const Extents &size, GLuint *resultOut) const
1718 {
1719     CheckedNumeric<GLuint> checkedWidth(size.width);
1720     CheckedNumeric<GLuint> checkedHeight(size.height);
1721     CheckedNumeric<GLuint> checkedDepth(size.depth);
1722     CheckedNumeric<GLuint> checkedBlockWidth(compressedBlockWidth);
1723     CheckedNumeric<GLuint> checkedBlockHeight(compressedBlockHeight);
1724     GLuint minBlockWidth, minBlockHeight;
1725     std::tie(minBlockWidth, minBlockHeight) = getCompressedImageMinBlocks();
1726 
1727     ASSERT(compressed);
1728     auto numBlocksWide = (checkedWidth + checkedBlockWidth - 1u) / checkedBlockWidth;
1729     auto numBlocksHigh = (checkedHeight + checkedBlockHeight - 1u) / checkedBlockHeight;
1730     if (numBlocksWide.IsValid() && numBlocksWide.ValueOrDie() < minBlockWidth)
1731         numBlocksWide = minBlockWidth;
1732     if (numBlocksHigh.IsValid() && numBlocksHigh.ValueOrDie() < minBlockHeight)
1733         numBlocksHigh = minBlockHeight;
1734     auto bytes = numBlocksWide * numBlocksHigh * pixelBytes * checkedDepth;
1735     return CheckedMathResult(bytes, resultOut);
1736 }
1737 
getCompressedImageMinBlocks() const1738 std::pair<GLuint, GLuint> InternalFormat::getCompressedImageMinBlocks() const
1739 {
1740     GLuint minBlockWidth  = 0;
1741     GLuint minBlockHeight = 0;
1742 
1743     // Per the specification, a PVRTC block needs information from the 3 nearest blocks.
1744     // GL_IMG_texture_compression_pvrtc specifies the minimum size requirement in pixels, but
1745     // ANGLE's texture tables are written in terms of blocks. The 4BPP formats use 4x4 blocks, and
1746     // the 2BPP formats, 8x4 blocks. Therefore, both kinds of formats require a minimum of 2x2
1747     // blocks.
1748     switch (internalFormat)
1749     {
1750         case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
1751         case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
1752         case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
1753         case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:
1754         case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT:
1755         case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT:
1756         case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT:
1757         case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT:
1758             minBlockWidth  = 2;
1759             minBlockHeight = 2;
1760             break;
1761 
1762         default:
1763             break;
1764     }
1765 
1766     return std::make_pair(minBlockWidth, minBlockHeight);
1767 }
1768 
computeSkipBytes(GLenum formatType,GLuint rowPitch,GLuint depthPitch,const PixelStoreStateBase & state,bool is3D,GLuint * resultOut) const1769 bool InternalFormat::computeSkipBytes(GLenum formatType,
1770                                       GLuint rowPitch,
1771                                       GLuint depthPitch,
1772                                       const PixelStoreStateBase &state,
1773                                       bool is3D,
1774                                       GLuint *resultOut) const
1775 {
1776     CheckedNumeric<GLuint> checkedRowPitch(rowPitch);
1777     CheckedNumeric<GLuint> checkedDepthPitch(depthPitch);
1778     CheckedNumeric<GLuint> checkedSkipImages(static_cast<GLuint>(state.skipImages));
1779     CheckedNumeric<GLuint> checkedSkipRows(static_cast<GLuint>(state.skipRows));
1780     CheckedNumeric<GLuint> checkedSkipPixels(static_cast<GLuint>(state.skipPixels));
1781     CheckedNumeric<GLuint> checkedPixelBytes(computePixelBytes(formatType));
1782     auto checkedSkipImagesBytes = checkedSkipImages * checkedDepthPitch;
1783     if (!is3D)
1784     {
1785         checkedSkipImagesBytes = 0;
1786     }
1787     auto skipBytes = checkedSkipImagesBytes + checkedSkipRows * checkedRowPitch +
1788                      checkedSkipPixels * checkedPixelBytes;
1789     return CheckedMathResult(skipBytes, resultOut);
1790 }
1791 
computePackUnpackEndByte(GLenum formatType,const Extents & size,const PixelStoreStateBase & state,bool is3D,GLuint * resultOut) const1792 bool InternalFormat::computePackUnpackEndByte(GLenum formatType,
1793                                               const Extents &size,
1794                                               const PixelStoreStateBase &state,
1795                                               bool is3D,
1796                                               GLuint *resultOut) const
1797 {
1798     GLuint rowPitch = 0;
1799     if (!computeRowPitch(formatType, size.width, state.alignment, state.rowLength, &rowPitch))
1800     {
1801         return false;
1802     }
1803 
1804     GLuint depthPitch = 0;
1805     if (is3D && !computeDepthPitch(size.height, state.imageHeight, rowPitch, &depthPitch))
1806     {
1807         return false;
1808     }
1809 
1810     CheckedNumeric<GLuint> checkedCopyBytes(0);
1811     if (compressed)
1812     {
1813         GLuint copyBytes = 0;
1814         if (!computeCompressedImageSize(size, &copyBytes))
1815         {
1816             return false;
1817         }
1818         checkedCopyBytes = copyBytes;
1819     }
1820     else if (size.height != 0 && (!is3D || size.depth != 0))
1821     {
1822         CheckedNumeric<GLuint> bytes = computePixelBytes(formatType);
1823         checkedCopyBytes += size.width * bytes;
1824 
1825         CheckedNumeric<GLuint> heightMinusOne = size.height - 1;
1826         checkedCopyBytes += heightMinusOne * rowPitch;
1827 
1828         if (is3D)
1829         {
1830             CheckedNumeric<GLuint> depthMinusOne = size.depth - 1;
1831             checkedCopyBytes += depthMinusOne * depthPitch;
1832         }
1833     }
1834 
1835     GLuint skipBytes = 0;
1836     if (!computeSkipBytes(formatType, rowPitch, depthPitch, state, is3D, &skipBytes))
1837     {
1838         return false;
1839     }
1840 
1841     CheckedNumeric<GLuint> endByte = checkedCopyBytes + CheckedNumeric<GLuint>(skipBytes);
1842 
1843     return CheckedMathResult(endByte, resultOut);
1844 }
1845 
GetUnsizedFormat(GLenum internalFormat)1846 GLenum GetUnsizedFormat(GLenum internalFormat)
1847 {
1848     auto sizedFormatInfo = GetSizedInternalFormatInfo(internalFormat);
1849     if (sizedFormatInfo.internalFormat != GL_NONE)
1850     {
1851         return sizedFormatInfo.format;
1852     }
1853 
1854     return internalFormat;
1855 }
1856 
CompressedFormatRequiresWholeImage(GLenum internalFormat)1857 bool CompressedFormatRequiresWholeImage(GLenum internalFormat)
1858 {
1859     // List of compressed texture format that require that the sub-image size is equal to texture's
1860     // respective mip level's size
1861     return IsPVRTC1Format(internalFormat);
1862 }
1863 
MaybeOverrideLuminance(GLenum & format,GLenum & type,GLenum actualFormat,GLenum actualType)1864 void MaybeOverrideLuminance(GLenum &format, GLenum &type, GLenum actualFormat, GLenum actualType)
1865 {
1866     gl::InternalFormat internalFormat = gl::GetInternalFormatInfo(format, type);
1867     if (internalFormat.isLUMA())
1868     {
1869         // Ensure the format and type are compatible
1870         ASSERT(internalFormat.pixelBytes ==
1871                gl::GetInternalFormatInfo(actualFormat, actualType).pixelBytes);
1872 
1873         // For Luminance formats, override with the internal format. Since this is not
1874         // renderable, our pixel pack routines don't handle it correctly.
1875         format = actualFormat;
1876         type   = actualType;
1877     }
1878 }
1879 
GetAllSizedInternalFormats()1880 const FormatSet &GetAllSizedInternalFormats()
1881 {
1882     static angle::base::NoDestructor<FormatSet> formatSet(BuildAllSizedInternalFormatSet());
1883     return *formatSet;
1884 }
1885 
GetAttributeType(GLenum enumValue)1886 AttributeType GetAttributeType(GLenum enumValue)
1887 {
1888     switch (enumValue)
1889     {
1890         case GL_FLOAT:
1891             return ATTRIBUTE_FLOAT;
1892         case GL_FLOAT_VEC2:
1893             return ATTRIBUTE_VEC2;
1894         case GL_FLOAT_VEC3:
1895             return ATTRIBUTE_VEC3;
1896         case GL_FLOAT_VEC4:
1897             return ATTRIBUTE_VEC4;
1898         case GL_INT:
1899             return ATTRIBUTE_INT;
1900         case GL_INT_VEC2:
1901             return ATTRIBUTE_IVEC2;
1902         case GL_INT_VEC3:
1903             return ATTRIBUTE_IVEC3;
1904         case GL_INT_VEC4:
1905             return ATTRIBUTE_IVEC4;
1906         case GL_UNSIGNED_INT:
1907             return ATTRIBUTE_UINT;
1908         case GL_UNSIGNED_INT_VEC2:
1909             return ATTRIBUTE_UVEC2;
1910         case GL_UNSIGNED_INT_VEC3:
1911             return ATTRIBUTE_UVEC3;
1912         case GL_UNSIGNED_INT_VEC4:
1913             return ATTRIBUTE_UVEC4;
1914         case GL_FLOAT_MAT2:
1915             return ATTRIBUTE_MAT2;
1916         case GL_FLOAT_MAT3:
1917             return ATTRIBUTE_MAT3;
1918         case GL_FLOAT_MAT4:
1919             return ATTRIBUTE_MAT4;
1920         case GL_FLOAT_MAT2x3:
1921             return ATTRIBUTE_MAT2x3;
1922         case GL_FLOAT_MAT2x4:
1923             return ATTRIBUTE_MAT2x4;
1924         case GL_FLOAT_MAT3x2:
1925             return ATTRIBUTE_MAT3x2;
1926         case GL_FLOAT_MAT3x4:
1927             return ATTRIBUTE_MAT3x4;
1928         case GL_FLOAT_MAT4x2:
1929             return ATTRIBUTE_MAT4x2;
1930         case GL_FLOAT_MAT4x3:
1931             return ATTRIBUTE_MAT4x3;
1932         default:
1933             UNREACHABLE();
1934 #if !UNREACHABLE_IS_NORETURN
1935             return ATTRIBUTE_FLOAT;
1936 #endif
1937     }
1938 }
1939 
GetVertexFormatID(VertexAttribType type,GLboolean normalized,GLuint components,bool pureInteger)1940 angle::FormatID GetVertexFormatID(VertexAttribType type,
1941                                   GLboolean normalized,
1942                                   GLuint components,
1943                                   bool pureInteger)
1944 {
1945     switch (type)
1946     {
1947         case VertexAttribType::Byte:
1948             switch (components)
1949             {
1950                 case 1:
1951                     if (pureInteger)
1952                         return angle::FormatID::R8_SINT;
1953                     if (normalized)
1954                         return angle::FormatID::R8_SNORM;
1955                     return angle::FormatID::R8_SSCALED;
1956                 case 2:
1957                     if (pureInteger)
1958                         return angle::FormatID::R8G8_SINT;
1959                     if (normalized)
1960                         return angle::FormatID::R8G8_SNORM;
1961                     return angle::FormatID::R8G8_SSCALED;
1962                 case 3:
1963                     if (pureInteger)
1964                         return angle::FormatID::R8G8B8_SINT;
1965                     if (normalized)
1966                         return angle::FormatID::R8G8B8_SNORM;
1967                     return angle::FormatID::R8G8B8_SSCALED;
1968                 case 4:
1969                     if (pureInteger)
1970                         return angle::FormatID::R8G8B8A8_SINT;
1971                     if (normalized)
1972                         return angle::FormatID::R8G8B8A8_SNORM;
1973                     return angle::FormatID::R8G8B8A8_SSCALED;
1974                 default:
1975                     UNREACHABLE();
1976 #if !UNREACHABLE_IS_NORETURN
1977                     return angle::FormatID::NONE;
1978 #endif
1979             }
1980         case VertexAttribType::UnsignedByte:
1981             switch (components)
1982             {
1983                 case 1:
1984                     if (pureInteger)
1985                         return angle::FormatID::R8_UINT;
1986                     if (normalized)
1987                         return angle::FormatID::R8_UNORM;
1988                     return angle::FormatID::R8_USCALED;
1989                 case 2:
1990                     if (pureInteger)
1991                         return angle::FormatID::R8G8_UINT;
1992                     if (normalized)
1993                         return angle::FormatID::R8G8_UNORM;
1994                     return angle::FormatID::R8G8_USCALED;
1995                 case 3:
1996                     if (pureInteger)
1997                         return angle::FormatID::R8G8B8_UINT;
1998                     if (normalized)
1999                         return angle::FormatID::R8G8B8_UNORM;
2000                     return angle::FormatID::R8G8B8_USCALED;
2001                 case 4:
2002                     if (pureInteger)
2003                         return angle::FormatID::R8G8B8A8_UINT;
2004                     if (normalized)
2005                         return angle::FormatID::R8G8B8A8_UNORM;
2006                     return angle::FormatID::R8G8B8A8_USCALED;
2007                 default:
2008                     UNREACHABLE();
2009 #if !UNREACHABLE_IS_NORETURN
2010                     return angle::FormatID::NONE;
2011 #endif
2012             }
2013         case VertexAttribType::Short:
2014             switch (components)
2015             {
2016                 case 1:
2017                     if (pureInteger)
2018                         return angle::FormatID::R16_SINT;
2019                     if (normalized)
2020                         return angle::FormatID::R16_SNORM;
2021                     return angle::FormatID::R16_SSCALED;
2022                 case 2:
2023                     if (pureInteger)
2024                         return angle::FormatID::R16G16_SINT;
2025                     if (normalized)
2026                         return angle::FormatID::R16G16_SNORM;
2027                     return angle::FormatID::R16G16_SSCALED;
2028                 case 3:
2029                     if (pureInteger)
2030                         return angle::FormatID::R16G16B16_SINT;
2031                     if (normalized)
2032                         return angle::FormatID::R16G16B16_SNORM;
2033                     return angle::FormatID::R16G16B16_SSCALED;
2034                 case 4:
2035                     if (pureInteger)
2036                         return angle::FormatID::R16G16B16A16_SINT;
2037                     if (normalized)
2038                         return angle::FormatID::R16G16B16A16_SNORM;
2039                     return angle::FormatID::R16G16B16A16_SSCALED;
2040                 default:
2041                     UNREACHABLE();
2042 #if !UNREACHABLE_IS_NORETURN
2043                     return angle::FormatID::NONE;
2044 #endif
2045             }
2046         case VertexAttribType::UnsignedShort:
2047             switch (components)
2048             {
2049                 case 1:
2050                     if (pureInteger)
2051                         return angle::FormatID::R16_UINT;
2052                     if (normalized)
2053                         return angle::FormatID::R16_UNORM;
2054                     return angle::FormatID::R16_USCALED;
2055                 case 2:
2056                     if (pureInteger)
2057                         return angle::FormatID::R16G16_UINT;
2058                     if (normalized)
2059                         return angle::FormatID::R16G16_UNORM;
2060                     return angle::FormatID::R16G16_USCALED;
2061                 case 3:
2062                     if (pureInteger)
2063                         return angle::FormatID::R16G16B16_UINT;
2064                     if (normalized)
2065                         return angle::FormatID::R16G16B16_UNORM;
2066                     return angle::FormatID::R16G16B16_USCALED;
2067                 case 4:
2068                     if (pureInteger)
2069                         return angle::FormatID::R16G16B16A16_UINT;
2070                     if (normalized)
2071                         return angle::FormatID::R16G16B16A16_UNORM;
2072                     return angle::FormatID::R16G16B16A16_USCALED;
2073                 default:
2074                     UNREACHABLE();
2075 #if !UNREACHABLE_IS_NORETURN
2076                     return angle::FormatID::NONE;
2077 #endif
2078             }
2079         case VertexAttribType::Int:
2080             switch (components)
2081             {
2082                 case 1:
2083                     if (pureInteger)
2084                         return angle::FormatID::R32_SINT;
2085                     if (normalized)
2086                         return angle::FormatID::R32_SNORM;
2087                     return angle::FormatID::R32_SSCALED;
2088                 case 2:
2089                     if (pureInteger)
2090                         return angle::FormatID::R32G32_SINT;
2091                     if (normalized)
2092                         return angle::FormatID::R32G32_SNORM;
2093                     return angle::FormatID::R32G32_SSCALED;
2094                 case 3:
2095                     if (pureInteger)
2096                         return angle::FormatID::R32G32B32_SINT;
2097                     if (normalized)
2098                         return angle::FormatID::R32G32B32_SNORM;
2099                     return angle::FormatID::R32G32B32_SSCALED;
2100                 case 4:
2101                     if (pureInteger)
2102                         return angle::FormatID::R32G32B32A32_SINT;
2103                     if (normalized)
2104                         return angle::FormatID::R32G32B32A32_SNORM;
2105                     return angle::FormatID::R32G32B32A32_SSCALED;
2106                 default:
2107                     UNREACHABLE();
2108 #if !UNREACHABLE_IS_NORETURN
2109                     return angle::FormatID::NONE;
2110 #endif
2111             }
2112         case VertexAttribType::UnsignedInt:
2113             switch (components)
2114             {
2115                 case 1:
2116                     if (pureInteger)
2117                         return angle::FormatID::R32_UINT;
2118                     if (normalized)
2119                         return angle::FormatID::R32_UNORM;
2120                     return angle::FormatID::R32_USCALED;
2121                 case 2:
2122                     if (pureInteger)
2123                         return angle::FormatID::R32G32_UINT;
2124                     if (normalized)
2125                         return angle::FormatID::R32G32_UNORM;
2126                     return angle::FormatID::R32G32_USCALED;
2127                 case 3:
2128                     if (pureInteger)
2129                         return angle::FormatID::R32G32B32_UINT;
2130                     if (normalized)
2131                         return angle::FormatID::R32G32B32_UNORM;
2132                     return angle::FormatID::R32G32B32_USCALED;
2133                 case 4:
2134                     if (pureInteger)
2135                         return angle::FormatID::R32G32B32A32_UINT;
2136                     if (normalized)
2137                         return angle::FormatID::R32G32B32A32_UNORM;
2138                     return angle::FormatID::R32G32B32A32_USCALED;
2139                 default:
2140                     UNREACHABLE();
2141 #if !UNREACHABLE_IS_NORETURN
2142                     return angle::FormatID::NONE;
2143 #endif
2144             }
2145         case VertexAttribType::Float:
2146             switch (components)
2147             {
2148                 case 1:
2149                     return angle::FormatID::R32_FLOAT;
2150                 case 2:
2151                     return angle::FormatID::R32G32_FLOAT;
2152                 case 3:
2153                     return angle::FormatID::R32G32B32_FLOAT;
2154                 case 4:
2155                     return angle::FormatID::R32G32B32A32_FLOAT;
2156                 default:
2157                     UNREACHABLE();
2158 #if !UNREACHABLE_IS_NORETURN
2159                     return angle::FormatID::NONE;
2160 #endif
2161             }
2162         case VertexAttribType::HalfFloat:
2163         case VertexAttribType::HalfFloatOES:
2164             switch (components)
2165             {
2166                 case 1:
2167                     return angle::FormatID::R16_FLOAT;
2168                 case 2:
2169                     return angle::FormatID::R16G16_FLOAT;
2170                 case 3:
2171                     return angle::FormatID::R16G16B16_FLOAT;
2172                 case 4:
2173                     return angle::FormatID::R16G16B16A16_FLOAT;
2174                 default:
2175                     UNREACHABLE();
2176 #if !UNREACHABLE_IS_NORETURN
2177                     return angle::FormatID::NONE;
2178 #endif
2179             }
2180         case VertexAttribType::Fixed:
2181             switch (components)
2182             {
2183                 case 1:
2184                     return angle::FormatID::R32_FIXED;
2185                 case 2:
2186                     return angle::FormatID::R32G32_FIXED;
2187                 case 3:
2188                     return angle::FormatID::R32G32B32_FIXED;
2189                 case 4:
2190                     return angle::FormatID::R32G32B32A32_FIXED;
2191                 default:
2192                     UNREACHABLE();
2193 #if !UNREACHABLE_IS_NORETURN
2194                     return angle::FormatID::NONE;
2195 #endif
2196             }
2197         case VertexAttribType::Int2101010:
2198             if (pureInteger)
2199                 return angle::FormatID::R10G10B10A2_SINT;
2200             if (normalized)
2201                 return angle::FormatID::R10G10B10A2_SNORM;
2202             return angle::FormatID::R10G10B10A2_SSCALED;
2203         case VertexAttribType::UnsignedInt2101010:
2204             if (pureInteger)
2205                 return angle::FormatID::R10G10B10A2_UINT;
2206             if (normalized)
2207                 return angle::FormatID::R10G10B10A2_UNORM;
2208             return angle::FormatID::R10G10B10A2_USCALED;
2209         case VertexAttribType::Int1010102:
2210             switch (components)
2211             {
2212                 case 3:
2213                     if (pureInteger)
2214                         return angle::FormatID::X2R10G10B10_SINT_VERTEX;
2215                     if (normalized)
2216                         return angle::FormatID::X2R10G10B10_SNORM_VERTEX;
2217                     return angle::FormatID::X2R10G10B10_SSCALED_VERTEX;
2218                 case 4:
2219                     if (pureInteger)
2220                         return angle::FormatID::A2R10G10B10_SINT_VERTEX;
2221                     if (normalized)
2222                         return angle::FormatID::A2R10G10B10_SNORM_VERTEX;
2223                     return angle::FormatID::A2R10G10B10_SSCALED_VERTEX;
2224                 default:
2225                     UNREACHABLE();
2226 #if !UNREACHABLE_IS_NORETURN
2227                     return angle::FormatID::NONE;
2228 #endif
2229             }
2230         case VertexAttribType::UnsignedInt1010102:
2231             switch (components)
2232             {
2233                 case 3:
2234                     if (pureInteger)
2235                         return angle::FormatID::X2R10G10B10_UINT_VERTEX;
2236                     if (normalized)
2237                         return angle::FormatID::X2R10G10B10_UNORM_VERTEX;
2238                     return angle::FormatID::X2R10G10B10_USCALED_VERTEX;
2239 
2240                 case 4:
2241                     if (pureInteger)
2242                         return angle::FormatID::A2R10G10B10_UINT_VERTEX;
2243                     if (normalized)
2244                         return angle::FormatID::A2R10G10B10_UNORM_VERTEX;
2245                     return angle::FormatID::A2R10G10B10_USCALED_VERTEX;
2246                 default:
2247                     UNREACHABLE();
2248 #if !UNREACHABLE_IS_NORETURN
2249                     return angle::FormatID::NONE;
2250 #endif
2251             }
2252         default:
2253             UNREACHABLE();
2254 #if !UNREACHABLE_IS_NORETURN
2255             return angle::FormatID::NONE;
2256 #endif
2257     }
2258 }
2259 
GetVertexFormatID(const VertexAttribute & attrib,VertexAttribType currentValueType)2260 angle::FormatID GetVertexFormatID(const VertexAttribute &attrib, VertexAttribType currentValueType)
2261 {
2262     if (!attrib.enabled)
2263     {
2264         return GetCurrentValueFormatID(currentValueType);
2265     }
2266     return attrib.format->id;
2267 }
2268 
GetCurrentValueFormatID(VertexAttribType currentValueType)2269 angle::FormatID GetCurrentValueFormatID(VertexAttribType currentValueType)
2270 {
2271     switch (currentValueType)
2272     {
2273         case VertexAttribType::Float:
2274             return angle::FormatID::R32G32B32A32_FLOAT;
2275         case VertexAttribType::Int:
2276             return angle::FormatID::R32G32B32A32_SINT;
2277         case VertexAttribType::UnsignedInt:
2278             return angle::FormatID::R32G32B32A32_UINT;
2279         default:
2280             UNREACHABLE();
2281             return angle::FormatID::NONE;
2282     }
2283 }
2284 
GetVertexFormatFromID(angle::FormatID vertexFormatID)2285 const VertexFormat &GetVertexFormatFromID(angle::FormatID vertexFormatID)
2286 {
2287     switch (vertexFormatID)
2288     {
2289         case angle::FormatID::R8_SSCALED:
2290         {
2291             static const VertexFormat format(GL_BYTE, GL_FALSE, 1, false);
2292             return format;
2293         }
2294         case angle::FormatID::R8_SNORM:
2295         {
2296             static const VertexFormat format(GL_BYTE, GL_TRUE, 1, false);
2297             return format;
2298         }
2299         case angle::FormatID::R8G8_SSCALED:
2300         {
2301             static const VertexFormat format(GL_BYTE, GL_FALSE, 2, false);
2302             return format;
2303         }
2304         case angle::FormatID::R8G8_SNORM:
2305         {
2306             static const VertexFormat format(GL_BYTE, GL_TRUE, 2, false);
2307             return format;
2308         }
2309         case angle::FormatID::R8G8B8_SSCALED:
2310         {
2311             static const VertexFormat format(GL_BYTE, GL_FALSE, 3, false);
2312             return format;
2313         }
2314         case angle::FormatID::R8G8B8_SNORM:
2315         {
2316             static const VertexFormat format(GL_BYTE, GL_TRUE, 3, false);
2317             return format;
2318         }
2319         case angle::FormatID::R8G8B8A8_SSCALED:
2320         {
2321             static const VertexFormat format(GL_BYTE, GL_FALSE, 4, false);
2322             return format;
2323         }
2324         case angle::FormatID::R8G8B8A8_SNORM:
2325         {
2326             static const VertexFormat format(GL_BYTE, GL_TRUE, 4, false);
2327             return format;
2328         }
2329         case angle::FormatID::R8_USCALED:
2330         {
2331             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 1, false);
2332             return format;
2333         }
2334         case angle::FormatID::R8_UNORM:
2335         {
2336             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 1, false);
2337             return format;
2338         }
2339         case angle::FormatID::R8G8_USCALED:
2340         {
2341             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 2, false);
2342             return format;
2343         }
2344         case angle::FormatID::R8G8_UNORM:
2345         {
2346             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 2, false);
2347             return format;
2348         }
2349         case angle::FormatID::R8G8B8_USCALED:
2350         {
2351             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 3, false);
2352             return format;
2353         }
2354         case angle::FormatID::R8G8B8_UNORM:
2355         {
2356             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 3, false);
2357             return format;
2358         }
2359         case angle::FormatID::R8G8B8A8_USCALED:
2360         {
2361             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 4, false);
2362             return format;
2363         }
2364         case angle::FormatID::R8G8B8A8_UNORM:
2365         {
2366             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_TRUE, 4, false);
2367             return format;
2368         }
2369         case angle::FormatID::R16_SSCALED:
2370         {
2371             static const VertexFormat format(GL_SHORT, GL_FALSE, 1, false);
2372             return format;
2373         }
2374         case angle::FormatID::R16_SNORM:
2375         {
2376             static const VertexFormat format(GL_SHORT, GL_TRUE, 1, false);
2377             return format;
2378         }
2379         case angle::FormatID::R16G16_SSCALED:
2380         {
2381             static const VertexFormat format(GL_SHORT, GL_FALSE, 2, false);
2382             return format;
2383         }
2384         case angle::FormatID::R16G16_SNORM:
2385         {
2386             static const VertexFormat format(GL_SHORT, GL_TRUE, 2, false);
2387             return format;
2388         }
2389         case angle::FormatID::R16G16B16_SSCALED:
2390         {
2391             static const VertexFormat format(GL_SHORT, GL_FALSE, 3, false);
2392             return format;
2393         }
2394         case angle::FormatID::R16G16B16_SNORM:
2395         {
2396             static const VertexFormat format(GL_SHORT, GL_TRUE, 3, false);
2397             return format;
2398         }
2399         case angle::FormatID::R16G16B16A16_SSCALED:
2400         {
2401             static const VertexFormat format(GL_SHORT, GL_FALSE, 4, false);
2402             return format;
2403         }
2404         case angle::FormatID::R16G16B16A16_SNORM:
2405         {
2406             static const VertexFormat format(GL_SHORT, GL_TRUE, 4, false);
2407             return format;
2408         }
2409         case angle::FormatID::R16_USCALED:
2410         {
2411             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 1, false);
2412             return format;
2413         }
2414         case angle::FormatID::R16_UNORM:
2415         {
2416             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 1, false);
2417             return format;
2418         }
2419         case angle::FormatID::R16G16_USCALED:
2420         {
2421             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 2, false);
2422             return format;
2423         }
2424         case angle::FormatID::R16G16_UNORM:
2425         {
2426             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 2, false);
2427             return format;
2428         }
2429         case angle::FormatID::R16G16B16_USCALED:
2430         {
2431             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 3, false);
2432             return format;
2433         }
2434         case angle::FormatID::R16G16B16_UNORM:
2435         {
2436             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 3, false);
2437             return format;
2438         }
2439         case angle::FormatID::R16G16B16A16_USCALED:
2440         {
2441             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 4, false);
2442             return format;
2443         }
2444         case angle::FormatID::R16G16B16A16_UNORM:
2445         {
2446             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_TRUE, 4, false);
2447             return format;
2448         }
2449         case angle::FormatID::R32_SSCALED:
2450         {
2451             static const VertexFormat format(GL_INT, GL_FALSE, 1, false);
2452             return format;
2453         }
2454         case angle::FormatID::R32_SNORM:
2455         {
2456             static const VertexFormat format(GL_INT, GL_TRUE, 1, false);
2457             return format;
2458         }
2459         case angle::FormatID::R32G32_SSCALED:
2460         {
2461             static const VertexFormat format(GL_INT, GL_FALSE, 2, false);
2462             return format;
2463         }
2464         case angle::FormatID::R32G32_SNORM:
2465         {
2466             static const VertexFormat format(GL_INT, GL_TRUE, 2, false);
2467             return format;
2468         }
2469         case angle::FormatID::R32G32B32_SSCALED:
2470         {
2471             static const VertexFormat format(GL_INT, GL_FALSE, 3, false);
2472             return format;
2473         }
2474         case angle::FormatID::R32G32B32_SNORM:
2475         {
2476             static const VertexFormat format(GL_INT, GL_TRUE, 3, false);
2477             return format;
2478         }
2479         case angle::FormatID::R32G32B32A32_SSCALED:
2480         {
2481             static const VertexFormat format(GL_INT, GL_FALSE, 4, false);
2482             return format;
2483         }
2484         case angle::FormatID::R32G32B32A32_SNORM:
2485         {
2486             static const VertexFormat format(GL_INT, GL_TRUE, 4, false);
2487             return format;
2488         }
2489         case angle::FormatID::R32_USCALED:
2490         {
2491             static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 1, false);
2492             return format;
2493         }
2494         case angle::FormatID::R32_UNORM:
2495         {
2496             static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 1, false);
2497             return format;
2498         }
2499         case angle::FormatID::R32G32_USCALED:
2500         {
2501             static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 2, false);
2502             return format;
2503         }
2504         case angle::FormatID::R32G32_UNORM:
2505         {
2506             static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 2, false);
2507             return format;
2508         }
2509         case angle::FormatID::R32G32B32_USCALED:
2510         {
2511             static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 3, false);
2512             return format;
2513         }
2514         case angle::FormatID::R32G32B32_UNORM:
2515         {
2516             static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 3, false);
2517             return format;
2518         }
2519         case angle::FormatID::R32G32B32A32_USCALED:
2520         {
2521             static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 4, false);
2522             return format;
2523         }
2524         case angle::FormatID::R32G32B32A32_UNORM:
2525         {
2526             static const VertexFormat format(GL_UNSIGNED_INT, GL_TRUE, 4, false);
2527             return format;
2528         }
2529         case angle::FormatID::R8_SINT:
2530         {
2531             static const VertexFormat format(GL_BYTE, GL_FALSE, 1, true);
2532             return format;
2533         }
2534         case angle::FormatID::R8G8_SINT:
2535         {
2536             static const VertexFormat format(GL_BYTE, GL_FALSE, 2, true);
2537             return format;
2538         }
2539         case angle::FormatID::R8G8B8_SINT:
2540         {
2541             static const VertexFormat format(GL_BYTE, GL_FALSE, 3, true);
2542             return format;
2543         }
2544         case angle::FormatID::R8G8B8A8_SINT:
2545         {
2546             static const VertexFormat format(GL_BYTE, GL_FALSE, 4, true);
2547             return format;
2548         }
2549         case angle::FormatID::R8_UINT:
2550         {
2551             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 1, true);
2552             return format;
2553         }
2554         case angle::FormatID::R8G8_UINT:
2555         {
2556             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 2, true);
2557             return format;
2558         }
2559         case angle::FormatID::R8G8B8_UINT:
2560         {
2561             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 3, true);
2562             return format;
2563         }
2564         case angle::FormatID::R8G8B8A8_UINT:
2565         {
2566             static const VertexFormat format(GL_UNSIGNED_BYTE, GL_FALSE, 4, true);
2567             return format;
2568         }
2569         case angle::FormatID::R16_SINT:
2570         {
2571             static const VertexFormat format(GL_SHORT, GL_FALSE, 1, true);
2572             return format;
2573         }
2574         case angle::FormatID::R16G16_SINT:
2575         {
2576             static const VertexFormat format(GL_SHORT, GL_FALSE, 2, true);
2577             return format;
2578         }
2579         case angle::FormatID::R16G16B16_SINT:
2580         {
2581             static const VertexFormat format(GL_SHORT, GL_FALSE, 3, true);
2582             return format;
2583         }
2584         case angle::FormatID::R16G16B16A16_SINT:
2585         {
2586             static const VertexFormat format(GL_SHORT, GL_FALSE, 4, true);
2587             return format;
2588         }
2589         case angle::FormatID::R16_UINT:
2590         {
2591             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 1, true);
2592             return format;
2593         }
2594         case angle::FormatID::R16G16_UINT:
2595         {
2596             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 2, true);
2597             return format;
2598         }
2599         case angle::FormatID::R16G16B16_UINT:
2600         {
2601             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 3, true);
2602             return format;
2603         }
2604         case angle::FormatID::R16G16B16A16_UINT:
2605         {
2606             static const VertexFormat format(GL_UNSIGNED_SHORT, GL_FALSE, 4, true);
2607             return format;
2608         }
2609         case angle::FormatID::R32_SINT:
2610         {
2611             static const VertexFormat format(GL_INT, GL_FALSE, 1, true);
2612             return format;
2613         }
2614         case angle::FormatID::R32G32_SINT:
2615         {
2616             static const VertexFormat format(GL_INT, GL_FALSE, 2, true);
2617             return format;
2618         }
2619         case angle::FormatID::R32G32B32_SINT:
2620         {
2621             static const VertexFormat format(GL_INT, GL_FALSE, 3, true);
2622             return format;
2623         }
2624         case angle::FormatID::R32G32B32A32_SINT:
2625         {
2626             static const VertexFormat format(GL_INT, GL_FALSE, 4, true);
2627             return format;
2628         }
2629         case angle::FormatID::R32_UINT:
2630         {
2631             static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 1, true);
2632             return format;
2633         }
2634         case angle::FormatID::R32G32_UINT:
2635         {
2636             static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 2, true);
2637             return format;
2638         }
2639         case angle::FormatID::R32G32B32_UINT:
2640         {
2641             static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 3, true);
2642             return format;
2643         }
2644         case angle::FormatID::R32G32B32A32_UINT:
2645         {
2646             static const VertexFormat format(GL_UNSIGNED_INT, GL_FALSE, 4, true);
2647             return format;
2648         }
2649         case angle::FormatID::R32_FIXED:
2650         {
2651             static const VertexFormat format(GL_FIXED, GL_FALSE, 1, false);
2652             return format;
2653         }
2654         case angle::FormatID::R32G32_FIXED:
2655         {
2656             static const VertexFormat format(GL_FIXED, GL_FALSE, 2, false);
2657             return format;
2658         }
2659         case angle::FormatID::R32G32B32_FIXED:
2660         {
2661             static const VertexFormat format(GL_FIXED, GL_FALSE, 3, false);
2662             return format;
2663         }
2664         case angle::FormatID::R32G32B32A32_FIXED:
2665         {
2666             static const VertexFormat format(GL_FIXED, GL_FALSE, 4, false);
2667             return format;
2668         }
2669         case angle::FormatID::R16_FLOAT:
2670         {
2671             static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 1, false);
2672             return format;
2673         }
2674         case angle::FormatID::R16G16_FLOAT:
2675         {
2676             static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 2, false);
2677             return format;
2678         }
2679         case angle::FormatID::R16G16B16_FLOAT:
2680         {
2681             static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 3, false);
2682             return format;
2683         }
2684         case angle::FormatID::R16G16B16A16_FLOAT:
2685         {
2686             static const VertexFormat format(GL_HALF_FLOAT, GL_FALSE, 4, false);
2687             return format;
2688         }
2689         case angle::FormatID::R32_FLOAT:
2690         {
2691             static const VertexFormat format(GL_FLOAT, GL_FALSE, 1, false);
2692             return format;
2693         }
2694         case angle::FormatID::R32G32_FLOAT:
2695         {
2696             static const VertexFormat format(GL_FLOAT, GL_FALSE, 2, false);
2697             return format;
2698         }
2699         case angle::FormatID::R32G32B32_FLOAT:
2700         {
2701             static const VertexFormat format(GL_FLOAT, GL_FALSE, 3, false);
2702             return format;
2703         }
2704         case angle::FormatID::R32G32B32A32_FLOAT:
2705         {
2706             static const VertexFormat format(GL_FLOAT, GL_FALSE, 4, false);
2707             return format;
2708         }
2709         case angle::FormatID::R10G10B10A2_SSCALED:
2710         {
2711             static const VertexFormat format(GL_INT_2_10_10_10_REV, GL_FALSE, 4, false);
2712             return format;
2713         }
2714         case angle::FormatID::R10G10B10A2_USCALED:
2715         {
2716             static const VertexFormat format(GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE, 4, false);
2717             return format;
2718         }
2719         case angle::FormatID::R10G10B10A2_SNORM:
2720         {
2721             static const VertexFormat format(GL_INT_2_10_10_10_REV, GL_TRUE, 4, false);
2722             return format;
2723         }
2724         case angle::FormatID::R10G10B10A2_UNORM:
2725         {
2726             static const VertexFormat format(GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 4, false);
2727             return format;
2728         }
2729         case angle::FormatID::R10G10B10A2_SINT:
2730         {
2731             static const VertexFormat format(GL_INT_2_10_10_10_REV, GL_FALSE, 4, true);
2732             return format;
2733         }
2734         case angle::FormatID::R10G10B10A2_UINT:
2735         {
2736             static const VertexFormat format(GL_UNSIGNED_INT_2_10_10_10_REV, GL_FALSE, 4, true);
2737             return format;
2738         }
2739         case angle::FormatID::A2R10G10B10_SSCALED_VERTEX:
2740         {
2741             static const VertexFormat format(GL_INT_10_10_10_2_OES, GL_FALSE, 4, false);
2742             return format;
2743         }
2744         case angle::FormatID::A2R10G10B10_USCALED_VERTEX:
2745         {
2746             static const VertexFormat format(GL_UNSIGNED_INT_10_10_10_2_OES, GL_FALSE, 4, false);
2747             return format;
2748         }
2749         case angle::FormatID::A2R10G10B10_SNORM_VERTEX:
2750         {
2751             static const VertexFormat format(GL_INT_10_10_10_2_OES, GL_TRUE, 4, false);
2752             return format;
2753         }
2754         case angle::FormatID::A2R10G10B10_UNORM_VERTEX:
2755         {
2756             static const VertexFormat format(GL_UNSIGNED_INT_10_10_10_2_OES, GL_TRUE, 4, false);
2757             return format;
2758         }
2759         case angle::FormatID::A2R10G10B10_SINT_VERTEX:
2760         {
2761             static const VertexFormat format(GL_INT_10_10_10_2_OES, GL_FALSE, 4, true);
2762             return format;
2763         }
2764         case angle::FormatID::A2R10G10B10_UINT_VERTEX:
2765         {
2766             static const VertexFormat format(GL_UNSIGNED_INT_10_10_10_2_OES, GL_FALSE, 4, true);
2767             return format;
2768         }
2769         case angle::FormatID::X2R10G10B10_SSCALED_VERTEX:
2770         {
2771             static const VertexFormat format(GL_INT_10_10_10_2_OES, GL_FALSE, 4, false);
2772             return format;
2773         }
2774         case angle::FormatID::X2R10G10B10_USCALED_VERTEX:
2775         {
2776             static const VertexFormat format(GL_UNSIGNED_INT_10_10_10_2_OES, GL_FALSE, 4, false);
2777             return format;
2778         }
2779         case angle::FormatID::X2R10G10B10_SNORM_VERTEX:
2780         {
2781             static const VertexFormat format(GL_INT_10_10_10_2_OES, GL_TRUE, 4, false);
2782             return format;
2783         }
2784         case angle::FormatID::X2R10G10B10_UNORM_VERTEX:
2785         {
2786             static const VertexFormat format(GL_UNSIGNED_INT_10_10_10_2_OES, GL_TRUE, 4, false);
2787             return format;
2788         }
2789         case angle::FormatID::X2R10G10B10_SINT_VERTEX:
2790         {
2791             static const VertexFormat format(GL_INT_10_10_10_2_OES, GL_FALSE, 4, true);
2792             return format;
2793         }
2794         default:
2795         {
2796             static const VertexFormat format(GL_NONE, GL_FALSE, 0, false);
2797             return format;
2798         }
2799     }
2800 }
2801 
GetVertexFormatSize(angle::FormatID vertexFormatID)2802 size_t GetVertexFormatSize(angle::FormatID vertexFormatID)
2803 {
2804     switch (vertexFormatID)
2805     {
2806         case angle::FormatID::R8_SSCALED:
2807         case angle::FormatID::R8_SNORM:
2808         case angle::FormatID::R8_USCALED:
2809         case angle::FormatID::R8_UNORM:
2810         case angle::FormatID::R8_SINT:
2811         case angle::FormatID::R8_UINT:
2812             return 1;
2813 
2814         case angle::FormatID::R8G8_SSCALED:
2815         case angle::FormatID::R8G8_SNORM:
2816         case angle::FormatID::R8G8_USCALED:
2817         case angle::FormatID::R8G8_UNORM:
2818         case angle::FormatID::R8G8_SINT:
2819         case angle::FormatID::R8G8_UINT:
2820         case angle::FormatID::R16_SSCALED:
2821         case angle::FormatID::R16_SNORM:
2822         case angle::FormatID::R16_USCALED:
2823         case angle::FormatID::R16_UNORM:
2824         case angle::FormatID::R16_SINT:
2825         case angle::FormatID::R16_UINT:
2826         case angle::FormatID::R16_FLOAT:
2827             return 2;
2828 
2829         case angle::FormatID::R8G8B8_SSCALED:
2830         case angle::FormatID::R8G8B8_SNORM:
2831         case angle::FormatID::R8G8B8_USCALED:
2832         case angle::FormatID::R8G8B8_UNORM:
2833         case angle::FormatID::R8G8B8_SINT:
2834         case angle::FormatID::R8G8B8_UINT:
2835             return 3;
2836 
2837         case angle::FormatID::R8G8B8A8_SSCALED:
2838         case angle::FormatID::R8G8B8A8_SNORM:
2839         case angle::FormatID::R8G8B8A8_USCALED:
2840         case angle::FormatID::R8G8B8A8_UNORM:
2841         case angle::FormatID::R8G8B8A8_SINT:
2842         case angle::FormatID::R8G8B8A8_UINT:
2843         case angle::FormatID::R16G16_SSCALED:
2844         case angle::FormatID::R16G16_SNORM:
2845         case angle::FormatID::R16G16_USCALED:
2846         case angle::FormatID::R16G16_UNORM:
2847         case angle::FormatID::R16G16_SINT:
2848         case angle::FormatID::R16G16_UINT:
2849         case angle::FormatID::R32_SSCALED:
2850         case angle::FormatID::R32_SNORM:
2851         case angle::FormatID::R32_USCALED:
2852         case angle::FormatID::R32_UNORM:
2853         case angle::FormatID::R32_SINT:
2854         case angle::FormatID::R32_UINT:
2855         case angle::FormatID::R16G16_FLOAT:
2856         case angle::FormatID::R32_FIXED:
2857         case angle::FormatID::R32_FLOAT:
2858         case angle::FormatID::R10G10B10A2_SSCALED:
2859         case angle::FormatID::R10G10B10A2_USCALED:
2860         case angle::FormatID::R10G10B10A2_SNORM:
2861         case angle::FormatID::R10G10B10A2_UNORM:
2862         case angle::FormatID::R10G10B10A2_SINT:
2863         case angle::FormatID::R10G10B10A2_UINT:
2864         case angle::FormatID::A2R10G10B10_SSCALED_VERTEX:
2865         case angle::FormatID::A2R10G10B10_USCALED_VERTEX:
2866         case angle::FormatID::A2R10G10B10_SINT_VERTEX:
2867         case angle::FormatID::A2R10G10B10_UINT_VERTEX:
2868         case angle::FormatID::A2R10G10B10_SNORM_VERTEX:
2869         case angle::FormatID::A2R10G10B10_UNORM_VERTEX:
2870         case angle::FormatID::X2R10G10B10_SSCALED_VERTEX:
2871         case angle::FormatID::X2R10G10B10_USCALED_VERTEX:
2872         case angle::FormatID::X2R10G10B10_SINT_VERTEX:
2873         case angle::FormatID::X2R10G10B10_UINT_VERTEX:
2874         case angle::FormatID::X2R10G10B10_SNORM_VERTEX:
2875         case angle::FormatID::X2R10G10B10_UNORM_VERTEX:
2876             return 4;
2877 
2878         case angle::FormatID::R16G16B16_SSCALED:
2879         case angle::FormatID::R16G16B16_SNORM:
2880         case angle::FormatID::R16G16B16_USCALED:
2881         case angle::FormatID::R16G16B16_UNORM:
2882         case angle::FormatID::R16G16B16_SINT:
2883         case angle::FormatID::R16G16B16_UINT:
2884         case angle::FormatID::R16G16B16_FLOAT:
2885             return 6;
2886 
2887         case angle::FormatID::R16G16B16A16_SSCALED:
2888         case angle::FormatID::R16G16B16A16_SNORM:
2889         case angle::FormatID::R16G16B16A16_USCALED:
2890         case angle::FormatID::R16G16B16A16_UNORM:
2891         case angle::FormatID::R16G16B16A16_SINT:
2892         case angle::FormatID::R16G16B16A16_UINT:
2893         case angle::FormatID::R32G32_SSCALED:
2894         case angle::FormatID::R32G32_SNORM:
2895         case angle::FormatID::R32G32_USCALED:
2896         case angle::FormatID::R32G32_UNORM:
2897         case angle::FormatID::R32G32_SINT:
2898         case angle::FormatID::R32G32_UINT:
2899         case angle::FormatID::R16G16B16A16_FLOAT:
2900         case angle::FormatID::R32G32_FIXED:
2901         case angle::FormatID::R32G32_FLOAT:
2902             return 8;
2903 
2904         case angle::FormatID::R32G32B32_SSCALED:
2905         case angle::FormatID::R32G32B32_SNORM:
2906         case angle::FormatID::R32G32B32_USCALED:
2907         case angle::FormatID::R32G32B32_UNORM:
2908         case angle::FormatID::R32G32B32_SINT:
2909         case angle::FormatID::R32G32B32_UINT:
2910         case angle::FormatID::R32G32B32_FIXED:
2911         case angle::FormatID::R32G32B32_FLOAT:
2912             return 12;
2913 
2914         case angle::FormatID::R32G32B32A32_SSCALED:
2915         case angle::FormatID::R32G32B32A32_SNORM:
2916         case angle::FormatID::R32G32B32A32_USCALED:
2917         case angle::FormatID::R32G32B32A32_UNORM:
2918         case angle::FormatID::R32G32B32A32_SINT:
2919         case angle::FormatID::R32G32B32A32_UINT:
2920         case angle::FormatID::R32G32B32A32_FIXED:
2921         case angle::FormatID::R32G32B32A32_FLOAT:
2922             return 16;
2923 
2924         case angle::FormatID::NONE:
2925         default:
2926             UNREACHABLE();
2927 #if !UNREACHABLE_IS_NORETURN
2928             return 0;
2929 #endif
2930     }
2931 }
2932 
ConvertFormatSignedness(const angle::Format & format)2933 angle::FormatID ConvertFormatSignedness(const angle::Format &format)
2934 {
2935     switch (format.id)
2936     {
2937         // 1 byte signed to unsigned
2938         case angle::FormatID::R8_SINT:
2939             return angle::FormatID::R8_UINT;
2940         case angle::FormatID::R8_SNORM:
2941             return angle::FormatID::R8_UNORM;
2942         case angle::FormatID::R8_SSCALED:
2943             return angle::FormatID::R8_USCALED;
2944         case angle::FormatID::R8G8_SINT:
2945             return angle::FormatID::R8G8_UINT;
2946         case angle::FormatID::R8G8_SNORM:
2947             return angle::FormatID::R8G8_UNORM;
2948         case angle::FormatID::R8G8_SSCALED:
2949             return angle::FormatID::R8G8_USCALED;
2950         case angle::FormatID::R8G8B8_SINT:
2951             return angle::FormatID::R8G8B8_UINT;
2952         case angle::FormatID::R8G8B8_SNORM:
2953             return angle::FormatID::R8G8B8_UNORM;
2954         case angle::FormatID::R8G8B8_SSCALED:
2955             return angle::FormatID::R8G8B8_USCALED;
2956         case angle::FormatID::R8G8B8A8_SINT:
2957             return angle::FormatID::R8G8B8A8_UINT;
2958         case angle::FormatID::R8G8B8A8_SNORM:
2959             return angle::FormatID::R8G8B8A8_UNORM;
2960         case angle::FormatID::R8G8B8A8_SSCALED:
2961             return angle::FormatID::R8G8B8A8_USCALED;
2962         // 1 byte unsigned to signed
2963         case angle::FormatID::R8_UINT:
2964             return angle::FormatID::R8_SINT;
2965         case angle::FormatID::R8_UNORM:
2966             return angle::FormatID::R8_SNORM;
2967         case angle::FormatID::R8_USCALED:
2968             return angle::FormatID::R8_SSCALED;
2969         case angle::FormatID::R8G8_UINT:
2970             return angle::FormatID::R8G8_SINT;
2971         case angle::FormatID::R8G8_UNORM:
2972             return angle::FormatID::R8G8_SNORM;
2973         case angle::FormatID::R8G8_USCALED:
2974             return angle::FormatID::R8G8_SSCALED;
2975         case angle::FormatID::R8G8B8_UINT:
2976             return angle::FormatID::R8G8B8_SINT;
2977         case angle::FormatID::R8G8B8_UNORM:
2978             return angle::FormatID::R8G8B8_SNORM;
2979         case angle::FormatID::R8G8B8_USCALED:
2980             return angle::FormatID::R8G8B8_SSCALED;
2981         case angle::FormatID::R8G8B8A8_UINT:
2982             return angle::FormatID::R8G8B8A8_SINT;
2983         case angle::FormatID::R8G8B8A8_UNORM:
2984             return angle::FormatID::R8G8B8A8_SNORM;
2985         case angle::FormatID::R8G8B8A8_USCALED:
2986             return angle::FormatID::R8G8B8A8_SSCALED;
2987         // 2 byte signed to unsigned
2988         case angle::FormatID::R16_SINT:
2989             return angle::FormatID::R16_UINT;
2990         case angle::FormatID::R16_SNORM:
2991             return angle::FormatID::R16_UNORM;
2992         case angle::FormatID::R16_SSCALED:
2993             return angle::FormatID::R16_USCALED;
2994         case angle::FormatID::R16G16_SINT:
2995             return angle::FormatID::R16G16_UINT;
2996         case angle::FormatID::R16G16_SNORM:
2997             return angle::FormatID::R16G16_UNORM;
2998         case angle::FormatID::R16G16_SSCALED:
2999             return angle::FormatID::R16G16_USCALED;
3000         case angle::FormatID::R16G16B16_SINT:
3001             return angle::FormatID::R16G16B16_UINT;
3002         case angle::FormatID::R16G16B16_SNORM:
3003             return angle::FormatID::R16G16B16_UNORM;
3004         case angle::FormatID::R16G16B16_SSCALED:
3005             return angle::FormatID::R16G16B16_USCALED;
3006         case angle::FormatID::R16G16B16A16_SINT:
3007             return angle::FormatID::R16G16B16A16_UINT;
3008         case angle::FormatID::R16G16B16A16_SNORM:
3009             return angle::FormatID::R16G16B16A16_UNORM;
3010         case angle::FormatID::R16G16B16A16_SSCALED:
3011             return angle::FormatID::R16G16B16A16_USCALED;
3012         // 2 byte unsigned to signed
3013         case angle::FormatID::R16_UINT:
3014             return angle::FormatID::R16_SINT;
3015         case angle::FormatID::R16_UNORM:
3016             return angle::FormatID::R16_SNORM;
3017         case angle::FormatID::R16_USCALED:
3018             return angle::FormatID::R16_SSCALED;
3019         case angle::FormatID::R16G16_UINT:
3020             return angle::FormatID::R16G16_SINT;
3021         case angle::FormatID::R16G16_UNORM:
3022             return angle::FormatID::R16G16_SNORM;
3023         case angle::FormatID::R16G16_USCALED:
3024             return angle::FormatID::R16G16_SSCALED;
3025         case angle::FormatID::R16G16B16_UINT:
3026             return angle::FormatID::R16G16B16_SINT;
3027         case angle::FormatID::R16G16B16_UNORM:
3028             return angle::FormatID::R16G16B16_SNORM;
3029         case angle::FormatID::R16G16B16_USCALED:
3030             return angle::FormatID::R16G16B16_SSCALED;
3031         case angle::FormatID::R16G16B16A16_UINT:
3032             return angle::FormatID::R16G16B16A16_SINT;
3033         case angle::FormatID::R16G16B16A16_UNORM:
3034             return angle::FormatID::R16G16B16A16_SNORM;
3035         case angle::FormatID::R16G16B16A16_USCALED:
3036             return angle::FormatID::R16G16B16A16_SSCALED;
3037         // 4 byte signed to unsigned
3038         case angle::FormatID::R32_SINT:
3039             return angle::FormatID::R32_UINT;
3040         case angle::FormatID::R32_SNORM:
3041             return angle::FormatID::R32_UNORM;
3042         case angle::FormatID::R32_SSCALED:
3043             return angle::FormatID::R32_USCALED;
3044         case angle::FormatID::R32G32_SINT:
3045             return angle::FormatID::R32G32_UINT;
3046         case angle::FormatID::R32G32_SNORM:
3047             return angle::FormatID::R32G32_UNORM;
3048         case angle::FormatID::R32G32_SSCALED:
3049             return angle::FormatID::R32G32_USCALED;
3050         case angle::FormatID::R32G32B32_SINT:
3051             return angle::FormatID::R32G32B32_UINT;
3052         case angle::FormatID::R32G32B32_SNORM:
3053             return angle::FormatID::R32G32B32_UNORM;
3054         case angle::FormatID::R32G32B32_SSCALED:
3055             return angle::FormatID::R32G32B32_USCALED;
3056         case angle::FormatID::R32G32B32A32_SINT:
3057             return angle::FormatID::R32G32B32A32_UINT;
3058         case angle::FormatID::R32G32B32A32_SNORM:
3059             return angle::FormatID::R32G32B32A32_UNORM;
3060         case angle::FormatID::R32G32B32A32_SSCALED:
3061             return angle::FormatID::R32G32B32A32_USCALED;
3062         // 4 byte unsigned to signed
3063         case angle::FormatID::R32_UINT:
3064             return angle::FormatID::R32_SINT;
3065         case angle::FormatID::R32_UNORM:
3066             return angle::FormatID::R32_SNORM;
3067         case angle::FormatID::R32_USCALED:
3068             return angle::FormatID::R32_SSCALED;
3069         case angle::FormatID::R32G32_UINT:
3070             return angle::FormatID::R32G32_SINT;
3071         case angle::FormatID::R32G32_UNORM:
3072             return angle::FormatID::R32G32_SNORM;
3073         case angle::FormatID::R32G32_USCALED:
3074             return angle::FormatID::R32G32_SSCALED;
3075         case angle::FormatID::R32G32B32_UINT:
3076             return angle::FormatID::R32G32B32_SINT;
3077         case angle::FormatID::R32G32B32_UNORM:
3078             return angle::FormatID::R32G32B32_SNORM;
3079         case angle::FormatID::R32G32B32_USCALED:
3080             return angle::FormatID::R32G32B32_SSCALED;
3081         case angle::FormatID::R32G32B32A32_UINT:
3082             return angle::FormatID::R32G32B32A32_SINT;
3083         case angle::FormatID::R32G32B32A32_UNORM:
3084             return angle::FormatID::R32G32B32A32_SNORM;
3085         case angle::FormatID::R32G32B32A32_USCALED:
3086             return angle::FormatID::R32G32B32A32_SSCALED;
3087         // 1010102 signed to unsigned
3088         case angle::FormatID::R10G10B10A2_SINT:
3089             return angle::FormatID::R10G10B10A2_UINT;
3090         case angle::FormatID::R10G10B10A2_SSCALED:
3091             return angle::FormatID::R10G10B10A2_USCALED;
3092         case angle::FormatID::R10G10B10A2_SNORM:
3093             return angle::FormatID::R10G10B10A2_UNORM;
3094         // 1010102 unsigned to signed
3095         case angle::FormatID::R10G10B10A2_UINT:
3096             return angle::FormatID::R10G10B10A2_SINT;
3097         case angle::FormatID::R10G10B10A2_USCALED:
3098             return angle::FormatID::R10G10B10A2_SSCALED;
3099         case angle::FormatID::R10G10B10A2_UNORM:
3100             return angle::FormatID::R10G10B10A2_SNORM;
3101         default:
3102             UNREACHABLE();
3103     }
3104 #if !UNREACHABLE_IS_NORETURN
3105     return angle::FormatID::NONE;
3106 #endif
3107 }
3108 
ValidES3InternalFormat(GLenum internalFormat)3109 bool ValidES3InternalFormat(GLenum internalFormat)
3110 {
3111     const InternalFormatInfoMap &formatMap = GetInternalFormatMap();
3112     return internalFormat != GL_NONE && formatMap.find(internalFormat) != formatMap.end();
3113 }
3114 
VertexFormat(GLenum typeIn,GLboolean normalizedIn,GLuint componentsIn,bool pureIntegerIn)3115 VertexFormat::VertexFormat(GLenum typeIn,
3116                            GLboolean normalizedIn,
3117                            GLuint componentsIn,
3118                            bool pureIntegerIn)
3119     : type(typeIn), normalized(normalizedIn), components(componentsIn), pureInteger(pureIntegerIn)
3120 {
3121     // float -> !normalized
3122     ASSERT(!(type == GL_FLOAT || type == GL_HALF_FLOAT || type == GL_FIXED) ||
3123            normalized == GL_FALSE);
3124 }
3125 }  // namespace gl
3126