add memory stats to more context drivers, use correct default variables for fps/stats/framecount/memory_show

This commit is contained in:
Brad Parker 2019-02-15 15:58:52 -05:00
parent 5bc8330548
commit 5e177c75a5
16 changed files with 249 additions and 27 deletions

View File

@ -1355,10 +1355,10 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings,
SETTING_BOOL("check_firmware_before_loading", &settings->bools.check_firmware_before_loading, true, check_firmware_before_loading, false);
SETTING_BOOL("builtin_mediaplayer_enable", &settings->bools.multimedia_builtin_mediaplayer_enable, false, false /* TODO */, false);
SETTING_BOOL("builtin_imageviewer_enable", &settings->bools.multimedia_builtin_imageviewer_enable, true, true, false);
SETTING_BOOL("fps_show", &settings->bools.video_fps_show, true, false, false);
SETTING_BOOL("statistics_show", &settings->bools.video_statistics_show, true, false, false);
SETTING_BOOL("framecount_show", &settings->bools.video_framecount_show, true, false, false);
SETTING_BOOL("memory_show", &settings->bools.video_memory_show, true, false, false);
SETTING_BOOL("fps_show", &settings->bools.video_fps_show, true, fps_show, false);
SETTING_BOOL("statistics_show", &settings->bools.video_statistics_show, true, statistics_show, false);
SETTING_BOOL("framecount_show", &settings->bools.video_framecount_show, true, framecount_show, false);
SETTING_BOOL("memory_show", &settings->bools.video_memory_show, true, memory_show, false);
SETTING_BOOL("ui_menubar_enable", &settings->bools.ui_menubar_enable, true, true, false);
SETTING_BOOL("suspend_screensaver_enable", &settings->bools.ui_suspend_screensaver_enable, true, true, false);
SETTING_BOOL("rewind_enable", &settings->bools.rewind_enable, true, rewind_enable, false);

View File

@ -28,6 +28,7 @@
#include "../../verbosity.h"
#include "../../ui/ui_companion_driver.h"
#include "../video_driver.h"
#include "../frontend/frontend_driver.h"
#include "win32_common.h"
#if defined(HAVE_DYNAMIC) && !defined(__WINRT__)
@ -310,15 +311,15 @@ void dxgi_update_title(video_frame_info_t* video_info)
if (settings->bools.video_memory_show)
{
#ifndef __WINRT__
MEMORYSTATUS stat;
uint64_t mem_bytes_used = frontend_driver_get_used_memory();
uint64_t mem_bytes_total = frontend_driver_get_total_memory();
char mem[128];
mem[0] = '\0';
GlobalMemoryStatus(&stat);
snprintf(
mem, sizeof(mem), " || MEM: %.2f/%.2fMB", stat.dwAvailPhys / (1024.0f * 1024.0f),
stat.dwTotalPhys / (1024.0f * 1024.0f));
mem, sizeof(mem), " || MEM: %.2f/%.2fMB", mem_bytes_used / (1024.0f * 1024.0f),
mem_bytes_total / (1024.0f * 1024.0f));
strlcat(video_info->fps_text, mem, sizeof(video_info->fps_text));
#endif
}

View File

