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

Commit e4a559c1 authored by Yiwei Zhang's avatar Yiwei Zhang
Browse files

swapchain: add condition to report mailbox mode

The current GetPhysicalDeviceSurfacePresentModesKHR() will by default
make VK_PRESENT_MODE_MAILBOX_KHR available to consumers. However, that
mode should not be reported when NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS +
1 < NATIVE_WINDOW_MAX_BUFFER_COUNT, in which case setAsyncMode(true)
will always fail.

Test: adb shell setprop debug.hwui.renderer skiavk
Test: click on apps in Play store, no setAsyncMode errors
Bug: b/73495125
Change-Id: Ida3bf471c6768b2e83dd8707198ed4f0b68514ad
parent 7e3b57a2
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);