OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include "GrGLCaps.h" | 9 #include "GrGLCaps.h" |
10 | 10 |
11 #include "GrGLContext.h" | 11 #include "GrGLContext.h" |
| 12 #include "glsl/GrGLSLCaps.h" |
12 #include "SkTSearch.h" | 13 #include "SkTSearch.h" |
13 #include "SkTSort.h" | 14 #include "SkTSort.h" |
14 | 15 |
15 GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, | 16 GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions, |
16 const GrGLContextInfo& ctxInfo, | 17 const GrGLContextInfo& ctxInfo, |
17 const GrGLInterface* glInterface) : INHERITED(contextOptions)
{ | 18 const GrGLInterface* glInterface) : INHERITED(contextOptions)
{ |
18 fVerifiedColorConfigs.reset(); | 19 fVerifiedColorConfigs.reset(); |
19 fStencilFormats.reset(); | 20 fStencilFormats.reset(); |
20 fStencilVerifiedColorConfigs.reset(); | 21 fStencilVerifiedColorConfigs.reset(); |
21 fMSFBOType = kNone_MSFBOType; | 22 fMSFBOType = kNone_MSFBOType; |
(...skipping 22 matching lines...) Expand all Loading... |
44 fDebugSupport = false; | 45 fDebugSupport = false; |
45 fES2CompatibilitySupport = false; | 46 fES2CompatibilitySupport = false; |
46 fMultisampleDisableSupport = false; | 47 fMultisampleDisableSupport = false; |
47 fUseNonVBOVertexAndIndexDynamicData = false; | 48 fUseNonVBOVertexAndIndexDynamicData = false; |
48 fIsCoreProfile = false; | 49 fIsCoreProfile = false; |
49 fFullClearIsFree = false; | 50 fFullClearIsFree = false; |
50 fBindFragDataLocationSupport = false; | 51 fBindFragDataLocationSupport = false; |
51 | 52 |
52 fReadPixelsSupportedCache.reset(); | 53 fReadPixelsSupportedCache.reset(); |
53 | 54 |
54 fShaderCaps.reset(SkNEW_ARGS(GrGLSLCaps, (contextOptions, | 55 fShaderCaps.reset(SkNEW_ARGS(GrGLSLCaps, (contextOptions))); |
55 ctxInfo, glInterface, *this))); | |
56 | 56 |
57 this->init(contextOptions, ctxInfo, glInterface); | 57 this->init(contextOptions, ctxInfo, glInterface); |
58 } | 58 } |
59 | 59 |
60 void GrGLCaps::init(const GrContextOptions& contextOptions, | 60 void GrGLCaps::init(const GrContextOptions& contextOptions, |
61 const GrGLContextInfo& ctxInfo, | 61 const GrGLContextInfo& ctxInfo, |
62 const GrGLInterface* gli) { | 62 const GrGLInterface* gli) { |
63 GrGLStandard standard = ctxInfo.standard(); | 63 GrGLStandard standard = ctxInfo.standard(); |
64 GrGLVersion version = ctxInfo.version(); | 64 GrGLVersion version = ctxInfo.version(); |
65 | 65 |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 } else { | 443 } else { |
444 SkASSERT(ctxInfo.hasExtension("GL_EXT_framebuffer_object")); | 444 SkASSERT(ctxInfo.hasExtension("GL_EXT_framebuffer_object")); |
445 } | 445 } |
446 } else { | 446 } else { |
447 // ES 3.0 supports mixed size FBO attachments, 2.0 does not. | 447 // ES 3.0 supports mixed size FBO attachments, 2.0 does not. |
448 fOversizedStencilSupport = ctxInfo.version() >= GR_GL_VER(3, 0); | 448 fOversizedStencilSupport = ctxInfo.version() >= GR_GL_VER(3, 0); |
449 } | 449 } |
450 | 450 |
451 this->initConfigTexturableTable(ctxInfo, gli); | 451 this->initConfigTexturableTable(ctxInfo, gli); |
452 this->initConfigRenderableTable(ctxInfo); | 452 this->initConfigRenderableTable(ctxInfo); |
453 glslCaps->initShaderPrecisionTable(ctxInfo, gli); | 453 this->initShaderPrecisionTable(ctxInfo, gli, glslCaps); |
454 | 454 |
455 this->applyOptionsOverrides(contextOptions); | 455 this->applyOptionsOverrides(contextOptions); |
456 glslCaps->applyOptionsOverrides(contextOptions); | 456 glslCaps->applyOptionsOverrides(contextOptions); |
457 } | 457 } |
458 | 458 |
459 void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) { | 459 void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) { |
460 // OpenGL < 3.0 | 460 // OpenGL < 3.0 |
461 // no support for render targets unless the GL_ARB_framebuffer_object | 461 // no support for render targets unless the GL_ARB_framebuffer_object |
462 // extension is supported (in which case we get ALPHA, RED, RG, RGB, | 462 // extension is supported (in which case we get ALPHA, RED, RG, RGB, |
463 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we | 463 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 r.appendf("Instanced drawing support: %s\n", (fInstancedDrawingSupport ? "YE
S": "NO")); | 1071 r.appendf("Instanced drawing support: %s\n", (fInstancedDrawingSupport ? "YE
S": "NO")); |
1072 r.appendf("Direct state access support: %s\n", (fDirectStateAccessSupport ?
"YES": "NO")); | 1072 r.appendf("Direct state access support: %s\n", (fDirectStateAccessSupport ?
"YES": "NO")); |
1073 r.appendf("Debug support: %s\n", (fDebugSupport ? "YES": "NO")); | 1073 r.appendf("Debug support: %s\n", (fDebugSupport ? "YES": "NO")); |
1074 r.appendf("Multisample disable support: %s\n", (fMultisampleDisableSupport ?
"YES" : "NO")); | 1074 r.appendf("Multisample disable support: %s\n", (fMultisampleDisableSupport ?
"YES" : "NO")); |
1075 r.appendf("Use non-VBO for dynamic data: %s\n", | 1075 r.appendf("Use non-VBO for dynamic data: %s\n", |
1076 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); | 1076 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); |
1077 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO
")); | 1077 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO
")); |
1078 return r; | 1078 return r; |
1079 } | 1079 } |
1080 | 1080 |
1081 ////////////////////////////////////////////////////////////////////////////////
//////////// | |
1082 | |
1083 GrGLSLCaps::GrGLSLCaps(const GrContextOptions& options, | |
1084 const GrGLContextInfo& ctxInfo, | |
1085 const GrGLInterface* gli, | |
1086 const GrGLCaps& glCaps) { | |
1087 fDropsTileOnZeroDivide = false; | |
1088 fFBFetchSupport = false; | |
1089 fFBFetchNeedsCustomOutput = false; | |
1090 fBindlessTextureSupport = false; | |
1091 fAdvBlendEqInteraction = kNotSupported_AdvBlendEqInteraction; | |
1092 fFBFetchColorName = NULL; | |
1093 fFBFetchExtensionString = NULL; | |
1094 } | |
1095 | |
1096 SkString GrGLSLCaps::dump() const { | |
1097 SkString r = INHERITED::dump(); | |
1098 | |
1099 static const char* kAdvBlendEqInteractionStr[] = { | |
1100 "Not Supported", | |
1101 "Automatic", | |
1102 "General Enable", | |
1103 "Specific Enables", | |
1104 }; | |
1105 GR_STATIC_ASSERT(0 == kNotSupported_AdvBlendEqInteraction); | |
1106 GR_STATIC_ASSERT(1 == kAutomatic_AdvBlendEqInteraction); | |
1107 GR_STATIC_ASSERT(2 == kGeneralEnable_AdvBlendEqInteraction); | |
1108 GR_STATIC_ASSERT(3 == kSpecificEnables_AdvBlendEqInteraction); | |
1109 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kAdvBlendEqInteractionStr) == kLast_AdvBlend
EqInteraction + 1); | |
1110 | |
1111 r.appendf("--- GLSL-Specific ---\n"); | |
1112 | |
1113 r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO")); | |
1114 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES"
: "NO")); | |
1115 r.appendf("Bindless texture support: %s\n", (fBindlessTextureSupport ? "YES"
: "NO")); | |
1116 r.appendf("Advanced blend equation interaction: %s\n", | |
1117 kAdvBlendEqInteractionStr[fAdvBlendEqInteraction]); | |
1118 return r; | |
1119 } | |
1120 | |
1121 static GrGLenum precision_to_gl_float_type(GrSLPrecision p) { | 1081 static GrGLenum precision_to_gl_float_type(GrSLPrecision p) { |
1122 switch (p) { | 1082 switch (p) { |
1123 case kLow_GrSLPrecision: | 1083 case kLow_GrSLPrecision: |
1124 return GR_GL_LOW_FLOAT; | 1084 return GR_GL_LOW_FLOAT; |
1125 case kMedium_GrSLPrecision: | 1085 case kMedium_GrSLPrecision: |
1126 return GR_GL_MEDIUM_FLOAT; | 1086 return GR_GL_MEDIUM_FLOAT; |
1127 case kHigh_GrSLPrecision: | 1087 case kHigh_GrSLPrecision: |
1128 return GR_GL_HIGH_FLOAT; | 1088 return GR_GL_HIGH_FLOAT; |
1129 } | 1089 } |
1130 SkFAIL("Unknown precision."); | 1090 SkFAIL("Unknown precision."); |
1131 return -1; | 1091 return -1; |
1132 } | 1092 } |
1133 | 1093 |
1134 static GrGLenum shader_type_to_gl_shader(GrShaderType type) { | 1094 static GrGLenum shader_type_to_gl_shader(GrShaderType type) { |
1135 switch (type) { | 1095 switch (type) { |
1136 case kVertex_GrShaderType: | 1096 case kVertex_GrShaderType: |
1137 return GR_GL_VERTEX_SHADER; | 1097 return GR_GL_VERTEX_SHADER; |
1138 case kGeometry_GrShaderType: | 1098 case kGeometry_GrShaderType: |
1139 return GR_GL_GEOMETRY_SHADER; | 1099 return GR_GL_GEOMETRY_SHADER; |
1140 case kFragment_GrShaderType: | 1100 case kFragment_GrShaderType: |
1141 return GR_GL_FRAGMENT_SHADER; | 1101 return GR_GL_FRAGMENT_SHADER; |
1142 } | 1102 } |
1143 SkFAIL("Unknown shader type."); | 1103 SkFAIL("Unknown shader type."); |
1144 return -1; | 1104 return -1; |
1145 } | 1105 } |
1146 | 1106 |
1147 void GrGLSLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, | 1107 void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, |
1148 const GrGLInterface* intf) { | 1108 const GrGLInterface* intf, |
| 1109 GrGLSLCaps* glslCaps) { |
1149 if (kGLES_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_V
ER(4, 1) || | 1110 if (kGLES_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_V
ER(4, 1) || |
1150 ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) { | 1111 ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) { |
1151 for (int s = 0; s < kGrShaderTypeCount; ++s) { | 1112 for (int s = 0; s < kGrShaderTypeCount; ++s) { |
1152 if (kGeometry_GrShaderType != s) { | 1113 if (kGeometry_GrShaderType != s) { |
1153 GrShaderType shaderType = static_cast<GrShaderType>(s); | 1114 GrShaderType shaderType = static_cast<GrShaderType>(s); |
1154 GrGLenum glShader = shader_type_to_gl_shader(shaderType); | 1115 GrGLenum glShader = shader_type_to_gl_shader(shaderType); |
1155 PrecisionInfo* first = NULL; | 1116 GrShaderCaps::PrecisionInfo* first = NULL; |
1156 fShaderPrecisionVaries = false; | 1117 glslCaps->fShaderPrecisionVaries = false; |
1157 for (int p = 0; p < kGrSLPrecisionCount; ++p) { | 1118 for (int p = 0; p < kGrSLPrecisionCount; ++p) { |
1158 GrSLPrecision precision = static_cast<GrSLPrecision>(p); | 1119 GrSLPrecision precision = static_cast<GrSLPrecision>(p); |
1159 GrGLenum glPrecision = precision_to_gl_float_type(precision)
; | 1120 GrGLenum glPrecision = precision_to_gl_float_type(precision)
; |
1160 GrGLint range[2]; | 1121 GrGLint range[2]; |
1161 GrGLint bits; | 1122 GrGLint bits; |
1162 GR_GL_GetShaderPrecisionFormat(intf, glShader, glPrecision,
range, &bits); | 1123 GR_GL_GetShaderPrecisionFormat(intf, glShader, glPrecision,
range, &bits); |
1163 if (bits) { | 1124 if (bits) { |
1164 fFloatPrecisions[s][p].fLogRangeLow = range[0]; | 1125 glslCaps->fFloatPrecisions[s][p].fLogRangeLow = range[0]
; |
1165 fFloatPrecisions[s][p].fLogRangeHigh = range[1]; | 1126 glslCaps->fFloatPrecisions[s][p].fLogRangeHigh = range[1
]; |
1166 fFloatPrecisions[s][p].fBits = bits; | 1127 glslCaps->fFloatPrecisions[s][p].fBits = bits; |
1167 if (!first) { | 1128 if (!first) { |
1168 first = &fFloatPrecisions[s][p]; | 1129 first = &glslCaps->fFloatPrecisions[s][p]; |
1169 } | 1130 } |
1170 else if (!fShaderPrecisionVaries) { | 1131 else if (!glslCaps->fShaderPrecisionVaries) { |
1171 fShaderPrecisionVaries = (*first != fFloatPrecisions
[s][p]); | 1132 glslCaps->fShaderPrecisionVaries = |
| 1133 (*first != glslCaps->fFloat
Precisions[s][p]); |
1172 } | 1134 } |
1173 } | 1135 } |
1174 } | 1136 } |
1175 } | 1137 } |
1176 } | 1138 } |
1177 } | 1139 } |
1178 else { | 1140 else { |
1179 // We're on a desktop GL that doesn't have precision info. Assume they'r
e all 32bit float. | 1141 // We're on a desktop GL that doesn't have precision info. Assume they'r
e all 32bit float. |
1180 fShaderPrecisionVaries = false; | 1142 glslCaps->fShaderPrecisionVaries = false; |
1181 for (int s = 0; s < kGrShaderTypeCount; ++s) { | 1143 for (int s = 0; s < kGrShaderTypeCount; ++s) { |
1182 if (kGeometry_GrShaderType != s) { | 1144 if (kGeometry_GrShaderType != s) { |
1183 for (int p = 0; p < kGrSLPrecisionCount; ++p) { | 1145 for (int p = 0; p < kGrSLPrecisionCount; ++p) { |
1184 fFloatPrecisions[s][p].fLogRangeLow = 127; | 1146 glslCaps->fFloatPrecisions[s][p].fLogRangeLow = 127; |
1185 fFloatPrecisions[s][p].fLogRangeHigh = 127; | 1147 glslCaps->fFloatPrecisions[s][p].fLogRangeHigh = 127; |
1186 fFloatPrecisions[s][p].fBits = 23; | 1148 glslCaps->fFloatPrecisions[s][p].fBits = 23; |
1187 } | 1149 } |
1188 } | 1150 } |
1189 } | 1151 } |
1190 } | 1152 } |
1191 // GetShaderPrecisionFormat doesn't accept GL_GEOMETRY_SHADER as a shader ty
pe. Assume they're | 1153 // GetShaderPrecisionFormat doesn't accept GL_GEOMETRY_SHADER as a shader ty
pe. Assume they're |
1192 // the same as the vertex shader. Only fragment shaders were ever allowed to
omit support for | 1154 // the same as the vertex shader. Only fragment shaders were ever allowed to
omit support for |
1193 // highp. GS was added after GetShaderPrecisionFormat was added to the list
of features that | 1155 // highp. GS was added after GetShaderPrecisionFormat was added to the list
of features that |
1194 // are recommended against. | 1156 // are recommended against. |
1195 if (fGeometryShaderSupport) { | 1157 if (glslCaps->fGeometryShaderSupport) { |
1196 for (int p = 0; p < kGrSLPrecisionCount; ++p) { | 1158 for (int p = 0; p < kGrSLPrecisionCount; ++p) { |
1197 fFloatPrecisions[kGeometry_GrShaderType][p] = fFloatPrecisions[kVert
ex_GrShaderType][p]; | 1159 glslCaps->fFloatPrecisions[kGeometry_GrShaderType][p] = |
| 1160 glslCaps->fFloatPrecisions[kVerte
x_GrShaderType][p]; |
1198 } | 1161 } |
1199 } | 1162 } |
1200 } | 1163 } |
1201 | 1164 |
1202 | 1165 |
1203 | 1166 |
1204 | 1167 |
OLD | NEW |