diff --git a/vulkan/vulkan_swapchain.cpp b/vulkan/vulkan_swapchain.cpp index 39301a65..b4d2734c 100644 --- a/vulkan/vulkan_swapchain.cpp +++ b/vulkan/vulkan_swapchain.cpp @@ -18,13 +18,9 @@ Swapchain::~Swapchain() { } -bool Swapchain::set_vsync(bool new_setting) +void Swapchain::set_vsync(bool new_setting) { - if (new_setting == vsync) - return false; - vsync = new_setting; - return true; } void Swapchain::on_render_pass_end(std::function function) @@ -104,14 +100,14 @@ static bool vector_find(std::vector haystack, T&& needle) vk::PresentModeKHR Swapchain::get_present_mode() { auto present_mode = vk::PresentModeKHR::eFifo; - if (supports_relaxed) - present_mode = vk::PresentModeKHR::eFifoRelaxed; + if (!vsync) { if (supports_mailbox) present_mode = vk::PresentModeKHR::eMailbox; if (supports_immediate) present_mode = vk::PresentModeKHR::eImmediate; } + return present_mode; } diff --git a/vulkan/vulkan_swapchain.hpp b/vulkan/vulkan_swapchain.hpp index 974b4f9f..ad271e83 100644 --- a/vulkan/vulkan_swapchain.hpp +++ b/vulkan/vulkan_swapchain.hpp @@ -27,8 +27,7 @@ class Swapchain void end_frame_without_swap(); bool swap(); void wait_on_frames(); - // Returns true if vsync setting was changed, false if it was the same - bool set_vsync(bool on); + void set_vsync(bool on); void on_render_pass_end(std::function function); int get_num_frames() { return num_swapchain_images; } vk::PresentModeKHR get_present_mode(); diff --git a/win32/CVulkan.cpp b/win32/CVulkan.cpp index bbde45b8..08b408b1 100644 --- a/win32/CVulkan.cpp +++ b/win32/CVulkan.cpp @@ -70,6 +70,8 @@ bool CVulkan::Initialize(HWND hWnd) return false; } + context->swapchain->set_vsync(GUI.Vsync); + if (!Settings.AutoDisplayMessages) { Settings.DisplayIndicators = true; @@ -91,11 +93,6 @@ bool CVulkan::Initialize(HWND hWnd) } } - if (context->swapchain->set_vsync(GUI.Vsync)) - { - context->recreate_swapchain(); - } - simple_output = std::make_unique(context.get(), vk::Format::eR5G6B5UnormPack16); return true; @@ -181,8 +178,6 @@ bool CVulkan::ChangeRenderSize(unsigned int newWidth, unsigned int newHeight) if (!context) return false; - bool vsync_changed = context->swapchain->set_vsync(GUI.Vsync); - if (newWidth != current_width || newHeight != current_height || vsync_changed) { context->recreate_swapchain(newWidth, newHeight); @@ -218,10 +213,7 @@ bool CVulkan::ApplyDisplayChanges(void) current_shadername = shadername; } - if (context->swapchain->set_vsync(GUI.Vsync)) - { - context->recreate_swapchain(); - } + context->swapchain->set_vsync(GUI.Vsync); return true; }