Add Vulkan extensions for AHardwareBuffer support

Just adds the appropriate extensions for AHardwareBuffer support on
Android doesn't yet attempt to expose any.

Bug: dawn:286
Change-Id: I1345d98044bbcaf91cb31235bffbdc28a163c6e0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101440
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Brandon Jones <bajones@chromium.org>
diff --git a/scripts/dawn_features.gni b/scripts/dawn_features.gni
index 57227de..76c4a03 100644
--- a/scripts/dawn_features.gni
+++ b/scripts/dawn_features.gni
@@ -36,7 +36,8 @@
 
   # Enables SwiftShader as the fallback adapter. Requires dawn_swiftshader_dir
   # to be set to take effect.
-  dawn_use_swiftshader = true
+  # TODO(dawn:1536): Enable SwiftShader for Android.
+  dawn_use_swiftshader = !is_android
 }
 
 declare_args() {
diff --git a/src/dawn/native/BUILD.gn b/src/dawn/native/BUILD.gn
index 53b237a..19ca4d4 100644
--- a/src/dawn/native/BUILD.gn
+++ b/src/dawn/native/BUILD.gn
@@ -30,8 +30,7 @@
 use_angle = dawn_use_angle && defined(dawn_angle_dir)
 
 # Swiftshader is an optional dependency, only use it if the path has been set.
-use_swiftshader =
-    dawn_use_swiftshader && dawn_swiftshader_dir != "" && !is_android
+use_swiftshader = dawn_use_swiftshader && dawn_swiftshader_dir != ""
 if (use_swiftshader) {
   assert(dawn_enable_vulkan,
          "dawn_use_swiftshader requires dawn_enable_vulkan=true")
diff --git a/src/dawn/native/vulkan/VulkanExtensions.cpp b/src/dawn/native/vulkan/VulkanExtensions.cpp
index aaf3e65..7e61d12 100644
--- a/src/dawn/native/vulkan/VulkanExtensions.cpp
+++ b/src/dawn/native/vulkan/VulkanExtensions.cpp
@@ -139,6 +139,7 @@
     {DeviceExt::GetPhysicalDeviceProperties2, "VK_KHR_get_physical_device_properties2",
      VulkanVersion_1_1},
     {DeviceExt::GetMemoryRequirements2, "VK_KHR_get_memory_requirements2", VulkanVersion_1_1},
+    {DeviceExt::DedicatedAllocation, "VK_KHR_dedicated_allocation", VulkanVersion_1_1},
     {DeviceExt::ExternalMemoryCapabilities, "VK_KHR_external_memory_capabilities",
      VulkanVersion_1_1},
     {DeviceExt::ExternalSemaphoreCapabilities, "VK_KHR_external_semaphore_capabilities",
@@ -156,16 +157,19 @@
     {DeviceExt::ZeroInitializeWorkgroupMemory, "VK_KHR_zero_initialize_workgroup_memory",
      VulkanVersion_1_3},
 
+    {DeviceExt::DepthClipEnable, "VK_EXT_depth_clip_enable", NeverPromoted},
+    {DeviceExt::ImageDrmFormatModifier, "VK_EXT_image_drm_format_modifier", NeverPromoted},
+    {DeviceExt::Swapchain, "VK_KHR_swapchain", NeverPromoted},
+    {DeviceExt::SubgroupSizeControl, "VK_EXT_subgroup_size_control", NeverPromoted},
+    {DeviceExt::QueueFamilyForeign, "VK_EXT_queue_family_foreign", NeverPromoted},
+
+    {DeviceExt::ExternalMemoryAndroidHardwareBuffer,
+     "VK_ANDROID_external_memory_android_hardware_buffer", NeverPromoted},
     {DeviceExt::ExternalMemoryFD, "VK_KHR_external_memory_fd", NeverPromoted},
     {DeviceExt::ExternalMemoryDmaBuf, "VK_EXT_external_memory_dma_buf", NeverPromoted},
     {DeviceExt::ExternalMemoryZirconHandle, "VK_FUCHSIA_external_memory", NeverPromoted},
     {DeviceExt::ExternalSemaphoreFD, "VK_KHR_external_semaphore_fd", NeverPromoted},
     {DeviceExt::ExternalSemaphoreZirconHandle, "VK_FUCHSIA_external_semaphore", NeverPromoted},
-
-    {DeviceExt::DepthClipEnable, "VK_EXT_depth_clip_enable", NeverPromoted},
-    {DeviceExt::ImageDrmFormatModifier, "VK_EXT_image_drm_format_modifier", NeverPromoted},
-    {DeviceExt::Swapchain, "VK_KHR_swapchain", NeverPromoted},
-    {DeviceExt::SubgroupSizeControl, "VK_EXT_subgroup_size_control", NeverPromoted},
     //
 }};
 
@@ -211,6 +215,10 @@
                 hasDependencies = true;
                 break;
 
+            case DeviceExt::DedicatedAllocation:
+                hasDependencies = HasDep(DeviceExt::GetMemoryRequirements2);
+                break;
+
             // Physical device extensions technically don't require the instance to support
             // them but VulkanFunctions only loads the function pointers if the instance
             // advertises the extension. So if we didn't have this check, we'd risk a calling
@@ -258,8 +266,16 @@
                 hasDependencies = HasDep(DeviceExt::ExternalSemaphoreCapabilities);
                 break;
 
+            case DeviceExt::ExternalMemoryAndroidHardwareBuffer:
+                hasDependencies = HasDep(DeviceExt::ExternalMemory) &&
+                                  HasDep(DeviceExt::SamplerYCbCrConversion) &&
+                                  HasDep(DeviceExt::DedicatedAllocation) &&
+                                  HasDep(DeviceExt::QueueFamilyForeign);
+                break;
+
             case DeviceExt::ExternalMemoryFD:
             case DeviceExt::ExternalMemoryZirconHandle:
+            case DeviceExt::QueueFamilyForeign:
                 hasDependencies = HasDep(DeviceExt::ExternalMemory);
                 break;
 
diff --git a/src/dawn/native/vulkan/VulkanExtensions.h b/src/dawn/native/vulkan/VulkanExtensions.h
index eb6ef49..77cade8 100644
--- a/src/dawn/native/vulkan/VulkanExtensions.h
+++ b/src/dawn/native/vulkan/VulkanExtensions.h
@@ -79,6 +79,7 @@
     StorageBufferStorageClass,
     GetPhysicalDeviceProperties2,
     GetMemoryRequirements2,
+    DedicatedAllocation,
     ExternalMemoryCapabilities,
     ExternalSemaphoreCapabilities,
     ExternalMemory,
@@ -95,18 +96,20 @@
     ShaderIntegerDotProduct,
     ZeroInitializeWorkgroupMemory,
 
-    // External* extensions
-    ExternalMemoryFD,
-    ExternalMemoryDmaBuf,
-    ExternalMemoryZirconHandle,
-    ExternalSemaphoreFD,
-    ExternalSemaphoreZirconHandle,
-
     // Others
     DepthClipEnable,
     ImageDrmFormatModifier,
     Swapchain,
     SubgroupSizeControl,
+    QueueFamilyForeign,
+
+    // External* extensions
+    ExternalMemoryAndroidHardwareBuffer,
+    ExternalMemoryFD,
+    ExternalMemoryDmaBuf,
+    ExternalMemoryZirconHandle,
+    ExternalSemaphoreFD,
+    ExternalSemaphoreZirconHandle,
 
     EnumCount,
 };