summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/gl_common/evas_gl_shader.c
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-01-20 20:24:20 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-01-20 20:24:20 +0900
commitebc3b88d099e10bd1cef8aa07ad0875c364101bb (patch)
tree9470999c4a1e88f0993e0a8dab2cfb95bd83c399 /src/modules/evas/engines/gl_common/evas_gl_shader.c
parent3fc6e48c8ac70c1d4566c5eec45a92c4eac75890 (diff)
Evas: Discard shaders cache when the code changed
Since we now have only two shader strings, this is trivial to do: hash the strings and add them to the cache filename. This will allow people using 1.17.0-alpha, etc... to discard their old shaders cache automagically and use the latest version of the shaders (because alpha is not in the filename). If we end up adding more runtime generated shaders, we might need a better strategy, but this should be good enough for now.
Diffstat (limited to '')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_shader.c24
1 files changed, 20 insertions, 4 deletions
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)
204 return 1; 204 return 1;
205} 205}
206 206
207static void
208_evas_gl_common_shader_binary_hash(Evas_GL_Shared *shared)
209{
210 if (shared->shaders_cache_name)
211 return;
212
213 /* This hash makes it sure that if the shaders code changes, then we
214 * will not reuse the old binaries. */
215 shared->shaders_cache_name = eina_stringshare_printf
216 ("%#x:%#x::binary_shader",
217 eina_hash_superfast(fragment_glsl, strlen(fragment_glsl)),
218 eina_hash_superfast(vertex_glsl, strlen(vertex_glsl)));
219}
220
207static int 221static int
208_evas_gl_common_shader_binary_init(Evas_GL_Shared *shared) 222_evas_gl_common_shader_binary_init(Evas_GL_Shared *shared)
209{ 223{
@@ -220,8 +234,9 @@ _evas_gl_common_shader_binary_init(Evas_GL_Shared *shared)
220 if (!evas_gl_common_file_cache_dir_check(bin_dir_path, sizeof(bin_dir_path))) 234 if (!evas_gl_common_file_cache_dir_check(bin_dir_path, sizeof(bin_dir_path)))
221 return 0; 235 return 0;
222 236
223 if (!evas_gl_common_file_cache_file_check(bin_dir_path, "binary_shader", bin_file_path, 237 _evas_gl_common_shader_binary_hash(shared);
224 sizeof(bin_dir_path))) 238 if (!evas_gl_common_file_cache_file_check(bin_dir_path, shared->shaders_cache_name,
239 bin_file_path, sizeof(bin_dir_path)))
225 return 0; 240 return 0;
226 241
227 if (!eet_init()) return 0; 242 if (!eet_init()) return 0;
@@ -259,8 +274,9 @@ _evas_gl_common_shader_binary_save(Evas_GL_Shared *shared)
259 return 0; /* we can't make directory */ 274 return 0; /* we can't make directory */
260 } 275 }
261 276
262 copy = evas_gl_common_file_cache_file_check(bin_dir_path, "binary_shader", bin_file_path, 277 _evas_gl_common_shader_binary_hash(shared);
263 sizeof(bin_dir_path)); 278 copy = evas_gl_common_file_cache_file_check(bin_dir_path, shared->shaders_cache_name,
279 bin_file_path, sizeof(bin_dir_path));
264 280
265 /* use mkstemp for writing */ 281 /* use mkstemp for writing */
266 snprintf(tmp_file_name, sizeof(tmp_file_name), "%s.XXXXXX.cache", bin_file_path); 282 snprintf(tmp_file_name, sizeof(tmp_file_name), "%s.XXXXXX.cache", bin_file_path);