From 262ba0a8577d54745efcf33ffece4d05ab9af3f6 Mon Sep 17 00:00:00 2001 From: Odilon Vatonne Date: Wed, 12 Oct 2022 23:13:44 +0200 Subject: [PATCH] Move situational code to lambda at call site and remove unused parameter warning --- src/VkBootstrap.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/VkBootstrap.cpp b/src/VkBootstrap.cpp index 7e94028..a50bcd9 100644 --- a/src/VkBootstrap.cpp +++ b/src/VkBootstrap.cpp @@ -1633,7 +1633,7 @@ Result query_surface_support_details(VkPhysicalDevice phy return SurfaceSupportDetails{ capabilities, formats, present_modes }; } -Result find_desired_surface_format(VkPhysicalDevice phys_device, +Result find_desired_surface_format(VkPhysicalDevice /* phys_device */, std::vector const& available_formats, std::vector const& desired_formats) { for (auto const& desired_format : desired_formats) { @@ -1671,11 +1671,6 @@ VkPresentModeKHR find_present_mode(std::vector const& availabl return VK_PRESENT_MODE_FIFO_KHR; } -bool is_unextended_present_mode(VkPresentModeKHR present_mode) { - return (present_mode == VK_PRESENT_MODE_IMMEDIATE_KHR) || (present_mode == VK_PRESENT_MODE_MAILBOX_KHR) || - (present_mode == VK_PRESENT_MODE_FIFO_KHR) || (present_mode == VK_PRESENT_MODE_FIFO_RELAXED_KHR); -} - template T minimum(T a, T b) { return a < b ? a : b; } template T maximum(T a, T b) { return a > b ? a : b; } @@ -1795,7 +1790,12 @@ Result SwapchainBuilder::build() const { VkPresentModeKHR present_mode = detail::find_present_mode(surface_support.present_modes, desired_present_modes); // VkSurfaceCapabilitiesKHR::supportedUsageFlags is only only valid for some present modes. For shared present modes, we should also check VkSharedPresentSurfaceCapabilitiesKHR::sharedPresentSupportedUsageFlags. - if (detail::is_unextended_present_mode(present_mode) && + auto is_unextended_present_mode = [](VkPresentModeKHR present_mode) { + return (present_mode == VK_PRESENT_MODE_IMMEDIATE_KHR) || (present_mode == VK_PRESENT_MODE_MAILBOX_KHR) || + (present_mode == VK_PRESENT_MODE_FIFO_KHR) || (present_mode == VK_PRESENT_MODE_FIFO_RELAXED_KHR); + }; + + if (is_unextended_present_mode(present_mode) && (info.image_usage_flags & surface_support.capabilities.supportedUsageFlags) != info.image_usage_flags) { return Error{ SwapchainError::required_usage_not_supported }; }