summaryrefslogtreecommitdiffstats
path: root/src/intel/vulkan/anv_device.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/intel/vulkan/anv_device.c')
-rw-r--r--src/intel/vulkan/anv_device.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 2d0b23dfdae..7b3ddbb9501 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -35,6 +35,7 @@
#include "util/strtod.h"
#include "util/debug.h"
#include "util/build_id.h"
+#include "util/disk_cache.h"
#include "util/mesa-sha1.h"
#include "vk_util.h"
#include "common/gen_defines.h"
@@ -233,6 +234,8 @@ anv_physical_device_init_uuids(struct anv_physical_device *device)
"build-id too short. It needs to be a SHA");
}
+ memcpy(device->driver_build_sha1, build_id_data(note), 20);
+
struct mesa_sha1 sha1_ctx;
uint8_t sha1[20];
STATIC_ASSERT(VK_UUID_SIZE <= sizeof(sha1));
@@ -271,6 +274,35 @@ anv_physical_device_init_uuids(struct anv_physical_device *device)
return VK_SUCCESS;
}
+static void
+anv_physical_device_init_disk_cache(struct anv_physical_device *device)
+{
+#ifdef ENABLE_SHADER_CACHE
+ char renderer[9];
+ MAYBE_UNUSED int len = snprintf(renderer, sizeof(renderer), "anv_%04x",
+ device->chipset_id);
+ assert(len == sizeof(renderer) - 1);
+
+ char timestamp[41];
+ _mesa_sha1_format(timestamp, device->driver_build_sha1);
+
+ device->disk_cache = disk_cache_create(renderer, timestamp, 0);
+#else
+ device->disk_cache = NULL;
+#endif
+}
+
+static void
+anv_physical_device_free_disk_cache(struct anv_physical_device *device)
+{
+#ifdef ENABLE_SHADER_CACHE
+ if (device->disk_cache)
+ disk_cache_destroy(device->disk_cache);
+#else
+ assert(device->disk_cache == NULL);
+#endif
+}
+
static VkResult
anv_physical_device_init(struct anv_physical_device *device,
struct anv_instance *instance,
@@ -442,6 +474,8 @@ anv_physical_device_init(struct anv_physical_device *device,
if (result != VK_SUCCESS)
goto fail;
+ anv_physical_device_init_disk_cache(device);
+
if (instance->enabled_extensions.KHR_display) {
master_fd = open(primary_path, O_RDWR | O_CLOEXEC);
if (master_fd >= 0) {
@@ -459,6 +493,7 @@ anv_physical_device_init(struct anv_physical_device *device,
result = anv_init_wsi(device);
if (result != VK_SUCCESS) {
ralloc_free(device->compiler);
+ anv_physical_device_free_disk_cache(device);
goto fail;
}
@@ -481,6 +516,7 @@ static void
anv_physical_device_finish(struct anv_physical_device *device)
{
anv_finish_wsi(device);
+ anv_physical_device_free_disk_cache(device);
ralloc_free(device->compiler);
close(device->local_fd);
if (device->master_fd >= 0)