Change IO thread shader cache strategy (flutter/engine#13121)

So it's the same with the GPU thread.

Otherwise, some shaders may be cached in binary on the IO thread, and we will lose them when we do the SkSL precompile.

For b/140174804
This commit is contained in:
liyuqian 2019-10-14 13:05:05 -07:00 committed by GitHub
parent 4aa3ee0c26
commit 892f852039
3 changed files with 8 additions and 2 deletions

View File

@ -47,7 +47,7 @@ std::atomic<bool> PersistentCache::cache_sksl_ = false;
std::atomic<bool> PersistentCache::strategy_set_ = false;
void PersistentCache::SetCacheSkSL(bool value) {
if (strategy_set_) {
if (strategy_set_ && value != cache_sksl_) {
FML_LOG(ERROR) << "Cache SkSL can only be set before the "
"GrContextOptions::fShaderCacheStrategy is set.";
return;

View File

@ -19,6 +19,12 @@ sk_sp<GrContext> ShellIOManager::CreateCompatibleResourceLoadingContext(
GrContextOptions options = {};
if (PersistentCache::cache_sksl()) {
FML_LOG(INFO) << "Cache SkSL";
options.fShaderCacheStrategy = GrContextOptions::ShaderCacheStrategy::kSkSL;
}
PersistentCache::MarkStrategySet();
options.fPersistentCache = PersistentCache::GetCacheForProcess();
// There is currently a bug with doing GPU YUV to RGB conversions on the IO

View File

@ -50,8 +50,8 @@ GPUSurfaceGL::GPUSurfaceGL(GPUSurfaceGLDelegate* delegate,
if (PersistentCache::cache_sksl()) {
FML_LOG(INFO) << "Cache SkSL";
options.fShaderCacheStrategy = GrContextOptions::ShaderCacheStrategy::kSkSL;
PersistentCache::MarkStrategySet();
}
PersistentCache::MarkStrategySet();
options.fPersistentCache = PersistentCache::GetCacheForProcess();
options.fAvoidStencilBuffers = true;