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 |
(...skipping 21 matching lines...) Expand all Loading... |
32 fUnpackFlipYSupport = false; | 32 fUnpackFlipYSupport = false; |
33 fPackRowLengthSupport = false; | 33 fPackRowLengthSupport = false; |
34 fPackFlipYSupport = false; | 34 fPackFlipYSupport = false; |
35 fTextureUsageSupport = false; | 35 fTextureUsageSupport = false; |
36 fTexStorageSupport = false; | 36 fTexStorageSupport = false; |
37 fTextureRedSupport = false; | 37 fTextureRedSupport = false; |
38 fImagingSupport = false; | 38 fImagingSupport = false; |
39 fTwoFormatLimit = false; | 39 fTwoFormatLimit = false; |
40 fFragCoordsConventionSupport = false; | 40 fFragCoordsConventionSupport = false; |
41 fVertexArrayObjectSupport = false; | 41 fVertexArrayObjectSupport = false; |
42 fInstancedDrawingSupport = false; | |
43 fDirectStateAccessSupport = false; | |
44 fDebugSupport = false; | |
45 fES2CompatibilitySupport = false; | 42 fES2CompatibilitySupport = false; |
46 fMultisampleDisableSupport = false; | 43 fMultisampleDisableSupport = false; |
47 fUseNonVBOVertexAndIndexDynamicData = false; | 44 fUseNonVBOVertexAndIndexDynamicData = false; |
48 fIsCoreProfile = false; | 45 fIsCoreProfile = false; |
49 fFullClearIsFree = false; | 46 fFullClearIsFree = false; |
50 | 47 |
51 fReadPixelsSupportedCache.reset(); | 48 fReadPixelsSupportedCache.reset(); |
52 | 49 |
53 fShaderCaps.reset(SkNEW_ARGS(GrGLSLCaps, (contextOptions, | 50 fShaderCaps.reset(SkNEW_ARGS(GrGLSLCaps, (contextOptions, |
54 ctxInfo, glInterface, *this))); | 51 ctxInfo, glInterface, *this))); |
(...skipping 30 matching lines...) Expand all Loading... |
85 } | 82 } |
86 else if (ctxInfo.hasExtension("GL_ARM_shader_framebuffer_fetch")) { | 83 else if (ctxInfo.hasExtension("GL_ARM_shader_framebuffer_fetch")) { |
87 // The arm extension also requires an additional flag which we will
set onResetContext | 84 // The arm extension also requires an additional flag which we will
set onResetContext |
88 glslCaps->fFBFetchNeedsCustomOutput = false; | 85 glslCaps->fFBFetchNeedsCustomOutput = false; |
89 glslCaps->fFBFetchSupport = true; | 86 glslCaps->fFBFetchSupport = true; |
90 glslCaps->fFBFetchColorName = "gl_LastFragColorARM"; | 87 glslCaps->fFBFetchColorName = "gl_LastFragColorARM"; |
91 glslCaps->fFBFetchExtensionString = "GL_ARM_shader_framebuffer_fetch
"; | 88 glslCaps->fFBFetchExtensionString = "GL_ARM_shader_framebuffer_fetch
"; |
92 } | 89 } |
93 } | 90 } |
94 | 91 |
95 glslCaps->fBindlessTextureSupport = ctxInfo.hasExtension("GL_NV_bindless_tex
ture"); | |
96 | |
97 // Adreno GPUs have a tendency to drop tiles when there is a divide-by-zero
in a shader | 92 // Adreno GPUs have a tendency to drop tiles when there is a divide-by-zero
in a shader |
98 glslCaps->fDropsTileOnZeroDivide = kQualcomm_GrGLVendor == ctxInfo.vendor(); | 93 glslCaps->fDropsTileOnZeroDivide = kQualcomm_GrGLVendor == ctxInfo.vendor(); |
99 | 94 |
100 /************************************************************************** | 95 /************************************************************************** |
101 * Caps specific to GrGLCaps | 96 * Caps specific to GrGLCaps |
102 **************************************************************************/ | 97 **************************************************************************/ |
103 | 98 |
104 if (kGLES_GrGLStandard == standard) { | 99 if (kGLES_GrGLStandard == standard) { |
105 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS, | 100 GR_GL_GetIntegerv(gli, GR_GL_MAX_FRAGMENT_UNIFORM_VECTORS, |
106 &fMaxFragmentUniformVectors); | 101 &fMaxFragmentUniformVectors); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 223 |
229 if (kGL_GrGLStandard == standard) { | 224 if (kGL_GrGLStandard == standard) { |
230 fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) || | 225 fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) || |
231 ctxInfo.hasExtension("GL_ARB_vertex_array_ob
ject") || | 226 ctxInfo.hasExtension("GL_ARB_vertex_array_ob
ject") || |
232 ctxInfo.hasExtension("GL_APPLE_vertex_array_
object"); | 227 ctxInfo.hasExtension("GL_APPLE_vertex_array_
object"); |
233 } else { | 228 } else { |
234 fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) || | 229 fVertexArrayObjectSupport = version >= GR_GL_VER(3, 0) || |
235 ctxInfo.hasExtension("GL_OES_vertex_array_ob
ject"); | 230 ctxInfo.hasExtension("GL_OES_vertex_array_ob
ject"); |
236 } | 231 } |
237 | 232 |
238 if ((kGL_GrGLStandard == standard && version >= GR_GL_VER(3,2)) || | |
239 (kGLES_GrGLStandard == standard && version >= GR_GL_VER(3,0))) { | |
240 fInstancedDrawingSupport = true; | |
241 } else { | |
242 fInstancedDrawingSupport = (ctxInfo.hasExtension("GL_ARB_draw_instanced"
) || | |
243 ctxInfo.hasExtension("GL_EXT_draw_instanced"
)) && | |
244 (ctxInfo.hasExtension("GL_ARB_instanced_array
s") || | |
245 ctxInfo.hasExtension("GL_EXT_instanced_array
s")); | |
246 } | |
247 | |
248 if (kGL_GrGLStandard == standard) { | |
249 fDirectStateAccessSupport = ctxInfo.hasExtension("GL_EXT_direct_state_ac
cess"); | |
250 } else { | |
251 fDirectStateAccessSupport = false; | |
252 } | |
253 | |
254 if (kGL_GrGLStandard == standard && version >= GR_GL_VER(4,3)) { | |
255 fDebugSupport = true; | |
256 } else { | |
257 fDebugSupport = ctxInfo.hasExtension("GL_KHR_debug"); | |
258 } | |
259 | |
260 if (kGL_GrGLStandard == standard) { | 233 if (kGL_GrGLStandard == standard) { |
261 fES2CompatibilitySupport = ctxInfo.hasExtension("GL_ARB_ES2_compatibilit
y"); | 234 fES2CompatibilitySupport = ctxInfo.hasExtension("GL_ARB_ES2_compatibilit
y"); |
262 } | 235 } |
263 else { | 236 else { |
264 fES2CompatibilitySupport = true; | 237 fES2CompatibilitySupport = true; |
265 } | 238 } |
266 | 239 |
267 if (kGL_GrGLStandard == standard) { | 240 if (kGL_GrGLStandard == standard) { |
268 fMultisampleDisableSupport = true; | 241 fMultisampleDisableSupport = true; |
269 } else { | 242 } else { |
270 fMultisampleDisableSupport = false; | 243 fMultisampleDisableSupport = false; |
271 } | 244 } |
272 | 245 |
273 /************************************************************************** | 246 /************************************************************************** |
274 * GrShaderCaps fields | 247 * GrShaderCaps fields |
275 **************************************************************************/ | 248 **************************************************************************/ |
276 | 249 |
277 glslCaps->fPathRenderingSupport = ctxInfo.hasExtension("GL_NV_path_rendering
"); | 250 glslCaps->fPathRenderingSupport = ctxInfo.hasExtension("GL_NV_path_rendering
"); |
278 | 251 |
279 if (glslCaps->fPathRenderingSupport) { | 252 if (glslCaps->fPathRenderingSupport) { |
280 if (kGL_GrGLStandard == standard) { | 253 if (kGL_GrGLStandard == standard) { |
281 // We only support v1.3+ of GL_NV_path_rendering which allows us to | 254 // We only support v1.3+ of GL_NV_path_rendering which allows us to |
282 // set individual fragment inputs with ProgramPathFragmentInputGen.
The API | 255 // set individual fragment inputs with ProgramPathFragmentInputGen.
The API |
283 // additions are detected by checking the existence of the function. | 256 // additions are detected by checking the existence of the function. |
284 glslCaps->fPathRenderingSupport = ((ctxInfo.version() >= GR_GL_VER(4
, 3) || | 257 glslCaps->fPathRenderingSupport = |
| 258 ctxInfo.hasExtension("GL_EXT_direct_state_access") && |
| 259 ((ctxInfo.version() >= GR_GL_VER(4, 3) || |
285 ctxInfo.hasExtension("GL_ARB_program_interface_query")) && | 260 ctxInfo.hasExtension("GL_ARB_program_interface_query")) && |
286 gli->fFunctions.fProgramPathFragmentInputGen); | 261 gli->fFunctions.fProgramPathFragmentInputGen); |
287 } | 262 } |
288 else { | 263 else { |
289 glslCaps->fPathRenderingSupport = ctxInfo.version() >= GR_GL_VER(3,
1); | 264 glslCaps->fPathRenderingSupport = ctxInfo.version() >= GR_GL_VER(3,
1); |
290 } | 265 } |
291 } | 266 } |
292 | 267 |
293 // For now these two are equivalent but we could have dst read in shader via
some other method | 268 // For now these two are equivalent but we could have dst read in shader via
some other method |
294 glslCaps->fDstReadInShaderSupport = glslCaps->fFBFetchSupport; | 269 glslCaps->fDstReadInShaderSupport = glslCaps->fFBFetchSupport; |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); | 980 r.appendf("Pack Flip Y support: %s\n", (fPackFlipYSupport ? "YES": "NO")); |
1006 | 981 |
1007 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO"
)); | 982 r.appendf("Texture Usage support: %s\n", (fTextureUsageSupport ? "YES": "NO"
)); |
1008 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO"
)); | 983 r.appendf("Texture Storage support: %s\n", (fTexStorageSupport ? "YES": "NO"
)); |
1009 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); | 984 r.appendf("GL_R support: %s\n", (fTextureRedSupport ? "YES": "NO")); |
1010 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); | 985 r.appendf("GL_ARB_imaging support: %s\n", (fImagingSupport ? "YES": "NO")); |
1011 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); | 986 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); |
1012 r.appendf("Fragment coord conventions support: %s\n", | 987 r.appendf("Fragment coord conventions support: %s\n", |
1013 (fFragCoordsConventionSupport ? "YES": "NO")); | 988 (fFragCoordsConventionSupport ? "YES": "NO")); |
1014 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ?
"YES": "NO")); | 989 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ?
"YES": "NO")); |
1015 r.appendf("Instanced drawing support: %s\n", (fInstancedDrawingSupport ? "YE
S": "NO")); | |
1016 r.appendf("Direct state access support: %s\n", (fDirectStateAccessSupport ?
"YES": "NO")); | |
1017 r.appendf("Debug support: %s\n", (fDebugSupport ? "YES": "NO")); | |
1018 r.appendf("Multisample disable support: %s\n", (fMultisampleDisableSupport ?
"YES" : "NO")); | 990 r.appendf("Multisample disable support: %s\n", (fMultisampleDisableSupport ?
"YES" : "NO")); |
1019 r.appendf("Use non-VBO for dynamic data: %s\n", | 991 r.appendf("Use non-VBO for dynamic data: %s\n", |
1020 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); | 992 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); |
1021 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO
")); | 993 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO
")); |
1022 return r; | 994 return r; |
1023 } | 995 } |
1024 | 996 |
1025 ////////////////////////////////////////////////////////////////////////////////
//////////// | 997 ////////////////////////////////////////////////////////////////////////////////
//////////// |
1026 | 998 |
1027 GrGLSLCaps::GrGLSLCaps(const GrContextOptions& options, | 999 GrGLSLCaps::GrGLSLCaps(const GrContextOptions& options, |
1028 const GrGLContextInfo& ctxInfo, | 1000 const GrGLContextInfo& ctxInfo, |
1029 const GrGLInterface* gli, | 1001 const GrGLInterface* gli, |
1030 const GrGLCaps& glCaps) { | 1002 const GrGLCaps& glCaps) { |
1031 fDropsTileOnZeroDivide = false; | 1003 fDropsTileOnZeroDivide = false; |
1032 fFBFetchSupport = false; | 1004 fFBFetchSupport = false; |
1033 fFBFetchNeedsCustomOutput = false; | 1005 fFBFetchNeedsCustomOutput = false; |
1034 fBindlessTextureSupport = false; | |
1035 fAdvBlendEqInteraction = kNotSupported_AdvBlendEqInteraction; | 1006 fAdvBlendEqInteraction = kNotSupported_AdvBlendEqInteraction; |
1036 fFBFetchColorName = NULL; | 1007 fFBFetchColorName = NULL; |
1037 fFBFetchExtensionString = NULL; | 1008 fFBFetchExtensionString = NULL; |
1038 } | 1009 } |
1039 | 1010 |
1040 SkString GrGLSLCaps::dump() const { | 1011 SkString GrGLSLCaps::dump() const { |
1041 SkString r = INHERITED::dump(); | 1012 SkString r = INHERITED::dump(); |
1042 | 1013 |
1043 static const char* kAdvBlendEqInteractionStr[] = { | 1014 static const char* kAdvBlendEqInteractionStr[] = { |
1044 "Not Supported", | 1015 "Not Supported", |
1045 "Automatic", | 1016 "Automatic", |
1046 "General Enable", | 1017 "General Enable", |
1047 "Specific Enables", | 1018 "Specific Enables", |
1048 }; | 1019 }; |
1049 GR_STATIC_ASSERT(0 == kNotSupported_AdvBlendEqInteraction); | 1020 GR_STATIC_ASSERT(0 == kNotSupported_AdvBlendEqInteraction); |
1050 GR_STATIC_ASSERT(1 == kAutomatic_AdvBlendEqInteraction); | 1021 GR_STATIC_ASSERT(1 == kAutomatic_AdvBlendEqInteraction); |
1051 GR_STATIC_ASSERT(2 == kGeneralEnable_AdvBlendEqInteraction); | 1022 GR_STATIC_ASSERT(2 == kGeneralEnable_AdvBlendEqInteraction); |
1052 GR_STATIC_ASSERT(3 == kSpecificEnables_AdvBlendEqInteraction); | 1023 GR_STATIC_ASSERT(3 == kSpecificEnables_AdvBlendEqInteraction); |
1053 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kAdvBlendEqInteractionStr) == kLast_AdvBlend
EqInteraction + 1); | 1024 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kAdvBlendEqInteractionStr) == kLast_AdvBlend
EqInteraction + 1); |
1054 | 1025 |
1055 r.appendf("--- GLSL-Specific ---\n"); | 1026 r.appendf("--- GLSL-Specific ---\n"); |
1056 | 1027 |
1057 r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO")); | 1028 r.appendf("FB Fetch Support: %s\n", (fFBFetchSupport ? "YES" : "NO")); |
1058 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES"
: "NO")); | 1029 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES"
: "NO")); |
1059 r.appendf("Bindless texture support: %s\n", (fBindlessTextureSupport ? "YES"
: "NO")); | |
1060 r.appendf("Advanced blend equation interaction: %s\n", | 1030 r.appendf("Advanced blend equation interaction: %s\n", |
1061 kAdvBlendEqInteractionStr[fAdvBlendEqInteraction]); | 1031 kAdvBlendEqInteractionStr[fAdvBlendEqInteraction]); |
1062 return r; | 1032 return r; |
1063 } | 1033 } |
1064 | 1034 |
1065 static GrGLenum precision_to_gl_float_type(GrSLPrecision p) { | 1035 static GrGLenum precision_to_gl_float_type(GrSLPrecision p) { |
1066 switch (p) { | 1036 switch (p) { |
1067 case kLow_GrSLPrecision: | 1037 case kLow_GrSLPrecision: |
1068 return GR_GL_LOW_FLOAT; | 1038 return GR_GL_LOW_FLOAT; |
1069 case kMedium_GrSLPrecision: | 1039 case kMedium_GrSLPrecision: |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 if (fGeometryShaderSupport) { | 1109 if (fGeometryShaderSupport) { |
1140 for (int p = 0; p < kGrSLPrecisionCount; ++p) { | 1110 for (int p = 0; p < kGrSLPrecisionCount; ++p) { |
1141 fFloatPrecisions[kGeometry_GrShaderType][p] = fFloatPrecisions[kVert
ex_GrShaderType][p]; | 1111 fFloatPrecisions[kGeometry_GrShaderType][p] = fFloatPrecisions[kVert
ex_GrShaderType][p]; |
1142 } | 1112 } |
1143 } | 1113 } |
1144 } | 1114 } |
1145 | 1115 |
1146 | 1116 |
1147 | 1117 |
1148 | 1118 |
OLD | NEW |