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

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

Vulkan: avoid calling cancelBuffer on a shared buffer

to silence the err log "cannot cancel a buffer in shared buffer mode"

Bug: 204681201
Test: dEQP-VK.wsi.android.shared_presentable_image.*
Change-Id: I3ffa0df28b10c5576a2196f5de0a9cf63bc6a1fa
parent 97272abc
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -299,6 +299,7 @@ static bool IsFencePending(int fd) {
}

void ReleaseSwapchainImage(VkDevice device,
                           bool shared_present,
                           ANativeWindow* window,
                           int release_fence,
                           Swapchain::Image& image,
@@ -330,7 +331,8 @@ void ReleaseSwapchainImage(VkDevice device,
        }
        image.dequeue_fence = -1;

        if (window) {
        // It's invalid to call cancelBuffer on a shared buffer
        if (window && !shared_present) {
            window->cancelBuffer(window, image.buffer.get(), release_fence);
        } else {
            if (release_fence >= 0) {
@@ -364,9 +366,10 @@ void OrphanSwapchain(VkDevice device, Swapchain* swapchain) {
    if (swapchain->surface.swapchain_handle != HandleFromSwapchain(swapchain))
        return;
    for (uint32_t i = 0; i < swapchain->num_images; i++) {
        if (!swapchain->images[i].dequeued)
            ReleaseSwapchainImage(device, nullptr, -1, swapchain->images[i],
                                  true);
        if (!swapchain->images[i].dequeued) {
            ReleaseSwapchainImage(device, swapchain->shared, nullptr, -1,
                                  swapchain->images[i], true);
        }
    }
    swapchain->surface.swapchain_handle = VK_NULL_HANDLE;
    swapchain->timing.clear();
@@ -1084,7 +1087,8 @@ static void DestroySwapchainInternal(VkDevice device,
    }

    for (uint32_t i = 0; i < swapchain->num_images; i++) {
        ReleaseSwapchainImage(device, window, -1, swapchain->images[i], false);
        ReleaseSwapchainImage(device, swapchain->shared, window, -1,
                              swapchain->images[i], false);
    }

    if (active) {
@@ -1854,7 +1858,8 @@ VkResult QueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* present_info) {
                    WorstPresentResult(swapchain_result, VK_SUBOPTIMAL_KHR);
            }
        } else {
            ReleaseSwapchainImage(device, nullptr, fence, img, true);
            ReleaseSwapchainImage(device, swapchain.shared, nullptr, fence,
                                  img, true);
            swapchain_result = VK_ERROR_OUT_OF_DATE_KHR;
        }