summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-04-24 16:54:11 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-04-24 16:56:56 +0100
commit3b0073bb5a4725bc23567247b9e1b8c480e03b78 (patch)
treedadc781a982a0621165a58e866ba7f6bdb2184b1
parented9ab21fdf9352b538d2ed4a2afac8644b611163 (diff)
evas gl - shader cache was needless losing and overwriting
we were losing cached chaders and overwriting the cache all the time when apps finished compiling new shaders and at other points... when they should have already had a populated shader cache that was all fine and happy. this fixes that so once the cache is fully populated it wont write anymore and it wont lose existing shaders in the cache @fix
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_shader.c37
1 files changed, 27 insertions, 10 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 5702ce49c3..cd3f57074e 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_shader.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_shader.c
@@ -325,10 +325,9 @@ _evas_gl_common_shader_binary_save(Evas_GL_Shared *shared)
325 char tmp_file_name[PATH_MAX + PATH_MAX + 128]; 325 char tmp_file_name[PATH_MAX + PATH_MAX + 128];
326 int tmpfd = -1, copy; 326 int tmpfd = -1, copy;
327 Eina_Tmpstr *tmp_file_path = NULL; 327 Eina_Tmpstr *tmp_file_path = NULL;
328 Eet_File *ef = NULL; 328 Eet_File *ef = NULL, *ef0 = NULL;
329 Evas_GL_Program *p; 329 Evas_GL_Program *p;
330 Eina_Iterator *it; 330 Eina_Iterator *it;
331 char pname[32];
332 331
333 /* use eet */ 332 /* use eet */
334 if (!eet_init()) return 0; 333 if (!eet_init()) return 0;
@@ -360,24 +359,42 @@ _evas_gl_common_shader_binary_save(Evas_GL_Shared *shared)
360 } 359 }
361 360
362save: 361save:
363 ef = eet_open(tmp_file_path, copy ? EET_FILE_MODE_READ_WRITE : EET_FILE_MODE_WRITE); 362 ef = eet_open(tmp_file_path, EET_FILE_MODE_WRITE);
364 if (!ef) goto error; 363 if (!ef) goto error;
365 364
365 if (copy) ef0 = shared->shaders_cache;
366
366 if (!_evas_gl_common_shader_binary_checksum_write(shared, ef)) 367 if (!_evas_gl_common_shader_binary_checksum_write(shared, ef))
367 goto error; 368 goto error;
368 369
370 if (ef0)
371 {
372 char **keys;
373 int keys_num = 0, i;
374
375 keys = eet_list(ef0, "/shader/*", &keys_num);
376 if (keys)
377 {
378 for (i = 0; i < keys_num; i++)
379 {
380 int len = 0;
381 void *data = eet_read(ef0, keys[i], &len);
382 if ((data) && (len > 0))
383 {
384 eet_write(ef, keys[i], data, len, SHADER_BINARY_EET_COMPRESS);
385 free(data);
386 }
387 }
388 free(keys);
389 }
390 }
369 it = eina_hash_iterator_data_new(shared->shaders_hash); 391 it = eina_hash_iterator_data_new(shared->shaders_hash);
370 EINA_ITERATOR_FOREACH(it, p) 392 EINA_ITERATOR_FOREACH(it, p)
371 { 393 {
372 if (!p->bin_saved) 394 if (!p->bin_saved)
373 { 395 {
374 int len = 0; 396 if (_evas_gl_common_shader_program_binary_save(p, ef))
375 sprintf(pname, SHADER_PROG_NAME_FMT, p->flags); 397 p->bin_saved = 1;
376 eet_read_direct(ef, pname, &len);
377 if (len > 0)
378 p->bin_saved = 1; // assume bin data is correct
379 else
380 _evas_gl_common_shader_program_binary_save(p, ef);
381 } 398 }
382 } 399 }
383 eina_iterator_free(it); 400 eina_iterator_free(it);