mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 16:09:47 +00:00
Refactor frame_counter.
Graphics drivers get the task of updating this. If threaded driver is used, main thread cannot update the counter due to race conditions.
This commit is contained in:
parent
6480f564c1
commit
e389220df8
@ -2091,7 +2091,6 @@ bool menu_iterate(void)
|
||||
if (driver.video_poke->apply_state_changes)
|
||||
driver.video_poke->apply_state_changes(driver.video_data);
|
||||
|
||||
g_extern.frame_count++;
|
||||
rarch_input_poll();
|
||||
#ifdef HAVE_OVERLAY
|
||||
rarch_check_overlay();
|
||||
|
@ -3409,8 +3409,6 @@ bool menu_iterate(void)
|
||||
g_extern.lifecycle_mode_state &= ~(1ULL << MODE_MENU_PREINIT);
|
||||
}
|
||||
|
||||
g_extern.frame_count++;
|
||||
|
||||
|
||||
//first button input frame
|
||||
uint64_t input_state_first_frame = 0;
|
||||
|
@ -194,11 +194,8 @@ static void gfx_ctx_set_resize(unsigned width, unsigned height)
|
||||
(void)height;
|
||||
}
|
||||
|
||||
static void gfx_ctx_update_window_title(bool reset)
|
||||
static void gfx_ctx_update_window_title(void)
|
||||
{
|
||||
if (reset)
|
||||
gfx_window_title_reset();
|
||||
|
||||
char buf[128];
|
||||
#if 0
|
||||
if (gfx_get_fps(buf, sizeof(buf), false))
|
||||
|
@ -316,11 +316,8 @@ static void gfx_ctx_set_resize(unsigned width, unsigned height)
|
||||
(void)height;
|
||||
}
|
||||
|
||||
static void gfx_ctx_update_window_title(bool reset)
|
||||
static void gfx_ctx_update_window_title(void)
|
||||
{
|
||||
if (reset)
|
||||
gfx_window_title_reset();
|
||||
|
||||
char buf[128];
|
||||
#if 0
|
||||
if (gfx_get_fps(buf, sizeof(buf), false))
|
||||
|
@ -234,10 +234,8 @@ static void gfx_ctx_set_resize(unsigned width, unsigned height)
|
||||
(void)height;
|
||||
}
|
||||
|
||||
static void gfx_ctx_update_window_title(bool reset)
|
||||
{
|
||||
(void)reset;
|
||||
}
|
||||
static void gfx_ctx_update_window_title(void)
|
||||
{}
|
||||
|
||||
static void gfx_ctx_get_video_size(unsigned *width, unsigned *height)
|
||||
{
|
||||
|
@ -144,11 +144,8 @@ static void gfx_ctx_set_resize(unsigned width, unsigned height)
|
||||
(void)height;
|
||||
}
|
||||
|
||||
static void gfx_ctx_update_window_title(bool reset)
|
||||
static void gfx_ctx_update_window_title(void)
|
||||
{
|
||||
if (reset)
|
||||
gfx_window_title_reset();
|
||||
|
||||
char buf[128];
|
||||
if (gfx_get_fps(buf, sizeof(buf), false))
|
||||
XStoreName(g_dpy, g_win, buf);
|
||||
@ -310,7 +307,6 @@ static bool gfx_ctx_set_video_mode(
|
||||
|
||||
g_glx_win = glXCreateWindow(g_dpy, g_fbc, g_win, 0);
|
||||
|
||||
gfx_ctx_update_window_title(true);
|
||||
x11_set_window_attr(g_dpy, g_win);
|
||||
|
||||
if (fullscreen)
|
||||
|
@ -42,7 +42,7 @@ static bool gfx_ctx_set_video_mode(
|
||||
return true;
|
||||
}
|
||||
|
||||
static void gfx_ctx_update_window_title(bool reset)
|
||||
static void gfx_ctx_update_window_title(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ static void gfx_ctx_swap_buffers(void)
|
||||
|
||||
static void gfx_ctx_set_resize(unsigned width, unsigned height) { }
|
||||
|
||||
static void gfx_ctx_update_window_title(bool reset) { }
|
||||
static void gfx_ctx_update_window_title(void) { }
|
||||
|
||||
static void gfx_ctx_get_video_size(unsigned *width, unsigned *height)
|
||||
{
|
||||
|
@ -88,11 +88,8 @@ static void gfx_ctx_wm_set_caption(const char *str)
|
||||
SDL_WM_SetCaption(str, NULL);
|
||||
}
|
||||
|
||||
static void gfx_ctx_update_window_title(bool reset)
|
||||
static void gfx_ctx_update_window_title(void)
|
||||
{
|
||||
if (reset)
|
||||
gfx_window_title_reset();
|
||||
|
||||
char buf[128];
|
||||
if (gfx_get_fps(buf, sizeof(buf), false))
|
||||
gfx_ctx_wm_set_caption(buf);
|
||||
|
@ -107,14 +107,9 @@ static void gfx_ctx_set_resize(unsigned width, unsigned height)
|
||||
(void)height;
|
||||
}
|
||||
|
||||
static void gfx_ctx_update_window_title(bool reset)
|
||||
static void gfx_ctx_update_window_title(void)
|
||||
{
|
||||
(void)reset;
|
||||
if (reset)
|
||||
gfx_window_title_reset();
|
||||
|
||||
char buf[128];
|
||||
|
||||
if (gfx_get_fps(buf, sizeof(buf), false))
|
||||
RARCH_LOG("%s.\n", buf);
|
||||
}
|
||||
|
@ -175,11 +175,8 @@ static void gfx_ctx_set_resize(unsigned width, unsigned height)
|
||||
(void)height;
|
||||
}
|
||||
|
||||
static void gfx_ctx_update_window_title(bool reset)
|
||||
static void gfx_ctx_update_window_title(void)
|
||||
{
|
||||
if (reset)
|
||||
gfx_window_title_reset();
|
||||
|
||||
char buf[128];
|
||||
if (gfx_get_fps(buf, sizeof(buf), false))
|
||||
SetWindowText(g_hwnd, buf);
|
||||
|
@ -80,7 +80,7 @@ static bool gfx_ctx_xdk_window_has_focus(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void gfx_ctx_xdk_update_window_title(bool reset) { }
|
||||
static void gfx_ctx_xdk_update_window_title(void) { }
|
||||
|
||||
static void gfx_ctx_xdk_get_video_size(unsigned *width, unsigned *height)
|
||||
{
|
||||
|
@ -144,11 +144,8 @@ static void gfx_ctx_set_resize(unsigned width, unsigned height)
|
||||
(void)height;
|
||||
}
|
||||
|
||||
static void gfx_ctx_update_window_title(bool reset)
|
||||
static void gfx_ctx_update_window_title(void)
|
||||
{
|
||||
if (reset)
|
||||
gfx_window_title_reset();
|
||||
|
||||
char buf[128];
|
||||
if (gfx_get_fps(buf, sizeof(buf), false))
|
||||
XStoreName(g_dpy, g_win, buf);
|
||||
@ -370,7 +367,6 @@ static bool gfx_ctx_set_video_mode(
|
||||
if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx))
|
||||
goto error;
|
||||
|
||||
gfx_ctx_update_window_title(true);
|
||||
x11_set_window_attr(g_dpy, g_win);
|
||||
|
||||
if (fullscreen)
|
||||
|
@ -946,6 +946,8 @@ void D3DVideo::update_title()
|
||||
title += " || Direct3D9";
|
||||
SetWindowText(hWnd, title.c_str());
|
||||
}
|
||||
|
||||
g_extern.frame_count++;
|
||||
}
|
||||
|
||||
void D3DVideo::resize(unsigned new_width, unsigned new_height)
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "../general.h"
|
||||
#include "../performance.h"
|
||||
|
||||
static float time_to_fps(rarch_time_t last_time, rarch_time_t new_time, int frames)
|
||||
static inline float time_to_fps(rarch_time_t last_time, rarch_time_t new_time, int frames)
|
||||
{
|
||||
return (1000000.0f * frames) / (new_time - last_time);
|
||||
}
|
||||
@ -71,11 +71,6 @@ bool gfx_get_fps(char *buf, size_t size, bool always_write)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void gfx_window_title_reset(void)
|
||||
{
|
||||
g_extern.frame_count = 0;
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
#include <windows.h>
|
||||
#include "../dynamic.h"
|
||||
|
@ -31,7 +31,6 @@ extern "C" {
|
||||
// If always_write is true, will always update FPS value
|
||||
// If always_write is false, returns true if FPS value was updated.
|
||||
bool gfx_get_fps(char *buf, size_t size, bool always_write);
|
||||
void gfx_window_title_reset(void);
|
||||
|
||||
#ifdef _WIN32
|
||||
void gfx_set_dwm(void);
|
||||
|
@ -60,7 +60,7 @@ typedef struct gfx_ctx_driver
|
||||
float (*translate_aspect)(unsigned, unsigned);
|
||||
|
||||
// Asks driver to update window title (FPS, etc).
|
||||
void (*update_window_title)(bool);
|
||||
void (*update_window_title)(void);
|
||||
|
||||
// Queries for resize and quit events.
|
||||
// Also processes events.
|
||||
|
4
gfx/gl.c
4
gfx/gl.c
@ -1443,7 +1443,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
|
||||
#endif
|
||||
|
||||
#if !defined(RARCH_CONSOLE)
|
||||
context_update_window_title_func(false);
|
||||
context_update_window_title_func();
|
||||
#endif
|
||||
|
||||
RARCH_PERFORMANCE_STOP(frame_run);
|
||||
@ -1462,6 +1462,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei
|
||||
#endif
|
||||
|
||||
context_swap_buffers_func();
|
||||
g_extern.frame_count++;
|
||||
|
||||
#if !defined(HAVE_OPENGLES) && defined(HAVE_FFMPEG)
|
||||
if (gl->pbo_readback_enable)
|
||||
@ -1778,7 +1779,6 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
|
||||
return NULL;
|
||||
}
|
||||
|
||||
context_update_window_title_func(true);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
if (!resolve_extensions(gl))
|
||||
|
@ -65,7 +65,7 @@
|
||||
#include "../griffin/hook_context.h"
|
||||
#else
|
||||
#define context_get_video_size_func(win, height) gl->ctx_driver->get_video_size(win, height)
|
||||
#define context_update_window_title_func(var) gl->ctx_driver->update_window_title(var)
|
||||
#define context_update_window_title_func() gl->ctx_driver->update_window_title()
|
||||
#define context_destroy_func() gl->ctx_driver->destroy()
|
||||
#define context_translate_aspect_func(width, height) gl->ctx_driver->translate_aspect(width, height)
|
||||
#define context_set_resize_func(width, height) gl->ctx_driver->set_resize(width, height)
|
||||
@ -76,7 +76,6 @@
|
||||
#define context_check_window_func(quit, resize, width, height, frame_count) \
|
||||
gl->ctx_driver->check_window(quit, resize, width, height, frame_count)
|
||||
|
||||
#define context_update_window_title_func(var) gl->ctx_driver->update_window_title(var)
|
||||
#define context_set_video_mode_func(width, height, fullscreen) gl->ctx_driver->set_video_mode(width, height, fullscreen)
|
||||
#define context_input_driver_func(input, input_data) gl->ctx_driver->input_driver(input, input_data)
|
||||
|
||||
|
@ -314,6 +314,7 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width, unsigne
|
||||
SDL_WM_SetCaption(buf, NULL);
|
||||
|
||||
SDL_Flip(vid->screen);
|
||||
g_extern.frame_count++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -702,6 +702,7 @@ static bool xv_frame(void *data, const void *frame, unsigned width, unsigned hei
|
||||
if (gfx_get_fps(buf, sizeof(buf), false))
|
||||
XStoreName(xv->display, xv->window, buf);
|
||||
|
||||
g_extern.frame_count++;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#if defined(ANDROID)
|
||||
#define context_get_video_size_func(win, height) gfx_ctx_get_video_size(win, height)
|
||||
#define context_update_window_title_func(var) gfx_ctx_update_window_title(var)
|
||||
#define context_update_window_title_func() gfx_ctx_update_window_title()
|
||||
#define context_destroy_func() gfx_ctx_destroy()
|
||||
|
||||
#define context_translate_aspect_func(width, height) (device_aspect)
|
||||
|
@ -975,6 +975,8 @@ static bool gx_frame(void *data, const void *frame,
|
||||
VIDEO_SetNextFramebuffer(g_framebuf[g_current_framebuf]);
|
||||
VIDEO_Flush();
|
||||
|
||||
g_extern.frame_count++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2959,7 +2959,6 @@ bool rarch_main_iterate(void)
|
||||
#endif
|
||||
|
||||
pretro_run();
|
||||
g_extern.frame_count++;
|
||||
|
||||
#ifdef HAVE_BSV_MOVIE
|
||||
if (g_extern.bsv.movie)
|
||||
|
@ -1021,6 +1021,8 @@ NULL, NULL, NULL, 0);
|
||||
|
||||
gfx_ctx_xdk_swap_buffers();
|
||||
|
||||
g_extern.frame_count++;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user