diff --git a/driver.c b/driver.c index 5c9345b582..5efef8f072 100644 --- a/driver.c +++ b/driver.c @@ -2006,8 +2006,11 @@ void uninit_drivers(int flags) * Gets the monitor FPS statistics based on the current * runtime. * - * Returns: true (1) on success, false (0) if threaded - * video mode is enabled and/or three are less than 2 frame time samples. + * Returns: true (1) on success. + * false (0) if: + * a) threaded video mode is enabled + * b) less than 2 frame time samples. + * c) FPS monitor enable is off. **/ bool driver_monitor_fps_statistics(double *refresh_rate, double *deviation, unsigned *sample_points) @@ -2017,7 +2020,8 @@ bool driver_monitor_fps_statistics(double *refresh_rate, unsigned samples = min(MEASURE_FRAME_TIME_SAMPLES_COUNT, g_extern.measure_data.frame_time_samples_count); - if (g_settings.video.threaded || (samples < 2)) + if (!g_settings.fps_monitor_enable || + g_settings.video.threaded || (samples < 2)) return false; /* Measure statistics on frame time (microsecs), *not* FPS. */ diff --git a/driver.h b/driver.h index e43577b0e6..930f3036a7 100644 --- a/driver.h +++ b/driver.h @@ -644,8 +644,11 @@ void driver_set_monitor_refresh_rate(float hz); * Gets the monitor FPS statistics based on the current * runtime. * - * Returns: true (1) on success, false (0) if threaded - * video mode is enabled and/or three are less than 2 frame time samples. + * Returns: true (1) on success. + * false (0) if: + * a) threaded video mode is enabled + * b) less than 2 frame time samples. + * c) FPS monitor enable is off. **/ bool driver_monitor_fps_statistics(double *refresh_rate, double *deviation, unsigned *sample_points); diff --git a/general.h b/general.h index 5e71731ffb..11b5063ad8 100644 --- a/general.h +++ b/general.h @@ -355,6 +355,7 @@ struct settings bool menu_show_start_screen; #endif bool fps_show; + bool fps_monitor_enable; bool load_dummy_on_core_shutdown; bool core_specific_config; diff --git a/gfx/context/androidegl_ctx.c b/gfx/context/androidegl_ctx.c index 7644e1f573..639c1837b5 100644 --- a/gfx/context/androidegl_ctx.c +++ b/gfx/context/androidegl_ctx.c @@ -269,15 +269,16 @@ static void android_gfx_ctx_set_resize(void *data, static void android_gfx_ctx_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + gfx_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); } static bool android_gfx_ctx_set_video_mode(void *data, diff --git a/gfx/context/bbqnx_ctx.c b/gfx/context/bbqnx_ctx.c index 68835f5b71..373649128f 100644 --- a/gfx/context/bbqnx_ctx.c +++ b/gfx/context/bbqnx_ctx.c @@ -353,15 +353,16 @@ static void gfx_ctx_qnx_set_resize(void *data, unsigned width, unsigned height) static void gfx_ctx_qnx_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + gfx_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); } static bool gfx_ctx_qnx_set_video_mode(void *data, diff --git a/gfx/context/d3d_ctx.cpp b/gfx/context/d3d_ctx.cpp index e452e1e2f9..2b1287b5b6 100644 --- a/gfx/context/d3d_ctx.cpp +++ b/gfx/context/d3d_ctx.cpp @@ -114,16 +114,16 @@ static void gfx_ctx_d3d_update_title(void *data) { d3d_video_t *d3d = (d3d_video_t*)data; char buf[128], buffer_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; - if (gfx_get_fps(buf, sizeof(buf), fps_draw ? buffer_fps : NULL, sizeof(buffer_fps))) + if (gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buffer_fps : NULL, sizeof(buffer_fps))) { #ifndef _XBOX SetWindowText(d3d->hWnd, buf); #endif } - if (fps_draw) + if (g_settings.fps_show) { #ifdef _XBOX char mem[128]; diff --git a/gfx/context/drm_egl_ctx.c b/gfx/context/drm_egl_ctx.c index 50c8235b42..8ae17257f3 100644 --- a/gfx/context/drm_egl_ctx.c +++ b/gfx/context/drm_egl_ctx.c @@ -265,15 +265,16 @@ static void gfx_ctx_drm_egl_set_resize(void *data, static void gfx_ctx_drm_egl_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + gfx_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); } static void gfx_ctx_drm_egl_get_video_size(void *data, unsigned *width, unsigned *height) diff --git a/gfx/context/emscriptenegl_ctx.c b/gfx/context/emscriptenegl_ctx.c index 374c285840..321bf13eed 100644 --- a/gfx/context/emscriptenegl_ctx.c +++ b/gfx/context/emscriptenegl_ctx.c @@ -86,15 +86,16 @@ static void gfx_ctx_emscripten_set_resize(void *data, static void gfx_ctx_emscripten_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + gfx_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); } static void gfx_ctx_emscripten_get_video_size(void *data, diff --git a/gfx/context/glx_ctx.c b/gfx/context/glx_ctx.c index 1e468afb2f..b2644f2a45 100644 --- a/gfx/context/glx_ctx.c +++ b/gfx/context/glx_ctx.c @@ -192,18 +192,16 @@ static void gfx_ctx_glx_update_window_title(void *data) { char buf[128], buf_fps[128]; gfx_ctx_glx_data_t *glx = NULL; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; glx = (gfx_ctx_glx_data_t*)driver.video_context_data; - if (gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps))) + if (gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps))) XStoreName(glx->g_dpy, glx->g_win, buf); - - if (!fps_draw) - return; - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + if (g_settings.fps_show) + msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } static void gfx_ctx_glx_get_video_size(void *data, diff --git a/gfx/context/mali_fbdev_ctx.c b/gfx/context/mali_fbdev_ctx.c index 7f23014cf2..752e932c66 100644 --- a/gfx/context/mali_fbdev_ctx.c +++ b/gfx/context/mali_fbdev_ctx.c @@ -198,15 +198,16 @@ static void gfx_ctx_mali_fbdev_set_resize(void *data, static void gfx_ctx_mali_fbdev_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + gfx_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); } static bool gfx_ctx_mali_fbdev_set_video_mode(void *data, diff --git a/gfx/context/ps3_ctx.c b/gfx/context/ps3_ctx.c index d106e2cf3f..7c36996147 100644 --- a/gfx/context/ps3_ctx.c +++ b/gfx/context/ps3_ctx.c @@ -209,14 +209,14 @@ static void gfx_ctx_ps3_update_window_title(void *data) { (void)data; char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), fps_draw - ? buf_fps : NULL, sizeof(buf_fps)); - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + gfx_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); } static void gfx_ctx_ps3_get_video_size(void *data, diff --git a/gfx/context/sdl_gl_ctx.c b/gfx/context/sdl_gl_ctx.c index 979bacc080..536ba41f3e 100644 --- a/gfx/context/sdl_gl_ctx.c +++ b/gfx/context/sdl_gl_ctx.c @@ -277,12 +277,12 @@ static void sdl_ctx_update_window_title(void *data) { char buf[128], buf_fps[128]; gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)driver.video_context_data; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; if (!sdl) return; - if (gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps))) + if (gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps))) { #ifdef HAVE_SDL2 SDL_SetWindowTitle(sdl->g_win, buf); @@ -290,8 +290,7 @@ static void sdl_ctx_update_window_title(void *data) SDL_WM_SetCaption(buf, NULL); #endif } - - if (fps_draw) + if (g_settings.fps_show) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } diff --git a/gfx/context/vc_egl_ctx.c b/gfx/context/vc_egl_ctx.c index c3b2c3c60b..8f68ad235f 100644 --- a/gfx/context/vc_egl_ctx.c +++ b/gfx/context/vc_egl_ctx.c @@ -118,15 +118,16 @@ static void gfx_ctx_vc_set_resize(void *data, unsigned width, unsigned height) static void gfx_ctx_vc_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + gfx_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); } static void gfx_ctx_vc_get_video_size(void *data, diff --git a/gfx/context/vivante_fbdev_ctx.c b/gfx/context/vivante_fbdev_ctx.c index cb7ca3ebc1..5e3b4b86eb 100644 --- a/gfx/context/vivante_fbdev_ctx.c +++ b/gfx/context/vivante_fbdev_ctx.c @@ -187,15 +187,16 @@ static void gfx_ctx_vivante_set_resize(void *data, static void gfx_ctx_vivante_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; if (!fps_draw) return; - gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps)); - msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); + gfx_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); } static bool gfx_ctx_vivante_set_video_mode(void *data, diff --git a/gfx/context/wayland_ctx.c b/gfx/context/wayland_ctx.c index a38885ae7f..0d4d92618c 100644 --- a/gfx/context/wayland_ctx.c +++ b/gfx/context/wayland_ctx.c @@ -331,17 +331,17 @@ static void gfx_ctx_wl_set_resize(void *data, unsigned width, unsigned height) static void gfx_ctx_wl_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*) driver.video_context_data; (void)data; - if (gfx_get_fps(buf, sizeof(buf), - fps_draw ? buf_fps : NULL, sizeof(buf_fps))) + if (gfx_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); - if (fps_draw) + if (g_settings.fps_show) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } diff --git a/gfx/context/wgl_ctx.c b/gfx/context/wgl_ctx.c index a434583bce..bc4a71e7f5 100644 --- a/gfx/context/wgl_ctx.c +++ b/gfx/context/wgl_ctx.c @@ -333,14 +333,13 @@ static void gfx_ctx_wgl_set_resize(void *data, static void gfx_ctx_wgl_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; - if (gfx_get_fps(buf, sizeof(buf), fps_draw ? buf_fps : NULL, sizeof(buf_fps))) + if (gfx_get_fps(buf, sizeof(buf), g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps))) SetWindowText(g_hwnd, buf); - - if (fps_draw) + if (g_settings.fps_show) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } diff --git a/gfx/context/xegl_ctx.c b/gfx/context/xegl_ctx.c index 46b7e3d77c..3e24f0feb7 100644 --- a/gfx/context/xegl_ctx.c +++ b/gfx/context/xegl_ctx.c @@ -212,15 +212,14 @@ static void gfx_ctx_xegl_set_resize(void *data, static void gfx_ctx_xegl_update_window_title(void *data) { char buf[128], buf_fps[128]; - bool fps_draw = g_settings.fps_show; + bool fps_draw = g_settings.fps_show || g_settings.fps_monitor_enable; (void)data; if (gfx_get_fps(buf, sizeof(buf), - fps_draw ? buf_fps : NULL, sizeof(buf_fps))) + g_settings.fps_show ? buf_fps : NULL, sizeof(buf_fps))) XStoreName(g_dpy, g_win, buf); - - if (fps_draw) + if (g_settings.fps_show) msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1); } diff --git a/settings.c b/settings.c index ac0248f6ea..702c91021f 100644 --- a/settings.c +++ b/settings.c @@ -1242,6 +1242,7 @@ static bool config_load_file(const char *path, bool set_defaults) } CONFIG_GET_BOOL(fps_show, "fps_show"); + CONFIG_GET_BOOL(fps_monitor_enable, "fps_monitor_enable"); CONFIG_GET_BOOL(load_dummy_on_core_shutdown, "load_dummy_on_core_shutdown"); CONFIG_GET_PATH(libretro_info_path, "libretro_info_path"); @@ -1723,6 +1724,7 @@ bool config_save_file(const char *path) config_set_bool(conf, "load_dummy_on_core_shutdown", g_settings.load_dummy_on_core_shutdown); config_set_bool(conf, "fps_show", g_settings.fps_show); + config_set_bool(conf, "fps_monitor_enable", g_settings.fps_monitor_enable); config_set_path(conf, "libretro_path", g_settings.libretro); config_set_path(conf, "libretro_directory", g_settings.libretro_directory); config_set_path(conf, "libretro_info_path", g_settings.libretro_info_path); diff --git a/settings_data.c b/settings_data.c index d4f7e54480..fee0b86835 100644 --- a/settings_data.c +++ b/settings_data.c @@ -4013,6 +4013,17 @@ static bool setting_data_append_list_video_options( general_read_handler); settings_list_current_add_range(list, list_info, 0, 0, 0.001, true, false); + CONFIG_BOOL(g_settings.fps_monitor_enable, + "fps_monitor_enable", + "Monitor FPS Enable", + true, + "OFF", + "ON", + group_info.name, + subgroup_info.name, + general_write_handler, + general_read_handler); + CONFIG_FLOAT( g_settings.video.refresh_rate, "video_refresh_rate_auto",