Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: src/gpu/gl/GrGLCaps.cpp

Issue 1569103003: Revert of Move config texturability/renderability to config table (Closed) Base URL: https://skia.googlesource.com/skia.git@readpixformat
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLCaps.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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;
23 fMapBufferType = kNone_MapBufferType; 24 fMapBufferType = kNone_MapBufferType;
24 fTransferBufferType = kNone_TransferBufferType; 25 fTransferBufferType = kNone_TransferBufferType;
25 fMaxFragmentUniformVectors = 0; 26 fMaxFragmentUniformVectors = 0;
26 fMaxVertexAttributes = 0; 27 fMaxVertexAttributes = 0;
27 fMaxFragmentTextureUnits = 0; 28 fMaxFragmentTextureUnits = 0;
29 fRGBA8RenderbufferSupport = false;
30 fBGRAIsInternalFormat = false;
28 fUnpackRowLengthSupport = false; 31 fUnpackRowLengthSupport = false;
29 fUnpackFlipYSupport = false; 32 fUnpackFlipYSupport = false;
30 fPackRowLengthSupport = false; 33 fPackRowLengthSupport = false;
31 fPackFlipYSupport = false; 34 fPackFlipYSupport = false;
32 fTextureUsageSupport = false; 35 fTextureUsageSupport = false;
33 fTexStorageSupport = false; 36 fTexStorageSupport = false;
34 fTextureRedSupport = false; 37 fTextureRedSupport = false;
35 fImagingSupport = false; 38 fImagingSupport = false;
36 fVertexArrayObjectSupport = false; 39 fVertexArrayObjectSupport = false;
37 fDirectStateAccessSupport = false; 40 fDirectStateAccessSupport = false;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 if (version >= GR_GL_VER(3, 2)) { 75 if (version >= GR_GL_VER(3, 2)) {
73 GrGLint profileMask; 76 GrGLint profileMask;
74 GR_GL_GetIntegerv(gli, GR_GL_CONTEXT_PROFILE_MASK, &profileMask); 77 GR_GL_GetIntegerv(gli, GR_GL_CONTEXT_PROFILE_MASK, &profileMask);
75 fIsCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_B IT); 78 fIsCoreProfile = SkToBool(profileMask & GR_GL_CONTEXT_CORE_PROFILE_B IT);
76 } 79 }
77 } 80 }
78 GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes); 81 GR_GL_GetIntegerv(gli, GR_GL_MAX_VERTEX_ATTRIBS, &fMaxVertexAttributes);
79 GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &fMaxFragmentTextureUn its); 82 GR_GL_GetIntegerv(gli, GR_GL_MAX_TEXTURE_IMAGE_UNITS, &fMaxFragmentTextureUn its);
80 83
81 if (kGL_GrGLStandard == standard) { 84 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) {
82 fUnpackRowLengthSupport = true; 93 fUnpackRowLengthSupport = true;
83 fUnpackFlipYSupport = false; 94 fUnpackFlipYSupport = false;
84 fPackRowLengthSupport = true; 95 fPackRowLengthSupport = true;
85 fPackFlipYSupport = false; 96 fPackFlipYSupport = false;
86 } else { 97 } else {
87 fUnpackRowLengthSupport = version >= GR_GL_VER(3,0) || 98 fUnpackRowLengthSupport = version >= GR_GL_VER(3,0) ||
88 ctxInfo.hasExtension("GL_EXT_unpack_subimage") ; 99 ctxInfo.hasExtension("GL_EXT_unpack_subimage") ;
89 fUnpackFlipYSupport = ctxInfo.hasExtension("GL_CHROMIUM_flipy"); 100 fUnpackFlipYSupport = ctxInfo.hasExtension("GL_CHROMIUM_flipy");
90 fPackRowLengthSupport = version >= GR_GL_VER(3,0) || 101 fPackRowLengthSupport = version >= GR_GL_VER(3,0) ||
91 ctxInfo.hasExtension("GL_NV_pack_subimage"); 102 ctxInfo.hasExtension("GL_NV_pack_subimage");
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 fTextureRedSupport = version >= GR_GL_VER(3,0) || 134 fTextureRedSupport = version >= GR_GL_VER(3,0) ||
124 ctxInfo.hasExtension("GL_ARB_texture_rg"); 135 ctxInfo.hasExtension("GL_ARB_texture_rg");
125 } else { 136 } else {
126 fTextureRedSupport = version >= GR_GL_VER(3,0) || 137 fTextureRedSupport = version >= GR_GL_VER(3,0) ||
127 ctxInfo.hasExtension("GL_EXT_texture_rg"); 138 ctxInfo.hasExtension("GL_EXT_texture_rg");
128 } 139 }
129 } 140 }
130 fImagingSupport = kGL_GrGLStandard == standard && 141 fImagingSupport = kGL_GrGLStandard == standard &&
131 ctxInfo.hasExtension("GL_ARB_imaging"); 142 ctxInfo.hasExtension("GL_ARB_imaging");
132 143
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
133 // SGX and Mali GPUs that are based on a tiled-deferred architecture that ha ve trouble with 166 // SGX and Mali GPUs that are based on a tiled-deferred architecture that ha ve trouble with
134 // frequently changing VBOs. We've measured a performance increase using non -VBO vertex 167 // frequently changing VBOs. We've measured a performance increase using non -VBO vertex
135 // data for dynamic content on these GPUs. Perhaps we should read the render er string and 168 // data for dynamic content on these GPUs. Perhaps we should read the render er string and
136 // limit this decision to specific GPU families rather than basing it on the vendor alone. 169 // limit this decision to specific GPU families rather than basing it on the vendor alone.
137 if (!GR_GL_MUST_USE_VBO && 170 if (!GR_GL_MUST_USE_VBO &&
138 (kARM_GrGLVendor == ctxInfo.vendor() || 171 (kARM_GrGLVendor == ctxInfo.vendor() ||
139 kImagination_GrGLVendor == ctxInfo.vendor() || 172 kImagination_GrGLVendor == ctxInfo.vendor() ||
140 kQualcomm_GrGLVendor == ctxInfo.vendor())) { 173 kQualcomm_GrGLVendor == ctxInfo.vendor())) {
141 fUseNonVBOVertexAndIndexDynamicData = true; 174 fUseNonVBOVertexAndIndexDynamicData = true;
142 } 175 }
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 version >= GR_GL_VER(3, 2) || 462 version >= GR_GL_VER(3, 2) ||
430 (ctxInfo.hasExtension("GL_ARB_draw_instanced") && 463 (ctxInfo.hasExtension("GL_ARB_draw_instanced") &&
431 ctxInfo.hasExtension("GL_ARB_instanced_arrays")); 464 ctxInfo.hasExtension("GL_ARB_instanced_arrays"));
432 } else { 465 } else {
433 fSupportsInstancedDraws = 466 fSupportsInstancedDraws =
434 version >= GR_GL_VER(3, 0) || 467 version >= GR_GL_VER(3, 0) ||
435 (ctxInfo.hasExtension("GL_EXT_draw_instanced") && 468 (ctxInfo.hasExtension("GL_EXT_draw_instanced") &&
436 ctxInfo.hasExtension("GL_EXT_instanced_arrays")); 469 ctxInfo.hasExtension("GL_EXT_instanced_arrays"));
437 } 470 }
438 471
472 this->initConfigTexturableTable(ctxInfo, gli, srgbSupport);
473 this->initConfigRenderableTable(ctxInfo, srgbSupport);
439 this->initShaderPrecisionTable(ctxInfo, gli, glslCaps); 474 this->initShaderPrecisionTable(ctxInfo, gli, glslCaps);
440 // Requires fTexutreSwizzleSupport and fTextureRedSupport to be set before t his point. 475 // Requires fTexutreSwizzleSupport and fTextureRedSupport to be set before t his point.
441 this->initConfigSwizzleTable(ctxInfo, glslCaps); 476 this->initConfigSwizzleTable(ctxInfo, glslCaps);
442 // Requires various members are already correctly initialized (e.g. fTexture RedSupport, 477 // Requires various members are already correctly initialized (e.g. fTexture RedSupport).
443 // msaa support). 478 this->initConfigTable(ctxInfo);
444 this->initConfigTable(ctxInfo, gli);
445 479
446 this->applyOptionsOverrides(contextOptions); 480 this->applyOptionsOverrides(contextOptions);
447 glslCaps->applyOptionsOverrides(contextOptions); 481 glslCaps->applyOptionsOverrides(contextOptions);
448 } 482 }
449 483
450 const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration generation, 484 const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration generation,
451 bool isCoreProfile) { 485 bool isCoreProfile) {
452 switch (generation) { 486 switch (generation) {
453 case k110_GrGLSLGeneration: 487 case k110_GrGLSLGeneration:
454 if (kGLES_GrGLStandard == standard) { 488 if (kGLES_GrGLStandard == standard) {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 // them for consistency. 638 // them for consistency.
605 if (nullptr == gli->fFunctions.fStencilThenCoverFillPath || 639 if (nullptr == gli->fFunctions.fStencilThenCoverFillPath ||
606 nullptr == gli->fFunctions.fStencilThenCoverStrokePath || 640 nullptr == gli->fFunctions.fStencilThenCoverStrokePath ||
607 nullptr == gli->fFunctions.fStencilThenCoverFillPathInstanced || 641 nullptr == gli->fFunctions.fStencilThenCoverFillPathInstanced ||
608 nullptr == gli->fFunctions.fStencilThenCoverStrokePathInstanced || 642 nullptr == gli->fFunctions.fStencilThenCoverStrokePathInstanced ||
609 nullptr == gli->fFunctions.fProgramPathFragmentInputGen) { 643 nullptr == gli->fFunctions.fProgramPathFragmentInputGen) {
610 return false; 644 return false;
611 } 645 }
612 return true; 646 return true;
613 } 647 }
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
614 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, 955 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
615 GrPixelConfig readConfig, 956 GrPixelConfig readConfig,
616 GrPixelConfig currFBOConfig) const { 957 GrPixelConfig currFBOConfig) const {
617 SkASSERT(this->isConfigRenderable(currFBOConfig, false)); 958 SkASSERT(this->isConfigRenderable(currFBOConfig, false));
618 959
619 if (kGL_GrGLStandard == intf->fStandard) { 960 if (kGL_GrGLStandard == intf->fStandard) {
620 // All of our renderable configs can be converted to each other by glRea dPixels in OpenGL. 961 // All of our renderable configs can be converted to each other by glRea dPixels in OpenGL.
621 return true; 962 return true;
622 } 963 }
623 // See Section 16.1.2 in the ES 3.2 specification. 964 // See Section 16.1.2 in the ES 3.2 specification.
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 GR_STATIC_ASSERT(3 == kChromium_MapBufferType); 1181 GR_STATIC_ASSERT(3 == kChromium_MapBufferType);
841 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMapBufferTypeStr) == kLast_MapBufferType + 1); 1182 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kMapBufferTypeStr) == kLast_MapBufferType + 1);
842 1183
843 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO")); 1184 r.appendf("Core Profile: %s\n", (fIsCoreProfile ? "YES" : "NO"));
844 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]); 1185 r.appendf("MSAA Type: %s\n", kMSFBOExtStr[fMSFBOType]);
845 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType ]); 1186 r.appendf("Invalidate FB Type: %s\n", kInvalidateFBTypeStr[fInvalidateFBType ]);
846 r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]); 1187 r.appendf("Map Buffer Type: %s\n", kMapBufferTypeStr[fMapBufferType]);
847 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors); 1188 r.appendf("Max FS Uniform Vectors: %d\n", fMaxFragmentUniformVectors);
848 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits); 1189 r.appendf("Max FS Texture Units: %d\n", fMaxFragmentTextureUnits);
849 r.appendf("Max Vertex Attributes: %d\n", fMaxVertexAttributes); 1190 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"));
850 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES ": "NO")); 1193 r.appendf("Unpack Row length support: %s\n", (fUnpackRowLengthSupport ? "YES ": "NO"));
851 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO") ); 1194 r.appendf("Unpack Flip Y support: %s\n", (fUnpackFlipYSupport ? "YES": "NO") );
852 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": " NO")); 1195 r.appendf("Pack Row length support: %s\n", (fPackRowLengthSupport ? "YES": " NO"));
853 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); 1196 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO"));
854 1197
855 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO" )); 1198 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO" ));
856 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO" )); 1199 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO" ));
857 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); 1200 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO"));
858 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); 1201 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO"));
859 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO")); 1202 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO"));
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 glslCaps->fConfigSwizzle[kSRGBA_8888_GrPixelConfig] = "rgba"; 1327 glslCaps->fConfigSwizzle[kSRGBA_8888_GrPixelConfig] = "rgba";
985 glslCaps->fConfigSwizzle[kETC1_GrPixelConfig] = "rgba"; 1328 glslCaps->fConfigSwizzle[kETC1_GrPixelConfig] = "rgba";
986 glslCaps->fConfigSwizzle[kLATC_GrPixelConfig] = "rrrr"; 1329 glslCaps->fConfigSwizzle[kLATC_GrPixelConfig] = "rrrr";
987 glslCaps->fConfigSwizzle[kR11_EAC_GrPixelConfig] = "rrrr"; 1330 glslCaps->fConfigSwizzle[kR11_EAC_GrPixelConfig] = "rrrr";
988 glslCaps->fConfigSwizzle[kASTC_12x12_GrPixelConfig] = "rgba"; 1331 glslCaps->fConfigSwizzle[kASTC_12x12_GrPixelConfig] = "rgba";
989 glslCaps->fConfigSwizzle[kRGBA_float_GrPixelConfig] = "rgba"; 1332 glslCaps->fConfigSwizzle[kRGBA_float_GrPixelConfig] = "rgba";
990 glslCaps->fConfigSwizzle[kRGBA_half_GrPixelConfig] = "rgba"; 1333 glslCaps->fConfigSwizzle[kRGBA_half_GrPixelConfig] = "rgba";
991 1334
992 } 1335 }
993 1336
994 bool GrGLCaps::bgraIsInternalFormat() const { 1337 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo) {
995 return fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = = GR_GL_BGRA;
996 }
997
998 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa ce* gli) {
999 /*
1000 Comments on renderability of configs on various GL versions.
1001 OpenGL < 3.0:
1002 no built in support for render targets.
1003 GL_EXT_framebuffer_object adds possible support for any sized format with base internal
1004 format RGB, RGBA and NV float formats we don't use.
1005 This is the following:
1006 R3_G3_B2, RGB4, RGB5, RGB8, RGB10, RGB12, RGB16, RGBA2, RGBA4, R GB5_A1, RGBA8
1007 RGB10_A2, RGBA12,RGBA16
1008 Though, it is hard to believe the more obscure formats such as RGB A12 would work
1009 since they aren't required by later standards and the driver can s imply return
1010 FRAMEBUFFER_UNSUPPORTED for anything it doesn't allow.
1011 GL_ARB_framebuffer_object adds everything added by the EXT extension and additionally
1012 any sized internal format with a base internal format of ALPHA, LU MINANCE,
1013 LUMINANCE_ALPHA, INTENSITY, RED, and RG.
1014 This adds a lot of additional renderable sized formats, including ALPHA8.
1015 The GL_ARB_texture_rg brings in the RED and RG formats (8, 8I, 8UI , 16, 16I, 16UI,
1016 16F, 32I, 32UI, and 32F variants).
1017 Again, the driver has an escape hatch via FRAMEBUFFER_UNSUPPORTED.
1018
1019 For both the above extensions we limit ourselves to those that are a lso required by
1020 OpenGL 3.0.
1021
1022 OpenGL 3.0:
1023 Any format with base internal format ALPHA, RED, RG, RGB or RGBA is "color-renderable"
1024 but are not required to be supported as renderable textures/renderbu ffer.
1025 Required renderable color formats:
1026 - RGBA32F, RGBA32I, RGBA32UI, RGBA16, RGBA16F, RGBA16I,
1027 RGBA16UI, RGBA8, RGBA8I, RGBA8UI, SRGB8_ALPHA8, and
1028 RGB10_A2.
1029 - R11F_G11F_B10F.
1030 - RG32F, RG32I, RG32UI, RG16, RG16F, RG16I, RG16UI, RG8, RG8I,
1031 and RG8UI.
1032 - R32F, R32I, R32UI, R16F, R16I, R16UI, R16, R8, R8I, and R8UI.
1033 - ALPHA8
1034
1035 OpenGL 3.1, 3.2, 3.3
1036 Same as 3.0 except ALPHA8 requires GL_ARB_compatibility/compatibilit y profile.
1037 OpengGL 3.3, 4.0, 4.1
1038 Adds RGB10_A2UI.
1039 OpengGL 4.2
1040 Adds
1041 - RGB5_A1, RGBA4
1042 - RGB565
1043 OpenGL 4.4
1044 Does away with the separate list and adds a column to the sized inte rnal color format
1045 table. However, no new formats become required color renderable.
1046
1047 ES 2.0
1048 color renderable: RGBA4, RGB5_A1, RGB565
1049 GL_EXT_texture_rg adds support for R8, RG5 as a color render target
1050 GL_OES_rgb8_rgba8 adds support for RGB8 and RGBA8
1051 GL_ARM_rgba8 adds support for RGBA8 (but not RGB8)
1052 GL_EXT_texture_format_BGRA8888 does not add renderbuffer support
1053 GL_CHROMIUM_renderbuffer_format_BGRA8888 adds BGRA8 as color-rendera ble
1054 GL_APPLE_texture_format_BGRA8888 does not add renderbuffer support
1055
1056 ES 3.0
1057 - RGBA32I, RGBA32UI, RGBA16I, RGBA16UI, RGBA8, RGBA8I,
1058 RGBA8UI, SRGB8_ALPHA8, RGB10_A2, RGB10_A2UI, RGBA4, and
1059 RGB5_A1.
1060 - RGB8 and RGB565.
1061 - RG32I, RG32UI, RG16I, RG16UI, RG8, RG8I, and RG8UI.
1062 - R32I, R32UI, R16I, R16UI, R8, R8I, and R8UI
1063 ES 3.1
1064 Adds RGB10_A2, RGB10_A2UI,
1065 ES 3.2
1066 Adds R16F, RG16F, RGBA16F, R32F, RG32F, RGBA32F, R11F_G11F_B10F.
1067 */
1068 uint32_t allRenderFlags = ConfigInfo::kRenderable_Flag;
1069 if (kNone_MSFBOType != fMSFBOType) {
1070 allRenderFlags |= ConfigInfo::kRenderableWithMSAA_Flag;
1071 }
1072
1073 GrGLStandard standard = ctxInfo.standard();
1074 GrGLVersion version = ctxInfo.version();
1075
1076 fConfigTable[kUnknown_GrPixelConfig].fFormats.fBaseInternalFormat = 0; 1338 fConfigTable[kUnknown_GrPixelConfig].fFormats.fBaseInternalFormat = 0;
1077 fConfigTable[kUnknown_GrPixelConfig].fFormats.fSizedInternalFormat = 0; 1339 fConfigTable[kUnknown_GrPixelConfig].fFormats.fSizedInternalFormat = 0;
1078 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalFormat = 0; 1340 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalFormat = 0;
1079 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalType = 0; 1341 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalType = 0;
1080 fConfigTable[kUnknown_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1342 fConfigTable[kUnknown_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType;
1081 1343
1082 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA; 1344 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA;
1083 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA8; 1345 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA8;
1084 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA ; 1346 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA ;
1085 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN ED_BYTE; 1347 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN ED_BYTE;
1086 fConfigTable[kRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType; 1348 fConfigTable[kRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType;
1087 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Fla g; 1349
1088 if (kGL_GrGLStandard != standard || version > GR_GL_VER(2, 0)) { 1350 if (this->bgraIsInternalFormat()) {
1089 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags |= allRenderFlags; 1351 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR _GL_BGRA;
1090 } else if (ctxInfo.hasExtension("GL_OES_rgb8_rgba8") || ctxInfo.hasExtension ("GL_ARM_rgba8")) { 1352 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = G R_GL_BGRA8;
1091 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags |= allRenderFlags; 1353 } else {
1354 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR _GL_RGBA;
1355 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = G R_GL_RGBA8;
1092 } 1356 }
1093
1094 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalFormat= GR_GL_BGRA; 1357 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalFormat= GR_GL_BGRA;
1095 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG NED_BYTE; 1358 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG NED_BYTE;
1096 fConfigTable[kBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType; 1359 fConfigTable[kBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType;
1097 if (kGL_GrGLStandard == standard) {
1098 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR _GL_RGBA;
1099 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = G R_GL_RGBA8;
1100 if (version >= GR_GL_VER(1, 2) || ctxInfo.hasExtension("GL_EXT_bgra")) {
1101 // Since the internal format is RGBA8, it is also renderable.
1102 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTexture able_Flag |
1103 allRenderFlags;
1104 }
1105 } else {
1106 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR _GL_BGRA;
1107 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = G R_GL_BGRA8;
1108 if (ctxInfo.hasExtension("GL_APPLE_texture_format_BGRA8888")) {
1109 // The APPLE extension doesn't make this renderable.
1110 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTexture able_Flag;
1111 if (version < GR_GL_VER(3,0)) {
1112 // On ES2 the internal format of a BGRA texture is RGBA with the APPLE extension.
1113 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFor mat = GR_GL_RGBA;
1114 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFo rmat = GR_GL_RGBA8;
1115 }
1116 } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) {
1117 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTexture able_Flag |
1118 ConfigInfo::kRendera ble_Flag;
1119 if (ctxInfo.hasExtension("GL_CHROMIUM_renderbuffer_format_BGRA8888") &&
1120 this->usesMSAARenderBuffers()) {
1121 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags |=
1122 ConfigInfo::kRenderableWithMSAA_Flag;
1123 }
1124 }
1125 }
1126 1360
1127 // We only enable srgb support if both textures and FBOs support srgb. 1361
1128 bool srgbSupport = false;
1129 if (kGL_GrGLStandard == standard) {
1130 if (ctxInfo.version() >= GR_GL_VER(3,0)) {
1131 srgbSupport = true;
1132 } else if (ctxInfo.hasExtension("GL_EXT_texture_sRGB")) {
1133 if (ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") ||
1134 ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) {
1135 srgbSupport = true;
1136 }
1137 }
1138 // All the above srgb extensions support toggling srgb writes
1139 fSRGBWriteControl = srgbSupport;
1140 } else {
1141 // See https://bug.skia.org/4148 for PowerVR issue.
1142 srgbSupport = kPowerVRRogue_GrGLRenderer != ctxInfo.renderer() &&
1143 (ctxInfo.version() >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT _sRGB"));
1144 // ES through 3.1 requires EXT_srgb_write_control to support toggling
1145 // sRGB writing for destinations.
1146 fSRGBWriteControl = ctxInfo.hasExtension("GL_EXT_sRGB_write_control");
1147 }
1148 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL _SRGB_ALPHA; 1362 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL _SRGB_ALPHA;
1149 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G L_SRGB8_ALPHA8; 1363 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G L_SRGB8_ALPHA8;
1150 // GL does not do srgb<->rgb conversions when transferring between cpu and g pu. Thus, the 1364 // GL does not do srgb<->rgb conversions when transferring between cpu and g pu. Thus, the
1151 // external format is GL_RGBA. See below for note about ES2.0 and glTex[Sub] Image. 1365 // external format is GL_RGBA. See below for note about ES2.0 and glTex[Sub] Image.
1152 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB A; 1366 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB A;
1153 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG NED_BYTE; 1367 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG NED_BYTE;
1154 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_ FormatType; 1368 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_ FormatType;
1155 if (srgbSupport) {
1156 fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag |
1157 allRenderFlags;
1158 }
1159 1369
1160 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RG B; 1370 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RG B;
1161 if (this->ES2CompatibilitySupport()) { 1371 if (this->ES2CompatibilitySupport()) {
1162 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_RGB565; 1372 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_RGB565;
1163 } else { 1373 } else {
1164 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_RGB5; 1374 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_RGB5;
1165 } 1375 }
1166 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB; 1376 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB;
1167 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED _SHORT_5_6_5; 1377 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED _SHORT_5_6_5;
1168 fConfigTable[kRGB_565_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1378 fConfigTable[kRGB_565_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType;
1169 fConfigTable[kRGB_565_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
1170 if (kGL_GrGLStandard == standard) {
1171 if (version >= GR_GL_VER(4, 2) || ctxInfo.hasExtension("GL_ES2_compatibi lity")) {
1172 fConfigTable[kRGB_565_GrPixelConfig].fFlags |= allRenderFlags;
1173 }
1174 } else {
1175 fConfigTable[kRGB_565_GrPixelConfig].fFlags |= allRenderFlags;
1176 }
1177 1379
1178 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA; 1380 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA;
1179 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA4; 1381 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA4;
1180 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA ; 1382 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA ;
1181 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN ED_SHORT_4_4_4_4; 1383 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN ED_SHORT_4_4_4_4;
1182 fConfigTable[kRGBA_4444_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType; 1384 fConfigTable[kRGBA_4444_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType;
1183 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Fla g; 1385
1184 if (kGL_GrGLStandard == standard) {
1185 if (version >= GR_GL_VER(4, 2)) {
1186 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags |= allRenderFlags;
1187 }
1188 } else {
1189 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags |= allRenderFlags;
1190 }
1191 1386
1192 if (this->textureRedSupport()) { 1387 if (this->textureRedSupport()) {
1193 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G L_RED; 1388 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G L_RED;
1194 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_R8; 1389 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_R8;
1195 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RE D; 1390 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RE D;
1196 } else { 1391 } else {
1197 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G L_ALPHA; 1392 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G L_ALPHA;
1198 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_ALPHA8; 1393 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_ALPHA8;
1199 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_AL PHA; 1394 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_AL PHA;
1200 } 1395 }
1201 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED _BYTE; 1396 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED _BYTE;
1202 fConfigTable[kAlpha_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1397 fConfigTable[kAlpha_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType;
1203 fConfigTable[kAlpha_8_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
1204 if (this->textureRedSupport() || kDesktop_ARB_MSFBOType == this->msFBOType() ) {
1205 // desktop ARB extension/3.0+ supports ALPHA8 as renderable.
1206 // Core profile removes ALPHA8 support, but we should have chosen R8 in that case.
1207 fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= allRenderFlags;
1208 }
1209
1210 // Check for [half] floating point texture support
1211 // NOTE: We disallow floating point textures on ES devices if linear filteri ng modes are not
1212 // supported. This is for simplicity, but a more granular approach is possib le. Coincidentally,
1213 // [half] floating point textures became part of the standard in ES3.1 / OGL 3.0.
1214 bool hasFPTextures = false;
1215 bool hasHalfFPTextures = false;
1216 // for now we don't support floating point MSAA on ES
1217 uint32_t fpRenderFlags = (kGL_GrGLStandard == standard) ?
1218 allRenderFlags : (uint32_t)ConfigInfo::kRenderable _Flag;
1219
1220 if (kGL_GrGLStandard == standard) {
1221 if (version >= GR_GL_VER(3, 0) || ctxInfo.hasExtension("GL_ARB_texture_f loat")) {
1222 hasFPTextures = true;
1223 hasHalfFPTextures = true;
1224 }
1225 } else {
1226 if (version >= GR_GL_VER(3, 1)) {
1227 hasFPTextures = true;
1228 hasHalfFPTextures = true;
1229 } else {
1230 if (ctxInfo.hasExtension("GL_OES_texture_float_linear") &&
1231 ctxInfo.hasExtension("GL_OES_texture_float")) {
1232 hasFPTextures = true;
1233 }
1234 if (ctxInfo.hasExtension("GL_OES_texture_half_float_linear") &&
1235 ctxInfo.hasExtension("GL_OES_texture_half_float")) {
1236 hasHalfFPTextures = true;
1237 }
1238 }
1239 }
1240 1398
1241 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL _RGBA; 1399 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL _RGBA;
1242 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G L_RGBA32F; 1400 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G L_RGBA32F;
1243 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB A; 1401 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB A;
1244 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalType = GR_GL_FLOAT ; 1402 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalType = GR_GL_FLOAT ;
1245 fConfigTable[kRGBA_float_GrPixelConfig].fFormatType = kFloat_FormatType; 1403 fConfigTable[kRGBA_float_GrPixelConfig].fFormatType = kFloat_FormatType;
1246 if (hasFPTextures) {
1247 fConfigTable[kRGBA_float_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag;
1248 // For now we only enable rendering to float on desktop, because on ES w e'd have to solve
1249 // many precision issues and no clients actually want this yet.
1250 if (kGL_GrGLStandard == standard /* || version >= GR_GL_VER(3,2) ||
1251 ctxInfo.hasExtension("GL_EXT_color_buffer_float")*/) {
1252 fConfigTable[kRGBA_float_GrPixelConfig].fFlags |= fpRenderFlags;
1253 }
1254 }
1255 1404
1256 if (this->textureRedSupport()) { 1405 if (this->textureRedSupport()) {
1257 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G R_GL_RED; 1406 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G R_GL_RED;
1258 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_R16F; 1407 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_R16F;
1259 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL _RED; 1408 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL _RED;
1260 } else { 1409 } else {
1261 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G R_GL_ALPHA; 1410 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G R_GL_ALPHA;
1262 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_ALPHA16F; 1411 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_ALPHA16F;
1263 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL _ALPHA; 1412 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL _ALPHA;
1264 } 1413 }
1265 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER (3, 0)) { 1414 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER (3, 0)) {
1266 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H ALF_FLOAT; 1415 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H ALF_FLOAT;
1267 } else { 1416 } else {
1268 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H ALF_FLOAT_OES; 1417 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H ALF_FLOAT_OES;
1269 } 1418 }
1270 fConfigTable[kAlpha_half_GrPixelConfig].fFormatType = kFloat_FormatType; 1419 fConfigTable[kAlpha_half_GrPixelConfig].fFormatType = kFloat_FormatType;
1271 if (hasHalfFPTextures) {
1272 fConfigTable[kAlpha_half_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag;
1273 // ES requires either 3.2 or the combination of EXT_color_buffer_half_fl oat and support for
1274 // GL_RED internal format.
1275 if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3,2) ||
1276 (this->textureRedSupport() &&
1277 ctxInfo.hasExtension("GL_EXT_color_buffer_half_float"))) {
1278 fConfigTable[kAlpha_half_GrPixelConfig].fFlags |= fpRenderFlags;
1279 }
1280 }
1281 1420
1282 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA; 1421 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA;
1283 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA16F; 1422 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA16F;
1284 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA ; 1423 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA ;
1285 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER (3, 0)) { 1424 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER (3, 0)) {
1286 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA LF_FLOAT; 1425 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA LF_FLOAT;
1287 } else { 1426 } else {
1288 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA LF_FLOAT_OES; 1427 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA LF_FLOAT_OES;
1289 } 1428 }
1290 fConfigTable[kRGBA_half_GrPixelConfig].fFormatType = kFloat_FormatType; 1429 fConfigTable[kRGBA_half_GrPixelConfig].fFormatType = kFloat_FormatType;
1291 if (hasHalfFPTextures) {
1292 fConfigTable[kRGBA_half_GrPixelConfig].fFlags = ConfigInfo::kTextureable _Flag;
1293 // ES requires 3.2 or EXT_color_buffer_half_float.
1294 if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3,2) ||
1295 ctxInfo.hasExtension("GL_EXT_color_buffer_half_float")) {
1296 fConfigTable[kRGBA_half_GrPixelConfig].fFlags |= fpRenderFlags;
1297 }
1298 }
1299
1300 // Compressed texture support
1301
1302 // glCompressedTexImage2D is available on all OpenGL ES devices. It is avail able on standard
1303 // OpenGL after version 1.3. We'll assume at least that level of OpenGL supp ort.
1304
1305 // TODO: Fix command buffer bindings and remove this.
1306 fCompressedTexSubImageSupport = SkToBool(gli->fFunctions.fCompressedTexSubIm age2D);
1307 1430
1308 // No sized/unsized internal format distinction for compressed formats, no e xternal format. 1431 // No sized/unsized internal format distinction for compressed formats, no e xternal format.
1309 // Below we set the external formats and types to 0.
1310 1432
1311 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_PA LETTE8_RGBA8; 1433 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_PA LETTE8_RGBA8;
1312 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_P ALETTE8_RGBA8; 1434 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_P ALETTE8_RGBA8;
1313 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalFormat = 0; 1435 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalFormat = 0;
1314 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalType = 0; 1436 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalType = 0;
1315 fConfigTable[kIndex_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1437 fConfigTable[kIndex_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType;
1316 // Disable this for now, while we investigate https://bug.skia.org/4333
1317 if (false) {
1318 // Check for 8-bit palette..
1319 GrGLint numFormats;
1320 GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats );
1321 if (numFormats) {
1322 SkAutoSTMalloc<10, GrGLint> formats(numFormats);
1323 GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats);
1324 for (int i = 0; i < numFormats; ++i) {
1325 if (GR_GL_PALETTE8_RGBA8 == formats[i]) {
1326 fConfigTable[kIndex_8_GrPixelConfig].fFlags = ConfigInfo::kT extureable_Flag;
1327 break;
1328 }
1329 }
1330 }
1331 }
1332 1438
1333 // May change the internal format based on extensions. 1439 switch(this->latcAlias()) {
1334 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = 1440 case GrGLCaps::kLATC_LATCAlias:
1335 GR_GL_COMPRESSED_LUMINANCE_LATC1; 1441 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat =
1336 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = 1442 GR_GL_COMPRESSED_LUMINANCE_LATC1;
1337 GR_GL_COMPRESSED_LUMINANCE_LATC1; 1443 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat =
1338 if (ctxInfo.hasExtension("GL_EXT_texture_compression_latc") || 1444 GR_GL_COMPRESSED_LUMINANCE_LATC1;
1339 ctxInfo.hasExtension("GL_NV_texture_compression_latc")) { 1445 break;
1340 fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag ; 1446 case GrGLCaps::kRGTC_LATCAlias:
1341 } else if ((kGL_GrGLStandard == standard && version >= GR_GL_VER(3, 0)) || 1447 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat =
1342 ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") || 1448 GR_GL_COMPRESSED_RED_RGTC1;
1343 ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc")) { 1449 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat =
1344 // RGTC is identical and available on OpenGL 3.0+ as well as with extens ions 1450 GR_GL_COMPRESSED_RED_RGTC1;
1345 fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag ; 1451 break;
1346 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = 1452 case GrGLCaps::k3DC_LATCAlias:
1347 GR_GL_COMPRESSED_RED_RGTC1; 1453 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_ GL_COMPRESSED_3DC_X;
1348 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = 1454 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat =
1349 GR_GL_COMPRESSED_RED_RGTC1; 1455 GR_GL_COMPRESSED_3DC_X;
1350 } else if (ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture")) { 1456 break;
1351 fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag ;
1352 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_C OMPRESSED_3DC_X;
1353 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat =
1354 GR_GL_COMPRESSED_3DC_X;
1355
1356 } 1457 }
1357 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalFormat = 0; 1458 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalFormat = 0;
1358 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalType = 0; 1459 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalType = 0;
1359 fConfigTable[kLATC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format Type; 1460 fConfigTable[kLATC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format Type;
1360 1461
1361 fConfigTable[kETC1_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPR ESSED_ETC1_RGB8; 1462 fConfigTable[kETC1_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPR ESSED_ETC1_RGB8;
1362 fConfigTable[kETC1_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_COMP RESSED_ETC1_RGB8; 1463 fConfigTable[kETC1_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_COMP RESSED_ETC1_RGB8;
1363 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalFormat = 0; 1464 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalFormat = 0;
1364 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalType = 0; 1465 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalType = 0;
1365 fConfigTable[kETC1_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format Type; 1466 fConfigTable[kETC1_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format Type;
1366 if (kGL_GrGLStandard == standard) {
1367 if (version >= GR_GL_VER(4, 3) || ctxInfo.hasExtension("GL_ARB_ES3_compa tibility")) {
1368 fConfigTable[kETC1_GrPixelConfig].fFlags = ConfigInfo::kTextureable_ Flag;
1369 }
1370 } else {
1371 if (version >= GR_GL_VER(3, 0) ||
1372 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") ||
1373 // ETC2 is a superset of ETC1, so we can just check for that, too.
1374 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") &&
1375 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))) {
1376 fConfigTable[kETC1_GrPixelConfig].fFlags = ConfigInfo::kTextureable_ Flag;
1377 }
1378 }
1379 1467
1380 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_CO MPRESSED_R11_EAC; 1468 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_CO MPRESSED_R11_EAC;
1381 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_C OMPRESSED_R11_EAC; 1469 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_C OMPRESSED_R11_EAC;
1382 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalFormat = 0; 1470 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalFormat = 0;
1383 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalType = 0; 1471 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalType = 0;
1384 fConfigTable[kR11_EAC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1472 fConfigTable[kR11_EAC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType;
1385 // Check for R11_EAC. We don't support R11_EAC on desktop, as most cards def ault to
1386 // decompressing the textures in the driver, and is generally slower.
1387 if (kGLES_GrGLStandard == standard && version >= GR_GL_VER(3,0)) {
1388 fConfigTable[kR11_EAC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_F lag;
1389 }
1390 1473
1391 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fBaseInternalFormat = 1474 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fBaseInternalFormat =
1392 GR_GL_COMPRESSED_RGBA_ASTC_12x12; 1475 GR_GL_COMPRESSED_RGBA_ASTC_12x12;
1393 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fSizedInternalFormat = 1476 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fSizedInternalFormat =
1394 GR_GL_COMPRESSED_RGBA_ASTC_12x12; 1477 GR_GL_COMPRESSED_RGBA_ASTC_12x12;
1395 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalFormat = 0; 1478 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalFormat = 0;
1396 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalType = 0; 1479 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalType = 0;
1397 fConfigTable[kASTC_12x12_GrPixelConfig].fFormatType = kNormalizedFixedPoint_ FormatType; 1480 fConfigTable[kASTC_12x12_GrPixelConfig].fFormatType = kNormalizedFixedPoint_ FormatType;
1398 if (ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") ||
1399 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") ||
1400 ctxInfo.hasExtension("GL_OES_texture_compression_astc")) {
1401 fConfigTable[kASTC_12x12_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag;
1402 }
1403 1481
1404 // Bulk populate the texture internal/external formats here and then deal wi th exceptions below. 1482 // Bulk populate the texture internal/external formats here and then deal wi th exceptions below.
1405 1483
1406 // ES 2.0 requires that the internal/external formats match. 1484 // ES 2.0 requires that the internal/external formats match.
1407 bool useSizedFormats = (kGL_GrGLStandard == ctxInfo.standard() || 1485 bool useSizedFormats = (kGL_GrGLStandard == ctxInfo.standard() ||
1408 ctxInfo.version() >= GR_GL_VER(3,0)); 1486 ctxInfo.version() >= GR_GL_VER(3,0));
1409 for (int i = 0; i < kGrPixelConfigCnt; ++i) { 1487 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
1410 // Almost always we want to pass fExternalFormat as the <format> param t o glTex[Sub]Image. 1488 // Almost always we want to pass fExternalFormat as the <format> param t o glTex[Sub]Image.
1411 fConfigTable[i].fFormats.fExternalFormatForTexImage = 1489 fConfigTable[i].fFormats.fExternalFormatForTexImage =
1412 fConfigTable[i].fFormats.fExternalFormat; 1490 fConfigTable[i].fFormats.fExternalFormat;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 fConfigTable[i].fFormats.fSizedInternalFormat); 1524 fConfigTable[i].fFormats.fSizedInternalFormat);
1447 SkASSERT(defaultEntry.fExternalFormat != fConfigTable[i].fFormats.fExter nalFormat); 1525 SkASSERT(defaultEntry.fExternalFormat != fConfigTable[i].fFormats.fExter nalFormat);
1448 SkASSERT(defaultEntry.fExternalType != fConfigTable[i].fFormats.fExterna lType); 1526 SkASSERT(defaultEntry.fExternalType != fConfigTable[i].fFormats.fExterna lType);
1449 } 1527 }
1450 #endif 1528 #endif
1451 } 1529 }
1452 1530
1453 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} 1531 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {}
1454 1532
1455 1533
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698