Add cache validation to ensure the validity
Create cache identity from GL_VERSION and store in ShaderCache.
In the next time ShaderCache is restored from disk, compare the
cache identity to ensure its validity. If GL_VERSION changes in
between, flush out entire FileBlobCache and start from an empty
one.
Bug: b/71800782
Test: Wrote a new unit test to save and restore ShaderCache
Test: hwui_unit_tests
Change-Id: Ie573dc4f18733eee090725be30445d879765231b
diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp
index bec80b1e..82bfc49 100644
--- a/libs/hwui/renderthread/CacheManager.cpp
+++ b/libs/hwui/renderthread/CacheManager.cpp
@@ -50,7 +50,6 @@
mVectorDrawableAtlas = new skiapipeline::VectorDrawableAtlas(
mMaxSurfaceArea / 2,
skiapipeline::VectorDrawableAtlas::StorageMode::disallowSharedSurface);
- skiapipeline::ShaderCache::get().initShaderDiskCache();
}
void CacheManager::reset(sk_sp<GrContext> context) {
@@ -103,7 +102,7 @@
}
};
-void CacheManager::configureContext(GrContextOptions* contextOptions) {
+void CacheManager::configureContext(GrContextOptions* contextOptions, const void* identity, ssize_t size) {
contextOptions->fAllowPathMaskCaching = true;
float screenMP = mMaxSurfaceArea / 1024.0f / 1024.0f;
@@ -133,7 +132,9 @@
contextOptions->fExecutor = mTaskProcessor.get();
}
- contextOptions->fPersistentCache = &skiapipeline::ShaderCache::get();
+ auto& cache = skiapipeline::ShaderCache::get();
+ cache.initShaderDiskCache(identity, size);
+ contextOptions->fPersistentCache = &cache;
contextOptions->fGpuPathRenderers &= ~GpuPathRenderers::kCoverageCounting;
}