[Impeller] Handle cases where the max swapchain image count can be zero. (flutter/engine#40776)

[Impeller] Handle cases where the max swapchain image count can be zero.
This commit is contained in:
Chinmay Garde
2023-03-30 00:13:10 -07:00
committed by GitHub
parent 51238bc477
commit d48b1b596f

View File

@@ -188,7 +188,11 @@ SwapchainImplVK::SwapchainImplVK(const std::shared_ptr<Context>& context,
caps.maxImageExtent.height),
};
swapchain_info.minImageCount = std::clamp(
caps.minImageCount + 1u, caps.minImageCount, caps.maxImageCount);
caps.minImageCount + 1u, // preferred image count
caps.minImageCount, // min count cannot be zero
caps.maxImageCount == 0u ? caps.minImageCount + 1u
: caps.maxImageCount // max zero means no limit
);
swapchain_info.imageArrayLayers = 1u;
swapchain_info.imageUsage = vk::ImageUsageFlagBits::eColorAttachment;
swapchain_info.preTransform = caps.currentTransform;