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 From 8bed27a3d1e3044d8e3ce02c17b6bd07b8130e80 Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Mon, 28 May 2012 11:37:14 +0200 Subject: Enable hires textures even when texture dumping is enabled. Remove some deprecated code. --- Source/Core/VideoCommon/Src/TextureCacheBase.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 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 cc5a0f29b4..69e4bffff8 100644 --- a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp @@ -61,28 +61,19 @@ TextureCache::TextureCache() SetHash64Function(g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures); } -// TODO: Kill shutdown parameter... -void TextureCache::Invalidate(bool shutdown) +void TextureCache::Invalidate() { TexCache::iterator iter = textures.begin(), tcend = textures.end(); for (; iter != tcend; ++iter) - { - if (shutdown) - iter->second->addr = 0; delete iter->second; - } textures.clear(); - if(g_ActiveConfig.bHiresTextures && !g_ActiveConfig.bDumpTextures) - HiresTextures::Init(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str()); - SetHash64Function(g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures); } TextureCache::~TextureCache() { - Invalidate(true); if (temp) { FreeAlignedMemory(temp); @@ -100,7 +91,14 @@ void TextureCache::OnConfigChanged(VideoConfig& config) 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); + { + g_texture_cache->Invalidate(); + + if(g_ActiveConfig.bHiresTextures) + HiresTextures::Init(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str()); + + SetHash64Function(g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures); + } // 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? -- cgit v1.2.3 From 8a5abbddc41120ec21a5bb2632279895b884c1ff Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Mon, 28 May 2012 11:39:55 +0200 Subject: Enable texture format overlay on the fly. --- Source/Core/VideoCommon/Src/TextureCacheBase.cpp | 1 + 1 file changed, 1 insertion(+) (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 69e4bffff8..268eab38d1 100644 --- a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp @@ -98,6 +98,7 @@ void TextureCache::OnConfigChanged(VideoConfig& config) HiresTextures::Init(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str()); SetHash64Function(g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures); + TexDecoder_SetTexFmtOverlayOptions(g_ActiveConfig.bTexFmtOverlayEnable, g_ActiveConfig.bTexFmtOverlayCenter); } // TODO: Probably shouldn't clear all render targets here, just mark them dirty or something. -- cgit v1.2.3 From 043a85f8a6dc55d5ef390115ca2c745bd5810339 Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Sun, 3 Jun 2012 13:02:11 +0200 Subject: Minor cleanup. --- Source/Core/VideoCommon/Src/TextureCacheBase.cpp | 12 ++++-------- 1 file changed, 4 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 268eab38d1..7b79944b0c 100644 --- a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp @@ -763,16 +763,12 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat TCacheEntryBase *entry = textures[dstAddr]; if (entry) { - if ((entry->type == TCET_EC_VRAM && entry->virtual_width == scaled_tex_w && entry->virtual_height == scaled_tex_h) - || (entry->type == TCET_EC_DYNAMIC && entry->native_width == tex_w && entry->native_height == tex_h)) + if (entry->type == TCET_EC_DYNAMIC && entry->native_width == tex_w && entry->native_height == tex_h) { - if (entry->type == TCET_EC_DYNAMIC) - { - scaled_tex_w = tex_w; - scaled_tex_h = tex_h; - } + scaled_tex_w = tex_w; + scaled_tex_h = tex_h; } - else + else if (!(entry->type == TCET_EC_VRAM && entry->virtual_width == scaled_tex_w && entry->virtual_height == scaled_tex_h)) { // remove it and recreate it as a render target delete entry; -- cgit v1.2.3 From 7dabba5095fd2a939d4ff8eeab8781240f65e149 Mon Sep 17 00:00:00 2001 From: NeoBrainX Date: Sun, 3 Jun 2012 13:03:20 +0200 Subject: Fix a small bug. --- Source/Core/VideoCommon/Src/TextureCacheBase.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 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 7b79944b0c..e9c2dbe9f3 100644 --- a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp @@ -355,8 +355,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage, // 2. a) For EFB copies, only the hash and the texture address need to match if (entry->IsEfbCopy() && tex_hash == entry->hash && address == entry->addr) { - if (entry->type != TCET_EC_VRAM) - entry->type = TCET_NORMAL; + entry->type = TCET_EC_VRAM; // TODO: Print a warning if the format changes! In this case, we could reinterpret the internal texture object data to the new pixel format (similiar to what is already being done in Renderer::ReinterpretPixelFormat()) goto return_entry; -- cgit v1.2.3