Add ANGLE workaround to prefer flushes over VRAM usage
On the whole, https://codereview.chromium.org/1286203002/ (Defer flushes if kPreferNoIO is specified) improved performance but it did cause a performance regression on ANGLE. This CL disables the deferral of flushes on ANGLE until we can add a separate incremental flushing mechanism.
TBR=bsalomon@google.com
BUG=skia:4201
BUG=521529
Review URL: https://codereview.chromium.org/1287193008
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index 7efe623..e77d9ac 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -58,7 +58,7 @@
//////////////////////////////////////////////////////////////////////////////
-GrResourceCache::GrResourceCache()
+GrResourceCache::GrResourceCache(const GrCaps* caps)
: fTimestamp(0)
, fMaxCount(kDefaultMaxCount)
, fMaxBytes(kDefaultMaxSize)
@@ -75,7 +75,8 @@
, fOverBudgetCB(NULL)
, fOverBudgetData(NULL)
, fFlushTimestamps(NULL)
- , fLastFlushTimestampIndex(0){
+ , fLastFlushTimestampIndex(0)
+ , fPreferVRAMUseOverFlushes(caps->preferVRAMUseOverFlushes()) {
SkDEBUGCODE(fCount = 0;)
SkDEBUGCODE(fNewlyPurgeableResourceForValidation = NULL;)
this->resetFlushTimestamps();
@@ -260,9 +261,12 @@
} else if (flags & kRequireNoPendingIO_ScratchFlag) {
return NULL;
}
- if (this->wouldFit(resourceSize)) {
+ // We would prefer to consume more available VRAM rather than flushing
+ // immediately, but on ANGLE this can lead to starving of the GPU.
+ if (fPreferVRAMUseOverFlushes && this->wouldFit(resourceSize)) {
// kPrefer is specified, we didn't find a resource without pending io,
- // but there is still space in our budget for the resource.
+ // but there is still space in our budget for the resource so force
+ // the caller to allocate a new resource.
return NULL;
}
}