| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 #include "GrGLCaps.h" | 9 #include "GrGLCaps.h" |
| 10 | 10 |
| 11 #include "GrContextOptions.h" | 11 #include "GrContextOptions.h" |
| 12 #include "GrGLContext.h" | 12 #include "GrGLContext.h" |
| 13 #include "glsl/GrGLSLCaps.h" | 13 #include "glsl/GrGLSLCaps.h" |
| 14 #include "SkTSearch.h" | 14 #include "SkTSearch.h" |
| 15 #include "SkTSort.h" | 15 #include "SkTSort.h" |
| 16 | 16 |
| 17 GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, | 17 GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, |
| 18 const GrGLContextInfo& ctxInfo, | 18 const GrGLContextInfo& ctxInfo, |
| 19 const GrGLInterface* glInterface) : INHERITED(contextOptions)
{ | 19 const GrGLInterface* glInterface) : INHERITED(contextOptions)
{ |
| 20 fStencilFormats.reset(); | 20 fStencilFormats.reset(); |
| 21 fMSFBOType = kNone_MSFBOType; | 21 fMSFBOType = kNone_MSFBOType; |
| 22 fInvalidateFBType = kNone_InvalidateFBType; | 22 fInvalidateFBType = kNone_InvalidateFBType; |
| 23 fLATCAlias = kLATC_LATCAlias; | |
| 24 fMapBufferType = kNone_MapBufferType; | 23 fMapBufferType = kNone_MapBufferType; |
| 25 fTransferBufferType = kNone_TransferBufferType; | 24 fTransferBufferType = kNone_TransferBufferType; |
| 26 fMaxFragmentUniformVectors = 0; | 25 fMaxFragmentUniformVectors = 0; |
| 27 fMaxVertexAttributes = 0; | 26 fMaxVertexAttributes = 0; |
| 28 fMaxFragmentTextureUnits = 0; | 27 fMaxFragmentTextureUnits = 0; |
| 29 fRGBA8RenderbufferSupport = false; | |
| 30 fBGRAIsInternalFormat = false; | |
| 31 fUnpackRowLengthSupport = false; | 28 fUnpackRowLengthSupport = false; |
| 32 fUnpackFlipYSupport = false; | 29 fUnpackFlipYSupport = false; |
| 33 fPackRowLengthSupport = false; | 30 fPackRowLengthSupport = false; |
| 34 fPackFlipYSupport = false; | 31 fPackFlipYSupport = false; |
| 35 fTextureUsageSupport = false; | 32 fTextureUsageSupport = false; |
| 36 fTexStorageSupport = false; | 33 fTexStorageSupport = false; |
| 37 fTextureRedSupport = false; | 34 fTextureRedSupport = false; |
| 38 fImagingSupport = false; | 35 fImagingSupport = false; |
| 39 fVertexArrayObjectSupport = false; | 36 fVertexArrayObjectSupport = false; |
| 40 fDirectStateAccessSupport = false; | 37 fDirectStateAccessSupport = false; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 if (version >= GR_GL_VER(3, 2)) { | 72 if (version >= GR_GL_VER(3, 2)) { |
| 76 GrGLint profileMask; | 73 GrGLint profileMask; |
| 77 GR_GL_GetIntegerv(gli, GR_GL_CONTEXT_PROFILE_MASK, &profileMask); | 74 GR_GL_GetIntegerv(gli, GR_GL_CONTEXT_PROFILE_MASK, &profileMask); |
| 78 fIsCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_B
IT); | 75 fIsCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_B
IT); |
| 79 } | 76 } |
| 80 } | 77 } |
| 81 GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes); | 78 GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes); |
| 82 GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &fMaxFragmentTextureUn
its); | 79 GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &fMaxFragmentTextureUn
its); |
| 83 | 80 |
| 84 if (kGL_GrGLStandard == standard) { | 81 if (kGL_GrGLStandard == standard) { |
| 85 fRGBA8RenderbufferSupport = true; | |
| 86 } else { | |
| 87 fRGBA8RenderbufferSupport = version >= GR_GL_VER(3,0) || | |
| 88 ctxInfo.hasExtension("GL_OES_rgb8_rgba8") || | |
| 89 ctxInfo.hasExtension("GL_ARM_rgba8"); | |
| 90 } | |
| 91 | |
| 92 if (kGL_GrGLStandard == standard) { | |
| 93 fUnpackRowLengthSupport = true; | 82 fUnpackRowLengthSupport = true; |
| 94 fUnpackFlipYSupport = false; | 83 fUnpackFlipYSupport = false; |
| 95 fPackRowLengthSupport = true; | 84 fPackRowLengthSupport = true; |
| 96 fPackFlipYSupport = false; | 85 fPackFlipYSupport = false; |
| 97 } else { | 86 } else { |
| 98 fUnpackRowLengthSupport = version >= GR_GL_VER(3,0) || | 87 fUnpackRowLengthSupport = version >= GR_GL_VER(3,0) || |
| 99 ctxInfo.hasExtension("GL_EXT_unpack_subimage")
; | 88 ctxInfo.hasExtension("GL_EXT_unpack_subimage")
; |
| 100 fUnpackFlipYSupport = ctxInfo.hasExtension("GL_CHROMIUM_flipy"); | 89 fUnpackFlipYSupport = ctxInfo.hasExtension("GL_CHROMIUM_flipy"); |
| 101 fPackRowLengthSupport = version >= GR_GL_VER(3,0) || | 90 fPackRowLengthSupport = version >= GR_GL_VER(3,0) || |
| 102 ctxInfo.hasExtension("GL_NV_pack_subimage"); | 91 ctxInfo.hasExtension("GL_NV_pack_subimage"); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 fTextureRedSupport = version >= GR_GL_VER(3,0) || | 123 fTextureRedSupport = version >= GR_GL_VER(3,0) || |
| 135 ctxInfo.hasExtension("GL_ARB_texture_rg"); | 124 ctxInfo.hasExtension("GL_ARB_texture_rg"); |
| 136 } else { | 125 } else { |
| 137 fTextureRedSupport = version >= GR_GL_VER(3,0) || | 126 fTextureRedSupport = version >= GR_GL_VER(3,0) || |
| 138 ctxInfo.hasExtension("GL_EXT_texture_rg"); | 127 ctxInfo.hasExtension("GL_EXT_texture_rg"); |
| 139 } | 128 } |
| 140 } | 129 } |
| 141 fImagingSupport = kGL_GrGLStandard == standard && | 130 fImagingSupport = kGL_GrGLStandard == standard && |
| 142 ctxInfo.hasExtension("GL_ARB_imaging"); | 131 ctxInfo.hasExtension("GL_ARB_imaging"); |
| 143 | 132 |
| 144 // We only enable srgb support if both textures and FBOs support srgb. | |
| 145 bool srgbSupport = false; | |
| 146 if (kGL_GrGLStandard == standard) { | |
| 147 if (ctxInfo.version() >= GR_GL_VER(3,0)) { | |
| 148 srgbSupport = true; | |
| 149 } else if (ctxInfo.hasExtension("GL_EXT_texture_sRGB")) { | |
| 150 if (ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") || | |
| 151 ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) { | |
| 152 srgbSupport = true; | |
| 153 } | |
| 154 } | |
| 155 // All the above srgb extensions support toggling srgb writes | |
| 156 fSRGBWriteControl = srgbSupport; | |
| 157 } else { | |
| 158 // See https://bug.skia.org/4148 for PowerVR issue. | |
| 159 srgbSupport = kPowerVRRogue_GrGLRenderer != ctxInfo.renderer() && | |
| 160 (ctxInfo.version() >= GR_GL_VER(3,0) || ctxInfo.hasExtensi
on("GL_EXT_sRGB")); | |
| 161 // ES through 3.1 requires EXT_srgb_write_control to support toggling | |
| 162 // sRGB writing for destinations. | |
| 163 fSRGBWriteControl = ctxInfo.hasExtension("GL_EXT_sRGB_write_control"); | |
| 164 } | |
| 165 | |
| 166 // SGX and Mali GPUs that are based on a tiled-deferred architecture that ha
ve trouble with | 133 // SGX and Mali GPUs that are based on a tiled-deferred architecture that ha
ve trouble with |
| 167 // frequently changing VBOs. We've measured a performance increase using non
-VBO vertex | 134 // frequently changing VBOs. We've measured a performance increase using non
-VBO vertex |
| 168 // data for dynamic content on these GPUs. Perhaps we should read the render
er string and | 135 // data for dynamic content on these GPUs. Perhaps we should read the render
er string and |
| 169 // limit this decision to specific GPU families rather than basing it on the
vendor alone. | 136 // limit this decision to specific GPU families rather than basing it on the
vendor alone. |
| 170 if (!GR_GL_MUST_USE_VBO && | 137 if (!GR_GL_MUST_USE_VBO && |
| 171 (kARM_GrGLVendor == ctxInfo.vendor() || | 138 (kARM_GrGLVendor == ctxInfo.vendor() || |
| 172 kImagination_GrGLVendor == ctxInfo.vendor() || | 139 kImagination_GrGLVendor == ctxInfo.vendor() || |
| 173 kQualcomm_GrGLVendor == ctxInfo.vendor())) { | 140 kQualcomm_GrGLVendor == ctxInfo.vendor())) { |
| 174 fUseNonVBOVertexAndIndexDynamicData = true; | 141 fUseNonVBOVertexAndIndexDynamicData = true; |
| 175 } | 142 } |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 version >= GR_GL_VER(3, 2) || | 429 version >= GR_GL_VER(3, 2) || |
| 463 (ctxInfo.hasExtension("GL_ARB_draw_instanced") && | 430 (ctxInfo.hasExtension("GL_ARB_draw_instanced") && |
| 464 ctxInfo.hasExtension("GL_ARB_instanced_arrays")); | 431 ctxInfo.hasExtension("GL_ARB_instanced_arrays")); |
| 465 } else { | 432 } else { |
| 466 fSupportsInstancedDraws = | 433 fSupportsInstancedDraws = |
| 467 version >= GR_GL_VER(3, 0) || | 434 version >= GR_GL_VER(3, 0) || |
| 468 (ctxInfo.hasExtension("GL_EXT_draw_instanced") && | 435 (ctxInfo.hasExtension("GL_EXT_draw_instanced") && |
| 469 ctxInfo.hasExtension("GL_EXT_instanced_arrays")); | 436 ctxInfo.hasExtension("GL_EXT_instanced_arrays")); |
| 470 } | 437 } |
| 471 | 438 |
| 472 this->initConfigTexturableTable(ctxInfo, gli, srgbSupport); | |
| 473 this->initConfigRenderableTable(ctxInfo, srgbSupport); | |
| 474 this->initShaderPrecisionTable(ctxInfo, gli, glslCaps); | 439 this->initShaderPrecisionTable(ctxInfo, gli, glslCaps); |
| 475 // Requires fTexutreSwizzleSupport and fTextureRedSupport to be set before t
his point. | 440 // Requires fTexutreSwizzleSupport and fTextureRedSupport to be set before t
his point. |
| 476 this->initConfigSwizzleTable(ctxInfo, glslCaps); | 441 this->initConfigSwizzleTable(ctxInfo, glslCaps); |
| 477 // Requires various members are already correctly initialized (e.g. fTexture
RedSupport). | 442 // Requires various members are already correctly initialized (e.g. fTexture
RedSupport, |
| 478 this->initConfigTable(ctxInfo); | 443 // msaa support). |
| 444 this->initConfigTable(ctxInfo, gli); |
| 479 | 445 |
| 480 this->applyOptionsOverrides(contextOptions); | 446 this->applyOptionsOverrides(contextOptions); |
| 481 glslCaps->applyOptionsOverrides(contextOptions); | 447 glslCaps->applyOptionsOverrides(contextOptions); |
| 482 } | 448 } |
| 483 | 449 |
| 484 const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration
generation, | 450 const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration
generation, |
| 485 bool isCoreProfile) { | 451 bool isCoreProfile) { |
| 486 switch (generation) { | 452 switch (generation) { |
| 487 case k110_GrGLSLGeneration: | 453 case k110_GrGLSLGeneration: |
| 488 if (kGLES_GrGLStandard == standard) { | 454 if (kGLES_GrGLStandard == standard) { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 // them for consistency. | 604 // them for consistency. |
| 639 if (nullptr == gli->fFunctions.fStencilThenCoverFillPath || | 605 if (nullptr == gli->fFunctions.fStencilThenCoverFillPath || |
| 640 nullptr == gli->fFunctions.fStencilThenCoverStrokePath || | 606 nullptr == gli->fFunctions.fStencilThenCoverStrokePath || |
| 641 nullptr == gli->fFunctions.fStencilThenCoverFillPathInstanced || | 607 nullptr == gli->fFunctions.fStencilThenCoverFillPathInstanced || |
| 642 nullptr == gli->fFunctions.fStencilThenCoverStrokePathInstanced || | 608 nullptr == gli->fFunctions.fStencilThenCoverStrokePathInstanced || |
| 643 nullptr == gli->fFunctions.fProgramPathFragmentInputGen) { | 609 nullptr == gli->fFunctions.fProgramPathFragmentInputGen) { |
| 644 return false; | 610 return false; |
| 645 } | 611 } |
| 646 return true; | 612 return true; |
| 647 } | 613 } |
| 648 | |
| 649 void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo, bool sr
gbSupport) { | |
| 650 // OpenGL < 3.0 | |
| 651 // no support for render targets unless the GL_ARB_framebuffer_object | |
| 652 // extension is supported (in which case we get ALPHA, RED, RG, RGB, | |
| 653 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we | |
| 654 // probably don't get R8 in this case. | |
| 655 | |
| 656 // OpenGL 3.0 | |
| 657 // base color renderable: ALPHA, RED, RG, RGB, and RGBA | |
| 658 // sized derivatives: ALPHA8, R8, RGBA4, RGBA8 | |
| 659 | |
| 660 // >= OpenGL 3.1 | |
| 661 // base color renderable: RED, RG, RGB, and RGBA | |
| 662 // sized derivatives: R8, RGBA4, RGBA8 | |
| 663 // if the GL_ARB_compatibility extension is supported then we get back | |
| 664 // support for GL_ALPHA and ALPHA8 | |
| 665 | |
| 666 // GL_EXT_bgra adds BGRA render targets to any version | |
| 667 | |
| 668 // ES 2.0 | |
| 669 // color renderable: RGBA4, RGB5_A1, RGB565 | |
| 670 // GL_EXT_texture_rg adds support for R8 as a color render target | |
| 671 // GL_OES_rgb8_rgba8 and/or GL_ARM_rgba8 adds support for RGBA8 | |
| 672 // GL_EXT_texture_format_BGRA8888 and/or GL_APPLE_texture_format_BGRA8888 a
dded BGRA support | |
| 673 | |
| 674 // ES 3.0 | |
| 675 // Same as ES 2.0 except R8 and RGBA8 are supported without extensions (the
functions called | |
| 676 // below already account for this). | |
| 677 | |
| 678 GrGLStandard standard = ctxInfo.standard(); | |
| 679 | |
| 680 enum { | |
| 681 kNo_MSAA = 0, | |
| 682 kYes_MSAA = 1, | |
| 683 }; | |
| 684 | |
| 685 if (kGL_GrGLStandard == standard) { | |
| 686 // Post 3.0 we will get R8 | |
| 687 // Prior to 3.0 we will get ALPHA8 (with GL_ARB_framebuffer_object) | |
| 688 if (ctxInfo.version() >= GR_GL_VER(3,0) || | |
| 689 ctxInfo.hasExtension("GL_ARB_framebuffer_object")) { | |
| 690 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = true; | |
| 691 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = true; | |
| 692 } | |
| 693 } else { | |
| 694 // On ES we can only hope for R8 | |
| 695 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kNo_MSAA] = fTextureRedSupp
ort; | |
| 696 fConfigRenderSupport[kAlpha_8_GrPixelConfig][kYes_MSAA] = fTextureRedSup
port; | |
| 697 } | |
| 698 | |
| 699 if (kGL_GrGLStandard != standard) { | |
| 700 // only available in ES | |
| 701 fConfigRenderSupport[kRGB_565_GrPixelConfig][kNo_MSAA] = true; | |
| 702 fConfigRenderSupport[kRGB_565_GrPixelConfig][kYes_MSAA] = true; | |
| 703 } | |
| 704 | |
| 705 // we no longer support 444 as a render target | |
| 706 fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kNo_MSAA] = false; | |
| 707 fConfigRenderSupport[kRGBA_4444_GrPixelConfig][kYes_MSAA] = false; | |
| 708 | |
| 709 if (this->fRGBA8RenderbufferSupport) { | |
| 710 fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kNo_MSAA] = true; | |
| 711 fConfigRenderSupport[kRGBA_8888_GrPixelConfig][kYes_MSAA] = true; | |
| 712 } | |
| 713 | |
| 714 if (this->isConfigTexturable(kBGRA_8888_GrPixelConfig)) { | |
| 715 // On iOS, BGRA is not supported as a renderable target on ES 3.0+ | |
| 716 if (!ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888") || | |
| 717 ctxInfo.version() < GR_GL_VER(3,0)) { | |
| 718 fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kNo_MSAA] = true; | |
| 719 // The GL_EXT_texture_format_BGRA8888 extension does not add BGRA to
the list of | |
| 720 // configs that are color-renderable and can be passed to | |
| 721 // glRenderBufferStorageMultisample. Chromium may have an extension
to allow BGRA | |
| 722 // renderbuffers to work on desktop platforms. | |
| 723 if (ctxInfo.hasExtension("GL_CHROMIUM_renderbuffer_format_BGRA8888")
) { | |
| 724 fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] = true
; | |
| 725 } else { | |
| 726 fConfigRenderSupport[kBGRA_8888_GrPixelConfig][kYes_MSAA] = | |
| 727 !fBGRAIsInternalFormat || !this->usesMSAARenderBuffers(); | |
| 728 } | |
| 729 } | |
| 730 } | |
| 731 | |
| 732 if (this->fRGBA8RenderbufferSupport && srgbSupport) { | |
| 733 fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kNo_MSAA] = true; | |
| 734 fConfigRenderSupport[kSRGBA_8888_GrPixelConfig][kYes_MSAA] = true; | |
| 735 } | |
| 736 | |
| 737 if (this->isConfigTexturable(kRGBA_float_GrPixelConfig)) { | |
| 738 if (kGL_GrGLStandard == standard) { | |
| 739 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true; | |
| 740 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kYes_MSAA] = true; | |
| 741 } else { | |
| 742 // for now we only enable this on desktop, because on ES we'd have t
o solve many | |
| 743 // precision issues and no clients actually want this yet | |
| 744 /* | |
| 745 if (ctxInfo.hasExtension("GL_EXT_color_buffer_float")) { | |
| 746 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true
; | |
| 747 } else { | |
| 748 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = fals
e; | |
| 749 } | |
| 750 // for now we don't support floating point MSAA on ES | |
| 751 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kYes_MSAA] = false;*
/ | |
| 752 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = false; | |
| 753 fConfigRenderSupport[kRGBA_float_GrPixelConfig][kYes_MSAA] = false; | |
| 754 } | |
| 755 } | |
| 756 | |
| 757 if (this->isConfigTexturable(kAlpha_half_GrPixelConfig)) { | |
| 758 if (kGL_GrGLStandard == standard) { | |
| 759 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true; | |
| 760 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = true; | |
| 761 } else if (ctxInfo.version() >= GR_GL_VER(3,0)) { | |
| 762 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true; | |
| 763 // for now we don't support floating point MSAA on ES | |
| 764 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false; | |
| 765 } else { | |
| 766 if (ctxInfo.hasExtension("GL_EXT_color_buffer_half_float") && fTextu
reRedSupport) { | |
| 767 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true
; | |
| 768 } else { | |
| 769 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = fals
e; | |
| 770 } | |
| 771 // for now we don't support floating point MSAA on ES | |
| 772 fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false; | |
| 773 } | |
| 774 } | |
| 775 | |
| 776 if (this->isConfigTexturable(kRGBA_half_GrPixelConfig)) { | |
| 777 if (kGL_GrGLStandard == standard) { | |
| 778 fConfigRenderSupport[kRGBA_half_GrPixelConfig][kNo_MSAA] = true; | |
| 779 fConfigRenderSupport[kRGBA_half_GrPixelConfig][kYes_MSAA] = true; | |
| 780 } else if (ctxInfo.version() >= GR_GL_VER(3, 0)) { | |
| 781 fConfigRenderSupport[kRGBA_half_GrPixelConfig][kNo_MSAA] = true; | |
| 782 // for now we don't support floating point MSAA on ES | |
| 783 fConfigRenderSupport[kRGBA_half_GrPixelConfig][kYes_MSAA] = false; | |
| 784 } else { | |
| 785 if (ctxInfo.hasExtension("GL_EXT_color_buffer_half_float")) { | |
| 786 fConfigRenderSupport[kRGBA_half_GrPixelConfig][kNo_MSAA] = true; | |
| 787 } else { | |
| 788 fConfigRenderSupport[kRGBA_half_GrPixelConfig][kNo_MSAA] = false
; | |
| 789 } | |
| 790 // for now we don't support floating point MSAA on ES | |
| 791 fConfigRenderSupport[kRGBA_half_GrPixelConfig][kYes_MSAA] = false; | |
| 792 } | |
| 793 } | |
| 794 | |
| 795 // If we don't support MSAA then undo any places above where we set a config
as renderable with | |
| 796 // msaa. | |
| 797 if (kNone_MSFBOType == fMSFBOType) { | |
| 798 for (int i = 0; i < kGrPixelConfigCnt; ++i) { | |
| 799 fConfigRenderSupport[i][kYes_MSAA] = false; | |
| 800 } | |
| 801 } | |
| 802 } | |
| 803 | |
| 804 void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const G
rGLInterface* gli, | |
| 805 bool srgbSupport) { | |
| 806 GrGLStandard standard = ctxInfo.standard(); | |
| 807 GrGLVersion version = ctxInfo.version(); | |
| 808 | |
| 809 // Base texture support | |
| 810 fConfigTextureSupport[kAlpha_8_GrPixelConfig] = true; | |
| 811 fConfigTextureSupport[kRGB_565_GrPixelConfig] = true; | |
| 812 fConfigTextureSupport[kRGBA_4444_GrPixelConfig] = true; | |
| 813 fConfigTextureSupport[kRGBA_8888_GrPixelConfig] = true; | |
| 814 | |
| 815 // Disable this for now, while we investigate https://bug.skia.org/4333 | |
| 816 if (false) { | |
| 817 // Check for 8-bit palette.. | |
| 818 GrGLint numFormats; | |
| 819 GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats
); | |
| 820 if (numFormats) { | |
| 821 SkAutoSTMalloc<10, GrGLint> formats(numFormats); | |
| 822 GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats); | |
| 823 for (int i = 0; i < numFormats; ++i) { | |
| 824 if (GR_GL_PALETTE8_RGBA8 == formats[i]) { | |
| 825 fConfigTextureSupport[kIndex_8_GrPixelConfig] = true; | |
| 826 break; | |
| 827 } | |
| 828 } | |
| 829 } | |
| 830 } | |
| 831 | |
| 832 // Check for BGRA | |
| 833 if (kGL_GrGLStandard == standard) { | |
| 834 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = | |
| 835 version >= GR_GL_VER(1,2) || ctxInfo.hasExtension("GL_EXT_bgra"); | |
| 836 } else { | |
| 837 if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) { | |
| 838 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true; | |
| 839 if (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT_textur
e_storage")) { | |
| 840 fBGRAIsInternalFormat = true; | |
| 841 } | |
| 842 } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) { | |
| 843 fConfigTextureSupport[kBGRA_8888_GrPixelConfig] = true; | |
| 844 fBGRAIsInternalFormat = true; | |
| 845 } | |
| 846 SkASSERT(fConfigTextureSupport[kBGRA_8888_GrPixelConfig] || | |
| 847 kSkia8888_GrPixelConfig != kBGRA_8888_GrPixelConfig); | |
| 848 } | |
| 849 | |
| 850 fConfigTextureSupport[kSRGBA_8888_GrPixelConfig] = srgbSupport; | |
| 851 | |
| 852 // Compressed texture support | |
| 853 | |
| 854 // glCompressedTexImage2D is available on all OpenGL ES devices... | |
| 855 // however, it is only available on standard OpenGL after version 1.3 | |
| 856 bool hasCompressTex2D = (kGL_GrGLStandard != standard || version >= GR_GL_VE
R(1, 3)); | |
| 857 | |
| 858 fCompressedTexSubImageSupport = | |
| 859 hasCompressTex2D && (gli->fFunctions.fCompressedTexSubImage2D); | |
| 860 | |
| 861 // Check for ETC1 | |
| 862 bool hasETC1 = false; | |
| 863 | |
| 864 // First check version for support | |
| 865 if (kGL_GrGLStandard == standard) { | |
| 866 hasETC1 = hasCompressTex2D && | |
| 867 (version >= GR_GL_VER(4, 3) || | |
| 868 ctxInfo.hasExtension("GL_ARB_ES3_compatibility")); | |
| 869 } else { | |
| 870 hasETC1 = hasCompressTex2D && | |
| 871 (version >= GR_GL_VER(3, 0) || | |
| 872 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") || | |
| 873 // ETC2 is a superset of ETC1, so we can just check for that, too. | |
| 874 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") && | |
| 875 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))); | |
| 876 } | |
| 877 fConfigTextureSupport[kETC1_GrPixelConfig] = hasETC1; | |
| 878 | |
| 879 // Check for LATC under its various forms | |
| 880 LATCAlias alias = kLATC_LATCAlias; | |
| 881 bool hasLATC = hasCompressTex2D && | |
| 882 (ctxInfo.hasExtension("GL_EXT_texture_compression_latc") || | |
| 883 ctxInfo.hasExtension("GL_NV_texture_compression_latc")); | |
| 884 | |
| 885 // Check for RGTC | |
| 886 if (!hasLATC) { | |
| 887 // If we're using OpenGL 3.0 or later, then we have RGTC, an identical c
ompression format. | |
| 888 if (kGL_GrGLStandard == standard) { | |
| 889 hasLATC = version >= GR_GL_VER(3, 0); | |
| 890 } | |
| 891 | |
| 892 if (!hasLATC) { | |
| 893 hasLATC = | |
| 894 ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") || | |
| 895 ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc"); | |
| 896 } | |
| 897 | |
| 898 if (hasLATC) { | |
| 899 alias = kRGTC_LATCAlias; | |
| 900 } | |
| 901 } | |
| 902 | |
| 903 // Check for 3DC | |
| 904 if (!hasLATC) { | |
| 905 hasLATC = ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture"); | |
| 906 if (hasLATC) { | |
| 907 alias = k3DC_LATCAlias; | |
| 908 } | |
| 909 } | |
| 910 | |
| 911 fConfigTextureSupport[kLATC_GrPixelConfig] = hasLATC; | |
| 912 fLATCAlias = alias; | |
| 913 | |
| 914 // Check for R11_EAC ... We don't support R11_EAC on desktop, as most | |
| 915 // cards default to decompressing the textures in the driver, and is | |
| 916 // generally slower. | |
| 917 if (kGL_GrGLStandard != standard) { | |
| 918 fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3,
0); | |
| 919 } | |
| 920 | |
| 921 // Check for ASTC | |
| 922 fConfigTextureSupport[kASTC_12x12_GrPixelConfig] = | |
| 923 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") || | |
| 924 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") || | |
| 925 ctxInfo.hasExtension("GL_OES_texture_compression_astc"); | |
| 926 | |
| 927 // Check for floating point texture support | |
| 928 // NOTE: We disallow floating point textures on ES devices if linear | |
| 929 // filtering modes are not supported. This is for simplicity, but a more | |
| 930 // granular approach is possible. Coincidentally, floating point textures b
ecame part of | |
| 931 // the standard in ES3.1 / OGL 3.1, hence the shorthand | |
| 932 bool hasFPTextures = version >= GR_GL_VER(3, 1); | |
| 933 if (!hasFPTextures) { | |
| 934 hasFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") || | |
| 935 (ctxInfo.hasExtension("GL_OES_texture_float_linear") && | |
| 936 ctxInfo.hasExtension("GL_OES_texture_float")); | |
| 937 } | |
| 938 fConfigTextureSupport[kRGBA_float_GrPixelConfig] = hasFPTextures; | |
| 939 | |
| 940 // Check for fp16 texture support | |
| 941 // NOTE: We disallow floating point textures on ES devices if linear | |
| 942 // filtering modes are not supported. This is for simplicity, but a more | |
| 943 // granular approach is possible. Coincidentally, 16-bit floating point tex
tures became part of | |
| 944 // the standard in ES3.1 / OGL 3.1, hence the shorthand | |
| 945 bool hasHalfFPTextures = version >= GR_GL_VER(3, 1); | |
| 946 if (!hasHalfFPTextures) { | |
| 947 hasHalfFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") || | |
| 948 (ctxInfo.hasExtension("GL_OES_texture_half_float_lin
ear") && | |
| 949 ctxInfo.hasExtension("GL_OES_texture_half_float")); | |
| 950 } | |
| 951 fConfigTextureSupport[kAlpha_half_GrPixelConfig] = hasHalfFPTextures; | |
| 952 fConfigTextureSupport[kRGBA_half_GrPixelConfig] = hasHalfFPTextures; | |
| 953 } | |
| 954 | |
| 955 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, | 614 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, |
| 956 GrPixelConfig readConfig, | 615 GrPixelConfig readConfig, |
| 957 GrPixelConfig currFBOConfig) const { | 616 GrPixelConfig currFBOConfig) const { |
| 958 SkASSERT(this->isConfigRenderable(currFBOConfig, false)); | 617 SkASSERT(this->isConfigRenderable(currFBOConfig, false)); |
| 959 | 618 |
| 960 if (kGL_GrGLStandard == intf->fStandard) { | 619 if (kGL_GrGLStandard == intf->fStandard) { |
| 961 // All of our renderable configs can be converted to each other by glRea
dPixels in OpenGL. | 620 // All of our renderable configs can be converted to each other by glRea
dPixels in OpenGL. |
| 962 return true; | 621 return true; |
| 963 } | 622 } |
| 964 // See Section 16.1.2 in the ES 3.2 specification. | 623 // See Section 16.1.2 in the ES 3.2 specification. |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 GR_STATIC_ASSERT(3 == kChromium_MapBufferType); | 840 GR_STATIC_ASSERT(3 == kChromium_MapBufferType); |
| 1182 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMapBufferTypeStr) == kLast_MapBufferType +
1); | 841 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMapBufferTypeStr) == kLast_MapBufferType +
1); |
| 1183 | 842 |
| 1184 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); | 843 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); |
| 1185 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]); | 844 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]); |
| 1186 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType
]); | 845 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType
]); |
| 1187 r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]); | 846 r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]); |
| 1188 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); | 847 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); |
| 1189 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits); | 848 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits); |
| 1190 r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); | 849 r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); |
| 1191 r.appendf("Support RGBA8 Render Buffer: %s\n", (fRGBA8RenderbufferSupport ?
"YES": "NO")); | |
| 1192 r.appendf("BGRA is an internal format: %s\n", (fBGRAIsInternalFormat ? "YES"
: "NO")); | |
| 1193 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES
": "NO")); | 850 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES
": "NO")); |
| 1194 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO")
); | 851 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO")
); |
| 1195 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "
NO")); | 852 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": "
NO")); |
| 1196 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); | 853 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); |
| 1197 | 854 |
| 1198 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO"
)); | 855 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO"
)); |
| 1199 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO"
)); | 856 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO"
)); |
| 1200 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); | 857 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); |
| 1201 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); | 858 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); |
| 1202 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ?
"YES": "NO")); | 859 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ?
"YES": "NO")); |
| 1203 r.appendf("Direct state access support: %s\n", (fDirectStateAccessSupport ?
"YES": "NO")); | 860 r.appendf("Direct state access support: %s\n", (fDirectStateAccessSupport ?
"YES": "NO")); |
| 1204 r.appendf("Debug support: %s\n", (fDebugSupport ? "YES": "NO")); | 861 r.appendf("Debug support: %s\n", (fDebugSupport ? "YES": "NO")); |
| 1205 r.appendf("Multisample disable support: %s\n", (fMultisampleDisableSupport ?
"YES" : "NO")); | 862 r.appendf("Multisample disable support: %s\n", (fMultisampleDisableSupport ?
"YES" : "NO")); |
| 1206 r.appendf("Use non-VBO for dynamic data: %s\n", | 863 r.appendf("Use non-VBO for dynamic data: %s\n", |
| 1207 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); | 864 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); |
| 1208 r.appendf("SRGB write contol: %s\n", (fSRGBWriteControl ? "YES" : "NO")); | 865 r.appendf("SRGB write contol: %s\n", (fSRGBWriteControl ? "YES" : "NO")); |
| 1209 r.appendf("RGBA 8888 pixel ops are slow: %s\n", (fRGBA8888PixelsOpsAreSlow ?
"YES" : "NO")); | 866 r.appendf("RGBA 8888 pixel ops are slow: %s\n", (fRGBA8888PixelsOpsAreSlow ?
"YES" : "NO")); |
| 1210 r.appendf("Partial FBO read is slow: %s\n", (fPartialFBOReadIsSlow ? "YES" :
"NO")); | 867 r.appendf("Partial FBO read is slow: %s\n", (fPartialFBOReadIsSlow ? "YES" :
"NO")); |
| 1211 r.appendf("Bind uniform location support: %s\n", (fBindUniformLocationSuppor
t ? "YES" : "NO")); | 868 r.appendf("Bind uniform location support: %s\n", (fBindUniformLocationSuppor
t ? "YES" : "NO")); |
| 869 |
| 870 r.append("Configs\n-------\n"); |
| 871 for (int i = 0; i < kGrPixelConfigCnt; ++i) { |
| 872 r.appendf(" cfg: %d flags: 0x%04x, b_internal: 0x%08x s_internal: 0x%08
x, e_format: " |
| 873 "0x%08x, e_type: 0x%08x, i_for_teximage: 0x%08x, e_for_teximag
e: 0x%08x\n", |
| 874 i, |
| 875 fConfigTable[i].fFlags, |
| 876 fConfigTable[i].fFormats.fBaseInternalFormat, |
| 877 fConfigTable[i].fFormats.fSizedInternalFormat, |
| 878 fConfigTable[i].fFormats.fExternalFormat, |
| 879 fConfigTable[i].fFormats.fExternalType, |
| 880 fConfigTable[i].fFormats.fInternalFormatTexImage, |
| 881 fConfigTable[i].fFormats.fExternalFormatForTexImage); |
| 882 } |
| 883 |
| 1212 return r; | 884 return r; |
| 1213 } | 885 } |
| 1214 | 886 |
| 1215 static GrGLenum precision_to_gl_float_type(GrSLPrecision p) { | 887 static GrGLenum precision_to_gl_float_type(GrSLPrecision p) { |
| 1216 switch (p) { | 888 switch (p) { |
| 1217 case kLow_GrSLPrecision: | 889 case kLow_GrSLPrecision: |
| 1218 return GR_GL_LOW_FLOAT; | 890 return GR_GL_LOW_FLOAT; |
| 1219 case kMedium_GrSLPrecision: | 891 case kMedium_GrSLPrecision: |
| 1220 return GR_GL_MEDIUM_FLOAT; | 892 return GR_GL_MEDIUM_FLOAT; |
| 1221 case kHigh_GrSLPrecision: | 893 case kHigh_GrSLPrecision: |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1327 glslCaps->fConfigSwizzle[kSRGBA_8888_GrPixelConfig] = "rgba"; | 999 glslCaps->fConfigSwizzle[kSRGBA_8888_GrPixelConfig] = "rgba"; |
| 1328 glslCaps->fConfigSwizzle[kETC1_GrPixelConfig] = "rgba"; | 1000 glslCaps->fConfigSwizzle[kETC1_GrPixelConfig] = "rgba"; |
| 1329 glslCaps->fConfigSwizzle[kLATC_GrPixelConfig] = "rrrr"; | 1001 glslCaps->fConfigSwizzle[kLATC_GrPixelConfig] = "rrrr"; |
| 1330 glslCaps->fConfigSwizzle[kR11_EAC_GrPixelConfig] = "rrrr"; | 1002 glslCaps->fConfigSwizzle[kR11_EAC_GrPixelConfig] = "rrrr"; |
| 1331 glslCaps->fConfigSwizzle[kASTC_12x12_GrPixelConfig] = "rgba"; | 1003 glslCaps->fConfigSwizzle[kASTC_12x12_GrPixelConfig] = "rgba"; |
| 1332 glslCaps->fConfigSwizzle[kRGBA_float_GrPixelConfig] = "rgba"; | 1004 glslCaps->fConfigSwizzle[kRGBA_float_GrPixelConfig] = "rgba"; |
| 1333 glslCaps->fConfigSwizzle[kRGBA_half_GrPixelConfig] = "rgba"; | 1005 glslCaps->fConfigSwizzle[kRGBA_half_GrPixelConfig] = "rgba"; |
| 1334 | 1006 |
| 1335 } | 1007 } |
| 1336 | 1008 |
| 1337 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo) { | 1009 bool GrGLCaps::bgraIsInternalFormat() const { |
| 1010 return fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat =
= GR_GL_BGRA; |
| 1011 } |
| 1012 |
| 1013 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa
ce* gli) { |
| 1014 /* |
| 1015 Comments on renderability of configs on various GL versions. |
| 1016 OpenGL < 3.0: |
| 1017 no built in support for render targets. |
| 1018 GL_EXT_framebuffer_object adds possible support for any sized format
with base internal |
| 1019 format RGB, RGBA and NV float formats we don't use. |
| 1020 This is the following: |
| 1021 R3_G3_B2, RGB4, RGB5, RGB8, RGB10, RGB12, RGB16, RGBA2, RGBA4, R
GB5_A1, RGBA8 |
| 1022 RGB10_A2, RGBA12,RGBA16 |
| 1023 Though, it is hard to believe the more obscure formats such as RGB
A12 would work |
| 1024 since they aren't required by later standards and the driver can s
imply return |
| 1025 FRAMEBUFFER_UNSUPPORTED for anything it doesn't allow. |
| 1026 GL_ARB_framebuffer_object adds everything added by the EXT extension
and additionally |
| 1027 any sized internal format with a base internal format of ALPHA, LU
MINANCE, |
| 1028 LUMINANCE_ALPHA, INTENSITY, RED, and RG. |
| 1029 This adds a lot of additional renderable sized formats, including
ALPHA8. |
| 1030 The GL_ARB_texture_rg brings in the RED and RG formats (8, 8I, 8UI
, 16, 16I, 16UI, |
| 1031 16F, 32I, 32UI, and 32F variants). |
| 1032 Again, the driver has an escape hatch via FRAMEBUFFER_UNSUPPORTED. |
| 1033 |
| 1034 For both the above extensions we limit ourselves to those that are a
lso required by |
| 1035 OpenGL 3.0. |
| 1036 |
| 1037 OpenGL 3.0: |
| 1038 Any format with base internal format ALPHA, RED, RG, RGB or RGBA is
"color-renderable" |
| 1039 but are not required to be supported as renderable textures/renderbu
ffer. |
| 1040 Required renderable color formats: |
| 1041 - RGBA32F, RGBA32I, RGBA32UI, RGBA16, RGBA16F, RGBA16I, |
| 1042 RGBA16UI, RGBA8, RGBA8I, RGBA8UI, SRGB8_ALPHA8, and |
| 1043 RGB10_A2. |
| 1044 - R11F_G11F_B10F. |
| 1045 - RG32F, RG32I, RG32UI, RG16, RG16F, RG16I, RG16UI, RG8, RG8I, |
| 1046 and RG8UI. |
| 1047 - R32F, R32I, R32UI, R16F, R16I, R16UI, R16, R8, R8I, and R8UI. |
| 1048 - ALPHA8 |
| 1049 |
| 1050 OpenGL 3.1, 3.2, 3.3 |
| 1051 Same as 3.0 except ALPHA8 requires GL_ARB_compatibility/compatibilit
y profile. |
| 1052 OpengGL 3.3, 4.0, 4.1 |
| 1053 Adds RGB10_A2UI. |
| 1054 OpengGL 4.2 |
| 1055 Adds |
| 1056 - RGB5_A1, RGBA4 |
| 1057 - RGB565 |
| 1058 OpenGL 4.4 |
| 1059 Does away with the separate list and adds a column to the sized inte
rnal color format |
| 1060 table. However, no new formats become required color renderable. |
| 1061 |
| 1062 ES 2.0 |
| 1063 color renderable: RGBA4, RGB5_A1, RGB565 |
| 1064 GL_EXT_texture_rg adds support for R8, RG5 as a color render target |
| 1065 GL_OES_rgb8_rgba8 adds support for RGB8 and RGBA8 |
| 1066 GL_ARM_rgba8 adds support for RGBA8 (but not RGB8) |
| 1067 GL_EXT_texture_format_BGRA8888 does not add renderbuffer support |
| 1068 GL_CHROMIUM_renderbuffer_format_BGRA8888 adds BGRA8 as color-rendera
ble |
| 1069 GL_APPLE_texture_format_BGRA8888 does not add renderbuffer support |
| 1070 |
| 1071 ES 3.0 |
| 1072 - RGBA32I, RGBA32UI, RGBA16I, RGBA16UI, RGBA8, RGBA8I, |
| 1073 RGBA8UI, SRGB8_ALPHA8, RGB10_A2, RGB10_A2UI, RGBA4, and |
| 1074 RGB5_A1. |
| 1075 - RGB8 and RGB565. |
| 1076 - RG32I, RG32UI, RG16I, RG16UI, RG8, RG8I, and RG8UI. |
| 1077 - R32I, R32UI, R16I, R16UI, R8, R8I, and R8UI |
| 1078 ES 3.1 |
| 1079 Adds RGB10_A2, RGB10_A2UI, |
| 1080 ES 3.2 |
| 1081 Adds R16F, RG16F, RGBA16F, R32F, RG32F, RGBA32F, R11F_G11F_B10F. |
| 1082 */ |
| 1083 uint32_t allRenderFlags = ConfigInfo::kRenderable_Flag; |
| 1084 if (kNone_MSFBOType != fMSFBOType) { |
| 1085 allRenderFlags |= ConfigInfo::kRenderableWithMSAA_Flag; |
| 1086 } |
| 1087 |
| 1088 GrGLStandard standard = ctxInfo.standard(); |
| 1089 GrGLVersion version = ctxInfo.version(); |
| 1090 |
| 1338 fConfigTable[kUnknown_GrPixelConfig].fFormats.fBaseInternalFormat = 0; | 1091 fConfigTable[kUnknown_GrPixelConfig].fFormats.fBaseInternalFormat = 0; |
| 1339 fConfigTable[kUnknown_GrPixelConfig].fFormats.fSizedInternalFormat = 0; | 1092 fConfigTable[kUnknown_GrPixelConfig].fFormats.fSizedInternalFormat = 0; |
| 1340 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalFormat = 0; | 1093 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalFormat = 0; |
| 1341 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalType = 0; | 1094 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalType = 0; |
| 1342 fConfigTable[kUnknown_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For
matType; | 1095 fConfigTable[kUnknown_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For
matType; |
| 1343 | 1096 |
| 1344 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_
RGBA; | 1097 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_
RGBA; |
| 1345 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL
_RGBA8; | 1098 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL
_RGBA8; |
| 1346 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA
; | 1099 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA
; |
| 1347 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN
ED_BYTE; | 1100 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN
ED_BYTE; |
| 1348 fConfigTable[kRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F
ormatType; | 1101 fConfigTable[kRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F
ormatType; |
| 1102 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Fla
g; |
| 1103 if (kGL_GrGLStandard == standard) { |
| 1104 // We require some form of FBO support and all GLs with FBO support can
render to RGBA8 |
| 1105 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags |= allRenderFlags; |
| 1106 } else { |
| 1107 if (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_OES_rgb8_rgba8
") || |
| 1108 ctxInfo.hasExtension("GL_ARM_rgba8")) { |
| 1109 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags |= allRenderFlags; |
| 1110 } |
| 1111 } |
| 1349 | 1112 |
| 1350 if (this->bgraIsInternalFormat()) { | |
| 1351 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR
_GL_BGRA; | |
| 1352 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = G
R_GL_BGRA8; | |
| 1353 } else { | |
| 1354 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR
_GL_RGBA; | |
| 1355 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = G
R_GL_RGBA8; | |
| 1356 } | |
| 1357 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalFormat= GR_GL_BGRA; | 1113 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalFormat= GR_GL_BGRA; |
| 1358 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG
NED_BYTE; | 1114 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG
NED_BYTE; |
| 1359 fConfigTable[kBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F
ormatType; | 1115 fConfigTable[kBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F
ormatType; |
| 1116 if (kGL_GrGLStandard == standard) { |
| 1117 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR
_GL_RGBA; |
| 1118 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = G
R_GL_RGBA8; |
| 1119 if (version >= GR_GL_VER(1, 2) || ctxInfo.hasExtension("GL_EXT_bgra")) { |
| 1120 // Since the internal format is RGBA8, it is also renderable. |
| 1121 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTexture
able_Flag | |
| 1122 allRenderFlags; |
| 1123 } |
| 1124 } else { |
| 1125 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR
_GL_BGRA; |
| 1126 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = G
R_GL_BGRA8; |
| 1127 if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) { |
| 1128 // The APPLE extension doesn't make this renderable. |
| 1129 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTexture
able_Flag; |
| 1130 if (version < GR_GL_VER(3,0) && !ctxInfo.hasExtension("GL_EXT_textur
e_storage")) { |
| 1131 // On ES2 the internal format of a BGRA texture is RGBA with the
APPLE extension. |
| 1132 // Though, that seems to not be the case if the texture storage
extension is |
| 1133 // present. The specs don't exactly make that clear. |
| 1134 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFor
mat = GR_GL_RGBA; |
| 1135 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFo
rmat = GR_GL_RGBA8; |
| 1136 } |
| 1137 } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) { |
| 1138 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTexture
able_Flag | |
| 1139 ConfigInfo::kRendera
ble_Flag; |
| 1140 if (ctxInfo.hasExtension("GL_CHROMIUM_renderbuffer_format_BGRA8888")
&& |
| 1141 this->usesMSAARenderBuffers()) { |
| 1142 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags |= |
| 1143 ConfigInfo::kRenderableWithMSAA_Flag; |
| 1144 } |
| 1145 } |
| 1146 } |
| 1360 | 1147 |
| 1361 | 1148 // We only enable srgb support if both textures and FBOs support srgb. |
| 1149 bool srgbSupport = false; |
| 1150 if (kGL_GrGLStandard == standard) { |
| 1151 if (ctxInfo.version() >= GR_GL_VER(3,0)) { |
| 1152 srgbSupport = true; |
| 1153 } else if (ctxInfo.hasExtension("GL_EXT_texture_sRGB")) { |
| 1154 if (ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") || |
| 1155 ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) { |
| 1156 srgbSupport = true; |
| 1157 } |
| 1158 } |
| 1159 // All the above srgb extensions support toggling srgb writes |
| 1160 fSRGBWriteControl = srgbSupport; |
| 1161 } else { |
| 1162 // See https://bug.skia.org/4148 for PowerVR issue. |
| 1163 srgbSupport = kPowerVRRogue_GrGLRenderer != ctxInfo.renderer() && |
| 1164 (ctxInfo.version() >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT
_sRGB")); |
| 1165 // ES through 3.1 requires EXT_srgb_write_control to support toggling |
| 1166 // sRGB writing for destinations. |
| 1167 fSRGBWriteControl = ctxInfo.hasExtension("GL_EXT_sRGB_write_control"); |
| 1168 } |
| 1362 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL
_SRGB_ALPHA; | 1169 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL
_SRGB_ALPHA; |
| 1363 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G
L_SRGB8_ALPHA8; | 1170 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G
L_SRGB8_ALPHA8; |
| 1364 // GL does not do srgb<->rgb conversions when transferring between cpu and g
pu. Thus, the | 1171 // GL does not do srgb<->rgb conversions when transferring between cpu and g
pu. Thus, the |
| 1365 // external format is GL_RGBA. See below for note about ES2.0 and glTex[Sub]
Image. | 1172 // external format is GL_RGBA. See below for note about ES2.0 and glTex[Sub]
Image. |
| 1366 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB
A; | 1173 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB
A; |
| 1367 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG
NED_BYTE; | 1174 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG
NED_BYTE; |
| 1368 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_
FormatType; | 1175 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_
FormatType; |
| 1176 if (srgbSupport) { |
| 1177 fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureabl
e_Flag | |
| 1178 allRenderFlags; |
| 1179 } |
| 1369 | 1180 |
| 1370 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RG
B; | 1181 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RG
B; |
| 1371 if (this->ES2CompatibilitySupport()) { | 1182 if (this->ES2CompatibilitySupport()) { |
| 1372 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_RGB565; | 1183 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_RGB565; |
| 1373 } else { | 1184 } else { |
| 1374 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_RGB5; | 1185 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_RGB5; |
| 1375 } | 1186 } |
| 1376 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB; | 1187 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB; |
| 1377 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED
_SHORT_5_6_5; | 1188 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED
_SHORT_5_6_5; |
| 1378 fConfigTable[kRGB_565_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For
matType; | 1189 fConfigTable[kRGB_565_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For
matType; |
| 1190 fConfigTable[kRGB_565_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag; |
| 1191 if (kGL_GrGLStandard == standard) { |
| 1192 if (version >= GR_GL_VER(4, 2) || ctxInfo.hasExtension("GL_ES2_compatibi
lity")) { |
| 1193 fConfigTable[kRGB_565_GrPixelConfig].fFlags |= allRenderFlags; |
| 1194 } |
| 1195 } else { |
| 1196 fConfigTable[kRGB_565_GrPixelConfig].fFlags |= allRenderFlags; |
| 1197 } |
| 1379 | 1198 |
| 1380 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_
RGBA; | 1199 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_
RGBA; |
| 1381 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL
_RGBA4; | 1200 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL
_RGBA4; |
| 1382 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA
; | 1201 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA
; |
| 1383 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN
ED_SHORT_4_4_4_4; | 1202 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN
ED_SHORT_4_4_4_4; |
| 1384 fConfigTable[kRGBA_4444_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F
ormatType; | 1203 fConfigTable[kRGBA_4444_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F
ormatType; |
| 1385 | 1204 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Fla
g; |
| 1205 if (kGL_GrGLStandard == standard) { |
| 1206 if (version >= GR_GL_VER(4, 2)) { |
| 1207 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags |= allRenderFlags; |
| 1208 } |
| 1209 } else { |
| 1210 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags |= allRenderFlags; |
| 1211 } |
| 1386 | 1212 |
| 1387 if (this->textureRedSupport()) { | 1213 if (this->textureRedSupport()) { |
| 1388 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G
L_RED; | 1214 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G
L_RED; |
| 1389 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_R8; | 1215 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_R8; |
| 1390 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RE
D; | 1216 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RE
D; |
| 1391 } else { | 1217 } else { |
| 1392 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G
L_ALPHA; | 1218 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G
L_ALPHA; |
| 1393 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_ALPHA8; | 1219 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_
GL_ALPHA8; |
| 1394 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_AL
PHA; | 1220 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_AL
PHA; |
| 1395 } | 1221 } |
| 1396 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED
_BYTE; | 1222 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED
_BYTE; |
| 1397 fConfigTable[kAlpha_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For
matType; | 1223 fConfigTable[kAlpha_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For
matType; |
| 1224 fConfigTable[kAlpha_8_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag; |
| 1225 if (this->textureRedSupport() || kDesktop_ARB_MSFBOType == this->msFBOType()
) { |
| 1226 // desktop ARB extension/3.0+ supports ALPHA8 as renderable. |
| 1227 // Core profile removes ALPHA8 support, but we should have chosen R8 in
that case. |
| 1228 fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= allRenderFlags; |
| 1229 } |
| 1230 |
| 1231 // Check for [half] floating point texture support |
| 1232 // NOTE: We disallow floating point textures on ES devices if linear filteri
ng modes are not |
| 1233 // supported. This is for simplicity, but a more granular approach is possib
le. Coincidentally, |
| 1234 // [half] floating point textures became part of the standard in ES3.1 / OGL
3.0. |
| 1235 bool hasFPTextures = false; |
| 1236 bool hasHalfFPTextures = false; |
| 1237 // for now we don't support floating point MSAA on ES |
| 1238 uint32_t fpRenderFlags = (kGL_GrGLStandard == standard) ? |
| 1239 allRenderFlags : (uint32_t)ConfigInfo::kRenderable
_Flag; |
| 1240 |
| 1241 if (kGL_GrGLStandard == standard) { |
| 1242 if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_texture_f
loat")) { |
| 1243 hasFPTextures = true; |
| 1244 hasHalfFPTextures = true; |
| 1245 } |
| 1246 } else { |
| 1247 if (version >= GR_GL_VER(3, 1)) { |
| 1248 hasFPTextures = true; |
| 1249 hasHalfFPTextures = true; |
| 1250 } else { |
| 1251 if (ctxInfo.hasExtension("GL_OES_texture_float_linear") && |
| 1252 ctxInfo.hasExtension("GL_OES_texture_float")) { |
| 1253 hasFPTextures = true; |
| 1254 } |
| 1255 if (ctxInfo.hasExtension("GL_OES_texture_half_float_linear") && |
| 1256 ctxInfo.hasExtension("GL_OES_texture_half_float")) { |
| 1257 hasHalfFPTextures = true; |
| 1258 } |
| 1259 } |
| 1260 } |
| 1398 | 1261 |
| 1399 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL
_RGBA; | 1262 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL
_RGBA; |
| 1400 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G
L_RGBA32F; | 1263 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G
L_RGBA32F; |
| 1401 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB
A; | 1264 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB
A; |
| 1402 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalType = GR_GL_FLOAT
; | 1265 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalType = GR_GL_FLOAT
; |
| 1403 fConfigTable[kRGBA_float_GrPixelConfig].fFormatType = kFloat_FormatType; | 1266 fConfigTable[kRGBA_float_GrPixelConfig].fFormatType = kFloat_FormatType; |
| 1267 if (hasFPTextures) { |
| 1268 fConfigTable[kRGBA_float_GrPixelConfig].fFlags = ConfigInfo::kTextureabl
e_Flag; |
| 1269 // For now we only enable rendering to float on desktop, because on ES w
e'd have to solve |
| 1270 // many precision issues and no clients actually want this yet. |
| 1271 if (kGL_GrGLStandard == standard /* || version >= GR_GL_VER(3,2) || |
| 1272 ctxInfo.hasExtension("GL_EXT_color_buffer_float")*/) { |
| 1273 fConfigTable[kRGBA_float_GrPixelConfig].fFlags |= fpRenderFlags; |
| 1274 } |
| 1275 } |
| 1404 | 1276 |
| 1405 if (this->textureRedSupport()) { | 1277 if (this->textureRedSupport()) { |
| 1406 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G
R_GL_RED; | 1278 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G
R_GL_RED; |
| 1407 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat =
GR_GL_R16F; | 1279 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat =
GR_GL_R16F; |
| 1408 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL
_RED; | 1280 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL
_RED; |
| 1409 } else { | 1281 } else { |
| 1410 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G
R_GL_ALPHA; | 1282 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G
R_GL_ALPHA; |
| 1411 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat =
GR_GL_ALPHA16F; | 1283 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat =
GR_GL_ALPHA16F; |
| 1412 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL
_ALPHA; | 1284 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL
_ALPHA; |
| 1413 } | 1285 } |
| 1414 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER
(3, 0)) { | 1286 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER
(3, 0)) { |
| 1415 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H
ALF_FLOAT; | 1287 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H
ALF_FLOAT; |
| 1416 } else { | 1288 } else { |
| 1417 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H
ALF_FLOAT_OES; | 1289 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H
ALF_FLOAT_OES; |
| 1418 } | 1290 } |
| 1419 fConfigTable[kAlpha_half_GrPixelConfig].fFormatType = kFloat_FormatType; | 1291 fConfigTable[kAlpha_half_GrPixelConfig].fFormatType = kFloat_FormatType; |
| 1292 if (hasHalfFPTextures) { |
| 1293 fConfigTable[kAlpha_half_GrPixelConfig].fFlags = ConfigInfo::kTextureabl
e_Flag; |
| 1294 // ES requires either 3.2 or the combination of EXT_color_buffer_half_fl
oat and support for |
| 1295 // GL_RED internal format. |
| 1296 if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3,2) || |
| 1297 (this->textureRedSupport() && |
| 1298 ctxInfo.hasExtension("GL_EXT_color_buffer_half_float"))) { |
| 1299 fConfigTable[kAlpha_half_GrPixelConfig].fFlags |= fpRenderFlags; |
| 1300 } |
| 1301 } |
| 1420 | 1302 |
| 1421 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_
RGBA; | 1303 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_
RGBA; |
| 1422 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL
_RGBA16F; | 1304 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL
_RGBA16F; |
| 1423 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA
; | 1305 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA
; |
| 1424 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER
(3, 0)) { | 1306 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER
(3, 0)) { |
| 1425 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA
LF_FLOAT; | 1307 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA
LF_FLOAT; |
| 1426 } else { | 1308 } else { |
| 1427 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA
LF_FLOAT_OES; | 1309 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA
LF_FLOAT_OES; |
| 1428 } | 1310 } |
| 1429 fConfigTable[kRGBA_half_GrPixelConfig].fFormatType = kFloat_FormatType; | 1311 fConfigTable[kRGBA_half_GrPixelConfig].fFormatType = kFloat_FormatType; |
| 1312 if (hasHalfFPTextures) { |
| 1313 fConfigTable[kRGBA_half_GrPixelConfig].fFlags = ConfigInfo::kTextureable
_Flag; |
| 1314 // ES requires 3.2 or EXT_color_buffer_half_float. |
| 1315 if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3,2) || |
| 1316 ctxInfo.hasExtension("GL_EXT_color_buffer_half_float")) { |
| 1317 fConfigTable[kRGBA_half_GrPixelConfig].fFlags |= fpRenderFlags; |
| 1318 } |
| 1319 } |
| 1320 |
| 1321 // Compressed texture support |
| 1322 |
| 1323 // glCompressedTexImage2D is available on all OpenGL ES devices. It is avail
able on standard |
| 1324 // OpenGL after version 1.3. We'll assume at least that level of OpenGL supp
ort. |
| 1325 |
| 1326 // TODO: Fix command buffer bindings and remove this. |
| 1327 fCompressedTexSubImageSupport = SkToBool(gli->fFunctions.fCompressedTexSubIm
age2D); |
| 1430 | 1328 |
| 1431 // No sized/unsized internal format distinction for compressed formats, no e
xternal format. | 1329 // No sized/unsized internal format distinction for compressed formats, no e
xternal format. |
| 1330 // Below we set the external formats and types to 0. |
| 1432 | 1331 |
| 1433 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_PA
LETTE8_RGBA8; | 1332 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_PA
LETTE8_RGBA8; |
| 1434 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_P
ALETTE8_RGBA8; | 1333 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_P
ALETTE8_RGBA8; |
| 1435 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalFormat = 0; | 1334 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalFormat = 0; |
| 1436 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalType = 0; | 1335 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalType = 0; |
| 1437 fConfigTable[kIndex_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For
matType; | 1336 fConfigTable[kIndex_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For
matType; |
| 1337 // Disable this for now, while we investigate https://bug.skia.org/4333 |
| 1338 if (false) { |
| 1339 // Check for 8-bit palette.. |
| 1340 GrGLint numFormats; |
| 1341 GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats
); |
| 1342 if (numFormats) { |
| 1343 SkAutoSTMalloc<10, GrGLint> formats(numFormats); |
| 1344 GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats); |
| 1345 for (int i = 0; i < numFormats; ++i) { |
| 1346 if (GR_GL_PALETTE8_RGBA8 == formats[i]) { |
| 1347 fConfigTable[kIndex_8_GrPixelConfig].fFlags = ConfigInfo::kT
extureable_Flag; |
| 1348 break; |
| 1349 } |
| 1350 } |
| 1351 } |
| 1352 } |
| 1438 | 1353 |
| 1439 switch(this->latcAlias()) { | 1354 // May change the internal format based on extensions. |
| 1440 case GrGLCaps::kLATC_LATCAlias: | 1355 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = |
| 1441 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = | 1356 GR_GL_COMPRESSED_LUMINANCE_LATC1; |
| 1442 GR_GL_COMPRESSED_LUMINANCE_LATC1; | 1357 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = |
| 1443 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = | 1358 GR_GL_COMPRESSED_LUMINANCE_LATC1; |
| 1444 GR_GL_COMPRESSED_LUMINANCE_LATC1; | 1359 if (ctxInfo.hasExtension("GL_EXT_texture_compression_latc") || |
| 1445 break; | 1360 ctxInfo.hasExtension("GL_NV_texture_compression_latc")) { |
| 1446 case GrGLCaps::kRGTC_LATCAlias: | 1361 fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag
; |
| 1447 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = | 1362 } else if ((kGL_GrGLStandard == standard && version >= GR_GL_VER(3, 0)) || |
| 1448 GR_GL_COMPRESSED_RED_RGTC1; | 1363 ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") || |
| 1449 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = | 1364 ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc")) { |
| 1450 GR_GL_COMPRESSED_RED_RGTC1; | 1365 // RGTC is identical and available on OpenGL 3.0+ as well as with extens
ions |
| 1451 break; | 1366 fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag
; |
| 1452 case GrGLCaps::k3DC_LATCAlias: | 1367 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = |
| 1453 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_
GL_COMPRESSED_3DC_X; | 1368 GR_GL_COMPRESSED_RED_RGTC1; |
| 1454 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = | 1369 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = |
| 1455 GR_GL_COMPRESSED_3DC_X; | 1370 GR_GL_COMPRESSED_RED_RGTC1; |
| 1456 break; | 1371 } else if (ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture")) { |
| 1372 fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag
; |
| 1373 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_C
OMPRESSED_3DC_X; |
| 1374 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = |
| 1375 GR_GL_COMPRESSED_3DC_X; |
| 1376 |
| 1457 } | 1377 } |
| 1458 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalFormat = 0; | 1378 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalFormat = 0; |
| 1459 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalType = 0; | 1379 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalType = 0; |
| 1460 fConfigTable[kLATC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format
Type; | 1380 fConfigTable[kLATC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format
Type; |
| 1461 | 1381 |
| 1462 fConfigTable[kETC1_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPR
ESSED_ETC1_RGB8; | 1382 fConfigTable[kETC1_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPR
ESSED_ETC1_RGB8; |
| 1463 fConfigTable[kETC1_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_COMP
RESSED_ETC1_RGB8; | 1383 fConfigTable[kETC1_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_COMP
RESSED_ETC1_RGB8; |
| 1464 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalFormat = 0; | 1384 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalFormat = 0; |
| 1465 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalType = 0; | 1385 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalType = 0; |
| 1466 fConfigTable[kETC1_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format
Type; | 1386 fConfigTable[kETC1_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format
Type; |
| 1387 if (kGL_GrGLStandard == standard) { |
| 1388 if (version >= GR_GL_VER(4, 3) || ctxInfo.hasExtension("GL_ARB_ES3_compa
tibility")) { |
| 1389 fConfigTable[kETC1_GrPixelConfig].fFlags = ConfigInfo::kTextureable_
Flag; |
| 1390 } |
| 1391 } else { |
| 1392 if (version >= GR_GL_VER(3, 0) || |
| 1393 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") || |
| 1394 // ETC2 is a superset of ETC1, so we can just check for that, too. |
| 1395 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") && |
| 1396 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))) { |
| 1397 fConfigTable[kETC1_GrPixelConfig].fFlags = ConfigInfo::kTextureable_
Flag; |
| 1398 } |
| 1399 } |
| 1467 | 1400 |
| 1468 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_CO
MPRESSED_R11_EAC; | 1401 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_CO
MPRESSED_R11_EAC; |
| 1469 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_C
OMPRESSED_R11_EAC; | 1402 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_C
OMPRESSED_R11_EAC; |
| 1470 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalFormat = 0; | 1403 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalFormat = 0; |
| 1471 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalType = 0; | 1404 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalType = 0; |
| 1472 fConfigTable[kR11_EAC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For
matType; | 1405 fConfigTable[kR11_EAC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For
matType; |
| 1406 // Check for R11_EAC. We don't support R11_EAC on desktop, as most cards def
ault to |
| 1407 // decompressing the textures in the driver, and is generally slower. |
| 1408 if (kGLES_GrGLStandard == standard && version >= GR_GL_VER(3,0)) { |
| 1409 fConfigTable[kR11_EAC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_F
lag; |
| 1410 } |
| 1473 | 1411 |
| 1474 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fBaseInternalFormat = | 1412 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fBaseInternalFormat = |
| 1475 GR_GL_COMPRESSED_RGBA_ASTC_12x12; | 1413 GR_GL_COMPRESSED_RGBA_ASTC_12x12; |
| 1476 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fSizedInternalFormat = | 1414 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fSizedInternalFormat = |
| 1477 GR_GL_COMPRESSED_RGBA_ASTC_12x12; | 1415 GR_GL_COMPRESSED_RGBA_ASTC_12x12; |
| 1478 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalFormat = 0; | 1416 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalFormat = 0; |
| 1479 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalType = 0; | 1417 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalType = 0; |
| 1480 fConfigTable[kASTC_12x12_GrPixelConfig].fFormatType = kNormalizedFixedPoint_
FormatType; | 1418 fConfigTable[kASTC_12x12_GrPixelConfig].fFormatType = kNormalizedFixedPoint_
FormatType; |
| 1419 if (ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") || |
| 1420 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") || |
| 1421 ctxInfo.hasExtension("GL_OES_texture_compression_astc")) { |
| 1422 fConfigTable[kASTC_12x12_GrPixelConfig].fFlags = ConfigInfo::kTextureabl
e_Flag; |
| 1423 } |
| 1481 | 1424 |
| 1482 // Bulk populate the texture internal/external formats here and then deal wi
th exceptions below. | 1425 // Bulk populate the texture internal/external formats here and then deal wi
th exceptions below. |
| 1483 | 1426 |
| 1484 // ES 2.0 requires that the internal/external formats match. | 1427 // ES 2.0 requires that the internal/external formats match. |
| 1485 bool useSizedFormats = (kGL_GrGLStandard == ctxInfo.standard() || | 1428 bool useSizedFormats = (kGL_GrGLStandard == ctxInfo.standard() || |
| 1486 ctxInfo.version() >= GR_GL_VER(3,0)); | 1429 ctxInfo.version() >= GR_GL_VER(3,0)); |
| 1487 for (int i = 0; i < kGrPixelConfigCnt; ++i) { | 1430 for (int i = 0; i < kGrPixelConfigCnt; ++i) { |
| 1488 // Almost always we want to pass fExternalFormat as the <format> param t
o glTex[Sub]Image. | 1431 // Almost always we want to pass fExternalFormat as the <format> param t
o glTex[Sub]Image. |
| 1489 fConfigTable[i].fFormats.fExternalFormatForTexImage = | 1432 fConfigTable[i].fFormats.fExternalFormatForTexImage = |
| 1490 fConfigTable[i].fFormats.fExternalFormat; | 1433 fConfigTable[i].fFormats.fExternalFormat; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 fConfigTable[i].fFormats.fSizedInternalFormat); | 1467 fConfigTable[i].fFormats.fSizedInternalFormat); |
| 1525 SkASSERT(defaultEntry.fExternalFormat != fConfigTable[i].fFormats.fExter
nalFormat); | 1468 SkASSERT(defaultEntry.fExternalFormat != fConfigTable[i].fFormats.fExter
nalFormat); |
| 1526 SkASSERT(defaultEntry.fExternalType != fConfigTable[i].fFormats.fExterna
lType); | 1469 SkASSERT(defaultEntry.fExternalType != fConfigTable[i].fFormats.fExterna
lType); |
| 1527 } | 1470 } |
| 1528 #endif | 1471 #endif |
| 1529 } | 1472 } |
| 1530 | 1473 |
| 1531 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} | 1474 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} |
| 1532 | 1475 |
| 1533 | 1476 |
| OLD | NEW |