diff options
author | Juan Linietsky <reduzio@gmail.com> | 2019-01-22 16:03:49 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2019-01-22 16:04:54 -0300 |
commit | ab843b16984d8b62a1100d9b77d8b0dcdc4252bb (patch) | |
tree | a709dd00915f83773fe3adbd63cd096ec24fb975 /platform/windows/os_windows.cpp | |
parent | 6a187f639511726583db05f8cd80957b1f936d03 (diff) | |
download | redot-engine-ab843b16984d8b62a1100d9b77d8b0dcdc4252bb.tar.gz |
Raised executable priority on windows to avoid stuter, helps #25162
Diffstat (limited to 'platform/windows/os_windows.cpp')
-rw-r--r-- | platform/windows/os_windows.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index d1693cb0b4..9fd372fd98 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -50,6 +50,7 @@ #include "servers/visual/visual_server_raster.h" #include "servers/visual/visual_server_wrap_mt.h" #include "windows_terminal_logger.h" +#include <avrt.h> #include <process.h> #include <regstr.h> @@ -1373,6 +1374,19 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int set_ime_active(false); + if (!OS::get_singleton()->is_in_low_processor_usage_mode()) { + //SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS); + SetPriorityClass(GetCurrentProcess(), ABOVE_NORMAL_PRIORITY_CLASS); + DWORD index = 0; + HANDLE handle = AvSetMmThreadCharacteristics("Games", &index); + if (handle) + AvSetMmThreadPriority(handle, AVRT_PRIORITY_CRITICAL); + + // This is needed to make sure that background work does not starve the main thread. + // This is only setting priority of this thread, not the whole process. + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); + } + return OK; } |