anv: Store UUID in physical device.
authorEmil Velikov <emil.velikov@collabora.com>
Thu, 24 Nov 2016 20:30:38 +0000 (20:30 +0000)
committerEmil Velikov <emil.l.velikov@gmail.com>
Mon, 28 Nov 2016 19:46:05 +0000 (19:46 +0000)
Port of an equivalent commit for radv.

v2: Move the call just after MMAP_VERSION (Ken).

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_pipeline_cache.c
src/intel/vulkan/anv_private.h

index 51f0dc4185b5f5503116fdd8119136584ef631f8..d5fbb8c832415515dcc32e6f77cb745ed0bab0e3 100644 (file)
@@ -53,6 +53,13 @@ compiler_perf_log(void *data, const char *fmt, ...)
    va_end(args);
 }
 
+static void
+anv_device_get_cache_uuid(void *uuid)
+{
+   memset(uuid, 0, VK_UUID_SIZE);
+   snprintf(uuid, VK_UUID_SIZE, "anv-%s", ANV_TIMESTAMP);
+}
+
 static VkResult
 anv_physical_device_init(struct anv_physical_device *device,
                          struct anv_instance *instance,
@@ -134,6 +141,7 @@ anv_physical_device_init(struct anv_physical_device *device,
       goto fail;
    }
 
+   anv_device_get_cache_uuid(device->uuid);
    bool swizzled = anv_gem_get_bit6_swizzle(fd, I915_TILING_X);
 
    /* GENs prior to 8 do not support EU/Subslice info */
@@ -454,13 +462,6 @@ void anv_GetPhysicalDeviceFeatures(
       pdevice->compiler->scalar_stage[MESA_SHADER_GEOMETRY];
 }
 
-void
-anv_device_get_cache_uuid(void *uuid)
-{
-   memset(uuid, 0, VK_UUID_SIZE);
-   snprintf(uuid, VK_UUID_SIZE, "anv-%s", ANV_TIMESTAMP);
-}
-
 void anv_GetPhysicalDeviceProperties(
     VkPhysicalDevice                            physicalDevice,
     VkPhysicalDeviceProperties*                 pProperties)
@@ -601,7 +602,7 @@ void anv_GetPhysicalDeviceProperties(
    };
 
    strcpy(pProperties->deviceName, pdevice->name);
-   anv_device_get_cache_uuid(pProperties->pipelineCacheUUID);
+   memcpy(pProperties->pipelineCacheUUID, pdevice->uuid, VK_UUID_SIZE);
 }
 
 void anv_GetPhysicalDeviceQueueFamilyProperties(
index ddd51dbfd771d42465d90d10c954037087c73dc0..a8ea80f51f5c63bc42bab5f3393093a6c9415745 100644 (file)
@@ -333,8 +333,8 @@ anv_pipeline_cache_load(struct anv_pipeline_cache *cache,
                         const void *data, size_t size)
 {
    struct anv_device *device = cache->device;
+   struct anv_physical_device *pdevice = &device->instance->physicalDevice;
    struct cache_header header;
-   uint8_t uuid[VK_UUID_SIZE];
 
    if (cache->cache == NULL)
       return;
@@ -350,8 +350,7 @@ anv_pipeline_cache_load(struct anv_pipeline_cache *cache,
       return;
    if (header.device_id != device->chipset_id)
       return;
-   anv_device_get_cache_uuid(uuid);
-   if (memcmp(header.uuid, uuid, VK_UUID_SIZE) != 0)
+   if (memcmp(header.uuid, pdevice->uuid, VK_UUID_SIZE) != 0)
       return;
 
    const void *end = data + size;
@@ -470,6 +469,7 @@ VkResult anv_GetPipelineCacheData(
 {
    ANV_FROM_HANDLE(anv_device, device, _device);
    ANV_FROM_HANDLE(anv_pipeline_cache, cache, _cache);
+   struct anv_physical_device *pdevice = &device->instance->physicalDevice;
    struct cache_header *header;
 
    if (pData == NULL) {
@@ -497,7 +497,7 @@ VkResult anv_GetPipelineCacheData(
    header->header_version = VK_PIPELINE_CACHE_HEADER_VERSION_ONE;
    header->vendor_id = 0x8086;
    header->device_id = device->chipset_id;
-   anv_device_get_cache_uuid(header->uuid);
+   memcpy(header->uuid, pdevice->uuid, VK_UUID_SIZE);
    p += align_u32(header->header_size, 8);
 
    uint32_t *count = p;
index edc008db71592028f361022824e2a88f134df3ed..4949a8008fa5dc093e9f731f0edc7830272c8d56 100644 (file)
@@ -506,6 +506,8 @@ struct anv_physical_device {
     uint32_t                                    eu_total;
     uint32_t                                    subslice_total;
 
+    uint8_t                                     uuid[VK_UUID_SIZE];
+
     struct wsi_device                       wsi_device;
 };
 
@@ -597,8 +599,6 @@ struct anv_device {
     pthread_cond_t                              queue_submit;
 };
 
-void anv_device_get_cache_uuid(void *uuid);
-
 void anv_device_init_blorp(struct anv_device *device);
 void anv_device_finish_blorp(struct anv_device *device);