System: Combine VRR and Optimal Frame Pacing
GSync/FreeSync display users should: - DISABLE VSync. - ENABLE Optimal Frame Pacing.
This commit is contained in:
@ -2023,7 +2023,7 @@ bool VulkanDevice::CreateDevice(const std::string_view& adapter, bool threaded_p
|
||||
|
||||
if (surface != VK_NULL_HANDLE)
|
||||
{
|
||||
m_swap_chain = VulkanSwapChain::Create(m_window_info, surface, m_sync_mode, m_exclusive_fullscreen_control);
|
||||
m_swap_chain = VulkanSwapChain::Create(m_window_info, surface, m_vsync_enabled, m_exclusive_fullscreen_control);
|
||||
if (!m_swap_chain)
|
||||
{
|
||||
Error::SetStringView(error, "Failed to create swap chain");
|
||||
@ -2244,7 +2244,7 @@ bool VulkanDevice::UpdateWindow()
|
||||
return false;
|
||||
}
|
||||
|
||||
m_swap_chain = VulkanSwapChain::Create(m_window_info, surface, m_sync_mode, m_exclusive_fullscreen_control);
|
||||
m_swap_chain = VulkanSwapChain::Create(m_window_info, surface, m_vsync_enabled, m_exclusive_fullscreen_control);
|
||||
if (!m_swap_chain)
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create swap chain");
|
||||
@ -2320,22 +2320,21 @@ std::string VulkanDevice::GetDriverInfo() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
void VulkanDevice::SetSyncMode(DisplaySyncMode mode)
|
||||
void VulkanDevice::SetVSyncEnabled(bool enabled)
|
||||
{
|
||||
if (m_sync_mode == mode)
|
||||
if (m_vsync_enabled == enabled)
|
||||
return;
|
||||
|
||||
const DisplaySyncMode prev_mode = m_sync_mode;
|
||||
m_sync_mode = mode;
|
||||
m_vsync_enabled = enabled;
|
||||
if (!m_swap_chain)
|
||||
return;
|
||||
|
||||
// This swap chain should not be used by the current buffer, thus safe to destroy.
|
||||
WaitForGPUIdle();
|
||||
if (!m_swap_chain->SetSyncMode(mode))
|
||||
if (!m_swap_chain->SetVSyncEnabled(enabled))
|
||||
{
|
||||
// Try switching back to the old mode..
|
||||
if (!m_swap_chain->SetSyncMode(prev_mode))
|
||||
if (!m_swap_chain->SetVSyncEnabled(!enabled))
|
||||
{
|
||||
Panic("Failed to reset old vsync mode after failure");
|
||||
m_swap_chain.reset();
|
||||
|
||||
Reference in New Issue
Block a user