From a6639da9eae675d24bd536604a82ce8227920c28 Mon Sep 17 00:00:00 2001 From: ShokerStlk Date: Tue, 21 Feb 2017 20:06:25 +0300 Subject: [PATCH] Fixed VSync for all renderers. Thnx to avbaula. --- src/Layers/xrRender/HW.cpp | 14 ++++++++++++-- src/Layers/xrRender/r__dsgraph_build.cpp | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Layers/xrRender/HW.cpp b/src/Layers/xrRender/HW.cpp index 7c24e9af633..dad498677dd 100644 --- a/src/Layers/xrRender/HW.cpp +++ b/src/Layers/xrRender/HW.cpp @@ -53,11 +53,16 @@ void CHW::Reset(HWND hwnd) // Windoze DevPP.SwapEffect = bWindowed ? D3DSWAPEFFECT_COPY : D3DSWAPEFFECT_DISCARD; DevPP.Windowed = bWindowed; - DevPP.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; if (!bWindowed) + { + DevPP.PresentationInterval = selectPresentInterval(); // Vsync (R1\R2) DevPP.FullScreen_RefreshRateInHz = selectRefresh(DevPP.BackBufferWidth, DevPP.BackBufferHeight, Caps.fTarget); + } else + { + DevPP.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; DevPP.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; + } #endif while (TRUE) @@ -339,11 +344,16 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window) P.Flags = 0; //. D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL; // Refresh rate - P.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; if (!bWindowed) + { + P.PresentationInterval = selectPresentInterval(); // Vsync (R1\R2) P.FullScreen_RefreshRateInHz = selectRefresh(P.BackBufferWidth, P.BackBufferHeight, fTarget); + } else + { + P.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; P.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; + } // Create the device u32 GPU = selectGPU(); diff --git a/src/Layers/xrRender/r__dsgraph_build.cpp b/src/Layers/xrRender/r__dsgraph_build.cpp index 7cb0510126c..cfa858dfdac 100644 --- a/src/Layers/xrRender/r__dsgraph_build.cpp +++ b/src/Layers/xrRender/r__dsgraph_build.cpp @@ -1161,7 +1161,8 @@ void D3DXRenderBase::End() Memory.dbg_check(); DoAsyncScreenshot(); #if defined(USE_DX10) || defined(USE_DX11) - HW.m_pSwapChain->Present(0, 0); + bool bUseVSync = psDeviceFlags.is(rsFullscreen) && psDeviceFlags.test(rsVSync); //xxx: weird tearing glitches when VSync turned on for windowed mode in DX10\11 + HW.m_pSwapChain->Present(bUseVSync ? 1 : 0, 0); #else CHK_DX(HW.pDevice->EndScene()); HW.pDevice->Present(NULL, NULL, NULL, NULL);