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

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

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