From 4bc9d80d8212e399437b26a5c42c05f9c2f80d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20S=C3=BC=C3=9Fenbach?= Date: Mon, 7 Aug 2023 12:00:11 +0200 Subject: [PATCH] Fix validation layer warning on minImageCount of 2. (#1634) --- RAII_Samples/05_InitSwapchain/05_InitSwapchain.cpp | 2 +- RAII_Samples/utils/utils.hpp | 2 +- samples/05_InitSwapchain/05_InitSwapchain.cpp | 4 ++-- samples/utils/utils.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/RAII_Samples/05_InitSwapchain/05_InitSwapchain.cpp b/RAII_Samples/05_InitSwapchain/05_InitSwapchain.cpp index 3d8ccf2..51e0e3a 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, - surfaceCapabilities.minImageCount, + vk::su::clamp( 3u, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount ), format, vk::ColorSpaceKHR::eSrgbNonlinear, swapchainExtent, diff --git a/RAII_Samples/utils/utils.hpp b/RAII_Samples/utils/utils.hpp index 850252e..490d227 100644 --- a/RAII_Samples/utils/utils.hpp +++ b/RAII_Samples/utils/utils.hpp @@ -367,7 +367,7 @@ namespace vk vk::PresentModeKHR presentMode = vk::su::pickPresentMode( physicalDevice.getSurfacePresentModesKHR( *surface ) ); vk::SwapchainCreateInfoKHR swapChainCreateInfo( {}, *surface, - surfaceCapabilities.minImageCount, + vk::su::clamp( 3u, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount ), colorFormat, surfaceFormat.colorSpace, swapchainExtent, diff --git a/samples/05_InitSwapchain/05_InitSwapchain.cpp b/samples/05_InitSwapchain/05_InitSwapchain.cpp index 9a0abbe..d0b8560 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, - surfaceCapabilities.minImageCount, + vk::su::clamp( 3u, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount ), format, vk::ColorSpaceKHR::eSrgbNonlinear, swapchainExtent, @@ -161,7 +161,7 @@ int main( int /*argc*/, char ** /*argv*/ ) imageViews.push_back( device.createImageView( imageViewCreateInfo ) ); } - // destroy the imageViews, the swapChain,and the surface + // destroy the imageViews, the swapChain, and the surface for ( auto & imageView : imageViews ) { device.destroyImageView( imageView ); diff --git a/samples/utils/utils.cpp b/samples/utils/utils.cpp index 3c39cf0..fb02b32 100644 --- a/samples/utils/utils.cpp +++ b/samples/utils/utils.cpp @@ -833,7 +833,7 @@ namespace vk vk::PresentModeKHR presentMode = vk::su::pickPresentMode( physicalDevice.getSurfacePresentModesKHR( surface ) ); vk::SwapchainCreateInfoKHR swapChainCreateInfo( {}, surface, - surfaceCapabilities.minImageCount, + vk::su::clamp( 3u, surfaceCapabilities.minImageCount, surfaceCapabilities.maxImageCount ), colorFormat, surfaceFormat.colorSpace, swapchainExtent,