- hook up vid_vsync and vk_debug

This commit is contained in:
Magnus Norddahl 2019-02-27 22:20:18 +01:00
parent b4154f1772
commit c2e0eba270
4 changed files with 12 additions and 4 deletions

View file

@ -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<VulkanSwapChain>(this, clientRect.right, clientRect.bottom, true);
swapChain = std::make_unique<VulkanSwapChain>(this, clientRect.right, clientRect.bottom, vid_vsync);
createSemaphores();
}
@ -96,7 +98,7 @@ void VulkanDevice::windowResized()
GetClientRect(Window, &clientRect);
swapChain.reset();
swapChain = std::make_unique<VulkanSwapChain>(this, clientRect.right, clientRect.bottom, true);
swapChain = std::make_unique<VulkanSwapChain>(this, clientRect.right, clientRect.bottom, vid_vsync);
}
void VulkanDevice::waitPresent()
@ -177,10 +179,11 @@ void VulkanDevice::createInstance()
std::vector<const char*> 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);

View file

@ -261,6 +261,10 @@ uint32_t VulkanFrameBuffer::GetCaps()
void VulkanFrameBuffer::SetVSync(bool vsync)
{
if (device->swapChain->vsync != vsync)
{
device->windowResized();
}
}
void VulkanFrameBuffer::CleanForRestart()

View file

@ -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);

View file

@ -8,6 +8,7 @@ public:
VulkanSwapChain(VulkanDevice *device, int width, int height, bool vsync);
~VulkanSwapChain();
bool vsync;
VkSwapchainKHR swapChain;
VkSurfaceFormatKHR swapChainFormat;