mirror of https://github.com/cemu-project/Cemu.git
GeneralSettings: Update vsync after settings close (#401)
This commit is contained in:
parent
f41f7b63e8
commit
c3182aedd9
|
@ -352,14 +352,19 @@ void OpenGLRenderer::NotifyLatteCommandProcessorIdle()
|
|||
glFlush();
|
||||
}
|
||||
|
||||
void OpenGLRenderer::EnableVSync(int state)
|
||||
void OpenGLRenderer::UpdateVSyncState()
|
||||
{
|
||||
int configValue = GetConfig().vsync.GetValue();
|
||||
if(m_activeVSyncState != configValue)
|
||||
{
|
||||
#if BOOST_OS_WINDOWS
|
||||
if(wglSwapIntervalEXT)
|
||||
wglSwapIntervalEXT(state); // 1 = enabled, 0 = disabled
|
||||
wglSwapIntervalEXT(configValue); // 1 = enabled, 0 = disabled
|
||||
#else
|
||||
cemuLog_log(LogType::Force, "OpenGL vsync not implemented");
|
||||
#endif
|
||||
m_activeVSyncState = configValue;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsRunningInWine();
|
||||
|
@ -438,6 +443,7 @@ void OpenGLRenderer::EnableDebugMode()
|
|||
void OpenGLRenderer::SwapBuffers(bool swapTV, bool swapDRC)
|
||||
{
|
||||
GLCanvas_SwapBuffers(swapTV, swapDRC);
|
||||
UpdateVSyncState();
|
||||
|
||||
if (swapTV)
|
||||
cleanupAfterFrame();
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
void Flush(bool waitIdle = false) override;
|
||||
void NotifyLatteCommandProcessorIdle() override;
|
||||
|
||||
void EnableVSync(int state) override;
|
||||
void UpdateVSyncState();
|
||||
|
||||
void EnableDebugMode() override;
|
||||
void SwapBuffers(bool swapTV = true, bool swapDRC = true) override;
|
||||
|
@ -168,6 +168,7 @@ private:
|
|||
GLuint m_defaultFramebufferId;
|
||||
GLuint m_pipeline = 0;
|
||||
|
||||
int m_activeVSyncState{};
|
||||
bool m_isPadViewContext{};
|
||||
|
||||
// rendertarget viewport
|
||||
|
|
|
@ -58,7 +58,6 @@ public:
|
|||
virtual bool GetVRAMInfo(int& usageInMB, int& totalInMB) const;
|
||||
|
||||
virtual void EnableDebugMode() {}
|
||||
virtual void EnableVSync(int state) = 0;
|
||||
|
||||
virtual void ClearColorbuffer(bool padView) = 0;
|
||||
virtual void DrawEmptyFrame(bool mainWindow) = 0;
|
||||
|
|
|
@ -1382,22 +1382,22 @@ VkSurfaceFormatKHR VulkanRenderer::ChooseSwapSurfaceFormat(const std::vector<VkS
|
|||
|
||||
VkPresentModeKHR VulkanRenderer::ChooseSwapPresentMode(const std::vector<VkPresentModeKHR>& modes)
|
||||
{
|
||||
m_vsync_state = (VSync)GetConfig().vsync.GetValue();
|
||||
if (m_vsync_state == VSync::MAILBOX)
|
||||
const auto vsyncState = (VSync)GetConfig().vsync.GetValue();
|
||||
if (vsyncState == VSync::MAILBOX)
|
||||
{
|
||||
if (std::find(modes.cbegin(), modes.cend(), VK_PRESENT_MODE_MAILBOX_KHR) != modes.cend())
|
||||
return VK_PRESENT_MODE_MAILBOX_KHR;
|
||||
|
||||
forceLog_printf("Vulkan: Can't find mailbox present mode");
|
||||
}
|
||||
else if (m_vsync_state == VSync::Immediate)
|
||||
else if (vsyncState == VSync::Immediate)
|
||||
{
|
||||
if (std::find(modes.cbegin(), modes.cend(), VK_PRESENT_MODE_IMMEDIATE_KHR) != modes.cend())
|
||||
return VK_PRESENT_MODE_IMMEDIATE_KHR;
|
||||
|
||||
forceLog_printf("Vulkan: Can't find immediate present mode");
|
||||
}
|
||||
else if (m_vsync_state == VSync::SYNC_AND_LIMIT)
|
||||
else if (vsyncState == VSync::SYNC_AND_LIMIT)
|
||||
{
|
||||
LatteTiming_EnableHostDrivenVSync();
|
||||
// use immediate mode if available, other wise fall back to
|
||||
|
@ -1991,19 +1991,6 @@ void VulkanRenderer::QueryAvailableFormats()
|
|||
}
|
||||
}
|
||||
|
||||
void VulkanRenderer::EnableVSync(int state)
|
||||
{
|
||||
if (m_vsync_state == (VSync)state)
|
||||
return;
|
||||
|
||||
m_vsync_state = (VSync)state;
|
||||
|
||||
// recreate spawn chains (vsync state is checked from config in ChooseSwapPresentMode)
|
||||
RecreateSwapchain(true);
|
||||
if (m_padSwapchainInfo)
|
||||
RecreateSwapchain(false);
|
||||
}
|
||||
|
||||
bool VulkanRenderer::ImguiBegin(bool mainWindow)
|
||||
{
|
||||
if (!Renderer::ImguiBegin(mainWindow))
|
||||
|
@ -2962,6 +2949,16 @@ void VulkanRenderer::RecreateSwapchain(bool main_window)
|
|||
ImguiInit();
|
||||
}
|
||||
|
||||
void VulkanRenderer::UpdateVSyncState(bool main_window)
|
||||
{
|
||||
auto& swapInfo = main_window ? *m_mainSwapchainInfo : *m_padSwapchainInfo;
|
||||
const auto configValue = (VSync)GetConfig().vsync.GetValue();
|
||||
if(swapInfo.m_activeVSyncState != configValue){
|
||||
RecreateSwapchain(main_window);
|
||||
swapInfo.m_activeVSyncState = configValue;
|
||||
}
|
||||
}
|
||||
|
||||
void VulkanRenderer::SwapBuffer(bool main_window)
|
||||
{
|
||||
auto& swapInfo = main_window ? *m_mainSwapchainInfo : *m_padSwapchainInfo;
|
||||
|
@ -2999,6 +2996,8 @@ void VulkanRenderer::SwapBuffer(bool main_window)
|
|||
}
|
||||
}
|
||||
|
||||
UpdateVSyncState(main_window);
|
||||
|
||||
auto& swapinfo = main_window ? *m_mainSwapchainInfo : *m_padSwapchainInfo;
|
||||
AcquireNextSwapchainImage(main_window);
|
||||
|
||||
|
|
|
@ -195,8 +195,6 @@ public:
|
|||
void QueryMemoryInfo();
|
||||
void QueryAvailableFormats();
|
||||
|
||||
void EnableVSync(int state) override;
|
||||
|
||||
#if BOOST_OS_WINDOWS
|
||||
static VkSurfaceKHR CreateWinSurface(VkInstance instance, HWND hwindow);
|
||||
#endif
|
||||
|
@ -466,6 +464,7 @@ private:
|
|||
VkExtent2D swapchainExtend{};
|
||||
uint32 swapchainImageIndex = (uint32)-1;
|
||||
uint32 m_acquireIndex = 0; // increases with every successful vkAcquireNextImageKHR
|
||||
VSync m_activeVSyncState = VSync::Immediate;
|
||||
|
||||
struct AcquireInfo
|
||||
{
|
||||
|
@ -557,8 +556,8 @@ private:
|
|||
static bool CheckDeviceExtensionSupport(const VkPhysicalDevice device, FeatureControl& info);
|
||||
static std::vector<const char*> CheckInstanceExtensionSupport(FeatureControl& info);
|
||||
|
||||
void UpdateVSyncState(bool main_window);
|
||||
void SwapBuffer(bool main_window);
|
||||
VSync m_vsync_state = VSync::Immediate;
|
||||
|
||||
struct SwapChainSupportDetails
|
||||
{
|
||||
|
|
|
@ -1334,8 +1334,9 @@ void GeneralSettings2::HandleGraphicsApiSelection()
|
|||
m_vsync->AppendString(_("Off"));
|
||||
m_vsync->AppendString(_("Double buffering"));
|
||||
m_vsync->AppendString(_("Triple buffering"));
|
||||
|
||||
#if BOOST_OS_WINDOWS
|
||||
m_vsync->AppendString(_("Match emulated display (Experimental)"));
|
||||
#endif
|
||||
|
||||
m_vsync->Select(selection);
|
||||
|
||||
|
|
Loading…
Reference in New Issue