Skip to content

Commit

Permalink
Fixed VSync for all renderers. Thnx to avbaula.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShokerStlk authored and CrossVR committed Mar 7, 2017
1 parent 8c9220e commit a6639da
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/Layers/xrRender/HW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion src/Layers/xrRender/r__dsgraph_build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a6639da

Please sign in to comment.