summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorNeoBrainX <NeoBrainX@googlemail.com>2010-10-24 15:16:31 +0000
committerNeoBrainX <NeoBrainX@googlemail.com>2010-10-24 15:16:31 +0000
commit52cd3aee95b80d5c81c319f2c089c24ee05a0d30 (patch)
tree8285938a51c46bd226813e721fa3ac1bcd9ca0df /Source/Core
parent56e79aa87da99172896844d891102193f323fc5c (diff)
Fix a major speed regression from r6288:
Upon texture reloading, the cache entry hash wasn't updated and thus we effectively disabled any texture caching in that case. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6308 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoCommon/Src/TextureCacheBase.cpp51
-rw-r--r--Source/Core/VideoCommon/Src/TextureCacheBase.h4
2 files changed, 29 insertions, 26 deletions
diff --git a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp
index 4ae678c66a..a3d6c62740 100644
--- a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp
+++ b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp
@@ -191,7 +191,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
if (g_ActiveConfig.bSafeTextureCache || g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures)
{
texHash = GetHash64(ptr, texture_size, g_ActiveConfig.iSafeTextureCache_ColorSamples);
-
+
if (isC4_C8_C14X2)
{
// WARNING! texID != address now => may break CopyRenderTargetToTexture (cf. TODO up)
@@ -208,7 +208,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
texHash ^= tlutHash;
if (g_ActiveConfig.bSafeTextureCache)
- texID ^= ((u32)tlutHash) ^ (tlutHash >> 32);
+ texID ^= ((u32)tlutHash) ^ (u32)(tlutHash >> 32);
}
if (g_ActiveConfig.bSafeTextureCache)
@@ -218,11 +218,11 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
TCacheEntryBase *entry = textures[texID];
if (entry)
{
- if (false == g_ActiveConfig.bSafeTextureCache)
+ if (!g_ActiveConfig.bSafeTextureCache)
{
if (entry->isRenderTarget || entry->isDynamic)
{
- if (false == g_ActiveConfig.bCopyEFBToTexture)
+ if (!g_ActiveConfig.bCopyEFBToTexture)
{
hash_value = GetHash64(ptr, texture_size, g_ActiveConfig.iSafeTextureCache_ColorSamples);
@@ -263,7 +263,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
// TODO: Is the mipLevels check needed?
if (!entry->isRenderTarget &&
- ((!entry->isDynamic && width == entry->realW && height == entry->realH && full_format == entry->format && entry->mipLevels == maxlevel)
+ ((!entry->isDynamic && width == entry->realW && height == entry->realH && full_format == entry->format && entry->mipLevels == maxlevel)
|| (entry->isDynamic && entry->realW == width && entry->realH == height)))
{
// reuse the texture
@@ -310,33 +310,36 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage,
texLevels = maxlevel + 1;
// create the entry/texture
- if (NULL == entry)
- {
+ if (NULL == entry) {
textures[texID] = entry = g_texture_cache->CreateTexture(width, height, expandedWidth, texLevels, pcfmt);
- entry->addr = address;
- entry->format = full_format;
+ // Sometimes, we can get around recreating a texture if only the number of mip levels gets changes
+ // e.g. if our texture cache entry got too many mipmap levels we can limit the number of used levels by setting the appropriate render states
+ // Thus, we don't update this member for every Load, but just whenever the texture gets recreated
entry->mipLevels = maxlevel;
- entry->size_in_bytes = texture_size;
+ }
+
+ entry->addr = address;
+ entry->format = full_format;
+ entry->size_in_bytes = texture_size;
- entry->virtualW = width;
- entry->virtualH = height;
+ entry->virtualW = width;
+ entry->virtualH = height;
- entry->realW = nativeW;
- entry->realH = nativeH;
+ entry->realW = nativeW;
+ entry->realH = nativeH;
- entry->isRenderTarget = false;
- entry->isNonPow2 = false;
- entry->isDynamic = texture_is_dynamic;
+ entry->isRenderTarget = false;
+ entry->isNonPow2 = false;
+ entry->isDynamic = texture_is_dynamic;
- entry->oldpixel = *(u32*)ptr;
+ entry->oldpixel = *(u32*)ptr;
- if (g_ActiveConfig.bSafeTextureCache || entry->isDynamic)
- entry->hash = hash_value;
- else
- // don't like rand() here
- entry->hash = *(u32*)ptr = (u32)(((double)rand() / RAND_MAX) * 0xFFFFFFFF);
- }
+ if (g_ActiveConfig.bSafeTextureCache || entry->isDynamic)
+ entry->hash = hash_value;
+ else
+ // don't like rand() here
+ entry->hash = *(u32*)ptr = (u32)(((double)rand() / RAND_MAX) * 0xFFFFFFFF);
// load texture
entry->Load(width, height, expandedWidth, 0);
diff --git a/Source/Core/VideoCommon/Src/TextureCacheBase.h b/Source/Core/VideoCommon/Src/TextureCacheBase.h
index 0793f8dd19..24ca3dd761 100644
--- a/Source/Core/VideoCommon/Src/TextureCacheBase.h
+++ b/Source/Core/VideoCommon/Src/TextureCacheBase.h
@@ -34,8 +34,8 @@ public:
unsigned int mipLevels;
- bool isRenderTarget;
- bool isDynamic; // mofified from cpu
+ bool isRenderTarget; // copied from EFB
+ bool isDynamic; // Used for hybrid EFB copies to enable checks for CPU modifications
bool isNonPow2; // doesn't seem to be used anywhere
//TCacheEntryBase()