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

Commit b8042d26 authored by Chris Forbes's avatar Chris Forbes
Browse files

vulkan: enable shared buffer mode and auto refresh if desired

First turn these off as part of the reset process, then set them based
on the present mode.

Test: build
Change-Id: I81297d6cfcdab1a569cd0c9d57ed3fcb4c534146
parent b442152d
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -484,6 +484,20 @@ VkResult CreateSwapchainKHR(VkDevice device,
        return VK_ERROR_INITIALIZATION_FAILED;
    }

    err = native_window_set_shared_buffer_mode(surface.window.get(), false);
    if (err != 0) {
        ALOGE("native_window_set_shared_buffer_mode(false) failed: %s (%d)",
              strerror(-err), err);
        return VK_ERROR_INITIALIZATION_FAILED;
    }

    err = native_window_set_auto_refresh(surface.window.get(), false);
    if (err != 0) {
        ALOGE("native_window_set_auto_refresh(false) failed: %s (%d)",
              strerror(-err), err);
        return VK_ERROR_INITIALIZATION_FAILED;
    }

    // -- Configure the native window --

    const auto& dispatch = GetData(device).driver;
@@ -595,6 +609,20 @@ VkResult CreateSwapchainKHR(VkDevice device,
    if (create_info->presentMode == VK_PRESENT_MODE_FRONT_BUFFERED_DEMAND_REFRESH_KHR ||
        create_info->presentMode == VK_PRESENT_MODE_FRONT_BUFFERED_CONTINUOUS_REFRESH_KHR) {
        swapchain_image_usage |= VK_SWAPCHAIN_IMAGE_USAGE_FRONT_BUFFER_BIT_ANDROID;

        err = native_window_set_shared_buffer_mode(surface.window.get(), true);
        if (err != 0) {
            ALOGE("native_window_set_shared_buffer_mode failed: %s (%d)", strerror(-err), err);
            return VK_ERROR_INITIALIZATION_FAILED;
        }
    }

    if (create_info->presentMode == VK_PRESENT_MODE_FRONT_BUFFERED_CONTINUOUS_REFRESH_KHR) {
        err = native_window_set_auto_refresh(surface.window.get(), true);
        if (err != 0) {
            ALOGE("native_window_set_auto_refresh failed: %s (%d)", strerror(-err), err);
            return VK_ERROR_INITIALIZATION_FAILED;
        }
    }

    int gralloc_usage = 0;