Don't use settings pointer inside video_frame function

This commit is contained in:
twinaphex 2017-01-09 14:25:59 +01:00
parent f3e7fc09d4
commit be2f921ee2
24 changed files with 93 additions and 58 deletions

View File

@ -96,7 +96,7 @@ static void *caca_gfx_init(const video_info_t *video,
static bool caca_gfx_frame(void *data, const void *frame, static bool caca_gfx_frame(void *data, const void *frame,
unsigned frame_width, unsigned frame_height, uint64_t frame_count, unsigned frame_width, unsigned frame_height, uint64_t frame_count,
unsigned pitch, const char *msg) unsigned pitch, const char *msg, video_frame_info_t video_info)
{ {
size_t len = 0; size_t len = 0;
void *buffer = NULL; void *buffer = NULL;

View File

@ -447,18 +447,17 @@ static void* ctr_init(const video_info_t* video,
static bool ctr_frame(void* data, const void* frame, static bool ctr_frame(void* data, const void* frame,
unsigned width, unsigned height, unsigned width, unsigned height,
uint64_t frame_count, uint64_t frame_count,
unsigned pitch, const char* msg) unsigned pitch, const char* msg, video_frame_info_t info)
{ {
uint32_t diff; uint32_t diff;
static uint64_t currentTick,lastTick; static uint64_t currentTick,lastTick;
touchPosition state_tmp_touch;
uint32_t state_tmp = 0;
ctr_video_t *ctr = (ctr_video_t*)data; ctr_video_t *ctr = (ctr_video_t*)data;
settings_t *settings = config_get_ptr();
static float fps = 0.0; static float fps = 0.0;
static int total_frames = 0; static int total_frames = 0;
static int frames = 0; static int frames = 0;
static struct retro_perf_counter ctrframe_f = {0}; static struct retro_perf_counter ctrframe_f = {0};
uint32_t state_tmp;
touchPosition state_tmp_touch;
extern bool select_pressed; extern bool select_pressed;

View File

@ -1368,13 +1368,12 @@ static void d3d_get_overlay_interface(void *data,
static bool d3d_frame(void *data, const void *frame, static bool d3d_frame(void *data, const void *frame,
unsigned frame_width, unsigned frame_height, unsigned frame_width, unsigned frame_height,
uint64_t frame_count, unsigned pitch, uint64_t frame_count, unsigned pitch,
const char *msg) const char *msg, video_frame_info_t video_info)
{ {
unsigned width, height; unsigned width, height;
static struct retro_perf_counter d3d_frame = {0}; static struct retro_perf_counter d3d_frame = {0};
unsigned i = 0; unsigned i = 0;
d3d_video_t *d3d = (d3d_video_t*)data; d3d_video_t *d3d = (d3d_video_t*)data;
settings_t *settings = config_get_ptr();
HWND window = win32_get_window(); HWND window = win32_get_window();
(void)i; (void)i;
@ -1424,7 +1423,7 @@ static bool d3d_frame(void *data, const void *frame,
/* Insert black frame first, so we /* Insert black frame first, so we
* can screenshot, etc. */ * can screenshot, etc. */
if (settings->video.black_frame_insertion) if (video_info.black_frame_insertion)
{ {
if (!d3d_swap(d3d, d3d->dev) || d3d->needs_restore) if (!d3d_swap(d3d, d3d->dev) || d3d->needs_restore)
return true; return true;

View File

@ -430,7 +430,8 @@ static void *dispmanx_gfx_init(const video_info_t *video,
} }
static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width, static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width,
unsigned height, uint64_t frame_count, unsigned pitch, const char *msg) unsigned height, uint64_t frame_count, unsigned pitch, const char *msg,
video_frame_info_t video_info)
{ {
struct dispmanx_video *_dispvars = data; struct dispmanx_video *_dispvars = data;
float aspect = video_driver_get_aspect_ratio(); float aspect = video_driver_get_aspect_ratio();

View File

@ -744,7 +744,8 @@ static void *drm_gfx_init(const video_info_t *video,
} }
static bool drm_gfx_frame(void *data, const void *frame, unsigned width, static bool drm_gfx_frame(void *data, const void *frame, unsigned width,
unsigned height, uint64_t frame_count, unsigned pitch, const char *msg) unsigned height, uint64_t frame_count, unsigned pitch, const char *msg,
video_frame_info_t video_info)
{ {
struct drm_video *_drmvars = data; struct drm_video *_drmvars = data;

View File

@ -1272,11 +1272,11 @@ static void exynos_gfx_free(void *data)
} }
static bool exynos_gfx_frame(void *data, const void *frame, unsigned width, static bool exynos_gfx_frame(void *data, const void *frame, unsigned width,
unsigned height, uint64_t frame_count, unsigned pitch, const char *msg) unsigned height, uint64_t frame_count, unsigned pitch, const char *msg,
video_frame_info_t video_info)
{ {
struct exynos_video *vid = data; struct exynos_video *vid = data;
struct exynos_page *page = NULL; struct exynos_page *page = NULL;
settings_t *settings = config_get_ptr();
/* Check if neither menu nor core framebuffer is to be displayed. */ /* Check if neither menu nor core framebuffer is to be displayed. */
if (!vid->menu_active && !frame) if (!vid->menu_active && !frame)
@ -1304,7 +1304,7 @@ static bool exynos_gfx_frame(void *data, const void *frame, unsigned width,
goto fail; goto fail;
} }
if (settings->fps_show) if (video_info.fps_show)
{ {
char buffer[128]; char buffer[128];
char buffer_fps[128]; char buffer_fps[128];
@ -1312,7 +1312,7 @@ static bool exynos_gfx_frame(void *data, const void *frame, unsigned width,
buffer[0] = buffer_fps[0] = '\0'; buffer[0] = buffer_fps[0] = '\0';
video_monitor_get_fps(buffer, sizeof(buffer), video_monitor_get_fps(buffer, sizeof(buffer),
settings->fps_show ? buffer_fps : NULL, sizeof(buffer_fps)); video_info.fps_show ? buffer_fps : NULL, sizeof(buffer_fps));
runloop_msg_queue_push(buffer_fps, 1, 1, false); runloop_msg_queue_push(buffer_fps, 1, 1, false);
} }

View File

@ -1077,7 +1077,8 @@ static INLINE void gl_draw_texture(gl_t *gl)
static bool gl_frame(void *data, const void *frame, static bool gl_frame(void *data, const void *frame,
unsigned frame_width, unsigned frame_height, unsigned frame_width, unsigned frame_height,
uint64_t frame_count, uint64_t frame_count,
unsigned pitch, const char *msg) unsigned pitch, const char *msg,
video_frame_info_t video_info)
{ {
video_shader_ctx_mvp_t mvp; video_shader_ctx_mvp_t mvp;
video_shader_ctx_coords_t coords; video_shader_ctx_coords_t coords;
@ -1087,7 +1088,6 @@ static bool gl_frame(void *data, const void *frame,
video_shader_ctx_info_t shader_info; video_shader_ctx_info_t shader_info;
static struct retro_perf_counter frame_run = {0}; static struct retro_perf_counter frame_run = {0};
gl_t *gl = (gl_t*)data; gl_t *gl = (gl_t*)data;
settings_t *settings = config_get_ptr();
performance_counter_init(&frame_run, "frame_run"); performance_counter_init(&frame_run, "frame_run");
performance_counter_start(&frame_run); performance_counter_start(&frame_run);
@ -1326,7 +1326,7 @@ static bool gl_frame(void *data, const void *frame,
/* Disable BFI during fast forward, slow-motion, /* Disable BFI during fast forward, slow-motion,
* and pause to prevent flicker. */ * and pause to prevent flicker. */
if ( if (
settings->video.black_frame_insertion video_info.black_frame_insertion
&& !input_driver_is_nonblock_state() && !input_driver_is_nonblock_state()
&& !runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL) && !runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL)
&& !runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) && !runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL))
@ -1338,7 +1338,7 @@ static bool gl_frame(void *data, const void *frame,
video_context_driver_swap_buffers(); video_context_driver_swap_buffers();
#ifdef HAVE_GL_SYNC #ifdef HAVE_GL_SYNC
if (settings->video.hard_sync && gl->have_sync) if (video_info.hard_sync && gl->have_sync)
{ {
static struct retro_perf_counter gl_fence = {0}; static struct retro_perf_counter gl_fence = {0};
@ -1348,7 +1348,7 @@ static bool gl_frame(void *data, const void *frame,
gl->fences[gl->fence_count++] = gl->fences[gl->fence_count++] =
glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
while (gl->fence_count > settings->video.hard_sync_frames) while (gl->fence_count > video_info.hard_sync_frames)
{ {
glClientWaitSync(gl->fences[0], glClientWaitSync(gl->fences[0],
GL_SYNC_FLUSH_COMMANDS_BIT, 1000000000); GL_SYNC_FLUSH_COMMANDS_BIT, 1000000000);

View File

@ -1436,14 +1436,14 @@ static void gx_free(void *data)
static bool gx_frame(void *data, const void *frame, static bool gx_frame(void *data, const void *frame,
unsigned width, unsigned height, unsigned width, unsigned height,
uint64_t frame_count, unsigned pitch, uint64_t frame_count, unsigned pitch,
const char *msg) const char *msg,
video_frame_info_t video_info)
{ {
char fps_txt[128]; char fps_txt[128];
char fps_text_buf[128]; char fps_text_buf[128];
static struct retro_perf_counter gx_frame = {0}; static struct retro_perf_counter gx_frame = {0};
gx_video_t *gx = (gx_video_t*)data; gx_video_t *gx = (gx_video_t*)data;
u8 clear_efb = GX_FALSE; u8 clear_efb = GX_FALSE;
settings_t *settings = config_get_ptr();
fps_txt[0] = fps_text_buf[0] = '\0'; fps_txt[0] = fps_text_buf[0] = '\0';
@ -1540,7 +1540,7 @@ static bool gx_frame(void *data, const void *frame,
video_monitor_get_fps(fps_txt, sizeof(fps_txt), video_monitor_get_fps(fps_txt, sizeof(fps_txt),
fps_text_buf, sizeof(fps_text_buf)); fps_text_buf, sizeof(fps_text_buf));
if (settings->fps_show) if (video_info.fps_show)
{ {
char mem1_txt[128]; char mem1_txt[128];
char mem2_txt[128]; char mem2_txt[128];

View File

@ -32,7 +32,7 @@ static void *null_gfx_init(const video_info_t *video,
static bool null_gfx_frame(void *data, const void *frame, static bool null_gfx_frame(void *data, const void *frame,
unsigned width, unsigned height, uint64_t frame_count, unsigned width, unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg) unsigned pitch, const char *msg, video_frame_info_t video_info)
{ {
(void)data; (void)data;
(void)frame; (void)frame;

View File

@ -984,7 +984,8 @@ fail:
} }
static bool omap_gfx_frame(void *data, const void *frame, unsigned width, static bool omap_gfx_frame(void *data, const void *frame, unsigned width,
unsigned height, uint64_t frame_count, unsigned pitch, const char *msg) unsigned height, uint64_t frame_count, unsigned pitch, const char *msg,
video_frame_info_t video_info)
{ {
omap_video_t *vid = (omap_video_t*)data; omap_video_t *vid = (omap_video_t*)data;

View File

@ -460,11 +460,13 @@ static void *psp_init(const video_info_t *video,
return psp; return psp;
} }
//#define DISPLAY_FPS #if 0
#define DISPLAY_FPS
#endif
static bool psp_frame(void *data, const void *frame, static bool psp_frame(void *data, const void *frame,
unsigned width, unsigned height, uint64_t frame_count, unsigned width, unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg) unsigned pitch, const char *msg, video_frame_info_t video_info)
{ {
#ifdef DISPLAY_FPS #ifdef DISPLAY_FPS
uint32_t diff; uint32_t diff;
@ -476,7 +478,6 @@ static bool psp_frame(void *data, const void *frame,
static char fps_txt[128] = {0}; static char fps_txt[128] = {0};
static char fps_text_buf[128] = {0}; static char fps_text_buf[128] = {0};
psp1_video_t *psp = (psp1_video_t*)data; psp1_video_t *psp = (psp1_video_t*)data;
settings_t *settings = config_get_ptr();
if (!width || !height) if (!width || !height)
return false; return false;
@ -494,10 +495,10 @@ static bool psp_frame(void *data, const void *frame,
pspDebugScreenSetXY(0,0); pspDebugScreenSetXY(0,0);
video_monitor_get_fps(fps_txt, sizeof(fps_txt), video_monitor_get_fps(fps_txt, sizeof(fps_txt),
settings->fps_show ? fps_text_buf : NULL, video_info.fps_show ? fps_text_buf : NULL,
settings->fps_show ? sizeof(fps_text_buf) : 0); video_info.fps_show ? sizeof(fps_text_buf) : 0);
if(settings->fps_show) if (video_info.fps_show)
{ {
pspDebugScreenSetXY(68 - strlen(fps_text_buf) - 1,0); pspDebugScreenSetXY(68 - strlen(fps_text_buf) - 1,0);
pspDebugScreenPuts(fps_text_buf); pspDebugScreenPuts(fps_text_buf);

View File

@ -498,11 +498,13 @@ static void check_window(sdl2_video_t *vid)
static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width, static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width,
unsigned height, uint64_t frame_count, unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg) unsigned pitch, const char *msg, video_frame_info_t video_info)
{ {
char buf[128] = {0}; char buf[128];
sdl2_video_t *vid = (sdl2_video_t*)data; sdl2_video_t *vid = (sdl2_video_t*)data;
buf[0] = '\0';
if (vid->should_resize) if (vid->should_resize)
sdl_refresh_viewport(vid); sdl_refresh_viewport(vid);

View File

@ -330,7 +330,7 @@ static void sdl_gfx_check_window(sdl_video_t *vid)
static bool sdl_gfx_frame(void *data, const void *frame, unsigned width, static bool sdl_gfx_frame(void *data, const void *frame, unsigned width,
unsigned height, uint64_t frame_count, unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg) unsigned pitch, const char *msg, video_frame_info_t video_info)
{ {
char buf[128]; char buf[128];
static struct retro_perf_counter sdl_scale = {0}; static struct retro_perf_counter sdl_scale = {0};

View File

@ -762,7 +762,8 @@ static void sunxi_setup_scale (void *data,
} }
static bool sunxi_gfx_frame(void *data, const void *frame, unsigned width, static bool sunxi_gfx_frame(void *data, const void *frame, unsigned width,
unsigned height, uint64_t frame_count, unsigned pitch, const char *msg) unsigned height, uint64_t frame_count, unsigned pitch, const char *msg,
video_frame_info_t video_info)
{ {
struct sunxi_video *_dispvars = (struct sunxi_video*)data; struct sunxi_video *_dispvars = (struct sunxi_video*)data;

View File

@ -378,7 +378,8 @@ static void vg_copy_frame(void *data, const void *frame,
static bool vg_frame(void *data, const void *frame, static bool vg_frame(void *data, const void *frame,
unsigned frame_width, unsigned frame_height, unsigned frame_width, unsigned frame_height,
uint64_t frame_count, unsigned pitch, const char *msg) uint64_t frame_count, unsigned pitch, const char *msg,
video_frame_info_t video_info)
{ {
unsigned width, height; unsigned width, height;
vg_t *vg = (vg_t*)data; vg_t *vg = (vg_t*)data;

View File

@ -126,11 +126,10 @@ static void vita2d_gfx_update_viewport(vita_video_t* vita);
static bool vita2d_gfx_frame(void *data, const void *frame, static bool vita2d_gfx_frame(void *data, const void *frame,
unsigned width, unsigned height, uint64_t frame_count, unsigned width, unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg) unsigned pitch, const char *msg, video_frame_info_t video_info)
{ {
void *tex_p; void *tex_p;
vita_video_t *vita = (vita_video_t *)data; vita_video_t *vita = (vita_video_t *)data;
settings_t *settings = config_get_ptr();
if (frame) if (frame)
{ {
@ -203,7 +202,7 @@ static bool vita2d_gfx_frame(void *data, const void *frame,
} }
} }
if (settings->fps_show) if (video_info.fps_show)
{ {
char buffer[128]; char buffer[128];
char buffer_fps[128]; char buffer_fps[128];
@ -211,7 +210,7 @@ static bool vita2d_gfx_frame(void *data, const void *frame,
buffer[0] = buffer_fps[0] = '\0'; buffer[0] = buffer_fps[0] = '\0';
video_monitor_get_fps(buffer, sizeof(buffer), video_monitor_get_fps(buffer, sizeof(buffer),
settings->fps_show ? buffer_fps : NULL, sizeof(buffer_fps)); video_info.fps_show ? buffer_fps : NULL, sizeof(buffer_fps));
runloop_msg_queue_push(buffer_fps, 1, 1, false); runloop_msg_queue_push(buffer_fps, 1, 1, false);
} }

View File

@ -1521,13 +1521,12 @@ static void vulkan_inject_black_frame(vk_t *vk)
static bool vulkan_frame(void *data, const void *frame, static bool vulkan_frame(void *data, const void *frame,
unsigned frame_width, unsigned frame_height, unsigned frame_width, unsigned frame_height,
uint64_t frame_count, uint64_t frame_count,
unsigned pitch, const char *msg) unsigned pitch, const char *msg, video_frame_info_t video_info)
{ {
struct vk_per_frame *chain; struct vk_per_frame *chain;
unsigned width, height; unsigned width, height;
VkClearValue clear_value; VkClearValue clear_value;
vk_t *vk = (vk_t*)data; vk_t *vk = (vk_t*)data;
settings_t *settings = config_get_ptr();
static struct retro_perf_counter frame_run = {0}; static struct retro_perf_counter frame_run = {0};
static struct retro_perf_counter begin_cmd = {0}; static struct retro_perf_counter begin_cmd = {0};
static struct retro_perf_counter build_cmd = {0}; static struct retro_perf_counter build_cmd = {0};
@ -1933,7 +1932,7 @@ static bool vulkan_frame(void *data, const void *frame,
/* Disable BFI during fast forward, slow-motion, /* Disable BFI during fast forward, slow-motion,
* and pause to prevent flicker. */ * and pause to prevent flicker. */
if ( if (
settings->video.black_frame_insertion video_info.black_frame_insertion
&& !input_driver_is_nonblock_state() && !input_driver_is_nonblock_state()
&& !runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL) && !runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL)
&& !runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) && !runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL))
@ -1948,7 +1947,8 @@ static bool vulkan_frame(void *data, const void *frame,
vk->context->swap_interval_emulation_lock = true; vk->context->swap_interval_emulation_lock = true;
for (i = 1; i < vk->context->swap_interval; i++) for (i = 1; i < vk->context->swap_interval; i++)
{ {
if (!vulkan_frame(vk, NULL, 0, 0, frame_count, 0, msg)) if (!vulkan_frame(vk, NULL, 0, 0, frame_count, 0, msg,
video_info))
{ {
vk->context->swap_interval_emulation_lock = false; vk->context->swap_interval_emulation_lock = false;
return false; return false;

View File

@ -532,8 +532,8 @@ static void wiiu_gfx_free(void* data)
} }
static bool wiiu_gfx_frame(void* data, const void* frame, static bool wiiu_gfx_frame(void* data, const void* frame,
unsigned width, unsigned height, uint64_t frame_count, unsigned width, unsigned height, uint64_t frame_count,
unsigned pitch, const char* msg) unsigned pitch, const char* msg, video_frame_info_t video_info)
{ {
(void)msg; (void)msg;
int i; int i;

View File

@ -193,7 +193,7 @@ static void *xenon360_gfx_init(const video_info_t *video, const input_driver_t *
} }
static bool xenon360_gfx_frame(void *data, const void *frame, unsigned width, unsigned height, static bool xenon360_gfx_frame(void *data, const void *frame, unsigned width, unsigned height,
uint64_t frame_count, unsigned pitch, const char *msg) uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t video_info)
{ {
gl_t *vid = data; gl_t *vid = data;

View File

@ -94,14 +94,15 @@ static void *xshm_gfx_init(const video_info_t *video,
static bool xshm_gfx_frame(void *data, const void *frame, unsigned width, static bool xshm_gfx_frame(void *data, const void *frame, unsigned width,
unsigned height, uint64_t frame_count, unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg) unsigned pitch, const char *msg, video_frame_info_t video_info)
{ {
xshm_t* xshm = (xshm_t*)data; xshm_t* xshm = (xshm_t*)data;
int y; int y;
for (y=0;y<height;y++) for (y=0;y<height;y++)
{ {
memcpy((uint8_t*)xshm->shmInfo.shmaddr + sizeof(uint32_t)*xshm->width*y, (uint8_t*)frame + pitch*y, pitch); memcpy((uint8_t*)xshm->shmInfo.shmaddr + sizeof(uint32_t)*xshm->width*y,
(uint8_t*)frame + pitch*y, pitch);
} }
XShmPutImage(xshm->display, xshm->wndw, xshm->gc, xshm->image, XShmPutImage(xshm->display, xshm->wndw, xshm->gc, xshm->image,

View File

@ -781,7 +781,7 @@ static void xv_render_msg(xv_t *xv, const char *msg,
static bool xv_frame(void *data, const void *frame, unsigned width, static bool xv_frame(void *data, const void *frame, unsigned width,
unsigned height, uint64_t frame_count, unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg) unsigned pitch, const char *msg, video_frame_info_t video_info)
{ {
XWindowAttributes target; XWindowAttributes target;
xv_t *xv = (xv_t*)data; xv_t *xv = (xv_t*)data;

View File

@ -2047,6 +2047,7 @@ void video_driver_frame(const void *data, unsigned width,
{ {
static char video_driver_msg[256]; static char video_driver_msg[256];
static struct retro_perf_counter video_frame_conv = {0}; static struct retro_perf_counter video_frame_conv = {0};
video_frame_info_t video_info;
unsigned output_width = 0; unsigned output_width = 0;
unsigned output_height = 0; unsigned output_height = 0;
unsigned output_pitch = 0; unsigned output_pitch = 0;
@ -2105,10 +2106,17 @@ void video_driver_frame(const void *data, unsigned width,
&& settings->video.font_enable && msg) && settings->video.font_enable && msg)
strlcpy(video_driver_msg, msg, sizeof(video_driver_msg)); strlcpy(video_driver_msg, msg, sizeof(video_driver_msg));
video_info.refresh_rate = settings->video.refresh_rate;
video_info.black_frame_insertion =
settings->video.black_frame_insertion;
video_info.hard_sync = settings->video.hard_sync;
video_info.hard_sync_frames = settings->video.hard_sync_frames;
video_info.fps_show = settings->fps_show;
if (!current_video || !current_video->frame( if (!current_video || !current_video->frame(
video_driver_data, data, width, height, video_driver_data, data, width, height,
video_driver_frame_count, video_driver_frame_count,
pitch, video_driver_msg)) pitch, video_driver_msg, video_info))
video_driver_active = false; video_driver_active = false;
video_driver_frame_count++; video_driver_frame_count++;

View File

@ -81,6 +81,15 @@ typedef struct video_info
#endif #endif
} video_info_t; } video_info_t;
typedef struct video_frame_info
{
float refresh_rate;
bool black_frame_insertion;
bool hard_sync;
unsigned hard_sync_frames;
bool fps_show;
} video_frame_info_t;
/* Optionally implemented interface to poke more /* Optionally implemented interface to poke more
* deeply into video driver. */ * deeply into video driver. */
@ -141,7 +150,7 @@ typedef struct video_viewport
typedef bool (*video_driver_frame_t)(void *data, typedef bool (*video_driver_frame_t)(void *data,
const void *frame, unsigned width, const void *frame, unsigned width,
unsigned height, uint64_t frame_count, unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg); unsigned pitch, const char *msg, video_frame_info_t video_info);
typedef struct video_driver typedef struct video_driver
{ {

View File

@ -612,10 +612,23 @@ static void video_thread_loop(void *data)
thread_update_driver_state(thr); thread_update_driver_state(thr);
if (thr->driver && thr->driver->frame) if (thr->driver && thr->driver->frame)
{
video_frame_info_t video_info;
settings_t *settings = config_get_ptr();
video_info.refresh_rate = settings->video.refresh_rate;
video_info.black_frame_insertion =
settings->video.black_frame_insertion;
video_info.hard_sync = settings->video.hard_sync;
video_info.hard_sync_frames = settings->video.hard_sync_frames;
video_info.fps_show = settings->fps_show;
ret = thr->driver->frame(thr->driver_data, ret = thr->driver->frame(thr->driver_data,
thr->frame.buffer, thr->frame.width, thr->frame.height, thr->frame.buffer, thr->frame.width, thr->frame.height,
thr->frame.count, thr->frame.count,
thr->frame.pitch, *thr->frame.msg ? thr->frame.msg : NULL); thr->frame.pitch, *thr->frame.msg ? thr->frame.msg : NULL,
video_info);
}
slock_unlock(thr->frame.lock); slock_unlock(thr->frame.lock);
@ -701,7 +714,7 @@ static bool video_thread_has_windowed(void *data)
static bool video_thread_frame(void *data, const void *frame_, static bool video_thread_frame(void *data, const void *frame_,
unsigned width, unsigned height, uint64_t frame_count, unsigned width, unsigned height, uint64_t frame_count,
unsigned pitch, const char *msg) unsigned pitch, const char *msg, video_frame_info_t video_info)
{ {
unsigned copy_stride; unsigned copy_stride;
static struct retro_perf_counter thr_frame = {0}; static struct retro_perf_counter thr_frame = {0};
@ -717,7 +730,7 @@ static bool video_thread_frame(void *data, const void *frame_,
if (thr->driver && thr->driver->frame) if (thr->driver && thr->driver->frame)
return thr->driver->frame(thr->driver_data, frame_, return thr->driver->frame(thr->driver_data, frame_,
width, height, frame_count, pitch, msg); width, height, frame_count, pitch, msg, video_info);
return false; return false;
} }
@ -734,10 +747,9 @@ static bool video_thread_frame(void *data, const void *frame_,
if (!thr->nonblock) if (!thr->nonblock)
{ {
settings_t *settings = config_get_ptr();
retro_time_t target_frame_time = (retro_time_t) retro_time_t target_frame_time = (retro_time_t)
roundf(1000000 / settings->video.refresh_rate); roundf(1000000 / video_info.refresh_rate);
retro_time_t target = thr->last_time + target_frame_time; retro_time_t target = thr->last_time + target_frame_time;
/* Ideally, use absolute time, but that is only a good idea on POSIX. */ /* Ideally, use absolute time, but that is only a good idea on POSIX. */