mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 04:20:27 +00:00
Start calling cpu_features_get_time_usec less per frame iteration
This commit is contained in:
parent
795801b1f5
commit
d19dd12b30
@ -1215,6 +1215,7 @@ void gfx_animation_unset_update_time_cb(void)
|
||||
}
|
||||
|
||||
static void gfx_animation_update_time(
|
||||
retro_time_t current_time,
|
||||
bool timedate_enable,
|
||||
unsigned video_width, unsigned video_height,
|
||||
float _ticker_speed)
|
||||
@ -1235,8 +1236,9 @@ static void gfx_animation_update_time(
|
||||
unsigned ticker_slow_speed =
|
||||
(unsigned)(((float)TICKER_SLOW_SPEED / speed_factor) + 0.5);
|
||||
|
||||
/* Note: cur_time & old_time are in us, delta_time is in ms */
|
||||
cur_time = cpu_features_get_time_usec();
|
||||
/* Note: cur_time & old_time are in us (microseconds),
|
||||
* delta_time is in ms */
|
||||
cur_time = current_time;
|
||||
delta_time = old_time == 0 ? 0.0f : (float)(cur_time - old_time) / 1000.0f;
|
||||
old_time = cur_time;
|
||||
|
||||
@ -1307,6 +1309,7 @@ static void gfx_animation_update_time(
|
||||
}
|
||||
|
||||
bool gfx_animation_update(
|
||||
retro_time_t current_time,
|
||||
bool timedate_enable,
|
||||
float ticker_speed,
|
||||
unsigned video_width,
|
||||
@ -1315,6 +1318,7 @@ bool gfx_animation_update(
|
||||
unsigned i;
|
||||
|
||||
gfx_animation_update_time(
|
||||
current_time,
|
||||
timedate_enable,
|
||||
video_width, video_height,
|
||||
ticker_speed);
|
||||
|
@ -201,6 +201,7 @@ void gfx_timer_start(gfx_timer_t *timer, gfx_timer_ctx_entry_t *timer_entry);
|
||||
void gfx_timer_kill(gfx_timer_t *timer);
|
||||
|
||||
bool gfx_animation_update(
|
||||
retro_time_t current_time,
|
||||
bool timedate_enable,
|
||||
float ticker_speed,
|
||||
unsigned video_width,
|
||||
|
20
retroarch.c
20
retroarch.c
@ -27205,7 +27205,7 @@ static void update_fastforwarding_state(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static enum runloop_state runloop_check_state(void)
|
||||
static enum runloop_state runloop_check_state(retro_time_t current_time)
|
||||
{
|
||||
input_bits_t current_bits;
|
||||
#ifdef HAVE_MENU
|
||||
@ -27364,7 +27364,7 @@ static enum runloop_state runloop_check_state(void)
|
||||
if (trig_quit_key && settings->bools.quit_press_twice)
|
||||
{
|
||||
static retro_time_t quit_key_time = 0;
|
||||
retro_time_t cur_time = cpu_features_get_time_usec();
|
||||
retro_time_t cur_time = current_time;
|
||||
trig_quit_key = (cur_time - quit_key_time < QUIT_DELAY_USEC);
|
||||
quit_key_time = cur_time;
|
||||
|
||||
@ -27450,6 +27450,7 @@ static enum runloop_state runloop_check_state(void)
|
||||
|
||||
#if defined(HAVE_MENU) || defined(HAVE_GFX_WIDGETS)
|
||||
gfx_animation_update(
|
||||
current_time,
|
||||
settings->bools.menu_timedate_enable,
|
||||
settings->floats.menu_ticker_speed,
|
||||
video_driver_width, video_driver_height);
|
||||
@ -27494,7 +27495,7 @@ static enum runloop_state runloop_check_state(void)
|
||||
{
|
||||
if (action == old_action)
|
||||
{
|
||||
retro_time_t press_time = cpu_features_get_time_usec();
|
||||
retro_time_t press_time = current_time;
|
||||
|
||||
if (action == MENU_ACTION_NOOP)
|
||||
global->menu.noop_press_time = press_time - global->menu.noop_start_time;
|
||||
@ -27505,13 +27506,13 @@ static enum runloop_state runloop_check_state(void)
|
||||
{
|
||||
if (action == MENU_ACTION_NOOP)
|
||||
{
|
||||
global->menu.noop_start_time = cpu_features_get_time_usec();
|
||||
global->menu.noop_start_time = current_time;
|
||||
global->menu.noop_press_time = 0;
|
||||
|
||||
if (global->menu.prev_action == old_action)
|
||||
global->menu.action_start_time = global->menu.prev_start_time;
|
||||
else
|
||||
global->menu.action_start_time = cpu_features_get_time_usec();
|
||||
global->menu.action_start_time = current_time;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -27519,11 +27520,11 @@ static enum runloop_state runloop_check_state(void)
|
||||
global->menu.noop_press_time < 200000) /* 250ms */
|
||||
{
|
||||
global->menu.action_start_time = global->menu.prev_start_time;
|
||||
global->menu.action_press_time = cpu_features_get_time_usec() - global->menu.action_start_time;
|
||||
global->menu.action_press_time = current_time - global->menu.action_start_time;
|
||||
}
|
||||
else
|
||||
{
|
||||
global->menu.prev_start_time = cpu_features_get_time_usec();
|
||||
global->menu.prev_start_time = current_time;
|
||||
global->menu.prev_action = action;
|
||||
global->menu.action_press_time = 0;
|
||||
}
|
||||
@ -28012,6 +28013,7 @@ int runloop_iterate(void)
|
||||
unsigned video_frame_delay = settings->uints.video_frame_delay;
|
||||
bool vrr_runloop_enable = settings->bools.vrr_runloop_enable;
|
||||
unsigned max_users = input_driver_max_users;
|
||||
retro_time_t current_time = cpu_features_get_time_usec();
|
||||
|
||||
#ifdef HAVE_DISCORD
|
||||
if (discord_is_inited)
|
||||
@ -28023,7 +28025,7 @@ int runloop_iterate(void)
|
||||
/* Updates frame timing if frame timing callback is in use by the core.
|
||||
* Limits frame time if fast forward ratio throttle is enabled. */
|
||||
retro_usec_t runloop_last_frame_time = runloop_frame_time_last;
|
||||
retro_time_t current = cpu_features_get_time_usec();
|
||||
retro_time_t current = current_time;
|
||||
bool is_locked_fps = (runloop_paused || input_driver_nonblock_state)
|
||||
| !!recording_data;
|
||||
retro_time_t delta = (!runloop_last_frame_time || is_locked_fps) ?
|
||||
@ -28045,7 +28047,7 @@ int runloop_iterate(void)
|
||||
runloop_frame_time.callback(delta);
|
||||
}
|
||||
|
||||
switch ((enum runloop_state)runloop_check_state())
|
||||
switch ((enum runloop_state)runloop_check_state(current_time))
|
||||
{
|
||||
case RUNLOOP_STATE_QUIT:
|
||||
frame_limit_last_time = 0.0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user