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

Commit ffedb65c authored by Ian Elliott's avatar Ian Elliott
Browse files

Ignore VK_KHR_incremental_present hint for MAILBOX.

Test: Using instrumented cube demo, and tmp ALOGI comments.

This code may eventually be replaced with code that constructs, stores,
and uses regions that spans multiple vkQueuePresentKHR() calls.  With
VK_PRESENT_MODE_MAILBOX_KHR, any given present may not be sent to the
display.  In such a case, the correct behavior is for the swapchain code
(a.k.a. acting for the "presentation engine") should build up a list of
regions across multiple vkQueuePresentKHR() calls, so that when an image
is presented, all of the updated regions will be sent to the display.
In the mean time, this code is correct (i.e. ignore the hint for
MAILBOX).

Change-Id: I413091871a9b9b7464ec941a857eea56e68f4189
parent 7bd8adbb
Loading
Loading
Loading
Loading
+9 −3
Original line number Original line Diff line number Diff line
@@ -191,9 +191,12 @@ enum { MAX_TIMING_INFOS = 10 };
enum { MIN_NUM_FRAMES_AGO = 5 };
enum { MIN_NUM_FRAMES_AGO = 5 };


struct Swapchain {
struct Swapchain {
    Swapchain(Surface& surface_, uint32_t num_images_)
    Swapchain(Surface& surface_,
              uint32_t num_images_,
              VkPresentModeKHR present_mode)
        : surface(surface_),
        : surface(surface_),
          num_images(num_images_),
          num_images(num_images_),
          mailbox_mode(present_mode == VK_PRESENT_MODE_MAILBOX_KHR),
          frame_timestamps_enabled(false) {
          frame_timestamps_enabled(false) {
        timing.clear();
        timing.clear();
        ANativeWindow* window = surface.window.get();
        ANativeWindow* window = surface.window.get();
@@ -206,6 +209,7 @@ struct Swapchain {


    Surface& surface;
    Surface& surface;
    uint32_t num_images;
    uint32_t num_images;
    bool mailbox_mode;
    bool frame_timestamps_enabled;
    bool frame_timestamps_enabled;
    uint64_t refresh_duration;
    uint64_t refresh_duration;


@@ -877,7 +881,8 @@ VkResult CreateSwapchainKHR(VkDevice device,
                                         VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
                                         VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
    if (!mem)
    if (!mem)
        return VK_ERROR_OUT_OF_HOST_MEMORY;
        return VK_ERROR_OUT_OF_HOST_MEMORY;
    Swapchain* swapchain = new (mem) Swapchain(surface, num_images);
    Swapchain* swapchain =
        new (mem) Swapchain(surface, num_images, create_info->presentMode);


    // -- Dequeue all buffers and create a VkImage for each --
    // -- Dequeue all buffers and create a VkImage for each --
    // Any failures during or after this must cancel the dequeued buffers.
    // Any failures during or after this must cancel the dequeued buffers.
@@ -1179,7 +1184,8 @@ VkResult QueuePresentKHR(VkQueue queue, const VkPresentInfoKHR* present_info) {
            *SwapchainFromHandle(present_info->pSwapchains[sc]);
            *SwapchainFromHandle(present_info->pSwapchains[sc]);
        uint32_t image_idx = present_info->pImageIndices[sc];
        uint32_t image_idx = present_info->pImageIndices[sc];
        Swapchain::Image& img = swapchain.images[image_idx];
        Swapchain::Image& img = swapchain.images[image_idx];
        const VkPresentRegionKHR* region = (regions) ? &regions[sc] : nullptr;
        const VkPresentRegionKHR* region =
            (regions && !swapchain.mailbox_mode) ? &regions[sc] : nullptr;
        const VkPresentTimeGOOGLE* time = (times) ? &times[sc] : nullptr;
        const VkPresentTimeGOOGLE* time = (times) ? &times[sc] : nullptr;
        VkResult swapchain_result = VK_SUCCESS;
        VkResult swapchain_result = VK_SUCCESS;
        VkResult result;
        VkResult result;