mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-16 16:21:02 +00:00
vk: Better vsync mode selection (#3571)
This commit is contained in:
parent
2e5f8c0786
commit
f5d450f24c
@ -836,34 +836,33 @@ namespace vk
|
|||||||
CHECK_RESULT(vkGetPhysicalDeviceSurfacePresentModesKHR(gpu, m_surface, &nb_available_modes, present_modes.data()));
|
CHECK_RESULT(vkGetPhysicalDeviceSurfacePresentModesKHR(gpu, m_surface, &nb_available_modes, present_modes.data()));
|
||||||
|
|
||||||
VkPresentModeKHR swapchain_present_mode = VK_PRESENT_MODE_FIFO_KHR;
|
VkPresentModeKHR swapchain_present_mode = VK_PRESENT_MODE_FIFO_KHR;
|
||||||
VkPresentModeKHR preferred_mode = (g_cfg.video.vsync) ? VK_PRESENT_MODE_FIFO_RELAXED_KHR : VK_PRESENT_MODE_IMMEDIATE_KHR;
|
std::vector<VkPresentModeKHR> preferred_modes;
|
||||||
bool mailbox_exists = false;
|
|
||||||
|
|
||||||
for (VkPresentModeKHR mode : present_modes)
|
//List of preferred modes in decreasing desirability
|
||||||
|
if (g_cfg.video.vsync)
|
||||||
|
preferred_modes = { VK_PRESENT_MODE_MAILBOX_KHR };
|
||||||
|
else
|
||||||
|
preferred_modes = { VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_FIFO_RELAXED_KHR, VK_PRESENT_MODE_MAILBOX_KHR };
|
||||||
|
|
||||||
|
bool mode_found = false;
|
||||||
|
for (VkPresentModeKHR preferred_mode : preferred_modes)
|
||||||
{
|
{
|
||||||
if (mode == VK_PRESENT_MODE_MAILBOX_KHR)
|
//Search for this mode in supported modes
|
||||||
|
for (VkPresentModeKHR mode : present_modes)
|
||||||
{
|
{
|
||||||
mailbox_exists = true;
|
if (mode == preferred_mode)
|
||||||
continue;
|
{
|
||||||
|
swapchain_present_mode = mode;
|
||||||
|
mode_found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == preferred_mode)
|
if (mode_found)
|
||||||
{
|
|
||||||
swapchain_present_mode = mode;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preferred_mode != swapchain_present_mode)
|
LOG_NOTICE(RSX, "Swapchain: present mode %d in use.", (s32&)swapchain_present_mode);
|
||||||
{
|
|
||||||
//Preferred video mode was not found. Fall back to mailbox if it exists
|
|
||||||
LOG_WARNING(RSX, "Swapchain: Could not set the preferred present mode 0x%X. Falling back to mailbox if supported (supported=%d)", (u32)preferred_mode, mailbox_exists);
|
|
||||||
|
|
||||||
if (mailbox_exists)
|
|
||||||
{
|
|
||||||
swapchain_present_mode = VK_PRESENT_MODE_MAILBOX_KHR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t nb_swap_images = surface_descriptors.minImageCount + 1;
|
uint32_t nb_swap_images = surface_descriptors.minImageCount + 1;
|
||||||
if (surface_descriptors.maxImageCount > 0)
|
if (surface_descriptors.maxImageCount > 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user