summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorMarkus Wick <degasus@users.noreply.github.com>2016-09-30 16:07:32 +0200
committerGitHub <noreply@github.com>2016-09-30 16:07:32 +0200
commitf3cdc6433cba253fa4485cd7e27025c31410ed0c (patch)
treecb5fdbe4a96367c8cf5a175cdf354fddd42aaab2 /Source/Core
parent60138b0269209bcc9dde3b7a76574ada3edc16f7 (diff)
parent9f541e490d9eb314f49a2016ec72b4c733510f74 (diff)
Merge pull request #4153 from stenzek/logicop-dstalpha
OGL: Handle case where both constant alpha and logic op is enabled
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoBackends/OGL/VertexManager.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/Source/Core/VideoBackends/OGL/VertexManager.cpp b/Source/Core/VideoBackends/OGL/VertexManager.cpp
index 0bc2e3a663..feb2351e49 100644
--- a/Source/Core/VideoBackends/OGL/VertexManager.cpp
+++ b/Source/Core/VideoBackends/OGL/VertexManager.cpp
@@ -10,6 +10,7 @@
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/GL/GLExtensions/GLExtensions.h"
+#include "Common/GL/GLInterfaceBase.h"
#include "Common/StringUtil.h"
#include "VideoBackends/OGL/ProgramShaderCache.h"
@@ -170,8 +171,15 @@ void VertexManager::vFlush(bool useDstAlpha)
Draw(stride);
- // run through vertex groups again to set alpha
- if (useDstAlpha && !dualSourcePossible)
+ // If the GPU does not support dual-source blending, we can approximate the effect by drawing
+ // 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);
@@ -180,6 +188,9 @@ void VertexManager::vFlush(bool useDstAlpha)
glDisable(GL_BLEND);
+ if (logic_op_enabled)
+ glDisable(GL_COLOR_LOGIC_OP);
+
Draw(stride);
// restore color mask
@@ -187,6 +198,9 @@ void VertexManager::vFlush(bool useDstAlpha)
if (bpmem.blendmode.blendenable || bpmem.blendmode.subtract)
glEnable(GL_BLEND);
+
+ if (logic_op_enabled)
+ glEnable(GL_COLOR_LOGIC_OP);
}
#if defined(_DEBUG) || defined(DEBUGFAST)