Simplify GrResourceCache/GrDrawingManager flush interaction.

Change-Id: I2442da32a364ec77ccbefc58ceaa62de8e991caf
Reviewed-on: https://skia-review.googlesource.com/152669
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Brian Salomon 2018-09-10 09:35:41 -04:00 committed by Skia Commit-Bot
parent 5f5dd18c28
commit 57d2beabc7
4 changed files with 11 additions and 45 deletions

View File

@ -195,11 +195,10 @@ void GrDrawingManager::freeGpuResources() {
}
// MDB TODO: make use of the 'proxy' parameter.
GrSemaphoresSubmitted GrDrawingManager::internalFlush(GrSurfaceProxy*,
GrResourceCache::FlushType type,
int numSemaphores,
GrBackendSemaphore backendSemaphores[]) {
GR_CREATE_TRACE_MARKER_CONTEXT("GrDrawingManager", "internalFlush", fContext);
GrSemaphoresSubmitted GrDrawingManager::flush(GrSurfaceProxy*,
int numSemaphores,
GrBackendSemaphore backendSemaphores[]) {
GR_CREATE_TRACE_MARKER_CONTEXT("GrDrawingManager", "flush", fContext);
if (fFlushing || this->wasAbandoned()) {
return GrSemaphoresSubmitted::kNo;
@ -321,9 +320,9 @@ GrSemaphoresSubmitted GrDrawingManager::internalFlush(GrSurfaceProxy*,
flushState.uninstantiateProxyTracker()->uninstantiateAllProxies();
// We always have to notify the cache when it requested a flush so it can reset its state.
if (flushed || type == GrResourceCache::FlushType::kCacheRequested) {
fContext->contextPriv().getResourceCache()->notifyFlushOccurred(type);
// Give the cache a chance to purge resources that become purgeable due to flushing.
if (flushed) {
fContext->contextPriv().getResourceCache()->purgeAsNeeded();
}
for (GrOnFlushCallbackObject* onFlushCBObject : fOnFlushCBObjects) {
onFlushCBObject->postFlush(fTokenTracker.nextTokenToFlush(), fFlushingOpListIDs.begin(),
@ -633,7 +632,8 @@ GrCoverageCountingPathRenderer* GrDrawingManager::getCoverageCountingPathRendere
void GrDrawingManager::flushIfNecessary() {
GrResourceCache* resourceCache = fContext->contextPriv().getResourceCache();
if (resourceCache && resourceCache->requestsFlush()) {
this->internalFlush(nullptr, GrResourceCache::kCacheRequested, 0, nullptr);
this->flush(nullptr, 0, nullptr);
resourceCache->purgeAsNeeded();
}
}

View File

@ -139,14 +139,7 @@ private:
GrSemaphoresSubmitted flush(GrSurfaceProxy* proxy,
int numSemaphores = 0,
GrBackendSemaphore backendSemaphores[] = nullptr) {
return this->internalFlush(proxy, GrResourceCache::FlushType::kExternal,
numSemaphores, backendSemaphores);
}
GrSemaphoresSubmitted internalFlush(GrSurfaceProxy*,
GrResourceCache::FlushType,
int numSemaphores,
GrBackendSemaphore backendSemaphores[]);
GrBackendSemaphore backendSemaphores[] = nullptr);
SkDEBUGCODE(void validate() const);

View File

@ -78,7 +78,6 @@ GrResourceCache::GrResourceCache(const GrCaps* caps, uint32_t contextUniqueID)
, fBudgetedCount(0)
, fBudgetedBytes(0)
, fPurgeableBytes(0)
, fRequestFlush(false)
, fInvalidUniqueKeyInbox(contextUniqueID)
, fFreedGpuResourceInbox(contextUniqueID)
, fContextUniqueID(contextUniqueID)
@ -459,12 +458,6 @@ 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;
}
}
void GrResourceCache::purgeUnlockedResources(bool scratchResourcesOnly) {
@ -672,18 +665,6 @@ uint32_t GrResourceCache::getNextTimestamp() {
return fTimestamp++;
}
void GrResourceCache::notifyFlushOccurred(FlushType type) {
switch (type) {
case FlushType::kCacheRequested:
SkASSERT(fRequestFlush);
fRequestFlush = false;
break;
case FlushType::kExternal:
break;
}
this->purgeAsNeeded();
}
void GrResourceCache::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const {
for (int i = 0; i < fNonpurgeableResources.count(); ++i) {
fNonpurgeableResources[i]->dumpMemoryStatistics(traceMemoryDump);

View File

@ -189,13 +189,7 @@ public:
/** Returns true if the cache would like a flush to occur in order to make more resources
purgeable. */
bool requestsFlush() const { return fRequestFlush; }
enum FlushType {
kExternal,
kCacheRequested,
};
void notifyFlushOccurred(FlushType);
bool requestsFlush() const { return this->overBudget() && !fPurgeableQueue.count(); }
/** Maintain a ref to this resource until we receive a GrGpuResourceFreedMessage. */
void insertCrossContextGpuResource(GrGpuResource* resource);
@ -352,8 +346,6 @@ private:
size_t fBudgetedBytes;
size_t fPurgeableBytes;
bool fRequestFlush;
InvalidUniqueKeyInbox fInvalidUniqueKeyInbox;
FreedGpuResourceInbox fFreedGpuResourceInbox;