diff --git a/src/rendering/vulkan/system/vk_device.cpp b/src/rendering/vulkan/system/vk_device.cpp index cbed3b5dc0..bd52c0c65c 100644 --- a/src/rendering/vulkan/system/vk_device.cpp +++ b/src/rendering/vulkan/system/vk_device.cpp @@ -46,6 +46,8 @@ extern HWND Window; #include "version.h" #include "doomerrors.h" +EXTERN_CVAR(Bool, vid_vsync); + #ifdef NDEBUG CVAR(Bool, vk_debug, true, 0); // this should be false, once the oversized model can be removed. #else @@ -74,7 +76,7 @@ VulkanDevice::VulkanDevice() RECT clientRect = { 0 }; GetClientRect(Window, &clientRect); - swapChain = std::make_unique(this, clientRect.right, clientRect.bottom, true); + swapChain = std::make_unique(this, clientRect.right, clientRect.bottom, vid_vsync); createSemaphores(); } @@ -96,7 +98,7 @@ void VulkanDevice::windowResized() GetClientRect(Window, &clientRect); swapChain.reset(); - swapChain = std::make_unique(this, clientRect.right, clientRect.bottom, true); + swapChain = std::make_unique(this, clientRect.right, clientRect.bottom, vid_vsync); } void VulkanDevice::waitPresent() @@ -177,10 +179,11 @@ void VulkanDevice::createInstance() std::vector validationLayers; std::string debugLayer = "VK_LAYER_LUNARG_standard_validation"; + bool wantDebugLayer = vk_debug; bool debugLayerFound = false; for (const VkLayerProperties &layer : availableLayers) { - if (layer.layerName == debugLayer) + if (layer.layerName == debugLayer && wantDebugLayer) { validationLayers.push_back(debugLayer.c_str()); enabledExtensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); diff --git a/src/rendering/vulkan/system/vk_framebuffer.cpp b/src/rendering/vulkan/system/vk_framebuffer.cpp index 50c595b1fa..b107b61455 100644 --- a/src/rendering/vulkan/system/vk_framebuffer.cpp +++ b/src/rendering/vulkan/system/vk_framebuffer.cpp @@ -261,6 +261,10 @@ uint32_t VulkanFrameBuffer::GetCaps() void VulkanFrameBuffer::SetVSync(bool vsync) { + if (device->swapChain->vsync != vsync) + { + device->windowResized(); + } } void VulkanFrameBuffer::CleanForRestart() diff --git a/src/rendering/vulkan/system/vk_swapchain.cpp b/src/rendering/vulkan/system/vk_swapchain.cpp index f866aca6f1..c6fa1bb336 100644 --- a/src/rendering/vulkan/system/vk_swapchain.cpp +++ b/src/rendering/vulkan/system/vk_swapchain.cpp @@ -1,7 +1,7 @@ #include "vk_swapchain.h" -VulkanSwapChain::VulkanSwapChain(VulkanDevice *device, int width, int height, bool vsync) : device(device) +VulkanSwapChain::VulkanSwapChain(VulkanDevice *device, int width, int height, bool vsync) : vsync(vsync), device(device) { VkSurfaceCapabilitiesKHR surfaceCapabilities; VkResult result = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(device->physicalDevice, device->surface, &surfaceCapabilities); diff --git a/src/rendering/vulkan/system/vk_swapchain.h b/src/rendering/vulkan/system/vk_swapchain.h index 6be32dd1dd..39fb9dfb63 100644 --- a/src/rendering/vulkan/system/vk_swapchain.h +++ b/src/rendering/vulkan/system/vk_swapchain.h @@ -8,6 +8,7 @@ public: VulkanSwapChain(VulkanDevice *device, int width, int height, bool vsync); ~VulkanSwapChain(); + bool vsync; VkSwapchainKHR swapChain; VkSurfaceFormatKHR swapChainFormat;