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

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

Issue 1576023002: Make readback of alpha channel work for RGBA. (Closed) Base URL: https://skia.googlesource.com/skia.git@swiz
Patch Set: more 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') | src/gpu/gl/GrGLGpu.h » ('j') | 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
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 nullptr == gli->fFunctions.fProgramPathFragmentInputGen) { 623 nullptr == gli->fFunctions.fProgramPathFragmentInputGen) {
624 return false; 624 return false;
625 } 625 }
626 return true; 626 return true;
627 } 627 }
628 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf, 628 bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
629 GrPixelConfig readConfig, 629 GrPixelConfig readConfig,
630 GrPixelConfig currFBOConfig) const { 630 GrPixelConfig currFBOConfig) const {
631 SkASSERT(this->isConfigRenderable(currFBOConfig, false)); 631 SkASSERT(this->isConfigRenderable(currFBOConfig, false));
632 632
633 GrGLenum readFormat;
634 GrGLenum readType;
635 if (!this->getReadPixelsFormat(currFBOConfig, readConfig, &readFormat, &read Type)) {
636 return false;
637 }
638
633 if (kGL_GrGLStandard == intf->fStandard) { 639 if (kGL_GrGLStandard == intf->fStandard) {
634 // All of our renderable configs can be converted to each other by glRea dPixels in OpenGL. 640 // All of our renderable configs can be converted to each other by glRea dPixels in OpenGL.
635 return true; 641 return true;
636 } 642 }
643
637 // See Section 16.1.2 in the ES 3.2 specification. 644 // See Section 16.1.2 in the ES 3.2 specification.
638 645
639 GrGLenum readFormat = fConfigTable[readConfig].fFormats.fExternalFormat;
640 GrGLenum readType = fConfigTable[readConfig].fFormats.fExternalType;
641
642 if (kNormalizedFixedPoint_FormatType == fConfigTable[currFBOConfig].fFormatT ype) { 646 if (kNormalizedFixedPoint_FormatType == fConfigTable[currFBOConfig].fFormatT ype) {
643 if (GR_GL_RGBA == readFormat && GR_GL_UNSIGNED_BYTE == readType) { 647 if (GR_GL_RGBA == readFormat && GR_GL_UNSIGNED_BYTE == readType) {
644 return true; 648 return true;
645 } 649 }
646 } else { 650 } else {
647 SkASSERT(kFloat_FormatType == fConfigTable[currFBOConfig].fFormatType); 651 SkASSERT(kFloat_FormatType == fConfigTable[currFBOConfig].fFormatType);
648 if (GR_GL_RGBA == readFormat && GR_GL_FLOAT == readType) { 652 if (GR_GL_RGBA == readFormat && GR_GL_FLOAT == readType) {
649 return true; 653 return true;
650 } 654 }
651 } 655 }
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 r.appendf("SRGB write contol: %s\n", (fSRGBWriteControl ? "YES" : "NO")); 883 r.appendf("SRGB write contol: %s\n", (fSRGBWriteControl ? "YES" : "NO"));
880 r.appendf("RGBA 8888 pixel ops are slow: %s\n", (fRGBA8888PixelsOpsAreSlow ? "YES" : "NO")); 884 r.appendf("RGBA 8888 pixel ops are slow: %s\n", (fRGBA8888PixelsOpsAreSlow ? "YES" : "NO"));
881 r.appendf("Partial FBO read is slow: %s\n", (fPartialFBOReadIsSlow ? "YES" : "NO")); 885 r.appendf("Partial FBO read is slow: %s\n", (fPartialFBOReadIsSlow ? "YES" : "NO"));
882 r.appendf("Bind uniform location support: %s\n", (fBindUniformLocationSuppor t ? "YES" : "NO")); 886 r.appendf("Bind uniform location support: %s\n", (fBindUniformLocationSuppor t ? "YES" : "NO"));
883 r.appendf("External texture support: %s\n", (fExternalTextureSupport ? "YES" : "NO")); 887 r.appendf("External texture support: %s\n", (fExternalTextureSupport ? "YES" : "NO"));
884 r.appendf("Texture swizzle support: %s\n", (fTextureSwizzleSupport ? "YES" : "NO")); 888 r.appendf("Texture swizzle support: %s\n", (fTextureSwizzleSupport ? "YES" : "NO"));
885 889
886 r.append("Configs\n-------\n"); 890 r.append("Configs\n-------\n");
887 for (int i = 0; i < kGrPixelConfigCnt; ++i) { 891 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
888 r.appendf(" cfg: %d flags: 0x%04x, b_internal: 0x%08x s_internal: 0x%08 x, e_format: " 892 r.appendf(" cfg: %d flags: 0x%04x, b_internal: 0x%08x s_internal: 0x%08 x, e_format: "
889 "0x%08x, e_type: 0x%08x, i_for_teximage: 0x%08x, e_for_teximag e: 0x%08x\n", 893 "0x%08x, e_format_teximage: 0x%08x, e_type: 0x%08x, i_for_texi mage: 0x%08x, "
894 "i_for_renderbuffer: 0x%08x\n",
890 i, 895 i,
891 fConfigTable[i].fFlags, 896 fConfigTable[i].fFlags,
892 fConfigTable[i].fFormats.fBaseInternalFormat, 897 fConfigTable[i].fFormats.fBaseInternalFormat,
893 fConfigTable[i].fFormats.fSizedInternalFormat, 898 fConfigTable[i].fFormats.fSizedInternalFormat,
894 fConfigTable[i].fFormats.fExternalFormat, 899 fConfigTable[i].fFormats.fExternalFormat[kOther_ExternalFormat Usage],
900 fConfigTable[i].fFormats.fExternalFormat[kTexImage_ExternalFor matUsage],
895 fConfigTable[i].fFormats.fExternalType, 901 fConfigTable[i].fFormats.fExternalType,
896 fConfigTable[i].fFormats.fInternalFormatTexImage, 902 fConfigTable[i].fFormats.fInternalFormatTexImage,
897 fConfigTable[i].fFormats.fExternalFormatForTexImage); 903 fConfigTable[i].fFormats.fInternalFormatRenderbuffer);
898 } 904 }
899 905
900 return r; 906 return r;
901 } 907 }
902 908
903 static GrGLenum precision_to_gl_float_type(GrSLPrecision p) { 909 static GrGLenum precision_to_gl_float_type(GrSLPrecision p) {
904 switch (p) { 910 switch (p) {
905 case kLow_GrSLPrecision: 911 case kLow_GrSLPrecision:
906 return GR_GL_LOW_FLOAT; 912 return GR_GL_LOW_FLOAT;
907 case kMedium_GrSLPrecision: 913 case kMedium_GrSLPrecision:
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 glslCaps->fFloatPrecisions[kGeometry_GrShaderType][p] = 987 glslCaps->fFloatPrecisions[kGeometry_GrShaderType][p] =
982 glslCaps->fFloatPrecisions[kVerte x_GrShaderType][p]; 988 glslCaps->fFloatPrecisions[kVerte x_GrShaderType][p];
983 } 989 }
984 } 990 }
985 } 991 }
986 992
987 bool GrGLCaps::bgraIsInternalFormat() const { 993 bool GrGLCaps::bgraIsInternalFormat() const {
988 return fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = = GR_GL_BGRA; 994 return fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = = GR_GL_BGRA;
989 } 995 }
990 996
997 bool GrGLCaps::getTexImageFormats(GrPixelConfig surfaceConfig, GrPixelConfig ext ernalConfig,
998 GrGLenum* internalFormat, GrGLenum* externalFo rmat,
999 GrGLenum* externalType) const {
1000 if (!this->getExternalFormat(surfaceConfig, externalConfig, kTexImage_Extern alFormatUsage,
1001 externalFormat, externalType)) {
1002 return false;
1003 }
1004 *internalFormat = fConfigTable[surfaceConfig].fFormats.fInternalFormatTexIma ge;
1005 return true;
1006 }
1007
1008 bool GrGLCaps::getCompressedTexImageFormats(GrPixelConfig surfaceConfig,
1009 GrGLenum* internalFormat) const {
1010 if (!GrPixelConfigIsCompressed(surfaceConfig)) {
1011 return false;
1012 }
1013 *internalFormat = fConfigTable[surfaceConfig].fFormats.fInternalFormatTexIma ge;
1014 return true;
1015 }
1016
1017 bool GrGLCaps::getReadPixelsFormat(GrPixelConfig surfaceConfig, GrPixelConfig ex ternalConfig,
1018 GrGLenum* externalFormat, GrGLenum* externalT ype) const {
1019 if (!this->getExternalFormat(surfaceConfig, externalConfig, kOther_ExternalF ormatUsage,
1020 externalFormat, externalType)) {
1021 return false;
1022 }
1023 return true;
1024 }
1025
1026 bool GrGLCaps::getRenderbufferFormat(GrPixelConfig config, GrGLenum* internalFor mat) const {
1027 if (!GrPixelConfigIsCompressed(config)) {
1028 return false;
1029 }
1030 *internalFormat = fConfigTable[config].fFormats.fInternalFormatRenderbuffer;
1031 return true;
1032 }
1033
1034 bool GrGLCaps::getExternalFormat(GrPixelConfig surfaceConfig, GrPixelConfig memo ryConfig,
1035 ExternalFormatUsage usage, GrGLenum* externalFo rmat,
1036 GrGLenum* externalType) const {
1037 SkASSERT(externalFormat && externalType);
1038 if (GrPixelConfigIsCompressed(memoryConfig) || GrPixelConfigIsCompressed(mem oryConfig)) {
1039 return false;
1040 }
1041
1042 bool surfaceIsAlphaOnly = GrPixelConfigIsAlphaOnly(surfaceConfig);
1043 bool memoryIsAlphaOnly = GrPixelConfigIsAlphaOnly(memoryConfig);
1044
1045 // We don't currently support moving RGBA data into and out of ALPHA surface s. It could be
1046 // made to work in many cases using glPixelStore and what not but is not nee ded currently.
1047 if (surfaceIsAlphaOnly && !memoryIsAlphaOnly) {
1048 return false;
1049 }
1050
1051 *externalFormat = fConfigTable[memoryConfig].fFormats.fExternalFormat[usage] ;
1052 *externalType = fConfigTable[memoryConfig].fFormats.fExternalType;
1053
1054 // When GL_RED is supported as a texture format, our alpha-only textures are stored using
1055 // GL_RED and we swizzle in order to map all components to 'r'. However, in this case the
1056 // surface is not alpha-only and we want alpha to really mean the alpha comp onent of the
1057 // texture, not the red component.
1058 if (memoryIsAlphaOnly && !surfaceIsAlphaOnly) {
1059 if (fTextureRedSupport) {
1060 SkASSERT(GR_GL_RED == *externalFormat);
1061 *externalFormat = GR_GL_ALPHA;
1062 }
1063 }
1064
1065 return true;
1066 }
1067
991 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa ce* gli, 1068 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa ce* gli,
992 GrGLSLCaps* glslCaps) { 1069 GrGLSLCaps* glslCaps) {
993 /* 1070 /*
994 Comments on renderability of configs on various GL versions. 1071 Comments on renderability of configs on various GL versions.
995 OpenGL < 3.0: 1072 OpenGL < 3.0:
996 no built in support for render targets. 1073 no built in support for render targets.
997 GL_EXT_framebuffer_object adds possible support for any sized format with base internal 1074 GL_EXT_framebuffer_object adds possible support for any sized format with base internal
998 format RGB, RGBA and NV float formats we don't use. 1075 format RGB, RGBA and NV float formats we don't use.
999 This is the following: 1076 This is the following:
1000 R3_G3_B2, RGB4, RGB5, RGB8, RGB10, RGB12, RGB16, RGBA2, RGBA4, R GB5_A1, RGBA8 1077 R3_G3_B2, RGB4, RGB5, RGB8, RGB10, RGB12, RGB16, RGBA2, RGBA4, R GB5_A1, RGBA8
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 uint32_t allRenderFlags = ConfigInfo::kRenderable_Flag; 1139 uint32_t allRenderFlags = ConfigInfo::kRenderable_Flag;
1063 if (kNone_MSFBOType != fMSFBOType) { 1140 if (kNone_MSFBOType != fMSFBOType) {
1064 allRenderFlags |= ConfigInfo::kRenderableWithMSAA_Flag; 1141 allRenderFlags |= ConfigInfo::kRenderableWithMSAA_Flag;
1065 } 1142 }
1066 1143
1067 GrGLStandard standard = ctxInfo.standard(); 1144 GrGLStandard standard = ctxInfo.standard();
1068 GrGLVersion version = ctxInfo.version(); 1145 GrGLVersion version = ctxInfo.version();
1069 1146
1070 fConfigTable[kUnknown_GrPixelConfig].fFormats.fBaseInternalFormat = 0; 1147 fConfigTable[kUnknown_GrPixelConfig].fFormats.fBaseInternalFormat = 0;
1071 fConfigTable[kUnknown_GrPixelConfig].fFormats.fSizedInternalFormat = 0; 1148 fConfigTable[kUnknown_GrPixelConfig].fFormats.fSizedInternalFormat = 0;
1072 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalFormat = 0; 1149 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalFormat[kOther_Externa lFormatUsage] = 0;
1073 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalType = 0; 1150 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalType = 0;
1074 fConfigTable[kUnknown_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1151 fConfigTable[kUnknown_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType;
1075 fConfigTable[kUnknown_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); 1152 fConfigTable[kUnknown_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1076 1153
1077 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA; 1154 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA;
1078 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA8; 1155 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA8;
1079 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA ; 1156 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kOther_Exter nalFormatUsage] =
1157 GR_GL_RGBA;
1080 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN ED_BYTE; 1158 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN ED_BYTE;
1081 fConfigTable[kRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType; 1159 fConfigTable[kRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType;
1082 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Fla g; 1160 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Fla g;
1083 if (kGL_GrGLStandard == standard) { 1161 if (kGL_GrGLStandard == standard) {
1084 // We require some form of FBO support and all GLs with FBO support can render to RGBA8 1162 // We require some form of FBO support and all GLs with FBO support can render to RGBA8
1085 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags |= allRenderFlags; 1163 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags |= allRenderFlags;
1086 } else { 1164 } else {
1087 if (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_OES_rgb8_rgba8 ") || 1165 if (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_OES_rgb8_rgba8 ") ||
1088 ctxInfo.hasExtension("GL_ARM_rgba8")) { 1166 ctxInfo.hasExtension("GL_ARM_rgba8")) {
1089 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags |= allRenderFlags; 1167 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags |= allRenderFlags;
1090 } 1168 }
1091 } 1169 }
1092 fConfigTable[kRGBA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); 1170 fConfigTable[kRGBA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1093 1171
1094 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalFormat= GR_GL_BGRA; 1172 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalFormat[kOther_Exter nalFormatUsage] =
1173 GR_GL_BGRA;
1095 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG NED_BYTE; 1174 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG NED_BYTE;
1096 fConfigTable[kBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType; 1175 fConfigTable[kBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType;
1097 if (kGL_GrGLStandard == standard) { 1176 if (kGL_GrGLStandard == standard) {
1098 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR _GL_RGBA; 1177 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR _GL_RGBA;
1099 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = G R_GL_RGBA8; 1178 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = G R_GL_RGBA8;
1100 if (version >= GR_GL_VER(1, 2) || ctxInfo.hasExtension("GL_EXT_bgra")) { 1179 if (version >= GR_GL_VER(1, 2) || ctxInfo.hasExtension("GL_EXT_bgra")) {
1101 // Since the internal format is RGBA8, it is also renderable. 1180 // Since the internal format is RGBA8, it is also renderable.
1102 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTexture able_Flag | 1181 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTexture able_Flag |
1103 allRenderFlags; 1182 allRenderFlags;
1104 } 1183 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 srgbSupport = kPowerVRRogue_GrGLRenderer != ctxInfo.renderer() && 1224 srgbSupport = kPowerVRRogue_GrGLRenderer != ctxInfo.renderer() &&
1146 (ctxInfo.version() >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT _sRGB")); 1225 (ctxInfo.version() >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT _sRGB"));
1147 // ES through 3.1 requires EXT_srgb_write_control to support toggling 1226 // ES through 3.1 requires EXT_srgb_write_control to support toggling
1148 // sRGB writing for destinations. 1227 // sRGB writing for destinations.
1149 fSRGBWriteControl = ctxInfo.hasExtension("GL_EXT_sRGB_write_control"); 1228 fSRGBWriteControl = ctxInfo.hasExtension("GL_EXT_sRGB_write_control");
1150 } 1229 }
1151 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL _SRGB_ALPHA; 1230 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL _SRGB_ALPHA;
1152 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G L_SRGB8_ALPHA8; 1231 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G L_SRGB8_ALPHA8;
1153 // GL does not do srgb<->rgb conversions when transferring between cpu and g pu. Thus, the 1232 // GL does not do srgb<->rgb conversions when transferring between cpu and g pu. Thus, the
1154 // external format is GL_RGBA. See below for note about ES2.0 and glTex[Sub] Image. 1233 // external format is GL_RGBA. See below for note about ES2.0 and glTex[Sub] Image.
1155 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB A; 1234 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kOther_Exte rnalFormatUsage] =
1235 GR_GL_RGBA;
1156 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG NED_BYTE; 1236 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG NED_BYTE;
1157 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_ FormatType; 1237 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_ FormatType;
1158 if (srgbSupport) { 1238 if (srgbSupport) {
1159 fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag | 1239 fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag |
1160 allRenderFlags; 1240 allRenderFlags;
1161 } 1241 }
1162 fConfigTable[kSRGBA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); 1242 fConfigTable[kSRGBA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1163 1243
1164 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RG B; 1244 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RG B;
1165 if (this->ES2CompatibilitySupport()) { 1245 if (this->ES2CompatibilitySupport()) {
1166 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_RGB565; 1246 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_RGB565;
1167 } else { 1247 } else {
1168 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_RGB5; 1248 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_RGB5;
1169 } 1249 }
1170 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB; 1250 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalFormat[kOther_Externa lFormatUsage] =
1251 GR_GL_RGB;
1171 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED _SHORT_5_6_5; 1252 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED _SHORT_5_6_5;
1172 fConfigTable[kRGB_565_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1253 fConfigTable[kRGB_565_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType;
1173 fConfigTable[kRGB_565_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag; 1254 fConfigTable[kRGB_565_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
1174 if (kGL_GrGLStandard == standard) { 1255 if (kGL_GrGLStandard == standard) {
1175 if (version >= GR_GL_VER(4, 2) || ctxInfo.hasExtension("GL_ES2_compatibi lity")) { 1256 if (version >= GR_GL_VER(4, 2) || ctxInfo.hasExtension("GL_ES2_compatibi lity")) {
1176 fConfigTable[kRGB_565_GrPixelConfig].fFlags |= allRenderFlags; 1257 fConfigTable[kRGB_565_GrPixelConfig].fFlags |= allRenderFlags;
1177 } 1258 }
1178 } else { 1259 } else {
1179 fConfigTable[kRGB_565_GrPixelConfig].fFlags |= allRenderFlags; 1260 fConfigTable[kRGB_565_GrPixelConfig].fFlags |= allRenderFlags;
1180 } 1261 }
1181 fConfigTable[kRGB_565_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); 1262 fConfigTable[kRGB_565_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1182 1263
1183 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA; 1264 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA;
1184 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA4; 1265 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA4;
1185 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA ; 1266 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalFormat[kOther_Exter nalFormatUsage] =
1267 GR_GL_RGBA;
1186 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN ED_SHORT_4_4_4_4; 1268 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN ED_SHORT_4_4_4_4;
1187 fConfigTable[kRGBA_4444_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType; 1269 fConfigTable[kRGBA_4444_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType;
1188 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Fla g; 1270 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Fla g;
1189 if (kGL_GrGLStandard == standard) { 1271 if (kGL_GrGLStandard == standard) {
1190 if (version >= GR_GL_VER(4, 2)) { 1272 if (version >= GR_GL_VER(4, 2)) {
1191 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags |= allRenderFlags; 1273 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags |= allRenderFlags;
1192 } 1274 }
1193 } else { 1275 } else {
1194 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags |= allRenderFlags; 1276 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags |= allRenderFlags;
1195 } 1277 }
1196 fConfigTable[kRGBA_4444_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); 1278 fConfigTable[kRGBA_4444_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1197 1279
1198 if (this->textureRedSupport()) { 1280 if (this->textureRedSupport()) {
1199 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G L_RED; 1281 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G L_RED;
1200 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_R8; 1282 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_R8;
1201 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RE D; 1283 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat[kOther_Ext ernalFormatUsage] =
1284 GR_GL_RED;
1202 fConfigTable[kAlpha_8_GrPixelConfig].fSwizzle = GrSwizzle::RRRR(); 1285 fConfigTable[kAlpha_8_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
1203 } else { 1286 } else {
1204 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G L_ALPHA; 1287 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G L_ALPHA;
1205 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_ALPHA8; 1288 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_ALPHA8;
1206 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_AL PHA; 1289 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat[kOther_Ext ernalFormatUsage] =
1290 GR_GL_ALPHA;
1207 fConfigTable[kAlpha_8_GrPixelConfig].fSwizzle = GrSwizzle::AAAA(); 1291 fConfigTable[kAlpha_8_GrPixelConfig].fSwizzle = GrSwizzle::AAAA();
1208 } 1292 }
1209 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED _BYTE; 1293 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED _BYTE;
1210 fConfigTable[kAlpha_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1294 fConfigTable[kAlpha_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType;
1211 fConfigTable[kAlpha_8_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag; 1295 fConfigTable[kAlpha_8_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
1212 if (this->textureRedSupport() || kDesktop_ARB_MSFBOType == this->msFBOType() ) { 1296 if (this->textureRedSupport() || kDesktop_ARB_MSFBOType == this->msFBOType() ) {
1213 // desktop ARB extension/3.0+ supports ALPHA8 as renderable. 1297 // desktop ARB extension/3.0+ supports ALPHA8 as renderable.
1214 // Core profile removes ALPHA8 support, but we should have chosen R8 in that case. 1298 // Core profile removes ALPHA8 support, but we should have chosen R8 in that case.
1215 fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= allRenderFlags; 1299 fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= allRenderFlags;
1216 } 1300 }
(...skipping 24 matching lines...) Expand all
1241 } 1325 }
1242 if (ctxInfo.hasExtension("GL_OES_texture_half_float_linear") && 1326 if (ctxInfo.hasExtension("GL_OES_texture_half_float_linear") &&
1243 ctxInfo.hasExtension("GL_OES_texture_half_float")) { 1327 ctxInfo.hasExtension("GL_OES_texture_half_float")) {
1244 hasHalfFPTextures = true; 1328 hasHalfFPTextures = true;
1245 } 1329 }
1246 } 1330 }
1247 } 1331 }
1248 1332
1249 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL _RGBA; 1333 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL _RGBA;
1250 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G L_RGBA32F; 1334 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G L_RGBA32F;
1251 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB A; 1335 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalFormat[kOther_Exte rnalFormatUsage] =
1336 GR_GL_RGBA;
1252 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalType = GR_GL_FLOAT ; 1337 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalType = GR_GL_FLOAT ;
1253 fConfigTable[kRGBA_float_GrPixelConfig].fFormatType = kFloat_FormatType; 1338 fConfigTable[kRGBA_float_GrPixelConfig].fFormatType = kFloat_FormatType;
1254 if (hasFPTextures) { 1339 if (hasFPTextures) {
1255 fConfigTable[kRGBA_float_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag; 1340 fConfigTable[kRGBA_float_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag;
1256 // For now we only enable rendering to float on desktop, because on ES w e'd have to solve 1341 // For now we only enable rendering to float on desktop, because on ES w e'd have to solve
1257 // many precision issues and no clients actually want this yet. 1342 // many precision issues and no clients actually want this yet.
1258 if (kGL_GrGLStandard == standard /* || version >= GR_GL_VER(3,2) || 1343 if (kGL_GrGLStandard == standard /* || version >= GR_GL_VER(3,2) ||
1259 ctxInfo.hasExtension("GL_EXT_color_buffer_float")*/) { 1344 ctxInfo.hasExtension("GL_EXT_color_buffer_float")*/) {
1260 fConfigTable[kRGBA_float_GrPixelConfig].fFlags |= fpRenderFlags; 1345 fConfigTable[kRGBA_float_GrPixelConfig].fFlags |= fpRenderFlags;
1261 } 1346 }
1262 } 1347 }
1263 fConfigTable[kRGBA_float_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); 1348 fConfigTable[kRGBA_float_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1264 1349
1265 if (this->textureRedSupport()) { 1350 if (this->textureRedSupport()) {
1266 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G R_GL_RED; 1351 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G R_GL_RED;
1267 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_R16F; 1352 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_R16F;
1268 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL _RED; 1353 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat[kOther_ ExternalFormatUsage]
1354 = GR_GL_RED;
1269 fConfigTable[kAlpha_half_GrPixelConfig].fSwizzle = GrSwizzle::RRRR(); 1355 fConfigTable[kAlpha_half_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
1270 } else { 1356 } else {
1271 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G R_GL_ALPHA; 1357 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G R_GL_ALPHA;
1272 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_ALPHA16F; 1358 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_ALPHA16F;
1273 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL _ALPHA; 1359 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat[kOther_ ExternalFormatUsage]
1360 = GR_GL_ALPHA;
1274 fConfigTable[kAlpha_half_GrPixelConfig].fSwizzle = GrSwizzle::AAAA(); 1361 fConfigTable[kAlpha_half_GrPixelConfig].fSwizzle = GrSwizzle::AAAA();
1275 } 1362 }
1276 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER (3, 0)) { 1363 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER (3, 0)) {
1277 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H ALF_FLOAT; 1364 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H ALF_FLOAT;
1278 } else { 1365 } else {
1279 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H ALF_FLOAT_OES; 1366 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H ALF_FLOAT_OES;
1280 } 1367 }
1281 fConfigTable[kAlpha_half_GrPixelConfig].fFormatType = kFloat_FormatType; 1368 fConfigTable[kAlpha_half_GrPixelConfig].fFormatType = kFloat_FormatType;
1282 if (hasHalfFPTextures) { 1369 if (hasHalfFPTextures) {
1283 fConfigTable[kAlpha_half_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag; 1370 fConfigTable[kAlpha_half_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag;
1284 // ES requires either 3.2 or the combination of EXT_color_buffer_half_fl oat and support for 1371 // ES requires either 3.2 or the combination of EXT_color_buffer_half_fl oat and support for
1285 // GL_RED internal format. 1372 // GL_RED internal format.
1286 if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3,2) || 1373 if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3,2) ||
1287 (this->textureRedSupport() && 1374 (this->textureRedSupport() &&
1288 ctxInfo.hasExtension("GL_EXT_color_buffer_half_float"))) { 1375 ctxInfo.hasExtension("GL_EXT_color_buffer_half_float"))) {
1289 fConfigTable[kAlpha_half_GrPixelConfig].fFlags |= fpRenderFlags; 1376 fConfigTable[kAlpha_half_GrPixelConfig].fFlags |= fpRenderFlags;
1290 } 1377 }
1291 } 1378 }
1292 1379
1293 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA; 1380 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA;
1294 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA16F; 1381 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA16F;
1295 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA ; 1382 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalFormat[kOther_Exter nalFormatUsage] =
1383 GR_GL_RGBA;
1296 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER (3, 0)) { 1384 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER (3, 0)) {
1297 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA LF_FLOAT; 1385 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA LF_FLOAT;
1298 } else { 1386 } else {
1299 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA LF_FLOAT_OES; 1387 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA LF_FLOAT_OES;
1300 } 1388 }
1301 fConfigTable[kRGBA_half_GrPixelConfig].fFormatType = kFloat_FormatType; 1389 fConfigTable[kRGBA_half_GrPixelConfig].fFormatType = kFloat_FormatType;
1302 if (hasHalfFPTextures) { 1390 if (hasHalfFPTextures) {
1303 fConfigTable[kRGBA_half_GrPixelConfig].fFlags = ConfigInfo::kTextureable _Flag; 1391 fConfigTable[kRGBA_half_GrPixelConfig].fFlags = ConfigInfo::kTextureable _Flag;
1304 // ES requires 3.2 or EXT_color_buffer_half_float. 1392 // ES requires 3.2 or EXT_color_buffer_half_float.
1305 if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3,2) || 1393 if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3,2) ||
1306 ctxInfo.hasExtension("GL_EXT_color_buffer_half_float")) { 1394 ctxInfo.hasExtension("GL_EXT_color_buffer_half_float")) {
1307 fConfigTable[kRGBA_half_GrPixelConfig].fFlags |= fpRenderFlags; 1395 fConfigTable[kRGBA_half_GrPixelConfig].fFlags |= fpRenderFlags;
1308 } 1396 }
1309 } 1397 }
1310 fConfigTable[kRGBA_half_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); 1398 fConfigTable[kRGBA_half_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1311 1399
1312 // Compressed texture support 1400 // Compressed texture support
1313 1401
1314 // glCompressedTexImage2D is available on all OpenGL ES devices. It is avail able on standard 1402 // glCompressedTexImage2D is available on all OpenGL ES devices. It is avail able on standard
1315 // OpenGL after version 1.3. We'll assume at least that level of OpenGL supp ort. 1403 // OpenGL after version 1.3. We'll assume at least that level of OpenGL supp ort.
1316 1404
1317 // TODO: Fix command buffer bindings and remove this. 1405 // TODO: Fix command buffer bindings and remove this.
1318 fCompressedTexSubImageSupport = SkToBool(gli->fFunctions.fCompressedTexSubIm age2D); 1406 fCompressedTexSubImageSupport = SkToBool(gli->fFunctions.fCompressedTexSubIm age2D);
1319 1407
1320 // No sized/unsized internal format distinction for compressed formats, no e xternal format. 1408 // No sized/unsized internal format distinction for compressed formats, no e xternal format.
1321 // Below we set the external formats and types to 0. 1409 // Below we set the external formats and types to 0.
1322 1410
1323 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_PA LETTE8_RGBA8; 1411 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_PA LETTE8_RGBA8;
1324 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_P ALETTE8_RGBA8; 1412 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_P ALETTE8_RGBA8;
1325 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalFormat = 0; 1413 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalFormat[kOther_Externa lFormatUsage] = 0;
1326 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalType = 0; 1414 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalType = 0;
1327 fConfigTable[kIndex_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1415 fConfigTable[kIndex_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType;
1328 // Disable this for now, while we investigate https://bug.skia.org/4333 1416 // Disable this for now, while we investigate https://bug.skia.org/4333
1329 if (false) { 1417 if (false) {
1330 // Check for 8-bit palette.. 1418 // Check for 8-bit palette..
1331 GrGLint numFormats; 1419 GrGLint numFormats;
1332 GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats ); 1420 GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats );
1333 if (numFormats) { 1421 if (numFormats) {
1334 SkAutoSTMalloc<10, GrGLint> formats(numFormats); 1422 SkAutoSTMalloc<10, GrGLint> formats(numFormats);
1335 GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats); 1423 GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats);
(...skipping 24 matching lines...) Expand all
1360 GR_GL_COMPRESSED_RED_RGTC1; 1448 GR_GL_COMPRESSED_RED_RGTC1;
1361 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = 1449 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat =
1362 GR_GL_COMPRESSED_RED_RGTC1; 1450 GR_GL_COMPRESSED_RED_RGTC1;
1363 } else if (ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture")) { 1451 } else if (ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture")) {
1364 fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag ; 1452 fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag ;
1365 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_C OMPRESSED_3DC_X; 1453 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_C OMPRESSED_3DC_X;
1366 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = 1454 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat =
1367 GR_GL_COMPRESSED_3DC_X; 1455 GR_GL_COMPRESSED_3DC_X;
1368 1456
1369 } 1457 }
1370 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalFormat = 0; 1458 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFo rmatUsage] = 0;
1371 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalType = 0; 1459 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalType = 0;
1372 fConfigTable[kLATC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format Type; 1460 fConfigTable[kLATC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format Type;
1373 fConfigTable[kLATC_GrPixelConfig].fSwizzle = GrSwizzle::RRRR(); 1461 fConfigTable[kLATC_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
1374 1462
1375 fConfigTable[kETC1_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPR ESSED_ETC1_RGB8; 1463 fConfigTable[kETC1_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPR ESSED_ETC1_RGB8;
1376 fConfigTable[kETC1_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_COMP RESSED_ETC1_RGB8; 1464 fConfigTable[kETC1_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_COMP RESSED_ETC1_RGB8;
1377 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalFormat = 0; 1465 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFo rmatUsage] = 0;
1378 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalType = 0; 1466 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalType = 0;
1379 fConfigTable[kETC1_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format Type; 1467 fConfigTable[kETC1_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format Type;
1380 if (kGL_GrGLStandard == standard) { 1468 if (kGL_GrGLStandard == standard) {
1381 if (version >= GR_GL_VER(4, 3) || ctxInfo.hasExtension("GL_ARB_ES3_compa tibility")) { 1469 if (version >= GR_GL_VER(4, 3) || ctxInfo.hasExtension("GL_ARB_ES3_compa tibility")) {
1382 fConfigTable[kETC1_GrPixelConfig].fFlags = ConfigInfo::kTextureable_ Flag; 1470 fConfigTable[kETC1_GrPixelConfig].fFlags = ConfigInfo::kTextureable_ Flag;
1383 } 1471 }
1384 } else { 1472 } else {
1385 if (version >= GR_GL_VER(3, 0) || 1473 if (version >= GR_GL_VER(3, 0) ||
1386 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") || 1474 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") ||
1387 // ETC2 is a superset of ETC1, so we can just check for that, too. 1475 // ETC2 is a superset of ETC1, so we can just check for that, too.
1388 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") && 1476 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") &&
1389 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))) { 1477 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))) {
1390 fConfigTable[kETC1_GrPixelConfig].fFlags = ConfigInfo::kTextureable_ Flag; 1478 fConfigTable[kETC1_GrPixelConfig].fFlags = ConfigInfo::kTextureable_ Flag;
1391 } 1479 }
1392 } 1480 }
1393 fConfigTable[kETC1_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); 1481 fConfigTable[kETC1_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1394 1482
1395 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_CO MPRESSED_R11_EAC; 1483 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_CO MPRESSED_R11_EAC;
1396 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_C OMPRESSED_R11_EAC; 1484 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_C OMPRESSED_R11_EAC;
1397 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalFormat = 0; 1485 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalFormat[kOther_Externa lFormatUsage] = 0;
1398 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalType = 0; 1486 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalType = 0;
1399 fConfigTable[kR11_EAC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1487 fConfigTable[kR11_EAC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType;
1400 // Check for R11_EAC. We don't support R11_EAC on desktop, as most cards def ault to 1488 // Check for R11_EAC. We don't support R11_EAC on desktop, as most cards def ault to
1401 // decompressing the textures in the driver, and is generally slower. 1489 // decompressing the textures in the driver, and is generally slower.
1402 if (kGLES_GrGLStandard == standard && version >= GR_GL_VER(3,0)) { 1490 if (kGLES_GrGLStandard == standard && version >= GR_GL_VER(3,0)) {
1403 fConfigTable[kR11_EAC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_F lag; 1491 fConfigTable[kR11_EAC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_F lag;
1404 } 1492 }
1405 fConfigTable[kR11_EAC_GrPixelConfig].fSwizzle = GrSwizzle::RRRR(); 1493 fConfigTable[kR11_EAC_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
1406 1494
1407 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fBaseInternalFormat = 1495 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fBaseInternalFormat =
1408 GR_GL_COMPRESSED_RGBA_ASTC_12x12; 1496 GR_GL_COMPRESSED_RGBA_ASTC_12x12;
1409 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fSizedInternalFormat = 1497 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fSizedInternalFormat =
1410 GR_GL_COMPRESSED_RGBA_ASTC_12x12; 1498 GR_GL_COMPRESSED_RGBA_ASTC_12x12;
1411 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalFormat = 0; 1499 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalFormat[kOther_Exte rnalFormatUsage] =
1500 0;
1412 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalType = 0; 1501 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalType = 0;
1413 fConfigTable[kASTC_12x12_GrPixelConfig].fFormatType = kNormalizedFixedPoint_ FormatType; 1502 fConfigTable[kASTC_12x12_GrPixelConfig].fFormatType = kNormalizedFixedPoint_ FormatType;
1414 if (ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") || 1503 if (ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") ||
1415 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") || 1504 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") ||
1416 ctxInfo.hasExtension("GL_OES_texture_compression_astc")) { 1505 ctxInfo.hasExtension("GL_OES_texture_compression_astc")) {
1417 fConfigTable[kASTC_12x12_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag; 1506 fConfigTable[kASTC_12x12_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag;
1418 } 1507 }
1419 fConfigTable[kASTC_12x12_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); 1508 fConfigTable[kASTC_12x12_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1420 1509
1421 // Bulk populate the texture internal/external formats here and then deal wi th exceptions below. 1510 // Bulk populate the texture internal/external formats here and then deal wi th exceptions below.
1422 1511
1423 // ES 2.0 requires that the internal/external formats match. 1512 // ES 2.0 requires that the internal/external formats match.
1424 bool useSizedFormats = (kGL_GrGLStandard == ctxInfo.standard() || 1513 bool useSizedTexFormats = (kGL_GrGLStandard == ctxInfo.standard() ||
1425 ctxInfo.version() >= GR_GL_VER(3,0)); 1514 ctxInfo.version() >= GR_GL_VER(3,0));
1515 // All ES versions (thus far) require sized internal formats for render buff ers.
1516 // TODO: Always use sized internal format?
1517 bool useSizedRbFormats = kGLES_GrGLStandard == ctxInfo.standard();
1518
1426 for (int i = 0; i < kGrPixelConfigCnt; ++i) { 1519 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
1427 // Almost always we want to pass fExternalFormat as the <format> param t o glTex[Sub]Image. 1520 // Almost always we want to pass fExternalFormat[kOther_ExternalFormatUs age] as the <format>
1428 fConfigTable[i].fFormats.fExternalFormatForTexImage = 1521 // param to glTex[Sub]Image.
1429 fConfigTable[i].fFormats.fExternalFormat; 1522 fConfigTable[i].fFormats.fExternalFormat[kTexImage_ExternalFormatUsage] =
1430 fConfigTable[i].fFormats.fInternalFormatTexImage = useSizedFormats ? 1523 fConfigTable[i].fFormats.fExternalFormat[kOther_ExternalFormatUsage] ;
1524 fConfigTable[i].fFormats.fInternalFormatTexImage = useSizedTexFormats ?
1525 fConfigTable[i].fFormats.fSizedInternalFormat :
1526 fConfigTable[i].fFormats.fBaseInternalFormat;
1527 fConfigTable[i].fFormats.fInternalFormatRenderbuffer = useSizedRbFormats ?
1431 fConfigTable[i].fFormats.fSizedInternalFormat : 1528 fConfigTable[i].fFormats.fSizedInternalFormat :
1432 fConfigTable[i].fFormats.fBaseInternalFormat; 1529 fConfigTable[i].fFormats.fBaseInternalFormat;
1433 } 1530 }
1434 // OpenGL ES 2.0 + GL_EXT_sRGB allows GL_SRGB_ALPHA to be specified as the < format> 1531 // OpenGL ES 2.0 + GL_EXT_sRGB allows GL_SRGB_ALPHA to be specified as the < format>
1435 // param to Tex(Sub)Image. ES 2.0 requires the <internalFormat> and <format> params to match. 1532 // param to Tex(Sub)Image. ES 2.0 requires the <internalFormat> and <format> params to match.
1436 // Thus, on ES 2.0 we will use GL_SRGB_ALPHA as the <format> param. 1533 // Thus, on ES 2.0 we will use GL_SRGB_ALPHA as the <format> param.
1437 // On OpenGL and ES 3.0+ GL_SRGB_ALPHA does not work for the <format> param to glTexImage. 1534 // On OpenGL and ES 3.0+ GL_SRGB_ALPHA does not work for the <format> param to glTexImage.
1438 if (ctxInfo.standard() == kGLES_GrGLStandard && ctxInfo.version() == GR_GL_V ER(2,0)) { 1535 if (ctxInfo.standard() == kGLES_GrGLStandard && ctxInfo.version() == GR_GL_V ER(2,0)) {
1439 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormatForTexIm age = 1536 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kTexIma ge_ExternalFormatUsage] =
1440 GR_GL_SRGB_ALPHA; 1537 GR_GL_SRGB_ALPHA;
1441 } 1538 }
1442 1539
1443 // If BGRA is supported as an internal format it must always be specified to glTex[Sub]Image 1540 // If BGRA is supported as an internal format it must always be specified to glTex[Sub]Image
1444 // as a base format. 1541 // as a base format.
1445 // GL_EXT_texture_format_BGRA8888: 1542 // GL_EXT_texture_format_BGRA8888:
1446 // This extension GL_BGRA as an unsized internal format. However, it is written against ES 1543 // This extension GL_BGRA as an unsized internal format. However, it is written against ES
1447 // 2.0 and therefore doesn't define a value for GL_BGRA8 as ES 2.0 uses unsized internal 1544 // 2.0 and therefore doesn't define a value for GL_BGRA8 as ES 2.0 uses unsized internal
1448 // formats. 1545 // formats.
1449 // GL_APPLE_texture_format_BGRA8888: 1546 // GL_APPLE_texture_format_BGRA8888:
1450 // ES 2.0: the extension makes BGRA an external format but not an intern al format. 1547 // ES 2.0: the extension makes BGRA an external format but not an intern al format.
1451 // ES 3.0: the extension explicitly states GL_BGRA8 is not a valid inter nal format for 1548 // ES 3.0: the extension explicitly states GL_BGRA8 is not a valid inter nal format for
1452 // glTexImage (just for glTexStorage). 1549 // glTexImage (just for glTexStorage).
1453 if (useSizedFormats && this->bgraIsInternalFormat()) { 1550 if (useSizedTexFormats && this->bgraIsInternalFormat()) {
1454 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fInternalFormatTexImage = GR_GL_BGRA; 1551 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fInternalFormatTexImage = GR_GL_BGRA;
1455 } 1552 }
1456 1553
1457 // If we don't have texture swizzle support then the shader generator must i nsert the 1554 // If we don't have texture swizzle support then the shader generator must i nsert the
1458 // swizzle into shader code. 1555 // swizzle into shader code.
1459 if (!this->textureSwizzleSupport()) { 1556 if (!this->textureSwizzleSupport()) {
1460 for (int i = 0; i < kGrPixelConfigCnt; ++i) { 1557 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
1461 glslCaps->fConfigTextureSwizzle[i] = fConfigTable[i].fSwizzle; 1558 glslCaps->fConfigTextureSwizzle[i] = fConfigTable[i].fSwizzle;
1462 } 1559 }
1463 } 1560 }
1464 1561
1562 if (this->textureRedSupport()) {
1563 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
1564 GrPixelConfig config = static_cast<GrPixelConfig>(i);
1565 if (GrPixelConfigIsAlphaOnly(config) &&
1566 fConfigTable[i].fFormats.fBaseInternalFormat == GR_GL_RED) {
1567 glslCaps->fConfigOutputSwizzle[i] = GrSwizzle::AAAA();
1568 }
1569 }
1570 }
1465 #ifdef SK_DEBUG 1571 #ifdef SK_DEBUG
1466 // Make sure we initialized everything. 1572 // Make sure we initialized everything.
1467 ConfigFormats defaultEntry; 1573 ConfigInfo defaultEntry;
1468 for (int i = 0; i < kGrPixelConfigCnt; ++i) { 1574 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
1469 SkASSERT(defaultEntry.fBaseInternalFormat != fConfigTable[i].fFormats.fB aseInternalFormat); 1575 SkASSERT(defaultEntry.fFormats.fBaseInternalFormat !=
1470 SkASSERT(defaultEntry.fSizedInternalFormat != 1576 fConfigTable[i].fFormats.fBaseInternalFormat);
1577 SkASSERT(defaultEntry.fFormats.fSizedInternalFormat !=
1471 fConfigTable[i].fFormats.fSizedInternalFormat); 1578 fConfigTable[i].fFormats.fSizedInternalFormat);
1472 SkASSERT(defaultEntry.fExternalFormat != fConfigTable[i].fFormats.fExter nalFormat); 1579 for (int j = 0; j < kExternalFormatUsageCnt; ++j) {
1473 SkASSERT(defaultEntry.fExternalType != fConfigTable[i].fFormats.fExterna lType); 1580 SkASSERT(defaultEntry.fFormats.fExternalFormat[j] !=
1581 fConfigTable[i].fFormats.fExternalFormat[j]);
1582 }
1583 SkASSERT(defaultEntry.fFormats.fExternalType != fConfigTable[i].fFormats .fExternalType);
1474 } 1584 }
1475 #endif 1585 #endif
1476 } 1586 }
1477 1587
1478 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} 1588 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {}
1479
1480
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.h ('k') | src/gpu/gl/GrGLGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698