From c073adaa767a0bd8902e0e259572682c91e41eda Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Tue, 17 Dec 2019 17:39:31 +0000 Subject: [PATCH] Fix compilation of VkResult changes on MSVC and ChromeOS Bug: dawn:295 Change-Id: I8156af4789fca155163e8beed57805eefe6ec686 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14640 Reviewed-by: Austin Eng Commit-Queue: Corentin Wallez --- src/dawn_native/vulkan/VulkanError.cpp | 8 ++++++-- src/dawn_native/vulkan/VulkanError.h | 2 +- .../vulkan/external_memory/MemoryServiceDmaBuf.cpp | 5 +++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/dawn_native/vulkan/VulkanError.cpp b/src/dawn_native/vulkan/VulkanError.cpp index 76f4a9a977..af235f1f27 100644 --- a/src/dawn_native/vulkan/VulkanError.cpp +++ b/src/dawn_native/vulkan/VulkanError.cpp @@ -18,8 +18,12 @@ namespace dawn_native { namespace vulkan { - const char* VkResultAsString(VkResult result) { - switch (result) { + const char* VkResultAsString(::VkResult result) { + // Convert to a uint32_t to silence and MSVC warning that the fake errors don't appear in + // the original VkResult enum. + uint32_t code = static_cast(result); + + switch (code) { case VK_SUCCESS: return "VK_SUCCESS"; case VK_NOT_READY: diff --git a/src/dawn_native/vulkan/VulkanError.h b/src/dawn_native/vulkan/VulkanError.h index c4ae5e7acf..7748f56cd3 100644 --- a/src/dawn_native/vulkan/VulkanError.h +++ b/src/dawn_native/vulkan/VulkanError.h @@ -24,7 +24,7 @@ constexpr VkResult VK_FAKE_DEVICE_OOM_FOR_TESTING = static_cast(VK_RES namespace dawn_native { namespace vulkan { // Returns a string version of the result. - const char* VkResultAsString(VkResult result); + const char* VkResultAsString(::VkResult result); MaybeError CheckVkSuccessImpl(VkResult result, const char* context); MaybeError CheckVkOOMThenSuccessImpl(VkResult result, const char* context); diff --git a/src/dawn_native/vulkan/external_memory/MemoryServiceDmaBuf.cpp b/src/dawn_native/vulkan/external_memory/MemoryServiceDmaBuf.cpp index e9944f8a4a..440852d538 100644 --- a/src/dawn_native/vulkan/external_memory/MemoryServiceDmaBuf.cpp +++ b/src/dawn_native/vulkan/external_memory/MemoryServiceDmaBuf.cpp @@ -141,8 +141,9 @@ namespace dawn_native { namespace vulkan { namespace external_memory { imageFormatProps.sType = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2; imageFormatProps.pNext = &externalImageFormatProps; - VkResult result = mDevice->fn.GetPhysicalDeviceImageFormatProperties2KHR( - physicalDevice, &imageFormatInfo, &imageFormatProps); + VkResult result = + WkResult::WrapUnsafe(mDevice->fn.GetPhysicalDeviceImageFormatProperties2KHR( + physicalDevice, &imageFormatInfo, &imageFormatProps)); if (result != VK_SUCCESS) { return false; }