From ce31ac361c6c222b17bb8bcda9d8a777f16646b4 Mon Sep 17 00:00:00 2001 From: gigaherz Date: Wed, 11 Nov 2009 03:56:14 +0000 Subject: [PATCH] Implemented a feature which could potentially reduce the slight slowdowns present when running in windowed mode inside Aero. Since it's late, I will leave it to the world to figure out of it really makes a difference. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2183 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/gui/AppInit.cpp | 5 +++ pcsx2/gui/MainFrame.cpp | 1 - pcsx2/windows/DwmSetup.cpp | 48 ++++++++++++++++++++++ pcsx2/windows/VCprojects/pcsx2_2008.vcproj | 7 +++- 4 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 pcsx2/windows/DwmSetup.cpp diff --git a/pcsx2/gui/AppInit.cpp b/pcsx2/gui/AppInit.cpp index baa971ae47..d630cdce15 100644 --- a/pcsx2/gui/AppInit.cpp +++ b/pcsx2/gui/AppInit.cpp @@ -294,6 +294,11 @@ bool Pcsx2App::OnInit() SysDetect(); AppApplySettings(); +#ifdef __WIN32__ + extern void SetupDwmStuff(WXHWND hMainWindow); + SetupDwmStuff(m_MainFrame->GetHWND()); +#endif + m_CoreAllocs = new SysCoreAllocations(); if( m_CoreAllocs->HadSomeFailures( g_Conf->EmuOptions.Cpu.Recompiler ) ) diff --git a/pcsx2/gui/MainFrame.cpp b/pcsx2/gui/MainFrame.cpp index 9455ac3a4f..e318b10972 100644 --- a/pcsx2/gui/MainFrame.cpp +++ b/pcsx2/gui/MainFrame.cpp @@ -269,7 +269,6 @@ MainEmuFrame::MainEmuFrame(wxWindow* parent, const wxString& title): m_Listener_SettingsApplied( wxGetApp().Source_SettingsApplied(), EventListener( this, OnSettingsApplied ) ), m_Listener_SettingsLoadSave( wxGetApp().Source_SettingsLoadSave(), EventListener( this, OnSettingsLoadSave ) ) { - for( int i=0; i +#include "Utilities/Console.h" + +// This could potentially reduce lag while running in Aero, +// by telling the DWM the application requires +// multimedia-class scheduling for smooth display. +void SetupDwmStuff(WXHWND hMainWindow) +{ + HRESULT (WINAPI * pDwmEnableMMCSS)(DWORD); + + OSVERSIONINFOEX info = {0}; + info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + info.dwMajorVersion = 6; + + DWORDLONG mask=0; + VER_SET_CONDITION(mask,VER_MAJORVERSION, VER_GREATER_EQUAL); + VER_SET_CONDITION(mask,VER_MINORVERSION, VER_GREATER_EQUAL); + VER_SET_CONDITION(mask,VER_SERVICEPACKMAJOR,VER_GREATER_EQUAL); + VER_SET_CONDITION(mask,VER_SERVICEPACKMINOR,VER_GREATER_EQUAL); + + //info + if(VerifyVersionInfo(&info, + VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR|VER_SERVICEPACKMINOR, + mask)) + { + HMODULE hDwmapi = LoadLibrary(wxT("dwmapi.dll")); + if(hDwmapi) + { + pDwmEnableMMCSS = (HRESULT (WINAPI *)(DWORD))GetProcAddress(hDwmapi,"DwmEnableMMCSS"); + if(pDwmEnableMMCSS) + { + if(FAILED(pDwmEnableMMCSS(TRUE))) + { + Console.WriteLn("Warning: DwmEnableMMCSS returned a failure code (not an error)."); + } + else + { + Console.WriteLn("DwmEnableMMCSS successful."); + } + } + + //DwmSetDxFrameDuration(hMainWindow,1); + + FreeLibrary(hDwmapi); + } + } +} \ No newline at end of file diff --git a/pcsx2/windows/VCprojects/pcsx2_2008.vcproj b/pcsx2/windows/VCprojects/pcsx2_2008.vcproj index d07eec9b82..dcf8626c2e 100644 --- a/pcsx2/windows/VCprojects/pcsx2_2008.vcproj +++ b/pcsx2/windows/VCprojects/pcsx2_2008.vcproj @@ -1,7 +1,7 @@ @@ -2477,6 +2476,10 @@ + +