OSDN Git Service

Return an error if apiVersion is 1.1+.
authorIan Elliott <ianelliott@google.com>
Mon, 8 May 2017 21:59:09 +0000 (15:59 -0600)
committerIan Elliott <ianelliott@google.com>
Mon, 8 May 2017 21:59:09 +0000 (15:59 -0600)
The Vulkan loader is supposed to check the requested apiVersion and return
VK_ERROR_INCOMPATIBLE_DRIVER if the requested version is not supported.  The
loader wasn't performing the check, nor returning the error.  A log message is
also issued, explaining why the application failed to create an instance.

Bug: 38040828
Test: Modify cube to use 1.0 or 1.1 and ensure proper return value.
Change-Id: I8cc792305a346c6e1db40f61d5235c301d8ae848

vulkan/libvulkan/driver.cpp

index f2cd8e6..0005a90 100644 (file)
@@ -887,6 +887,19 @@ VkResult CreateInstance(const VkInstanceCreateInfo* pCreateInfo,
     const VkAllocationCallbacks& data_allocator =
         (pAllocator) ? *pAllocator : GetDefaultAllocator();
 
+    if (pCreateInfo->pApplicationInfo &&
+        pCreateInfo->pApplicationInfo->apiVersion >= VK_MAKE_VERSION(1, 1, 0)) {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wold-style-cast"
+        ALOGI(
+            "Requested Vulkan instance version %d.%d is greater than max "
+            "supported version (1.0)",
+            VK_VERSION_MAJOR(pCreateInfo->pApplicationInfo->apiVersion),
+            VK_VERSION_MINOR(pCreateInfo->pApplicationInfo->apiVersion));
+#pragma clang diagnostic pop
+        return VK_ERROR_INCOMPATIBLE_DRIVER;
+    }
+
     CreateInfoWrapper wrapper(*pCreateInfo, data_allocator);
     VkResult result = wrapper.Validate();
     if (result != VK_SUCCESS)