Make the size of program/pipeline caches configurable in GrContextOptions
Change-Id: I988fd8cc7e78e2124f20b7d8a815f160bb166756
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/239756
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index a43f589..5193452 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -319,10 +319,6 @@
const GrPipeline&, bool hasPointSize);
private:
- // We may actually have kMaxEntries+1 shaders in the GL context because we create a new
- // shader before evicting from the cache.
- static const int kMaxEntries = 128;
-
struct Entry;
struct DescHash {
diff --git a/src/gpu/gl/GrGLGpuProgramCache.cpp b/src/gpu/gl/GrGLGpuProgramCache.cpp
index 2c00fdf..279dd03 100644
--- a/src/gpu/gl/GrGLGpuProgramCache.cpp
+++ b/src/gpu/gl/GrGLGpuProgramCache.cpp
@@ -7,6 +7,8 @@
#include "src/gpu/gl/GrGLGpu.h"
+#include "include/gpu/GrContextOptions.h"
+#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrProcessor.h"
#include "src/gpu/GrProgramDesc.h"
#include "src/gpu/gl/builders/GrGLProgramBuilder.h"
@@ -19,7 +21,7 @@
};
GrGLGpu::ProgramCache::ProgramCache(GrGLGpu* gpu)
- : fMap(kMaxEntries)
+ : fMap(gpu->getContext()->priv().options().fRuntimeProgramCacheSize)
, fGpu(gpu) {}
GrGLGpu::ProgramCache::~ProgramCache() {}
diff --git a/src/gpu/mtl/GrMtlResourceProvider.mm b/src/gpu/mtl/GrMtlResourceProvider.mm
index b27bbff..d47cac9 100644
--- a/src/gpu/mtl/GrMtlResourceProvider.mm
+++ b/src/gpu/mtl/GrMtlResourceProvider.mm
@@ -7,6 +7,8 @@
#include "src/gpu/mtl/GrMtlResourceProvider.h"
+#include "include/gpu/GrContextOptions.h"
+#include "src/gpu/GrContextPriv.h"
#include "src/gpu/mtl/GrMtlCommandBuffer.h"
#include "src/gpu/mtl/GrMtlGpu.h"
#include "src/gpu/mtl/GrMtlPipelineState.h"
@@ -107,7 +109,8 @@
};
GrMtlResourceProvider::PipelineStateCache::PipelineStateCache(GrMtlGpu* gpu)
- : fMap(kMaxEntries)
+ // Temporary hack to keep this as large as Chrome wants, until they update GrContextOptions
+ : fMap(SkTMax(gpu->getContext()->priv().options().fRuntimeProgramCacheSize, 1024))
, fGpu(gpu)
#ifdef GR_PIPELINE_STATE_CACHE_STATS
, fTotalRequests(0)
diff --git a/src/gpu/vk/GrVkPipelineStateCache.cpp b/src/gpu/vk/GrVkPipelineStateCache.cpp
index 0c25c6f..68c0be1 100644
--- a/src/gpu/vk/GrVkPipelineStateCache.cpp
+++ b/src/gpu/vk/GrVkPipelineStateCache.cpp
@@ -6,7 +6,9 @@
*/
+#include "include/gpu/GrContextOptions.h"
#include "src/core/SkOpts.h"
+#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrProcessor.h"
#include "src/gpu/GrRenderTargetPriv.h"
#include "src/gpu/GrStencilSettings.h"
@@ -38,7 +40,7 @@
};
GrVkResourceProvider::PipelineStateCache::PipelineStateCache(GrVkGpu* gpu)
- : fMap(kMaxEntries)
+ : fMap(gpu->getContext()->priv().options().fRuntimeProgramCacheSize)
, fGpu(gpu)
#ifdef GR_PIPELINE_STATE_CACHE_STATS
, fTotalRequests(0)
diff --git a/src/gpu/vk/GrVkResourceProvider.h b/src/gpu/vk/GrVkResourceProvider.h
index 649d461..9cd457e 100644
--- a/src/gpu/vk/GrVkResourceProvider.h
+++ b/src/gpu/vk/GrVkResourceProvider.h
@@ -205,12 +205,6 @@
VkRenderPass compatibleRenderPass);
private:
- enum {
- // We may actually have kMaxEntries+1 PipelineStates in context because we create a new
- // PipelineState before evicting from the cache.
- kMaxEntries = 128,
- };
-
struct Entry;
struct DescHash {