vulkan: Tolerate missing GetSwapchainGrallocUsageANDROID function

Some drivers implementing ANDROID_native_buffer V6 have /removed/ the
old function. We shouldn't really mind if they do that -- we're never
going to call it anyway if they do expose the new
GetSwapchainGrallocUsage2ANDROID function.

V2: Fail at CreateDevice-time if neither function is exposed.

Change-Id: Id1e3dd5e2e71a9291dd610e908f9906acaaf0ad0
Related bugs: b/34177594
Test: build
diff --git a/vulkan/libvulkan/driver.cpp b/vulkan/libvulkan/driver.cpp
index 991c3ed..16d2ebc 100644
--- a/vulkan/libvulkan/driver.cpp
+++ b/vulkan/libvulkan/driver.cpp
@@ -899,6 +899,23 @@
 
         return VK_ERROR_INCOMPATIBLE_DRIVER;
     }
+
+    // sanity check ANDROID_native_buffer implementation, whose set of
+    // entrypoints varies according to the spec version.
+    if ((wrapper.GetHalExtensions()[ProcHook::ANDROID_native_buffer]) &&
+        !data->driver.GetSwapchainGrallocUsageANDROID &&
+        !data->driver.GetSwapchainGrallocUsage2ANDROID) {
+        ALOGE("Driver's implementation of ANDROID_native_buffer is broken;"
+              " must expose at least one of "
+              "vkGetSwapchainGrallocUsageANDROID or "
+              "vkGetSwapchainGrallocUsage2ANDROID");
+
+        data->driver.DestroyDevice(dev, pAllocator);
+        FreeDeviceData(data, data_allocator);
+
+        return VK_ERROR_INCOMPATIBLE_DRIVER;
+    }
+
     data->driver_device = dev;
 
     *pDevice = dev;