mirror of
https://github.com/libretro/RetroArch
synced 2025-02-04 03:40:03 +00:00
Rewrite gfx_get_fps - now outputs proper string for FPS output
This commit is contained in:
parent
80079e297b
commit
c0c6ecc6cb
@ -380,8 +380,8 @@ void apple_gfx_ctx_get_video_size(unsigned* width, unsigned* height)
|
|||||||
void apple_gfx_ctx_update_window_title(void)
|
void apple_gfx_ctx_update_window_title(void)
|
||||||
{
|
{
|
||||||
#ifdef OSX
|
#ifdef OSX
|
||||||
static char buf[128];
|
static char buf[128], buf_fps[128];
|
||||||
bool got_text = gfx_get_fps(buf, sizeof(buf), false);
|
bool got_text = gfx_get_fps(buf, sizeof(buf), false, buf_fps, sizeof(buf_fps));
|
||||||
static const char* const text = buf; // < Can't access buf directly in the block
|
static const char* const text = buf; // < Can't access buf directly in the block
|
||||||
|
|
||||||
if (got_text)
|
if (got_text)
|
||||||
|
@ -196,8 +196,8 @@ static void gfx_ctx_set_resize(unsigned width, unsigned height)
|
|||||||
|
|
||||||
static void gfx_ctx_update_window_title(void)
|
static void gfx_ctx_update_window_title(void)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128], buf_fps[128];
|
||||||
gfx_get_fps(buf, sizeof(buf), false);
|
gfx_get_fps(buf, sizeof(buf), false, buf_fps, sizeof(buf_fps));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gfx_ctx_set_video_mode(
|
static bool gfx_ctx_set_video_mode(
|
||||||
|
@ -322,8 +322,8 @@ static void gfx_ctx_set_resize(unsigned width, unsigned height)
|
|||||||
|
|
||||||
static void gfx_ctx_update_window_title(void)
|
static void gfx_ctx_update_window_title(void)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128], buf_fps[128];
|
||||||
gfx_get_fps(buf, sizeof(buf), false);
|
gfx_get_fps(buf, sizeof(buf), false, buf_fps, sizeof(buf_fps));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gfx_ctx_set_video_mode(
|
static bool gfx_ctx_set_video_mode(
|
||||||
|
@ -215,8 +215,8 @@ static void gfx_ctx_set_resize(unsigned width, unsigned height)
|
|||||||
|
|
||||||
static void gfx_ctx_update_window_title(void)
|
static void gfx_ctx_update_window_title(void)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128], buf_fps[128];
|
||||||
gfx_get_fps(buf, sizeof(buf), false);
|
gfx_get_fps(buf, sizeof(buf), false, buf_fps, sizeof(buf_fps));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gfx_ctx_get_video_size(unsigned *width, unsigned *height)
|
static void gfx_ctx_get_video_size(unsigned *width, unsigned *height)
|
||||||
|
@ -82,8 +82,8 @@ static void gfx_ctx_set_resize(unsigned width, unsigned height)
|
|||||||
|
|
||||||
static void gfx_ctx_update_window_title(void)
|
static void gfx_ctx_update_window_title(void)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128], buf_fps[128];
|
||||||
if (gfx_get_fps(buf, sizeof(buf), false))
|
if (gfx_get_fps(buf, sizeof(buf), false, buf_fps, sizeof(buf_fps))
|
||||||
RARCH_LOG("%s\n", buf);
|
RARCH_LOG("%s\n", buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,13 +166,13 @@ static void gfx_ctx_set_resize(unsigned width, unsigned height)
|
|||||||
static void gfx_ctx_update_window_title(void)
|
static void gfx_ctx_update_window_title(void)
|
||||||
{
|
{
|
||||||
gl_t *gl = (gl_t*)driver.video_data;
|
gl_t *gl = (gl_t*)driver.video_data;
|
||||||
char buf[128];
|
char buf[128], buf_fps[128];
|
||||||
if (gfx_get_fps(buf, sizeof(buf), true))
|
if (gfx_get_fps(buf, sizeof(buf), true, buf_fps, sizeof(buf_fps)))
|
||||||
XStoreName(g_dpy, g_win, buf);
|
XStoreName(g_dpy, g_win, buf);
|
||||||
|
|
||||||
if ((g_extern.lifecycle_mode_state & (1ULL << MODE_FPS_DRAW)) &&
|
if ((g_extern.lifecycle_mode_state & (1ULL << MODE_FPS_DRAW)) &&
|
||||||
gl->font_ctx)
|
gl->font_ctx)
|
||||||
msg_queue_push(g_extern.msg_queue, buf, 1, 1);
|
msg_queue_push(g_extern.msg_queue, buf_fps, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gfx_ctx_get_video_size(unsigned *width, unsigned *height)
|
static void gfx_ctx_get_video_size(unsigned *width, unsigned *height)
|
||||||
|
@ -63,8 +63,8 @@ static void gfx_ctx_set_resize(unsigned width, unsigned height)
|
|||||||
|
|
||||||
static void gfx_ctx_update_window_title(void)
|
static void gfx_ctx_update_window_title(void)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128], buf_fps[128];
|
||||||
gfx_get_fps(buf, sizeof(buf), false);
|
gfx_get_fps(buf, sizeof(buf), false, buf_fps, sizeof(buf_fps));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gfx_ctx_set_video_mode(
|
static bool gfx_ctx_set_video_mode(
|
||||||
|
@ -189,9 +189,9 @@ static void gfx_ctx_set_resize(unsigned width, unsigned height) { }
|
|||||||
static void gfx_ctx_update_window_title(void)
|
static void gfx_ctx_update_window_title(void)
|
||||||
{
|
{
|
||||||
gl_t *gl = (gl_t*)driver.video_data;
|
gl_t *gl = (gl_t*)driver.video_data;
|
||||||
char buf[128];
|
char buf[128], buf_fps[128];
|
||||||
|
|
||||||
if (gfx_get_fps(buf, sizeof(buf), false) &&
|
if (gfx_get_fps(buf, sizeof(buf), false, buf_fps, sizeof(buf_fps)) &&
|
||||||
(g_extern.lifecycle_mode_state & (1ULL << MODE_FPS_DRAW)) &&
|
(g_extern.lifecycle_mode_state & (1ULL << MODE_FPS_DRAW)) &&
|
||||||
gl->font_ctx)
|
gl->font_ctx)
|
||||||
{
|
{
|
||||||
|
@ -109,8 +109,8 @@ static void gfx_ctx_set_resize(unsigned width, unsigned height)
|
|||||||
|
|
||||||
static void gfx_ctx_update_window_title(void)
|
static void gfx_ctx_update_window_title(void)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128], buf_fps[128]
|
||||||
gfx_get_fps(buf, sizeof(buf), false);
|
gfx_get_fps(buf, sizeof(buf), false, buf_fps, sizeof(buf_fps));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gfx_ctx_get_video_size(unsigned *width, unsigned *height)
|
static void gfx_ctx_get_video_size(unsigned *width, unsigned *height)
|
||||||
|
@ -277,8 +277,8 @@ static void gfx_ctx_set_resize(unsigned width, unsigned height)
|
|||||||
|
|
||||||
static void gfx_ctx_update_window_title(void)
|
static void gfx_ctx_update_window_title(void)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128], buf_fps[128];
|
||||||
if (gfx_get_fps(buf, sizeof(buf), false))
|
if (gfx_get_fps(buf, sizeof(buf), false, buf_fps, sizeof(buf_fps)))
|
||||||
SetWindowText(g_hwnd, buf);
|
SetWindowText(g_hwnd, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,10 +83,10 @@ extern unsigned font_x, font_y;
|
|||||||
|
|
||||||
static void gfx_ctx_xdk_update_window_title(void)
|
static void gfx_ctx_xdk_update_window_title(void)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128], buf_fps[128];
|
||||||
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data;
|
xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)driver.video_data;
|
||||||
|
|
||||||
if (gfx_get_fps(buf, sizeof(buf), false) &&
|
if (gfx_get_fps(buf, sizeof(buf), false, buf_fps, sizeof(buf_fps)) &&
|
||||||
g_extern.lifecycle_mode_state & (1ULL << MODE_FPS_DRAW))
|
g_extern.lifecycle_mode_state & (1ULL << MODE_FPS_DRAW))
|
||||||
{
|
{
|
||||||
MEMORYSTATUS stat;
|
MEMORYSTATUS stat;
|
||||||
|
@ -179,8 +179,8 @@ static void gfx_ctx_set_resize(unsigned width, unsigned height)
|
|||||||
|
|
||||||
static void gfx_ctx_update_window_title(void)
|
static void gfx_ctx_update_window_title(void)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128], buf_fps[128];
|
||||||
if (gfx_get_fps(buf, sizeof(buf), false))
|
if (gfx_get_fps(buf, sizeof(buf), false, buf_fps, sizeof(buf_fps)))
|
||||||
XStoreName(g_dpy, g_win, buf);
|
XStoreName(g_dpy, g_win, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,8 +489,8 @@ D3DVideo::D3DVideo(const video_info_t *info) :
|
|||||||
win_height = rect.bottom - rect.top;
|
win_height = rect.bottom - rect.top;
|
||||||
}
|
}
|
||||||
|
|
||||||
char buffer[128];
|
char buffer[128], buffer_fps[128];
|
||||||
gfx_get_fps(buffer, sizeof(buffer), false);
|
gfx_get_fps(buffer, sizeof(buffer), false, buffer_fps, sizeof(buffer_fps));
|
||||||
std::string title = buffer;
|
std::string title = buffer;
|
||||||
title += " || Direct3D9";
|
title += " || Direct3D9";
|
||||||
|
|
||||||
@ -1006,8 +1006,8 @@ void D3DVideo::deinit_font()
|
|||||||
|
|
||||||
void D3DVideo::update_title()
|
void D3DVideo::update_title()
|
||||||
{
|
{
|
||||||
char buffer[128];
|
char buffer[128], buffer_fps[128];
|
||||||
if (gfx_get_fps(buffer, sizeof(buffer), false))
|
if (gfx_get_fps(buffer, sizeof(buffer), false, buffer_fps, sizeof(buffer_fps)))
|
||||||
{
|
{
|
||||||
std::string title = buffer;
|
std::string title = buffer;
|
||||||
title += " || Direct3D9";
|
title += " || Direct3D9";
|
||||||
|
@ -24,7 +24,7 @@ static inline float time_to_fps(rarch_time_t last_time, rarch_time_t new_time, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define FPS_UPDATE_INTERVAL 256
|
#define FPS_UPDATE_INTERVAL 256
|
||||||
bool gfx_get_fps(char *buf, size_t size, bool always_write)
|
bool gfx_get_fps(char *buf, size_t size, bool always_write, char *buf_fps, size_t size_fps)
|
||||||
{
|
{
|
||||||
static rarch_time_t time;
|
static rarch_time_t time;
|
||||||
static rarch_time_t fps_time;
|
static rarch_time_t fps_time;
|
||||||
@ -45,20 +45,14 @@ bool gfx_get_fps(char *buf, size_t size, bool always_write)
|
|||||||
last_fps = time_to_fps(time, new_time, FPS_UPDATE_INTERVAL);
|
last_fps = time_to_fps(time, new_time, FPS_UPDATE_INTERVAL);
|
||||||
time = new_time;
|
time = new_time;
|
||||||
|
|
||||||
#ifdef RARCH_CONSOLE
|
snprintf(buf_fps, size_fps, "FPS: %6.1f || Frames: %d", last_fps, g_extern.frame_count);
|
||||||
snprintf(buf, size, "FPS: %6.1f || Frames: %d", last_fps, g_extern.frame_count);
|
|
||||||
#else
|
|
||||||
snprintf(buf, size, "%s || FPS: %6.1f || Frames: %d", g_extern.title_buf, last_fps, g_extern.frame_count);
|
snprintf(buf, size, "%s || FPS: %6.1f || Frames: %d", g_extern.title_buf, last_fps, g_extern.frame_count);
|
||||||
#endif
|
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
else if (always_write)
|
else if (always_write)
|
||||||
{
|
{
|
||||||
#ifdef RARCH_CONSOLE
|
snprintf(buf_fps, size_fps, "FPS: %6.1f || Frames: %d", last_fps, g_extern.frame_count);
|
||||||
snprintf(buf, size, "FPS: %6.1f || Frames: %d", last_fps, g_extern.frame_count);
|
|
||||||
#else
|
|
||||||
snprintf(buf, size, "%s || FPS: %6.1f || Frames: %d", g_extern.title_buf, last_fps, g_extern.frame_count);
|
snprintf(buf, size, "%s || FPS: %6.1f || Frames: %d", g_extern.title_buf, last_fps, g_extern.frame_count);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -30,7 +30,7 @@ extern "C" {
|
|||||||
|
|
||||||
// If always_write is true, will always update FPS value
|
// If always_write is true, will always update FPS value
|
||||||
// If always_write is false, returns true if FPS value was updated.
|
// If always_write is false, returns true if FPS value was updated.
|
||||||
bool gfx_get_fps(char *buf, size_t size, bool always_write);
|
bool gfx_get_fps(char *buf, size_t size, bool always_write, char *buf_fps, size_t size_fps);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
void gfx_set_dwm(void);
|
void gfx_set_dwm(void);
|
||||||
|
@ -311,8 +311,8 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width, unsigne
|
|||||||
if (SDL_MUSTLOCK(vid->screen))
|
if (SDL_MUSTLOCK(vid->screen))
|
||||||
SDL_UnlockSurface(vid->screen);
|
SDL_UnlockSurface(vid->screen);
|
||||||
|
|
||||||
char buf[128];
|
char buf[128], buf_fps[128];
|
||||||
if (gfx_get_fps(buf, sizeof(buf), false))
|
if (gfx_get_fps(buf, sizeof(buf), false, buf_fps, sizeof(buf_fps)))
|
||||||
SDL_WM_SetCaption(buf, NULL);
|
SDL_WM_SetCaption(buf, NULL);
|
||||||
|
|
||||||
SDL_Flip(vid->screen);
|
SDL_Flip(vid->screen);
|
||||||
|
@ -338,7 +338,7 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo
|
|||||||
int visualmatches = 0;
|
int visualmatches = 0;
|
||||||
XSetWindowAttributes attributes = {0};
|
XSetWindowAttributes attributes = {0};
|
||||||
unsigned width = 0, height = 0;
|
unsigned width = 0, height = 0;
|
||||||
char buf[128];
|
char buf[128], buf_fps[128];
|
||||||
Atom atom = 0;
|
Atom atom = 0;
|
||||||
void *xinput = NULL;
|
void *xinput = NULL;
|
||||||
XVisualInfo *visualinfo = NULL;
|
XVisualInfo *visualinfo = NULL;
|
||||||
@ -409,7 +409,7 @@ static void *xv_init(const video_info_t *video, const input_driver_t **input, vo
|
|||||||
|
|
||||||
XMapWindow(xv->display, xv->window);
|
XMapWindow(xv->display, xv->window);
|
||||||
|
|
||||||
if (gfx_get_fps(buf, sizeof(buf), false))
|
if (gfx_get_fps(buf, sizeof(buf), false, buf_fps, sizeof(buf_fps)))
|
||||||
XStoreName(xv->display, xv->window, buf);
|
XStoreName(xv->display, xv->window, buf);
|
||||||
|
|
||||||
x11_set_window_attr(xv->display, xv->window);
|
x11_set_window_attr(xv->display, xv->window);
|
||||||
@ -700,8 +700,8 @@ static bool xv_frame(void *data, const void *frame, unsigned width, unsigned hei
|
|||||||
true);
|
true);
|
||||||
XSync(xv->display, False);
|
XSync(xv->display, False);
|
||||||
|
|
||||||
char buf[128];
|
char buf[128], buf_fps[128];
|
||||||
if (gfx_get_fps(buf, sizeof(buf), false))
|
if (gfx_get_fps(buf, sizeof(buf), false, buf_fps, sizeof(buf_fps)))
|
||||||
XStoreName(xv->display, xv->window, buf);
|
XStoreName(xv->display, xv->window, buf);
|
||||||
|
|
||||||
g_extern.frame_count++;
|
g_extern.frame_count++;
|
||||||
|
@ -943,8 +943,8 @@ static bool gx_frame(void *data, const void *frame,
|
|||||||
GX_DrawDone();
|
GX_DrawDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
char fps_txt[128];
|
char fps_txt[128], fps_text_buf[128];
|
||||||
gfx_get_fps(fps_txt, sizeof(fps_txt), lifecycle_mode_state & (1ULL << MODE_FPS_DRAW) ? true : false);
|
gfx_get_fps(fps_txt, sizeof(fps_txt), lifecycle_mode_state & (1ULL << MODE_FPS_DRAW) ? true : false, fps_text_buf, sizeof(fps_text_buf));
|
||||||
|
|
||||||
if (lifecycle_mode_state & (1ULL << MODE_FPS_DRAW))
|
if (lifecycle_mode_state & (1ULL << MODE_FPS_DRAW))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user