From 78321be96d15afaccb3d0a179e91a3e5887d3376 Mon Sep 17 00:00:00 2001 From: quou Date: Thu, 9 Jan 2025 21:19:42 +1100 Subject: Actually pay attention to the vsync flag passed into choose_swap_mode --- video.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/video.cpp b/video.cpp index 8203eea..a0bbc2c 100644 --- a/video.cpp +++ b/video.cpp @@ -1895,8 +1895,15 @@ static VkSurfaceFormatKHR choose_swap_format(const Swap_Cap& cap) { } static VkPresentModeKHR choose_swap_mode(const Swap_Cap& cap, bool vsync) { - (void)vsync; - (void)cap; /* todo */ + if (!vsync) { + int i, c = cap.pm_count; + for (i = 0; i < c; i++) + if (cap.pms[i] == VK_PRESENT_MODE_IMMEDIATE_KHR) + return cap.pms[i]; + for (i = 0; i < c; i++) + if (cap.pms[i] == VK_PRESENT_MODE_MAILBOX_KHR) + return cap.pms[i]; + } return VK_PRESENT_MODE_FIFO_KHR; } @@ -1937,7 +1944,7 @@ void Swapchain::initr(const App& app, Device_Vk* dev) { image_count = get_image_count(dev->swap_cap); size = choose_swap_extent(app, dev->swap_cap.cap); format = choose_swap_format(dev->swap_cap); - mode = choose_swap_mode(dev->swap_cap, false); + mode = choose_swap_mode(dev->swap_cap, true); { VkResult r; VkSwapchainCreateInfoKHR si{}; -- cgit v1.2.3-54-g00ecf