From 37e9fc59b36f03ff270764cd2e04f07a20dd212b Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 29 Mar 2014 12:10:44 +0100 Subject: [PATCH] 2x alpha: Safer change than the last attempt. Still fixes P2. I think this can be simplified, anyway. --- GPU/GLES/DepalettizeShader.cpp | 0 GPU/GLES/DepalettizeShader.h | 0 GPU/GLES/FragmentShaderGenerator.cpp | 17 +++++++++++++---- 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 GPU/GLES/DepalettizeShader.cpp create mode 100644 GPU/GLES/DepalettizeShader.h diff --git a/GPU/GLES/DepalettizeShader.cpp b/GPU/GLES/DepalettizeShader.cpp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/GPU/GLES/DepalettizeShader.h b/GPU/GLES/DepalettizeShader.h new file mode 100644 index 0000000000..e69de29bb2 diff --git a/GPU/GLES/FragmentShaderGenerator.cpp b/GPU/GLES/FragmentShaderGenerator.cpp index eeac7f593c..13808c6ba1 100644 --- a/GPU/GLES/FragmentShaderGenerator.cpp +++ b/GPU/GLES/FragmentShaderGenerator.cpp @@ -234,6 +234,13 @@ static bool IsColorTestTriviallyTrue() { } } +static bool AlphaToColorDoubling() { + // 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. + return (gstate.getBlendFuncA() == GE_SRCBLEND_DOUBLESRCALPHA) && (gstate_c.vertexFullAlpha && (gstate_c.textureFullAlpha || !gstate.isTextureAlphaUsed())); +} + static bool CanDoubleSrcBlendMode() { if (!gstate.isAlphaBlendEnabled()) { return false; @@ -275,9 +282,10 @@ void ComputeFragmentShaderID(FragmentShaderID *id) { bool enableFog = gstate.isFogEnabled() && !gstate.isModeThrough(); bool enableAlphaTest = gstate.isAlphaTestEnabled() && !IsAlphaTestTriviallyTrue() && !g_Config.bDisableAlphaTest; bool enableColorTest = gstate.isColorTestEnabled() && !IsColorTestTriviallyTrue(); - bool enableColorDoubling = gstate.isColorDoublingEnabled(); + bool alphaToColorDoubling = AlphaToColorDoubling(); + bool enableColorDoubling = gstate.isColorDoublingEnabled() || alphaToColorDoubling; // This isn't really correct, but it's a hack to get doubled blend modes to work more correctly. - bool enableAlphaDoubling = CanDoubleSrcBlendMode(); + bool enableAlphaDoubling = !alphaToColorDoubling && CanDoubleSrcBlendMode(); bool doTextureProjection = gstate.getUVGenMode() == GE_TEXMAP_TEXTURE_MATRIX; bool doTextureAlpha = gstate.isTextureAlphaUsed(); ReplaceAlphaType stencilToAlpha = ReplaceAlphaWithStencil(); @@ -381,9 +389,10 @@ void GenerateFragmentShader(char *buffer) { bool enableFog = gstate.isFogEnabled() && !gstate.isModeThrough() && !gstate.isModeClear(); bool enableAlphaTest = gstate.isAlphaTestEnabled() && !IsAlphaTestTriviallyTrue() && !gstate.isModeClear() && !g_Config.bDisableAlphaTest; bool enableColorTest = gstate.isColorTestEnabled() && !IsColorTestTriviallyTrue() && !gstate.isModeClear(); - bool enableColorDoubling = gstate.isColorDoublingEnabled() && gstate.isTextureMapEnabled(); + bool alphaToColorDoubling = AlphaToColorDoubling(); + bool enableColorDoubling = (gstate.isColorDoublingEnabled() && gstate.isTextureMapEnabled()) || alphaToColorDoubling; // This isn't really correct, but it's a hack to get doubled blend modes to work more correctly. - bool enableAlphaDoubling = CanDoubleSrcBlendMode(); + bool enableAlphaDoubling = !alphaToColorDoubling && CanDoubleSrcBlendMode(); bool doTextureProjection = gstate.getUVGenMode() == GE_TEXMAP_TEXTURE_MATRIX; bool doTextureAlpha = gstate.isTextureAlphaUsed(); ReplaceAlphaType stencilToAlpha = ReplaceAlphaWithStencil();