diff --git a/gfx/drivers/caca_gfx.c b/gfx/drivers/caca_gfx.c index 210327f2a1..ad31d37b5d 100644 --- a/gfx/drivers/caca_gfx.c +++ b/gfx/drivers/caca_gfx.c @@ -96,7 +96,7 @@ static void *caca_gfx_init(const video_info_t *video, static bool caca_gfx_frame(void *data, const void *frame, 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; void *buffer = NULL; diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index 389a81e9a7..ec1db8364e 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -447,18 +447,17 @@ static void* ctr_init(const video_info_t* video, static bool ctr_frame(void* data, const void* frame, unsigned width, unsigned height, uint64_t frame_count, - unsigned pitch, const char* msg) + unsigned pitch, const char* msg, video_frame_info_t info) { uint32_t diff; static uint64_t currentTick,lastTick; + touchPosition state_tmp_touch; + uint32_t state_tmp = 0; ctr_video_t *ctr = (ctr_video_t*)data; - settings_t *settings = config_get_ptr(); static float fps = 0.0; static int total_frames = 0; static int frames = 0; static struct retro_perf_counter ctrframe_f = {0}; - uint32_t state_tmp; - touchPosition state_tmp_touch; extern bool select_pressed; diff --git a/gfx/drivers/d3d.cpp b/gfx/drivers/d3d.cpp index 016e3b41d0..d4aece5215 100644 --- a/gfx/drivers/d3d.cpp +++ b/gfx/drivers/d3d.cpp @@ -1368,13 +1368,12 @@ static void d3d_get_overlay_interface(void *data, static bool d3d_frame(void *data, const void *frame, unsigned frame_width, unsigned frame_height, uint64_t frame_count, unsigned pitch, - const char *msg) + const char *msg, video_frame_info_t video_info) { unsigned width, height; static struct retro_perf_counter d3d_frame = {0}; unsigned i = 0; d3d_video_t *d3d = (d3d_video_t*)data; - settings_t *settings = config_get_ptr(); HWND window = win32_get_window(); (void)i; @@ -1424,7 +1423,7 @@ static bool d3d_frame(void *data, const void *frame, /* Insert black frame first, so we * can screenshot, etc. */ - if (settings->video.black_frame_insertion) + if (video_info.black_frame_insertion) { if (!d3d_swap(d3d, d3d->dev) || d3d->needs_restore) return true; diff --git a/gfx/drivers/dispmanx_gfx.c b/gfx/drivers/dispmanx_gfx.c index 932bd4f602..9ae0f11e0b 100644 --- a/gfx/drivers/dispmanx_gfx.c +++ b/gfx/drivers/dispmanx_gfx.c @@ -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, - 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; float aspect = video_driver_get_aspect_ratio(); diff --git a/gfx/drivers/drm_gfx.c b/gfx/drivers/drm_gfx.c index 320758236b..5ccbeac671 100644 --- a/gfx/drivers/drm_gfx.c +++ b/gfx/drivers/drm_gfx.c @@ -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, - 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; diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index 76c031914b..36d6e0d8d0 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -1272,11 +1272,11 @@ static void exynos_gfx_free(void *data) } 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_page *page = NULL; - settings_t *settings = config_get_ptr(); /* Check if neither menu nor core framebuffer is to be displayed. */ if (!vid->menu_active && !frame) @@ -1304,7 +1304,7 @@ static bool exynos_gfx_frame(void *data, const void *frame, unsigned width, goto fail; } - if (settings->fps_show) + if (video_info.fps_show) { char buffer[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'; 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); } diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index c5af50d90e..4d1f15bb12 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1077,7 +1077,8 @@ static INLINE void gl_draw_texture(gl_t *gl) static bool gl_frame(void *data, const void *frame, 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) { video_shader_ctx_mvp_t mvp; 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; static struct retro_perf_counter frame_run = {0}; gl_t *gl = (gl_t*)data; - settings_t *settings = config_get_ptr(); performance_counter_init(&frame_run, "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, * and pause to prevent flicker. */ if ( - settings->video.black_frame_insertion + video_info.black_frame_insertion && !input_driver_is_nonblock_state() && !runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, 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(); #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}; @@ -1348,7 +1348,7 @@ static bool gl_frame(void *data, const void *frame, gl->fences[gl->fence_count++] = 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], GL_SYNC_FLUSH_COMMANDS_BIT, 1000000000); diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index 6231ef374c..4fcaf45918 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -1436,14 +1436,14 @@ static void gx_free(void *data) static bool gx_frame(void *data, const void *frame, unsigned width, unsigned height, uint64_t frame_count, unsigned pitch, - const char *msg) + const char *msg, + video_frame_info_t video_info) { char fps_txt[128]; char fps_text_buf[128]; static struct retro_perf_counter gx_frame = {0}; gx_video_t *gx = (gx_video_t*)data; u8 clear_efb = GX_FALSE; - settings_t *settings = config_get_ptr(); 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), fps_text_buf, sizeof(fps_text_buf)); - if (settings->fps_show) + if (video_info.fps_show) { char mem1_txt[128]; char mem2_txt[128]; diff --git a/gfx/drivers/nullgfx.c b/gfx/drivers/nullgfx.c index b736a7aab7..2a9adebf50 100644 --- a/gfx/drivers/nullgfx.c +++ b/gfx/drivers/nullgfx.c @@ -32,7 +32,7 @@ static void *null_gfx_init(const video_info_t *video, static bool null_gfx_frame(void *data, const void *frame, 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)frame; diff --git a/gfx/drivers/omap_gfx.c b/gfx/drivers/omap_gfx.c index 36c5ced711..af46ff7687 100644 --- a/gfx/drivers/omap_gfx.c +++ b/gfx/drivers/omap_gfx.c @@ -984,7 +984,8 @@ fail: } 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; diff --git a/gfx/drivers/psp1_gfx.c b/gfx/drivers/psp1_gfx.c index 3dfac31f55..19364a1a2a 100644 --- a/gfx/drivers/psp1_gfx.c +++ b/gfx/drivers/psp1_gfx.c @@ -460,11 +460,13 @@ static void *psp_init(const video_info_t *video, return psp; } -//#define DISPLAY_FPS +#if 0 +#define DISPLAY_FPS +#endif static bool psp_frame(void *data, const void *frame, 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 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_text_buf[128] = {0}; psp1_video_t *psp = (psp1_video_t*)data; - settings_t *settings = config_get_ptr(); if (!width || !height) return false; @@ -494,10 +495,10 @@ static bool psp_frame(void *data, const void *frame, pspDebugScreenSetXY(0,0); video_monitor_get_fps(fps_txt, sizeof(fps_txt), - settings->fps_show ? fps_text_buf : NULL, - settings->fps_show ? sizeof(fps_text_buf) : 0); + video_info.fps_show ? fps_text_buf : NULL, + 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); pspDebugScreenPuts(fps_text_buf); diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index bc548486ad..abed41587a 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -498,11 +498,13 @@ static void check_window(sdl2_video_t *vid) static bool sdl2_gfx_frame(void *data, const void *frame, unsigned width, 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; + buf[0] = '\0'; + if (vid->should_resize) sdl_refresh_viewport(vid); diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 731778fa09..572b971738 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -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, 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]; static struct retro_perf_counter sdl_scale = {0}; diff --git a/gfx/drivers/sunxi_gfx.c b/gfx/drivers/sunxi_gfx.c index 9cf03d4d75..8c62172f2d 100644 --- a/gfx/drivers/sunxi_gfx.c +++ b/gfx/drivers/sunxi_gfx.c @@ -762,7 +762,8 @@ static void sunxi_setup_scale (void *data, } 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; diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index e5158b5864..ec9b6c1e76 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -378,7 +378,8 @@ static void vg_copy_frame(void *data, const void *frame, static bool vg_frame(void *data, const void *frame, 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; vg_t *vg = (vg_t*)data; diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index f3be92b8b9..69f24a2169 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -126,11 +126,10 @@ static void vita2d_gfx_update_viewport(vita_video_t* vita); static bool vita2d_gfx_frame(void *data, const void *frame, 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; vita_video_t *vita = (vita_video_t *)data; - settings_t *settings = config_get_ptr(); 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_fps[128]; @@ -211,7 +210,7 @@ static bool vita2d_gfx_frame(void *data, const void *frame, buffer[0] = buffer_fps[0] = '\0'; 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); } diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index cece351d83..066740c540 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -1521,13 +1521,12 @@ static void vulkan_inject_black_frame(vk_t *vk) static bool vulkan_frame(void *data, const void *frame, 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) { struct vk_per_frame *chain; unsigned width, height; VkClearValue clear_value; 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 begin_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, * and pause to prevent flicker. */ if ( - settings->video.black_frame_insertion + video_info.black_frame_insertion && !input_driver_is_nonblock_state() && !runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, 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; 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; return false; diff --git a/gfx/drivers/wiiu_gfx.c b/gfx/drivers/wiiu_gfx.c index c5af592e70..fad9c6792f 100644 --- a/gfx/drivers/wiiu_gfx.c +++ b/gfx/drivers/wiiu_gfx.c @@ -532,8 +532,8 @@ static void wiiu_gfx_free(void* data) } static bool wiiu_gfx_frame(void* data, const void* frame, - unsigned width, unsigned height, uint64_t frame_count, - unsigned pitch, const char* msg) + unsigned width, unsigned height, uint64_t frame_count, + unsigned pitch, const char* msg, video_frame_info_t video_info) { (void)msg; int i; diff --git a/gfx/drivers/xenon360_gfx.c b/gfx/drivers/xenon360_gfx.c index 0411b2bd57..8ad04d3ae6 100644 --- a/gfx/drivers/xenon360_gfx.c +++ b/gfx/drivers/xenon360_gfx.c @@ -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, - 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; diff --git a/gfx/drivers/xshm_gfx.c b/gfx/drivers/xshm_gfx.c index 6a5211a4a6..6221405a36 100644 --- a/gfx/drivers/xshm_gfx.c +++ b/gfx/drivers/xshm_gfx.c @@ -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, 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; int y; for (y=0;yshmInfo.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, diff --git a/gfx/drivers/xvideo.c b/gfx/drivers/xvideo.c index 5261502c76..b645e866e2 100644 --- a/gfx/drivers/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -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, unsigned height, uint64_t frame_count, - unsigned pitch, const char *msg) + unsigned pitch, const char *msg, video_frame_info_t video_info) { XWindowAttributes target; xv_t *xv = (xv_t*)data; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 553d96ffb1..64bfcd6ca8 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2047,6 +2047,7 @@ void video_driver_frame(const void *data, unsigned width, { static char video_driver_msg[256]; static struct retro_perf_counter video_frame_conv = {0}; + video_frame_info_t video_info; unsigned output_width = 0; unsigned output_height = 0; unsigned output_pitch = 0; @@ -2105,10 +2106,17 @@ void video_driver_frame(const void *data, unsigned width, && settings->video.font_enable && 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( video_driver_data, data, width, height, video_driver_frame_count, - pitch, video_driver_msg)) + pitch, video_driver_msg, video_info)) video_driver_active = false; video_driver_frame_count++; diff --git a/gfx/video_driver.h b/gfx/video_driver.h index d7cf142475..731c9d0cd8 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -81,6 +81,15 @@ typedef struct video_info #endif } 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 * deeply into video driver. */ @@ -141,7 +150,7 @@ typedef struct video_viewport typedef bool (*video_driver_frame_t)(void *data, const void *frame, unsigned width, 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 { diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index cad24dd3cd..1c1f65874c 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -612,10 +612,23 @@ static void video_thread_loop(void *data) thread_update_driver_state(thr); 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, - thr->frame.buffer, thr->frame.width, thr->frame.height, - thr->frame.count, - thr->frame.pitch, *thr->frame.msg ? thr->frame.msg : NULL); + thr->frame.buffer, thr->frame.width, thr->frame.height, + thr->frame.count, + thr->frame.pitch, *thr->frame.msg ? thr->frame.msg : NULL, + video_info); + } 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_, 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; 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) return thr->driver->frame(thr->driver_data, frame_, - width, height, frame_count, pitch, msg); + width, height, frame_count, pitch, msg, video_info); return false; } @@ -734,10 +747,9 @@ static bool video_thread_frame(void *data, const void *frame_, if (!thr->nonblock) { - settings_t *settings = config_get_ptr(); 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; /* Ideally, use absolute time, but that is only a good idea on POSIX. */