Fix VK_NV_external_memory_capabilities support
authorJames Jones <james@lowfidelity.net>
Thu, 18 Aug 2016 22:41:19 +0000 (23:41 +0100)
committerMark Young <marky@lunarg.com>
Fri, 2 Sep 2016 14:59:25 +0000 (08:59 -0600)
-Need to init the instance function pointer

-The function should gracefully fall back on
 drivers that don't support it.

Change-Id: I15b0c68028c8f5ad3b07342e255dbb4c37bb6f0a

loader/extensions.c
loader/loader.c

index 17190a4..e14ceb1 100644 (file)
@@ -58,17 +58,27 @@ terminator_GetPhysicalDeviceExternalImageFormatPropertiesNV(
     VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags,
     VkExternalMemoryHandleTypeFlagsNV externalHandleType,
     VkExternalImageFormatPropertiesNV *pExternalImageFormatProperties) {
-
     struct loader_physical_device *phys_dev =
         (struct loader_physical_device *)physicalDevice;
     struct loader_icd *icd = phys_dev->this_icd;
 
-    assert(icd->GetPhysicalDeviceExternalImageFormatPropertiesNV &&
-           "loader: null GetPhysicalDeviceExternalImageFormatPropertiesNV ICD "
-           "pointer");
+    if (!icd->GetPhysicalDeviceExternalImageFormatPropertiesNV) {
+        if (externalHandleType) {
+            return VK_ERROR_FORMAT_NOT_SUPPORTED;
+        }
+
+        if (!icd->GetPhysicalDeviceImageFormatProperties) {
+            return VK_ERROR_INITIALIZATION_FAILED;
+        }
+
+        pExternalImageFormatProperties->externalMemoryFeatures = 0;
+        pExternalImageFormatProperties->exportFromImportedHandleTypes = 0;
+        pExternalImageFormatProperties->compatibleHandleTypes = 0;
 
-    if (!icd->GetPhysicalDeviceExternalImageFormatPropertiesNV)
-        return VK_ERROR_INITIALIZATION_FAILED;
+        return icd->GetPhysicalDeviceImageFormatProperties(
+            phys_dev->phys_dev, format, type, tiling, usage, flags,
+            &pExternalImageFormatProperties->imageFormatProperties);
+    }
 
     return icd->GetPhysicalDeviceExternalImageFormatPropertiesNV(
         phys_dev->phys_dev, format, type, tiling, usage, flags,
index a519e43..7f90ee4 100644 (file)
@@ -1651,6 +1651,7 @@ static bool loader_icd_init_entrys(struct loader_icd *icd, VkInstance inst,
 #ifdef VK_USE_PLATFORM_WAYLAND_KHR
     LOOKUP_GIPA(GetPhysicalDeviceWaylandPresentationSupportKHR, false);
 #endif
+    LOOKUP_GIPA(GetPhysicalDeviceExternalImageFormatPropertiesNV, false);
 
 #undef LOOKUP_GIPA