Fix validation layer warning on minImageCount of 2. (#1634)
authorAndreas Süßenbach <asuessenbach@nvidia.com>
Mon, 7 Aug 2023 10:00:11 +0000 (12:00 +0200)
committerGitHub <noreply@github.com>
Mon, 7 Aug 2023 10:00:11 +0000 (12:00 +0200)
RAII_Samples/05_InitSwapchain/05_InitSwapchain.cpp
RAII_Samples/utils/utils.hpp
samples/05_InitSwapchain/05_InitSwapchain.cpp
samples/utils/utils.cpp

index 3d8ccf2..51e0e3a 100644 (file)
@@ -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,
index 850252e..490d227 100644 (file)
@@ -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,
index 9a0abbe..d0b8560 100644 (file)
@@ -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 );
index 3c39cf0..fb02b32 100644 (file)
@@ -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,