Bump default GrResourceCache size to 256MB
Consider rendering an SkPicture to a 1080p, 4x msaa render target:
1920 * 1080 * (4 color bytes + 1 stencil byte) * 4 samples = 40Mb!
But SkCanvas::drawPicture calls saveLayer, which allocates a duplicate
render target:
40Mb * 2 = 80Mb!!
So with the original 96MB, a quite conservative msaa render target
almost blows out the entire resource cache just on the backing. This
CL bumps up the default cache size to 256MB.
Change-Id: I756c62f4ee6b9c62b1a3e535f31e15a1ecc3d63f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292265
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
diff --git a/modules/canvaskit/gpu.js b/modules/canvaskit/gpu.js
index 8ac078d..9b522a1 100644
--- a/modules/canvaskit/gpu.js
+++ b/modules/canvaskit/gpu.js
@@ -69,12 +69,6 @@
var grcontext = this.MakeGrContext(ctx);
- if (grcontext) {
- // Bump the default resource cache limit.
- var RESOURCE_CACHE_BYTES = 256 * 1024 * 1024;
- grcontext.setResourceCacheLimitBytes(RESOURCE_CACHE_BYTES);
- }
-
// Note that canvas.width/height here is used because it gives the size of the buffer we're
// rendering into. This may not be the same size the element is displayed on the page, which
// constrolled by css, and available in canvas.clientWidth/height.
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h
index 4db77e2..23639dc 100644
--- a/src/gpu/GrResourceCache.h
+++ b/src/gpu/GrResourceCache.h
@@ -61,7 +61,7 @@
~GrResourceCache();
// Default maximum number of bytes of gpu memory of budgeted resources in the cache.
- static const size_t kDefaultMaxSize = 96 * (1 << 20);
+ static const size_t kDefaultMaxSize = 256 * (1 << 20);
/** Used to access functionality needed by GrGpuResource for lifetime management. */
class ResourceAccess;