raster pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=3b0073bb5a4725bc23567247b9e1b8c480e03b78

commit 3b0073bb5a4725bc23567247b9e1b8c480e03b78
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Fri Apr 24 16:54:11 2020 +0100

    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
---
 .../evas/engines/gl_common/evas_gl_shader.c        | 37 ++++++++++++++++------
 1 file 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);

-- 


Reply via email to