diff --git a/apple/common/apple_gfx_context.c.inl b/apple/common/apple_gfx_context.c.inl index 83b91e1260..bce45e1ce0 100644 --- a/apple/common/apple_gfx_context.c.inl +++ b/apple/common/apple_gfx_context.c.inl @@ -4,6 +4,7 @@ #endif #include "../../gfx/gfx_common.h" +#include "../../gfx/video_monitor.h" #include "../../gfx/video_context_driver.h" #include "../../gfx/gl_common.h" @@ -249,8 +250,9 @@ static void apple_gfx_ctx_update_window_title(void *data) { #ifdef OSX static char buf[128], buf_fps[128]; - bool got_text = gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); - static const char* const text = buf; // < Can't access buf directly in the block + bool got_text = video_monitor_get_fps(buf, sizeof(buf), + g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); + static const char* const text = buf; /* < Can't access buffer directly in the block */ if (got_text) [[g_view window] setTitle:[NSString stringWithCString:text encoding:NSUTF8StringEncoding]]; if (g_settings.fps_show) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 28105ad5f6..e23bc754c6 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -548,6 +548,7 @@ static bool d3d_construct(d3d_video_t *d3d, d3d->screen_height = info->fullscreen ? full_y : info->height; #if defined(HAVE_WINDOW) && !defined(_XBOX) + char buffer[128]; unsigned win_width = d3d->screen_width; unsigned win_height = d3d->screen_height; RECT rect = {0}; @@ -561,8 +562,7 @@ static bool d3d_construct(d3d_video_t *d3d, win_height = rect.bottom - rect.top; } - char buffer[128]; - gfx_get_fps(buffer, sizeof(buffer), NULL, 0); + video_monitor_get_fps(buffer, sizeof(buffer), NULL, 0); std::string title = buffer; title += " || Direct3D"; diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index 15acc8b6e9..04d4f38489 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -33,6 +33,7 @@ #include "../../general.h" #include "../../retroarch.h" #include "../gfx_common.h" +#include "../video_monitor.h" #include "../font_renderer_driver.h" /* TODO: Honor these properties: vsync, menu rotation, menu alpha, aspect ratio change */ @@ -1284,10 +1285,11 @@ static bool exynos_gfx_frame(void *data, const void *frame, unsigned width, goto fail; } - if (g_settings.fps_show) { + if (g_settings.fps_show) + { char buffer[128], buffer_fps[128]; - - gfx_get_fps(buffer, sizeof(buffer), g_settings.fps_show ? buffer_fps : NULL, sizeof(buffer_fps)); + video_monitor_get_fps(buffer, sizeof(buffer), + g_settings.fps_show ? buffer_fps : NULL, sizeof(buffer_fps)); msg_queue_push(g_extern.msg_queue, buffer_fps, 1, 1); } diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index 86539c0258..537be9bcbc 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -20,6 +20,7 @@ #include "../drivers_font_renderer/bitmap.h" #include "../../menu/menu.h" #include "../gfx_common.h" +#include "../video_monitor.h" #ifdef HW_RVL #include "../../wii/mem2_manager.h" @@ -903,7 +904,8 @@ static bool gx_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg) { - + char fps_txt[128], fps_text_buf[128]; + bool fps_draw = g_settings.fps_show; gx_video_t *gx = (gx_video_t*)data; struct __gx_regdef *__gx = (struct __gx_regdef*)__gxregs; u8 clear_efb = GX_FALSE; @@ -984,9 +986,7 @@ static bool gx_frame(void *data, const void *frame, GX_DrawDone(); - char fps_txt[128], fps_text_buf[128]; - bool fps_draw = g_settings.fps_show; - gfx_get_fps(fps_txt, sizeof(fps_txt), + video_monitor_get_fps(fps_txt, sizeof(fps_txt), fps_draw ? fps_text_buf : NULL, sizeof(fps_text_buf)); if (fps_draw) diff --git a/gfx/drivers/omap_gfx.c b/gfx/drivers/omap_gfx.c index 77789f7f0e..3f37380075 100644 --- a/gfx/drivers/omap_gfx.c +++ b/gfx/drivers/omap_gfx.c @@ -21,6 +21,7 @@ #include "../../retroarch.h" #include #include "../gfx_common.h" +#include "../video_monitor.h" #include "../video_context_driver.h" #include "../font_renderer_driver.h" diff --git a/gfx/drivers/psp1_gfx.c b/gfx/drivers/psp1_gfx.c index f2f9566a06..bc09cc816d 100644 --- a/gfx/drivers/psp1_gfx.c +++ b/gfx/drivers/psp1_gfx.c @@ -25,6 +25,7 @@ #include "../../general.h" #include "../../driver.h" #include "../gfx_common.h" +#include "../video_monitor.h" #ifndef SCEGU_SCR_WIDTH #define SCEGU_SCR_WIDTH 480 @@ -491,15 +492,16 @@ static bool psp_frame(void *data, const void *frame, pspDebugScreenSetXY(0,0); + video_monitor_get_fps(fps_txt, sizeof(fps_txt), + g_settings.fps_show ? fps_text_buf : NULL, + g_settings.fps_show ? sizeof(fps_text_buf) : 0); + if(g_settings.fps_show) { - gfx_get_fps(fps_txt, sizeof(fps_txt), fps_text_buf, sizeof(fps_text_buf)); pspDebugScreenSetXY(68 - strlen(fps_text_buf) - 1,0); pspDebugScreenPuts(fps_text_buf); pspDebugScreenSetXY(0,1); } - else - gfx_get_fps(fps_txt, sizeof(fps_txt), NULL, 0); if (msg) pspDebugScreenPuts(msg); diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 46a7e2fad2..efbe1ece03 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -21,8 +21,10 @@ #include #include "../../general.h" #include "../../retroarch.h" +#include "../../performance.h" #include #include "../gfx_common.h" +#include "../video_monitor.h" #include "../video_context_driver.h" #include "../font_renderer_driver.h" @@ -470,6 +472,7 @@ static void check_window(sdl2_video_t *vid) static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg) { + char buf[128]; sdl2_video_t *vid = (sdl2_video_t*)data; if (vid->should_resize) @@ -503,8 +506,7 @@ static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width, SDL_RenderPresent(vid->renderer); - char buf[128]; - if (gfx_get_fps(buf, sizeof(buf), NULL, 0)) + if (video_monitor_get_fps(buf, sizeof(buf), NULL, 0)) SDL_SetWindowTitle(vid->window, buf); g_extern.frame_count++; diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 6acb046d75..b9ab61bc80 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -21,6 +21,7 @@ #include "../../general.h" #include #include "../gfx_common.h" +#include "../video_monitor.h" #include "../video_context_driver.h" #include "../font_renderer_driver.h" @@ -335,11 +336,12 @@ static void check_window(sdl_video_t *vid) static bool sdl_gfx_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg) { + char buf[128]; + sdl_video_t *vid = (sdl_video_t*)data; + if (!frame) return true; - sdl_video_t *vid = (sdl_video_t*)data; - sdl_update_scaler(vid->screen, &vid->scaler, vid->scaler.in_fmt, width, height, pitch); if (SDL_MUSTLOCK(vid->screen)) @@ -359,8 +361,7 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width, if (SDL_MUSTLOCK(vid->screen)) SDL_UnlockSurface(vid->screen); - char buf[128]; - if (gfx_get_fps(buf, sizeof(buf), NULL, 0)) + if (video_monitor_get_fps(buf, sizeof(buf), NULL, 0)) SDL_WM_SetCaption(buf, NULL); SDL_Flip(vid->screen); diff --git a/gfx/drivers/xvideo.c b/gfx/drivers/xvideo.c index 3e6e8e7b9e..cd227c6fcb 100644 --- a/gfx/drivers/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -20,6 +20,7 @@ #include #include #include "../gfx_common.h" +#include "../video_monitor.h" #include "../font_renderer_driver.h" #include "../drivers_context/x11_common.h" @@ -500,7 +501,7 @@ static void *xv_init(const video_info_t *video, XMapWindow(xv->display, xv->window); - if (gfx_get_fps(buf, sizeof(buf), NULL, 0)) + if (video_monitor_get_fps(buf, sizeof(buf), NULL, 0)) XStoreName(xv->display, xv->window, buf); x11_set_window_attr(xv->display, xv->window); @@ -771,7 +772,7 @@ static bool xv_frame(void *data, const void *frame, unsigned width, true); XSync(xv->display, False); - if (gfx_get_fps(buf, sizeof(buf), NULL, 0)) + if (video_monitor_get_fps(buf, sizeof(buf), NULL, 0)) XStoreName(xv->display, xv->window, buf); g_extern.frame_count++; diff --git a/gfx/drivers_context/androidegl_ctx.c b/gfx/drivers_context/androidegl_ctx.c index d3eda923df..415027a76e 100644 --- a/gfx/drivers_context/androidegl_ctx.c +++ b/gfx/drivers_context/androidegl_ctx.c @@ -17,6 +17,7 @@ #include "../../driver.h" #include "../../general.h" #include "../gfx_common.h" +#include "../video_monitor.h" #include "../gl_common.h" #include @@ -276,7 +277,8 @@ static void android_gfx_ctx_update_window_title(void *data) if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); + video_monitor_get_fps(buf, sizeof(buf), + g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); if (g_settings.fps_show) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } diff --git a/gfx/drivers_context/bbqnx_ctx.c b/gfx/drivers_context/bbqnx_ctx.c index 596da9a903..be18b2194c 100644 --- a/gfx/drivers_context/bbqnx_ctx.c +++ b/gfx/drivers_context/bbqnx_ctx.c @@ -17,6 +17,7 @@ #include "../../driver.h" #include "../../general.h" #include "../gfx_common.h" +#include "../video_monitor.h" #include "../gl_common.h" #include @@ -359,7 +360,8 @@ static void gfx_ctx_qnx_update_window_title(void *data) if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); + video_monitor_get_fps(buf, sizeof(buf), + g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); if (g_settings.fps_show) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index f3287df2b7..552b31c40b 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -19,6 +19,7 @@ #include "win32_common.h" #include "../gfx_common.h" +#include "../video_monitor.h" #ifdef _MSC_VER #ifndef _XBOX @@ -127,7 +128,8 @@ static void gfx_ctx_d3d_update_title(void *data) char buf[128], buffer_fps[128]; bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; - if (gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buffer_fps : NULL, sizeof(buffer_fps))) + if (video_monitor_get_fps(buf, sizeof(buf), + g_settings.fps_show ? buffer_fps : NULL, sizeof(buffer_fps))) { #ifndef _XBOX SetWindowText(d3d->hWnd, buf); diff --git a/gfx/drivers_context/drm_egl_ctx.c b/gfx/drivers_context/drm_egl_ctx.c index d9bb67a396..b9599c4571 100644 --- a/gfx/drivers_context/drm_egl_ctx.c +++ b/gfx/drivers_context/drm_egl_ctx.c @@ -21,6 +21,7 @@ #include "../../driver.h" #include "../gl_common.h" #include "../gfx_common.h" +#include "../video_monitor.h" #include #ifdef HAVE_CONFIG_H @@ -271,7 +272,8 @@ static void gfx_ctx_drm_egl_update_window_title(void *data) if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); + video_monitor_get_fps(buf, sizeof(buf), + g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); if (g_settings.fps_show) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } diff --git a/gfx/drivers_context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c index 88e9241e64..b3df41fdb9 100644 --- a/gfx/drivers_context/emscriptenegl_ctx.c +++ b/gfx/drivers_context/emscriptenegl_ctx.c @@ -18,6 +18,7 @@ #include "../video_context_driver.h" #include "../gl_common.h" #include "../gfx_common.h" +#include "../video_monitor.h" #ifdef HAVE_CONFIG_H #include "../../config.h" @@ -93,7 +94,8 @@ static void gfx_ctx_emscripten_update_window_title(void *data) if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); + video_monitor_get_fps(buf, sizeof(buf), + g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); if (g_settings.fps_show) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } diff --git a/gfx/drivers_context/gfx_null_ctx.c b/gfx/drivers_context/gfx_null_ctx.c index a6dd7a0a84..f0a5a8c1b2 100644 --- a/gfx/drivers_context/gfx_null_ctx.c +++ b/gfx/drivers_context/gfx_null_ctx.c @@ -19,6 +19,7 @@ #include "../../driver.h" #include "../video_context_driver.h" #include "../gfx_common.h" +#include "../video_monitor.h" static void gfx_ctx_null_swap_interval(void *data, unsigned interval) { diff --git a/gfx/drivers_context/glx_ctx.c b/gfx/drivers_context/glx_ctx.c index b83caca2bd..31133373e5 100644 --- a/gfx/drivers_context/glx_ctx.c +++ b/gfx/drivers_context/glx_ctx.c @@ -17,6 +17,7 @@ #include "../../driver.h" #include "../gl_common.h" #include "../gfx_common.h" +#include "../video_monitor.h" #include "x11_common.h" #include @@ -197,7 +198,8 @@ static void gfx_ctx_glx_update_window_title(void *data) glx = (gfx_ctx_glx_data_t*)driver.video_context_data; - if (gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps))) + if (video_monitor_get_fps(buf, sizeof(buf), + g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps))) XStoreName(glx->g_dpy, glx->g_win, buf); if (g_settings.fps_show) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index 752e932c66..6feebd7bd7 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -16,6 +16,7 @@ #include "../../driver.h" #include "../../general.h" #include "../gfx_common.h" +#include "../video_monitor.h" #include "../gl_common.h" #include @@ -205,7 +206,8 @@ static void gfx_ctx_mali_fbdev_update_window_title(void *data) if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); + video_monitor_get_fps(buf, sizeof(buf), + g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); if (g_settings.fps_show) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } diff --git a/gfx/drivers_context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index 74f393926e..3117437a4e 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -24,6 +24,7 @@ #endif #include "../gfx_common.h" +#include "../video_monitor.h" #ifndef __PSL1GHT__ #include @@ -214,7 +215,8 @@ static void gfx_ctx_ps3_update_window_title(void *data) if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); + video_monitor_get_fps(buf, sizeof(buf), + g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); if (g_settings.fps_show) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index 928b91bcd1..3d4b9afeb9 100644 --- a/gfx/drivers_context/sdl_gl_ctx.c +++ b/gfx/drivers_context/sdl_gl_ctx.c @@ -17,6 +17,7 @@ #include "../../driver.h" #include "../gl_common.h" #include "../gfx_common.h" +#include "../video_monitor.h" #include "SDL.h" @@ -281,7 +282,8 @@ static void sdl_ctx_update_window_title(void *data) if (!sdl) return; - if (gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps))) + if (video_monitor_get_fps(buf, sizeof(buf), + g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps))) { #ifdef HAVE_SDL2 SDL_SetWindowTitle(sdl->g_win, buf); diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index 85d294cb62..4d8ff1ab5b 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -18,6 +18,7 @@ #include "../video_context_driver.h" #include "../gl_common.h" #include "../gfx_common.h" +#include "../video_monitor.h" #ifdef HAVE_CONFIG_H #include "../../config.h" @@ -125,7 +126,8 @@ static void gfx_ctx_vc_update_window_title(void *data) if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); + video_monitor_get_fps(buf, sizeof(buf), + g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); if (g_settings.fps_show) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index 5e3b4b86eb..7bd9f907ab 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -17,6 +17,7 @@ #include "../../driver.h" #include "../../general.h" #include "../gfx_common.h" +#include "../video_monitor.h" #include "../gl_common.h" #include @@ -194,7 +195,8 @@ static void gfx_ctx_vivante_update_window_title(void *data) if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); + video_monitor_get_fps(buf, sizeof(buf), + g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps)); if (g_settings.fps_show) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 0d4d92618c..09c6291386 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -17,6 +17,7 @@ #include "../../driver.h" #include "../../general.h" #include "../gfx_common.h" +#include "../video_monitor.h" #include "../gl_common.h" #include @@ -337,7 +338,7 @@ static void gfx_ctx_wl_update_window_title(void *data) (void)data; - if (gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? + if (video_monitor_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps))) wl_shell_surface_set_title(wl->g_shell_surf, buf); diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index f36dc0f045..3b0ca5f73b 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -25,6 +25,7 @@ #include "../video_context_driver.h" #include "../gl_common.h" #include "../gfx_common.h" +#include "../video_monitor.h" #include "win32_common.h" #include #include @@ -344,7 +345,8 @@ static void gfx_ctx_wgl_update_window_title(void *data) (void)data; - if (gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps))) + if (video_monitor_get_fps(buf, sizeof(buf), + g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps))) SetWindowText(g_hwnd, buf); if (g_settings.fps_show) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 7e4977d60d..e7a45d98be 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -21,6 +21,7 @@ #include "../../driver.h" #include "../gl_common.h" #include "../gfx_common.h" +#include "../video_monitor.h" #include "x11_common.h" #include @@ -215,7 +216,7 @@ static void gfx_ctx_xegl_update_window_title(void *data) (void)data; - if (gfx_get_fps(buf, sizeof(buf), + if (video_monitor_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps))) XStoreName(g_dpy, g_win, buf); if (g_settings.fps_show) diff --git a/gfx/gfx_common.c b/gfx/gfx_common.c index bd7645098c..32a87f0d89 100644 --- a/gfx/gfx_common.c +++ b/gfx/gfx_common.c @@ -16,71 +16,6 @@ #include "gfx_common.h" #include "../general.h" -#include "../performance.h" - -#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 - -/** - * gfx_get_fps: - * @buf : string suitable for Window title - * @size : size of buffer. - * @buf_fps : string of raw FPS only (optional). - * @size_fps : size of raw FPS buffer. - * - * Get the amount of frames per seconds. - * - * Returns: true if framerate per seconds could be obtained, - * otherwise false. - * - **/ -bool gfx_get_fps(char *buf, size_t size, char *buf_fps, size_t size_fps) -{ - retro_time_t new_time; - static retro_time_t curr_time; - static retro_time_t fps_time; - static float last_fps; - *buf = '\0'; - - new_time = rarch_get_time_usec(); - - if (g_extern.frame_count) - { - bool ret = false; - unsigned write_index = - g_extern.measure_data.frame_time_samples_count++ & - (MEASURE_FRAME_TIME_SAMPLES_COUNT - 1); - g_extern.measure_data.frame_time_samples[write_index] = - new_time - fps_time; - fps_time = new_time; - - if ((g_extern.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", - g_extern.title_buf, last_fps, g_extern.frame_count); - ret = true; - } - - if (buf_fps) - snprintf(buf_fps, size_fps, "FPS: %6.1f || Frames: %u", - last_fps, g_extern.frame_count); - - return ret; - } - - curr_time = fps_time = new_time; - strlcpy(buf, g_extern.title_buf, size); - if (buf_fps) - strlcpy(buf_fps, "N/A", size_fps); - - return true; -} #if defined(_WIN32) && !defined(_XBOX) #include @@ -339,4 +274,3 @@ void gfx_set_config_viewport(void) aspectratio_lut[ASPECT_RATIO_CONFIG].value = g_settings.video.aspect_ratio; } - diff --git a/gfx/gfx_common.h b/gfx/gfx_common.h index 8b2a19e11e..e3f361dc5f 100644 --- a/gfx/gfx_common.h +++ b/gfx/gfx_common.h @@ -25,28 +25,11 @@ extern "C" { #include #include "../general.h" #include -#include "../performance.h" #ifdef HAVE_CONFIG_H #include "../config.h" #endif -/** - * gfx_get_fps: - * @buf : string suitable for Window title - * @size : size of buffer. - * @buf_fps : string of raw FPS only (optional). - * @size_fps : size of raw FPS buffer. - * - * Get the amount of frames per seconds. - * - * Returns: true if framerate per seconds could be obtained, - * otherwise false. - * - **/ -bool gfx_get_fps(char *buf, size_t size, - char *buf_fps, size_t size_fps); - #ifdef _WIN32 void gfx_set_dwm(void); #endif diff --git a/gfx/video_monitor.c b/gfx/video_monitor.c index 65f997d85b..3b8ce0af33 100644 --- a/gfx/video_monitor.c +++ b/gfx/video_monitor.c @@ -17,6 +17,7 @@ #include "video_monitor.h" #include "../general.h" #include "../retroarch.h" +#include "../performance.h" void video_monitor_adjust_system_rates(void) { @@ -148,3 +149,68 @@ bool video_monitor_fps_statistics(double *refresh_rate, return true; } + +#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 + +/** + * video_monitor_get_fps: + * @buf : string suitable for Window title + * @size : size of buffer. + * @buf_fps : string of raw FPS only (optional). + * @size_fps : size of raw FPS buffer. + * + * Get the amount of frames per seconds. + * + * Returns: true if framerate per seconds could be obtained, + * otherwise false. + * + **/ +bool video_monitor_get_fps(char *buf, size_t size, + char *buf_fps, size_t size_fps) +{ + retro_time_t new_time; + static retro_time_t curr_time; + static retro_time_t fps_time; + static float last_fps; + *buf = '\0'; + + new_time = rarch_get_time_usec(); + + if (g_extern.frame_count) + { + bool ret = false; + unsigned write_index = + g_extern.measure_data.frame_time_samples_count++ & + (MEASURE_FRAME_TIME_SAMPLES_COUNT - 1); + g_extern.measure_data.frame_time_samples[write_index] = + new_time - fps_time; + fps_time = new_time; + + if ((g_extern.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", + g_extern.title_buf, last_fps, g_extern.frame_count); + ret = true; + } + + if (buf_fps) + snprintf(buf_fps, size_fps, "FPS: %6.1f || Frames: %u", + last_fps, g_extern.frame_count); + + return ret; + } + + curr_time = fps_time = new_time; + strlcpy(buf, g_extern.title_buf, size); + if (buf_fps) + strlcpy(buf_fps, "N/A", size_fps); + + return true; +} diff --git a/gfx/video_monitor.h b/gfx/video_monitor.h index 1a54389130..868a7f01fa 100644 --- a/gfx/video_monitor.h +++ b/gfx/video_monitor.h @@ -18,6 +18,7 @@ #define __VIDEO_MONITOR_H #include +#include #ifdef __cplusplus extern "C" { @@ -58,6 +59,22 @@ void video_monitor_compute_fps_statistics(void); bool video_monitor_fps_statistics(double *refresh_rate, double *deviation, unsigned *sample_points); +/** + * video_monitor_get_fps: + * @buf : string suitable for Window title + * @size : size of buffer. + * @buf_fps : string of raw FPS only (optional). + * @size_fps : size of raw FPS buffer. + * + * Get the amount of frames per seconds. + * + * Returns: true if framerate per seconds could be obtained, + * otherwise false. + * + **/ +bool video_monitor_get_fps(char *buf, size_t size, + char *buf_fps, size_t size_fps); + #ifdef __cplusplus } #endif diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 8b379fb871..c46fa5cd57 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -26,6 +26,7 @@ #include "../config.def.h" #include "../cheats.h" #include "../retroarch.h" +#include "../performance.h" #ifdef GEKKO enum diff --git a/settings_data.c b/settings_data.c index 0e7a9d9d05..ba5521abde 100644 --- a/settings_data.c +++ b/settings_data.c @@ -27,6 +27,7 @@ #include "file_ext.h" #include "settings.h" #include "retroarch.h" +#include "performance.h" #if defined(__CELLOS_LV2__) #include