Commit eb47e2c4 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: improve calculation of swapchain image count

Based on present mode, different values for the image count make sense. In mailbox mode, the driver will increase the number as necessary. In immediate mode, two buffers suffice. In fifo mode, we would ideally want triple-buffering. Bug: angleproject:2932 Change-Id: I45eec83d0292eea472b931fe81e49cde6d105c27 Reviewed-on: https://chromium-review.googlesource.com/c/1454290Reviewed-by: 's avatarIan Elliott <ianelliott@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent bf5dbd8d
......@@ -392,8 +392,26 @@ angle::Result WindowSurfaceVk::initializeImpl(DisplayVk *displayVk)
mSwapchainPresentMode = GetDesiredPresentMode(presentModes, minSwapInterval, maxSwapInterval);
// Determine number of swapchain images. Aim for one more than the minimum.
uint32_t minImageCount = surfaceCaps.minImageCount + 1;
// Determine the number of swapchain images:
//
// - On mailbox, we use minImageCount. The drivers may increase the number so that non-blocking
// mailbox actually makes sense.
// - On immediate, we use max(2, minImageCount). The vkQueuePresentKHR call immediately frees
// up the other image, so there is no point in having any more images.
// - On fifo, we use max(3, minImageCount). Triple-buffering allows us to present an image,
// have one in the queue and record in another. Note: on certain configurations (windows +
// nvidia + windowed mode), we could get away with a smaller number.
uint32_t minImageCount = surfaceCaps.minImageCount;
if (mSwapchainPresentMode == VK_PRESENT_MODE_IMMEDIATE_KHR)
{
minImageCount = std::max<uint32_t>(2, minImageCount);
}
else if (mSwapchainPresentMode == VK_PRESENT_MODE_FIFO_KHR)
{
minImageCount = std::max<uint32_t>(3, minImageCount);
}
// Make sure we don't exceed maxImageCount.
if (surfaceCaps.maxImageCount > 0 && minImageCount > surfaceCaps.maxImageCount)
{
minImageCount = surfaceCaps.maxImageCount;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment