mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 00:20:01 +00:00
Add monitor FPS enable option
This commit is contained in:
parent
371e3ebdd7
commit
badb29942b
10
driver.c
10
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. */
|
||||
|
7
driver.h
7
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);
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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];
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user