[Mesa-dev] [PATCH 1/8] anv: Store UUID in physical device.

Jason Ekstrand jason at jlekstrand.net
Thu Nov 24 20:53:46 UTC 2016


On Nov 24, 2016 12:42 PM, "Emil Velikov" <emil.l.velikov at gmail.com> wrote:
>
> From: Emil Velikov <emil.velikov at collabora.com>
>
> Port of an equivalent commit for radv.
>
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
> ---
>  src/intel/vulkan/anv_device.c         | 18 ++++++++++--------
>  src/intel/vulkan/anv_pipeline_cache.c |  8 ++++----
>  src/intel/vulkan/anv_private.h        |  4 ++--
>  3 files changed, 16 insertions(+), 14 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
> index 2c8ac49..58c6b3f 100644
> --- a/src/intel/vulkan/anv_device.c
> +++ b/src/intel/vulkan/anv_device.c
> @@ -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);

This is just two lines.  Let's inline it.  Also, it occurs to new that we
should also be including the PCI ID in the UUID so that you don't end up
using cached shaders on the wrong hardware when using distro builds.  If
you want that to be a separate patch that's fine.  I can also do it.  In
any case, this seems reasonable.  With this guy inlined,

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>

> +}
> +
>  static VkResult
>  anv_physical_device_init(struct anv_physical_device *device,
>                           struct anv_instance *instance,
> @@ -179,6 +186,8 @@ anv_physical_device_init(struct anv_physical_device
*device,
>     if (result != VK_SUCCESS)
>         goto fail;
>
> +   anv_device_get_cache_uuid(device->uuid);
> +
>     /* XXX: Actually detect bit6 swizzling */
>     isl_device_init(&device->isl_dev, &device->info, swizzled);
>
> @@ -455,13 +464,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)
> @@ -602,7 +604,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(
> diff --git a/src/intel/vulkan/anv_pipeline_cache.c
b/src/intel/vulkan/anv_pipeline_cache.c
> index ddd51db..a8ea80f 100644
> --- a/src/intel/vulkan/anv_pipeline_cache.c
> +++ b/src/intel/vulkan/anv_pipeline_cache.c
> @@ -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;
> diff --git a/src/intel/vulkan/anv_private.h
b/src/intel/vulkan/anv_private.h
> index 2fc543d..d3f98e8 100644
> --- a/src/intel/vulkan/anv_private.h
> +++ b/src/intel/vulkan/anv_private.h
> @@ -505,6 +505,8 @@ struct anv_physical_device {
>      uint32_t                                    eu_total;
>      uint32_t                                    subslice_total;
>
> +    uint8_t                                     uuid[VK_UUID_SIZE];
> +
>      struct wsi_device                       wsi_device;
>  };
>
> @@ -596,8 +598,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);
>
> --
> 2.10.2
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161124/ca4acf20/attachment-0001.html>


More information about the mesa-dev mailing list