GPUDevice: Add support for VRR and relaxed vsync

This commit is contained in:
Stenzek
2024-03-03 12:25:37 +10:00
parent d9e496284f
commit a1d7d214cf
27 changed files with 474 additions and 364 deletions

View File

@ -1060,11 +1060,6 @@ std::string D3D12Device::GetDriverInfo() const
return ret;
}
void D3D12Device::SetVSync(bool enabled)
{
m_vsync_enabled = enabled;
}
bool D3D12Device::BeginPresent(bool frame_skip)
{
if (InRenderPass())
@ -1112,10 +1107,13 @@ void D3D12Device::EndPresent()
SubmitCommandList(false);
if (!m_vsync_enabled && m_using_allow_tearing)
// DirectX has no concept of tear-or-sync. I guess if we measured times ourselves, we could implement it.
if (m_sync_mode == DisplaySyncMode::VSync || m_sync_mode == DisplaySyncMode::VSyncRelaxed)
m_swap_chain->Present(BoolToUInt32(1), 0);
else if (m_using_allow_tearing) // Disabled or VRR, VRR requires the allow tearing flag :/
m_swap_chain->Present(0, DXGI_PRESENT_ALLOW_TEARING);
else
m_swap_chain->Present(static_cast<UINT>(m_vsync_enabled), 0);
m_swap_chain->Present(0, 0);
TrimTexturePool();
}