mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-25 00:49:47 +00:00
Throttle RGUI with timers.
Some drivers have broken VSync and without audio blocking, RGUI can blast away at 1k+ FPS making it unusable.
This commit is contained in:
parent
e60f907ec6
commit
73016a2752
@ -577,6 +577,8 @@ void menu_init(void)
|
||||
RARCH_LOG("[RGUI]: Opening history: %s.\n", history_path);
|
||||
rgui->history = rom_history_init(history_path, g_settings.game_history_size);
|
||||
}
|
||||
|
||||
rgui->last_time = rarch_get_time_usec();
|
||||
}
|
||||
|
||||
void menu_free(void)
|
||||
@ -829,6 +831,15 @@ bool menu_iterate(void)
|
||||
|
||||
rarch_render_cached_frame();
|
||||
|
||||
// Throttle in case VSync is broken (avoid 1000+ FPS RGUI).
|
||||
rarch_time_t time = rarch_get_time_usec();
|
||||
rarch_time_t delta = (time - rgui->last_time) / 1000;
|
||||
rarch_time_t target_msec = 1000 / g_settings.video.refresh_rate;
|
||||
rarch_time_t sleep_msec = target_msec - delta;
|
||||
if (sleep_msec > 0)
|
||||
rarch_sleep(sleep_msec);
|
||||
rgui->last_time = rarch_get_time_usec();
|
||||
|
||||
if (driver.video_poke && driver.video_poke->set_texture_enable)
|
||||
driver.video_poke->set_texture_enable(driver.video_data, false,
|
||||
MENU_TEXTURE_FULLSCREEN);
|
||||
|
@ -262,6 +262,7 @@ typedef struct
|
||||
unsigned current_pad;
|
||||
|
||||
rom_history_t *history;
|
||||
rarch_time_t last_time; // Used to throttle RGUI in case VSync is broken.
|
||||
} rgui_handle_t;
|
||||
|
||||
extern rgui_handle_t *rgui;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "../../dynamic.h"
|
||||
#include "../../compat/posix_string.h"
|
||||
#include "../../gfx/shader_parse.h"
|
||||
#include "../../performance.h"
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
#include "../../gfx/gl_common.h"
|
||||
|
Loading…
Reference in New Issue
Block a user