diff --git a/src/modules/evas/engines/gl_common/evas_gl_common.h b/src/modules/evas/engines/gl_common/evas_gl_common.h index 93e30f43c9..eab1c50b5b 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_common.h +++ b/src/modules/evas/engines/gl_common/evas_gl_common.h @@ -191,6 +191,7 @@ struct _Evas_GL_Shared Eet_File *shaders_cache; Eina_Hash *shaders_hash; + Eina_Stringshare *shaders_cache_name; #ifdef GL_GLES // FIXME: hack. diff --git a/src/modules/evas/engines/gl_common/evas_gl_context.c b/src/modules/evas/engines/gl_common/evas_gl_context.c index caf1619a33..cf382342b3 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_context.c +++ b/src/modules/evas/engines/gl_common/evas_gl_context.c @@ -1041,6 +1041,7 @@ evas_gl_common_context_free(Evas_Engine_GL_Context *gc) eina_hash_free(gc->shared->native_wl_hash); eina_hash_free(gc->shared->native_tbm_hash); eina_hash_free(gc->shared->native_evasgl_hash); + eina_stringshare_del(gc->shared->shaders_cache_name); free(gc->shared); shared = NULL; } diff --git a/src/modules/evas/engines/gl_common/evas_gl_shader.c b/src/modules/evas/engines/gl_common/evas_gl_shader.c index c049d9e609..ebee5880fe 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_shader.c +++ b/src/modules/evas/engines/gl_common/evas_gl_shader.c @@ -204,6 +204,20 @@ _evas_gl_common_shader_program_binary_save(Evas_GL_Program *p, Eet_File *ef) return 1; } +static void +_evas_gl_common_shader_binary_hash(Evas_GL_Shared *shared) +{ + if (shared->shaders_cache_name) + return; + + /* This hash makes it sure that if the shaders code changes, then we + * will not reuse the old binaries. */ + shared->shaders_cache_name = eina_stringshare_printf + ("%#x:%#x::binary_shader", + eina_hash_superfast(fragment_glsl, strlen(fragment_glsl)), + eina_hash_superfast(vertex_glsl, strlen(vertex_glsl))); +} + static int _evas_gl_common_shader_binary_init(Evas_GL_Shared *shared) { @@ -220,8 +234,9 @@ _evas_gl_common_shader_binary_init(Evas_GL_Shared *shared) if (!evas_gl_common_file_cache_dir_check(bin_dir_path, sizeof(bin_dir_path))) return 0; - if (!evas_gl_common_file_cache_file_check(bin_dir_path, "binary_shader", bin_file_path, - sizeof(bin_dir_path))) + _evas_gl_common_shader_binary_hash(shared); + if (!evas_gl_common_file_cache_file_check(bin_dir_path, shared->shaders_cache_name, + bin_file_path, sizeof(bin_dir_path))) return 0; if (!eet_init()) return 0; @@ -259,8 +274,9 @@ _evas_gl_common_shader_binary_save(Evas_GL_Shared *shared) return 0; /* we can't make directory */ } - copy = evas_gl_common_file_cache_file_check(bin_dir_path, "binary_shader", bin_file_path, - sizeof(bin_dir_path)); + _evas_gl_common_shader_binary_hash(shared); + copy = evas_gl_common_file_cache_file_check(bin_dir_path, shared->shaders_cache_name, + bin_file_path, sizeof(bin_dir_path)); /* use mkstemp for writing */ snprintf(tmp_file_name, sizeof(tmp_file_name), "%s.XXXXXX.cache", bin_file_path);