[vulkan] Add unwrap hook for QueueSubmit and semaphore resource tracking

Change-Id: I491e3c226186968bf6b692e513d9ea5c1052b609
diff --git a/system/vulkan_enc/ResourceTracker.cpp b/system/vulkan_enc/ResourceTracker.cpp
index 17bb4fc..8f16f8a 100644
--- a/system/vulkan_enc/ResourceTracker.cpp
+++ b/system/vulkan_enc/ResourceTracker.cpp
@@ -1209,6 +1209,23 @@
             device, bindInfoCount, pBindInfos);
     }
 
+    VkResult on_vkCreateSemaphore(
+        void* context, VkResult,
+        VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo,
+        const VkAllocationCallbacks* pAllocator,
+        VkSemaphore* pSemaphore) {
+        VkEncoder* enc = (VkEncoder*)context;
+        return enc->vkCreateSemaphore(
+            device, pCreateInfo, pAllocator, pSemaphore);
+    }
+
+    void on_vkDestroySemaphore(
+        void* context,
+        VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks *pAllocator) {
+        VkEncoder* enc = (VkEncoder*)context;
+        enc->vkDestroySemaphore(device, semaphore, pAllocator);
+    }
+
     void unwrap_VkNativeBufferANDROID(
         const VkImageCreateInfo* pCreateInfo,
         VkImageCreateInfo* local_pCreateInfo) {
@@ -1246,6 +1263,9 @@
         }
     }
 
+    void unwrap_vkQueueSubmit(uint32_t, const VkSubmitInfo*, VkSubmitInfo*) {
+    }
+
     // Action of vkMapMemoryIntoAddressSpaceGOOGLE:
     // 1. preprocess (on_vkMapMemoryIntoAddressSpaceGOOGLE_pre):
     //    uses address space device to reserve the right size of
@@ -1709,6 +1729,22 @@
         device, bindInfoCount, pBindInfos);
 }
 
+VkResult ResourceTracker::on_vkCreateSemaphore(
+    void* context, VkResult input_result,
+    VkDevice device, const VkSemaphoreCreateInfo *pCreateInfo,
+    const VkAllocationCallbacks *pAllocator,
+    VkSemaphore *pSemaphore) {
+    return mImpl->on_vkCreateSemaphore(
+        context, input_result,
+        device, pCreateInfo, pAllocator, pSemaphore);
+}
+
+void ResourceTracker::on_vkDestroySemaphore(
+    void* context,
+    VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks *pAllocator) {
+    mImpl->on_vkDestroySemaphore(context, device, semaphore, pAllocator);
+}
+
 void ResourceTracker::unwrap_VkNativeBufferANDROID(
     const VkImageCreateInfo* pCreateInfo,
     VkImageCreateInfo* local_pCreateInfo) {
@@ -1719,6 +1755,11 @@
     mImpl->unwrap_vkAcquireImageANDROID_nativeFenceFd(fd, fd_out);
 }
 
+void ResourceTracker::unwrap_vkQueueSubmit(
+    uint32_t submitCount, const VkSubmitInfo* pSubmits, VkSubmitInfo* local_pSubmits) {
+    mImpl->unwrap_vkQueueSubmit(submitCount, pSubmits, local_pSubmits);
+}
+
 VkResult ResourceTracker::on_vkMapMemoryIntoAddressSpaceGOOGLE_pre(
     void* context,
     VkResult input_result,
diff --git a/system/vulkan_enc/ResourceTracker.h b/system/vulkan_enc/ResourceTracker.h
index 2358ffe..19e6d56 100644
--- a/system/vulkan_enc/ResourceTracker.h
+++ b/system/vulkan_enc/ResourceTracker.h
@@ -184,11 +184,23 @@
         void* context, VkResult input_result,
         VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo *pBindInfos);
 
+  VkResult on_vkCreateSemaphore(
+        void* context, VkResult,
+        VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo,
+        const VkAllocationCallbacks* pAllocator,
+        VkSemaphore* pSemaphore);
+    void on_vkDestroySemaphore(
+        void* context,
+        VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks *pAllocator);
+
     void unwrap_VkNativeBufferANDROID(
         const VkImageCreateInfo* pCreateInfo,
         VkImageCreateInfo* local_pCreateInfo);
     void unwrap_vkAcquireImageANDROID_nativeFenceFd(int fd, int* fd_out);
 
+    void unwrap_vkQueueSubmit(
+        uint32_t submitCount, const VkSubmitInfo* pSubmits, VkSubmitInfo* local_pSubmits);
+
     VkResult on_vkMapMemoryIntoAddressSpaceGOOGLE_pre(
         void* context,
         VkResult input_result,
diff --git a/system/vulkan_enc/VkEncoder.cpp b/system/vulkan_enc/VkEncoder.cpp
index 210459c..eaeb08f 100644
--- a/system/vulkan_enc/VkEncoder.cpp
+++ b/system/vulkan_enc/VkEncoder.cpp
@@ -1373,6 +1373,7 @@
         }
     }
     local_fence = fence;
+    mImpl->resources()->unwrap_vkQueueSubmit(submitCount, pSubmits, local_pSubmits);
     if (local_pSubmits)
     {
         for (uint32_t i = 0; i < (uint32_t)((submitCount)); ++i)