summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrevor Black <vantablack@google.com>2023-06-08 20:46:44 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2023-06-08 20:46:44 +0000
commitff9eccdef7f0e4d7691e98acd959715abdd5f421 (patch)
treebc6bcdd11e65a423c062b52c095eddb91b186cd4
parent0db53ee3c9ae908d14c09290a4fb51036df25620 (diff)
parent1d3509ed5dd2c9b38acb4b5dc8c02a97a5a38ee6 (diff)
downloadnative-ff9eccdef7f0e4d7691e98acd959715abdd5f421.tar.gz
Merge "Correctly implement minImageCount for swapchain" into udc-dev
-rw-r--r--vulkan/libvulkan/swapchain.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/vulkan/libvulkan/swapchain.cpp b/vulkan/libvulkan/swapchain.cpp
index 5965953b38..af873065ff 100644
--- a/vulkan/libvulkan/swapchain.cpp
+++ b/vulkan/libvulkan/swapchain.cpp
@@ -877,6 +877,7 @@ VkResult GetPhysicalDeviceSurfaceCapabilities2KHR(
int width, height;
int transform_hint;
int max_buffer_count;
+ int min_undequeued_buffers;
if (surface == VK_NULL_HANDLE) {
const InstanceData& instance_data = GetData(physicalDevice);
ProcHook::Extension surfaceless = ProcHook::GOOGLE_surfaceless_query;
@@ -929,17 +930,24 @@ VkResult GetPhysicalDeviceSurfaceCapabilities2KHR(
return VK_ERROR_SURFACE_LOST_KHR;
}
+ err = window->query(window, NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS,
+ &min_undequeued_buffers);
+ if (err != android::OK) {
+ ALOGE("NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS query failed: %s (%d)",
+ strerror(-err), err);
+ return VK_ERROR_SURFACE_LOST_KHR;
+ }
+
if (pPresentMode && IsSharedPresentMode(pPresentMode->presentMode)) {
capabilities->minImageCount = 1;
capabilities->maxImageCount = 1;
} else if (pPresentMode && pPresentMode->presentMode == VK_PRESENT_MODE_MAILBOX_KHR) {
- // TODO: use undequeued buffer requirement for more precise bound
- capabilities->minImageCount = std::min(max_buffer_count, 4);
+ capabilities->minImageCount =
+ std::min(max_buffer_count, min_undequeued_buffers + 2);
capabilities->maxImageCount = static_cast<uint32_t>(max_buffer_count);
} else {
- // TODO: if we're able to, provide better bounds on the number of buffers
- // for other modes as well.
- capabilities->minImageCount = std::min(max_buffer_count, 3);
+ capabilities->minImageCount =
+ std::min(max_buffer_count, min_undequeued_buffers + 1);
capabilities->maxImageCount = static_cast<uint32_t>(max_buffer_count);
}
}