Declare AHB blob unsupported in Vulkan

It diverged between old gralloc and minigbm.

Test: dEQP-VK.api.external.memory.android_hardware_buffer.*
Bug: 299520213
Merged-In: If0c1896c6acef97db9ec3ae3abfe88eea333b42f
Change-Id: I029cfb0765b0265409c71d4a6732275b385a4901
diff --git a/guest/vulkan_enc/ResourceTracker.cpp b/guest/vulkan_enc/ResourceTracker.cpp
index 202090a..b2affa9 100644
--- a/guest/vulkan_enc/ResourceTracker.cpp
+++ b/guest/vulkan_enc/ResourceTracker.cpp
@@ -3444,7 +3444,8 @@
             ResourceTracker::threadingCallbacks.hostConnectionGetFunc()->grallocHelper();
 
         const uint32_t hostHandle = gralloc->getHostHandle(ahw);
-        if (gralloc->getFormat(ahw) == AHARDWAREBUFFER_FORMAT_BLOB) {
+        if (gralloc->getFormat(ahw) == AHARDWAREBUFFER_FORMAT_BLOB &&
+            !gralloc->treatBlobAsImage()) {
             importBufferInfo.buffer = hostHandle;
             vk_append_struct(&structChainIter, &importBufferInfo);
         } else {
@@ -6496,6 +6497,19 @@
     VkExternalBufferProperties* pExternalBufferProperties) {
     VkEncoder* enc = (VkEncoder*)context;
 
+    // Older versions of Goldfish's Gralloc did not support allocating AHARDWAREBUFFER_FORMAT_BLOB
+    // with GPU usage (b/299520213).
+    if (ResourceTracker::threadingCallbacks.hostConnectionGetFunc()
+            ->grallocHelper()
+            ->treatBlobAsImage() &&
+        pExternalBufferInfo->handleType ==
+            VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID) {
+        pExternalBufferProperties->externalMemoryProperties.externalMemoryFeatures = 0;
+        pExternalBufferProperties->externalMemoryProperties.exportFromImportedHandleTypes = 0;
+        pExternalBufferProperties->externalMemoryProperties.compatibleHandleTypes = 0;
+        return;
+    }
+
     uint32_t supportedHandleType = 0;
 #ifdef VK_USE_PLATFORM_FUCHSIA
     supportedHandleType |= VK_EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VMO_BIT_FUCHSIA;