diff options
Diffstat (limited to 'src/common/windows/timer_resolution.cpp')
| -rw-r--r-- | src/common/windows/timer_resolution.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/common/windows/timer_resolution.cpp b/src/common/windows/timer_resolution.cpp index 29c6e5c7e1..1fb985b735 100644 --- a/src/common/windows/timer_resolution.cpp +++ b/src/common/windows/timer_resolution.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -62,14 +65,15 @@ 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)); + static auto pf = (decltype(&SetProcessInformation))(void*)GetProcAddress(GetModuleHandle(TEXT("Kernel32.dll")), "SetProcessInformation"); + if (pf) { + PROCESS_POWER_THROTTLING_STATE PowerThrottling{ + .Version = PROCESS_POWER_THROTTLING_CURRENT_VERSION, + .ControlMask = PROCESS_POWER_THROTTLING_EXECUTION_SPEED | PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION, + .StateMask = 0, + }; + pf(GetCurrentProcess(), ProcessPowerThrottling, &PowerThrottling, sizeof(PROCESS_POWER_THROTTLING_STATE)); // Windows 7+ + } } } // Anonymous namespace |
