From a365c070b34068a00463f4c9414010309f9c7920 Mon Sep 17 00:00:00 2001 From: jsjtxietian Date: Fri, 12 Jan 2024 11:17:57 +0800 Subject: [PATCH] Add shader_cache_dir_valid check to _save_to_cache --- drivers/gles3/shader_gles3.cpp | 1 + drivers/gles3/shader_gles3.h | 4 +++- servers/rendering/renderer_rd/shader_rd.cpp | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index 8b5aaa6b8da..27402da7c84 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -611,6 +611,7 @@ void ShaderGLES3::_save_to_cache(Version *p_version) { #ifdef WEB_ENABLED // not supported in webgl return; #else + ERR_FAIL_COND(!shader_cache_dir_valid); #if !defined(ANDROID_ENABLED) && !defined(IOS_ENABLED) if (RasterizerGLES3::is_gles_over_gl() && (glGetProgramBinary == NULL)) { // ARB_get_program_binary extension not available. return; diff --git a/drivers/gles3/shader_gles3.h b/drivers/gles3/shader_gles3.h index 0cb53da3163..8968e76c12c 100644 --- a/drivers/gles3/shader_gles3.h +++ b/drivers/gles3/shader_gles3.h @@ -209,7 +209,9 @@ protected: _compile_specialization(s, p_variant, version, p_specialization); version->variants[p_variant].insert(p_specialization, s); spec = version->variants[p_variant].lookup_ptr(p_specialization); - _save_to_cache(version); + if (shader_cache_dir_valid) { + _save_to_cache(version); + } } } else if (spec->build_queued) { // Still queued, wait diff --git a/servers/rendering/renderer_rd/shader_rd.cpp b/servers/rendering/renderer_rd/shader_rd.cpp index db2ca29474c..1c54ce56579 100644 --- a/servers/rendering/renderer_rd/shader_rd.cpp +++ b/servers/rendering/renderer_rd/shader_rd.cpp @@ -463,6 +463,7 @@ bool ShaderRD::_load_from_cache(Version *p_version, int p_group) { } void ShaderRD::_save_to_cache(Version *p_version, int p_group) { + ERR_FAIL_COND(!shader_cache_dir_valid); String sha1 = _version_get_sha1(p_version); String path = shader_cache_dir.path_join(name).path_join(group_sha256[p_group]).path_join(sha1) + ".cache";