Commit 579d8c7d by Geoff Lang Committed by Commit Bot

Only use the last context for the texture completeness cache.

The frequency of contexts switches is very slow compared to draw calls. Instead of doing a map lookup, only store the completeness cache for the last context used with the texture. BUG=angleproject:2078 Change-Id: Ia24c891e1b5781b61fd463ce70e90d4b394c6f8a Reviewed-on: https://chromium-review.googlesource.com/542946Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 65ec0b2e
...@@ -200,30 +200,20 @@ bool TextureState::isCubeComplete() const ...@@ -200,30 +200,20 @@ bool TextureState::isCubeComplete() const
bool TextureState::isSamplerComplete(const SamplerState &samplerState, bool TextureState::isSamplerComplete(const SamplerState &samplerState,
const ContextState &data) const const ContextState &data) const
{ {
bool newEntry = false; if (data.getContextID() != mCompletenessCache.context ||
auto cacheIter = mCompletenessCache.find(data.getContextID()); mCompletenessCache.samplerState != samplerState)
if (cacheIter == mCompletenessCache.end())
{ {
// Add a new cache entry mCompletenessCache.context = data.getContextID();
cacheIter = mCompletenessCache mCompletenessCache.samplerState = samplerState;
.insert(std::make_pair(data.getContextID(), SamplerCompletenessCache())) mCompletenessCache.samplerComplete = computeSamplerCompleteness(samplerState, data);
.first;
newEntry = true;
} }
SamplerCompletenessCache *cacheEntry = &cacheIter->second; return mCompletenessCache.samplerComplete;
if (newEntry || cacheEntry->samplerState != samplerState)
{
cacheEntry->samplerState = samplerState;
cacheEntry->samplerComplete = computeSamplerCompleteness(samplerState, data);
}
return cacheEntry->samplerComplete;
} }
void TextureState::invalidateCompletenessCache() void TextureState::invalidateCompletenessCache()
{ {
mCompletenessCache.clear(); mCompletenessCache.context = 0;
} }
bool TextureState::computeSamplerCompleteness(const SamplerState &samplerState, bool TextureState::computeSamplerCompleteness(const SamplerState &samplerState,
...@@ -514,7 +504,7 @@ void TextureState::clearImageDescs() ...@@ -514,7 +504,7 @@ void TextureState::clearImageDescs()
} }
TextureState::SamplerCompletenessCache::SamplerCompletenessCache() TextureState::SamplerCompletenessCache::SamplerCompletenessCache()
: samplerState(), samplerComplete(false) : context(0), samplerState(), samplerComplete(false)
{ {
} }
......
...@@ -160,6 +160,9 @@ struct TextureState final : private angle::NonCopyable ...@@ -160,6 +160,9 @@ struct TextureState final : private angle::NonCopyable
{ {
SamplerCompletenessCache(); SamplerCompletenessCache();
// Context used to generate this cache entry
ContextID context;
// All values that affect sampler completeness that are not stored within // All values that affect sampler completeness that are not stored within
// the texture itself // the texture itself
SamplerState samplerState; SamplerState samplerState;
...@@ -168,7 +171,7 @@ struct TextureState final : private angle::NonCopyable ...@@ -168,7 +171,7 @@ struct TextureState final : private angle::NonCopyable
bool samplerComplete; bool samplerComplete;
}; };
mutable std::unordered_map<ContextID, SamplerCompletenessCache> mCompletenessCache; mutable SamplerCompletenessCache mCompletenessCache;
}; };
bool operator==(const TextureState &a, const TextureState &b); bool operator==(const TextureState &a, const TextureState &b);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment