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

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

Issue 1569393002: Revert of Add a class representing texture swizzle. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLCaps.h ('k') | 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 24 matching lines...) Expand all
35 fImagingSupport = false; 35 fImagingSupport = false;
36 fVertexArrayObjectSupport = false; 36 fVertexArrayObjectSupport = false;
37 fDirectStateAccessSupport = false; 37 fDirectStateAccessSupport = false;
38 fDebugSupport = false; 38 fDebugSupport = false;
39 fES2CompatibilitySupport = false; 39 fES2CompatibilitySupport = false;
40 fMultisampleDisableSupport = false; 40 fMultisampleDisableSupport = false;
41 fUseNonVBOVertexAndIndexDynamicData = false; 41 fUseNonVBOVertexAndIndexDynamicData = false;
42 fIsCoreProfile = false; 42 fIsCoreProfile = false;
43 fBindFragDataLocationSupport = false; 43 fBindFragDataLocationSupport = false;
44 fExternalTextureSupport = false; 44 fExternalTextureSupport = false;
45 fTextureSwizzleSupport = false;
46 fSRGBWriteControl = false; 45 fSRGBWriteControl = false;
47 fRGBA8888PixelsOpsAreSlow = false; 46 fRGBA8888PixelsOpsAreSlow = false;
48 fPartialFBOReadIsSlow = false; 47 fPartialFBOReadIsSlow = false;
49 48
50 fShaderCaps.reset(new GrGLSLCaps(contextOptions)); 49 fShaderCaps.reset(new GrGLSLCaps(contextOptions));
51 50
52 this->init(contextOptions, ctxInfo, glInterface); 51 this->init(contextOptions, ctxInfo, glInterface);
53 } 52 }
54 53
55 void GrGLCaps::init(const GrContextOptions& contextOptions, 54 void GrGLCaps::init(const GrContextOptions& contextOptions,
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 if (ctxInfo.hasExtension("GL_OES_EGL_image_external")) { 211 if (ctxInfo.hasExtension("GL_OES_EGL_image_external")) {
213 if (ctxInfo.glslGeneration() == k110_GrGLSLGeneration) { 212 if (ctxInfo.glslGeneration() == k110_GrGLSLGeneration) {
214 fExternalTextureSupport = true; 213 fExternalTextureSupport = true;
215 } else if (ctxInfo.hasExtension("GL_OES_EGL_image_external_essl3") || 214 } else if (ctxInfo.hasExtension("GL_OES_EGL_image_external_essl3") ||
216 ctxInfo.hasExtension("OES_EGL_image_external_essl3")) { 215 ctxInfo.hasExtension("OES_EGL_image_external_essl3")) {
217 // At least one driver has been found that has this extension withou t the "GL_" prefix. 216 // At least one driver has been found that has this extension withou t the "GL_" prefix.
218 fExternalTextureSupport = true; 217 fExternalTextureSupport = true;
219 } 218 }
220 } 219 }
221 220
222 if (kGL_GrGLStandard == standard) {
223 if (version >= GR_GL_VER(3,3) || ctxInfo.hasExtension("GL_ARB_texture_sw izzle")) {
224 fTextureSwizzleSupport = true;
225 }
226 } else {
227 if (version >= GR_GL_VER(3,0)) {
228 fTextureSwizzleSupport = true;
229 }
230 }
231
232 #ifdef SK_BUILD_FOR_WIN 221 #ifdef SK_BUILD_FOR_WIN
233 // We're assuming that on Windows Chromium we're using ANGLE. 222 // We're assuming that on Windows Chromium we're using ANGLE.
234 bool isANGLE = kANGLE_GrGLDriver == ctxInfo.driver() || 223 bool isANGLE = kANGLE_GrGLDriver == ctxInfo.driver() ||
235 kChromium_GrGLDriver == ctxInfo.driver(); 224 kChromium_GrGLDriver == ctxInfo.driver();
236 // Angle has slow read/write pixel paths for 32bit RGBA (but fast for BGRA). 225 // Angle has slow read/write pixel paths for 32bit RGBA (but fast for BGRA).
237 fRGBA8888PixelsOpsAreSlow = isANGLE; 226 fRGBA8888PixelsOpsAreSlow = isANGLE;
238 // On DX9 ANGLE reading a partial FBO is slow. TODO: Check whether this is s till true and 227 // On DX9 ANGLE reading a partial FBO is slow. TODO: Check whether this is s till true and
239 // check DX11 ANGLE. 228 // check DX11 ANGLE.
240 fPartialFBOReadIsSlow = isANGLE; 229 fPartialFBOReadIsSlow = isANGLE;
241 #endif 230 #endif
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 (ctxInfo.hasExtension("GL_ARB_draw_instanced") && 430 (ctxInfo.hasExtension("GL_ARB_draw_instanced") &&
442 ctxInfo.hasExtension("GL_ARB_instanced_arrays")); 431 ctxInfo.hasExtension("GL_ARB_instanced_arrays"));
443 } else { 432 } else {
444 fSupportsInstancedDraws = 433 fSupportsInstancedDraws =
445 version >= GR_GL_VER(3, 0) || 434 version >= GR_GL_VER(3, 0) ||
446 (ctxInfo.hasExtension("GL_EXT_draw_instanced") && 435 (ctxInfo.hasExtension("GL_EXT_draw_instanced") &&
447 ctxInfo.hasExtension("GL_EXT_instanced_arrays")); 436 ctxInfo.hasExtension("GL_EXT_instanced_arrays"));
448 } 437 }
449 438
450 this->initShaderPrecisionTable(ctxInfo, gli, glslCaps); 439 this->initShaderPrecisionTable(ctxInfo, gli, glslCaps);
451 440 // Requires fTexutreSwizzleSupport and fTextureRedSupport to be set before t his point.
452 if (contextOptions.fUseShaderSwizzling) { 441 this->initConfigSwizzleTable(ctxInfo, glslCaps);
453 fTextureSwizzleSupport = false; 442 // Requires various members are already correctly initialized (e.g. fTexture RedSupport,
454 } 443 // msaa support).
455 444 this->initConfigTable(ctxInfo, gli);
456 // Requires fTextureRedSupport, fTextureSwizzleSupport, msaa support, ES com patibility have
457 // already been detected.
458 this->initConfigTable(ctxInfo, gli, glslCaps);
459 445
460 this->applyOptionsOverrides(contextOptions); 446 this->applyOptionsOverrides(contextOptions);
461 glslCaps->applyOptionsOverrides(contextOptions); 447 glslCaps->applyOptionsOverrides(contextOptions);
462 } 448 }
463 449
464 const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration generation, 450 const char* get_glsl_version_decl_string(GrGLStandard standard, GrGLSLGeneration generation,
465 bool isCoreProfile) { 451 bool isCoreProfile) {
466 switch (generation) { 452 switch (generation) {
467 case k110_GrGLSLGeneration: 453 case k110_GrGLSLGeneration:
468 if (kGLES_GrGLStandard == standard) { 454 if (kGLES_GrGLStandard == standard) {
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO")); 859 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO"));
874 r.appendf("Direct state access support: %s\n", (fDirectStateAccessSupport ? "YES": "NO")); 860 r.appendf("Direct state access support: %s\n", (fDirectStateAccessSupport ? "YES": "NO"));
875 r.appendf("Debug support: %s\n", (fDebugSupport ? "YES": "NO")); 861 r.appendf("Debug support: %s\n", (fDebugSupport ? "YES": "NO"));
876 r.appendf("Multisample disable support: %s\n", (fMultisampleDisableSupport ? "YES" : "NO")); 862 r.appendf("Multisample disable support: %s\n", (fMultisampleDisableSupport ? "YES" : "NO"));
877 r.appendf("Use non-VBO for dynamic data: %s\n", 863 r.appendf("Use non-VBO for dynamic data: %s\n",
878 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); 864 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO"));
879 r.appendf("SRGB write contol: %s\n", (fSRGBWriteControl ? "YES" : "NO")); 865 r.appendf("SRGB write contol: %s\n", (fSRGBWriteControl ? "YES" : "NO"));
880 r.appendf("RGBA 8888 pixel ops are slow: %s\n", (fRGBA8888PixelsOpsAreSlow ? "YES" : "NO")); 866 r.appendf("RGBA 8888 pixel ops are slow: %s\n", (fRGBA8888PixelsOpsAreSlow ? "YES" : "NO"));
881 r.appendf("Partial FBO read is slow: %s\n", (fPartialFBOReadIsSlow ? "YES" : "NO")); 867 r.appendf("Partial FBO read is slow: %s\n", (fPartialFBOReadIsSlow ? "YES" : "NO"));
882 r.appendf("Bind uniform location support: %s\n", (fBindUniformLocationSuppor t ? "YES" : "NO")); 868 r.appendf("Bind uniform location support: %s\n", (fBindUniformLocationSuppor t ? "YES" : "NO"));
883 r.appendf("External texture support: %s\n", (fExternalTextureSupport ? "YES" : "NO"));
884 r.appendf("Texture swizzle support: %s\n", (fTextureSwizzleSupport ? "YES" : "NO"));
885 869
886 r.append("Configs\n-------\n"); 870 r.append("Configs\n-------\n");
887 for (int i = 0; i < kGrPixelConfigCnt; ++i) { 871 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: " 872 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", 873 "0x%08x, e_type: 0x%08x, i_for_teximage: 0x%08x, e_for_teximag e: 0x%08x\n",
890 i, 874 i,
891 fConfigTable[i].fFlags, 875 fConfigTable[i].fFlags,
892 fConfigTable[i].fFormats.fBaseInternalFormat, 876 fConfigTable[i].fFormats.fBaseInternalFormat,
893 fConfigTable[i].fFormats.fSizedInternalFormat, 877 fConfigTable[i].fFormats.fSizedInternalFormat,
894 fConfigTable[i].fFormats.fExternalFormat, 878 fConfigTable[i].fFormats.fExternalFormat,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 // highp. GS was added after GetShaderPrecisionFormat was added to the list of features that 961 // highp. GS was added after GetShaderPrecisionFormat was added to the list of features that
978 // are recommended against. 962 // are recommended against.
979 if (glslCaps->fGeometryShaderSupport) { 963 if (glslCaps->fGeometryShaderSupport) {
980 for (int p = 0; p < kGrSLPrecisionCount; ++p) { 964 for (int p = 0; p < kGrSLPrecisionCount; ++p) {
981 glslCaps->fFloatPrecisions[kGeometry_GrShaderType][p] = 965 glslCaps->fFloatPrecisions[kGeometry_GrShaderType][p] =
982 glslCaps->fFloatPrecisions[kVerte x_GrShaderType][p]; 966 glslCaps->fFloatPrecisions[kVerte x_GrShaderType][p];
983 } 967 }
984 } 968 }
985 } 969 }
986 970
971 void GrGLCaps::initConfigSwizzleTable(const GrGLContextInfo& ctxInfo, GrGLSLCaps * glslCaps) {
972 GrGLStandard standard = ctxInfo.standard();
973 GrGLVersion version = ctxInfo.version();
974
975 glslCaps->fMustSwizzleInShader = true;
976 if (kGL_GrGLStandard == standard) {
977 if (version >= GR_GL_VER(3,3) || ctxInfo.hasExtension("GL_ARB_texture_sw izzle")) {
978 glslCaps->fMustSwizzleInShader = false;
979 }
980 } else {
981 if (version >= GR_GL_VER(3,0)) {
982 glslCaps->fMustSwizzleInShader = false;
983 }
984 }
985
986 glslCaps->fConfigSwizzle[kUnknown_GrPixelConfig] = nullptr;
987 if (fTextureRedSupport) {
988 glslCaps->fConfigSwizzle[kAlpha_8_GrPixelConfig] = "rrrr";
989 glslCaps->fConfigSwizzle[kAlpha_half_GrPixelConfig] = "rrrr";
990 } else {
991 glslCaps->fConfigSwizzle[kAlpha_8_GrPixelConfig] = "aaaa";
992 glslCaps->fConfigSwizzle[kAlpha_half_GrPixelConfig] = "aaaa";
993 }
994 glslCaps->fConfigSwizzle[kIndex_8_GrPixelConfig] = "rgba";
995 glslCaps->fConfigSwizzle[kRGB_565_GrPixelConfig] = "rgba";
996 glslCaps->fConfigSwizzle[kRGBA_4444_GrPixelConfig] = "rgba";
997 glslCaps->fConfigSwizzle[kRGBA_8888_GrPixelConfig] = "rgba";
998 glslCaps->fConfigSwizzle[kBGRA_8888_GrPixelConfig] = "rgba";
999 glslCaps->fConfigSwizzle[kSRGBA_8888_GrPixelConfig] = "rgba";
1000 glslCaps->fConfigSwizzle[kETC1_GrPixelConfig] = "rgba";
1001 glslCaps->fConfigSwizzle[kLATC_GrPixelConfig] = "rrrr";
1002 glslCaps->fConfigSwizzle[kR11_EAC_GrPixelConfig] = "rrrr";
1003 glslCaps->fConfigSwizzle[kASTC_12x12_GrPixelConfig] = "rgba";
1004 glslCaps->fConfigSwizzle[kRGBA_float_GrPixelConfig] = "rgba";
1005 glslCaps->fConfigSwizzle[kRGBA_half_GrPixelConfig] = "rgba";
1006
1007 }
1008
987 bool GrGLCaps::bgraIsInternalFormat() const { 1009 bool GrGLCaps::bgraIsInternalFormat() const {
988 return fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = = GR_GL_BGRA; 1010 return fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = = GR_GL_BGRA;
989 } 1011 }
990 1012
991 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa ce* gli, 1013 void GrGLCaps::initConfigTable(const GrGLContextInfo& ctxInfo, const GrGLInterfa ce* gli) {
992 GrGLSLCaps* glslCaps) {
993 /* 1014 /*
994 Comments on renderability of configs on various GL versions. 1015 Comments on renderability of configs on various GL versions.
995 OpenGL < 3.0: 1016 OpenGL < 3.0:
996 no built in support for render targets. 1017 no built in support for render targets.
997 GL_EXT_framebuffer_object adds possible support for any sized format with base internal 1018 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. 1019 format RGB, RGBA and NV float formats we don't use.
999 This is the following: 1020 This is the following:
1000 R3_G3_B2, RGB4, RGB5, RGB8, RGB10, RGB12, RGB16, RGBA2, RGBA4, R GB5_A1, RGBA8 1021 R3_G3_B2, RGB4, RGB5, RGB8, RGB10, RGB12, RGB16, RGBA2, RGBA4, R GB5_A1, RGBA8
1001 RGB10_A2, RGBA12,RGBA16 1022 RGB10_A2, RGBA12,RGBA16
1002 Though, it is hard to believe the more obscure formats such as RGB A12 would work 1023 Though, it is hard to believe the more obscure formats such as RGB A12 would work
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 } 1086 }
1066 1087
1067 GrGLStandard standard = ctxInfo.standard(); 1088 GrGLStandard standard = ctxInfo.standard();
1068 GrGLVersion version = ctxInfo.version(); 1089 GrGLVersion version = ctxInfo.version();
1069 1090
1070 fConfigTable[kUnknown_GrPixelConfig].fFormats.fBaseInternalFormat = 0; 1091 fConfigTable[kUnknown_GrPixelConfig].fFormats.fBaseInternalFormat = 0;
1071 fConfigTable[kUnknown_GrPixelConfig].fFormats.fSizedInternalFormat = 0; 1092 fConfigTable[kUnknown_GrPixelConfig].fFormats.fSizedInternalFormat = 0;
1072 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalFormat = 0; 1093 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalFormat = 0;
1073 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalType = 0; 1094 fConfigTable[kUnknown_GrPixelConfig].fFormats.fExternalType = 0;
1074 fConfigTable[kUnknown_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1095 fConfigTable[kUnknown_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType;
1075 fConfigTable[kUnknown_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1076 1096
1077 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA; 1097 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA;
1078 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA8; 1098 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA8;
1079 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA ; 1099 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA ;
1080 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN ED_BYTE; 1100 fConfigTable[kRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN ED_BYTE;
1081 fConfigTable[kRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType; 1101 fConfigTable[kRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType;
1082 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Fla g; 1102 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Fla g;
1083 if (kGL_GrGLStandard == standard) { 1103 if (kGL_GrGLStandard == standard) {
1084 // We require some form of FBO support and all GLs with FBO support can render to RGBA8 1104 // We require some form of FBO support and all GLs with FBO support can render to RGBA8
1085 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags |= allRenderFlags; 1105 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags |= allRenderFlags;
1086 } else { 1106 } else {
1087 if (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_OES_rgb8_rgba8 ") || 1107 if (version >= GR_GL_VER(3,0) || ctxInfo.hasExtension("GL_OES_rgb8_rgba8 ") ||
1088 ctxInfo.hasExtension("GL_ARM_rgba8")) { 1108 ctxInfo.hasExtension("GL_ARM_rgba8")) {
1089 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags |= allRenderFlags; 1109 fConfigTable[kRGBA_8888_GrPixelConfig].fFlags |= allRenderFlags;
1090 } 1110 }
1091 } 1111 }
1092 fConfigTable[kRGBA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1093 1112
1094 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalFormat= GR_GL_BGRA; 1113 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalFormat= GR_GL_BGRA;
1095 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG NED_BYTE; 1114 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG NED_BYTE;
1096 fConfigTable[kBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType; 1115 fConfigTable[kBGRA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType;
1097 if (kGL_GrGLStandard == standard) { 1116 if (kGL_GrGLStandard == standard) {
1098 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR _GL_RGBA; 1117 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fBaseInternalFormat = GR _GL_RGBA;
1099 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = G R_GL_RGBA8; 1118 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = G R_GL_RGBA8;
1100 if (version >= GR_GL_VER(1, 2) || ctxInfo.hasExtension("GL_EXT_bgra")) { 1119 if (version >= GR_GL_VER(1, 2) || ctxInfo.hasExtension("GL_EXT_bgra")) {
1101 // Since the internal format is RGBA8, it is also renderable. 1120 // Since the internal format is RGBA8, it is also renderable.
1102 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTexture able_Flag | 1121 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTexture able_Flag |
(...skipping 15 matching lines...) Expand all
1118 } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) { 1137 } else if (ctxInfo.hasExtension("GL_EXT_texture_format_BGRA8888")) {
1119 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTexture able_Flag | 1138 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags = ConfigInfo::kTexture able_Flag |
1120 ConfigInfo::kRendera ble_Flag; 1139 ConfigInfo::kRendera ble_Flag;
1121 if (ctxInfo.hasExtension("GL_CHROMIUM_renderbuffer_format_BGRA8888") && 1140 if (ctxInfo.hasExtension("GL_CHROMIUM_renderbuffer_format_BGRA8888") &&
1122 this->usesMSAARenderBuffers()) { 1141 this->usesMSAARenderBuffers()) {
1123 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags |= 1142 fConfigTable[kBGRA_8888_GrPixelConfig].fFlags |=
1124 ConfigInfo::kRenderableWithMSAA_Flag; 1143 ConfigInfo::kRenderableWithMSAA_Flag;
1125 } 1144 }
1126 } 1145 }
1127 } 1146 }
1128 fConfigTable[kBGRA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1129 1147
1130 // We only enable srgb support if both textures and FBOs support srgb. 1148 // We only enable srgb support if both textures and FBOs support srgb.
1131 bool srgbSupport = false; 1149 bool srgbSupport = false;
1132 if (kGL_GrGLStandard == standard) { 1150 if (kGL_GrGLStandard == standard) {
1133 if (ctxInfo.version() >= GR_GL_VER(3,0)) { 1151 if (ctxInfo.version() >= GR_GL_VER(3,0)) {
1134 srgbSupport = true; 1152 srgbSupport = true;
1135 } else if (ctxInfo.hasExtension("GL_EXT_texture_sRGB")) { 1153 } else if (ctxInfo.hasExtension("GL_EXT_texture_sRGB")) {
1136 if (ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") || 1154 if (ctxInfo.hasExtension("GL_ARB_framebuffer_sRGB") ||
1137 ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) { 1155 ctxInfo.hasExtension("GL_EXT_framebuffer_sRGB")) {
1138 srgbSupport = true; 1156 srgbSupport = true;
(...skipping 13 matching lines...) Expand all
1152 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fSizedInternalFormat = GR_G L_SRGB8_ALPHA8; 1170 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 1171 // 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. 1172 // 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; 1173 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB A;
1156 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG NED_BYTE; 1174 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIG NED_BYTE;
1157 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_ FormatType; 1175 fConfigTable[kSRGBA_8888_GrPixelConfig].fFormatType = kNormalizedFixedPoint_ FormatType;
1158 if (srgbSupport) { 1176 if (srgbSupport) {
1159 fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag | 1177 fConfigTable[kSRGBA_8888_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag |
1160 allRenderFlags; 1178 allRenderFlags;
1161 } 1179 }
1162 fConfigTable[kSRGBA_8888_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1163 1180
1164 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RG B; 1181 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_RG B;
1165 if (this->ES2CompatibilitySupport()) { 1182 if (this->ES2CompatibilitySupport()) {
1166 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_RGB565; 1183 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_RGB565;
1167 } else { 1184 } else {
1168 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_RGB5; 1185 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_RGB5;
1169 } 1186 }
1170 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB; 1187 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGB;
1171 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED _SHORT_5_6_5; 1188 fConfigTable[kRGB_565_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED _SHORT_5_6_5;
1172 fConfigTable[kRGB_565_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1189 fConfigTable[kRGB_565_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType;
1173 fConfigTable[kRGB_565_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag; 1190 fConfigTable[kRGB_565_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
1174 if (kGL_GrGLStandard == standard) { 1191 if (kGL_GrGLStandard == standard) {
1175 if (version >= GR_GL_VER(4, 2) || ctxInfo.hasExtension("GL_ES2_compatibi lity")) { 1192 if (version >= GR_GL_VER(4, 2) || ctxInfo.hasExtension("GL_ES2_compatibi lity")) {
1176 fConfigTable[kRGB_565_GrPixelConfig].fFlags |= allRenderFlags; 1193 fConfigTable[kRGB_565_GrPixelConfig].fFlags |= allRenderFlags;
1177 } 1194 }
1178 } else { 1195 } else {
1179 fConfigTable[kRGB_565_GrPixelConfig].fFlags |= allRenderFlags; 1196 fConfigTable[kRGB_565_GrPixelConfig].fFlags |= allRenderFlags;
1180 } 1197 }
1181 fConfigTable[kRGB_565_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1182 1198
1183 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA; 1199 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_ RGBA;
1184 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA4; 1200 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL _RGBA4;
1185 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA ; 1201 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RGBA ;
1186 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN ED_SHORT_4_4_4_4; 1202 fConfigTable[kRGBA_4444_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGN ED_SHORT_4_4_4_4;
1187 fConfigTable[kRGBA_4444_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType; 1203 fConfigTable[kRGBA_4444_GrPixelConfig].fFormatType = kNormalizedFixedPoint_F ormatType;
1188 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Fla g; 1204 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Fla g;
1189 if (kGL_GrGLStandard == standard) { 1205 if (kGL_GrGLStandard == standard) {
1190 if (version >= GR_GL_VER(4, 2)) { 1206 if (version >= GR_GL_VER(4, 2)) {
1191 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags |= allRenderFlags; 1207 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags |= allRenderFlags;
1192 } 1208 }
1193 } else { 1209 } else {
1194 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags |= allRenderFlags; 1210 fConfigTable[kRGBA_4444_GrPixelConfig].fFlags |= allRenderFlags;
1195 } 1211 }
1196 fConfigTable[kRGBA_4444_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1197 1212
1198 if (this->textureRedSupport()) { 1213 if (this->textureRedSupport()) {
1199 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G L_RED; 1214 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G L_RED;
1200 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_R8; 1215 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_R8;
1201 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RE D; 1216 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_RE D;
1202 fConfigTable[kAlpha_8_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
1203 } else { 1217 } else {
1204 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G L_ALPHA; 1218 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fBaseInternalFormat = GR_G L_ALPHA;
1205 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_ALPHA8; 1219 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fSizedInternalFormat = GR_ GL_ALPHA8;
1206 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_AL PHA; 1220 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalFormat = GR_GL_AL PHA;
1207 fConfigTable[kAlpha_8_GrPixelConfig].fSwizzle = GrSwizzle::AAAA();
1208 } 1221 }
1209 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED _BYTE; 1222 fConfigTable[kAlpha_8_GrPixelConfig].fFormats.fExternalType = GR_GL_UNSIGNED _BYTE;
1210 fConfigTable[kAlpha_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1223 fConfigTable[kAlpha_8_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType;
1211 fConfigTable[kAlpha_8_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag; 1224 fConfigTable[kAlpha_8_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag;
1212 if (this->textureRedSupport() || kDesktop_ARB_MSFBOType == this->msFBOType() ) { 1225 if (this->textureRedSupport() || kDesktop_ARB_MSFBOType == this->msFBOType() ) {
1213 // desktop ARB extension/3.0+ supports ALPHA8 as renderable. 1226 // desktop ARB extension/3.0+ supports ALPHA8 as renderable.
1214 // Core profile removes ALPHA8 support, but we should have chosen R8 in that case. 1227 // Core profile removes ALPHA8 support, but we should have chosen R8 in that case.
1215 fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= allRenderFlags; 1228 fConfigTable[kAlpha_8_GrPixelConfig].fFlags |= allRenderFlags;
1216 } 1229 }
1217 1230
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 fConfigTable[kRGBA_float_GrPixelConfig].fFormatType = kFloat_FormatType; 1266 fConfigTable[kRGBA_float_GrPixelConfig].fFormatType = kFloat_FormatType;
1254 if (hasFPTextures) { 1267 if (hasFPTextures) {
1255 fConfigTable[kRGBA_float_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag; 1268 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 1269 // 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. 1270 // many precision issues and no clients actually want this yet.
1258 if (kGL_GrGLStandard == standard /* || version >= GR_GL_VER(3,2) || 1271 if (kGL_GrGLStandard == standard /* || version >= GR_GL_VER(3,2) ||
1259 ctxInfo.hasExtension("GL_EXT_color_buffer_float")*/) { 1272 ctxInfo.hasExtension("GL_EXT_color_buffer_float")*/) {
1260 fConfigTable[kRGBA_float_GrPixelConfig].fFlags |= fpRenderFlags; 1273 fConfigTable[kRGBA_float_GrPixelConfig].fFlags |= fpRenderFlags;
1261 } 1274 }
1262 } 1275 }
1263 fConfigTable[kRGBA_float_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1264 1276
1265 if (this->textureRedSupport()) { 1277 if (this->textureRedSupport()) {
1266 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G R_GL_RED; 1278 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G R_GL_RED;
1267 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_R16F; 1279 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_R16F;
1268 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL _RED; 1280 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL _RED;
1269 fConfigTable[kAlpha_half_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
1270 } else { 1281 } else {
1271 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G R_GL_ALPHA; 1282 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fBaseInternalFormat = G R_GL_ALPHA;
1272 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_ALPHA16F; 1283 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_ALPHA16F;
1273 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL _ALPHA; 1284 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalFormat = GR_GL _ALPHA;
1274 fConfigTable[kAlpha_half_GrPixelConfig].fSwizzle = GrSwizzle::AAAA();
1275 } 1285 }
1276 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER (3, 0)) { 1286 if (kGL_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_VER (3, 0)) {
1277 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H ALF_FLOAT; 1287 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H ALF_FLOAT;
1278 } else { 1288 } else {
1279 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H ALF_FLOAT_OES; 1289 fConfigTable[kAlpha_half_GrPixelConfig].fFormats.fExternalType = GR_GL_H ALF_FLOAT_OES;
1280 } 1290 }
1281 fConfigTable[kAlpha_half_GrPixelConfig].fFormatType = kFloat_FormatType; 1291 fConfigTable[kAlpha_half_GrPixelConfig].fFormatType = kFloat_FormatType;
1282 if (hasHalfFPTextures) { 1292 if (hasHalfFPTextures) {
1283 fConfigTable[kAlpha_half_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag; 1293 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 1294 // ES requires either 3.2 or the combination of EXT_color_buffer_half_fl oat and support for
(...skipping 15 matching lines...) Expand all
1300 } 1310 }
1301 fConfigTable[kRGBA_half_GrPixelConfig].fFormatType = kFloat_FormatType; 1311 fConfigTable[kRGBA_half_GrPixelConfig].fFormatType = kFloat_FormatType;
1302 if (hasHalfFPTextures) { 1312 if (hasHalfFPTextures) {
1303 fConfigTable[kRGBA_half_GrPixelConfig].fFlags = ConfigInfo::kTextureable _Flag; 1313 fConfigTable[kRGBA_half_GrPixelConfig].fFlags = ConfigInfo::kTextureable _Flag;
1304 // ES requires 3.2 or EXT_color_buffer_half_float. 1314 // ES requires 3.2 or EXT_color_buffer_half_float.
1305 if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3,2) || 1315 if (kGL_GrGLStandard == standard || version >= GR_GL_VER(3,2) ||
1306 ctxInfo.hasExtension("GL_EXT_color_buffer_half_float")) { 1316 ctxInfo.hasExtension("GL_EXT_color_buffer_half_float")) {
1307 fConfigTable[kRGBA_half_GrPixelConfig].fFlags |= fpRenderFlags; 1317 fConfigTable[kRGBA_half_GrPixelConfig].fFlags |= fpRenderFlags;
1308 } 1318 }
1309 } 1319 }
1310 fConfigTable[kRGBA_half_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1311 1320
1312 // Compressed texture support 1321 // Compressed texture support
1313 1322
1314 // glCompressedTexImage2D is available on all OpenGL ES devices. It is avail able on standard 1323 // 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. 1324 // OpenGL after version 1.3. We'll assume at least that level of OpenGL supp ort.
1316 1325
1317 // TODO: Fix command buffer bindings and remove this. 1326 // TODO: Fix command buffer bindings and remove this.
1318 fCompressedTexSubImageSupport = SkToBool(gli->fFunctions.fCompressedTexSubIm age2D); 1327 fCompressedTexSubImageSupport = SkToBool(gli->fFunctions.fCompressedTexSubIm age2D);
1319 1328
1320 // No sized/unsized internal format distinction for compressed formats, no e xternal format. 1329 // No sized/unsized internal format distinction for compressed formats, no e xternal format.
(...skipping 13 matching lines...) Expand all
1334 SkAutoSTMalloc<10, GrGLint> formats(numFormats); 1343 SkAutoSTMalloc<10, GrGLint> formats(numFormats);
1335 GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats); 1344 GR_GL_GetIntegerv(gli, GR_GL_COMPRESSED_TEXTURE_FORMATS, formats);
1336 for (int i = 0; i < numFormats; ++i) { 1345 for (int i = 0; i < numFormats; ++i) {
1337 if (GR_GL_PALETTE8_RGBA8 == formats[i]) { 1346 if (GR_GL_PALETTE8_RGBA8 == formats[i]) {
1338 fConfigTable[kIndex_8_GrPixelConfig].fFlags = ConfigInfo::kT extureable_Flag; 1347 fConfigTable[kIndex_8_GrPixelConfig].fFlags = ConfigInfo::kT extureable_Flag;
1339 break; 1348 break;
1340 } 1349 }
1341 } 1350 }
1342 } 1351 }
1343 } 1352 }
1344 fConfigTable[kIndex_8_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1345 1353
1346 // May change the internal format based on extensions. 1354 // May change the internal format based on extensions.
1347 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = 1355 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat =
1348 GR_GL_COMPRESSED_LUMINANCE_LATC1; 1356 GR_GL_COMPRESSED_LUMINANCE_LATC1;
1349 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = 1357 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat =
1350 GR_GL_COMPRESSED_LUMINANCE_LATC1; 1358 GR_GL_COMPRESSED_LUMINANCE_LATC1;
1351 if (ctxInfo.hasExtension("GL_EXT_texture_compression_latc") || 1359 if (ctxInfo.hasExtension("GL_EXT_texture_compression_latc") ||
1352 ctxInfo.hasExtension("GL_NV_texture_compression_latc")) { 1360 ctxInfo.hasExtension("GL_NV_texture_compression_latc")) {
1353 fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag ; 1361 fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag ;
1354 } else if ((kGL_GrGLStandard == standard && version >= GR_GL_VER(3, 0)) || 1362 } else if ((kGL_GrGLStandard == standard && version >= GR_GL_VER(3, 0)) ||
1355 ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") || 1363 ctxInfo.hasExtension("GL_EXT_texture_compression_rgtc") ||
1356 ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc")) { 1364 ctxInfo.hasExtension("GL_ARB_texture_compression_rgtc")) {
1357 // RGTC is identical and available on OpenGL 3.0+ as well as with extens ions 1365 // RGTC is identical and available on OpenGL 3.0+ as well as with extens ions
1358 fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag ; 1366 fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag ;
1359 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = 1367 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat =
1360 GR_GL_COMPRESSED_RED_RGTC1; 1368 GR_GL_COMPRESSED_RED_RGTC1;
1361 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = 1369 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat =
1362 GR_GL_COMPRESSED_RED_RGTC1; 1370 GR_GL_COMPRESSED_RED_RGTC1;
1363 } else if (ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture")) { 1371 } else if (ctxInfo.hasExtension("GL_AMD_compressed_3DC_texture")) {
1364 fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag ; 1372 fConfigTable[kLATC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_Flag ;
1365 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_C OMPRESSED_3DC_X; 1373 fConfigTable[kLATC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_C OMPRESSED_3DC_X;
1366 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat = 1374 fConfigTable[kLATC_GrPixelConfig].fFormats.fSizedInternalFormat =
1367 GR_GL_COMPRESSED_3DC_X; 1375 GR_GL_COMPRESSED_3DC_X;
1368 1376
1369 } 1377 }
1370 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalFormat = 0; 1378 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalFormat = 0;
1371 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalType = 0; 1379 fConfigTable[kLATC_GrPixelConfig].fFormats.fExternalType = 0;
1372 fConfigTable[kLATC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format Type; 1380 fConfigTable[kLATC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format Type;
1373 fConfigTable[kLATC_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
1374 1381
1375 fConfigTable[kETC1_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPR ESSED_ETC1_RGB8; 1382 fConfigTable[kETC1_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_COMPR ESSED_ETC1_RGB8;
1376 fConfigTable[kETC1_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_COMP RESSED_ETC1_RGB8; 1383 fConfigTable[kETC1_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_COMP RESSED_ETC1_RGB8;
1377 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalFormat = 0; 1384 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalFormat = 0;
1378 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalType = 0; 1385 fConfigTable[kETC1_GrPixelConfig].fFormats.fExternalType = 0;
1379 fConfigTable[kETC1_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format Type; 1386 fConfigTable[kETC1_GrPixelConfig].fFormatType = kNormalizedFixedPoint_Format Type;
1380 if (kGL_GrGLStandard == standard) { 1387 if (kGL_GrGLStandard == standard) {
1381 if (version >= GR_GL_VER(4, 3) || ctxInfo.hasExtension("GL_ARB_ES3_compa tibility")) { 1388 if (version >= GR_GL_VER(4, 3) || ctxInfo.hasExtension("GL_ARB_ES3_compa tibility")) {
1382 fConfigTable[kETC1_GrPixelConfig].fFlags = ConfigInfo::kTextureable_ Flag; 1389 fConfigTable[kETC1_GrPixelConfig].fFlags = ConfigInfo::kTextureable_ Flag;
1383 } 1390 }
1384 } else { 1391 } else {
1385 if (version >= GR_GL_VER(3, 0) || 1392 if (version >= GR_GL_VER(3, 0) ||
1386 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") || 1393 ctxInfo.hasExtension("GL_OES_compressed_ETC1_RGB8_texture") ||
1387 // ETC2 is a superset of ETC1, so we can just check for that, too. 1394 // ETC2 is a superset of ETC1, so we can just check for that, too.
1388 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") && 1395 (ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGB8_texture") &&
1389 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))) { 1396 ctxInfo.hasExtension("GL_OES_compressed_ETC2_RGBA8_texture"))) {
1390 fConfigTable[kETC1_GrPixelConfig].fFlags = ConfigInfo::kTextureable_ Flag; 1397 fConfigTable[kETC1_GrPixelConfig].fFlags = ConfigInfo::kTextureable_ Flag;
1391 } 1398 }
1392 } 1399 }
1393 fConfigTable[kETC1_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1394 1400
1395 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_CO MPRESSED_R11_EAC; 1401 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fBaseInternalFormat = GR_GL_CO MPRESSED_R11_EAC;
1396 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_C OMPRESSED_R11_EAC; 1402 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fSizedInternalFormat = GR_GL_C OMPRESSED_R11_EAC;
1397 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalFormat = 0; 1403 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalFormat = 0;
1398 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalType = 0; 1404 fConfigTable[kR11_EAC_GrPixelConfig].fFormats.fExternalType = 0;
1399 fConfigTable[kR11_EAC_GrPixelConfig].fFormatType = kNormalizedFixedPoint_For matType; 1405 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 1406 // 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. 1407 // decompressing the textures in the driver, and is generally slower.
1402 if (kGLES_GrGLStandard == standard && version >= GR_GL_VER(3,0)) { 1408 if (kGLES_GrGLStandard == standard && version >= GR_GL_VER(3,0)) {
1403 fConfigTable[kR11_EAC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_F lag; 1409 fConfigTable[kR11_EAC_GrPixelConfig].fFlags = ConfigInfo::kTextureable_F lag;
1404 } 1410 }
1405 fConfigTable[kR11_EAC_GrPixelConfig].fSwizzle = GrSwizzle::RRRR();
1406 1411
1407 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fBaseInternalFormat = 1412 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fBaseInternalFormat =
1408 GR_GL_COMPRESSED_RGBA_ASTC_12x12; 1413 GR_GL_COMPRESSED_RGBA_ASTC_12x12;
1409 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fSizedInternalFormat = 1414 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fSizedInternalFormat =
1410 GR_GL_COMPRESSED_RGBA_ASTC_12x12; 1415 GR_GL_COMPRESSED_RGBA_ASTC_12x12;
1411 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalFormat = 0; 1416 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalFormat = 0;
1412 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalType = 0; 1417 fConfigTable[kASTC_12x12_GrPixelConfig].fFormats.fExternalType = 0;
1413 fConfigTable[kASTC_12x12_GrPixelConfig].fFormatType = kNormalizedFixedPoint_ FormatType; 1418 fConfigTable[kASTC_12x12_GrPixelConfig].fFormatType = kNormalizedFixedPoint_ FormatType;
1414 if (ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") || 1419 if (ctxInfo.hasExtension("GL_KHR_texture_compression_astc_hdr") ||
1415 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") || 1420 ctxInfo.hasExtension("GL_KHR_texture_compression_astc_ldr") ||
1416 ctxInfo.hasExtension("GL_OES_texture_compression_astc")) { 1421 ctxInfo.hasExtension("GL_OES_texture_compression_astc")) {
1417 fConfigTable[kASTC_12x12_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag; 1422 fConfigTable[kASTC_12x12_GrPixelConfig].fFlags = ConfigInfo::kTextureabl e_Flag;
1418 } 1423 }
1419 fConfigTable[kASTC_12x12_GrPixelConfig].fSwizzle = GrSwizzle::RGBA();
1420 1424
1421 // Bulk populate the texture internal/external formats here and then deal wi th exceptions below. 1425 // Bulk populate the texture internal/external formats here and then deal wi th exceptions below.
1422 1426
1423 // ES 2.0 requires that the internal/external formats match. 1427 // ES 2.0 requires that the internal/external formats match.
1424 bool useSizedFormats = (kGL_GrGLStandard == ctxInfo.standard() || 1428 bool useSizedFormats = (kGL_GrGLStandard == ctxInfo.standard() ||
1425 ctxInfo.version() >= GR_GL_VER(3,0)); 1429 ctxInfo.version() >= GR_GL_VER(3,0));
1426 for (int i = 0; i < kGrPixelConfigCnt; ++i) { 1430 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
1427 // Almost always we want to pass fExternalFormat as the <format> param t o glTex[Sub]Image. 1431 // Almost always we want to pass fExternalFormat as the <format> param t o glTex[Sub]Image.
1428 fConfigTable[i].fFormats.fExternalFormatForTexImage = 1432 fConfigTable[i].fFormats.fExternalFormatForTexImage =
1429 fConfigTable[i].fFormats.fExternalFormat; 1433 fConfigTable[i].fFormats.fExternalFormat;
(...skipping 17 matching lines...) Expand all
1447 // 2.0 and therefore doesn't define a value for GL_BGRA8 as ES 2.0 uses unsized internal 1451 // 2.0 and therefore doesn't define a value for GL_BGRA8 as ES 2.0 uses unsized internal
1448 // formats. 1452 // formats.
1449 // GL_APPLE_texture_format_BGRA8888: 1453 // GL_APPLE_texture_format_BGRA8888:
1450 // ES 2.0: the extension makes BGRA an external format but not an intern al format. 1454 // 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 1455 // ES 3.0: the extension explicitly states GL_BGRA8 is not a valid inter nal format for
1452 // glTexImage (just for glTexStorage). 1456 // glTexImage (just for glTexStorage).
1453 if (useSizedFormats && this->bgraIsInternalFormat()) { 1457 if (useSizedFormats && this->bgraIsInternalFormat()) {
1454 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fInternalFormatTexImage = GR_GL_BGRA; 1458 fConfigTable[kBGRA_8888_GrPixelConfig].fFormats.fInternalFormatTexImage = GR_GL_BGRA;
1455 } 1459 }
1456 1460
1457 // If we don't have texture swizzle support then the shader generator must i nsert the
1458 // swizzle into shader code.
1459 if (!this->textureSwizzleSupport()) {
1460 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
1461 glslCaps->fConfigTextureSwizzle[i] = fConfigTable[i].fSwizzle;
1462 }
1463 }
1464
1465 #ifdef SK_DEBUG 1461 #ifdef SK_DEBUG
1466 // Make sure we initialized everything. 1462 // Make sure we initialized everything.
1467 ConfigFormats defaultEntry; 1463 ConfigFormats defaultEntry;
1468 for (int i = 0; i < kGrPixelConfigCnt; ++i) { 1464 for (int i = 0; i < kGrPixelConfigCnt; ++i) {
1469 SkASSERT(defaultEntry.fBaseInternalFormat != fConfigTable[i].fFormats.fB aseInternalFormat); 1465 SkASSERT(defaultEntry.fBaseInternalFormat != fConfigTable[i].fFormats.fB aseInternalFormat);
1470 SkASSERT(defaultEntry.fSizedInternalFormat != 1466 SkASSERT(defaultEntry.fSizedInternalFormat !=
1471 fConfigTable[i].fFormats.fSizedInternalFormat); 1467 fConfigTable[i].fFormats.fSizedInternalFormat);
1472 SkASSERT(defaultEntry.fExternalFormat != fConfigTable[i].fFormats.fExter nalFormat); 1468 SkASSERT(defaultEntry.fExternalFormat != fConfigTable[i].fFormats.fExter nalFormat);
1473 SkASSERT(defaultEntry.fExternalType != fConfigTable[i].fFormats.fExterna lType); 1469 SkASSERT(defaultEntry.fExternalType != fConfigTable[i].fFormats.fExterna lType);
1474 } 1470 }
1475 #endif 1471 #endif
1476 } 1472 }
1477 1473
1478 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {} 1474 void GrGLCaps::onApplyOptionsOverrides(const GrContextOptions& options) {}
1479 1475
1480 1476
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