1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 12:12:50 +01:00

Set Windows timer resolution to 0,5ms (#4579)

* Fix for https://github.com/RPCS3/rpcs3/issues/4569
(Win 10 update 1803 performance regression)
This commit is contained in:
pauls-gh 2018-05-17 04:00:22 -07:00 committed by Ivan
parent 2eae06454b
commit fdef77d779
3 changed files with 18 additions and 7 deletions

View File

@ -24,6 +24,7 @@
#include <unordered_map> #include <unordered_map>
#ifdef _WIN32 #ifdef _WIN32
DYNAMIC_IMPORT("ntdll.dll", NtQueryTimerResolution, NTSTATUS(PULONG MinimumResolution, PULONG MaximumResolution, PULONG CurrentResolution));
DYNAMIC_IMPORT("ntdll.dll", NtSetTimerResolution, NTSTATUS(ULONG DesiredResolution, BOOLEAN SetResolution, PULONG CurrentResolution)); DYNAMIC_IMPORT("ntdll.dll", NtSetTimerResolution, NTSTATUS(ULONG DesiredResolution, BOOLEAN SetResolution, PULONG CurrentResolution));
DYNAMIC_IMPORT("ntdll.dll", NtWaitForKeyedEvent, NTSTATUS(HANDLE Handle, PVOID Key, BOOLEAN Alertable, PLARGE_INTEGER Timeout)); DYNAMIC_IMPORT("ntdll.dll", NtWaitForKeyedEvent, NTSTATUS(HANDLE Handle, PVOID Key, BOOLEAN Alertable, PLARGE_INTEGER Timeout));
DYNAMIC_IMPORT("ntdll.dll", NtReleaseKeyedEvent, NTSTATUS(HANDLE Handle, PVOID Key, BOOLEAN Alertable, PLARGE_INTEGER Timeout)); DYNAMIC_IMPORT("ntdll.dll", NtReleaseKeyedEvent, NTSTATUS(HANDLE Handle, PVOID Key, BOOLEAN Alertable, PLARGE_INTEGER Timeout));

View File

@ -79,13 +79,6 @@ int main(int argc, char** argv)
// I think there was an issue with gsframe if I recall correctly, so look out for that // I think there was an issue with gsframe if I recall correctly, so look out for that
//QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); //QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
SetProcessDPIAware(); SetProcessDPIAware();
timeBeginPeriod(1);
atexit([]
{
timeEndPeriod(1);
});
#else #else
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1"); qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1");
#endif #endif

View File

@ -57,6 +57,12 @@
#include "Emu/Audio/Pulse/PulseThread.h" #include "Emu/Audio/Pulse/PulseThread.h"
#endif #endif
#ifdef _WIN32
#include "Utilities/dynamic_library.h"
DYNAMIC_IMPORT("ntdll.dll", NtQueryTimerResolution, NTSTATUS(PULONG MinimumResolution, PULONG MaximumResolution, PULONG CurrentResolution));
DYNAMIC_IMPORT("ntdll.dll", NtSetTimerResolution, NTSTATUS(ULONG DesiredResolution, BOOLEAN SetResolution, PULONG CurrentResolution));
#endif
// For now, a trivial constructor/destructor. May add command line usage later. // For now, a trivial constructor/destructor. May add command line usage later.
rpcs3_app::rpcs3_app(int& argc, char** argv) : QApplication(argc, argv) rpcs3_app::rpcs3_app(int& argc, char** argv) : QApplication(argc, argv)
{ {
@ -101,6 +107,17 @@ void rpcs3_app::Init()
Discord_Initialize("424004941485572097", &handlers, 1, NULL); Discord_Initialize("424004941485572097", &handlers, 1, NULL);
} }
#endif #endif
#ifdef _WIN32
// Set 0.5 msec timer resolution for best performance
// - As QT5 timers (QTimer) sets the timer resolution to 1 msec, override it here.
// - Don't bother "unsetting" the timer resolution after the emulator stops as QT5 will still require the timer resolution to be set to 1 msec.
ULONG min_res, max_res, orig_res, new_res;
if (NtQueryTimerResolution(&min_res, &max_res, &orig_res) == 0)
{
NtSetTimerResolution(max_res, TRUE, &new_res);
}
#endif
} }
/** RPCS3 emulator has functions it desires to call from the GUI at times. Initialize them in here. /** RPCS3 emulator has functions it desires to call from the GUI at times. Initialize them in here.