OpenGL plugin: Should fix building with earlier versions of GLEW. You'll still need the latest GLEW if you want to try dual-source blending.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6311 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Nolan Check 2010-10-24 18:26:28 +00:00
parent 5be617c129
commit 61c6d4fe59
3 changed files with 19 additions and 3 deletions

View File

@ -139,6 +139,6 @@ extern CGprofile g_cgvProf, g_cgfProf;
// XXX: Dual-source blending in OpenGL does not work correctly yet. To make it // XXX: Dual-source blending in OpenGL does not work correctly yet. To make it
// work, we may need to use glBindFragDataLocation. To use that, we need to // work, we may need to use glBindFragDataLocation. To use that, we need to
// use GLSL shaders across the whole pipeline. Yikes! // use GLSL shaders across the whole pipeline. Yikes!
const bool USE_DUAL_SOURCE_BLEND = false; //#define USE_DUAL_SOURCE_BLEND
#endif // _GLINIT_H_ #endif // _GLINIT_H_

View File

@ -1034,9 +1034,11 @@ void Renderer::SetBlendMode(bool forceUpdate)
u32 changes = forceUpdate ? 0xFFFFFFFF : newval ^ s_blendMode; u32 changes = forceUpdate ? 0xFFFFFFFF : newval ^ s_blendMode;
#ifdef USE_DUAL_SOURCE_BLEND
bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate
&& bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24; && bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
bool useDualSource = USE_DUAL_SOURCE_BLEND && useDstAlpha && GLEW_ARB_blend_func_extended; bool useDualSource = useDstAlpha && GLEW_ARB_blend_func_extended;
#endif
if (changes & 1) if (changes & 1)
// blend enable change // blend enable change
@ -1044,14 +1046,19 @@ void Renderer::SetBlendMode(bool forceUpdate)
if (changes & 4) if (changes & 4)
{ {
#ifdef USE_DUAL_SOURCE_BLEND
// subtract enable change // subtract enable change
GLenum equation = newval & 4 ? GL_FUNC_REVERSE_SUBTRACT : GL_FUNC_ADD; GLenum equation = newval & 4 ? GL_FUNC_REVERSE_SUBTRACT : GL_FUNC_ADD;
GLenum equationAlpha = useDualSource ? GL_FUNC_ADD : equation; GLenum equationAlpha = useDualSource ? GL_FUNC_ADD : equation;
glBlendEquationSeparate(equation, equationAlpha); glBlendEquationSeparate(equation, equationAlpha);
#else
glBlendEquation(newval & 4 ? GL_FUNC_REVERSE_SUBTRACT : GL_FUNC_ADD);
#endif
} }
if (changes & 0x1F8) if (changes & 0x1F8)
{ {
#ifdef USE_DUAL_SOURCE_BLEND
GLenum srcFactor = glSrcFactors[(newval >> 3) & 7]; GLenum srcFactor = glSrcFactors[(newval >> 3) & 7];
GLenum srcFactorAlpha = srcFactor; GLenum srcFactorAlpha = srcFactor;
GLenum dstFactor = glDestFactors[(newval >> 6) & 7]; GLenum dstFactor = glDestFactors[(newval >> 6) & 7];
@ -1074,6 +1081,9 @@ void Renderer::SetBlendMode(bool forceUpdate)
// blend RGB change // blend RGB change
glBlendFuncSeparate(srcFactor, dstFactor, srcFactorAlpha, dstFactorAlpha); glBlendFuncSeparate(srcFactor, dstFactor, srcFactorAlpha, dstFactorAlpha);
#else
glBlendFunc(glSrcFactors[(newval >> 3) & 7], glDestFactors[(newval >> 6) & 7]);
#endif
} }
s_blendMode = newval; s_blendMode = newval;

View File

@ -186,7 +186,9 @@ void VertexManager::vFlush()
bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate bool useDstAlpha = !g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate
&& bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24; && bpmem.zcontrol.pixel_format == PIXELFMT_RGBA6_Z24;
bool dualSourcePossible = USE_DUAL_SOURCE_BLEND && GLEW_ARB_blend_func_extended;
#ifdef USE_DUAL_SOURCE_BLEND
bool dualSourcePossible = GLEW_ARB_blend_func_extended;
// finally bind // finally bind
FRAGMENTSHADER* ps; FRAGMENTSHADER* ps;
@ -209,6 +211,10 @@ void VertexManager::vFlush()
{ {
ps = PixelShaderCache::SetShader(DSTALPHA_NONE,g_nativeVertexFmt->m_components); ps = PixelShaderCache::SetShader(DSTALPHA_NONE,g_nativeVertexFmt->m_components);
} }
#else
bool dualSourcePossible = false;
FRAGMENTSHADER* ps = PixelShaderCache::SetShader(DSTALPHA_NONE,g_nativeVertexFmt->m_components);
#endif
VERTEXSHADER* vs = VertexShaderCache::SetShader(g_nativeVertexFmt->m_components); VERTEXSHADER* vs = VertexShaderCache::SetShader(g_nativeVertexFmt->m_components);
if (ps) PixelShaderCache::SetCurrentShader(ps->glprogid); // Lego Star Wars crashes here. if (ps) PixelShaderCache::SetCurrentShader(ps->glprogid); // Lego Star Wars crashes here.
if (vs) VertexShaderCache::SetCurrentShader(vs->glprogid); if (vs) VertexShaderCache::SetCurrentShader(vs->glprogid);