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)
downloadefl-3b0073bb5a4725bc23567247b9e1b8c480e03b78.tar.gz
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)
char tmp_file_name[PATH_MAX + PATH_MAX + 128];
int tmpfd = -1, copy;
Eina_Tmpstr *tmp_file_path = NULL;
- Eet_File *ef = NULL;
+ Eet_File *ef = NULL, *ef0 = NULL;
Evas_GL_Program *p;
Eina_Iterator *it;
- char pname[32];
/* use eet */
if (!eet_init()) return 0;
@@ -360,24 +359,42 @@ _evas_gl_common_shader_binary_save(Evas_GL_Shared *shared)
}
save:
- ef = eet_open(tmp_file_path, copy ? EET_FILE_MODE_READ_WRITE : EET_FILE_MODE_WRITE);
+ ef = eet_open(tmp_file_path, EET_FILE_MODE_WRITE);
if (!ef) goto error;
+ if (copy) ef0 = shared->shaders_cache;
+
if (!_evas_gl_common_shader_binary_checksum_write(shared, ef))
goto error;
+ if (ef0)
+ {
+ char **keys;
+ int keys_num = 0, i;
+
+ keys = eet_list(ef0, "/shader/*", &keys_num);
+ if (keys)
+ {
+ for (i = 0; i < keys_num; i++)
+ {
+ int len = 0;
+ void *data = eet_read(ef0, keys[i], &len);
+ if ((data) && (len > 0))
+ {
+ eet_write(ef, keys[i], data, len, SHADER_BINARY_EET_COMPRESS);
+ free(data);
+ }
+ }
+ free(keys);
+ }
+ }
it = eina_hash_iterator_data_new(shared->shaders_hash);
EINA_ITERATOR_FOREACH(it, p)
{
if (!p->bin_saved)
{
- int len = 0;
- sprintf(pname, SHADER_PROG_NAME_FMT, p->flags);
- eet_read_direct(ef, pname, &len);
- if (len > 0)
- p->bin_saved = 1; // assume bin data is correct
- else
- _evas_gl_common_shader_program_binary_save(p, ef);
+ if (_evas_gl_common_shader_program_binary_save(p, ef))
+ p->bin_saved = 1;
}
}
eina_iterator_free(it);