diff options
-rw-r--r-- | include/gpu/GrCaps.h | 5 | ||||
-rw-r--r-- | src/gpu/GrCaps.cpp | 4 | ||||
-rwxr-xr-x | src/gpu/GrContext.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrResourceCache.cpp | 12 | ||||
-rw-r--r-- | src/gpu/GrResourceCache.h | 5 | ||||
-rw-r--r-- | src/gpu/gl/GrGLCaps.cpp | 9 |
6 files changed, 29 insertions, 8 deletions
diff --git a/include/gpu/GrCaps.h b/include/gpu/GrCaps.h index 48bcb28c4d..248135d691 100644 --- a/include/gpu/GrCaps.h +++ b/include/gpu/GrCaps.h @@ -133,6 +133,8 @@ public: return fUseDrawInsteadOfPartialRenderTargetWrite; } + bool preferVRAMUseOverFlushes() const { return fPreferVRAMUseOverFlushes; } + /** * Indicates the capabilities of the fixed function blend unit. */ @@ -249,6 +251,9 @@ protected: bool fUseDrawInsteadOfClear : 1; bool fUseDrawInsteadOfPartialRenderTargetWrite : 1; + // ANGLE workaround + bool fPreferVRAMUseOverFlushes : 1; + BlendEquationSupport fBlendEquationSupport; uint32_t fAdvBlendEqBlacklist; GR_STATIC_ASSERT(kLast_GrBlendEquation < 32); diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp index b7e43d6a11..e40057686c 100644 --- a/src/gpu/GrCaps.cpp +++ b/src/gpu/GrCaps.cpp @@ -114,6 +114,8 @@ GrCaps::GrCaps(const GrContextOptions& options) { fDrawPathMasksToCompressedTextureSupport = options.fDrawPathToCompressedTexture; fGeometryBufferMapThreshold = options.fGeometryBufferMapThreshold; fUseDrawInsteadOfPartialRenderTargetWrite = options.fUseDrawInsteadOfPartialRenderTargetWrite; + + fPreferVRAMUseOverFlushes = true; } void GrCaps::applyOptionsOverrides(const GrContextOptions& options) { @@ -161,6 +163,8 @@ SkString GrCaps::dump() const { r.appendf("Draw Instead of Clear [workaround] : %s\n", gNY[fUseDrawInsteadOfClear]); r.appendf("Draw Instead of TexSubImage [workaround] : %s\n", gNY[fUseDrawInsteadOfPartialRenderTargetWrite]); + r.appendf("Prefer VRAM Use over flushes [workaround] : %s\n", gNY[fPreferVRAMUseOverFlushes]); + if (this->advancedBlendEquationSupport()) { r.appendf("Advanced Blend Equation Blacklist : 0x%x\n", fAdvBlendEqBlacklist); } diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 91415ac2b4..2f334c6ba0 100755 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -182,7 +182,7 @@ bool GrContext::init(GrBackend backend, GrBackendContext backendContext, void GrContext::initCommon() { fCaps = SkRef(fGpu->caps()); - fResourceCache = SkNEW(GrResourceCache); + fResourceCache = SkNEW_ARGS(GrResourceCache, (fCaps)); fResourceCache->setOverBudgetCallback(OverBudgetCB, this); fResourceProvider = SkNEW_ARGS(GrResourceProvider, (fGpu, fResourceCache)); diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp index 7efe62365b..e77d9acd62 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; } } diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h index 809c4f491e..2171420a43 100644 --- a/src/gpu/GrResourceCache.h +++ b/src/gpu/GrResourceCache.h @@ -20,6 +20,7 @@ #include "SkTInternalLList.h" #include "SkTMultiMap.h" +class GrCaps; class SkString; /** @@ -47,7 +48,7 @@ class SkString; */ class GrResourceCache { public: - GrResourceCache(); + GrResourceCache(const GrCaps* caps); ~GrResourceCache(); // Default maximum number of budgeted resources in the cache. @@ -298,6 +299,8 @@ private: // This resource is allowed to be in the nonpurgeable array for the sake of validate() because // we're in the midst of converting it to purgeable status. SkDEBUGCODE(GrGpuResource* fNewlyPurgeableResourceForValidation;) + + bool fPreferVRAMUseOverFlushes; }; class GrResourceCache::ResourceAccess { diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index 21d3d9374e..af0fa78f7e 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -471,6 +471,11 @@ void GrGLCaps::init(const GrContextOptions& contextOptions, fUseDrawInsteadOfPartialRenderTargetWrite = true; } +#ifdef SK_BUILD_FOR_WIN + // On ANGLE deferring flushes can lead to GPU starvation + fPreferVRAMUseOverFlushes = !isANGLE; +#endif + if (kChromium_GrGLDriver == ctxInfo.driver()) { fMustClearUploadedBufferData = true; } @@ -1147,8 +1152,8 @@ SkString GrGLCaps::dump() const { r.appendf("Use non-VBO for dynamic data: %s\n", (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); r.appendf("SRGB write contol: %s\n", (fSRGBWriteControl ? "YES" : "NO")); - r.appendf("RGBA 8888 pixel ops are slow: %s\n", (fRGBA8888PixelsOpsAreSlow? "YES" : "NO")); - r.appendf("Partial FBO read is slow: %s\n", (fPartialFBOReadIsSlow? "YES" : "NO")); + r.appendf("RGBA 8888 pixel ops are slow: %s\n", (fRGBA8888PixelsOpsAreSlow ? "YES" : "NO")); + r.appendf("Partial FBO read is slow: %s\n", (fPartialFBOReadIsSlow ? "YES" : "NO")); return r; } |