diff --git a/src/libANGLE/Texture.cpp b/src/libANGLE/Texture.cpp index ddbb5d482..9619087ad 100644 --- a/src/libANGLE/Texture.cpp +++ b/src/libANGLE/Texture.cpp @@ -200,30 +200,20 @@ bool TextureState::isCubeComplete() const bool TextureState::isSamplerComplete(const SamplerState &samplerState, const ContextState &data) const { - bool newEntry = false; - auto cacheIter = mCompletenessCache.find(data.getContextID()); - if (cacheIter == mCompletenessCache.end()) + if (data.getContextID() != mCompletenessCache.context || + mCompletenessCache.samplerState != samplerState) { - // Add a new cache entry - cacheIter = mCompletenessCache - .insert(std::make_pair(data.getContextID(), SamplerCompletenessCache())) - .first; - newEntry = true; + mCompletenessCache.context = data.getContextID(); + mCompletenessCache.samplerState = samplerState; + mCompletenessCache.samplerComplete = computeSamplerCompleteness(samplerState, data); } - SamplerCompletenessCache *cacheEntry = &cacheIter->second; - if (newEntry || cacheEntry->samplerState != samplerState) - { - cacheEntry->samplerState = samplerState; - cacheEntry->samplerComplete = computeSamplerCompleteness(samplerState, data); - } - - return cacheEntry->samplerComplete; + return mCompletenessCache.samplerComplete; } void TextureState::invalidateCompletenessCache() { - mCompletenessCache.clear(); + mCompletenessCache.context = 0; } bool TextureState::computeSamplerCompleteness(const SamplerState &samplerState, @@ -514,7 +504,7 @@ void TextureState::clearImageDescs() } TextureState::SamplerCompletenessCache::SamplerCompletenessCache() - : samplerState(), samplerComplete(false) + : context(0), samplerState(), samplerComplete(false) { } diff --git a/src/libANGLE/Texture.h b/src/libANGLE/Texture.h index 13c755a62..31fd0fbe7 100644 --- a/src/libANGLE/Texture.h +++ b/src/libANGLE/Texture.h @@ -160,6 +160,9 @@ struct TextureState final : private angle::NonCopyable { SamplerCompletenessCache(); + // Context used to generate this cache entry + ContextID context; + // All values that affect sampler completeness that are not stored within // the texture itself SamplerState samplerState; @@ -168,7 +171,7 @@ struct TextureState final : private angle::NonCopyable bool samplerComplete; }; - mutable std::unordered_map mCompletenessCache; + mutable SamplerCompletenessCache mCompletenessCache; }; bool operator==(const TextureState &a, const TextureState &b);