GS/HW: Don't disable depth testing for channel shuffle

Mercenaries needs it. But we can skip it when z testing is off.
This commit is contained in:
Connor McLaughlin 2022-02-01 19:33:07 +10:00 committed by lightningterror
parent 8ce8ac4404
commit d29f843525
2 changed files with 22 additions and 17 deletions

View File

@ -479,6 +479,8 @@ void GSRendererNew::EmulateChannelShuffle(const GSTextureCache::Source* tex)
if (m_channel_shuffle) if (m_channel_shuffle)
{ {
m_conf.tex = tex->m_from_target; m_conf.tex = tex->m_from_target;
if (m_conf.tex)
{
if (m_conf.tex == m_conf.rt) if (m_conf.tex == m_conf.rt)
{ {
// sample from fb instead // sample from fb instead
@ -488,9 +490,13 @@ void GSRendererNew::EmulateChannelShuffle(const GSTextureCache::Source* tex)
} }
else if (m_conf.tex == m_conf.ds) else if (m_conf.tex == m_conf.ds)
{ {
// using the current depth buffer. make sure it's not bound (needed for not-GL). // if depth testing is disabled, we don't need to copy, and can just unbind the depth buffer
// no need for a barrier for GL either, since it's not bound to depth and texture concurrently
// otherwise, the backend should recognise the hazard, and copy the buffer (D3D/Vulkan).
if (m_conf.depth.ztst == ZTST_ALWAYS)
m_conf.ds = nullptr; m_conf.ds = nullptr;
} }
}
// Replace current draw with a fullscreen sprite // Replace current draw with a fullscreen sprite
// //
@ -1165,6 +1171,9 @@ void GSRendererNew::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
ASSERT(g_gs_device != NULL); ASSERT(g_gs_device != NULL);
// Z setup has to come before channel shuffle
EmulateZbuffer();
// HLE implementation of the channel selection effect // HLE implementation of the channel selection effect
// //
// Warning it must be done at the begining because it will change the // Warning it must be done at the begining because it will change the
@ -1315,11 +1324,6 @@ void GSRendererNew::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
m_conf.datm = m_context->TEST.DATM; m_conf.datm = m_context->TEST.DATM;
// om
if (!m_channel_shuffle)
EmulateZbuffer(); // will update VS depth mask
// vs // vs
m_conf.vs.tme = PRIM->TME; m_conf.vs.tme = PRIM->TME;

View File

@ -2043,9 +2043,10 @@ void GSDeviceOGL::SendHWDraw(const GSHWDrawConfig& config)
DrawIndexedPrimitive(p, config.indices_per_prim); DrawIndexedPrimitive(p, config.indices_per_prim);
} }
} }
else if (config.require_one_barrier) else if (config.require_one_barrier || (config.tex && config.tex == config.ds))
{ {
// One barrier needed // The common renderer code doesn't put a barrier here because D3D/VK need to copy the DS, so we need to check it.
// One barrier needed for non-overlapping draw.
glTextureBarrier(); glTextureBarrier();
DrawIndexedPrimitive(); DrawIndexedPrimitive();
} }