diff --git a/plugins/GSdx/GLState.cpp b/plugins/GSdx/GLState.cpp index e00c25ca1c..4caf54afb4 100644 --- a/plugins/GSdx/GLState.cpp +++ b/plugins/GSdx/GLState.cpp @@ -28,13 +28,12 @@ namespace GLState { GSVector4i scissor; bool blend; - GLenum eq_RGB; - GLenum f_sRGB; - GLenum f_dRGB; + uint16 eq_RGB; + uint16 f_sRGB; + uint16 f_dRGB; + uint8 bf; uint32 wrgba; - int bf; - bool depth; GLenum depth_func; bool depth_mask; @@ -68,8 +67,8 @@ namespace GLState { eq_RGB = 0; f_sRGB = 0; f_dRGB = 0; - wrgba = 0xF; bf = 0; + wrgba = 0xF; depth = false; depth_func = 0; diff --git a/plugins/GSdx/GLState.h b/plugins/GSdx/GLState.h index 2db08da410..dc44c35957 100644 --- a/plugins/GSdx/GLState.h +++ b/plugins/GSdx/GLState.h @@ -30,11 +30,11 @@ namespace GLState { extern GSVector4i scissor; extern bool blend; - extern GLenum eq_RGB; - extern GLenum f_sRGB; - extern GLenum f_dRGB; + extern uint16 eq_RGB; + extern uint16 f_sRGB; + extern uint16 f_dRGB; + extern uint8 bf; extern uint32 wrgba; - extern int bf; extern bool depth; extern GLenum depth_func; diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index e60b628e4c..47031d4c6d 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -1332,7 +1332,7 @@ void GSDeviceOGL::OMSetColorMaskState(OMColorMaskSelector sel) } } -void GSDeviceOGL::OMSetBlendState(int blend_index, int blend_factor, bool is_blend_constant) +void GSDeviceOGL::OMSetBlendState(uint8 blend_index, uint8 blend_factor, bool is_blend_constant) { if (blend_index) { if (!GLState::blend) { @@ -1346,25 +1346,23 @@ void GSDeviceOGL::OMSetBlendState(int blend_index, int blend_factor, bool is_ble gl_BlendColor(bf, bf, bf, bf); } - // FIXME test to use uint16 (cache friendly) - const GLenum& op = m_blendMapD3D9[blend_index].op; - if (GLState::eq_RGB != op) { - GLState::eq_RGB = op; + const OGLBlend& b = m_blendMapOGL[blend_index]; + + if (GLState::eq_RGB != b.op) { + GLState::eq_RGB = b.op; if (gl_BlendEquationSeparateiARB) - gl_BlendEquationSeparateiARB(0, op, GL_FUNC_ADD); + gl_BlendEquationSeparateiARB(0, b.op, GL_FUNC_ADD); else - gl_BlendEquationSeparate(op, GL_FUNC_ADD); + gl_BlendEquationSeparate(b.op, GL_FUNC_ADD); } - const GLenum& src = m_blendMapD3D9[blend_index].src; - const GLenum& dst = m_blendMapD3D9[blend_index].dst; - if (GLState::f_sRGB != src || GLState::f_dRGB != dst) { - GLState::f_sRGB = src; - GLState::f_dRGB = dst; + if (GLState::f_sRGB != b.src || GLState::f_dRGB != b.dst) { + GLState::f_sRGB = b.src; + GLState::f_dRGB = b.dst; if (gl_BlendFuncSeparateiARB) - gl_BlendFuncSeparateiARB(0, src, dst, GL_ONE, GL_ZERO); + gl_BlendFuncSeparateiARB(0, b.src, b.dst, GL_ONE, GL_ZERO); else - gl_BlendFuncSeparate(src, dst, GL_ONE, GL_ZERO); + gl_BlendFuncSeparate(b.src, b.dst, GL_ONE, GL_ZERO); } } else { @@ -1532,7 +1530,7 @@ void GSDeviceOGL::DebugOutputToFile(GLenum gl_source, GLenum gl_type, GLuint id, const int GSDeviceOGL::m_NO_BLEND = 0; const int GSDeviceOGL::m_MERGE_BLEND = 3*3*3*3; -const GSDeviceOGL::D3D9Blend GSDeviceOGL::m_blendMapD3D9[3*3*3*3 + 1] = +const GSDeviceOGL::OGLBlend GSDeviceOGL::m_blendMapOGL[3*3*3*3 + 1] = { { BLEND_NO_BAR , D3DBLENDOP_ADD , D3DBLEND_ONE , D3DBLEND_ZERO} , // 0000: (Cs - Cs)*As + Cs ==> Cs { 0 , D3DBLENDOP_ADD , D3DBLEND_ZERO , D3DBLEND_ONE} , // 0001: (Cs - Cs)*As + Cd ==> Cd diff --git a/plugins/GSdx/GSDeviceOGL.h b/plugins/GSdx/GSDeviceOGL.h index e17c9bb951..189d102229 100644 --- a/plugins/GSdx/GSDeviceOGL.h +++ b/plugins/GSdx/GSDeviceOGL.h @@ -379,8 +379,8 @@ class GSDeviceOGL : public GSDevice OMColorMaskSelector(uint32 c) { wrgba = c; } }; - struct D3D9Blend {int bogus, op, src, dst;}; - static const D3D9Blend m_blendMapD3D9[3*3*3*3 + 1]; + struct OGLBlend {uint16 bogus, op, src, dst;}; + static const OGLBlend m_blendMapOGL[3*3*3*3 + 1]; static const int m_NO_BLEND; static const int m_MERGE_BLEND; @@ -527,7 +527,7 @@ class GSDeviceOGL : public GSDevice void PSSetSamplerState(GLuint ss); void OMSetDepthStencilState(GSDepthStencilOGL* dss); - void OMSetBlendState(int blend_index = 0, int blend_factor = 0, bool is_blend_constant = false); + void OMSetBlendState(uint8 blend_index = 0, uint8 blend_factor = 0, bool is_blend_constant = false); void OMSetRenderTargets(GSTexture* rt, GSTexture* ds, const GSVector4i* scissor = NULL); void OMSetWriteBuffer(GLenum buffer = GL_COLOR_ATTACHMENT0); void OMSetColorMaskState(OMColorMaskSelector sel = OMColorMaskSelector()); diff --git a/plugins/GSdx/GSRendererOGL.cpp b/plugins/GSdx/GSRendererOGL.cpp index 4e5236bd05..07750fc247 100644 --- a/plugins/GSdx/GSRendererOGL.cpp +++ b/plugins/GSdx/GSRendererOGL.cpp @@ -332,8 +332,8 @@ bool GSRendererOGL::EmulateBlending(GSDeviceOGL::PSSelector& ps_sel, bool DATE_G } // Compute the blending equation to detect special case - int blend_index = ((ALPHA.A * 3 + ALPHA.B) * 3 + ALPHA.C) * 3 + ALPHA.D; - int blend_flag = GSDeviceOGL::m_blendMapD3D9[blend_index].bogus; + uint8 blend_index = ((ALPHA.A * 3 + ALPHA.B) * 3 + ALPHA.C) * 3 + ALPHA.D; + int blend_flag = GSDeviceOGL::m_blendMapOGL[blend_index].bogus; // SW Blend is (nearly) free. Let's use it. bool impossible_or_free_blend = (blend_flag & (BLEND_NO_BAR|BLEND_A_MAX|BLEND_ACCU))