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