Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1624c614 authored by Yiwei Zhang's avatar Yiwei Zhang Committed by Android (Google) Code Review
Browse files

Merge "swapchain: add condition to report mailbox mode"

parents 8c07c336 e4a559c1
Loading
Loading
Loading
Loading
+23 −2
Original line number Diff line number Diff line
@@ -751,10 +751,31 @@ VkResult GetPhysicalDeviceSurfaceFormats2KHR(

VKAPI_ATTR
VkResult GetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice pdev,
                                                 VkSurfaceKHR /*surface*/,
                                                 VkSurfaceKHR surface,
                                                 uint32_t* count,
                                                 VkPresentModeKHR* modes) {
    int err;
    int query_value;
    ANativeWindow* window = SurfaceFromHandle(surface)->window.get();

    err = window->query(window, NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, &query_value);
    if (err != 0 || query_value < 0) {
        ALOGE("NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS query failed: %s (%d) value=%d",
              strerror(-err), err, query_value);
        return VK_ERROR_SURFACE_LOST_KHR;
    }
    uint32_t min_undequeued_buffers = static_cast<uint32_t>(query_value);

    err = window->query(window, NATIVE_WINDOW_MAX_BUFFER_COUNT, &query_value);
    if (err != 0 || query_value < 0) {
        ALOGE("NATIVE_WINDOW_MAX_BUFFER_COUNT query failed: %s (%d) value=%d",
              strerror(-err), err, query_value);
        return VK_ERROR_SURFACE_LOST_KHR;
    }
    uint32_t max_buffer_count = static_cast<uint32_t>(query_value);

    android::Vector<VkPresentModeKHR> present_modes;
    if (min_undequeued_buffers + 1 < max_buffer_count)
        present_modes.push_back(VK_PRESENT_MODE_MAILBOX_KHR);
    present_modes.push_back(VK_PRESENT_MODE_FIFO_KHR);