From e6d8f0d4a03a63dc25899c9dde4b8340030eccb9 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 25 May 2024 13:15:40 +1000 Subject: [PATCH] GPUDevice: Use FIFO for D3D exclusive fullscreen --- src/util/d3d11_device.cpp | 14 ++++++++++++++ src/util/d3d12_device.cpp | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/util/d3d11_device.cpp b/src/util/d3d11_device.cpp index 73573ccec..e215275c9 100644 --- a/src/util/d3d11_device.cpp +++ b/src/util/d3d11_device.cpp @@ -226,6 +226,13 @@ bool D3D11Device::CreateSwapChain() D3DCommon::GetRequestedExclusiveFullscreenModeDesc(m_dxgi_factory.Get(), client_rc, fullscreen_width, fullscreen_height, fullscreen_refresh_rate, dxgi_format, &fullscreen_mode, fullscreen_output.GetAddressOf()); + + // Using mailbox-style no-allow-tearing causes tearing in exclusive fullscreen. + if (m_vsync_mode == GPUVSyncMode::Mailbox && m_is_exclusive_fullscreen) + { + WARNING_LOG("Using FIFO instead of Mailbox vsync due to exclusive fullscreen."); + m_vsync_mode = GPUVSyncMode::FIFO; + } } else { @@ -592,6 +599,13 @@ void D3D11Device::SetVSyncMode(GPUVSyncMode mode, bool allow_present_throttle) { m_allow_present_throttle = allow_present_throttle; + // Using mailbox-style no-allow-tearing causes tearing in exclusive fullscreen. + if (mode == GPUVSyncMode::Mailbox && m_is_exclusive_fullscreen) + { + WARNING_LOG("Using FIFO instead of Mailbox vsync due to exclusive fullscreen."); + mode = GPUVSyncMode::FIFO; + } + if (m_vsync_mode == mode) return; diff --git a/src/util/d3d12_device.cpp b/src/util/d3d12_device.cpp index a9bae63d7..dfe1eb7be 100644 --- a/src/util/d3d12_device.cpp +++ b/src/util/d3d12_device.cpp @@ -826,6 +826,13 @@ bool D3D12Device::CreateSwapChain() D3DCommon::GetRequestedExclusiveFullscreenModeDesc(m_dxgi_factory.Get(), client_rc, fullscreen_width, fullscreen_height, fullscreen_refresh_rate, fm.resource_format, &fullscreen_mode, fullscreen_output.GetAddressOf()); + + // Using mailbox-style no-allow-tearing causes tearing in exclusive fullscreen. + if (m_vsync_mode == GPUVSyncMode::Mailbox && m_is_exclusive_fullscreen) + { + WARNING_LOG("Using FIFO instead of Mailbox vsync due to exclusive fullscreen."); + m_vsync_mode = GPUVSyncMode::FIFO; + } } else { @@ -1087,6 +1094,14 @@ std::string D3D12Device::GetDriverInfo() const void D3D12Device::SetVSyncMode(GPUVSyncMode mode, bool allow_present_throttle) { m_allow_present_throttle = allow_present_throttle; + + // Using mailbox-style no-allow-tearing causes tearing in exclusive fullscreen. + if (mode == GPUVSyncMode::Mailbox && m_is_exclusive_fullscreen) + { + WARNING_LOG("Using FIFO instead of Mailbox vsync due to exclusive fullscreen."); + mode = GPUVSyncMode::FIFO; + } + if (m_vsync_mode == mode) return;