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