summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2025-01-09 21:19:42 +1100
committerquou <quou@disroot.org>2025-01-09 21:19:42 +1100
commit78321be96d15afaccb3d0a179e91a3e5887d3376 (patch)
treec7c4862488e37819e95422394ed61d8efa70d380
parenta51515008fcddfd0c8fdd3beac539801f4183ca1 (diff)
Actually pay attention to the vsync flag passed into choose_swap_mode
-rw-r--r--video.cpp13
1 files 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{};