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

Commit f3339223 authored by Jesse Hall's avatar Jesse Hall
Browse files

libvulkan: Implement VK_PRESENT_MODE_MAILBOX_KHR

Change-Id: Ibbb11849c7a59236e27af32148ab5c5fb22d9b19
(cherry picked from commit 388e6ab8bc0067f88147e68dd20d5c2b6b1e3213)
parent 993849ce
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -332,8 +332,10 @@ VkResult CreateSwapchainKHR_Bottom(VkDevice device,
             "swapchain re-creation not yet implemented");
    ALOGE_IF(create_info->preTransform != VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR,
             "swapchain preTransform not yet implemented");
    ALOGE_IF(create_info->presentMode != VK_PRESENT_MODE_FIFO_KHR,
             "present modes other than FIFO are not yet implemented");
    ALOGW_IF((create_info->presentMode != VK_PRESENT_MODE_FIFO_KHR ||
              create_info->presentMode != VK_PRESENT_MODE_MAILBOX_KHR),
             "swapchain present mode %d not supported",
             create_info->presentMode);

    // -- Configure the native window --

@@ -404,6 +406,17 @@ VkResult CreateSwapchainKHR_Bottom(VkDevice device,
        return VK_ERROR_INITIALIZATION_FAILED;
    }

    err = surface.window->setSwapInterval(
        surface.window.get(),
        create_info->presentMode == VK_PRESENT_MODE_MAILBOX_KHR ? 0 : 1);
    if (err != 0) {
        // TODO(jessehall): Improve error reporting. Can we enumerate possible
        // errors and translate them to valid Vulkan result codes?
        ALOGE("native_window->setSwapInterval failed: %s (%d)", strerror(-err),
              err);
        return VK_ERROR_INITIALIZATION_FAILED;
    }

    // -- Allocate our Swapchain object --
    // After this point, we must deallocate the swapchain on error.