More Fuchsia build fixes

Change-Id: If8e952f8895ce4110983bffc0875157bff0b36a1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/185480
Auto-Submit: Austin Eng <enga@chromium.org>
Reviewed-by: Shrek Shao <shrekshao@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
diff --git a/include/dawn/native/VulkanBackend.h b/include/dawn/native/VulkanBackend.h
index bc644ec..d5f31b4 100644
--- a/include/dawn/native/VulkanBackend.h
+++ b/include/dawn/native/VulkanBackend.h
@@ -90,7 +90,7 @@
 };
 
 // Can't use DAWN_PLATFORM_IS(LINUX) since header included in both Dawn and Chrome
-#ifdef __linux__
+#if defined(__linux__) || defined(__Fuchsia__)
 
 // Common properties of external images represented by FDs. On successful import the file
 // descriptor's ownership is transferred to the Dawn implementation and they shouldn't be
@@ -166,7 +166,7 @@
 
 #endif  // __ANDROID__
 
-#endif  // __linux__
+#endif  // defined(__linux__) || defined(__Fuchsia__)
 
 // Imports external memory into a Vulkan image. Internally, this uses external memory /
 // semaphore extensions to import the image and wait on the provided synchronizaton
diff --git a/src/dawn/native/WaitAnySystemEvent.h b/src/dawn/native/WaitAnySystemEvent.h
index 8deb5d2..9cc2aa4 100644
--- a/src/dawn/native/WaitAnySystemEvent.h
+++ b/src/dawn/native/WaitAnySystemEvent.h
@@ -98,7 +98,7 @@
     StackVector<pollfd, 4 /* avoid heap allocation for small waits */> pollfds;
     pollfds->reserve(count);
     for (auto it = begin; it != end; ++it) {
-        pollfds->push_back(pollfd{(*it).first.mPrimitive.Get(), POLLIN, 0});
+        pollfds->push_back(pollfd{static_cast<int>((*it).first.mPrimitive.Get()), POLLIN, 0});
     }
     int status = poll(pollfds->data(), pollfds->size(), ToMilliseconds(timeout));
 
diff --git a/src/dawn/native/vulkan/BackendVk.cpp b/src/dawn/native/vulkan/BackendVk.cpp
index 001a988..3f8e885 100644
--- a/src/dawn/native/vulkan/BackendVk.cpp
+++ b/src/dawn/native/vulkan/BackendVk.cpp
@@ -44,7 +44,7 @@
 
 // TODO(crbug.com/dawn/283): Link against the Vulkan Loader and remove this.
 #if defined(DAWN_ENABLE_SWIFTSHADER)
-#if DAWN_PLATFORM_IS(LINUX) || DAWN_PLATFORM_IS(FUSCHIA)
+#if DAWN_PLATFORM_IS(LINUX) || DAWN_PLATFORM_IS(FUCHSIA)
 constexpr char kSwiftshaderLibName[] = "libvk_swiftshader.so";
 #elif DAWN_PLATFORM_IS(WINDOWS)
 constexpr char kSwiftshaderLibName[] = "vk_swiftshader.dll";
diff --git a/src/dawn/native/vulkan/SharedFenceVk.cpp b/src/dawn/native/vulkan/SharedFenceVk.cpp
index 93225fa..881c5eb 100644
--- a/src/dawn/native/vulkan/SharedFenceVk.cpp
+++ b/src/dawn/native/vulkan/SharedFenceVk.cpp
@@ -94,7 +94,7 @@
     DAWN_TRY(info.ValidateSubset<SharedFenceVkSemaphoreZirconHandleExportInfo>());
     auto* exportInfo = info.Get<SharedFenceVkSemaphoreZirconHandleExportInfo>();
     if (exportInfo != nullptr) {
-        exportInfo->handle = mHandle;
+        exportInfo->handle = mHandle.Get();
     }
 #elif DAWN_PLATFORM_IS(LINUX)
     switch (mType) {
diff --git a/src/dawn/native/vulkan/external_memory/MemoryServiceImplementationZirconHandle.cpp b/src/dawn/native/vulkan/external_memory/MemoryServiceImplementationZirconHandle.cpp
index 567ca26..e96ce76 100644
--- a/src/dawn/native/vulkan/external_memory/MemoryServiceImplementationZirconHandle.cpp
+++ b/src/dawn/native/vulkan/external_memory/MemoryServiceImplementationZirconHandle.cpp
@@ -79,9 +79,9 @@
         formatProperties.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR;
         formatProperties.pNext = &externalFormatProperties;
 
-        VkResult result = mDevice->fn.GetPhysicalDeviceImageFormatProperties2(
+        VkResult result = VkResult::WrapUnsafe(mDevice->fn.GetPhysicalDeviceImageFormatProperties2(
             ToBackend(mDevice->GetPhysicalDevice())->GetVkPhysicalDevice(), &formatInfo,
-            &formatProperties);
+            &formatProperties));
 
         // If handle not supported, result == VK_ERROR_FORMAT_NOT_SUPPORTED
         if (result != VK_SUCCESS) {
@@ -105,7 +105,7 @@
     ResultOrError<MemoryImportParams> GetMemoryImportParams(
         const ExternalImageDescriptor* descriptor,
         VkImage image) override {
-        DAWN_INVALID_IF(descriptor->type != ExternalImageType::OpaqueFD,
+        DAWN_INVALID_IF(descriptor->GetType() != ExternalImageType::OpaqueFD,
                         "ExternalImageDescriptor is not an OpaqueFD descriptor.");
 
         const ExternalImageDescriptorOpaqueFD* opaqueFDDescriptor =
diff --git a/src/dawn/native/vulkan/external_semaphore/SemaphoreServiceImplementationZirconHandle.cpp b/src/dawn/native/vulkan/external_semaphore/SemaphoreServiceImplementationZirconHandle.cpp
index 2bf1e04..7dcd21c 100644
--- a/src/dawn/native/vulkan/external_semaphore/SemaphoreServiceImplementationZirconHandle.cpp
+++ b/src/dawn/native/vulkan/external_semaphore/SemaphoreServiceImplementationZirconHandle.cpp
@@ -25,6 +25,7 @@
 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+#include <zircon/syscalls.h>
 #include <utility>
 
 #include "dawn/native/SystemHandle.h"
@@ -49,9 +50,7 @@
 
     static bool CheckSupport(const VulkanDeviceInfo& deviceInfo,
                              VkPhysicalDevice vkPhysicalDevice,
-                             const VulkanFunctions& fn);
-
-    static void CloseHandle(ExternalSemaphoreHandle handle) {
+                             const VulkanFunctions& fn) {
         if (!deviceInfo.HasExt(DeviceExt::ExternalSemaphoreZirconHandle)) {
             return false;
         }
@@ -109,7 +108,7 @@
             VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_ZIRCON_EVENT_BIT_FUCHSIA;
         SystemHandle handleCopy;
         DAWN_TRY_ASSIGN(handleCopy, SystemHandle::Duplicate(handle));
-        importSemaphoreHandleInfo.handle = handleCopy.Get();
+        importSemaphoreHandleInfo.zirconHandle = handleCopy.Get();
 
         MaybeError status = CheckVkSuccess(mDevice->fn.ImportSemaphoreZirconHandleFUCHSIA(
                                                mDevice->GetVkDevice(), &importSemaphoreHandleInfo),
@@ -171,7 +170,7 @@
         return out_handle;
     }
 
-    void ServiceImplementationZirconHandle::CloseHandle(ExternalSemaphoreHandle handle) override {
+    void CloseHandle(ExternalSemaphoreHandle handle) override {
         zx_status_t status = zx_handle_close(handle);
         DAWN_ASSERT(status == ZX_OK);
     }
@@ -181,7 +180,7 @@
 };
 
 std::unique_ptr<ServiceImplementation> CreateZirconHandleService(Device* device) {
-    return td::make_unique<ServiceImplementationZirconHandle>(device);
+    return std::make_unique<ServiceImplementationZirconHandle>(device);
 }
 bool CheckZirconHandleSupport(const VulkanDeviceInfo& deviceInfo,
                               VkPhysicalDevice vkPhysicalDevice,