diff --git a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp index 1dfcfbe562..0dd5b51535 100644 --- a/pcsx2/GS/Renderers/HW/GSTextureCache.cpp +++ b/pcsx2/GS/Renderers/HW/GSTextureCache.cpp @@ -2436,15 +2436,17 @@ 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 GSLocalMemory::psm_t& spsm_s = GSLocalMemory::m_psm[SPSM]; + const GSLocalMemory::psm_t& dpsm_s = GSLocalMemory::m_psm[DPSM]; if (GSConfig.Renderer == GSRendererType::DX11 || GSConfig.Renderer == GSRendererType::DX12) { - if (GSLocalMemory::m_psm[SPSM].depth || GSLocalMemory::m_psm[DPSM].depth) + if (spsm_s.depth || dpsm_s.depth) return false; } // Look for an exact match on the targets. - GSTextureCache::Target* src = GetExactTarget(SBP, SBW, SPSM); - GSTextureCache::Target* dst = GetExactTarget(DBP, DBW, DPSM); + GSTextureCache::Target* src = GetExactTarget(SBP, SBW, spsm_s.depth ? DepthStencil : RenderTarget); + GSTextureCache::Target* dst = GetExactTarget(DBP, DBW, dpsm_s.depth ? DepthStencil : RenderTarget); // Beware of the case where a game might create a larger texture by moving a bunch of chunks around. // We use dx/dy == 0 and the TBW check as a safeguard to make sure these go through to local memory. @@ -2652,14 +2654,17 @@ bool GSTextureCache::ShuffleMove(u32 BP, u32 BW, u32 PSM, int sx, int sy, int dx return true; } -GSTextureCache::Target* GSTextureCache::GetExactTarget(u32 BP, u32 BW, u32 PSM) const +GSTextureCache::Target* GSTextureCache::GetExactTarget(u32 BP, u32 BW, int type) { - auto& rts = m_dst[GSLocalMemory::m_psm[PSM].depth ? DepthStencil : RenderTarget]; + auto& rts = m_dst[type]; for (auto it = rts.begin(); it != rts.end(); ++it) // Iterate targets from MRU to LRU. { Target* t = *it; - if (t->m_TEX0.TBP0 == BP && t->m_TEX0.TBW == BW && t->m_TEX0.PSM == PSM) + if (t->m_TEX0.TBP0 == BP && t->m_TEX0.TBW == BW) + { + rts.MoveFront(it.Index()); return t; + } } return nullptr; diff --git a/pcsx2/GS/Renderers/HW/GSTextureCache.h b/pcsx2/GS/Renderers/HW/GSTextureCache.h index 922da7cc48..e1eb311b0f 100644 --- a/pcsx2/GS/Renderers/HW/GSTextureCache.h +++ b/pcsx2/GS/Renderers/HW/GSTextureCache.h @@ -444,8 +444,8 @@ public: bool is_frame = false, bool is_clear = false, bool preload = GSConfig.PreloadFrameWithGSData); Target* LookupDisplayTarget(GIFRegTEX0 TEX0, const GSVector2i& size, float scale); - /// Looks up a target in the cache, and only returns it if the BP/BW/PSM match exactly. - Target* GetExactTarget(u32 BP, u32 BW, u32 PSM) const; + /// Looks up a target in the cache, and only returns it if the BP/BW match exactly. + Target* GetExactTarget(u32 BP, u32 BW, int type); Target* GetTargetWithSharedBits(u32 BP, u32 PSM) const; GSVector2i GetTargetSize(u32 bp, u32 fbw, u32 psm, s32 min_width, s32 min_height);