diff --git a/driver.c b/driver.c index c93cfd6c0b..eb39f227b4 100644 --- a/driver.c +++ b/driver.c @@ -307,7 +307,7 @@ void init_drivers(int flags) if (flags & DRIVER_VIDEO) { - g_extern.frame_count = 0; + g_runloop.frames.video.count = 0; init_video(); diff --git a/general.h b/general.h index b9b79f3d9f..8983bc76ca 100644 --- a/general.h +++ b/general.h @@ -454,6 +454,15 @@ struct runloop } db; #endif + struct + { + struct + { + unsigned count; + unsigned max; + } video; + } frames; + nbio_handle_t nbio; msg_queue_t *msg_queue; }; @@ -711,8 +720,6 @@ struct global size_t pitch; } frame_cache; - unsigned frame_count; - unsigned max_frames; char title_buf[64]; diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 343cc44115..e6faaad595 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -406,7 +406,7 @@ static bool d3d_alive(void *data) if (d3d->ctx_driver && d3d->ctx_driver->check_window) d3d->ctx_driver->check_window(d3d, &quit, &resize, - &d3d->screen_width, &d3d->screen_height, g_extern.frame_count); + &d3d->screen_width, &d3d->screen_height, g_runloop.frames.video.count); if (quit) d3d->quitting = quit; diff --git a/gfx/d3d/render_chain_xdk.h b/gfx/d3d/render_chain_xdk.h index ed188a76a9..ab562d432e 100644 --- a/gfx/d3d/render_chain_xdk.h +++ b/gfx/d3d/render_chain_xdk.h @@ -138,7 +138,7 @@ static void renderchain_render_pass(void *data, const void *frame, unsigned widt d3d_draw_primitive(d3dr, D3DPT_TRIANGLESTRIP, 0, 2); - g_extern.frame_count++; + g_runloop.frames.video.count++; renderchain_set_mvp(d3d, d3d->screen_width, d3d->screen_height, d3d->dev_rotation); } @@ -222,7 +222,7 @@ static void renderchain_set_vertices(void *data, unsigned pass, unsigned width, d3d->shader->use(d3d, pass); if (d3d->shader->set_params) d3d->shader->set_params(d3d, width, height, d3d->tex_w, d3d->tex_h, d3d->screen_width, - d3d->screen_height, g_extern.frame_count, + d3d->screen_height, g_runloop.frames.video.count, NULL, NULL, NULL, 0); } #endif diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index 4e52230d6a..5eece59229 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -1461,7 +1461,7 @@ static bool exynos_gfx_frame(void *data, const void *frame, unsigned width, if (exynos_flip(vid->data, page) != 0) goto fail; - g_extern.frame_count++; + g_runloop.frames.video.count++; return true; diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index b1bb3e7d0b..b518357554 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -996,7 +996,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, g_extern.frame_count, + gl->vp.width, gl->vp.height, g_runloop.frames.video.count, tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt); gl->coords.vertices = 4; @@ -1043,7 +1043,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, g_extern.frame_count, + gl->vp.width, gl->vp.height, g_runloop.frames.video.count, tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt); gl->coords.vertex = gl->vertex_ptr; @@ -1569,7 +1569,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, - g_extern.frame_count, + g_runloop.frames.video.count, &gl->tex_info, gl->prev_info, NULL, 0); gl->coords.vertices = 4; @@ -1649,7 +1649,6 @@ static bool gl_frame(void *data, const void *frame, } gl->ctx_driver->swap_buffers(gl); - g_extern.frame_count++; #ifdef HAVE_GL_SYNC if (g_settings.video.hard_sync && gl->have_sync) @@ -1682,6 +1681,8 @@ static bool gl_frame(void *data, const void *frame, context_bind_hw_render(gl, true); + g_runloop.frames.video.count++; + return true; } @@ -2435,7 +2436,7 @@ static bool gl_alive(void *data) gl->ctx_driver->check_window(gl, &quit, &resize, &gl->win_width, &gl->win_height, - g_extern.frame_count); + g_runloop.frames.video.count); if (quit) gl->quitting = true; diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index e2f7b7ebe9..ef4c6b8ada 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -1149,7 +1149,7 @@ static bool gx_frame(void *data, const void *frame, VISetNextFrameBuffer(g_framebuf[g_current_framebuf]); VIFlush(); - g_extern.frame_count++; + g_runloop.frames.video.count++; RARCH_PERFORMANCE_STOP(gx_frame); diff --git a/gfx/drivers/omap_gfx.c b/gfx/drivers/omap_gfx.c index 93d5daa119..4f5cf02ed0 100644 --- a/gfx/drivers/omap_gfx.c +++ b/gfx/drivers/omap_gfx.c @@ -1000,7 +1000,7 @@ static bool omap_gfx_frame(void *data, const void *frame, unsigned width, if (msg) omap_render_msg(vid, msg); - g_extern.frame_count++; + g_runloop.frames.video.count++; return true; } diff --git a/gfx/drivers/psp1_gfx.c b/gfx/drivers/psp1_gfx.c index 8b65b15939..36fa5ce81f 100644 --- a/gfx/drivers/psp1_gfx.c +++ b/gfx/drivers/psp1_gfx.c @@ -527,7 +527,7 @@ static bool psp_frame(void *data, const void *frame, #endif psp->draw_buffer = FROM_GU_POINTER(sceGuSwapBuffers()); - g_extern.frame_count++; + g_runloop.frames.video.count++; RARCH_PERFORMANCE_INIT(psp_frame_run); diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 4a4986896c..4aa93c48c8 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -517,7 +517,7 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width, if (video_monitor_get_fps(buf, sizeof(buf), NULL, 0)) SDL_SetWindowTitle(vid->window, buf); - g_extern.frame_count++; + g_runloop.frames.video.count++; return true; } diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 6707b1a08e..881b0e5083 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -376,7 +376,7 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width, SDL_WM_SetCaption(buf, NULL); SDL_Flip(vid->screen); - g_extern.frame_count++; + g_runloop.frames.video.count++; return true; } diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 90b222fe17..dc900c82e3 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -409,7 +409,7 @@ static bool vg_alive(void *data) vg->driver->check_window(vg, &quit, &vg->should_resize, &vg->mScreenWidth, &vg->mScreenHeight, - g_extern.frame_count); + g_runloop.frames.video.count); return !quit; } diff --git a/gfx/drivers/xvideo.c b/gfx/drivers/xvideo.c index 4d5e9dbc03..3c3c9863f0 100644 --- a/gfx/drivers/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -775,7 +775,7 @@ static bool xv_frame(void *data, const void *frame, unsigned width, if (video_monitor_get_fps(buf, sizeof(buf), NULL, 0)) XStoreName(xv->display, xv->window, buf); - g_extern.frame_count++; + g_runloop.frames.video.count++; return true; } diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index 3937e975c9..ed5a23eb84 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -149,7 +149,7 @@ static void gfx_ctx_d3d_update_title(void *data) } #ifndef _XBOX - g_extern.frame_count++; + g_runloop.frames.video.count++; #endif } diff --git a/gfx/video_monitor.c b/gfx/video_monitor.c index 211e3d9a24..6337661b95 100644 --- a/gfx/video_monitor.c +++ b/gfx/video_monitor.c @@ -180,7 +180,7 @@ bool video_monitor_get_fps(char *buf, size_t size, new_time = rarch_get_time_usec(); - if (g_extern.frame_count) + if (g_runloop.frames.video.count) { bool ret = false; unsigned write_index = @@ -190,19 +190,19 @@ bool video_monitor_get_fps(char *buf, size_t size, new_time - fps_time; fps_time = new_time; - if ((g_extern.frame_count % FPS_UPDATE_INTERVAL) == 0) + if ((g_runloop.frames.video.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", - g_extern.title_buf, last_fps, g_extern.frame_count); + g_extern.title_buf, last_fps, g_runloop.frames.video.count); ret = true; } if (buf_fps) snprintf(buf_fps, size_fps, "FPS: %6.1f || Frames: %u", - last_fps, g_extern.frame_count); + last_fps, g_runloop.frames.video.count); return ret; } diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 61befbcd44..dd3bc2c119 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -335,7 +335,7 @@ static void glui_frame(void) get_title(label, dir, menu_type, title, sizeof(title)); menu_animation_ticker_line(title_buf, glui->term_width - 3, - g_extern.frame_count / glui->margin, title, true); + g_runloop.frames.video.count / glui->margin, title, true); glui_blit_line(gl, glui->margin * 2, glui->margin + glui->line_height, title_buf, true); @@ -402,9 +402,9 @@ static void glui_frame(void) selected = (i == menu->navigation.selection_ptr); menu_animation_ticker_line(entry_title_buf, glui->term_width - (w + 1 + 2), - g_extern.frame_count / glui->margin, path_buf, selected); + g_runloop.frames.video.count / glui->margin, path_buf, selected); menu_animation_ticker_line(type_str_buf, w, - g_extern.frame_count / glui->margin, type_str, selected); + g_runloop.frames.video.count / glui->margin, type_str, selected); strlcpy(message, entry_title_buf, sizeof(message)); diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index a0c16a83b1..ad18f2f643 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -354,7 +354,7 @@ static void rgui_render(void) get_title(label, dir, menu_type, title, sizeof(title)); menu_animation_ticker_line(title_buf, RGUI_TERM_WIDTH - 3, - g_extern.frame_count / RGUI_TERM_START_X, title, true); + g_runloop.frames.video.count / RGUI_TERM_START_X, title, true); blit_line(menu, RGUI_TERM_START_X + RGUI_TERM_START_X, RGUI_TERM_START_X, title_buf, true); core_name = g_extern.menu.info.library_name; @@ -424,8 +424,8 @@ static void rgui_render(void) continue; menu_animation_ticker_line(entry_title_buf, RGUI_TERM_WIDTH - (w + 1 + 2), - g_extern.frame_count / RGUI_TERM_START_X, path_buf, selected); - menu_animation_ticker_line(type_str_buf, w, g_extern.frame_count / RGUI_TERM_START_X, + g_runloop.frames.video.count / RGUI_TERM_START_X, path_buf, selected); + menu_animation_ticker_line(type_str_buf, w, g_runloop.frames.video.count / RGUI_TERM_START_X, type_str, selected); snprintf(message, sizeof(message), "%c %-*.*s %-*s", diff --git a/menu/drivers/rmenu.c b/menu/drivers/rmenu.c index cbba1e9021..6d10ef0dae 100644 --- a/menu/drivers/rmenu.c +++ b/menu/drivers/rmenu.c @@ -191,7 +191,7 @@ static void rmenu_render(void) get_title(label, dir, menu_type, title, sizeof(title)); menu_animation_ticker_line(title_buf, RMENU_TERM_WIDTH, - g_extern.frame_count / 15, title, true); + g_runloop.frames.video.count / 15, title, true); font_parms.x = POSITION_EDGE_MIN + POSITION_OFFSET; font_parms.y = POSITION_EDGE_MIN + POSITION_RENDER_OFFSET @@ -258,8 +258,8 @@ static void rmenu_render(void) selected = (i == menu->navigation.selection_ptr); menu_animation_ticker_line(entry_title_buf, RMENU_TERM_WIDTH - (w + 1 + 2), - g_extern.frame_count / 15, path, selected); - menu_animation_ticker_line(type_str_buf, w, g_extern.frame_count / 15, + g_runloop.frames.video.count / 15, path, selected); + menu_animation_ticker_line(type_str_buf, w, g_runloop.frames.video.count / 15, type_str, selected); snprintf(message, sizeof(message), "%c %s", diff --git a/menu/drivers/rmenu_xui.cpp b/menu/drivers/rmenu_xui.cpp index 9792755094..c53d0aa79d 100644 --- a/menu/drivers/rmenu_xui.cpp +++ b/menu/drivers/rmenu_xui.cpp @@ -569,7 +569,7 @@ static void rmenu_xui_render(void) get_title(label, dir, menu_type, title, sizeof(title)); mbstowcs(strw_buffer, title, sizeof(strw_buffer) / sizeof(wchar_t)); XuiTextElementSetText(m_menutitle, strw_buffer); - menu_animation_ticker_line(title, RXUI_TERM_WIDTH - 3, g_extern.frame_count / 15, title, true); + menu_animation_ticker_line(title, RXUI_TERM_WIDTH - 3, g_runloop.frames.video.count / 15, title, true); } if (XuiHandleIsValid(m_menutitle)) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 416e78132d..caa0123d20 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1060,7 +1060,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, xmb_draw_icon(gl, xmb, icon, icon_x, icon_y, node->alpha, 0, node->zoom); - menu_animation_ticker_line(name, 35, g_extern.frame_count / 20, path_buf, + menu_animation_ticker_line(name, 35, g_runloop.frames.video.count / 20, path_buf, (i == current)); xmb_draw_text(gl, xmb, name, @@ -1068,7 +1068,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl, xmb->margins.screen.top + node->y + xmb->margins.label.top, 1, node->label_alpha, 0); - menu_animation_ticker_line(value, 35, g_extern.frame_count / 20, type_str, + menu_animation_ticker_line(value, 35, g_runloop.frames.video.count / 20, type_str, (i == current)); if(( strcmp(type_str, "...") diff --git a/retroarch.c b/retroarch.c index 5de04fc0b9..e11089bc80 100644 --- a/retroarch.c +++ b/retroarch.c @@ -652,7 +652,7 @@ static void parse_input(int argc, char *argv[]) break; case 'm': - g_extern.max_frames = strtoul(optarg, NULL, 10); + g_runloop.frames.video.max = strtoul(optarg, NULL, 10); break; case 0: diff --git a/runloop.c b/runloop.c index e34a8f25e1..0b19c327a8 100644 --- a/runloop.c +++ b/runloop.c @@ -647,8 +647,8 @@ static inline int time_to_exit(retro_input_t input) if ( g_extern.system.shutdown || check_quit_key_func(input) - || (g_extern.max_frames && g_extern.frame_count >= - g_extern.max_frames) + || (g_runloop.frames.video.max && + g_runloop.frames.video.count >= g_runloop.frames.video.max) || (g_extern.bsv.movie_end && g_extern.bsv.eof_exit) || !video_driver_is_alive() )