From 1286c309e3a7b9a7a28b6128e68ab06f1502864c Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 1 Oct 2016 10:40:44 +1000 Subject: Vulkan: Fix compilation on 32-bit targets --- Source/Core/VideoBackends/Vulkan/SwapChain.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Source/Core/VideoBackends/Vulkan/SwapChain.cpp') diff --git a/Source/Core/VideoBackends/Vulkan/SwapChain.cpp b/Source/Core/VideoBackends/Vulkan/SwapChain.cpp index f0a35fd526..34ad5c39f2 100644 --- a/Source/Core/VideoBackends/Vulkan/SwapChain.cpp +++ b/Source/Core/VideoBackends/Vulkan/SwapChain.cpp @@ -280,8 +280,8 @@ void SwapChain::DestroyRenderPass() if (!m_render_pass) return; - g_command_buffer_mgr->DeferResourceDestruction(m_render_pass); - m_render_pass = nullptr; + vkDestroyRenderPass(g_vulkan_context->GetDevice(), m_render_pass, nullptr); + m_render_pass = VK_NULL_HANDLE; } bool SwapChain::CreateSwapChain() -- cgit v1.2.3 From 5e29508b8f4747e92e8de68b75971f26e4a78cd4 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 2 Oct 2016 22:09:19 +1000 Subject: Vulkan: Fix vsync behavior when throttler is temp disabled --- Source/Core/VideoBackends/Vulkan/SwapChain.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'Source/Core/VideoBackends/Vulkan/SwapChain.cpp') 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::Create(void* native_handle, VkSurfaceKHR surface) +std::unique_ptr SwapChain::Create(void* native_handle, VkSurfaceKHR surface, bool vsync) { - std::unique_ptr swap_chain = std::make_unique(native_handle, surface); + std::unique_ptr swap_chain = + std::make_unique(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. -- cgit v1.2.3