Vulkan: Partial revert of swap chain refactor.

On Windows presenting mode mailbox would reduce lag. We might want to be
more selective on which mode to use when.
This commit is contained in:
Jeroen Bakker
2025-04-01 16:33:31 +02:00
parent 853640c063
commit 439a4e4687

View File

@@ -733,13 +733,26 @@ static void requireExtension(const vector<VkExtensionProperties> &extensions_ava
}
}
static GHOST_TSuccess selectPresentMode(VkPhysicalDevice /*device*/,
VkSurfaceKHR /*surface*/,
static GHOST_TSuccess selectPresentMode(VkPhysicalDevice device,
VkSurfaceKHR surface,
VkPresentModeKHR *r_presentMode)
{
/* FIFO present mode is always available and we prefer it as it will keep the main loop running
* along the monitor refresh rate. Mailbox and Fifo relaxed can generate a lot of frames that
* will never be displayed. */
uint32_t present_count;
vkGetPhysicalDeviceSurfacePresentModesKHR(device, surface, &present_count, nullptr);
vector<VkPresentModeKHR> presents(present_count);
vkGetPhysicalDeviceSurfacePresentModesKHR(device, surface, &present_count, presents.data());
/* MAILBOX is the lowest latency V-Sync enabled mode. We will use it if available as it fixes
* some lag on NVIDIA/Intel GPUs. */
for (auto present_mode : presents) {
if (present_mode == VK_PRESENT_MODE_MAILBOX_KHR) {
*r_presentMode = present_mode;
return GHOST_kSuccess;
}
}
/*FIFO present mode is always available and we (should) prefer it as it will keep the main loop
* running along the monitor refresh rate. Mailbox and Fifo relaxed can generate a lot of frames
* that will never be displayed. */
*r_presentMode = VK_PRESENT_MODE_FIFO_KHR;
return GHOST_kSuccess;
}