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