Skip to content

Commit

Permalink
Menu throttling adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
sonninnos committed Jan 1, 2023
1 parent c0bdf44 commit 74d4320
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion menu/menu_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -6783,7 +6783,8 @@ void menu_driver_toggle(

/* Menu should always run with vsync on and
* a video swap interval of 1 */
if (current_video->set_nonblock_state)
if ( settings->bools.menu_throttle_framerate
&& current_video->set_nonblock_state)
{
current_video->set_nonblock_state(
video_driver_data,
Expand Down
19 changes: 19 additions & 0 deletions runloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -7145,6 +7145,25 @@ static enum runloop_state_enum runloop_check_state(
float fastforward_ratio = runloop_get_fastforward_ratio(settings,
&runloop_st->fastmotion_override.current);

/* Sleep half frame time when menu pause is enabled to
* keep framerate under reasonable levels without vsync, but
* sleep regardless of vsync to keep CPU usage and temperature
* lower with GL when vsync is on */
if (settings->bools.menu_pause_libretro)
{
float refresh_rate = video_driver_get_refresh_rate();
uint8_t sleep = 0;

if (refresh_rate == 0.0f)
refresh_rate = settings->floats.video_refresh_rate;

if (refresh_rate > 0)
{
sleep = 1000000 / refresh_rate / 2 / 1000;
retro_sleep(sleep);
}
}

if (!settings->bools.menu_throttle_framerate && !fastforward_ratio)
return RUNLOOP_STATE_MENU_ITERATE;

Expand Down

0 comments on commit 74d4320

Please sign in to comment.