diff options
author | 2016-09-07 10:02:04 -0700 | |
---|---|---|
committer | 2016-09-07 10:02:04 -0700 | |
commit | b77a907c2fb4402b7e70e9fff70eb71482354e67 (patch) | |
tree | 692acfaad6a575969ceb547d617aa6bfcbc7a4d8 /src/gpu/GrResourceCache.cpp | |
parent | 5edf2908a305d3365a1574a8358343bb26468b35 (diff) |
Restructure flushing relationship between GrContext, GrDrawingManager, and GrResourceCache.
Consolidates all flush actions into GrDrawingManager and makes GrContext::flush a passthrough.
Removes the unused and untested discard flush variation.
Replaces the indirect overbudget callback mechanism of GrResourceCache with a flag set by resource cache when it wants to flush that is checked after each draw by GrDrawContext.
Modifies GrResourceCache::notifyFlushOccurred() to take a param indicating whether it triggered the
flush that just occurred.
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2307053002
Committed: https://skia.googlesource.com/skia/+/1dbb207babecdae8f1f74ed9d9900c73064df744
Review-Url: https://codereview.chromium.org/2307053002
Diffstat (limited to 'src/gpu/GrResourceCache.cpp')
-rw-r--r-- | src/gpu/GrResourceCache.cpp | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp index 62360ed535..529f87c124 100644 --- a/src/gpu/GrResourceCache.cpp +++ b/src/gpu/GrResourceCache.cpp @@ -73,8 +73,7 @@ GrResourceCache::GrResourceCache(const GrCaps* caps) , fBytes(0) , fBudgetedCount(0) , fBudgetedBytes(0) - , fOverBudgetCB(nullptr) - , fOverBudgetData(nullptr) + , fRequestFlush(false) , fFlushTimestamps(nullptr) , fLastFlushTimestampIndex(0) , fPreferVRAMUseOverFlushes(caps->preferVRAMUseOverFlushes()) { @@ -503,10 +502,9 @@ void GrResourceCache::purgeAsNeeded() { this->validate(); if (stillOverbudget) { - // Despite the purge we're still over budget. Call our over budget callback. If this frees - // any resources then we'll get notified and take appropriate action. - (*fOverBudgetCB)(fOverBudgetData); - this->validate(); + // Set this so that GrDrawingManager will issue a flush to free up resources with pending + // IO that we were unable to purge in this pass. + fRequestFlush = true; } } @@ -621,16 +619,26 @@ uint32_t GrResourceCache::getNextTimestamp() { return fTimestamp++; } -void GrResourceCache::notifyFlushOccurred() { - if (fFlushTimestamps) { - SkASSERT(SkIsPow2(fMaxUnusedFlushes)); - fLastFlushTimestampIndex = (fLastFlushTimestampIndex + 1) & (fMaxUnusedFlushes - 1); - // get the timestamp before accessing fFlushTimestamps because getNextTimestamp will - // reallocate fFlushTimestamps on timestamp overflow. - uint32_t timestamp = this->getNextTimestamp(); - fFlushTimestamps[fLastFlushTimestampIndex] = timestamp; - this->purgeAsNeeded(); +void GrResourceCache::notifyFlushOccurred(FlushType type) { + switch (type) { + case FlushType::kImmediateMode: + break; + case FlushType::kCacheRequested: + SkASSERT(fRequestFlush); + fRequestFlush = false; + break; + case FlushType::kExternal: + if (fFlushTimestamps) { + SkASSERT(SkIsPow2(fMaxUnusedFlushes)); + fLastFlushTimestampIndex = (fLastFlushTimestampIndex + 1) & (fMaxUnusedFlushes - 1); + // get the timestamp before accessing fFlushTimestamps because getNextTimestamp will + // reallocate fFlushTimestamps on timestamp overflow. + uint32_t timestamp = this->getNextTimestamp(); + fFlushTimestamps[fLastFlushTimestampIndex] = timestamp; + } + break; } + this->purgeAsNeeded(); } void GrResourceCache::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { |