From bc50e5ce6c039f02dc805361ae5b0b66f40b4820 Mon Sep 17 00:00:00 2001 From: bsalomon Date: Thu, 4 Jun 2015 08:49:34 -0700 Subject: Disable dual source blending support when GLSL version is too old BUG=skia:3891 Review URL: https://codereview.chromium.org/1160923007 --- src/gpu/gl/GrGLCaps.cpp | 5 +++-- src/gpu/gl/GrGLSL.cpp | 18 +++++++++++++++--- src/gpu/gl/GrGLSL.h | 2 ++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index dd4ba65f77..ad0f2caf78 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -984,8 +984,9 @@ void GrGLSLCaps::init(const GrGLContextInfo& ctxInfo, // Enable supported shader-related caps if (kGL_GrGLStandard == standard) { - fDualSourceBlendingSupport = ctxInfo.version() >= GR_GL_VER(3, 3) || - ctxInfo.hasExtension("GL_ARB_blend_func_extended"); + fDualSourceBlendingSupport = (ctxInfo.version() >= GR_GL_VER(3, 3) || + ctxInfo.hasExtension("GL_ARB_blend_func_extended")) && + GrGLSLSupportsNamedFragmentShaderOutputs(ctxInfo.glslGeneration()); fShaderDerivativeSupport = true; // we don't support GL_ARB_geometry_shader4, just GL 3.2+ GS fGeometryShaderSupport = ctxInfo.version() >= GR_GL_VER(3, 2) && diff --git a/src/gpu/gl/GrGLSL.cpp b/src/gpu/gl/GrGLSL.cpp index f4caf52012..20e6e20938 100644 --- a/src/gpu/gl/GrGLSL.cpp +++ b/src/gpu/gl/GrGLSL.cpp @@ -85,10 +85,22 @@ const char* GrGetGLSLVersionDecl(const GrGLContextInfo& info) { case k310es_GrGLSLGeneration: SkASSERT(kGLES_GrGLStandard == info.standard()); return "#version 310 es\n"; - default: - SkFAIL("Unknown GL version."); - return ""; // suppress warning } + return ""; +} + +bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration gen) { + switch (gen) { + case k110_GrGLSLGeneration: + return false; + case k130_GrGLSLGeneration: + case k140_GrGLSLGeneration: + case k150_GrGLSLGeneration: + case k330_GrGLSLGeneration: + case k310es_GrGLSLGeneration: + return true; + } + return false; } void GrGLSLAppendDefaultFloatPrecisionDeclaration(GrSLPrecision p, GrGLStandard s, SkString* out) { diff --git a/src/gpu/gl/GrGLSL.h b/src/gpu/gl/GrGLSL.h index db8e1bdca5..b338c991a6 100644 --- a/src/gpu/gl/GrGLSL.h +++ b/src/gpu/gl/GrGLSL.h @@ -50,6 +50,8 @@ enum GrGLSLGeneration { */ bool GrGetGLSLGeneration(const GrGLInterface* gl, GrGLSLGeneration* generation); +bool GrGLSLSupportsNamedFragmentShaderOutputs(GrGLSLGeneration); + /** * Returns a string to include at the beginning of a shader to declare the GLSL * version. -- cgit v1.2.3