From 811a6edab94e094143ba3a83df7c9735a0dfd975 Mon Sep 17 00:00:00 2001
From: Philip Whitfield <philip@undef.ch>
Date: Thu, 11 Jun 2020 11:21:15 +0200
Subject: [PATCH] fallback to immediate presentation mode if mailbox is not
 available

---
 liblava/frame/swapchain.cpp | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/liblava/frame/swapchain.cpp b/liblava/frame/swapchain.cpp
index 53887bf8..48bcbd0d 100644
--- a/liblava/frame/swapchain.cpp
+++ b/liblava/frame/swapchain.cpp
@@ -116,9 +116,13 @@ VkPresentModeKHR swapchain::choose_present_mode(VkPresentModeKHRs const& present
     if (v_sync())
         return VK_PRESENT_MODE_FIFO_KHR;
 
-    for (auto const& present_mode : present_modes)
-        if (present_mode == VK_PRESENT_MODE_MAILBOX_KHR)
-            return present_mode;
+    if(std::find(present_modes.begin(), present_modes.end(), VK_PRESENT_MODE_MAILBOX_KHR) != present_modes.end()){
+        return VK_PRESENT_MODE_MAILBOX_KHR;
+    }
+
+    if(std::find(present_modes.begin(), present_modes.end(), VK_PRESENT_MODE_IMMEDIATE_KHR) != present_modes.end()){
+        return VK_PRESENT_MODE_IMMEDIATE_KHR;
+    }
 
     return VK_PRESENT_MODE_FIFO_KHR;
 }
-- 
GitLab