diff options
author | Emil Velikov <[email protected]> | 2016-11-24 20:30:39 +0000 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2016-11-28 19:46:45 +0000 |
commit | 83548e12921b5724aa6c78c2b1efc9ff774fd7a2 (patch) | |
tree | b99c1a5ee2f941766e0742c6a2de00e14c3b1406 /src | |
parent | de138e9cede4b1996fac9256d894c80e7b48a6d7 (diff) |
anv: Use library mtime for cache UUID.
Inspired by a similar commit for radv.
Rather than recomputing the timestamp on each make invocation, just
fetch it at runtime.
Thus we no longer get the constant rebuild of anv_device.c and the
follow-up libvulkan_intel.so link, when nothing has changed.
I.e. using make && make install is a little bit faster.
v2: Use bool return type (Ken).
Signed-off-by: Emil Velikov <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/intel/vulkan/anv_device.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index d5fbb8c8324..3050c383a79 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -21,15 +21,16 @@ * IN THE SOFTWARE. */ +#include <dlfcn.h> #include <assert.h> #include <stdbool.h> #include <string.h> #include <sys/mman.h> +#include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include "anv_private.h" -#include "anv_timestamp.h" #include "util/strtod.h" #include "util/debug.h" @@ -53,11 +54,32 @@ compiler_perf_log(void *data, const char *fmt, ...) va_end(args); } -static void +static bool +anv_get_function_timestamp(void *ptr, uint32_t* timestamp) +{ + Dl_info info; + struct stat st; + if (!dladdr(ptr, &info) || !info.dli_fname) + return false; + + if (stat(info.dli_fname, &st)) + return false; + + *timestamp = st.st_mtim.tv_sec; + return true; +} + +static bool anv_device_get_cache_uuid(void *uuid) { + uint32_t timestamp; + memset(uuid, 0, VK_UUID_SIZE); - snprintf(uuid, VK_UUID_SIZE, "anv-%s", ANV_TIMESTAMP); + if (anv_get_function_timestamp(anv_device_get_cache_uuid, ×tamp)) + return false; + + snprintf(uuid, VK_UUID_SIZE, "anv-%d", timestamp); + return true; } static VkResult @@ -141,7 +163,11 @@ anv_physical_device_init(struct anv_physical_device *device, goto fail; } - anv_device_get_cache_uuid(device->uuid); + if (!anv_device_get_cache_uuid(device->uuid)) { + result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED, + "cannot generate UUID"); + goto fail; + } bool swizzled = anv_gem_get_bit6_swizzle(fd, I915_TILING_X); /* GENs prior to 8 do not support EU/Subslice info */ |