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

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

Issue 1580003002: Hide formats in GrGLCaps and use specific getters for different GL functions. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixes 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.cpp » ('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 return true;
1055 }
1056
991 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa ce* gli, 1057 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa ce* gli,
992 GrGLSLCaps* glslCaps) { 1058 GrGLSLCaps* glslCaps) {
993 /* 1059 /*
994 Comments on renderability of configs on various GL versions. 1060 Comments on renderability of configs on various GL versions.
995 OpenGL < 3.0: 1061 OpenGL < 3.0:
996 no built in support for render targets. 1062 no built in support for render targets.
997 GL_EXT_framebuffer_object adds possible support for any sized format with base internal 1063 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. 1064 format RGB, RGBA and NV float formats we don't use.
999 This is the following: 1065 This is the following:
1000 R3_G3_B2, RGB4, RGB5, RGB8, RGB10, RGB12, RGB16, RGBA2, RGBA4, R GB5_A1, RGBA8 1066 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; 1128 uint32_t allRenderFlags = ConfigInfo::kRenderable_Flag;
1063 if (kNone_MSFBOType != fMSFBOType) { 1129 if (kNone_MSFBOType != fMSFBOType) {
1064 allRenderFlags |= ConfigInfo::kRenderableWithMSAA_Flag; 1130 allRenderFlags |= ConfigInfo::kRenderableWithMSAA_Flag;
1065 } 1131 }
1066 1132
1067 GrGLStandard standard = ctxInfo.standard(); 1133 GrGLStandard standard = ctxInfo.standard();
1068 GrGLVersion version = ctxInfo.version(); 1134 GrGLVersion version = ctxInfo.version();
1069 1135
1070 fConfigTable[kUnknown_GrPixelConfig].fFormats.fBaseInternalFormat = 0; 1136 fConfigTable[kUnknown_GrPixelConfig].fFormats.fBaseInternalFormat = 0;
1071 fConfigTable[kUnknown_GrPixelConfig].fFormats.fSizedInternalFormat = 0; 1137 fConfigTable[kUnknown_GrPixelConfig].fFormats.fSizedInternalFormat = 0;
1072 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalFormat = 0; 1138 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalFormat[kOther_Externa lFormatUsage] = 0;
1073 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalType = 0; 1139 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalType = 0;
1074 fConfigTable[kUnknown_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1140 fConfigTable[kUnknown_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType;
1075 fConfigTable[kUnknown_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); 1141 fConfigTable[kUnknown_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1076 1142
1077 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA; 1143 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA;
1078 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA8; 1144 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA8;
1079 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA ; 1145 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kOther_Exter nalFormatUsage] =
1146 GR_GL_RGBA;
1080 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN ED_BYTE; 1147 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN ED_BYTE;
1081 fConfigTable[kRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType; 1148 fConfigTable[kRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType;
1082 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Fla g; 1149 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Fla g;
1083 if (kGL_GrGLStandard == standard) { 1150 if (kGL_GrGLStandard == standard) {
1084 // We require some form of FBO support and all GLs with FBO support can render to RGBA8 1151 // We require some form of FBO support and all GLs with FBO support can render to RGBA8
1085 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags |= allRenderFlags; 1152 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags |= allRenderFlags;
1086 } else { 1153 } else {
1087 if (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_OES_rgb8_rgba8 ") || 1154 if (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_OES_rgb8_rgba8 ") ||
1088 ctxInfo.hasExtension("GL_ARM_rgba8")) { 1155 ctxInfo.hasExtension("GL_ARM_rgba8")) {
1089 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags |= allRenderFlags; 1156 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags |= allRenderFlags;
1090 } 1157 }
1091 } 1158 }
1092 fConfigTable[kRGBA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); 1159 fConfigTable[kRGBA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1093 1160
1094 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalFormat= GR_GL_BGRA; 1161 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalFormat[kOther_Exter nalFormatUsage] =
1162 GR_GL_BGRA;
1095 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG NED_BYTE; 1163 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG NED_BYTE;
1096 fConfigTable[kBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType; 1164 fConfigTable[kBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType;
1097 if (kGL_GrGLStandard == standard) { 1165 if (kGL_GrGLStandard == standard) {
1098 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR _GL_RGBA; 1166 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR _GL_RGBA;
1099 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = G R_GL_RGBA8; 1167 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = G R_GL_RGBA8;
1100 if (version >= GR_GL_VER(1, 2) || ctxInfo.hasExtension("GL_EXT_bgra")) { 1168 if (version >= GR_GL_VER(1, 2) || ctxInfo.hasExtension("GL_EXT_bgra")) {
1101 // Since the internal format is RGBA8, it is also renderable. 1169 // Since the internal format is RGBA8, it is also renderable.
1102 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTexture able_Flag | 1170 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTexture able_Flag |
1103 allRenderFlags; 1171 allRenderFlags;
1104 } 1172 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 srgbSupport = kPowerVRRogue_GrGLRenderer != ctxInfo.renderer() && 1213 srgbSupport = kPowerVRRogue_GrGLRenderer != ctxInfo.renderer() &&
1146 (ctxInfo.version() >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_EXT _sRGB")); 1214 (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 1215 // ES through 3.1 requires EXT_srgb_write_control to support toggling
1148 // sRGB writing for destinations. 1216 // sRGB writing for destinations.
1149 fSRGBWriteControl = ctxInfo.hasExtension("GL_EXT_sRGB_write_control"); 1217 fSRGBWriteControl = ctxInfo.hasExtension("GL_EXT_sRGB_write_control");
1150 } 1218 }
1151 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL _SRGB_ALPHA; 1219 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL _SRGB_ALPHA;
1152 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G L_SRGB8_ALPHA8; 1220 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 1221 // 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. 1222 // 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; 1223 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kOther_Exte rnalFormatUsage] =
1224 GR_GL_RGBA;
1156 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG NED_BYTE; 1225 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG NED_BYTE;
1157 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_ FormatType; 1226 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_ FormatType;
1158 if (srgbSupport) { 1227 if (srgbSupport) {
1159 fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag | 1228 fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag |
1160 allRenderFlags; 1229 allRenderFlags;
1161 } 1230 }
1162 fConfigTable[kSRGBA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); 1231 fConfigTable[kSRGBA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1163 1232
1164 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RG B; 1233 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RG B;
1165 if (this->ES2CompatibilitySupport()) { 1234 if (this->ES2CompatibilitySupport()) {
1166 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_RGB565; 1235 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_RGB565;
1167 } else { 1236 } else {
1168 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_RGB5; 1237 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_RGB5;
1169 } 1238 }
1170 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB; 1239 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalFormat[kOther_Externa lFormatUsage] =
1240 GR_GL_RGB;
1171 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED _SHORT_5_6_5; 1241 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED _SHORT_5_6_5;
1172 fConfigTable[kRGB_565_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1242 fConfigTable[kRGB_565_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType;
1173 fConfigTable[kRGB_565_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag; 1243 fConfigTable[kRGB_565_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
1174 if (kGL_GrGLStandard == standard) { 1244 if (kGL_GrGLStandard == standard) {
1175 if (version >= GR_GL_VER(4, 2) || ctxInfo.hasExtension("GL_ES2_compatibi lity")) { 1245 if (version >= GR_GL_VER(4, 2) || ctxInfo.hasExtension("GL_ES2_compatibi lity")) {
1176 fConfigTable[kRGB_565_GrPixelConfig].fFlags |= allRenderFlags; 1246 fConfigTable[kRGB_565_GrPixelConfig].fFlags |= allRenderFlags;
1177 } 1247 }
1178 } else { 1248 } else {
1179 fConfigTable[kRGB_565_GrPixelConfig].fFlags |= allRenderFlags; 1249 fConfigTable[kRGB_565_GrPixelConfig].fFlags |= allRenderFlags;
1180 } 1250 }
1181 fConfigTable[kRGB_565_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); 1251 fConfigTable[kRGB_565_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1182 1252
1183 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA; 1253 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA;
1184 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA4; 1254 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA4;
1185 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA ; 1255 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalFormat[kOther_Exter nalFormatUsage] =
1256 GR_GL_RGBA;
1186 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN ED_SHORT_4_4_4_4; 1257 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN ED_SHORT_4_4_4_4;
1187 fConfigTable[kRGBA_4444_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType; 1258 fConfigTable[kRGBA_4444_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType;
1188 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Fla g; 1259 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Fla g;
1189 if (kGL_GrGLStandard == standard) { 1260 if (kGL_GrGLStandard == standard) {
1190 if (version >= GR_GL_VER(4, 2)) { 1261 if (version >= GR_GL_VER(4, 2)) {
1191 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags |= allRenderFlags; 1262 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags |= allRenderFlags;
1192 } 1263 }
1193 } else { 1264 } else {
1194 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags |= allRenderFlags; 1265 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags |= allRenderFlags;
1195 } 1266 }
1196 fConfigTable[kRGBA_4444_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); 1267 fConfigTable[kRGBA_4444_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1197 1268
1198 if (this->textureRedSupport()) { 1269 if (this->textureRedSupport()) {
1199 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G L_RED; 1270 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G L_RED;
1200 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_R8; 1271 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_R8;
1201 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RE D; 1272 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat[kOther_Ext ernalFormatUsage] =
1273 GR_GL_RED;
1202 fConfigTable[kAlpha_8_GrPixelConfig].fSwizzle = GrSwizzle::RRRR(); 1274 fConfigTable[kAlpha_8_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
1203 } else { 1275 } else {
1204 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G L_ALPHA; 1276 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G L_ALPHA;
1205 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_ALPHA8; 1277 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_ALPHA8;
1206 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_AL PHA; 1278 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat[kOther_Ext ernalFormatUsage] =
1279 GR_GL_ALPHA;
1207 fConfigTable[kAlpha_8_GrPixelConfig].fSwizzle = GrSwizzle::AAAA(); 1280 fConfigTable[kAlpha_8_GrPixelConfig].fSwizzle = GrSwizzle::AAAA();
1208 } 1281 }
1209 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED _BYTE; 1282 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED _BYTE;
1210 fConfigTable[kAlpha_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1283 fConfigTable[kAlpha_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType;
1211 fConfigTable[kAlpha_8_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag; 1284 fConfigTable[kAlpha_8_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
1212 if (this->textureRedSupport() || kDesktop_ARB_MSFBOType == this->msFBOType() ) { 1285 if (this->textureRedSupport() || kDesktop_ARB_MSFBOType == this->msFBOType() ) {
1213 // desktop ARB extension/3.0+ supports ALPHA8 as renderable. 1286 // desktop ARB extension/3.0+ supports ALPHA8 as renderable.
1214 // Core profile removes ALPHA8 support, but we should have chosen R8 in that case. 1287 // Core profile removes ALPHA8 support, but we should have chosen R8 in that case.
1215 fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= allRenderFlags; 1288 fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= allRenderFlags;
1216 } 1289 }
(...skipping 24 matching lines...) Expand all
1241 } 1314 }
1242 if (ctxInfo.hasExtension("GL_OES_texture_half_float_linear") && 1315 if (ctxInfo.hasExtension("GL_OES_texture_half_float_linear") &&
1243 ctxInfo.hasExtension("GL_OES_texture_half_float")) { 1316 ctxInfo.hasExtension("GL_OES_texture_half_float")) {
1244 hasHalfFPTextures = true; 1317 hasHalfFPTextures = true;
1245 } 1318 }
1246 } 1319 }
1247 } 1320 }
1248 1321
1249 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL _RGBA; 1322 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL _RGBA;
1250 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G L_RGBA32F; 1323 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G L_RGBA32F;
1251 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB A; 1324 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalFormat[kOther_Exte rnalFormatUsage] =
1325 GR_GL_RGBA;
1252 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalType = GR_GL_FLOAT ; 1326 fConfigTable[kRGBA_float_GrPixelConfig].fFormats.fExternalType = GR_GL_FLOAT ;
1253 fConfigTable[kRGBA_float_GrPixelConfig].fFormatType = kFloat_FormatType; 1327 fConfigTable[kRGBA_float_GrPixelConfig].fFormatType = kFloat_FormatType;
1254 if (hasFPTextures) { 1328 if (hasFPTextures) {
1255 fConfigTable[kRGBA_float_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag; 1329 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 1330 // 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. 1331 // many precision issues and no clients actually want this yet.
1258 if (kGL_GrGLStandard == standard /* || version >= GR_GL_VER(3,2) || 1332 if (kGL_GrGLStandard == standard /* || version >= GR_GL_VER(3,2) ||
1259 ctxInfo.hasExtension("GL_EXT_color_buffer_float")*/) { 1333 ctxInfo.hasExtension("GL_EXT_color_buffer_float")*/) {
1260 fConfigTable[kRGBA_float_GrPixelConfig].fFlags |= fpRenderFlags; 1334 fConfigTable[kRGBA_float_GrPixelConfig].fFlags |= fpRenderFlags;
1261 } 1335 }
1262 } 1336 }
1263 fConfigTable[kRGBA_float_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); 1337 fConfigTable[kRGBA_float_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1264 1338
1265 if (this->textureRedSupport()) { 1339 if (this->textureRedSupport()) {
1266 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G R_GL_RED; 1340 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G R_GL_RED;
1267 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_R16F; 1341 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_R16F;
1268 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL _RED; 1342 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat[kOther_ ExternalFormatUsage]
1343 = GR_GL_RED;
1269 fConfigTable[kAlpha_half_GrPixelConfig].fSwizzle = GrSwizzle::RRRR(); 1344 fConfigTable[kAlpha_half_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
1270 } else { 1345 } else {
1271 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G R_GL_ALPHA; 1346 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G R_GL_ALPHA;
1272 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_ALPHA16F; 1347 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_ALPHA16F;
1273 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL _ALPHA; 1348 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat[kOther_ ExternalFormatUsage]
1349 = GR_GL_ALPHA;
1274 fConfigTable[kAlpha_half_GrPixelConfig].fSwizzle = GrSwizzle::AAAA(); 1350 fConfigTable[kAlpha_half_GrPixelConfig].fSwizzle = GrSwizzle::AAAA();
1275 } 1351 }
1276 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER (3, 0)) { 1352 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER (3, 0)) {
1277 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H ALF_FLOAT; 1353 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H ALF_FLOAT;
1278 } else { 1354 } else {
1279 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H ALF_FLOAT_OES; 1355 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H ALF_FLOAT_OES;
1280 } 1356 }
1281 fConfigTable[kAlpha_half_GrPixelConfig].fFormatType = kFloat_FormatType; 1357 fConfigTable[kAlpha_half_GrPixelConfig].fFormatType = kFloat_FormatType;
1282 if (hasHalfFPTextures) { 1358 if (hasHalfFPTextures) {
1283 fConfigTable[kAlpha_half_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag; 1359 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 1360 // ES requires either 3.2 or the combination of EXT_color_buffer_half_fl oat and support for
1285 // GL_RED internal format. 1361 // GL_RED internal format.
1286 if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3,2) || 1362 if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3,2) ||
1287 (this->textureRedSupport() && 1363 (this->textureRedSupport() &&
1288 ctxInfo.hasExtension("GL_EXT_color_buffer_half_float"))) { 1364 ctxInfo.hasExtension("GL_EXT_color_buffer_half_float"))) {
1289 fConfigTable[kAlpha_half_GrPixelConfig].fFlags |= fpRenderFlags; 1365 fConfigTable[kAlpha_half_GrPixelConfig].fFlags |= fpRenderFlags;
1290 } 1366 }
1291 } 1367 }
1292 1368
1293 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA; 1369 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA;
1294 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA16F; 1370 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA16F;
1295 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA ; 1371 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalFormat[kOther_Exter nalFormatUsage] =
1372 GR_GL_RGBA;
1296 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER (3, 0)) { 1373 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER (3, 0)) {
1297 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA LF_FLOAT; 1374 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA LF_FLOAT;
1298 } else { 1375 } else {
1299 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA LF_FLOAT_OES; 1376 fConfigTable[kRGBA_half_GrPixelConfig].fFormats.fExternalType = GR_GL_HA LF_FLOAT_OES;
1300 } 1377 }
1301 fConfigTable[kRGBA_half_GrPixelConfig].fFormatType = kFloat_FormatType; 1378 fConfigTable[kRGBA_half_GrPixelConfig].fFormatType = kFloat_FormatType;
1302 if (hasHalfFPTextures) { 1379 if (hasHalfFPTextures) {
1303 fConfigTable[kRGBA_half_GrPixelConfig].fFlags = ConfigInfo::kTextureable _Flag; 1380 fConfigTable[kRGBA_half_GrPixelConfig].fFlags = ConfigInfo::kTextureable _Flag;
1304 // ES requires 3.2 or EXT_color_buffer_half_float. 1381 // ES requires 3.2 or EXT_color_buffer_half_float.
1305 if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3,2) || 1382 if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3,2) ||
1306 ctxInfo.hasExtension("GL_EXT_color_buffer_half_float")) { 1383 ctxInfo.hasExtension("GL_EXT_color_buffer_half_float")) {
1307 fConfigTable[kRGBA_half_GrPixelConfig].fFlags |= fpRenderFlags; 1384 fConfigTable[kRGBA_half_GrPixelConfig].fFlags |= fpRenderFlags;
1308 } 1385 }
1309 } 1386 }
1310 fConfigTable[kRGBA_half_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); 1387 fConfigTable[kRGBA_half_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1311 1388
1312 // Compressed texture support 1389 // Compressed texture support
1313 1390
1314 // glCompressedTexImage2D is available on all OpenGL ES devices. It is avail able on standard 1391 // 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. 1392 // OpenGL after version 1.3. We'll assume at least that level of OpenGL supp ort.
1316 1393
1317 // TODO: Fix command buffer bindings and remove this. 1394 // TODO: Fix command buffer bindings and remove this.
1318 fCompressedTexSubImageSupport = SkToBool(gli->fFunctions.fCompressedTexSubIm age2D); 1395 fCompressedTexSubImageSupport = SkToBool(gli->fFunctions.fCompressedTexSubIm age2D);
1319 1396
1320 // No sized/unsized internal format distinction for compressed formats, no e xternal format. 1397 // No sized/unsized internal format distinction for compressed formats, no e xternal format.
1321 // Below we set the external formats and types to 0. 1398 // Below we set the external formats and types to 0.
1322 1399
1323 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_PA LETTE8_RGBA8; 1400 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_PA LETTE8_RGBA8;
1324 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_P ALETTE8_RGBA8; 1401 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_P ALETTE8_RGBA8;
1325 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalFormat = 0; 1402 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalFormat[kOther_Externa lFormatUsage] = 0;
1326 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalType = 0; 1403 fConfigTable[kIndex_8_GrPixelConfig].fFormats.fExternalType = 0;
1327 fConfigTable[kIndex_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1404 fConfigTable[kIndex_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType;
1328 // Disable this for now, while we investigate https://bug.skia.org/4333 1405 // Disable this for now, while we investigate https://bug.skia.org/4333
1329 if (false) { 1406 if (false) {
1330 // Check for 8-bit palette.. 1407 // Check for 8-bit palette..
1331 GrGLint numFormats; 1408 GrGLint numFormats;
1332 GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats ); 1409 GR_GL_GetIntegerv(gli, GR_GL_NUM_COMPRESSED_TEXTURE_FORMATS, &numFormats );
1333 if (numFormats) { 1410 if (numFormats) {
1334 SkAutoSTMalloc<10, GrGLint> formats(numFormats); 1411 SkAutoSTMalloc<10, GrGLint> formats(numFormats);
1335 GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats); 1412 GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats);
(...skipping 24 matching lines...) Expand all
1360 GR_GL_COMPRESSED_RED_RGTC1; 1437 GR_GL_COMPRESSED_RED_RGTC1;
1361 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = 1438 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat =
1362 GR_GL_COMPRESSED_RED_RGTC1; 1439 GR_GL_COMPRESSED_RED_RGTC1;
1363 } else if (ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture")) { 1440 } else if (ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture")) {
1364 fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag ; 1441 fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag ;
1365 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_C OMPRESSED_3DC_X; 1442 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_C OMPRESSED_3DC_X;
1366 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = 1443 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat =
1367 GR_GL_COMPRESSED_3DC_X; 1444 GR_GL_COMPRESSED_3DC_X;
1368 1445
1369 } 1446 }
1370 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalFormat = 0; 1447 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFo rmatUsage] = 0;
1371 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalType = 0; 1448 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalType = 0;
1372 fConfigTable[kLATC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format Type; 1449 fConfigTable[kLATC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format Type;
1373 fConfigTable[kLATC_GrPixelConfig].fSwizzle = GrSwizzle::RRRR(); 1450 fConfigTable[kLATC_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
1374 1451
1375 fConfigTable[kETC1_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPR ESSED_ETC1_RGB8; 1452 fConfigTable[kETC1_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPR ESSED_ETC1_RGB8;
1376 fConfigTable[kETC1_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_COMP RESSED_ETC1_RGB8; 1453 fConfigTable[kETC1_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_COMP RESSED_ETC1_RGB8;
1377 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalFormat = 0; 1454 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalFormat[kOther_ExternalFo rmatUsage] = 0;
1378 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalType = 0; 1455 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalType = 0;
1379 fConfigTable[kETC1_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format Type; 1456 fConfigTable[kETC1_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format Type;
1380 if (kGL_GrGLStandard == standard) { 1457 if (kGL_GrGLStandard == standard) {
1381 if (version >= GR_GL_VER(4, 3) || ctxInfo.hasExtension("GL_ARB_ES3_compa tibility")) { 1458 if (version >= GR_GL_VER(4, 3) || ctxInfo.hasExtension("GL_ARB_ES3_compa tibility")) {
1382 fConfigTable[kETC1_GrPixelConfig].fFlags = ConfigInfo::kTextureable_ Flag; 1459 fConfigTable[kETC1_GrPixelConfig].fFlags = ConfigInfo::kTextureable_ Flag;
1383 } 1460 }
1384 } else { 1461 } else {
1385 if (version >= GR_GL_VER(3, 0) || 1462 if (version >= GR_GL_VER(3, 0) ||
1386 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") || 1463 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") ||
1387 // ETC2 is a superset of ETC1, so we can just check for that, too. 1464 // ETC2 is a superset of ETC1, so we can just check for that, too.
1388 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") && 1465 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") &&
1389 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))) { 1466 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))) {
1390 fConfigTable[kETC1_GrPixelConfig].fFlags = ConfigInfo::kTextureable_ Flag; 1467 fConfigTable[kETC1_GrPixelConfig].fFlags = ConfigInfo::kTextureable_ Flag;
1391 } 1468 }
1392 } 1469 }
1393 fConfigTable[kETC1_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); 1470 fConfigTable[kETC1_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1394 1471
1395 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_CO MPRESSED_R11_EAC; 1472 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; 1473 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_C OMPRESSED_R11_EAC;
1397 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalFormat = 0; 1474 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalFormat[kOther_Externa lFormatUsage] = 0;
1398 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalType = 0; 1475 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalType = 0;
1399 fConfigTable[kR11_EAC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1476 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 1477 // 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. 1478 // decompressing the textures in the driver, and is generally slower.
1402 if (kGLES_GrGLStandard == standard && version >= GR_GL_VER(3,0)) { 1479 if (kGLES_GrGLStandard == standard && version >= GR_GL_VER(3,0)) {
1403 fConfigTable[kR11_EAC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_F lag; 1480 fConfigTable[kR11_EAC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_F lag;
1404 } 1481 }
1405 fConfigTable[kR11_EAC_GrPixelConfig].fSwizzle = GrSwizzle::RRRR(); 1482 fConfigTable[kR11_EAC_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
1406 1483
1407 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fBaseInternalFormat = 1484 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fBaseInternalFormat =
1408 GR_GL_COMPRESSED_RGBA_ASTC_12x12; 1485 GR_GL_COMPRESSED_RGBA_ASTC_12x12;
1409 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fSizedInternalFormat = 1486 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fSizedInternalFormat =
1410 GR_GL_COMPRESSED_RGBA_ASTC_12x12; 1487 GR_GL_COMPRESSED_RGBA_ASTC_12x12;
1411 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalFormat = 0; 1488 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalFormat[kOther_Exte rnalFormatUsage] =
1489 0;
1412 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalType = 0; 1490 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalType = 0;
1413 fConfigTable[kASTC_12x12_GrPixelConfig].fFormatType = kNormalizedFixedPoint_ FormatType; 1491 fConfigTable[kASTC_12x12_GrPixelConfig].fFormatType = kNormalizedFixedPoint_ FormatType;
1414 if (ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") || 1492 if (ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") ||
1415 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") || 1493 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") ||
1416 ctxInfo.hasExtension("GL_OES_texture_compression_astc")) { 1494 ctxInfo.hasExtension("GL_OES_texture_compression_astc")) {
1417 fConfigTable[kASTC_12x12_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag; 1495 fConfigTable[kASTC_12x12_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag;
1418 } 1496 }
1419 fConfigTable[kASTC_12x12_GrPixelConfig].fSwizzle = GrSwizzle::RGBA(); 1497 fConfigTable[kASTC_12x12_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1420 1498
1421 // Bulk populate the texture internal/external formats here and then deal wi th exceptions below. 1499 // Bulk populate the texture internal/external formats here and then deal wi th exceptions below.
1422 1500
1423 // ES 2.0 requires that the internal/external formats match. 1501 // ES 2.0 requires that the internal/external formats match.
1424 bool useSizedFormats = (kGL_GrGLStandard == ctxInfo.standard() || 1502 bool useSizedTexFormats = (kGL_GrGLStandard == ctxInfo.standard() ||
1425 ctxInfo.version() >= GR_GL_VER(3,0)); 1503 ctxInfo.version() >= GR_GL_VER(3,0));
1504 // All ES versions (thus far) require sized internal formats for render buff ers.
1505 // TODO: Always use sized internal format?
1506 bool useSizedRbFormats = kGLES_GrGLStandard == ctxInfo.standard();
1507
1426 for (int i = 0; i < kGrPixelConfigCnt; ++i) { 1508 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
1427 // Almost always we want to pass fExternalFormat as the <format> param t o glTex[Sub]Image. 1509 // Almost always we want to pass fExternalFormat[kOther_ExternalFormatUs age] as the <format>
1428 fConfigTable[i].fFormats.fExternalFormatForTexImage = 1510 // param to glTex[Sub]Image.
1429 fConfigTable[i].fFormats.fExternalFormat; 1511 fConfigTable[i].fFormats.fExternalFormat[kTexImage_ExternalFormatUsage] =
1430 fConfigTable[i].fFormats.fInternalFormatTexImage = useSizedFormats ? 1512 fConfigTable[i].fFormats.fExternalFormat[kOther_ExternalFormatUsage] ;
1513 fConfigTable[i].fFormats.fInternalFormatTexImage = useSizedTexFormats ?
1514 fConfigTable[i].fFormats.fSizedInternalFormat :
1515 fConfigTable[i].fFormats.fBaseInternalFormat;
1516 fConfigTable[i].fFormats.fInternalFormatRenderbuffer = useSizedRbFormats ?
1431 fConfigTable[i].fFormats.fSizedInternalFormat : 1517 fConfigTable[i].fFormats.fSizedInternalFormat :
1432 fConfigTable[i].fFormats.fBaseInternalFormat; 1518 fConfigTable[i].fFormats.fBaseInternalFormat;
1433 } 1519 }
1434 // OpenGL ES 2.0 + GL_EXT_sRGB allows GL_SRGB_ALPHA to be specified as the < format> 1520 // 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. 1521 // 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. 1522 // 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. 1523 // 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)) { 1524 if (ctxInfo.standard() == kGLES_GrGLStandard && ctxInfo.version() == GR_GL_V ER(2,0)) {
1439 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormatForTexIm age = 1525 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat[kTexIma ge_ExternalFormatUsage] =
1440 GR_GL_SRGB_ALPHA; 1526 GR_GL_SRGB_ALPHA;
1441 } 1527 }
1442 1528
1443 // If BGRA is supported as an internal format it must always be specified to glTex[Sub]Image 1529 // If BGRA is supported as an internal format it must always be specified to glTex[Sub]Image
1444 // as a base format. 1530 // as a base format.
1445 // GL_EXT_texture_format_BGRA8888: 1531 // GL_EXT_texture_format_BGRA8888:
1446 // This extension GL_BGRA as an unsized internal format. However, it is written against ES 1532 // 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 1533 // 2.0 and therefore doesn't define a value for GL_BGRA8 as ES 2.0 uses unsized internal
1448 // formats. 1534 // formats.
1449 // GL_APPLE_texture_format_BGRA8888: 1535 // GL_APPLE_texture_format_BGRA8888:
1450 // ES 2.0: the extension makes BGRA an external format but not an intern al format. 1536 // 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 1537 // ES 3.0: the extension explicitly states GL_BGRA8 is not a valid inter nal format for
1452 // glTexImage (just for glTexStorage). 1538 // glTexImage (just for glTexStorage).
1453 if (useSizedFormats && this->bgraIsInternalFormat()) { 1539 if (useSizedTexFormats && this->bgraIsInternalFormat()) {
1454 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fInternalFormatTexImage = GR_GL_BGRA; 1540 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fInternalFormatTexImage = GR_GL_BGRA;
1455 } 1541 }
1456 1542
1457 // If we don't have texture swizzle support then the shader generator must i nsert the 1543 // If we don't have texture swizzle support then the shader generator must i nsert the
1458 // swizzle into shader code. 1544 // swizzle into shader code.
1459 if (!this->textureSwizzleSupport()) { 1545 if (!this->textureSwizzleSupport()) {
1460 for (int i = 0; i < kGrPixelConfigCnt; ++i) { 1546 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
1461 glslCaps->fConfigTextureSwizzle[i] = fConfigTable[i].fSwizzle; 1547 glslCaps->fConfigTextureSwizzle[i] = fConfigTable[i].fSwizzle;
1462 } 1548 }
1463 } 1549 }
1464 1550
1465 #ifdef SK_DEBUG 1551 #ifdef SK_DEBUG
1466 // Make sure we initialized everything. 1552 // Make sure we initialized everything.
1467 ConfigFormats defaultEntry; 1553 ConfigInfo defaultEntry;
1468 for (int i = 0; i < kGrPixelConfigCnt; ++i) { 1554 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
1469 SkASSERT(defaultEntry.fBaseInternalFormat != fConfigTable[i].fFormats.fB aseInternalFormat); 1555 SkASSERT(defaultEntry.fFormats.fBaseInternalFormat !=
1470 SkASSERT(defaultEntry.fSizedInternalFormat != 1556 fConfigTable[i].fFormats.fBaseInternalFormat);
1557 SkASSERT(defaultEntry.fFormats.fSizedInternalFormat !=
1471 fConfigTable[i].fFormats.fSizedInternalFormat); 1558 fConfigTable[i].fFormats.fSizedInternalFormat);
1472 SkASSERT(defaultEntry.fExternalFormat != fConfigTable[i].fFormats.fExter nalFormat); 1559 for (int j = 0; j < kExternalFormatUsageCnt; ++j) {
1473 SkASSERT(defaultEntry.fExternalType != fConfigTable[i].fFormats.fExterna lType); 1560 SkASSERT(defaultEntry.fFormats.fExternalFormat[j] !=
1561 fConfigTable[i].fFormats.fExternalFormat[j]);
1562 }
1563 SkASSERT(defaultEntry.fFormats.fExternalType != fConfigTable[i].fFormats .fExternalType);
1474 } 1564 }
1475 #endif 1565 #endif
1476 } 1566 }
1477 1567
1478 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} 1568 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {}
1479
1480
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.h ('k') | src/gpu/gl/GrGLGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698