diff options
| author | Markus Wick <degasus@users.noreply.github.com> | 2016-10-06 12:27:23 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-06 12:27:23 +0200 |
| commit | 3c822f2c55a436d1b5c8c1f075dd8e9fad219b6e (patch) | |
| tree | 6055627a57841a78304c529a75222eb803dde2b7 /Source/Core/VideoCommon/TextureCacheBase.cpp | |
| parent | 062de51d707e68c40910b8c2cc11638d45b8805c (diff) | |
| parent | b6d09c61ed328259f2e43bc9e14ad725d8ba0017 (diff) | |
Merge pull request #4304 from stenzek/pool-reuse
TextureCache: Don't re-use pooled textures within the same frame
Diffstat (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/TextureCacheBase.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index 39af7f155c..0f8a39b341 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -1353,7 +1353,7 @@ void TextureCacheBase::CopyRenderTargetToTexture(u32 dstAddr, unsigned int dstFo TextureCacheBase::TCacheEntryBase* TextureCacheBase::AllocateTexture(const TCacheEntryConfig& config) { - TexPool::iterator iter = texture_pool.find(config); + TexPool::iterator iter = FindMatchingTextureFromPool(config); TextureCacheBase::TCacheEntryBase* entry; if (iter != texture_pool.end()) { @@ -1373,6 +1373,19 @@ TextureCacheBase::AllocateTexture(const TCacheEntryConfig& config) return entry; } +TextureCacheBase::TexPool::iterator +TextureCacheBase::FindMatchingTextureFromPool(const TCacheEntryConfig& config) +{ + // Find a texture from the pool that does not have a frameCount of FRAMECOUNT_INVALID. + // This prevents a texture from being used twice in a single frame with different data, + // which potentially means that a driver has to maintain two copies of the texture anyway. + auto range = texture_pool.equal_range(config); + auto matching_iter = std::find_if(range.first, range.second, [](const auto& iter) { + return iter.second->frameCount != FRAMECOUNT_INVALID; + }); + return matching_iter != range.second ? matching_iter : texture_pool.end(); +} + TextureCacheBase::TexCache::iterator TextureCacheBase::GetTexCacheIter(TextureCacheBase::TCacheEntryBase* entry) { |
