diff options
author | 2016-09-06 13:49:32 -0700 | |
---|---|---|
committer | 2016-09-06 13:49:32 -0700 | |
commit | 5eb41fdf94187d6cc22702444622ed7897c8039a (patch) | |
tree | 11a9437f3ccc9f7be96abaed7c9365069e9d5383 /src/gpu/GrResourceCache.cpp | |
parent | 128a958c1ff2f0c0c846b4975eb46a091bc33cd8 (diff) |
Revert of Restructure flushing relationship between GrContext, GrDrawingManager, and GrResourceCache. (patchset #4 id:60001 of https://codereview.chromium.org/2307053002/ )
Reason for revert:
Causing assertions on bots
Original issue's description:
> 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
TBR=robertphillips@google.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Review-Url: https://codereview.chromium.org/2312123003
Diffstat (limited to 'src/gpu/GrResourceCache.cpp')
-rw-r--r-- | src/gpu/GrResourceCache.cpp | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp index e3f4f9ff50..62360ed535 100644 --- a/src/gpu/GrResourceCache.cpp +++ b/src/gpu/GrResourceCache.cpp @@ -73,6 +73,8 @@ GrResourceCache::GrResourceCache(const GrCaps* caps) , fBytes(0) , fBudgetedCount(0) , fBudgetedBytes(0) + , fOverBudgetCB(nullptr) + , fOverBudgetData(nullptr) , fFlushTimestamps(nullptr) , fLastFlushTimestampIndex(0) , fPreferVRAMUseOverFlushes(caps->preferVRAMUseOverFlushes()) { @@ -501,9 +503,10 @@ void GrResourceCache::purgeAsNeeded() { this->validate(); if (stillOverbudget) { - // 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; + // 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(); } } @@ -618,26 +621,16 @@ uint32_t GrResourceCache::getNextTimestamp() { return fTimestamp++; } -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; +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(); } - this->purgeAsNeeded(); } void GrResourceCache::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const { |