summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2023-03-04 02:54:15 +0100
committerMorph <39850852+Morph1984@users.noreply.github.com>2023-03-05 08:36:31 +0100
commit026eaddbeef4d0a4992fb19b40af9242f09c3c6a (patch)
treed275b240a3871e5c7aa4ed944a6e8f3f3b3b79c3 /src
parentgeneral: Target Windows 10 SDK (diff)
downloadyuzu-026eaddbeef4d0a4992fb19b40af9242f09c3c6a.tar
yuzu-026eaddbeef4d0a4992fb19b40af9242f09c3c6a.tar.gz
yuzu-026eaddbeef4d0a4992fb19b40af9242f09c3c6a.tar.bz2
yuzu-026eaddbeef4d0a4992fb19b40af9242f09c3c6a.tar.lz
yuzu-026eaddbeef4d0a4992fb19b40af9242f09c3c6a.tar.xz
yuzu-026eaddbeef4d0a4992fb19b40af9242f09c3c6a.tar.zst
yuzu-026eaddbeef4d0a4992fb19b40af9242f09c3c6a.zip
Diffstat (limited to '')
-rw-r--r--src/common/windows/timer_resolution.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/common/windows/timer_resolution.cpp b/src/common/windows/timer_resolution.cpp
index 6c2063a4c..29c6e5c7e 100644
--- a/src/common/windows/timer_resolution.cpp
+++ b/src/common/windows/timer_resolution.cpp
@@ -18,6 +18,15 @@ NTSYSAPI LONG NTAPI NtSetTimerResolution(ULONG DesiredResolution, BOOLEAN SetRes
NTSYSAPI LONG NTAPI NtDelayExecution(BOOLEAN Alertable, PLARGE_INTEGER DelayInterval);
}
+// Defines for compatibility with older Windows 10 SDKs.
+
+#ifndef PROCESS_POWER_THROTTLING_EXECUTION_SPEED
+#define PROCESS_POWER_THROTTLING_EXECUTION_SPEED 0x1
+#endif
+#ifndef PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION
+#define PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION 0x4
+#endif
+
namespace Common::Windows {
namespace {
@@ -51,6 +60,18 @@ TimerResolution GetTimerResolution() {
};
}
+void SetHighQoS() {
+ // https://learn.microsoft.com/en-us/windows/win32/procthread/quality-of-service
+ PROCESS_POWER_THROTTLING_STATE PowerThrottling{
+ .Version{PROCESS_POWER_THROTTLING_CURRENT_VERSION},
+ .ControlMask{PROCESS_POWER_THROTTLING_EXECUTION_SPEED |
+ PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION},
+ .StateMask{},
+ };
+ SetProcessInformation(GetCurrentProcess(), ProcessPowerThrottling, &PowerThrottling,
+ sizeof(PROCESS_POWER_THROTTLING_STATE));
+}
+
} // Anonymous namespace
nanoseconds GetMinimumTimerResolution() {
@@ -74,6 +95,7 @@ nanoseconds SetCurrentTimerResolution(nanoseconds timer_resolution) {
}
nanoseconds SetCurrentTimerResolutionToMaximum() {
+ SetHighQoS();
return SetCurrentTimerResolution(GetMaximumTimerResolution());
}