@ -39,6 +39,7 @@
#include <X11/extensions/xf86vmode.h>
#include <encodings/utf.h>
#include <compat/strl.h>
#ifdef HAVE_DBUS
#include "dbus_common.h"
@ -49,6 +50,7 @@
#include "../../input/input_keymaps.h"
#include "../../input/common/input_x11_common.h"
#include "../../verbosity.h"
#include "../../configuration.h"
#define _NET_WM_STATE_ADD 1
#define MOVERESIZE_GRAVITY_CENTER 5
@ -648,10 +650,26 @@ bool x11_connect(void)
void x11_update_title(void *data, void *data2)
{
const settings_t *settings = config_get_ptr();
video_frame_info_t *video_info = (video_frame_info_t*)data2;
char title[128];
title[0] = '\0';
if (settings->bools.video_memory_show)
{
uint64_t mem_bytes_used = frontend_driver_get_used_memory();
uint64_t mem_bytes_total = frontend_driver_get_total_memory();
char mem[128];
mem[0] = '\0';
snprintf(
mem, sizeof(mem), " || MEM: %.2f/%.2fMB", mem_bytes_used / (1024.0f * 1024.0f),
mem_bytes_total / (1024.0f * 1024.0f));
strlcat(video_info->fps_text, mem, sizeof(video_info->fps_text));
}
video_driver_get_window_title(title, sizeof(title));
if (title[0])

View File

@ -31,7 +31,7 @@
#include "../../driver.h"
#include "../../verbosity.h"
#include "../configuration.h"
#include "../../configuration.h"
#include "../../retroarch.h"
#include "../video_driver.h"
#include "../font_driver.h"

View File

@ -37,6 +37,7 @@
#include "../video_coord_array.h"
#include "../../configuration.h"
#include "../../dynamic.h"
#include "../../frontend/frontend_driver.h"
#include "../video_driver.h"
#ifdef HAVE_THREADS
@ -1492,21 +1493,25 @@ static void d3d8_get_overlay_interface(void *data,
static void d3d8_update_title(video_frame_info_t *video_info)
{
const settings_t *settings = config_get_ptr();
#ifndef _XBOX
const ui_window_t *window = ui_companion_driver_get_window_ptr();
#endif
if (video_info->fps_show)
if (settings->bools.video_memory_show)
{
MEMORYSTATUS stat;
char mem[128];
#ifndef __WINRT__
uint64_t mem_bytes_used = frontend_driver_get_used_memory();
uint64_t mem_bytes_total = frontend_driver_get_total_memory();
char mem[128];
mem[0] = '\0';
GlobalMemoryStatus(&stat);
snprintf(mem, sizeof(mem), "|| MEM: %.2f/%.2fMB",
stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f));
snprintf(
mem, sizeof(mem), " || MEM: %.2f/%.2fMB", mem_bytes_used / (1024.0f * 1024.0f),
mem_bytes_total / (1024.0f * 1024.0f));
strlcat(video_info->fps_text, mem, sizeof(video_info->fps_text));
#endif
}
#ifndef _XBOX

View File

@ -39,6 +39,7 @@
#include "../../dynamic.h"
#include "../video_driver.h"
#include "../../ui/ui_companion_driver.h"
#include "../../frontend/frontend_driver.h"
#ifdef HAVE_THREADS
#include "../video_thread_wrapper.h"
@ -1562,23 +1563,27 @@ static void d3d9_get_overlay_interface(void *data,
static void d3d9_update_title(video_frame_info_t *video_info)
{
const settings_t *settings = config_get_ptr();
#ifdef _XBOX
const ui_window_t *window = NULL;
#else
const ui_window_t *window = ui_companion_driver_get_window_ptr();
#endif
if (video_info->fps_show)
if (settings->bools.video_memory_show)
{
MEMORYSTATUS stat;
char mem[128];
#ifndef __WINRT__
uint64_t mem_bytes_used = frontend_driver_get_used_memory();
uint64_t mem_bytes_total = frontend_driver_get_total_memory();
char mem[128];
mem[0] = '\0';
GlobalMemoryStatus(&stat);
snprintf(mem, sizeof(mem), "|| MEM: %.2f/%.2fMB",
stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f));
snprintf(
mem, sizeof(mem), " || MEM: %.2f/%.2fMB", mem_bytes_used / (1024.0f * 1024.0f),
mem_bytes_total / (1024.0f * 1024.0f));
strlcat(video_info->fps_text, mem, sizeof(video_info->fps_text));
#endif
}
#ifndef _XBOX

View File

@ -793,6 +793,9 @@ static bool drm_gfx_frame(void *data, const void *frame, unsigned width,
menu_driver_frame(video_info);
#endif
video_info->cb_update_window_title(
video_info->context_data, video_info);
/* Update main surface: locate free page, blit and flip. */
drm_surface_update(_drmvars, frame, _drmvars->main_surface);
return true;

View File

@ -19,6 +19,7 @@
#include <formats/image.h>
#include <string/stdstring.h>
#include <compat/strl.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
@ -36,8 +37,10 @@
#include "../common/vulkan_common.h"
#endif
#include "../../frontend/frontend_driver.h"
#include "../../frontend/drivers/platform_unix.h"
#include "../../verbosity.h"
#include "../../configuration.h"
static enum gfx_ctx_api android_api = GFX_CTX_NONE;
@ -595,6 +598,26 @@ static void android_gfx_ctx_set_flags(void *data, uint32_t flags)
(void)flags;
}
static void android_gfx_update_window_title(void *data, void *data2)
{
const settings_t *settings = config_get_ptr();
video_frame_info_t* video_info = (video_frame_info_t*)data2;
if (settings->bools.video_memory_show)
{
uint64_t mem_bytes_used = frontend_driver_get_used_memory();
uint64_t mem_bytes_total = frontend_driver_get_total_memory();
char mem[128];
mem[0] = '\0';
snprintf(
mem, sizeof(mem), " || MEM: %.2f/%.2fMB", mem_bytes_used / (1024.0f * 1024.0f),
mem_bytes_total / (1024.0f * 1024.0f));
strlcat(video_info->fps_text, mem, sizeof(video_info->fps_text));
}
}
const gfx_ctx_driver_t gfx_ctx_android = {
android_gfx_ctx_init,
android_gfx_ctx_destroy,
@ -609,7 +632,7 @@ const gfx_ctx_driver_t gfx_ctx_android = {
NULL, /* get_video_output_next */
android_gfx_ctx_get_metrics,
NULL,
NULL, /* update_title */
android_gfx_update_window_title,
android_gfx_ctx_check_window,
android_gfx_ctx_set_resize,
android_gfx_ctx_has_focus,

View File

@ -919,6 +919,26 @@ static void gfx_ctx_drm_set_flags(void *data, uint32_t flags)
drm->core_hw_context_enable = true;
}
void gfx_ctx_drm_update_window_title(void *data, void *data2)
{
const settings_t *settings = config_get_ptr();
video_frame_info_t* video_info = (video_frame_info_t*)data2;
if (settings->bools.video_memory_show)
{
uint64_t mem_bytes_used = frontend_driver_get_used_memory();
uint64_t mem_bytes_total = frontend_driver_get_total_memory();
char mem[128];
mem[0] = '\0';
snprintf(
mem, sizeof(mem), " || MEM: %.2f/%.2fMB", mem_bytes_used / (1024.0f * 1024.0f),
mem_bytes_total / (1024.0f * 1024.0f));
strlcat(video_info->fps_text, mem, sizeof(video_info->fps_text));
}
}
const gfx_ctx_driver_t gfx_ctx_drm = {
gfx_ctx_drm_init,
gfx_ctx_drm_destroy,
@ -933,7 +953,7 @@ const gfx_ctx_driver_t gfx_ctx_drm = {
NULL, /* get_video_output_next */
NULL, /* get_metrics */
NULL,
NULL, /* update_window_title */
gfx_ctx_drm_update_window_title,
gfx_ctx_drm_check_window,
NULL, /* set_resize */
gfx_ctx_drm_has_focus,

View File

@ -37,6 +37,7 @@
#include "../../configuration.h"
#include "../../dynamic.h"
#include "../../verbosity.h"
#include "../../frontend/frontend_driver.h"
#include "../video_driver.h"
#include "../common/win32_common.h"
@ -95,11 +96,29 @@ static bool gfx_ctx_gdi_set_resize(void *data,
static void gfx_ctx_gdi_update_window_title(void *data, void *data2)
{
const settings_t *settings = config_get_ptr();
video_frame_info_t* video_info = (video_frame_info_t*)data2;
const ui_window_t *window = ui_companion_driver_get_window_ptr();
char title[128];
title[0] = '\0';
if (settings->bools.video_memory_show)
{
#ifndef __WINRT__
uint64_t mem_bytes_used = frontend_driver_get_used_memory();
uint64_t mem_bytes_total = frontend_driver_get_total_memory();
char mem[128];
mem[0] = '\0';
snprintf(
mem, sizeof(mem), " || MEM: %.2f/%.2fMB", mem_bytes_used / (1024.0f * 1024.0f),
mem_bytes_total / (1024.0f * 1024.0f));
strlcat(video_info->fps_text, mem, sizeof(video_info->fps_text));
#endif
}
video_driver_get_window_title(title, sizeof(title));
if (window && title[0])

View File

@ -13,6 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <compat/strl.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
@ -20,6 +22,7 @@
#include "../../frontend/frontend_driver.h"
#include "../common/vulkan_common.h"
#include "../../verbosity.h"
#include "../../configuration.h"
typedef struct
{
@ -234,6 +237,26 @@ static void *gfx_ctx_khr_display_get_context_data(void *data)
return &khr->vk.context;
}
static void gfx_ctx_khr_display_update_window_title(void *data, void *data2)
{
const settings_t *settings = config_get_ptr();
video_frame_info_t *video_info = (video_frame_info_t*)data2;
if (settings->bools.video_memory_show)
{
uint64_t mem_bytes_used = frontend_driver_get_used_memory();
uint64_t mem_bytes_total = frontend_driver_get_total_memory();
char mem[128];
mem[0] = '\0';
snprintf(
mem, sizeof(mem), " || MEM: %.2f/%.2fMB", mem_bytes_used / (1024.0f * 1024.0f),
mem_bytes_total / (1024.0f * 1024.0f));
strlcat(video_info->fps_text, mem, sizeof(video_info->fps_text));
}
}
const gfx_ctx_driver_t gfx_ctx_khr_display = {
gfx_ctx_khr_display_init,
gfx_ctx_khr_display_destroy,
@ -248,7 +271,7 @@ const gfx_ctx_driver_t gfx_ctx_khr_display = {
NULL, /* get_video_output_next */
NULL, /* get_metrics */
NULL,
NULL, /* update_title */
gfx_ctx_khr_display_update_window_title,
gfx_ctx_khr_display_check_window,
gfx_ctx_khr_display_set_resize,
gfx_ctx_khr_display_has_focus,

View File

@ -24,6 +24,8 @@
#include <linux/fb.h>
#include <linux/vt.h>
#include <compat/strl.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
@ -38,6 +40,7 @@
#include "../../frontend/frontend_driver.h"
#include "../../verbosity.h"
#include "../../configuration.h"
typedef struct
{
@ -300,6 +303,26 @@ static float gfx_ctx_mali_fbdev_get_refresh_rate(void *data)
return mali->refresh_rate;
}
static void gfx_ctx_mali_fbdev_update_window_title(void *data, void *data2)
{
const settings_t *settings = config_get_ptr();
video_frame_info_t* video_info = (video_frame_info_t*)data2;
if (settings->bools.video_memory_show)
{
uint64_t mem_bytes_used = frontend_driver_get_used_memory();
uint64_t mem_bytes_total = frontend_driver_get_total_memory();
char mem[128];
mem[0] = '\0';
snprintf(
mem, sizeof(mem), " || MEM: %.2f/%.2fMB", mem_bytes_used / (1024.0f * 1024.0f),
mem_bytes_total / (1024.0f * 1024.0f));
strlcat(video_info->fps_text, mem, sizeof(video_info->fps_text));
}
}
const gfx_ctx_driver_t gfx_ctx_mali_fbdev = {
gfx_ctx_mali_fbdev_init,
gfx_ctx_mali_fbdev_destroy,
@ -314,7 +337,7 @@ const gfx_ctx_driver_t gfx_ctx_mali_fbdev = {
NULL, /* get_video_output_next */
NULL, /* get_metrics */
NULL,
NULL, /* update_title */
gfx_ctx_mali_fbdev_update_window_title,
gfx_ctx_mali_fbdev_check_window,
NULL, /* set_resize */
gfx_ctx_mali_fbdev_has_focus,

View File

@ -15,12 +15,16 @@
*/
#include <stdlib.h>
#include <compat/strl.h>
#ifdef HAVE_CONFIG_H
#include "../../config.h"
#endif
#include "../common/orbis_common.h"
#include "../../frontend/frontend_driver.h"
#include "../../configuration.h"
static enum gfx_ctx_api ctx_orbis_api = GFX_CTX_OPENGL_API;
@ -273,6 +277,26 @@ static float orbis_ctx_get_refresh_rate(void *data)
return ctx_orbis->refresh_rate;
}
static void orbis_ctx_update_window_title(void *data, void *data2)
{
const settings_t *settings = config_get_ptr();
video_frame_info_t* video_info = (video_frame_info_t*)data2;
if (settings->bools.video_memory_show)
{
uint64_t mem_bytes_used = frontend_driver_get_used_memory();
uint64_t mem_bytes_total = frontend_driver_get_total_memory();
char mem[128];
mem[0] = '\0';
snprintf(
mem, sizeof(mem), " || MEM: %.2f/%.2fMB", mem_bytes_used / (1024.0f * 1024.0f),
mem_bytes_total / (1024.0f * 1024.0f));
strlcat(video_info->fps_text, mem, sizeof(video_info->fps_text));
}
}
const gfx_ctx_driver_t orbis_ctx = {
orbis_ctx_init,
orbis_ctx_destroy,
@ -287,7 +311,7 @@ const gfx_ctx_driver_t orbis_ctx = {
NULL, /* get_video_output_next */
NULL, /* get_metrics */
NULL,
NULL, /* update_title */
orbis_ctx_update_window_title,
orbis_ctx_check_window,
NULL, /* set_resize */
orbis_ctx_has_focus,

View File

@ -30,9 +30,12 @@
#endif
#endif
#include <compat/strl.h>
#include "../../configuration.h"
#include "../../verbosity.h"
#include "../../defines/ps3_defines.h"
#include "../../frontend/frontend_driver.h"
#include "../common/gl_common.h"
#include "../video_driver.h"
@ -411,6 +414,26 @@ static void gfx_ctx_ps3_set_flags(void *data, uint32_t flags)
(void)data;
}
static void gfx_ctx_ps3_update_window_title(void *data, void *data2)
{
const settings_t *settings = config_get_ptr();
video_frame_info_t* video_info = (video_frame_info_t*)data2;
if (settings->bools.video_memory_show)
{
uint64_t mem_bytes_used = frontend_driver_get_used_memory();
uint64_t mem_bytes_total = frontend_driver_get_total_memory();
char mem[128];
mem[0] = '\0';
snprintf(
mem, sizeof(mem), " || MEM: %.2f/%.2fMB", mem_bytes_used / (1024.0f * 1024.0f),
mem_bytes_total / (1024.0f * 1024.0f));
strlcat(video_info->fps_text, mem, sizeof(video_info->fps_text));
}
}
const gfx_ctx_driver_t gfx_ctx_ps3 = {
gfx_ctx_ps3_init,
gfx_ctx_ps3_destroy,
@ -425,7 +448,7 @@ const gfx_ctx_driver_t gfx_ctx_ps3 = {
gfx_ctx_ps3_get_video_output_next,
NULL, /* get_metrics */
NULL,
NULL, /* update_title */
gfx_ctx_ps3_update_window_title,
gfx_ctx_ps3_check_window,
NULL, /* set_resize */
gfx_ctx_ps3_has_focus,

View File

@ -50,12 +50,28 @@ static bool gfx_ctx_sixel_set_resize(void *data,
static void gfx_ctx_sixel_update_window_title(void *data, void *data2)
{
const settings_t *settings = config_get_ptr();
video_frame_info_t *video_info = (video_frame_info_t*)data2;
#if defined(_WIN32) && !defined(_XBOX)
const ui_window_t *window = ui_companion_driver_get_window_ptr();
char title[128];
title[0] = '\0';
if (settings->bools.video_memory_show)
{
uint64_t mem_bytes_used = frontend_driver_get_used_memory();
uint64_t mem_bytes_total = frontend_driver_get_total_memory();
char mem[128];
mem[0] = '\0';
snprintf(
mem, sizeof(mem), " || MEM: %.2f/%.2fMB", mem_bytes_used / (1024.0f * 1024.0f),
mem_bytes_total / (1024.0f * 1024.0f));
strlcat(video_info->fps_text, mem, sizeof(video_info->fps_text));
}
video_driver_get_window_title(title, sizeof(title));
if (window && title[0])

View File

@ -42,6 +42,7 @@
#include "../../configuration.h"
#include "../../dynamic.h"
#include "../../verbosity.h"
#include "../../frontend/frontend_driver.h"
#include "../video_driver.h"
#include "../common/win32_common.h"
@ -475,10 +476,28 @@ static bool gfx_ctx_wgl_set_resize(void *data,
static void gfx_ctx_wgl_update_title(void *data, void *data2)
{
const settings_t *settings = config_get_ptr();
video_frame_info_t* video_info = (video_frame_info_t*)data2;
char title[128];
title[0] = '\0';
if (settings->bools.video_memory_show)
{
#ifndef __WINRT__
uint64_t mem_bytes_used = frontend_driver_get_used_memory();
uint64_t mem_bytes_total = frontend_driver_get_total_memory();
char mem[128];
mem[0] = '\0';
snprintf(
mem, sizeof(mem), " || MEM: %.2f/%.2fMB", mem_bytes_used / (1024.0f * 1024.0f),
mem_bytes_total / (1024.0f * 1024.0f));
strlcat(video_info->fps_text, mem, sizeof(video_info->fps_text));
#endif
}
video_driver_get_window_title(title, sizeof(title));
if (title[0])