anv: Implement VK_KHR_get_physical_device_properties2
authorChad Versace <chadversary@chromium.org>
Wed, 25 Jan 2017 20:12:20 +0000 (12:12 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 26 Jan 2017 03:18:47 +0000 (19:18 -0800)
Reviewed-by: Jason Ekstranad <jason@jlekstrand.net>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/intel/vulkan/anv_device.c
src/intel/vulkan/anv_formats.c
src/intel/vulkan/anv_private.h

index 84338dce812e2bb782de9051b563def3abc7ac61..f40e9b25ce9fb32f14d26fe5926c6b18c7df63d5 100644 (file)
@@ -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[] = {
@@ -497,6 +501,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) {
+      switch (c->sType) {
+      default:
+         anv_debug_ignored_stype(c->sType);
+         break;
+      }
+   }
+}
+
 void anv_GetPhysicalDeviceProperties(
     VkPhysicalDevice                            physicalDevice,
     VkPhysicalDeviceProperties*                 pProperties)
@@ -640,6 +659,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)
@@ -679,6 +713,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)
@@ -731,6 +804,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)
index 47f939b47eea18db9966a51e81a6a71a8c848e03..0e84960085a12c963c9668c4d79bfc23b779e2ac 100644 (file)
@@ -462,6 +462,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,
@@ -637,6 +655,31 @@ VkResult anv_GetPhysicalDeviceImageFormatProperties(
                                           pImageFormatProperties);
 }
 
+VkResult anv_GetPhysicalDeviceImageFormatProperties2KHR(
+    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,
@@ -650,3 +693,13 @@ void anv_GetPhysicalDeviceSparseImageFormatProperties(
    /* Sparse images are not yet supported. */
    *pNumProperties = 0;
 }
+
+void anv_GetPhysicalDeviceSparseImageFormatProperties2KHR(
+    VkPhysicalDevice                            physicalDevice,
+    const VkPhysicalDeviceSparseImageFormatInfo2KHR* pFormatInfo,
+    uint32_t*                                   pPropertyCount,
+    VkSparseImageFormatProperties2KHR*          pProperties)
+{
+   /* Sparse images are not yet supported. */
+   *pPropertyCount = 0;
+}
index 12ee79d3d89468292359724abec87b204a262bf2..0cc6550a402be6c39c0e2092e8e66df0018a789a 100644 (file)
@@ -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);