diff --git a/plugins/GSdx/GSRendererDX.cpp b/plugins/GSdx/GSRendererDX.cpp index cb7aa8f24a..d356cbdb35 100644 --- a/plugins/GSdx/GSRendererDX.cpp +++ b/plugins/GSdx/GSRendererDX.cpp @@ -53,7 +53,7 @@ void GSRendererDX::EmulateAtst(const int pass, const GSTextureCache::Source* tex static const uint32 inverted_atst[] = { ATST_ALWAYS, ATST_NEVER, ATST_GEQUAL, ATST_GREATER, ATST_NOTEQUAL, ATST_LESS, ATST_LEQUAL, ATST_EQUAL }; int atst = (pass == 2) ? inverted_atst[m_context->TEST.ATST] : m_context->TEST.ATST; - if (!m_context->TEST.ATE) return; + if (!m_ATE) return; switch (atst) { case ATST_LESS: @@ -98,7 +98,7 @@ void GSRendererDX::EmulateAtst(const int pass, const GSTextureCache::Source* tex // to only draw pixels which would cause the destination alpha test to fail in the future once. // Unfortunately this also means only drawing those pixels at all, which is why this is a hack. // The interaction with FBA in D3D9 is probably less than ideal. - if (UserHacks_AlphaStencil && DATE && dev->HasStencil() && om_bsel.wa && (!m_context->TEST.ATE || m_context->TEST.ATST == 1)) + if (UserHacks_AlphaStencil && DATE && dev->HasStencil() && om_bsel.wa && !m_ATE) { if (!m_context->FBA.FBA) { diff --git a/plugins/GSdx/GSRendererHW.cpp b/plugins/GSdx/GSRendererHW.cpp index 889f913e35..d7a5cf2725 100644 --- a/plugins/GSdx/GSRendererHW.cpp +++ b/plugins/GSdx/GSRendererHW.cpp @@ -32,6 +32,7 @@ GSRendererHW::GSRendererHW(GSTextureCache* tc) , m_tc(tc) , m_channel_shuffle(false) , m_double_downscale(false) + , m_ATE(false) { m_upscale_multiplier = theApp.GetConfigI("upscale_multiplier"); m_large_framebuffer = theApp.GetConfigB("large_framebuffer"); @@ -683,13 +684,8 @@ void GSRendererHW::Draw() uint32 fm = context->FRAME.FBMSK; uint32 zm = context->ZBUF.ZMSK || context->TEST.ZTE == 0 ? 0xffffffff : 0; - if(context->TEST.ATE && context->TEST.ATST != ATST_ALWAYS) - { - if(GSRenderer::TryAlphaTest(fm, zm)) - { - context->TEST.ATST = ATST_ALWAYS; - } - } + // Test if we can optimize Alpha Test as a NOP + m_ATE = context->TEST.ATE && !GSRenderer::TryAlphaTest(fm, zm); context->FRAME.FBMSK = fm; context->ZBUF.ZMSK = zm != 0; diff --git a/plugins/GSdx/GSRendererHW.h b/plugins/GSdx/GSRendererHW.h index 09e2ea5c4c..5aca0e951d 100644 --- a/plugins/GSdx/GSRendererHW.h +++ b/plugins/GSdx/GSRendererHW.h @@ -154,6 +154,7 @@ protected: bool m_channel_shuffle; bool m_double_downscale; + bool m_ATE; public: GSRendererHW(GSTextureCache* tc); diff --git a/plugins/GSdx/GSRendererOGL.cpp b/plugins/GSdx/GSRendererOGL.cpp index e5b6504b8c..a585cdbf03 100644 --- a/plugins/GSdx/GSRendererOGL.cpp +++ b/plugins/GSdx/GSRendererOGL.cpp @@ -203,7 +203,7 @@ void GSRendererOGL::EmulateAtst(const int pass, const GSTextureCache::Source* te static const uint32 inverted_atst[] = {ATST_ALWAYS, ATST_NEVER, ATST_GEQUAL, ATST_GREATER, ATST_NOTEQUAL, ATST_LESS, ATST_LEQUAL, ATST_EQUAL}; int atst = (pass == 2) ? inverted_atst[m_context->TEST.ATST] : m_context->TEST.ATST; - if (!m_context->TEST.ATE) return; + if (!m_ATE) return; switch (atst) { case ATST_LESS: @@ -1180,7 +1180,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour m_require_full_barrier = true; DATE_GL45 = true; DATE = false; - } else if (m_om_csel.wa && (!m_context->TEST.ATE || m_context->TEST.ATST == ATST_ALWAYS)) { + } else if (m_om_csel.wa && !m_ATE) { // Performance note: check alpha range with GetAlphaMinMax() // Note: all my dump are already above 120fps, but it seems to reduce GPU load // with big upscaling @@ -1211,7 +1211,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour DATE = false; } } - } else if (!m_om_csel.wa && (!m_context->TEST.ATE || m_context->TEST.ATST == ATST_ALWAYS)) { + } else if (!m_om_csel.wa && !m_ATE) { // TODO: is it legal ? Likely but it need to be tested carefully // DATE_GL45 = true; // m_require_one_barrier = true; << replace it with a cheap barrier