summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/Vulkan/SwapChain.cpp
diff options
context:
space:
mode:
authorStenzek <stenzek@gmail.com>2016-10-02 22:09:19 +1000
committerStenzek <stenzek@gmail.com>2016-10-03 19:11:48 +1000
commit5e29508b8f4747e92e8de68b75971f26e4a78cd4 (patch)
treedcb37c362268aef9699a5263b011687918c64dfa /Source/Core/VideoBackends/Vulkan/SwapChain.cpp
parentb1932828303d290bb886fde940bf21a6e207d266 (diff)
Vulkan: Fix vsync behavior when throttler is temp disabled
Diffstat (limited to 'Source/Core/VideoBackends/Vulkan/SwapChain.cpp')
-rw-r--r--Source/Core/VideoBackends/Vulkan/SwapChain.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/Source/Core/VideoBackends/Vulkan/SwapChain.cpp b/Source/Core/VideoBackends/Vulkan/SwapChain.cpp
index 34ad5c39f2..899f931c6d 100644
--- a/Source/Core/VideoBackends/Vulkan/SwapChain.cpp
+++ b/Source/Core/VideoBackends/Vulkan/SwapChain.cpp
@@ -24,8 +24,8 @@
namespace Vulkan
{
-SwapChain::SwapChain(void* native_handle, VkSurfaceKHR surface)
- : m_native_handle(native_handle), m_surface(surface)
+SwapChain::SwapChain(void* native_handle, VkSurfaceKHR surface, bool vsync)
+ : m_native_handle(native_handle), m_surface(surface), m_vsync_enabled(vsync)
{
}
@@ -127,9 +127,10 @@ VkSurfaceKHR SwapChain::CreateVulkanSurface(VkInstance instance, void* hwnd)
#endif
}
-std::unique_ptr<SwapChain> SwapChain::Create(void* native_handle, VkSurfaceKHR surface)
+std::unique_ptr<SwapChain> SwapChain::Create(void* native_handle, VkSurfaceKHR surface, bool vsync)
{
- std::unique_ptr<SwapChain> swap_chain = std::make_unique<SwapChain>(native_handle, surface);
+ std::unique_ptr<SwapChain> swap_chain =
+ std::make_unique<SwapChain>(native_handle, surface, vsync);
if (!swap_chain->CreateSwapChain() || !swap_chain->CreateRenderPass() ||
!swap_chain->SetupSwapChainImages())
@@ -198,7 +199,7 @@ bool SwapChain::SelectPresentMode()
};
// If vsync is enabled, prefer VK_PRESENT_MODE_FIFO_KHR.
- if (g_ActiveConfig.IsVSync())
+ if (m_vsync_enabled)
{
// Try for relaxed vsync first, since it's likely the VI won't line up with
// the refresh rate of the system exactly, so tearing once is better than
@@ -456,11 +457,8 @@ VkResult SwapChain::AcquireNextImage(VkSemaphore available_semaphore)
bool SwapChain::ResizeSwapChain()
{
- if (!CreateSwapChain())
- return false;
-
DestroySwapChainImages();
- if (!SetupSwapChainImages())
+ if (!CreateSwapChain() || !SetupSwapChainImages())
{
PanicAlert("Failed to re-configure swap chain images, this is fatal (for now)");
return false;
@@ -469,6 +467,16 @@ bool SwapChain::ResizeSwapChain()
return true;
}
+bool SwapChain::SetVSync(bool enabled)
+{
+ if (m_vsync_enabled == enabled)
+ return true;
+
+ // Resizing recreates the swap chain with the new present mode.
+ m_vsync_enabled = enabled;
+ return ResizeSwapChain();
+}
+
bool SwapChain::RecreateSurface(void* native_handle)
{
// Destroy the old swap chain, images, and surface.