From 8d30ac462a499d0bde615c260bf9c69146859b9a Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Mon, 28 May 2012 11:31:37 +0200 Subject: Instead of invalidating texcache whenever the graphics configuration dialog gets opened, clean up textures on configuration changes. --- Source/Core/VideoCommon/Src/TextureCacheBase.cpp | 46 +++++++++++++++++++----- 1 file changed, 38 insertions(+), 8 deletions(-) (limited to 'Source/Core/VideoCommon/Src/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp index bb240d5df3..cc5a0f29b4 100644 --- a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp @@ -42,7 +42,9 @@ GC_ALIGNED16(u8 *TextureCache::temp) = NULL; unsigned int TextureCache::temp_size; TextureCache::TexCache TextureCache::textures; -bool TextureCache::DeferredInvalidate; + +TextureCache::BackupConfig TextureCache::backup_config; + TextureCache::TCacheEntryBase::~TCacheEntryBase() { @@ -59,6 +61,7 @@ TextureCache::TextureCache() SetHash64Function(g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures); } +// TODO: Kill shutdown parameter... void TextureCache::Invalidate(bool shutdown) { TexCache::iterator @@ -75,13 +78,6 @@ void TextureCache::Invalidate(bool shutdown) if(g_ActiveConfig.bHiresTextures && !g_ActiveConfig.bDumpTextures) HiresTextures::Init(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str()); SetHash64Function(g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures); - - DeferredInvalidate = false; -} - -void TextureCache::InvalidateDefer() -{ - DeferredInvalidate = true; } TextureCache::~TextureCache() @@ -94,6 +90,40 @@ TextureCache::~TextureCache() } } +void TextureCache::OnConfigChanged(VideoConfig& config) +{ + if (!g_texture_cache) + goto skip_checks; + + // TODO: Invalidating texcache is really stupid in some of these cases + if (config.iSafeTextureCache_ColorSamples != backup_config.s_colorsamples || + config.bTexFmtOverlayEnable != backup_config.s_texfmt_overlay || + config.bTexFmtOverlayCenter != backup_config.s_texfmt_overlay_center || + config.bHiresTextures != backup_config.s_hires_textures) + g_texture_cache->Invalidate(false); + + // TODO: Probably shouldn't clear all render targets here, just mark them dirty or something. + if (config.bEFBCopyCacheEnable != backup_config.s_copy_cache_enable || // TODO: not sure if this is needed? + config.bCopyEFBToTexture != backup_config.s_copy_efb_to_texture || + config.bCopyEFBScaled != backup_config.s_copy_efb_scaled || + config.bEFBCopyEnable != backup_config.s_copy_efb || + config.iEFBScale != backup_config.s_efb_scale) + { + g_texture_cache->ClearRenderTargets(); + } + +skip_checks: + backup_config.s_colorsamples = config.iSafeTextureCache_ColorSamples; + backup_config.s_copy_efb_to_texture = config.bCopyEFBToTexture; + backup_config.s_copy_efb_scaled = config.bCopyEFBScaled; + backup_config.s_copy_efb = config.bEFBCopyEnable; + backup_config.s_efb_scale = config.iEFBScale; + backup_config.s_texfmt_overlay = config.bTexFmtOverlayEnable; + backup_config.s_texfmt_overlay_center = config.bTexFmtOverlayCenter; + backup_config.s_hires_textures = config.bHiresTextures; + backup_config.s_copy_cache_enable = config.bEFBCopyCacheEnable; +} + void TextureCache::Cleanup() { TexCache::iterator iter = textures.begin(); -- cgit v1.2.3