[Mesa-dev] [PATCH] etnaviv: enable glsl/tgsi on-disk cache

Christian Gmeiner christian.gmeiner at gmail.com
Tue Feb 20 18:36:01 UTC 2018


Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
---
 src/gallium/drivers/etnaviv/etnaviv_screen.c | 36 ++++++++++++++++++++++++++++
 src/gallium/drivers/etnaviv/etnaviv_screen.h |  2 ++
 2 files changed, 38 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c b/src/gallium/drivers/etnaviv/etnaviv_screen.c
index 3dd628bd9b..361745214c 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c
@@ -79,6 +79,8 @@ etna_screen_destroy(struct pipe_screen *pscreen)
 {
    struct etna_screen *screen = etna_screen(pscreen);
 
+   disk_cache_destroy(screen->disk_shader_cache);
+
    if (screen->pipe)
       etna_pipe_del(screen->pipe);
 
@@ -94,6 +96,36 @@ etna_screen_destroy(struct pipe_screen *pscreen)
    FREE(screen);
 }
 
+static void etna_disk_cache_create(struct etna_screen *screen)
+{
+   uint32_t mesa_timestamp;
+
+   if (disk_cache_get_function_timestamp(etna_disk_cache_create,
+                                         &mesa_timestamp)) {
+      char *timestamp_str;
+      int res = -1;
+
+      res = asprintf(&timestamp_str, "%u", mesa_timestamp);
+      if (res != -1) {
+         char name[128];
+
+         util_snprintf(name, sizeof(name), "gc%x_%04x", screen->model,
+                       screen->revision);
+
+         screen->disk_shader_cache = disk_cache_create(name, timestamp_str, 0);
+         free(timestamp_str);
+      }
+   }
+}
+
+static struct disk_cache *
+etna_get_disk_shader_cache(struct pipe_screen *pscreen)
+{
+   struct etna_screen *priv = etna_screen(pscreen);
+
+   return priv->disk_shader_cache;
+}
+
 static const char *
 etna_screen_get_name(struct pipe_screen *pscreen)
 {
@@ -978,12 +1010,16 @@ etna_screen_create(struct etna_device *dev, struct etna_gpu *gpu,
    pscreen->is_format_supported = etna_screen_is_format_supported;
    pscreen->query_dmabuf_modifiers = etna_screen_query_dmabuf_modifiers;
 
+   pscreen->get_disk_shader_cache = etna_get_disk_shader_cache;
+
    etna_fence_screen_init(pscreen);
    etna_query_screen_init(pscreen);
    etna_resource_screen_init(pscreen);
 
    slab_create_parent(&screen->transfer_pool, sizeof(struct etna_transfer), 16);
 
+   etna_disk_cache_create(screen);
+
    return pscreen;
 
 fail:
diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.h b/src/gallium/drivers/etnaviv/etnaviv_screen.h
index dc57a38dbb..f9eb8ffe6e 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_screen.h
+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.h
@@ -33,6 +33,7 @@
 #include "os/os_thread.h"
 #include "pipe/p_screen.h"
 #include "renderonly/renderonly.h"
+#include "util/disk_cache.h"
 #include "util/slab.h"
 
 struct etna_bo;
@@ -68,6 +69,7 @@ struct etna_screen {
    struct renderonly *ro;
 
    struct slab_parent_pool transfer_pool;
+   struct disk_cache *disk_shader_cache;
 
    uint32_t model;
    uint32_t revision;
-- 
2.14.3



More information about the mesa-dev mailing list