From 1883d919da92a89a5d647174b41ab366d10a8b2d Mon Sep 17 00:00:00 2001 From: narzoul Date: Sun, 10 Jan 2016 21:00:21 +0100 Subject: [PATCH] Fixed slowdowns caused by palette animation support The vsynced paletted update is causing performance problems in games that frequently update the palette outside of a palette animation loop, e.g. StarCraft. Vsync has been removed from the palette update, and instead a primary surface synchronization is forced on the main thread, which still seems to preserve the palette fade-in/fade-out effects in Fallout. Perhaps only the small delay introduced by the sync was needed? (Seems it would work with Sleep(1) too). --- DDrawCompat/Config.h | 1 - DDrawCompat/RealPrimarySurface.cpp | 23 ++--------------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/DDrawCompat/Config.h b/DDrawCompat/Config.h index ffa2da1..e976559 100644 --- a/DDrawCompat/Config.h +++ b/DDrawCompat/Config.h @@ -6,5 +6,4 @@ namespace Config { const DWORD minRefreshInterval = 1000 / 60; const DWORD minRefreshIntervalAfterFlip = 1000 / 10; - const DWORD minPaletteUpdateInterval = 1000 / 60; } diff --git a/DDrawCompat/RealPrimarySurface.cpp b/DDrawCompat/RealPrimarySurface.cpp index 28b8cdf..2c7baf3 100644 --- a/DDrawCompat/RealPrimarySurface.cpp +++ b/DDrawCompat/RealPrimarySurface.cpp @@ -361,10 +361,7 @@ void RealPrimarySurface::setPalette(LPDIRECTDRAWPALETTE palette) } } - if (palette) - { - updatePalette(); - } + updatePalette(); } void RealPrimarySurface::update() @@ -376,21 +373,5 @@ void RealPrimarySurface::update() void RealPrimarySurface::updatePalette() { CompatGdi::updatePalette(); - - if (isFullScreen()) - { - flip(DDFLIP_WAIT); - } - else - { - update(); - } - - static LARGE_INTEGER lastUpdateTime = {}; - DWORD timeSinceLastUpdate = getTimeElapsedInMs(lastUpdateTime); - if (timeSinceLastUpdate < Config::minPaletteUpdateInterval) - { - Sleep(Config::minPaletteUpdateInterval - timeSinceLastUpdate); - } - QueryPerformanceCounter(&lastUpdateTime); + updateNow(); }