1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 18:53:28 +01:00

vulkan: Implement vsync

This commit is contained in:
kd-11 2017-09-29 15:50:35 +03:00
parent 6e8107a5cb
commit 55df3cdf67

View File

@ -834,20 +834,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;
bool mailbox_exists = false;
for (VkPresentModeKHR mode : present_modes) for (VkPresentModeKHR mode : present_modes)
{ {
if (mode == VK_PRESENT_MODE_MAILBOX_KHR) if (mode == VK_PRESENT_MODE_MAILBOX_KHR)
{ {
//If we can get a mailbox mode, use it mailbox_exists = true;
continue;
}
if (mode == preferred_mode)
{
swapchain_present_mode = mode; swapchain_present_mode = mode;
break; break;
} }
}
//If we can get out of using the FIFO mode, take it. Fifo is very high latency (generic vsync) if (preferred_mode != swapchain_present_mode)
if (swapchain_present_mode == VK_PRESENT_MODE_FIFO_KHR && {
(mode == VK_PRESENT_MODE_IMMEDIATE_KHR || mode == VK_PRESENT_MODE_FIFO_RELAXED_KHR)) //Preferred video mode was not found. Fall back to mailbox if it exists
swapchain_present_mode = mode; 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;