[Mesa-stable] [PATCH 2/4] anv: use cache uuid based on the build timestamp.

Emil Velikov emil.l.velikov at gmail.com
Wed Jun 22 12:04:41 UTC 2016


From: Emil Velikov <emil.velikov at collabora.com>

Do not rely on the git sha1:
 - its current truncated form makes it less unique
 - it does not attribute for local (Vulkand or otherwise) changes

Use a timestamp produced at the time of build. It's perfectly unique,
unless someone explicitly thinkers with their system clock. Even then
chances of producing the exact same one are very small, if not zero.

Cc: Jason Ekstrand <jason at jlekstrand.net>
Cc: mesa-stable at lists.freedesktop.org
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
Current approach uses seconds since Epoch, but if people prefer we
can use nano seconds, combination of the two and/or other.
---
 src/intel/vulkan/.gitignore   |  2 ++
 src/intel/vulkan/Makefile.am  | 15 ++++++++++++++-
 src/intel/vulkan/anv_device.c |  4 ++--
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/intel/vulkan/.gitignore b/src/intel/vulkan/.gitignore
index a496146..7ef6a48 100644
--- a/src/intel/vulkan/.gitignore
+++ b/src/intel/vulkan/.gitignore
@@ -2,3 +2,5 @@
 /anv_entrypoints.c
 /anv_entrypoints.h
 /dev_icd.json
+/anv_timestamp.h.tmp
+/anv_timestamp.h
diff --git a/src/intel/vulkan/Makefile.am b/src/intel/vulkan/Makefile.am
index 4d9ff90..8332ae5 100644
--- a/src/intel/vulkan/Makefile.am
+++ b/src/intel/vulkan/Makefile.am
@@ -131,7 +131,20 @@ anv_entrypoints.c : anv_entrypoints_gen.py $(vulkan_include_HEADERS)
 	$(AM_V_GEN) cat $(vulkan_include_HEADERS) |\
 	$(PYTHON2) $(srcdir)/anv_entrypoints_gen.py code > $@
 
-BUILT_SOURCES = $(VULKAN_GENERATED_FILES)
+
+.PHONY: anv_timestamp.h.tmp
+anv_timestamp.h.tmp:
+	$(AM_V_GEN) echo "#define ANV_TIMESTAMP `date +%s`" > $@
+
+anv_timestamp.h: anv_timestamp.h.tmp
+	@echo "Updating anv_timestamp.h"
+	@if ! cmp -s anv_timestamp.h.tmp anv_timestamp.h; then \
+		mv anv_timestamp.h.tmp anv_timestamp.h ;\
+	else \
+		rm anv_timestamp.h.tmp ;\
+	fi
+
+BUILT_SOURCES = $(VULKAN_GENERATED_FILES) anv_timestamp.h
 CLEANFILES = $(BUILT_SOURCES) dev_icd.json
 EXTRA_DIST = \
 	$(top_srcdir)/include/vulkan/vk_icd.h \
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 97300c3..e395b1c 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -28,7 +28,7 @@
 #include <fcntl.h>
 
 #include "anv_private.h"
-#include "git_sha1.h"
+#include "anv_timestamp.h"
 #include "util/strtod.h"
 #include "util/debug.h"
 
@@ -426,7 +426,7 @@ void
 anv_device_get_cache_uuid(void *uuid)
 {
    memset(uuid, 0, VK_UUID_SIZE);
-   snprintf(uuid, VK_UUID_SIZE, "anv-%s", MESA_GIT_SHA1 + 4);
+   snprintf(uuid, VK_UUID_SIZE, "anv-%s", ANV_TIMESTAMP);
 }
 
 void anv_GetPhysicalDeviceProperties(
-- 
2.8.2



More information about the mesa-stable mailing list