summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorBoyan Ding <[email protected]>2017-03-22 11:18:19 +0800
committerIlia Mirkin <[email protected]>2017-03-22 22:51:35 -0400
commit51b7fae1ae7f9dadd66c560072f1917302f99fde (patch)
treeacc6ed8491551296718e89a6f708ae8df0ef4b63 /src/gallium/drivers
parente8875c7a87ee06b9bdd3e2b56c659672b0d733cf (diff)
nouveau: enable glsl/tgsi on-disk cache
v2: Fix argument to nouveau_screen_get_name() Signed-off-by: Boyan Ding <[email protected]> Reviewed-by: Timothy Arceri <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/nouveau/nouveau_screen.c30
-rw-r--r--src/gallium/drivers/nouveau/nouveau_screen.h3
2 files changed, 33 insertions, 0 deletions
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c
index f59e101cafb..15cb965453a 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.c
+++ b/src/gallium/drivers/nouveau/nouveau_screen.c
@@ -60,6 +60,12 @@ nouveau_screen_get_timestamp(struct pipe_screen *pscreen)
return cpu_time + nouveau_screen(pscreen)->cpu_gpu_time_delta;
}
+static struct disk_cache *
+nouveau_screen_get_disk_shader_cache(struct pipe_screen *pscreen)
+{
+ return nouveau_screen(pscreen)->disk_shader_cache;
+}
+
static void
nouveau_screen_fence_ref(struct pipe_screen *pscreen,
struct pipe_fence_handle **ptr,
@@ -139,6 +145,25 @@ nouveau_screen_bo_get_handle(struct pipe_screen *pscreen,
}
}
+static void
+nouveau_disk_cache_create(struct nouveau_screen *screen)
+{
+ uint32_t mesa_timestamp;
+ char *timestamp_str;
+ int res;
+
+ if (disk_cache_get_function_timestamp(nouveau_disk_cache_create,
+ &mesa_timestamp)) {
+ res = asprintf(&timestamp_str, "%u", mesa_timestamp);
+ if (res != -1) {
+ screen->disk_shader_cache =
+ disk_cache_create(nouveau_screen_get_name(&screen->base),
+ timestamp_str);
+ free(timestamp_str);
+ }
+ }
+}
+
int
nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
{
@@ -208,12 +233,15 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
pscreen->get_name = nouveau_screen_get_name;
pscreen->get_vendor = nouveau_screen_get_vendor;
pscreen->get_device_vendor = nouveau_screen_get_device_vendor;
+ pscreen->get_disk_shader_cache = nouveau_screen_get_disk_shader_cache;
pscreen->get_timestamp = nouveau_screen_get_timestamp;
pscreen->fence_reference = nouveau_screen_fence_ref;
pscreen->fence_finish = nouveau_screen_fence_finish;
+ nouveau_disk_cache_create(screen);
+
util_format_s3tc_init();
screen->lowmem_bindings = PIPE_BIND_GLOBAL; /* gallium limit */
@@ -254,6 +282,8 @@ nouveau_screen_fini(struct nouveau_screen *screen)
nouveau_device_del(&screen->device);
nouveau_drm_del(&screen->drm);
close(fd);
+
+ disk_cache_destroy(screen->disk_shader_cache);
}
static void
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h
index 28c4760af20..e4fbae99ca4 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.h
+++ b/src/gallium/drivers/nouveau/nouveau_screen.h
@@ -2,6 +2,7 @@
#define __NOUVEAU_SCREEN_H__
#include "pipe/p_screen.h"
+#include "util/disk_cache.h"
#include "util/u_memory.h"
#ifdef DEBUG
@@ -59,6 +60,8 @@ struct nouveau_screen {
unsigned profiles_present;
} firmware_info;
+ struct disk_cache *disk_shader_cache;
+
#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS
union {
uint64_t v[29];