vulkan-renderer icon indicating copy to clipboard operation
vulkan-renderer copied to clipboard

Use VK_PRESENT_MODE_IMMEDIATE_KHR when vsync is turned off

Open IAmNotHanni opened this issue 2 years ago • 1 comments

Is your feature request related to a problem?

Currently, this is our default present mode priority list:

static const std::vector<VkPresentModeKHR> default_present_mode_priorities{
    VK_PRESENT_MODE_MAILBOX_KHR,
    VK_PRESENT_MODE_FIFO_RELAXED_KHR,
    VK_PRESENT_MODE_FIFO_KHR
};

Description

When choosing the VkPresentModeKHR in the swapchain wrapper, we do this:

VkPresentModeKHR Swapchain::choose_present_mode(const std::vector<VkPresentModeKHR> &available_present_modes,
                                                const std::vector<VkPresentModeKHR> &present_mode_priority_list,
                                                const bool vsync_enabled) {
    assert(!available_present_modes.empty());
    assert(!present_mode_priority_list.empty());
    if (!vsync_enabled) {
        for (const auto requested_present_mode : present_mode_priority_list) {
            const auto present_mode =
                std::find(available_present_modes.begin(), available_present_modes.end(), requested_present_mode);
            if (present_mode != available_present_modes.end()) {
                return *present_mode;
            }
        }
    }
    return VK_PRESENT_MODE_FIFO_KHR;
}

Even if vsync is turned off, VK_PRESENT_MODE_IMMEDIATE_KHR is not considered because it's not in our default list of present modes.

Alternatives

Enforce vsync by not supporting VK_PRESENT_MODE_IMMEDIATE_KHR (not recommended)

Affected Code

The swapchain wrapper

Operating System

All

Additional Context

none

IAmNotHanni avatar May 11 '23 09:05 IAmNotHanni

Another title for this issue could be "allow vsync to be turned off again".

IAmNotHanni avatar May 11 '23 09:05 IAmNotHanni