GS/HW: Fix invalid self copy from move in DX renderers

This commit is contained in:
Connor McLaughlin 2024-05-11 21:04:37 +10:00
parent fdb751ed1a
commit 95843dc84a
1 changed files with 4 additions and 2 deletions

View File

@ -3626,7 +3626,8 @@ bool GSTextureCache::Move(u32 SBP, u32 SBW, u32 SPSM, int sx, int sy, u32 DBP, u
// DX11/12 is a bit lame and can't partial copy depth targets. We could do this with a blit instead,
// but so far haven't seen anything which needs it.
const GSRendererType renderer = GSGetCurrentRenderer();
if (renderer == GSRendererType::DX11 || renderer == GSRendererType::DX12)
const bool renderer_is_directx = (renderer == GSRendererType::DX11 || renderer == GSRendererType::DX12);
if (renderer_is_directx)
{
if (spsm_s.depth || dpsm_s.depth)
return false;
@ -3744,7 +3745,8 @@ bool GSTextureCache::Move(u32 SBP, u32 SBW, u32 SPSM, int sx, int sy, u32 DBP, u
}
// If the copies overlap, this is a validation error, so we need to copy to a temporary texture first.
if ((SBP == DBP) && !(GSVector4i(sx, sy, sx + w, sy + h).rintersect(GSVector4i(dx, dy, dx + w, dy + h))).rempty())
// DirectX also can't copy to the same texture it's reading from (except potentially with enhanced barriers).
if (SBP == DBP && (!(GSVector4i(sx, sy, sx + w, sy + h).rintersect(GSVector4i(dx, dy, dx + w, dy + h))).rempty() || renderer_is_directx))
{
GSTexture* tmp_texture = src->m_texture->IsDepthStencil() ?
g_gs_device->CreateDepthStencil(src->m_texture->GetWidth(), src->m_texture->GetHeight(), src->m_texture->GetFormat(), false) :