vulkan: Always request at least 2 images for swapchain
For shared mode, we really only care about 1 image, but there are other
changes further down the stack that need to be made for that to really
work. For now, just tell the bufferqueue that we want 2. After that, we
still only dequeue one buffer (as in fact required by BQ in shared mode)
and construct one VkImage over it for giving back to the vulkan app.
[in V1 we were just smashing the buffer count to 2, which is messier and
observable by the app]
Change-Id: Idc0d3c232d56a5c0127f9472611d151f3605939c
Test: build
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp
index 5574da2..46e83db 100644
--- a/vulkan/libvulkan/swapchain.cpp
+++ b/vulkan/libvulkan/swapchain.cpp
@@ -941,7 +941,13 @@
uint32_t min_undequeued_buffers = static_cast<uint32_t>(query_value);
uint32_t num_images =
(create_info->minImageCount - 1) + min_undequeued_buffers;
- err = native_window_set_buffer_count(surface.window.get(), num_images);
+
+ // 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
+ // in place for that to work yet. Note we only lie to the lower layer-- we
+ // don't want to give the app back a swapchain with extra images (which they
+ // can't actually use!).
+ err = native_window_set_buffer_count(surface.window.get(), std::max(2u, num_images));
if (err != 0) {
// TODO(jessehall): Improve error reporting. Can we enumerate possible
// errors and translate them to valid Vulkan result codes?