state: Support VkSemaphores imported with Zircon handles

This adds support for vkImportSemaphoreZirconHandleFUCHSIA()
and vkGetSemaphoreZirconHandleFUCHSIA() to state_tracker.
The logic is similar to fd and win32 handles.

Bug: https://fxbug.dev/379153784
Test: Fuchsia image-pipe-swapchain-test [1] passed with Vulkan-
ValidationLayers vulkan-sdk-1.4.304.1 patched with this change.

[1] https://cs.opensource.google/fuchsia/fuchsia/+/main:src/lib/vulkan/tests/test_swapchain.cc

Change-Id: I228ef5131e3c84f9d8e3d81ceaeb8e4f209fbed8
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/Vulkan-ValidationLayers/+/1207904
Reviewed-by: Craig Stout <cstout@google.com>
diff --git a/layers/state_tracker/state_tracker.cpp b/layers/state_tracker/state_tracker.cpp
index 2ca1758..5b6af8a 100644
--- a/layers/state_tracker/state_tracker.cpp
+++ b/layers/state_tracker/state_tracker.cpp
@@ -3825,6 +3825,25 @@
 }
 #endif
 
+#ifdef VK_USE_PLATFORM_FUCHSIA
+void ValidationStateTracker::PostCallRecordImportSemaphoreZirconHandleFUCHSIA(
+    VkDevice device, const VkImportSemaphoreZirconHandleInfoFUCHSIA *pImportSemaphoreZirconHandleInfo,
+    const RecordObject &record_obj) {
+    if (VK_SUCCESS != record_obj.result) return;
+    RecordImportSemaphoreState(pImportSemaphoreZirconHandleInfo->semaphore, pImportSemaphoreZirconHandleInfo->handleType,
+                               pImportSemaphoreZirconHandleInfo->flags);
+}
+
+void ValidationStateTracker::PostCallRecordGetSemaphoreZirconHandleFUCHSIA(
+    VkDevice device, const VkSemaphoreGetZirconHandleInfoFUCHSIA *pGetZirconHandleInfo, zx_handle_t *pZirconHandle,
+    const RecordObject &record_obj) {
+    if (VK_SUCCESS != record_obj.result) return;
+    if (auto semaphore_state = Get<vvl::Semaphore>(pGetZirconHandleInfo->semaphore)) {
+        RecordGetExternalSemaphoreState(*semaphore_state, pGetZirconHandleInfo->handleType);
+    }
+}
+#endif  // VK_USE_PLATFORM_FUCHSIA
+
 void ValidationStateTracker::PostCallRecordGetSemaphoreFdKHR(VkDevice device, const VkSemaphoreGetFdInfoKHR *pGetFdInfo, int *pFd,
                                                              const RecordObject &record_obj) {
     if (VK_SUCCESS != record_obj.result) return;
diff --git a/layers/state_tracker/state_tracker.h b/layers/state_tracker/state_tracker.h
index 4fa2d1f..68cf05b 100644
--- a/layers/state_tracker/state_tracker.h
+++ b/layers/state_tracker/state_tracker.h
@@ -524,6 +524,11 @@
     void PostCallRecordGetSemaphoreWin32HandleKHR(VkDevice device, const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo,
                                                   HANDLE* pHandle, const RecordObject& record_obj) override;
 #endif  // VK_USE_PLATFORM_WIN32_KHR
+#ifdef VK_USE_PLATFORM_FUCHSIA
+    void PostCallRecordGetSemaphoreZirconHandleFUCHSIA(VkDevice device,
+                                                       const VkSemaphoreGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo,
+                                                       zx_handle_t* pZirconHandle, const RecordObject& record_obj) override;
+#endif  // VK_USE_PLATFORM_FUCHSIA
 #ifdef VK_USE_PLATFORM_WIN32_KHR
     void PostCallRecordGetMemoryWin32HandleKHR(VkDevice device, const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo,
                                                HANDLE* pHandle, const RecordObject& record_obj) override;
@@ -544,6 +549,11 @@
                                                      const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo,
                                                      const RecordObject& record_obj) override;
 #endif  // VK_USE_PLATFORM_WIN32_KHR
+#ifdef VK_USE_PLATFORM_FUCHSIA
+    void PostCallRecordImportSemaphoreZirconHandleFUCHSIA(
+        VkDevice device, const VkImportSemaphoreZirconHandleInfoFUCHSIA* pImportSemaphoreZirconHandleInfo,
+        const RecordObject& record_obj) override;
+#endif  // VK_USE_PLATFORM_FUCHSIA
     void PreCallRecordSignalSemaphoreKHR(VkDevice device, const VkSemaphoreSignalInfo* pSignalInfo,
                                          const RecordObject& record_obj) override;
     void PreCallRecordSignalSemaphore(VkDevice device, const VkSemaphoreSignalInfo* pSignalInfo,