Index: src/gpu/GrResourceCache.cpp |
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp |
index 7efe62365bf432f112e12e5a01d9b97fa4f7ec98..c32f77862d36c2d3d4f0f32459293a1338b3f7f7 100644 |
--- a/src/gpu/GrResourceCache.cpp |
+++ b/src/gpu/GrResourceCache.cpp |
@@ -58,7 +58,7 @@ private: |
////////////////////////////////////////////////////////////////////////////// |
-GrResourceCache::GrResourceCache() |
+GrResourceCache::GrResourceCache(const GrCaps* caps) |
: fTimestamp(0) |
, fMaxCount(kDefaultMaxCount) |
, fMaxBytes(kDefaultMaxSize) |
@@ -75,7 +75,8 @@ GrResourceCache::GrResourceCache() |
, 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 @@ GrGpuResource* GrResourceCache::findAndRefScratchResource(const GrScratchKey& sc |
} 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; |
} |
} |