diff --git a/Source/Core/VideoCommon/Src/BPStructs.cpp b/Source/Core/VideoCommon/Src/BPStructs.cpp index 0bde9cc613..47dab0ec94 100644 --- a/Source/Core/VideoCommon/Src/BPStructs.cpp +++ b/Source/Core/VideoCommon/Src/BPStructs.cpp @@ -224,6 +224,8 @@ void BPWritten(const BPCmd& bp) { PRIM_LOG("constalpha: alp=%d, en=%d", bpmem.dstalpha.alpha, bpmem.dstalpha.enable); PixelShaderManager::SetDestAlpha(bpmem.dstalpha); + if(bp.changes & 0x100) + SetBlendMode(); break; } // This is called when the game is done drawing the new frame (eg: like in DX: Begin(); Draw(); End();) @@ -457,6 +459,8 @@ void BPWritten(const BPCmd& bp) case BPMEM_ZCOMPARE: // Set the Z-Compare and EFB pixel format g_renderer->SetColorMask(); // alpha writing needs to be disabled if the new pixel format doesn't have an alpha channel OnPixelFormatChange(); + if(bp.changes & 3) + SetBlendMode(); // dual source could be activated by changing to PIXELFMT_RGBA6_Z24 break; case BPMEM_MIPMAP_STRIDE: // MipMap Stride Channel diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index ff554d0276..76ac9e3cbb 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -959,13 +959,19 @@ void Renderer::ReinterpretPixelData(unsigned int convtype) void Renderer::SetBlendMode(bool forceUpdate) { + bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate + && bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24; + bool useDualSource = useDstAlpha && g_ActiveConfig.backend_info.bSupportsDualSourceBlend; + // blend mode bit mask // 0 - blend enable + // 1 - dst alpha enabled // 2 - reverse subtract enable (else add) // 3-5 - srcRGB function // 6-8 - dstRGB function - u32 newval = bpmem.blendmode.subtract << 2; + u32 newval = useDualSource << 1; + newval |= bpmem.blendmode.subtract << 2; if (bpmem.blendmode.subtract) newval |= 0x0049; // enable blending src 1 dst 1 @@ -978,10 +984,6 @@ void Renderer::SetBlendMode(bool forceUpdate) u32 changes = forceUpdate ? 0xFFFFFFFF : newval ^ s_blendMode; - bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate - && bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24; - bool useDualSource = useDstAlpha && g_ActiveConfig.backend_info.bSupportsDualSourceBlend; - if (changes & 1) // blend enable change (newval & 1) ? glEnable(GL_BLEND) : glDisable(GL_BLEND); @@ -998,7 +1000,7 @@ void Renderer::SetBlendMode(bool forceUpdate) glBlendEquation(newval & 4 ? GL_FUNC_REVERSE_SUBTRACT : GL_FUNC_ADD); } - if (changes & 0x1F8) + if (changes & 0x1FA) { if (g_ActiveConfig.backend_info.bSupportsDualSourceBlend) { diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp index 5d3840775a..04889dfadf 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp @@ -311,12 +311,10 @@ void VertexManager::vFlush() { // If host supports GL_ARB_blend_func_extended, we can do dst alpha in // the same pass as regular rendering. - g_renderer->SetBlendMode(true); ps = PixelShaderCache::SetShader(DSTALPHA_DUAL_SOURCE_BLEND, g_nativeVertexFmt->m_components); } else { - g_renderer->SetBlendMode(true); ps = PixelShaderCache::SetShader(DSTALPHA_NONE,g_nativeVertexFmt->m_components); } }