GS: Flush targets back to GS memory when swapping renderers

This commit is contained in:
refractionpcsx2 2023-02-18 20:09:22 +00:00
parent e846ac367a
commit cd4c1e920e
4 changed files with 9 additions and 3 deletions

View File

@ -800,6 +800,8 @@ void GSSwitchRenderer(GSRendererType new_renderer)
if (existing_api == RenderAPI::OpenGLES)
existing_api = RenderAPI::OpenGL;
g_gs_renderer->PurgeTextureCache();
const bool is_software_switch = (new_renderer == GSRendererType::SW || GSConfig.Renderer == GSRendererType::SW);
const bool recreate_display = (!is_software_switch && existing_api != GetAPIForRenderer(new_renderer));
const Pcsx2Config::GSOptions old_config(GSConfig);

View File

@ -72,7 +72,7 @@ void GSRendererHW::Destroy()
void GSRendererHW::PurgeTextureCache()
{
GSRenderer::PurgeTextureCache();
m_tc->RemoveAll();
m_tc->RemoveAll(true);
}
GSTexture* GSRendererHW::LookupPaletteSource(u32 CBP, u32 CPSM, u32 CBW, GSVector2i& offset, const GSVector2i& size)

View File

@ -46,14 +46,18 @@ GSTextureCache::~GSTextureCache()
_aligned_free(s_unswizzle_buffer);
}
void GSTextureCache::RemoveAll()
void GSTextureCache::RemoveAll(bool readback_targets)
{
m_src.RemoveAll();
for (int type = 0; type < 2; type++)
{
for (auto t : m_dst[type])
{
if (readback_targets)
Read(t, t->m_drawn_since_read);
delete t;
}
m_dst[type].clear();
}

View File

@ -396,7 +396,7 @@ public:
void Read(Target* t, const GSVector4i& r);
void Read(Source* t, const GSVector4i& r);
void RemoveAll();
void RemoveAll(bool readback_targets = false);
void AddDirtyRectTarget(Target* target, GSVector4i rect, u32 psm, u32 bw);
GSTexture* LookupPaletteSource(u32 CBP, u32 CPSM, u32 CBW, GSVector2i& offset, const GSVector2i& size);