From 31a43b93900e9305b293b711452bfb1b5a4a177d Mon Sep 17 00:00:00 2001 From: sonninnos Date: Sun, 12 Jun 2022 10:56:43 +0300 Subject: [PATCH] (D3D11/12) Reduce lag with WaitForVBlank --- gfx/drivers/d3d11.c | 8 ++++++++ gfx/drivers/d3d12.c | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index 1747ba26d8..522a94d9f2 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -2374,6 +2374,14 @@ static bool d3d11_gfx_frame( #endif DXGIPresent(d3d11->swapChain, d3d11->swap_interval, present_flags); + + if (vsync) + { + IDXGIOutput *pOutput; + DXGIGetContainingOutput(d3d11->swapChain, &pOutput); + DXGIWaitForVBlank(pOutput); + } + Release(rtv); return true; diff --git a/gfx/drivers/d3d12.c b/gfx/drivers/d3d12.c index e5cb894e7a..7c202dec87 100644 --- a/gfx/drivers/d3d12.c +++ b/gfx/drivers/d3d12.c @@ -2660,6 +2660,13 @@ static bool d3d12_gfx_frame( #endif DXGIPresent(d3d12->chain.handle, sync_interval, present_flags); + if (vsync) + { + IDXGIOutput *pOutput; + DXGIGetContainingOutput(d3d12->chain.handle, &pOutput); + DXGIWaitForVBlank(pOutput); + } + return true; }