summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Src/TextureCacheBase.cpp
diff options
context:
space:
mode:
authorNeoBrainX <NeoBrainX@gmail.com>2012-06-21 22:20:48 +0200
committerNeoBrainX <NeoBrainX@gmail.com>2012-06-21 22:21:34 +0200
commit29e21026e9bf790a21f5a398d151e683196ade1e (patch)
treebd5a970200f37bf9a5fc1c5239ce3fa5df4aacb6 /Source/Core/VideoCommon/Src/TextureCacheBase.cpp
parentfa2ee1f4a0bf7e6ba4432e8e4bd1e726bec434d5 (diff)
parent1c8cdebc22818d1802297be8993662ef6301b1e5 (diff)
Merge branch 'awesome-texcache-cleanups-and-fixes'
Diffstat (limited to 'Source/Core/VideoCommon/Src/TextureCacheBase.cpp')
-rw-r--r--Source/Core/VideoCommon/Src/TextureCacheBase.cpp78
1 files changed, 51 insertions, 27 deletions
diff --git a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp
index bb240d5df3..e9c2dbe9f3 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,34 +61,19 @@ TextureCache::TextureCache()
SetHash64Function(g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures);
}
-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);
-
- DeferredInvalidate = false;
-}
-
-void TextureCache::InvalidateDefer()
-{
- DeferredInvalidate = true;
}
TextureCache::~TextureCache()
{
- Invalidate(true);
if (temp)
{
FreeAlignedMemory(temp);
@@ -94,6 +81,48 @@ 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();
+
+ if(g_ActiveConfig.bHiresTextures)
+ 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.
+ 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();
@@ -326,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;
@@ -734,16 +762,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;