From 143ad92afd538eb5372ee6a4fce43142c7cbf366 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 16 Jun 2014 23:33:15 -0700 Subject: [PATCH] Convert blending to doubling in more cases. We're not doubling the alpha, so all these cases are safe regardless of the alpha value. --- GPU/GLES/FragmentShaderGenerator.cpp | 37 ++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/GPU/GLES/FragmentShaderGenerator.cpp b/GPU/GLES/FragmentShaderGenerator.cpp index c5a7348652..4d935bce3a 100644 --- a/GPU/GLES/FragmentShaderGenerator.cpp +++ b/GPU/GLES/FragmentShaderGenerator.cpp @@ -236,17 +236,38 @@ static bool AlphaToColorDoubling() { if (!gstate.isAlphaBlendEnabled()) { return false; } - // 2x alpha in the source function and full alpha = source color doubling. - // If we see this, we don't really need to care about the dest alpha function - sure we can't handle - // the doubling dest ones, but there's nothing we can do about that. - if (gstate.getBlendFuncA() != GE_SRCBLEND_DOUBLESRCALPHA) { + // 2x alpha in the source function and not in the dest = source color doubling. + switch (gstate.getBlendFuncA()) { + case GE_SRCBLEND_DOUBLESRCALPHA: + case GE_SRCBLEND_DOUBLEINVSRCALPHA: + break; + + case GE_SRCBLEND_DOUBLEDSTALPHA: + case GE_SRCBLEND_DOUBLEINVDSTALPHA: + // Even dest alpha is safe, since we're moving the * 2.0 into the src color. + break; + + default: return false; } - if (gstate.getBlendFuncB() == GE_DSTBLEND_INVSRCALPHA) { - // If it's 1.0 or 0.0, then we can still color double (since 0.0 will blend out anyway.) - return (gstate_c.vertexFullAlpha && (gstate_c.textureSimpleAlpha || !gstate.isTextureAlphaUsed())); + switch (gstate.getBlendFuncB()) { + case GE_DSTBLEND_SRCCOLOR: + case GE_DSTBLEND_INVSRCCOLOR: + // Can't double, we need the source color to be correct. + return false; + + case GE_DSTBLEND_DOUBLESRCALPHA: + case GE_DSTBLEND_DOUBLEINVSRCALPHA: + case GE_DSTBLEND_DOUBLEDSTALPHA: + case GE_DSTBLEND_DOUBLEINVDSTALPHA: + // Won't do the trick, would be better to double both sides. + return false; + + default: + // In all other cases, we're pre-multiplying the src side by 2. + // For example, src * (2.0 * a) + dst * fixB, we're just moving the 2.0. + return true; } - return (gstate_c.vertexFullAlpha && (gstate_c.textureFullAlpha || !gstate.isTextureAlphaUsed())); } static bool CanDoubleSrcBlendMode() {