diff options
| author | degasus <wickmarkus@web.de> | 2015-01-17 10:57:19 +0100 |
|---|---|---|
| committer | degasus <wickmarkus@web.de> | 2015-01-18 19:58:33 +0100 |
| commit | 8565f0269978cb0414ccddfc212312f132acc035 (patch) | |
| tree | c57901c2d22bbc42ca03f1517e92df26b366ed11 /Source/Core/VideoCommon/TextureCacheBase.cpp | |
| parent | 4639d3b1bc3a882461645e0356c894c7d79a28f8 (diff) | |
TexCache: use an unordered_multimap for the tex pool
Diffstat (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/TextureCacheBase.cpp | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index f87b10aba9..f9f603e8e5 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -31,7 +31,7 @@ GC_ALIGNED16(u8 *TextureCache::temp) = nullptr; size_t TextureCache::temp_size; TextureCache::TexCache TextureCache::textures; -TextureCache::TexturePool TextureCache::texture_pool; +TextureCache::TexPool TextureCache::texture_pool; TextureCache::BackupConfig TextureCache::backup_config; @@ -82,7 +82,7 @@ void TextureCache::Invalidate() for (auto& rt : texture_pool) { - delete rt; + delete rt.second; } texture_pool.clear(); } @@ -161,19 +161,22 @@ void TextureCache::Cleanup(int _frameCount) } } - for (size_t i = 0; i < texture_pool.size();) + TexPool::iterator iter2 = texture_pool.begin(); + TexPool::iterator tcend2 = texture_pool.end(); + while (iter2 != tcend2) { - auto rt = texture_pool[i]; - - if (_frameCount > TEXTURE_POOL_KILL_THRESHOLD + rt->frameCount) + if(iter2->second->frameCount == FRAMECOUNT_INVALID) + { + iter2->second->frameCount = _frameCount; + } + if (_frameCount > TEXTURE_POOL_KILL_THRESHOLD + iter2->second->frameCount) { - delete rt; - texture_pool[i] = texture_pool.back(); - texture_pool.pop_back(); + delete iter2->second; + iter2 = texture_pool.erase(iter2); } else { - ++i; + ++iter2; } } } @@ -888,17 +891,12 @@ void TextureCache::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFormat TextureCache::TCacheEntryBase* TextureCache::AllocateTexture(const TCacheEntryConfig& config) { - for (size_t i = 0; i < texture_pool.size(); ++i) + TexPool::iterator iter = texture_pool.find(config); + if (iter != texture_pool.end()) { - auto rt = texture_pool[i]; - - if (rt->config == config) - { - texture_pool[i] = texture_pool.back(); - texture_pool.pop_back(); - - return rt; - } + TextureCache::TCacheEntryBase* entry = iter->second; + texture_pool.erase(iter); + return entry; } INCSTAT(stats.numTexturesCreated); @@ -907,5 +905,6 @@ TextureCache::TCacheEntryBase* TextureCache::AllocateTexture(const TCacheEntryCo void TextureCache::FreeTexture(TCacheEntryBase* entry) { - texture_pool.push_back(entry); + entry->frameCount = FRAMECOUNT_INVALID; + texture_pool.insert(TexPool::value_type(entry->config, entry)); } |
