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/542946
Reviewed-by: Jamie Madill <[email protected]>
Reviewed-by: Corentin Wallez <[email protected]>
Commit-Queue: Geoff Lang <[email protected]>
This commit is contained in:
Geoff Lang authored and Commit Bot committed 2017-06-22 16:43:07 +00:00
1 parent 65ec0b2ec4
commit 579d8c7dfc
2 files changed
+12 -19

No files matched your search

+8 -18
View File
@@ -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)
{
}
+4 -1
View File
@@ -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<ContextID, SamplerCompletenessCache> mCompletenessCache;
mutable SamplerCompletenessCache mCompletenessCache;
};
bool operator==(const TextureState &a, const TextureState &b);