From 717f0fcb4d88925fd63bcf66d50872f9a5eceb7a Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Wed, 5 Aug 2015 22:12:54 +0200 Subject: [PATCH] gsdx-ogl: optimize fbmask setup --- plugins/GSdx/GSRendererOGL.cpp | 41 +++++++++------------------------- 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/plugins/GSdx/GSRendererOGL.cpp b/plugins/GSdx/GSRendererOGL.cpp index 3e1056042c..5fa20365bb 100644 --- a/plugins/GSdx/GSRendererOGL.cpp +++ b/plugins/GSdx/GSRendererOGL.cpp @@ -282,38 +282,19 @@ bool GSRendererOGL::EmulateTextureShuffleAndFbmask(GSDeviceOGL::PSSelector& ps_s } else { ps_sel.dfmt = GSLocalMemory::m_psm[m_context->FRAME.PSM].fmt; - om_csel.wrgba = ~GSVector4i::load((int)m_context->FRAME.FBMSK).eq8(GSVector4i::xffffffff()).mask(); + GSVector4i fbmask_v = GSVector4i::load((int)m_context->FRAME.FBMSK); + int ff_fbmask = fbmask_v.eq8(GSVector4i::xffffffff()).mask(); + int zero_fbmask = fbmask_v.eq8(GSVector4i::zero()).mask(); - { - // FIXME GSVector will be nice here - uint8 r_mask = (m_context->FRAME.FBMSK >> 0) & 0xFF; - uint8 g_mask = (m_context->FRAME.FBMSK >> 8) & 0xFF; - uint8 b_mask = (m_context->FRAME.FBMSK >> 16) & 0xFF; - uint8 a_mask = (m_context->FRAME.FBMSK >> 24) & 0xFF; - if (r_mask != 0 && r_mask != 0xFF) { - ps_sel.fbmask = 1; - } - if (g_mask != 0 && g_mask != 0xFF) { - ps_sel.fbmask = 1; - } - if (b_mask != 0 && b_mask != 0xFF) { - ps_sel.fbmask = 1; - } - if (a_mask != 0 && a_mask != 0xFF) { - ps_sel.fbmask = 1; - } + om_csel.wrgba = ~ff_fbmask; // Enable channel if at least 1 bit is 0 - if (ps_sel.fbmask && m_sw_blending) { - GL_INS("FBMASK SW emulated fb_mask:%x on %d bits format", m_context->FRAME.FBMSK, - (GSLocalMemory::m_psm[m_context->FRAME.PSM].fmt == 2) ? 16 : 32); - ps_cb.FbMask.r = r_mask; - ps_cb.FbMask.g = g_mask; - ps_cb.FbMask.b = b_mask; - ps_cb.FbMask.a = a_mask; - require_barrier = true; - } else { - ps_sel.fbmask = 0; - } + ps_sel.fbmask = m_sw_blending && (~ff_fbmask & ~zero_fbmask & 0xF); + + if (ps_sel.fbmask) { + GL_INS("FBMASK SW emulated fb_mask:%x on %d bits format", m_context->FRAME.FBMSK, + (GSLocalMemory::m_psm[m_context->FRAME.PSM].fmt == 2) ? 16 : 32); + ps_cb.FbMask = fbmask_v.u8to32(); + require_barrier = true; } }