OGL: Handle case where both constant alpha and logic op is enabled

This commit is contained in:
Stenzek 2016-08-28 23:43:32 +10:00
parent 60138b0269
commit 9f541e490d
1 changed files with 16 additions and 2 deletions

View File

@ -10,6 +10,7 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/GL/GLExtensions/GLExtensions.h" #include "Common/GL/GLExtensions/GLExtensions.h"
#include "Common/GL/GLInterfaceBase.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "VideoBackends/OGL/ProgramShaderCache.h" #include "VideoBackends/OGL/ProgramShaderCache.h"
@ -170,8 +171,15 @@ void VertexManager::vFlush(bool useDstAlpha)
Draw(stride); Draw(stride);
// run through vertex groups again to set alpha // If the GPU does not support dual-source blending, we can approximate the effect by drawing
if (useDstAlpha && !dualSourcePossible) // the object a second time, with the write mask set to alpha only using a shader that outputs
// the destination/constant alpha value (which would normally be SRC_COLOR.a).
//
// This is also used when logic ops and destination alpha is enabled, since we can't enable
// blending and logic ops concurrently.
bool logic_op_enabled = (bpmem.blendmode.logicopenable && !bpmem.blendmode.blendenable &&
GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL);
if (useDstAlpha && (!dualSourcePossible || logic_op_enabled))
{ {
ProgramShaderCache::SetShader(DSTALPHA_ALPHA_PASS, m_current_primitive_type); ProgramShaderCache::SetShader(DSTALPHA_ALPHA_PASS, m_current_primitive_type);
@ -180,6 +188,9 @@ void VertexManager::vFlush(bool useDstAlpha)
glDisable(GL_BLEND); glDisable(GL_BLEND);
if (logic_op_enabled)
glDisable(GL_COLOR_LOGIC_OP);
Draw(stride); Draw(stride);
// restore color mask // restore color mask
@ -187,6 +198,9 @@ void VertexManager::vFlush(bool useDstAlpha)
if (bpmem.blendmode.blendenable || bpmem.blendmode.subtract) if (bpmem.blendmode.blendenable || bpmem.blendmode.subtract)
glEnable(GL_BLEND); glEnable(GL_BLEND);
if (logic_op_enabled)
glEnable(GL_COLOR_LOGIC_OP);
} }
#if defined(_DEBUG) || defined(DEBUGFAST) #if defined(_DEBUG) || defined(DEBUGFAST)