KhronosGroup / Vulkan-Samples

One stop solution for all Vulkan samples
Apache License 2.0
4.36k stars 650 forks source link

Present mode stuck in eFifo if eMailbox not available on platform+GPU #1159

Closed SRSaunders closed 2 months ago

SRSaunders commented 2 months ago

vk::PresentModeKHR::eMailbox is not available on some platform+GPU combinations, e.g. on Windows and macOS using an AMD 6600XT GPU (perhaps other AMD GPUs as well??). In these cases, the present mode is always stuck in vk::PresentModeKHR::eFifo independent of the --vsync <ON|OFF> command line setting.

This is caused by the following logic in vulkan_sample.h:

vk::PresentModeKHR              present_mode = (window->get_properties().vsync == Window::Vsync::ON) ? vk::PresentModeKHR::eFifo : vk::PresentModeKHR::eMailbox;
std::vector<vk::PresentModeKHR> present_mode_priority_list{vk::PresentModeKHR::eMailbox, vk::PresentModeKHR::eFifo, vk::PresentModeKHR::eImmediate};

The preference is correctly given to eMailbox, but the fallback is currently eFifo. There is no way to select eImmediate.

Perhaps the fallback priority should be: eMailbox -> eImmediate -> eFifo, as follows:

vk::PresentModeKHR              present_mode = (window->get_properties().vsync == Window::Vsync::ON) ? vk::PresentModeKHR::eFifo : vk::PresentModeKHR::eMailbox;
std::vector<vk::PresentModeKHR> present_mode_priority_list{vk::PresentModeKHR::eMailbox, vk::PresentModeKHR::eImmediate, vk::PresentModeKHR::eFifo};

eMailbox and eImmediate should preceed eFifo, since this would always allow command line selection, and eFifo is the only guaranteed value according to the Vulkan spec and should be last in priority.

In addition, this would make the default (i.e. no command line option set) either eMailbox or eImmediate for most platforms. This would be preferable since many samples show performance stats which are useless today if eFifo is forced on as the eMailbox fallback for common platform+GPU setups.

asuessenbach commented 2 months ago

eMailbox and eImmediate should preceed eFifo, since this would always allow command line selection, and eFifo is the only guaranteed value according to the Vulkan spec and should be last in priority.

Totally agree! Thanks for spotting this issue.