aboutsummaryrefslogtreecommitdiffstats
path: root/src/amd/vulkan
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <[email protected]>2016-11-22 00:19:30 +0100
committerBas Nieuwenhuizen <[email protected]>2016-11-22 07:58:35 +0100
commitd94383970f2cad9f474760b18fd277efeda4c612 (patch)
tree79402638e2a74444767945230e945aabd4b11c21 /src/amd/vulkan
parent43ee4917cadbba7677def091333edbf3cf069f8a (diff)
radv: Use library mtime for cache UUID.
We want to also invalidate the cache when LLVM gets changed. As the specific LLVM revision is not fixed at build time, we will need to check at runtime. Computing a checksum for LLVM is going to be very expensive, so just use the mtime. Tested on my computer that the returned DSO for the LLVM symbol is actually the LLVM DSO. Signed-off-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src/amd/vulkan')
-rw-r--r--src/amd/vulkan/radv_device.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index b73117128de..04c0bdc1941 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -25,10 +25,12 @@
* IN THE SOFTWARE.
*/
+#include <dlfcn.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
+#include <sys/stat.h>
#include "radv_private.h"
#include "util/strtod.h"
@@ -40,15 +42,37 @@
#include "ac_llvm_util.h"
#include "vk_format.h"
#include "sid.h"
-#include "radv_timestamp.h"
#include "util/debug.h"
struct radv_dispatch_table dtable;
-static void
+static int
+radv_get_function_timestamp(void *ptr, uint32_t* timestamp)
+{
+ Dl_info info;
+ struct stat st;
+ if (!dladdr(ptr, &info) || !info.dli_fname) {
+ return -1;
+ }
+ if (stat(info.dli_fname, &st)) {
+ return -1;
+ }
+ *timestamp = st.st_mtim.tv_sec;
+ return 0;
+}
+
+static int
radv_device_get_cache_uuid(void *uuid)
{
+ uint32_t mesa_timestamp, llvm_timestamp;
memset(uuid, 0, VK_UUID_SIZE);
- snprintf(uuid, VK_UUID_SIZE, "radv-%s", RADV_TIMESTAMP);
+ if (radv_get_function_timestamp(radv_device_get_cache_uuid, &mesa_timestamp) ||
+ radv_get_function_timestamp(LLVMInitializeAMDGPUTargetInfo, &llvm_timestamp))
+ return -1;
+
+ memcpy(uuid, &mesa_timestamp, 4);
+ memcpy((char*)uuid + 4, &llvm_timestamp, 4);
+ snprintf((char*)uuid + 8, VK_UUID_SIZE - 8, "radv");
+ return 0;
}
static VkResult
@@ -96,7 +120,11 @@ radv_physical_device_init(struct radv_physical_device *device,
goto fail;
}
- radv_device_get_cache_uuid(device->uuid);
+ if (radv_device_get_cache_uuid(device->uuid)) {
+ radv_finish_wsi(device);
+ device->ws->destroy(device->ws);
+ goto fail;
+ }
fprintf(stderr, "WARNING: radv is not a conformant vulkan implementation, testing use only.\n");
device->name = device->rad_info.name;