diff options
author | bsalomon <bsalomon@google.com> | 2016-09-22 12:42:11 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-09-22 12:42:11 -0700 |
commit | e2e87f3484e5524dbfd6c01f402136738d1d434b (patch) | |
tree | 6562a880cb3c1bc8d028cb78e188a7ba01b4c205 /src/gpu/GrResourceCache.h | |
parent | 5745d795a15333f80c7526bf3643212773c5b3b7 (diff) |
Change implementation of flush-count based GrGpuResource purging
Change default to approx 30seconds (given some API usage assumptions)
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2361093002
Review-Url: https://codereview.chromium.org/2361093002
Diffstat (limited to 'src/gpu/GrResourceCache.h')
-rw-r--r-- | src/gpu/GrResourceCache.h | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h index bf7b237006..ae9a4e7ee7 100644 --- a/src/gpu/GrResourceCache.h +++ b/src/gpu/GrResourceCache.h @@ -40,12 +40,6 @@ class SkTraceMemoryDump; * A unique key always takes precedence over a scratch key when a resource has both types of keys. * If a resource has neither key type then it will be deleted as soon as the last reference to it * is dropped. - * - * When proactive purging is enabled, on every flush, the timestamp of that flush is stored in a - * n-sized ring buffer. When purging occurs each purgeable resource's timestamp is compared to the - * timestamp of the n-th prior flush. If the resource's last use timestamp is older than the old - * flush then the resource is proactively purged even when the cache is under budget. By default - * this feature is disabled, though it can be enabled by calling GrResourceCache::setLimits. */ class GrResourceCache { public: @@ -56,11 +50,12 @@ public: static const int kDefaultMaxCount = 2 * (1 << 12); // Default maximum number of bytes of gpu memory of budgeted resources in the cache. static const size_t kDefaultMaxSize = 96 * (1 << 20); - // Default number of flushes a budgeted resources can go unused in the cache before it is - // purged. Large values disable the feature (as the ring buffer of flush timestamps would be - // large). This is currently the default until we decide to enable this feature - // of the cache by default. - static const int kDefaultMaxUnusedFlushes = 64; + // Default number of external flushes a budgeted resources can go unused in the cache before it + // is purged. Using a value <= 0 disables this feature. + static const int kDefaultMaxUnusedFlushes = + 1 * /* flushes per frame */ + 60 * /* fps */ + 30; /* seconds */ /** Used to access functionality needed by GrGpuResource for lifetime management. */ class ResourceAccess; @@ -68,9 +63,9 @@ public: /** * Sets the cache limits in terms of number of resources, max gpu memory byte size, and number - * of GrContext flushes that a resource can be unused before it is evicted. The latter value is - * a suggestion and there is no promise that a resource will be purged immediately after it - * hasn't been used in maxUnusedFlushes flushes. + * of external GrContext flushes that a resource can be unused before it is evicted. The latter + * value is a suggestion and there is no promise that a resource will be purged immediately + * after it hasn't been used in maxUnusedFlushes flushes. */ void setLimits(int count, size_t bytes, int maxUnusedFlushes = kDefaultMaxUnusedFlushes); @@ -237,7 +232,6 @@ private: void refAndMakeResourceMRU(GrGpuResource*); /// @} - void resetFlushTimestamps(); void processInvalidUniqueKeys(const SkTArray<GrUniqueKeyInvalidatedMessage>&); void addToNonpurgeableArray(GrGpuResource*); void removeFromNonpurgeableArray(GrGpuResource*); @@ -321,11 +315,7 @@ private: size_t fBudgetedBytes; bool fRequestFlush; - - // We keep track of the "timestamps" of the last n flushes. If a resource hasn't been used in - // that time then we well preemptively purge it to reduce memory usage. - uint32_t* fFlushTimestamps; - int fLastFlushTimestampIndex; + uint32_t fExternalFlushCnt; InvalidUniqueKeyInbox fInvalidUniqueKeyInbox; |