summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ian Elliott <ianelliott@google.com> 2019-05-15 14:11:33 -0600
committer Ian Elliott <ianelliott@google.com> 2019-05-16 20:01:21 -0600
commita3515f424c76d0cb1b82968d90bb58f3cc2a3b3d (patch)
tree4b5579b9450d526f284338135337c23858c91bde
parent14eda77e753dd27a923e8778c9a4efd9d1217127 (diff)
Vulkan: Ensure swapchain gets enough images for MAILBOX.
The Vulkan specification for MAILBOX allows for a swapchain to be created with 3 images, assuming 1 "current image": one image is displayed, and the app can ping-pong between the other 2. MAILBOX mode is the equivalent of eglSwapInterval(0). The platform swapchain code always added min_undequeued_buffers-1 (i.e. normally 1) to what the app requested for MAILBOX. Apps often request the advertised minimum of 2. However, a SF and HWC change, some time ago, resulted in HWC displaying 1 image, SF latching another image, and the app blocked ~30% of the time. This equates to a "current image" count of 2, breaking MAILBOX with 3 images. Nobody noticed this until ANGLE discovered that the glmark2 composite score decreased when it only asked for minimum (2) images (per the spec). Analysis determined that 4 images are needed in order to get the ping-pong semantics of MAILBOX, and to not slow down benchmarks. When this was tried, glmark2's composite score increased by 30%. In talking with the SF team, we realized what happened. The agreement is that we need to ensure that the Vulkan swapchain code needs to ensure that the swapchain has at least 4 images (in the normal case) when MAILBOX is enabled. This CL still honors min_undequeued_buffers, for cases when it's higher than the normal 2 for MAILBOX. Bug: b/132806469 Test: Run glmark2 with ANGLE Change-Id: I152f61f318236fd4718895aec7188135ee849f46
-rw-r--r--vulkan/libvulkan/swapchain.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp
index bc00190779..f1a73b1daa 100644
--- a/vulkan/libvulkan/swapchain.cpp
+++ b/vulkan/libvulkan/swapchain.cpp
@@ -1162,7 +1162,9 @@ VkResult CreateSwapchainKHR(VkDevice device,
}
uint32_t min_undequeued_buffers = static_cast<uint32_t>(query_value);
uint32_t num_images =
- (create_info->minImageCount - 1) + min_undequeued_buffers;
+ (swap_interval ? create_info->minImageCount
+ : std::max(3u, create_info->minImageCount)) -
+ 1 + min_undequeued_buffers;
// Lower layer insists that we have at least two buffers. This is wasteful
// and we'd like to relax it in the shared case, but not all the pieces are