Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Validation Error From Zero MaxImageCount in VkSurfaceCapabilitiesKHR #1844

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RAII_Samples/05_InitSwapchain/05_InitSwapchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion samples/05_InitSwapchain/05_InitSwapchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion samples/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions samples/utils/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion tests/UniqueHandle/UniqueHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading