summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSt├ęphane Marchesin <marcheu@chromium.org>2021-04-13 06:26:26 +0200
committerMarge Bot <eric+marge@anholt.net>2021-04-14 07:37:34 +0000
commitd6db4d2e08100b12fe6ac539f419768b3b412643 (patch)
tree93b49f01f429885b666369c2f5012a4585f7fd56
parenta86450e00a224efe3999411064fcdd791411d434 (diff)
virgl: Add simple disk cache
Since virgl has no backend compilation, this is just a disk cache for the frontend. As such it is very simple and only implements enough for get_disk_shader_cache() to work. With portal2 apitrace: Before: 100.65 fps After: 129.051 fps Reviewed-by: Gert Wollny <gert.wollny@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10200>
-rw-r--r--src/gallium/drivers/virgl/virgl_screen.c27
-rw-r--r--src/gallium/drivers/virgl/virgl_screen.h3
2 files changed, 30 insertions, 0 deletions
diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c
index e630025191c..30fa47a8fef 100644
--- a/src/gallium/drivers/virgl/virgl_screen.c
+++ b/src/gallium/drivers/virgl/virgl_screen.c
@@ -824,6 +824,9 @@ virgl_destroy_screen(struct pipe_screen *screen)
if (vws)
vws->destroy(vws);
+
+ disk_cache_destroy(vscreen->disk_cache);
+
FREE(vscreen);
}
@@ -881,6 +884,28 @@ static void virgl_query_memory_info(struct pipe_screen *screen, struct pipe_memo
ctx->destroy(ctx);
}
+static struct disk_cache *virgl_get_disk_shader_cache (struct pipe_screen *pscreen)
+{
+ struct virgl_screen *screen = virgl_screen(pscreen);
+
+ return screen->disk_cache;
+}
+
+static void virgl_disk_cache_create(struct virgl_screen *screen)
+{
+ const struct build_id_note *note =
+ build_id_find_nhdr_for_addr(virgl_disk_cache_create);
+ assert(note && build_id_length(note) == 20); /* sha1 */
+
+ const uint8_t *id_sha1 = build_id_data(note);
+ assert(id_sha1);
+
+ char timestamp[41];
+ _mesa_sha1_format(timestamp, id_sha1);
+
+ screen->disk_cache = disk_cache_create("virgl", timestamp, 0);
+}
+
struct pipe_screen *
virgl_create_screen(struct virgl_winsys *vws, const struct pipe_screen_config *config)
{
@@ -923,6 +948,7 @@ virgl_create_screen(struct virgl_winsys *vws, const struct pipe_screen_config *c
screen->base.fence_finish = virgl_fence_finish;
screen->base.fence_get_fd = virgl_fence_get_fd;
screen->base.query_memory_info = virgl_query_memory_info;
+ screen->base.get_disk_shader_cache = virgl_get_disk_shader_cache;
virgl_init_screen_resource_functions(&screen->base);
@@ -937,5 +963,6 @@ virgl_create_screen(struct virgl_winsys *vws, const struct pipe_screen_config *c
slab_create_parent(&screen->transfer_pool, sizeof(struct virgl_transfer), 16);
+ virgl_disk_cache_create(screen);
return &screen->base;
}
diff --git a/src/gallium/drivers/virgl/virgl_screen.h b/src/gallium/drivers/virgl/virgl_screen.h
index 6349cafc8c7..22275cbea1c 100644
--- a/src/gallium/drivers/virgl/virgl_screen.h
+++ b/src/gallium/drivers/virgl/virgl_screen.h
@@ -25,6 +25,7 @@
#include "pipe/p_screen.h"
#include "util/slab.h"
+#include "util/disk_cache.h"
#include "virgl_winsys.h"
enum virgl_debug_flags {
@@ -56,6 +57,8 @@ struct virgl_screen {
bool tweak_gles_emulate_bgra;
bool tweak_gles_apply_bgra_dest_swizzle;
int32_t tweak_gles_tf3_value;
+
+ struct disk_cache *disk_cache;
};