diff --git a/gfx/gfx_common.c b/gfx/gfx_common.c index 5fe6f81b35..cd648e5211 100644 --- a/gfx/gfx_common.c +++ b/gfx/gfx_common.c @@ -18,16 +18,15 @@ #include "../general.h" #include "../performance.h" -static inline float time_to_fps(retro_time_t last_time, - retro_time_t new_time, int frames) -{ - return (1000000.0f * frames) / (new_time - last_time); -} +#ifndef TIME_TO_FPS +#define TIME_TO_FPS(last_time, new_time, frames) ((1000000.0f * (frames)) / ((new_time) - (last_time))) +#endif #define FPS_UPDATE_INTERVAL 256 + bool gfx_get_fps(char *buf, size_t size, char *buf_fps, size_t size_fps) { - static retro_time_t time; + static retro_time_t curr_time; static retro_time_t fps_time; static float last_fps; bool ret = false; @@ -45,8 +44,8 @@ bool gfx_get_fps(char *buf, size_t size, char *buf_fps, size_t size_fps) if ((g_extern.frame_count % FPS_UPDATE_INTERVAL) == 0) { - last_fps = time_to_fps(time, new_time, FPS_UPDATE_INTERVAL); - time = new_time; + last_fps = TIME_TO_FPS(curr_time, new_time, FPS_UPDATE_INTERVAL); + curr_time = new_time; snprintf(buf, size, "%s || FPS: %6.1f || Frames: %u", g_extern.title_buf, last_fps, g_extern.frame_count); @@ -59,7 +58,7 @@ bool gfx_get_fps(char *buf, size_t size, char *buf_fps, size_t size_fps) } else { - time = fps_time = new_time; + curr_time = fps_time = new_time; strlcpy(buf, g_extern.title_buf, size); if (buf_fps) strlcpy(buf_fps, "N/A", size_fps); diff --git a/runloop.c b/runloop.c index 588f026373..9fc305bd4d 100644 --- a/runloop.c +++ b/runloop.c @@ -468,8 +468,8 @@ static inline int time_to_exit(retro_input_t input) static void update_frame_time(void) { - retro_time_t time = rarch_get_time_usec(); - retro_time_t delta = time - g_extern.system.frame_time_last; + retro_time_t curr_time = rarch_get_time_usec(); + retro_time_t delta = curr_time - g_extern.system.frame_time_last; bool is_locked_fps = g_extern.is_paused || driver.nonblock_state; is_locked_fps |= !!driver.recording_data; @@ -479,7 +479,7 @@ static void update_frame_time(void) if (!is_locked_fps && g_extern.is_slowmotion) delta /= g_settings.slowmotion_ratio; - g_extern.system.frame_time_last = is_locked_fps ? 0 : time; + g_extern.system.frame_time_last = is_locked_fps ? 0 : curr_time; g_extern.system.frame_time.callback(delta); }