Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 139051f

Browse files
authored
Change IO thread shader cache strategy (#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
1 parent 438e3b5 commit 139051f

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

shell/common/persistent_cache.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ std::atomic<bool> PersistentCache::cache_sksl_ = false;
4747
std::atomic<bool> PersistentCache::strategy_set_ = false;
4848

4949
void PersistentCache::SetCacheSkSL(bool value) {
50-
if (strategy_set_) {
50+
if (strategy_set_ && value != cache_sksl_) {
5151
FML_LOG(ERROR) << "Cache SkSL can only be set before the "
5252
"GrContextOptions::fShaderCacheStrategy is set.";
5353
return;

shell/common/shell_io_manager.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ sk_sp<GrContext> ShellIOManager::CreateCompatibleResourceLoadingContext(
1919

2020
GrContextOptions options = {};
2121

22+
if (PersistentCache::cache_sksl()) {
23+
FML_LOG(INFO) << "Cache SkSL";
24+
options.fShaderCacheStrategy = GrContextOptions::ShaderCacheStrategy::kSkSL;
25+
}
26+
PersistentCache::MarkStrategySet();
27+
2228
options.fPersistentCache = PersistentCache::GetCacheForProcess();
2329

2430
// There is currently a bug with doing GPU YUV to RGB conversions on the IO

shell/gpu/gpu_surface_gl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ GPUSurfaceGL::GPUSurfaceGL(GPUSurfaceGLDelegate* delegate,
5050
if (PersistentCache::cache_sksl()) {
5151
FML_LOG(INFO) << "Cache SkSL";
5252
options.fShaderCacheStrategy = GrContextOptions::ShaderCacheStrategy::kSkSL;
53-
PersistentCache::MarkStrategySet();
5453
}
54+
PersistentCache::MarkStrategySet();
5555
options.fPersistentCache = PersistentCache::GetCacheForProcess();
5656

5757
options.fAvoidStencilBuffers = true;

0 commit comments

Comments
 (0)