Skip to content

Commit a6639da

Browse files
ShokerStlkCrossVR
authored andcommitted
Fixed VSync for all renderers. Thnx to avbaula.
1 parent 8c9220e commit a6639da

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/Layers/xrRender/HW.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,16 @@ void CHW::Reset(HWND hwnd)
5353
// Windoze
5454
DevPP.SwapEffect = bWindowed ? D3DSWAPEFFECT_COPY : D3DSWAPEFFECT_DISCARD;
5555
DevPP.Windowed = bWindowed;
56-
DevPP.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
5756
if (!bWindowed)
57+
{
58+
DevPP.PresentationInterval = selectPresentInterval(); // Vsync (R1\R2)
5859
DevPP.FullScreen_RefreshRateInHz = selectRefresh(DevPP.BackBufferWidth, DevPP.BackBufferHeight, Caps.fTarget);
60+
}
5961
else
62+
{
63+
DevPP.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
6064
DevPP.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
65+
}
6166
#endif
6267

6368
while (TRUE)
@@ -339,11 +344,16 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window)
339344
P.Flags = 0; //. D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL;
340345

341346
// Refresh rate
342-
P.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
343347
if (!bWindowed)
348+
{
349+
P.PresentationInterval = selectPresentInterval(); // Vsync (R1\R2)
344350
P.FullScreen_RefreshRateInHz = selectRefresh(P.BackBufferWidth, P.BackBufferHeight, fTarget);
351+
}
345352
else
353+
{
354+
P.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
346355
P.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
356+
}
347357

348358
// Create the device
349359
u32 GPU = selectGPU();

src/Layers/xrRender/r__dsgraph_build.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,8 @@ void D3DXRenderBase::End()
11611161
Memory.dbg_check();
11621162
DoAsyncScreenshot();
11631163
#if defined(USE_DX10) || defined(USE_DX11)
1164-
HW.m_pSwapChain->Present(0, 0);
1164+
bool bUseVSync = psDeviceFlags.is(rsFullscreen) && psDeviceFlags.test(rsVSync); //xxx: weird tearing glitches when VSync turned on for windowed mode in DX10\11
1165+
HW.m_pSwapChain->Present(bUseVSync ? 1 : 0, 0);
11651166
#else
11661167
CHK_DX(HW.pDevice->EndScene());
11671168
HW.pDevice->Present(NULL, NULL, NULL, NULL);

0 commit comments

Comments
 (0)