Skip to content
Permalink
Browse files

- don't let Vulkan access the vid_vsync variable directly.

Since the FrameBuffers have a SetVsync method anything these last set must count, not the global variable directly.
  • Loading branch information...
coelckers committed Oct 1, 2019
1 parent b9d4e77 commit 5179a69fdb258aa0773aafa07806d97751dcebc6
@@ -92,7 +92,6 @@ - (void)enterFullscreenOnZoom

@end

EXTERN_CVAR(Bool, vid_vsync)
EXTERN_CVAR(Bool, vid_hidpi)
EXTERN_CVAR(Int, vid_defwidth)
EXTERN_CVAR(Int, vid_defheight)
@@ -63,7 +63,6 @@ CVAR(Int, vid_showpalette, 0, 0)
EXTERN_CVAR(Bool, ticker)
EXTERN_CVAR(Float, vid_brightness)
EXTERN_CVAR(Float, vid_contrast)
EXTERN_CVAR(Bool, vid_vsync)
EXTERN_CVAR(Int, vid_maxfps)
EXTERN_CVAR(Bool, cl_capfps)
EXTERN_CVAR(Int, screenblocks)
@@ -636,6 +636,7 @@ const char* VulkanFrameBuffer::DeviceName() const
void VulkanFrameBuffer::SetVSync(bool vsync)
{
// This is handled in VulkanSwapChain::AcquireImage.
cur_vsync = vsync;
}

void VulkanFrameBuffer::CleanForRestart()
@@ -25,6 +25,7 @@ class VulkanFrameBuffer : public SystemBaseFrameBuffer
VulkanDevice *device;
std::unique_ptr<VulkanSwapChain> swapChain;
uint32_t presentImageIndex = 0xffffffff;
bool cur_vsync;

VulkanCommandBuffer *GetTransferCommands();
VulkanCommandBuffer *GetDrawCommands();
@@ -3,8 +3,9 @@
#include "vk_objects.h"
#include "c_cvars.h"
#include "version.h"
#include "v_video.h"
#include "vk_framebuffer.h"

EXTERN_CVAR(Bool, vid_vsync);

CVAR(Bool, vk_hdr, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);

@@ -21,12 +22,13 @@ VulkanSwapChain::~VulkanSwapChain()

uint32_t VulkanSwapChain::AcquireImage(int width, int height, VulkanSemaphore *semaphore, VulkanFence *fence)
{
if (lastSwapWidth != width || lastSwapHeight != height || lastVsync != vid_vsync || lastHdr != vk_hdr || !swapChain)
auto vsync = static_cast<VulkanFrameBuffer*>(screen)->cur_vsync;
if (lastSwapWidth != width || lastSwapHeight != height || lastVsync != vsync || lastHdr != vk_hdr || !swapChain)
{
Recreate();
lastSwapWidth = width;
lastSwapHeight = height;
lastVsync = vid_vsync;
lastVsync = vsync;
lastHdr = vk_hdr;
}

@@ -271,7 +273,8 @@ void VulkanSwapChain::SelectPresentMode()
VulkanError("No surface present modes supported");

swapChainPresentMode = VK_PRESENT_MODE_FIFO_KHR;
if (vid_vsync)
auto vsync = static_cast<VulkanFrameBuffer*>(screen)->cur_vsync;
if (vsync)
{
bool supportsFifoRelaxed = std::find(presentModes.begin(), presentModes.end(), VK_PRESENT_MODE_FIFO_RELAXED_KHR) != presentModes.end();
if (supportsFifoRelaxed)

0 comments on commit 5179a69

Please sign in to comment.
You can’t perform that action at this time.