gsdx hw: reduce conplexity around TryAlphaTest

* As sw renderer, don't bother to bypass it when it is ATST_ALWAYS
* Don't update the ATE register value
=> It is a really bad idea. Next draw call will be wrong if TEST register isn't written.
The TryAlphaTest context could have been updated
This commit is contained in:
Gregory Hainaut 2016-09-25 15:40:12 +02:00
parent c5f086b385
commit 3996fbe365
4 changed files with 9 additions and 12 deletions

View File

@ -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)
{

View File

@ -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;

View File

@ -154,6 +154,7 @@ protected:
bool m_channel_shuffle;
bool m_double_downscale;
bool m_ATE;
public:
GSRendererHW(GSTextureCache* tc);

View File

@ -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