From 9b9e65abf3769690158754cfc42f81d24850a9ba Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 9 May 2015 16:04:12 +0200 Subject: [PATCH] Start using video_driver_get_frame_count --- driver.c | 1 - gfx/drivers/gl.c | 8 +++++--- gfx/video_context_driver.c | 3 +-- gfx/video_monitor.c | 17 +++++++++-------- libretro_version_1.c | 2 -- menu/drivers/glui.c | 12 +++++++----- menu/drivers/rgui.c | 7 ++++--- menu/drivers/xmb.c | 5 +++-- runloop.c | 3 ++- runloop.h | 1 - 10 files changed, 31 insertions(+), 28 deletions(-) diff --git a/driver.c b/driver.c index 3f18b5d0cf..295cc7ad83 100644 --- a/driver.c +++ b/driver.c @@ -390,7 +390,6 @@ void init_drivers(int flags) if (flags & DRIVER_VIDEO) { - runloop->frames.video.count = 0; runloop->measure_data.frame_time_samples_count = 0; init_video(); diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index c4a871fea3..f9af05bb06 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -972,6 +972,7 @@ static void gl_frame_fbo(gl_t *gl, GLfloat fbo_tex_coords[8] = {0.0f}; runloop_t *runloop = rarch_main_get_ptr(); global_t *global = global_get_ptr(); + uint64_t frame_count = video_driver_get_frame_count(); /* Render the rest of our passes. */ gl->coords.tex_coord = fbo_tex_coords; @@ -1011,7 +1012,7 @@ static void gl_frame_fbo(gl_t *gl, gl_set_viewport(gl, rect->img_width, rect->img_height, true, false); gl->shader->set_params(gl, prev_rect->img_width, prev_rect->img_height, prev_rect->width, prev_rect->height, - gl->vp.width, gl->vp.height, runloop->frames.video.count, + gl->vp.width, gl->vp.height, frame_count, tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt); gl->coords.vertices = 4; @@ -1058,7 +1059,7 @@ static void gl_frame_fbo(gl_t *gl, gl->shader->set_params(gl, prev_rect->img_width, prev_rect->img_height, prev_rect->width, prev_rect->height, - gl->vp.width, gl->vp.height, runloop->frames.video.count, + gl->vp.width, gl->vp.height, frame_count, tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt); gl->coords.vertex = gl->vertex_ptr; @@ -1489,6 +1490,7 @@ static bool gl_frame(void *data, const void *frame, driver_t *driver = driver_get_ptr(); settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); + uint64_t frame_count = video_driver_get_frame_count(); const struct font_renderer *font_driver = driver ? driver->font_osd_driver : NULL; RARCH_PERFORMANCE_INIT(frame_run); @@ -1597,7 +1599,7 @@ static bool gl_frame(void *data, const void *frame, gl->shader->set_params(gl, width, height, gl->tex_w, gl->tex_h, gl->vp.width, gl->vp.height, - runloop->frames.video.count, + frame_count, &gl->tex_info, gl->prev_info, NULL, 0); gl->coords.vertices = 4; diff --git a/gfx/video_context_driver.c b/gfx/video_context_driver.c index a0c86b73d1..e4d089ea34 100644 --- a/gfx/video_context_driver.c +++ b/gfx/video_context_driver.c @@ -237,8 +237,7 @@ bool gfx_ctx_check_window(void *data, bool *quit, bool *resize, { runloop_t *runloop = rarch_main_get_ptr(); const gfx_ctx_driver_t *ctx = gfx_ctx_get_ptr(); - unsigned frame_count = runloop ? - runloop->frames.video.count : 0; + uint64_t frame_count = video_driver_get_frame_count(); if (!data) return false; diff --git a/gfx/video_monitor.c b/gfx/video_monitor.c index 881c6aab4b..c88bcc5475 100644 --- a/gfx/video_monitor.c +++ b/gfx/video_monitor.c @@ -186,14 +186,15 @@ bool video_monitor_get_fps(char *buf, size_t size, retro_time_t new_time; static retro_time_t curr_time; static retro_time_t fps_time; - runloop_t *runloop = rarch_main_get_ptr(); - global_t *global = global_get_ptr(); + uint64_t frame_count = video_driver_get_frame_count(); + runloop_t *runloop = rarch_main_get_ptr(); + global_t *global = global_get_ptr(); *buf = '\0'; new_time = rarch_get_time_usec(); - if (runloop->frames.video.count) + if (frame_count) { bool ret = false; unsigned write_index = @@ -203,19 +204,19 @@ bool video_monitor_get_fps(char *buf, size_t size, new_time - fps_time; fps_time = new_time; - if ((runloop->frames.video.count % FPS_UPDATE_INTERVAL) == 0) + if ((frame_count % FPS_UPDATE_INTERVAL) == 0) { 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", - global->title_buf, last_fps, runloop->frames.video.count); + snprintf(buf, size, "%s || FPS: %6.1f || Frames: %lu", + global->title_buf, last_fps, frame_count); ret = true; } if (buf_fps) - snprintf(buf_fps, size_fps, "FPS: %6.1f || Frames: %u", - last_fps, runloop->frames.video.count); + snprintf(buf_fps, size_fps, "FPS: %6.1f || Frames: %lu", + last_fps, frame_count); return ret; } diff --git a/libretro_version_1.c b/libretro_version_1.c index a17f5b265b..a783b63b1a 100644 --- a/libretro_version_1.c +++ b/libretro_version_1.c @@ -165,8 +165,6 @@ static void video_frame(const void *data, unsigned width, if (!video_driver_frame(data, width, height, pitch, msg)) driver->video_active = false; - - runloop->frames.video.count++; } /** diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 9220212f14..d0b5164b28 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -294,7 +294,8 @@ static void glui_render_menu_list(runloop_t *runloop, uint32_t hover_color) { size_t i = 0; - global_t *global = global_get_ptr(); + uint64_t frame_count = video_driver_get_frame_count(); + global_t *global = global_get_ptr(); if (!menu_display_update_pending()) return; @@ -313,9 +314,9 @@ static void glui_render_menu_list(runloop_t *runloop, selected = menu_list_entry_is_currently_selected(&entry); menu_animation_ticker_line(entry_title_buf, glui->ticker_limit, - runloop->frames.video.count / 100, entry.path, selected); + frame_count / 100, entry.path, selected); menu_animation_ticker_line(type_str_buf, glui->ticker_limit, - runloop->frames.video.count / 100, entry.value, selected); + frame_count / 100, entry.value, selected); strlcpy(message, entry_title_buf, sizeof(message)); @@ -340,6 +341,7 @@ static void glui_frame(void) glui_handle_t *glui = NULL; const char *core_name = NULL; const char *core_version = NULL; + const struct font_renderer *font_driver = NULL; driver_t *driver = driver_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr(); settings_t *settings = config_get_ptr(); @@ -351,7 +353,7 @@ static void glui_frame(void) settings->menu.title_color); runloop_t *runloop = rarch_main_get_ptr(); global_t *global = global_get_ptr(); - const struct font_renderer *font_driver = NULL; + uint64_t frame_count = video_driver_get_frame_count(); if (!menu || !menu->userdata) return; @@ -399,7 +401,7 @@ static void glui_frame(void) menu->header_height, 0.2, 0.2, 0.2, 1); menu_animation_ticker_line(title_buf, glui->ticker_limit, - runloop->frames.video.count / 100, title, true); + frame_count / 100, title, true); glui_blit_line(global->video_data.width / 2, 0, title_buf, title_color, TEXT_ALIGN_CENTER); diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 7d646ab9d5..2096308000 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -366,6 +366,7 @@ static void rgui_render(void) driver_t *driver = driver_get_ptr(); global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); + uint64_t frame_count = video_driver_get_frame_count(); (void)driver; @@ -437,7 +438,7 @@ static void rgui_render(void) get_title(label, dir, menu_type, title, sizeof(title)); menu_animation_ticker_line(title_buf, RGUI_TERM_WIDTH - 10, - runloop->frames.video.count / RGUI_TERM_START_X, title, true); + frame_count / RGUI_TERM_START_X, title, true); hover_color = HOVER_COLOR(settings); normal_color = NORMAL_COLOR(settings); @@ -500,9 +501,9 @@ static void rgui_render(void) continue; menu_animation_ticker_line(entry_title_buf, RGUI_TERM_WIDTH - (entry.spacing + 1 + 2), - runloop->frames.video.count / RGUI_TERM_START_X, entry.path, selected); + frame_count / RGUI_TERM_START_X, entry.path, selected); menu_animation_ticker_line(type_str_buf, entry.spacing, - runloop->frames.video.count / RGUI_TERM_START_X, + frame_count / RGUI_TERM_START_X, entry.value, selected); snprintf(message, sizeof(message), "%c %-*.*s %-*s", diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 7ecdd95346..2987e5197e 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -978,6 +978,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, xmb_node_t *core_node = NULL; size_t end = 0; global_t *global = global_get_ptr(); + uint64_t frame_count = video_driver_get_frame_count(); if (!list || !list->size) return; @@ -1050,7 +1051,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, menu_animation_ticker_line(name, 35, - runloop->frames.video.count / 20, entry.path, + frame_count / 20, entry.path, (i == current)); xmb_draw_text(menu, xmb, name, @@ -1060,7 +1061,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, 1, node->label_alpha, TEXT_ALIGN_LEFT); menu_animation_ticker_line(value, 35, - runloop->frames.video.count / 20, entry.value, + frame_count / 20, entry.value, (i == current)); if(( strcmp(entry.value, "...") diff --git a/runloop.c b/runloop.c index 3f7c8a722c..5a68951982 100644 --- a/runloop.c +++ b/runloop.c @@ -618,8 +618,9 @@ static INLINE int time_to_exit(event_cmd_state_t *cmd) bool shutdown_pressed = global->system.shutdown; bool video_alive = video_driver_is_alive(); bool movie_end = (global->bsv.movie_end && global->bsv.eof_exit); + uint64_t frame_count = video_driver_get_frame_count(); bool frame_count_end = (runloop->frames.video.max && - runloop->frames.video.count >= runloop->frames.video.max); + frame_count >= runloop->frames.video.max); if (shutdown_pressed || cmd->quit_key_pressed || frame_count_end || movie_end || !video_alive) diff --git a/runloop.h b/runloop.h index 18c51ccd28..2b325cea2c 100644 --- a/runloop.h +++ b/runloop.h @@ -54,7 +54,6 @@ typedef struct runloop { struct { - unsigned count; unsigned max; struct {