vulkan: Driver device extension enumeration and filtering

- Return VK_ERROR_EXTENSION_NOT_PRESENT if a requested device
  extension is not supported by the loader, driver, or any enabled
  device layer.
- Filter out device extensions not supported by the driver when
  creating the driver device.
- Enumerate device extensions supported by the driver or loader.

Change-Id: I538e37bc74cc7f0eb27b1211b9324fb3b8a06e14
(cherry picked from commit 35873021f4f79ded0f584e433076c2675c6aed69)
diff --git a/vulkan/nulldrv/null_driver.cpp b/vulkan/nulldrv/null_driver.cpp
index c66ec95..e12409c 100644
--- a/vulkan/nulldrv/null_driver.cpp
+++ b/vulkan/nulldrv/null_driver.cpp
@@ -38,7 +38,6 @@
     VkAllocationCallbacks allocator;
     VkPhysicalDevice_T physical_device;
     uint64_t next_callback_handle;
-    bool debug_report_enabled;
 };
 
 struct VkQueue_T {
@@ -251,13 +250,15 @@
     instance->allocator = *allocator;
     instance->physical_device.dispatch.magic = HWVULKAN_DISPATCH_MAGIC;
     instance->next_callback_handle = 0;
-    instance->debug_report_enabled = false;
 
     for (uint32_t i = 0; i < create_info->enabledExtensionCount; i++) {
         if (strcmp(create_info->ppEnabledExtensionNames[i],
                    VK_EXT_DEBUG_REPORT_EXTENSION_NAME) == 0) {
-            ALOGV("Enabling " VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
-            instance->debug_report_enabled = true;
+            ALOGV("instance extension '%s' requested",
+                  create_info->ppEnabledExtensionNames[i]);
+        } else {
+            ALOGW("unsupported extension '%s' requested",
+                  create_info->ppEnabledExtensionNames[i]);
         }
     }
 
@@ -375,7 +376,7 @@
 // Device
 
 VkResult CreateDevice(VkPhysicalDevice physical_device,
-                      const VkDeviceCreateInfo*,
+                      const VkDeviceCreateInfo* create_info,
                       const VkAllocationCallbacks* allocator,
                       VkDevice* out_device) {
     VkInstance_T* instance = GetInstanceFromPhysicalDevice(physical_device);
@@ -394,6 +395,13 @@
     std::fill(device->next_handle.begin(), device->next_handle.end(),
               UINT64_C(0));
 
+    for (uint32_t i = 0; i < create_info->enabledExtensionCount; i++) {
+        if (strcmp(create_info->ppEnabledExtensionNames[i],
+                   VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME) == 0) {
+            ALOGV("Enabling " VK_ANDROID_NATIVE_BUFFER_EXTENSION_NAME);
+        }
+    }
+
     *out_device = device;
     return VK_SUCCESS;
 }