vulkan: always tear down host visible memory blocks properly (guest)

Test: Chrome Fuchsia cc_unittests don't flake
Change-Id: I2e736dfb3d940b604970a4e62b5447a34734dea3
diff --git a/system/vulkan/func_table.cpp b/system/vulkan/func_table.cpp
index 3f77e85..721e7c5 100644
--- a/system/vulkan/func_table.cpp
+++ b/system/vulkan/func_table.cpp
@@ -5256,6 +5256,35 @@
     return vkGetMemoryHostAddressInfoGOOGLE_VkResult_return;
 }
 #endif
+#ifdef VK_GOOGLE_free_memory_sync
+static VkResult entry_vkFreeMemorySyncGOOGLE(
+    VkDevice device,
+    VkDeviceMemory memory,
+    const VkAllocationCallbacks* pAllocator)
+{
+    AEMU_SCOPED_TRACE("vkFreeMemorySyncGOOGLE");
+    auto vkEnc = HostConnection::get()->vkEncoder();
+    VkResult vkFreeMemorySyncGOOGLE_VkResult_return = (VkResult)0;
+    vkFreeMemorySyncGOOGLE_VkResult_return = vkEnc->vkFreeMemorySyncGOOGLE(device, memory, pAllocator);
+    return vkFreeMemorySyncGOOGLE_VkResult_return;
+}
+static VkResult dynCheck_entry_vkFreeMemorySyncGOOGLE(
+    VkDevice device,
+    VkDeviceMemory memory,
+    const VkAllocationCallbacks* pAllocator)
+{
+    auto resources = ResourceTracker::get();
+    if (!resources->hasDeviceExtension(device, "VK_GOOGLE_free_memory_sync"))
+    {
+        sOnInvalidDynamicallyCheckedCall("vkFreeMemorySyncGOOGLE", "VK_GOOGLE_free_memory_sync");
+    }
+    AEMU_SCOPED_TRACE("vkFreeMemorySyncGOOGLE");
+    auto vkEnc = HostConnection::get()->vkEncoder();
+    VkResult vkFreeMemorySyncGOOGLE_VkResult_return = (VkResult)0;
+    vkFreeMemorySyncGOOGLE_VkResult_return = vkEnc->vkFreeMemorySyncGOOGLE(device, memory, pAllocator);
+    return vkFreeMemorySyncGOOGLE_VkResult_return;
+}
+#endif
 void* goldfish_vulkan_get_proc_address(const char* name){
 #ifdef VK_VERSION_1_0
     if (!strcmp(name, "vkCreateInstance"))
@@ -6707,6 +6736,12 @@
         return nullptr;
     }
 #endif
+#ifdef VK_GOOGLE_free_memory_sync
+    if (!strcmp(name, "vkFreeMemorySyncGOOGLE"))
+    {
+        return nullptr;
+    }
+#endif
     return nullptr;
 }
 void* goldfish_vulkan_get_instance_proc_address(VkInstance instance, const char* name){
@@ -8255,6 +8290,12 @@
         return (void*)dynCheck_entry_vkGetMemoryHostAddressInfoGOOGLE;
     }
 #endif
+#ifdef VK_GOOGLE_free_memory_sync
+    if (!strcmp(name, "vkFreeMemorySyncGOOGLE"))
+    {
+        return (void*)dynCheck_entry_vkFreeMemorySyncGOOGLE;
+    }
+#endif
     return nullptr;
 }
 void* goldfish_vulkan_get_device_proc_address(VkDevice device, const char* name){
@@ -9873,6 +9914,13 @@
         return hasExt ? (void*)entry_vkGetMemoryHostAddressInfoGOOGLE : nullptr;
     }
 #endif
+#ifdef VK_GOOGLE_free_memory_sync
+    if (!strcmp(name, "vkFreeMemorySyncGOOGLE"))
+    {
+        bool hasExt = resources->hasDeviceExtension(device, "VK_GOOGLE_free_memory_sync");
+        return hasExt ? (void*)entry_vkFreeMemorySyncGOOGLE : nullptr;
+    }
+#endif
     return nullptr;
 }