From c78c7c927fac5517560857c9ed22ef8afe9f340c Mon Sep 17 00:00:00 2001 From: narzoul Date: Sun, 3 Apr 2016 15:13:38 +0200 Subject: [PATCH] Aligned usage of flip between compat and real primary surface chains Using flip for direct front buffer updates can cause performance problems if the driver forces vertical sync and overrides the DDFLIP_NOVSYNC flag. On the other hand, DDFLIP_NOVSYNC flip requests on the compat primary surface should be handled via real flip to allow vertical sync override. --- DDrawCompat/RealPrimarySurface.cpp | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/DDrawCompat/RealPrimarySurface.cpp b/DDrawCompat/RealPrimarySurface.cpp index 9e8d1b0..71eee3c 100644 --- a/DDrawCompat/RealPrimarySurface.cpp +++ b/DDrawCompat/RealPrimarySurface.cpp @@ -64,6 +64,14 @@ namespace CompatPaletteConverter::unlockDc(); CompatPaletteConverter::unlockSurface(); + + if (dest == g_frontBuffer) + { + // Force the screen to be updated. It won't refresh from BitBlt alone. + RECT r = { 0, 0, 1, 1 }; + CompatDirectDrawSurface::s_origVtable.BltFast( + g_frontBuffer, 0, 0, g_frontBuffer, &r, DDBLTFAST_WAIT); + } } else { @@ -99,18 +107,7 @@ namespace void updateNow() { QueryPerformanceCounter(&g_lastUpdateTime); - - if (g_backBuffer) - { - if (compatBlt(g_backBuffer)) - { - g_frontBuffer->lpVtbl->Flip(g_frontBuffer, nullptr, DDFLIP_NOVSYNC | DDFLIP_WAIT); - } - } - else - { - compatBlt(g_frontBuffer); - } + compatBlt(g_frontBuffer); } DWORD WINAPI updateThreadProc(LPVOID /*lpParameter*/) @@ -235,12 +232,6 @@ HRESULT RealPrimarySurface::flip(DWORD flags) return DDERR_NOTFLIPPABLE; } - if (flags & DDFLIP_NOVSYNC) - { - update(); - return DD_OK; - } - compatBlt(g_backBuffer); if (flags & DDFLIP_DONOTWAIT) {