SF: include number of Skia shaders in perfetto traces
When a new shader is compiled in SurfaceFlinger (tracked by the ATRACE
tag "shader_compile"), SkSLCacheMonitor::store will be called.
(Eventually, we'd like to store the shader in a persistent cache - this
is blocked on b/119203607.) Use this method to keep track of the total
number of shaders used since boot. Print this number in the perfetto
trace.
This can be used to verify whether we have compiled enough shaders to
require cache eviction, and can also be used to determine how much
larger the cache should be. We are currently using
GrContextOptions.fRuntimeProgramCacheSize's default of 256.
Bug: 226662927
Bug: 222355787
Bug: 222109133
Bug: 190487656
Test: perfetto trace
Change-Id: Ifa99a8a2e16c136dc6f19e2a8dda0692aa4358a8
diff --git a/libs/renderengine/skia/SkiaGLRenderEngine.cpp b/libs/renderengine/skia/SkiaGLRenderEngine.cpp
index 76ae2fc..9bb68e3 100644
--- a/libs/renderengine/skia/SkiaGLRenderEngine.cpp
+++ b/libs/renderengine/skia/SkiaGLRenderEngine.cpp
@@ -292,6 +292,8 @@
void SkiaGLRenderEngine::SkSLCacheMonitor::store(const SkData& key, const SkData& data,
const SkString& description) {
mShadersCachedSinceLastCall++;
+ mTotalShadersCompiled++;
+ ATRACE_FORMAT("SF cache: %i shaders", mTotalShadersCompiled);
}
void SkiaGLRenderEngine::assertShadersCompiled(int numShaders) {
diff --git a/libs/renderengine/skia/SkiaGLRenderEngine.h b/libs/renderengine/skia/SkiaGLRenderEngine.h
index a650313..56815fe 100644
--- a/libs/renderengine/skia/SkiaGLRenderEngine.h
+++ b/libs/renderengine/skia/SkiaGLRenderEngine.h
@@ -180,6 +180,7 @@
private:
int mShadersCachedSinceLastCall = 0;
+ int mTotalShadersCompiled = 0;
};
SkSLCacheMonitor mSkSLCacheMonitor;