diff --git a/gfx/drivers/d3d.cpp b/gfx/drivers/d3d.cpp index 736899e249..9503a0cdf3 100644 --- a/gfx/drivers/d3d.cpp +++ b/gfx/drivers/d3d.cpp @@ -1465,7 +1465,7 @@ static bool d3d_frame(void *data, const void *frame, performance_counter_stop(&d3d_frame); - video_context_driver_swap_buffers(); + video_context_driver_swap_buffers(video_info); return true; } diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index cf0240d5d5..c24048e9b7 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1331,11 +1331,11 @@ static bool gl_frame(void *data, const void *frame, && !runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL) && !runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) { - video_context_driver_swap_buffers(); + video_context_driver_swap_buffers(video_info); glClear(GL_COLOR_BUFFER_BIT); } - video_context_driver_swap_buffers(); + video_context_driver_swap_buffers(video_info); #ifdef HAVE_GL_SYNC if (video_info.hard_sync && gl->have_sync) diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 8c803aa8c1..aa4c3d15d2 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -428,7 +428,7 @@ static bool vg_frame(void *data, const void *frame, performance_counter_stop(&vg_fr); - video_context_driver_swap_buffers(); + video_context_driver_swap_buffers(video_info); return true; } diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index fd9bf1f26e..4937ac8068 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -1464,7 +1464,7 @@ static void vulkan_readback(vk_t *vk) VK_PIPELINE_STAGE_HOST_BIT); } -static void vulkan_inject_black_frame(vk_t *vk) +static void vulkan_inject_black_frame(vk_t *vk, video_frame_info_t video_info) { VkCommandBufferBeginInfo begin_info = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO }; @@ -1515,7 +1515,7 @@ static void vulkan_inject_black_frame(vk_t *vk) slock_unlock(vk->context->queue_lock); #endif - video_context_driver_swap_buffers(); + video_context_driver_swap_buffers(video_info); } static bool vulkan_frame(void *data, const void *frame, @@ -1910,7 +1910,7 @@ static bool vulkan_frame(void *data, const void *frame, performance_counter_stop(&queue_submit); performance_counter_start(&swapbuffers); - video_context_driver_swap_buffers(); + video_context_driver_swap_buffers(video_info); performance_counter_stop(&swapbuffers); if (!vk->context->swap_interval_emulation_lock) @@ -1937,7 +1937,7 @@ static bool vulkan_frame(void *data, const void *frame, && !runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL) && !runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) { - vulkan_inject_black_frame(vk); + vulkan_inject_black_frame(vk, video_info); } /* Vulkan doesn't directly support swap_interval > 1, so we fake it by duping out more frames. */ diff --git a/gfx/drivers_context/android_ctx.c b/gfx/drivers_context/android_ctx.c index 49e56af317..0c3493a260 100644 --- a/gfx/drivers_context/android_ctx.c +++ b/gfx/drivers_context/android_ctx.c @@ -37,7 +37,6 @@ #endif #include "../../frontend/drivers/platform_linux.h" -#include "../../configuration.h" #include "../../runloop.h" static enum gfx_ctx_api android_api = GFX_CTX_NONE; @@ -492,7 +491,7 @@ dpi_fallback: return true; } -static void android_gfx_ctx_swap_buffers(void *data) +static void android_gfx_ctx_swap_buffers(void *data, video_frame_info_t video_info) { android_ctx_data_t *and = (android_ctx_data_t*)data; diff --git a/gfx/drivers_context/bbqnx_ctx.c b/gfx/drivers_context/bbqnx_ctx.c index e6b97d2137..2c5c426c6d 100644 --- a/gfx/drivers_context/bbqnx_ctx.c +++ b/gfx/drivers_context/bbqnx_ctx.c @@ -42,7 +42,6 @@ #include "../common/gl_common.h" #endif -#include "../../configuration.h" #include "../../runloop.h" #define WINDOW_BUFFERS 2 @@ -363,7 +362,7 @@ static void gfx_ctx_qnx_set_swap_interval(void *data, unsigned swap_interval) #endif } -static void gfx_ctx_qnx_swap_buffers(void *data) +static void gfx_ctx_qnx_swap_buffers(void *data, video_frame_info_t video_info) { qnx_ctx_data_t *qnx = (qnx_ctx_data_t*)data; diff --git a/gfx/drivers_context/cgl_ctx.c b/gfx/drivers_context/cgl_ctx.c index e326ccfffa..2f47daeaa7 100644 --- a/gfx/drivers_context/cgl_ctx.c +++ b/gfx/drivers_context/cgl_ctx.c @@ -29,9 +29,7 @@ #include #include -#include "../../configuration.h" #include "../../runloop.h" -#include "../../configuration.h" #include "../video_context_driver.h" typedef int CGSConnectionID; @@ -97,7 +95,7 @@ static void gfx_ctx_cgl_check_window(void *data, bool *quit, } } -static void gfx_ctx_cgl_swap_buffers(void *data) +static void gfx_ctx_cgl_swap_buffers(void *data, video_frame_info_t video_info) { gfx_ctx_cgl_data_t *cgl = (gfx_ctx_cgl_data_t*)data; diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index 787a1c210d..8cfb295614 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -536,7 +536,7 @@ static bool cocoagl_gfx_ctx_has_windowed(void *data) #endif } -static void cocoagl_gfx_ctx_swap_buffers(void *data) +static void cocoagl_gfx_ctx_swap_buffers(void *data, video_frame_info_t video_info) { if (!(--g_fast_forward_skips < 0)) return; diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index 734597337d..ae20d1354d 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -29,7 +29,6 @@ #include "../drivers/d3d.h" #include "../common/win32_common.h" -#include "../../configuration.h" #include "../../runloop.h" #include "../../verbosity.h" #include "../../ui/ui_companion_driver.h" @@ -77,7 +76,7 @@ static bool gfx_ctx_d3d_set_resize(void *data, unsigned new_width, unsigned new_ return true; } -static void gfx_ctx_d3d_swap_buffers(void *data) +static void gfx_ctx_d3d_swap_buffers(void *data, video_frame_info_t video_info) { d3d_video_t *d3d = (d3d_video_t*)data; LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index 1559d8e533..5463573528 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -226,10 +226,9 @@ static bool gfx_ctx_drm_queue_flip(void) return false; } -static void gfx_ctx_drm_swap_buffers(void *data) +static void gfx_ctx_drm_swap_buffers(void *data, video_frame_info_t video_info) { gfx_ctx_drm_data_t *drm = (gfx_ctx_drm_data_t*)data; - settings_t *settings = config_get_ptr(); switch (drm_api) { @@ -255,7 +254,7 @@ static void gfx_ctx_drm_swap_buffers(void *data) waiting_for_flip = gfx_ctx_drm_queue_flip(); /* Triple-buffered page flips */ - if (settings->video.max_swapchain_images >= 3 && + if (video_info.max_swapchain_images >= 3 && gbm_surface_has_free_buffers(g_gbm_surface)) return; diff --git a/gfx/drivers_context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c index 566cdbd284..ac194f34cc 100644 --- a/gfx/drivers_context/emscriptenegl_ctx.c +++ b/gfx/drivers_context/emscriptenegl_ctx.c @@ -24,7 +24,6 @@ #include "../../config.h" #endif -#include "../../configuration.h" #include "../../runloop.h" #include "../video_context_driver.h" @@ -36,10 +35,6 @@ #include "../common/gl_common.h" #endif -#ifdef HAVE_CONFIG_H -#include "../../config.h" -#endif - typedef struct { #ifdef HAVE_EGL @@ -80,7 +75,7 @@ static void gfx_ctx_emscripten_check_window(void *data, bool *quit, *quit = false; } -static void gfx_ctx_emscripten_swap_buffers(void *data) +static void gfx_ctx_emscripten_swap_buffers(void *data, video_frame_info_t video_info) { (void)data; /* no-op in emscripten, no way to force swap/wait for VSync in browsers */ diff --git a/gfx/drivers_context/gfx_null_ctx.c b/gfx/drivers_context/gfx_null_ctx.c index 37061bd3a6..0610ac5cf7 100644 --- a/gfx/drivers_context/gfx_null_ctx.c +++ b/gfx/drivers_context/gfx_null_ctx.c @@ -35,7 +35,7 @@ static void gfx_ctx_null_check_window(void *data, bool *quit, (void)resize; } -static void gfx_ctx_null_swap_buffers(void *data) +static void gfx_ctx_null_swap_buffers(void *data, video_frame_info_t video_info) { (void)data; } diff --git a/gfx/drivers_context/khr_display_ctx.c b/gfx/drivers_context/khr_display_ctx.c index 3c874bcbad..f3c0dc1b84 100644 --- a/gfx/drivers_context/khr_display_ctx.c +++ b/gfx/drivers_context/khr_display_ctx.c @@ -17,7 +17,6 @@ #include "../../config.h" #endif -#include "../../configuration.h" #include "../../runloop.h" #include "../../frontend/frontend_driver.h" #include "../common/vulkan_common.h" @@ -201,7 +200,7 @@ static void gfx_ctx_khr_display_set_swap_interval(void *data, unsigned swap_inte } } -static void gfx_ctx_khr_display_swap_buffers(void *data) +static void gfx_ctx_khr_display_swap_buffers(void *data, video_frame_info_t video_info) { khr_display_ctx_data_t *khr = (khr_display_ctx_data_t*)data; vulkan_present(&khr->vk, khr->vk.context.current_swapchain_index); diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index 974b8f89a6..413713e802 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -37,7 +37,6 @@ #endif #include "../../frontend/frontend_driver.h" -#include "../../configuration.h" #include "../../runloop.h" typedef struct @@ -269,7 +268,7 @@ static void gfx_ctx_mali_fbdev_set_swap_interval(void *data, unsigned swap_inter #endif } -static void gfx_ctx_mali_fbdev_swap_buffers(void *data) +static void gfx_ctx_mali_fbdev_swap_buffers(void *data, video_frame_info_t video_info) { mali_ctx_data_t *mali = (mali_ctx_data_t*)data; diff --git a/gfx/drivers_context/opendingux_fbdev_ctx.c b/gfx/drivers_context/opendingux_fbdev_ctx.c index 5bfa3008cf..5c61086ab9 100644 --- a/gfx/drivers_context/opendingux_fbdev_ctx.c +++ b/gfx/drivers_context/opendingux_fbdev_ctx.c @@ -29,7 +29,6 @@ #endif #include "../../frontend/frontend_driver.h" -#include "../../configuration.h" #include "../../runloop.h" typedef struct @@ -232,7 +231,7 @@ static bool gfx_ctx_opendingux_has_windowed(void *data) return false; } -static void gfx_ctx_opendingux_swap_buffers(void *data) +static void gfx_ctx_opendingux_swap_buffers(void *data, video_frame_info_t video_info) { opendingux_ctx_data_t *viv = (opendingux_ctx_data_t*)data; diff --git a/gfx/drivers_context/osmesa_ctx.c b/gfx/drivers_context/osmesa_ctx.c index 41bab2da4f..c283ed06b9 100644 --- a/gfx/drivers_context/osmesa_ctx.c +++ b/gfx/drivers_context/osmesa_ctx.c @@ -361,7 +361,7 @@ static bool osmesa_ctx_has_windowed(void *data) return true; } -static void osmesa_ctx_swap_buffers(void *data) +static void osmesa_ctx_swap_buffers(void *data, video_frame_info_t video_info) { gfx_ctx_osmesa_data_t *osmesa = (gfx_ctx_osmesa_data_t*)data; osmesa_fifo_accept(osmesa); diff --git a/gfx/drivers_context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index e882ccc8e7..d967dc8107 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -16,6 +16,10 @@ #include +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #ifndef __PSL1GHT__ #include #endif @@ -31,10 +35,6 @@ #include "../common/gl_common.h" #include "../video_context_driver.h" -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - typedef struct gfx_ctx_ps3_data { #if defined(HAVE_PSGL) @@ -178,7 +178,7 @@ static bool gfx_ctx_ps3_has_windowed(void *data) return false; } -static void gfx_ctx_ps3_swap_buffers(void *data) +static void gfx_ctx_ps3_swap_buffers(void *data, video_frame_info_t video_info) { (void)data; #ifdef HAVE_LIBDBGFONT diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index c4e08a01e4..39181f8743 100644 --- a/gfx/drivers_context/sdl_gl_ctx.c +++ b/gfx/drivers_context/sdl_gl_ctx.c @@ -378,7 +378,7 @@ static bool sdl_ctx_has_windowed(void *data) return true; } -static void sdl_ctx_swap_buffers(void *data) +static void sdl_ctx_swap_buffers(void *data, video_frame_info_t video_info) { #ifdef HAVE_SDL2 gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*)data; diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index 25b1f13a26..45603bd6bf 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -607,7 +607,7 @@ error: return false; } -static void gfx_ctx_vc_swap_buffers(void *data) +static void gfx_ctx_vc_swap_buffers(void *data, video_frame_info_t video_info) { vc_ctx_data_t *vc = (vc_ctx_data_t*)data; diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index 18302d4bf0..17abc79b05 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -28,7 +28,6 @@ #include "../common/gl_common.h" #endif -#include "../../configuration.h" #include "../../frontend/frontend_driver.h" #include "../../runloop.h" @@ -246,7 +245,7 @@ static void gfx_ctx_vivante_set_swap_interval(void *data, unsigned swap_interval #endif } -static void gfx_ctx_vivante_swap_buffers(void *data) +static void gfx_ctx_vivante_swap_buffers(void *data, video_frame_info_t video_info) { vivante_ctx_data_t *viv = (vivante_ctx_data_t*)data; diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 6cec614f0f..ab30e3ba45 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -1548,7 +1548,7 @@ static void *gfx_ctx_wl_get_context_data(void *data) } #endif -static void gfx_ctx_wl_swap_buffers(void *data) +static void gfx_ctx_wl_swap_buffers(void *data, video_frame_info_t video_info) { gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index 9467189c20..15766f0733 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -39,7 +39,6 @@ #include "../../config.h" #endif -#include "../../configuration.h" #include "../../dynamic.h" #include "../../runloop.h" #include "../video_context_driver.h" @@ -331,7 +330,7 @@ static void gfx_ctx_wgl_check_window(void *data, bool *quit, } } -static void gfx_ctx_wgl_swap_buffers(void *data) +static void gfx_ctx_wgl_swap_buffers(void *data, video_frame_info_t video_info) { (void)data; diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index b18f865f64..ac7efb619d 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -250,7 +250,7 @@ static void gfx_ctx_x_swap_interval(void *data, unsigned interval) } } -static void gfx_ctx_x_swap_buffers(void *data) +static void gfx_ctx_x_swap_buffers(void *data, video_frame_info_t video_info) { gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*)data; @@ -570,6 +570,7 @@ static bool gfx_ctx_x_set_video_mode(void *data, 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; + video_info.max_swapchain_images = settings->video.max_swapchain_images; x11_set_window_attr(g_x11_dpy, g_x11_win); x11_update_window_title(NULL, video_info); diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 025f51fb43..30a09ee8c5 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -362,6 +362,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, 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; + video_info.max_swapchain_images = settings->video.max_swapchain_images; x11_set_window_attr(g_x11_dpy, g_x11_win); x11_update_window_title(NULL, video_info); @@ -503,7 +504,7 @@ static void gfx_ctx_xegl_show_mouse(void *data, bool state) x11_show_mouse(g_x11_dpy, g_x11_win, state); } -static void gfx_ctx_xegl_swap_buffers(void *data) +static void gfx_ctx_xegl_swap_buffers(void *data, video_frame_info_t video_info) { xegl_ctx_data_t *xegl = (xegl_ctx_data_t*)data; diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index 41e2d6b148..b6fea97c8c 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -122,7 +122,7 @@ typedef struct gfx_ctx_driver /* Swaps buffers. VBlank sync depends on * earlier calls to swap_interval. */ - void (*swap_buffers)(void*); + void (*swap_buffers)(void*, video_frame_info_t video_info); /* Most video backends will want to use a certain input driver. * Checks for it here. */ @@ -294,9 +294,9 @@ void video_context_driver_destroy(void); if (current_video_context && current_video_context->update_window_title) \ current_video_context->update_window_title(video_context_data, video_info) -#define video_context_driver_swap_buffers() \ +#define video_context_driver_swap_buffers(video_info) \ if (current_video_context && current_video_context->swap_buffers) \ - current_video_context->swap_buffers(video_context_data) + current_video_context->swap_buffers(video_context_data, video_info) #define video_context_driver_focus() ((video_context_data && current_video_context->has_focus && current_video_context->has_focus(video_context_data)) ? true : false) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 64bfcd6ca8..04e6ef6a1a 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2112,6 +2112,7 @@ void video_driver_frame(const void *data, unsigned width, 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; + video_info.max_swapchain_images = settings->video.max_swapchain_images; if (!current_video || !current_video->frame( video_driver_data, data, width, height, diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 731c9d0cd8..764cc4ca56 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -88,6 +88,7 @@ typedef struct video_frame_info bool hard_sync; unsigned hard_sync_frames; bool fps_show; + unsigned max_swapchain_images; } video_frame_info_t; /* Optionally implemented interface to poke more diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index 1c1f65874c..aaa0bd258e 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -622,6 +622,7 @@ static void video_thread_loop(void *data) 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; + video_info.max_swapchain_images = settings->video.max_swapchain_images; ret = thr->driver->frame(thr->driver_data, thr->frame.buffer, thr->frame.width, thr->frame.height, diff --git a/runloop.h b/runloop.h index 5e2460b36e..3a1771da1f 100644 --- a/runloop.h +++ b/runloop.h @@ -17,6 +17,9 @@ #ifndef __RETROARCH_RUNLOOP_H #define __RETROARCH_RUNLOOP_H +#include +#include +#include #include #include