Use more efficient sleep approach on Windows when low-processor mode is enabled
This aims to fix the idle CPU utilization regression from 4.3 to 4.4
by reverting to the previous approach, but only when low-processor mode
is enabled.
(cherry picked from commit 03b4e0dd58)
This commit is contained in:
committed by
Rémi Verschelde
parent
ccb325f0bc
commit
40e3cec9e0
@ -2340,6 +2340,7 @@ void OS_Windows::add_frame_delay(bool p_can_draw) {
|
||||
target_ticks += dynamic_delay;
|
||||
uint64_t current_ticks = get_ticks_usec();
|
||||
|
||||
if (!is_in_low_processor_usage_mode()) {
|
||||
if (target_ticks > current_ticks + delay_resolution) {
|
||||
uint64_t delay_time = target_ticks - current_ticks - delay_resolution;
|
||||
// Make sure we always sleep for a multiple of delay_resolution to avoid overshooting.
|
||||
@ -2353,6 +2354,13 @@ void OS_Windows::add_frame_delay(bool p_can_draw) {
|
||||
while (get_ticks_usec() < target_ticks) {
|
||||
YieldProcessor();
|
||||
}
|
||||
} else {
|
||||
// Use a more relaxed approach for low processor usage mode.
|
||||
// This has worse frame pacing but is more power efficient.
|
||||
if (current_ticks < target_ticks) {
|
||||
delay_usec(target_ticks - current_ticks);
|
||||
}
|
||||
}
|
||||
|
||||
current_ticks = get_ticks_usec();
|
||||
target_ticks = MIN(MAX(target_ticks, current_ticks - dynamic_delay), current_ticks + dynamic_delay);
|
||||
|
||||
Reference in New Issue
Block a user