[Mesa-dev] [PATCH 5/5] anv: Implement VK_KHR_get_physical_device_properties2

Jason Ekstrand jason at jlekstrand.net
Wed Jan 25 22:02:52 UTC 2017


Having read through this code, I think I like this approach.  It seems to
be the most easily extensible thing we can do.  Series is

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

On Wed, Jan 25, 2017 at 12:12 PM, Chad Versace <chadversary at chromium.org>
wrote:

> ---
>  src/intel/vulkan/anv_device.c  | 90 ++++++++++++++++++++++++++++++
> ++++++++++++
>  src/intel/vulkan/anv_formats.c | 53 +++++++++++++++++++++++++
>  src/intel/vulkan/anv_private.h | 18 +++++++++
>  3 files changed, 161 insertions(+)
>
> diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
> index 5c9652290f..5f86444ed9 100644
> --- a/src/intel/vulkan/anv_device.c
> +++ b/src/intel/vulkan/anv_device.c
> @@ -253,6 +253,10 @@ static const VkExtensionProperties
> global_extensions[] = {
>        .specVersion = 5,
>     },
>  #endif
> +   {
> +      .extensionName = VK_KHR_GET_PHYSICAL_DEVICE_
> PROPERTIES_2_EXTENSION_NAME,
> +      .specVersion = 1,
> +   },
>  };
>
>  static const VkExtensionProperties device_extensions[] = {
> @@ -493,6 +497,21 @@ void anv_GetPhysicalDeviceFeatures(
>        pdevice->compiler->scalar_stage[MESA_SHADER_GEOMETRY];
>  }
>
> +void anv_GetPhysicalDeviceFeatures2KHR(
> +    VkPhysicalDevice                            physicalDevice,
> +    VkPhysicalDeviceFeatures2KHR*               pFeatures)
> +{
> +   anv_GetPhysicalDeviceFeatures(physicalDevice, &pFeatures->features);
> +
> +   for (struct anv_common *c = pFeatures->pNext; c != NULL; c = c->pNext)
> {
>

It seems like it might be nice to have an anv_foreach_ext_struct macro so
this becomes:

anv_foreach_ext_struct(s, pFeatures) {
}


> +      switch (c->sType) {
> +      default:
> +         anv_debug_ignored_stype(c->sType);
> +         break;
> +      }
> +   }
> +}
> +
>  void anv_GetPhysicalDeviceProperties(
>      VkPhysicalDevice                            physicalDevice,
>      VkPhysicalDeviceProperties*                 pProperties)
> @@ -636,6 +655,21 @@ void anv_GetPhysicalDeviceProperties(
>     memcpy(pProperties->pipelineCacheUUID, pdevice->uuid, VK_UUID_SIZE);
>  }
>
> +void anv_GetPhysicalDeviceProperties2KHR(
> +    VkPhysicalDevice                            physicalDevice,
> +    VkPhysicalDeviceProperties2KHR*             pProperties)
> +{
> +   anv_GetPhysicalDeviceProperties(physicalDevice,
> &pProperties->properties);
> +
> +   for (struct anv_common *c = pProperties->pNext; c != NULL; c =
> c->pNext) {
> +      switch (c->sType) {
> +      default:
> +         anv_debug_ignored_stype(c->sType);
> +         break;
> +      }
> +   }
> +}
> +
>  static void
>  anv_get_queue_family_properties(struct anv_physical_device *phys_dev,
>                                  VkQueueFamilyProperties *props)
> @@ -675,6 +709,45 @@ void anv_GetPhysicalDeviceQueueFamilyProperties(
>     anv_get_queue_family_properties(phys_dev, pQueueFamilyProperties);
>  }
>
> +void anv_GetPhysicalDeviceQueueFamilyProperties2KHR(
> +    VkPhysicalDevice                            physicalDevice,
> +    uint32_t*                                   pQueueFamilyPropertyCount,
> +    VkQueueFamilyProperties2KHR*                pQueueFamilyProperties)
> +{
> +
> +   ANV_FROM_HANDLE(anv_physical_device, phys_dev, physicalDevice);
> +
> +   if (pQueueFamilyProperties == NULL) {
> +      *pQueueFamilyPropertyCount = 1;
> +      return;
> +   }
> +
> +   /* The spec implicitly allows the incoming count to be 0. From the
> Vulkan
> +    * 1.0.38 spec, Section 4.1 Physical Devices:
> +    *
> +    *     If the value referenced by pQueueFamilyPropertyCount is not 0
> [then
> +    *     do stuff].
> +    */
> +   if (*pQueueFamilyPropertyCount == 0)
> +      return;
> +
> +   /* We support exactly one queue family. So need to traverse only the
> first
> +    * array element's pNext chain.
> +    */
> +   *pQueueFamilyPropertyCount = 1;
> +   anv_get_queue_family_properties(phys_dev,
> +         &pQueueFamilyProperties->queueFamilyProperties);
> +
> +   for (struct anv_common *c = pQueueFamilyProperties->pNext;
> +        c != NULL; c = c->pNext) {
> +      switch (c->sType) {
> +      default:
> +         anv_debug_ignored_stype(c->sType);
> +         break;
> +      }
> +   }
> +}
> +
>  void anv_GetPhysicalDeviceMemoryProperties(
>      VkPhysicalDevice                            physicalDevice,
>      VkPhysicalDeviceMemoryProperties*           pMemoryProperties)
> @@ -727,6 +800,23 @@ void anv_GetPhysicalDeviceMemoryProperties(
>     };
>  }
>
> +void anv_GetPhysicalDeviceMemoryProperties2KHR(
> +    VkPhysicalDevice                            physicalDevice,
> +    VkPhysicalDeviceMemoryProperties2KHR*       pMemoryProperties)
> +{
> +   anv_GetPhysicalDeviceMemoryProperties(physicalDevice,
> +                                         &pMemoryProperties->
> memoryProperties);
> +
> +   for (struct anv_common *c = pMemoryProperties->pNext;
> +        c != NULL; c = c->pNext) {
> +      switch (c->sType) {
> +      default:
> +         anv_debug_ignored_stype(c->sType);
> +         break;
> +      }
> +   }
> +}
> +
>  PFN_vkVoidFunction anv_GetInstanceProcAddr(
>      VkInstance                                  instance,
>      const char*                                 pName)
> diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_
> formats.c
> index b4ff9c7698..e7a04f313c 100644
> --- a/src/intel/vulkan/anv_formats.c
> +++ b/src/intel/vulkan/anv_formats.c
> @@ -450,6 +450,24 @@ void anv_GetPhysicalDeviceFormatProperties(
>                 pFormatProperties);
>  }
>
> +void anv_GetPhysicalDeviceFormatProperties2KHR(
> +    VkPhysicalDevice                            physicalDevice,
> +    VkFormat                                    format,
> +    VkFormatProperties2KHR*                     pFormatProperties)
> +{
> +   anv_GetPhysicalDeviceFormatProperties(physicalDevice, format,
> +                                         &pFormatProperties->
> formatProperties);
> +
> +   for (struct anv_common *c = pFormatProperties->pNext;
> +        c != NULL; c = c->pNext) {
> +      switch (c->sType) {
> +      default:
> +         anv_debug_ignored_stype(c->sType);
> +         break;
> +      }
> +   }
> +}
> +
>  static VkResult
>  anv_get_image_format_properties(
>     struct anv_physical_device *physical_device,
> @@ -625,6 +643,31 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties(
>                                            pImageFormatProperties);
>  }
>
> +VkResult vkGetPhysicalDeviceImageFormatProperties2KHR(
> +    VkPhysicalDevice                            physicalDevice,
> +    const VkPhysicalDeviceImageFormatInfo2KHR*  pImageFormatInfo,
> +    VkImageFormatProperties2KHR*                pImageFormatProperties)
> +{
> +   ANV_FROM_HANDLE(anv_physical_device, physical_device, physicalDevice);
> +   VkResult result;
> +
> +   result = anv_get_image_format_properties(physical_device,
> pImageFormatInfo,
> +               &pImageFormatProperties->imageFormatProperties);
> +   if (result != VK_SUCCESS)
> +      return result;
> +
> +   for (struct anv_common *c = pImageFormatProperties->pNext;
> +        c != NULL; c = c->pNext) {
> +      switch (c->sType) {
> +      default:
> +         anv_debug_ignored_stype(c->sType);
> +         break;
> +      }
> +   }
> +
> +   return VK_SUCCESS;
> +}
> +
>  void anv_GetPhysicalDeviceSparseImageFormatProperties(
>      VkPhysicalDevice                            physicalDevice,
>      VkFormat                                    format,
> @@ -638,3 +681,13 @@ void anv_GetPhysicalDeviceSparseImageFo
> rmatProperties(
>     /* Sparse images are not yet supported. */
>     *pNumProperties = 0;
>  }
> +
> +void vkGetPhysicalDeviceSparseImageFormatProperties2KHR(
> +    VkPhysicalDevice                            physicalDevice,
> +    const VkPhysicalDeviceSparseImageFormatInfo2KHR* pFormatInfo,
> +    uint32_t*                                   pPropertyCount,
> +    VkSparseImageFormatProperties2KHR*          pProperties)
> +{
> +   /* Sparse images are not yet supported. */
> +   *pPropertyCount = 0;
> +}
> diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_
> private.h
> index 2a071693ca..8b1ada29f8 100644
> --- a/src/intel/vulkan/anv_private.h
> +++ b/src/intel/vulkan/anv_private.h
> @@ -206,6 +206,24 @@ VkResult __vk_errorf(VkResult error, const char
> *file, int line, const char *for
>  #define anv_debug(format, ...)
>  #endif
>
> +/**
> + * Warn on ignored extension structs.
> + *
> + * The Vulkan spec requires us to ignore unsupported or unknown structs in
> + * a pNext chain.  In debug mode, emitting warnings for ignored structs
> may
> + * help us discover structs that we should not have ignored.
> + *
> + *
> + * From the Vulkan 1.0.38 spec:
> + *
> + *    Any component of the implementation (the loader, any enabled layers,
> + *    and drivers) must skip over, without processing (other than reading
> the
> + *    sType and pNext members) any chained structures with sType values
> not
> + *    defined by extensions supported by that component.
> + */
> +#define anv_debug_ignored_stype(sType) \
> +   anv_debug("debug: %s: ignored VkStructureType %u\n", __func__, (sType))
> +
>  void __anv_finishme(const char *file, int line, const char *format, ...)
>     anv_printflike(3, 4);
>  void anv_loge(const char *format, ...) anv_printflike(1, 2);
> --
> 2.11.0
>
> _______________________________________________
> 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/20170125/73e080cb/attachment-0001.html>


More information about the mesa-dev mailing list