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