diff --git a/RAII_Samples/05_InitSwapchain/05_InitSwapchain.cpp b/RAII_Samples/05_InitSwapchain/05_InitSwapchain.cpp index 98ed47dbe..ac225e1bd 100644 --- a/RAII_Samples/05_InitSwapchain/05_InitSwapchain.cpp +++ b/RAII_Samples/05_InitSwapchain/05_InitSwapchain.cpp @@ -120,7 +120,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::SwapchainCreateInfoKHR swapChainCreateInfo( vk::SwapchainCreateFlagsKHR(), surface, - vk::su::clamp( 3u, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount ), + vk::su::clampSurfaceImageCount( 3u, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount ), format, vk::ColorSpaceKHR::eSrgbNonlinear, swapchainExtent, diff --git a/samples/05_InitSwapchain/05_InitSwapchain.cpp b/samples/05_InitSwapchain/05_InitSwapchain.cpp index d0b85603d..1c5479aa9 100644 --- a/samples/05_InitSwapchain/05_InitSwapchain.cpp +++ b/samples/05_InitSwapchain/05_InitSwapchain.cpp @@ -123,7 +123,7 @@ int main( int /*argc*/, char ** /*argv*/ ) vk::SwapchainCreateInfoKHR swapChainCreateInfo( vk::SwapchainCreateFlagsKHR(), surface, - vk::su::clamp( 3u, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount ), + vk::su::clampSurfaceImageCount( 3u, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount ), format, vk::ColorSpaceKHR::eSrgbNonlinear, swapchainExtent, diff --git a/samples/utils/utils.cpp b/samples/utils/utils.cpp index 64eb1bc53..ff56e862a 100644 --- a/samples/utils/utils.cpp +++ b/samples/utils/utils.cpp @@ -826,7 +826,7 @@ namespace vk vk::PresentModeKHR presentMode = vk::su::pickPresentMode( physicalDevice.getSurfacePresentModesKHR( surface ) ); vk::SwapchainCreateInfoKHR swapChainCreateInfo( {}, surface, - vk::su::clamp( 3u, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount ), + vk::su::clampSurfaceImageCount( 3u, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount ), colorFormat, surfaceFormat.colorSpace, swapchainExtent, diff --git a/samples/utils/utils.hpp b/samples/utils/utils.hpp index 5a88a0ee3..8d170293e 100644 --- a/samples/utils/utils.hpp +++ b/samples/utils/utils.hpp @@ -74,6 +74,16 @@ namespace vk return v < lo ? lo : hi < v ? hi : v; } + VULKAN_HPP_INLINE uint32_t clampSurfaceImageCount( const uint32_t desiredImageCount, const uint32_t minImageCount, const uint32_t maxImageCount ) + { + uint32_t imageCount = std::max( desiredImageCount, minImageCount ); + if( maxImageCount > 0 ) + { + imageCount = std::min( imageCount, maxImageCount ); + } + return imageCount; + } + void setImageLayout( vk::CommandBuffer const & commandBuffer, vk::Image image, vk::Format format, vk::ImageLayout oldImageLayout, vk::ImageLayout newImageLayout ); diff --git a/tests/UniqueHandle/UniqueHandle.cpp b/tests/UniqueHandle/UniqueHandle.cpp index e90202784..bd4501fc0 100644 --- a/tests/UniqueHandle/UniqueHandle.cpp +++ b/tests/UniqueHandle/UniqueHandle.cpp @@ -195,7 +195,7 @@ vk::UniqueSwapchainKHR createSwapchainKHRUnique( vk::PhysicalDevice physicalDevi : vk::CompositeAlphaFlagBitsKHR::eOpaque; vk::SwapchainCreateInfoKHR swapChainCreateInfo( {}, surface, - vk::su::clamp( 3u, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount ), + vk::su::clampSurfaceImageCount( 3u, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount ), surfaceFormat.format, surfaceFormat.colorSpace, swapchainExtent,