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

Commit 5396b701 authored by Ian Elliott's avatar Ian Elliott
Browse files

swapchain: Fix SHARED presentation modes

The code under the Vulkan swapchain code requires additional
images now, even though only one will be used for the SHARED
presentation modes.

Test: dEQP-VK.wsi.android.shared_presentable_image.scale_none.horizontal_mirror.inherit#continuous
Bug: 209035115
Bug: 200378297
Change-Id: Idbb3983becefa47e4f792106ab8274027a0db6c0
parent 7ad74670
Loading
Loading
Loading
Loading
+14 −6
Original line number Original line Diff line number Diff line
@@ -1205,18 +1205,26 @@ VkResult CreateSwapchainKHR(VkDevice device,
        swap_interval ? create_info->minImageCount : mailbox_num_images;
        swap_interval ? create_info->minImageCount : mailbox_num_images;
    uint32_t num_images = requested_images - 1 + min_undequeued_buffers;
    uint32_t num_images = requested_images - 1 + min_undequeued_buffers;


    // Lower layer insists that we have at least two buffers. This is wasteful
    // Lower layer insists that we have at least min_undequeued_buffers + 1
    // and we'd like to relax it in the shared case, but not all the pieces are
    // buffers.  This is wasteful and we'd like to relax it in the shared case,
    // in place for that to work yet. Note we only lie to the lower layer-- we
    // but not all the pieces are in place for that to work yet.  Note we only
    // don't want to give the app back a swapchain with extra images (which they
    // lie to the lower layer--we don't want to give the app back a swapchain
    // can't actually use!).
    // with extra images (which they can't actually use!).
    err = native_window_set_buffer_count(window, std::max(2u, num_images));
    uint32_t min_buffer_count = min_undequeued_buffers + 1;
    err = native_window_set_buffer_count(
        window, std::max(min_buffer_count, num_images));
    if (err != android::OK) {
    if (err != android::OK) {
        ALOGE("native_window_set_buffer_count(%d) failed: %s (%d)", num_images,
        ALOGE("native_window_set_buffer_count(%d) failed: %s (%d)", num_images,
              strerror(-err), err);
              strerror(-err), err);
        return VK_ERROR_SURFACE_LOST_KHR;
        return VK_ERROR_SURFACE_LOST_KHR;
    }
    }


    // In shared mode the num_images must be one regardless of how many
    // buffers were allocated for the buffer queue.
    if (swapchain_image_usage & VK_SWAPCHAIN_IMAGE_USAGE_SHARED_BIT_ANDROID) {
        num_images = 1;
    }

    int32_t legacy_usage = 0;
    int32_t legacy_usage = 0;
    if (dispatch.GetSwapchainGrallocUsage2ANDROID) {
    if (dispatch.GetSwapchainGrallocUsage2ANDROID) {
        uint64_t consumer_usage, producer_usage;
        uint64_t consumer_usage, producer_usage;