diff options
| author | baby.lueshi <baby.lueshi@gmail.com> | 2011-02-05 10:08:06 +0000 |
|---|---|---|
| committer | baby.lueshi <baby.lueshi@gmail.com> | 2011-02-05 10:08:06 +0000 |
| commit | 888cd787248839377c56a4d4db64bced3b3fa028 (patch) | |
| tree | 94394e0894be33e1eaff9c83dd2bc9b1bed1e575 /Source/Core/VideoCommon | |
| parent | 20e2046fe180acf5e8034c7ff035ecf4acbc9c34 (diff) | |
Changes to hi-res textures. Textures now load correctly when loading/saving a savestate, and can be toggled on and off in game.
Changed non-hi-res textures to use MurmurHash3, which has better performance that the previous hash.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7080 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/Src/HiresTextures.cpp | 7 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/HiresTextures.h | 1 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/TextureCacheBase.cpp | 40 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/TextureCacheBase.h | 5 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/VertexManagerBase.cpp | 2 |
5 files changed, 34 insertions, 21 deletions
diff --git a/Source/Core/VideoCommon/Src/HiresTextures.cpp b/Source/Core/VideoCommon/Src/HiresTextures.cpp index 1fcd996427..694150d1ac 100644 --- a/Source/Core/VideoCommon/Src/HiresTextures.cpp +++ b/Source/Core/VideoCommon/Src/HiresTextures.cpp @@ -33,6 +33,8 @@ std::map<std::string, std::string> textureMap; void Init(const char *gameCode) { + textureMap.clear(); + CFileSearch::XStringVector Directories; //Directories.push_back(std::string(File::GetUserPath(D_HIRESTEXTURES_IDX))); char szDir[MAX_PATH]; @@ -88,11 +90,6 @@ void Init(const char *gameCode) } } -void Shutdown() -{ - textureMap.clear(); -} - PC_TexFormat GetHiresTex(const char *fileName, unsigned int *pWidth, unsigned int *pHeight, int texformat, u8 *data) { std::string key(fileName); diff --git a/Source/Core/VideoCommon/Src/HiresTextures.h b/Source/Core/VideoCommon/Src/HiresTextures.h index dc4434e5d4..409c2cc260 100644 --- a/Source/Core/VideoCommon/Src/HiresTextures.h +++ b/Source/Core/VideoCommon/Src/HiresTextures.h @@ -25,7 +25,6 @@ namespace HiresTextures { void Init(const char *gameCode); -void Shutdown(); PC_TexFormat GetHiresTex(const char *fileName, unsigned int *pWidth, unsigned int *pHeight, int texformat, u8 *data); }; diff --git a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp index 3989cc57b6..e1bd47077b 100644 --- a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp @@ -23,8 +23,10 @@ enum TextureCache *g_texture_cache; -u8 *TextureCache::temp; +u8 *TextureCache::temp = NULL; + TextureCache::TexCache TextureCache::textures; +Common::CriticalSection TextureCache::texMutex; TextureCache::TCacheEntryBase::~TCacheEntryBase() { @@ -41,13 +43,17 @@ TextureCache::TCacheEntryBase::~TCacheEntryBase() TextureCache::TextureCache() { - temp = (u8*)AllocateMemoryPages(TEMP_SIZE); + if (!temp) + temp = (u8*)AllocateMemoryPages(TEMP_SIZE); TexDecoder_SetTexFmtOverlayOptions(g_ActiveConfig.bTexFmtOverlayEnable, g_ActiveConfig.bTexFmtOverlayCenter); - HiresTextures::Init(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str()); + if(g_ActiveConfig.bHiresTextures && !g_ActiveConfig.bDumpTextures) + HiresTextures::Init(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str()); + SetHash64Function(g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures); } void TextureCache::Invalidate(bool shutdown) { + texMutex.Enter(); TexCache::iterator iter = textures.begin(), tcend = textures.end(); @@ -59,14 +65,20 @@ void TextureCache::Invalidate(bool shutdown) } textures.clear(); - HiresTextures::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); + texMutex.Leave(); } TextureCache::~TextureCache() { Invalidate(true); - FreeMemoryPages(temp, TEMP_SIZE); - temp = NULL; + if (temp) + { + FreeMemoryPages(temp, TEMP_SIZE); + temp = NULL; + } } void TextureCache::Cleanup() @@ -180,22 +192,20 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage, const u32 texture_size = TexDecoder_GetTextureSizeInBytes(expandedWidth, expandedHeight, texformat); const u32 palette_size = TexDecoder_GetPaletteSize(texformat); bool texture_is_dynamic = false; - bool forceLegacyHash = (g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures); unsigned int texLevels; PC_TexFormat pcfmt = PC_TEX_FMT_NONE; - // someone who understands this var could rename it :p - const bool isC4_C8_C14X2 = (texformat == GX_TF_C4 || texformat == GX_TF_C8 || texformat == GX_TF_C14X2); + const bool isPaletteTexture = (texformat == GX_TF_C4 || texformat == GX_TF_C8 || texformat == GX_TF_C14X2); - if (isC4_C8_C14X2) + if (isPaletteTexture) full_format = texformat | (tlutfmt << 16); // hires texture loading and texture dumping require accurate hashes - if (g_ActiveConfig.bSafeTextureCache || forceLegacyHash) + if (g_ActiveConfig.bSafeTextureCache || g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures) { - texHash = GetHash64(ptr, texture_size, g_ActiveConfig.iSafeTextureCache_ColorSamples, forceLegacyHash); + texHash = GetHash64(ptr, texture_size, g_ActiveConfig.iSafeTextureCache_ColorSamples); - if (isC4_C8_C14X2) + if (isPaletteTexture) { // WARNING! texID != address now => may break CopyRenderTargetToTexture (cf. TODO up) // tlut size can be up to 32768B (GX_TF_C14X2) but Safer == Slower. @@ -206,7 +216,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage, // we must make sure that texture with different tluts get different IDs. const u64 tlutHash = GetHash64(texMem + tlutaddr, palette_size, - g_ActiveConfig.iSafeTextureCache_ColorSamples, forceLegacyHash); + g_ActiveConfig.iSafeTextureCache_ColorSamples); texHash ^= tlutHash; @@ -229,7 +239,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage, { hash_value = GetHash64(ptr, texture_size, g_ActiveConfig.iSafeTextureCache_ColorSamples); - if (isC4_C8_C14X2) + if (isPaletteTexture) { hash_value ^= GetHash64(&texMem[tlutaddr], palette_size, g_ActiveConfig.iSafeTextureCache_ColorSamples); diff --git a/Source/Core/VideoCommon/Src/TextureCacheBase.h b/Source/Core/VideoCommon/Src/TextureCacheBase.h index 201bd1dc65..9561e3b1e4 100644 --- a/Source/Core/VideoCommon/Src/TextureCacheBase.h +++ b/Source/Core/VideoCommon/Src/TextureCacheBase.h @@ -7,6 +7,7 @@ #include "VideoCommon.h" #include "TextureDecoder.h" #include "BPMemory.h" +#include "Thread.h" #include "CommonTypes.h" @@ -71,6 +72,8 @@ public: virtual ~TextureCache(); // needs virtual for DX11 dtor + static void Init(); + static void Shutdown(); static void Cleanup(); static void Invalidate(bool shutdown); @@ -88,6 +91,8 @@ public: static void CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, bool bScaleByHalf, const EFBRectangle &source_rect); + static Common::CriticalSection texMutex; + protected: TextureCache(); diff --git a/Source/Core/VideoCommon/Src/VertexManagerBase.cpp b/Source/Core/VideoCommon/Src/VertexManagerBase.cpp index 84c53b3ebf..7b07430c8f 100644 --- a/Source/Core/VideoCommon/Src/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/Src/VertexManagerBase.cpp @@ -158,7 +158,9 @@ void VertexManager::AddVertices(int primitive, int numVertices) void VertexManager::Flush() { + TextureCache::texMutex.Enter(); g_vertex_manager->vFlush(); + TextureCache::texMutex.Leave(); } // TODO: need to merge more stuff into VideoCommon to use this |
