From 1fa3475d7957d72f1d70d26bc2bcc83a13829e1f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 Jan 2017 16:52:07 +0100 Subject: [PATCH] Add parameter to video_context_driver's 'init' function --- gfx/drivers_context/android_ctx.c | 2 +- gfx/drivers_context/cgl_ctx.c | 2 +- gfx/drivers_context/cocoa_gl_ctx.m | 2 +- gfx/drivers_context/d3d_ctx.cpp | 2 +- gfx/drivers_context/drm_ctx.c | 2 +- gfx/drivers_context/emscriptenegl_ctx.c | 2 +- gfx/drivers_context/gfx_null_ctx.c | 2 +- gfx/drivers_context/khr_display_ctx.c | 2 +- gfx/drivers_context/mali_fbdev_ctx.c | 2 +- gfx/drivers_context/opendingux_fbdev_ctx.c | 2 +- gfx/drivers_context/osmesa_ctx.c | 2 +- gfx/drivers_context/ps3_ctx.c | 2 +- gfx/drivers_context/qnx_ctx.c | 2 +- gfx/drivers_context/sdl_gl_ctx.c | 2 +- gfx/drivers_context/vc_egl_ctx.c | 2 +- gfx/drivers_context/vivante_fbdev_ctx.c | 2 +- gfx/drivers_context/wayland_ctx.c | 2 +- gfx/drivers_context/wgl_ctx.cpp | 2 +- gfx/drivers_context/x_ctx.c | 2 +- gfx/drivers_context/xegl_ctx.c | 2 +- gfx/video_context_driver.c | 10 +++++++--- gfx/video_context_driver.h | 2 +- gfx/video_driver.c | 1 + gfx/video_driver.h | 1 + 24 files changed, 30 insertions(+), 24 deletions(-) diff --git a/gfx/drivers_context/android_ctx.c b/gfx/drivers_context/android_ctx.c index 3e0cf45ffb..5c84cf1d7c 100644 --- a/gfx/drivers_context/android_ctx.c +++ b/gfx/drivers_context/android_ctx.c @@ -101,7 +101,7 @@ static void android_gfx_ctx_destroy(void *data) free(data); } -static void *android_gfx_ctx_init(void *video_driver) +static void *android_gfx_ctx_init(video_frame_info_t video_info, void *video_driver) { #ifdef HAVE_OPENGLES EGLint n, major, minor; diff --git a/gfx/drivers_context/cgl_ctx.c b/gfx/drivers_context/cgl_ctx.c index e836775e66..60f1dfe2b1 100644 --- a/gfx/drivers_context/cgl_ctx.c +++ b/gfx/drivers_context/cgl_ctx.c @@ -303,7 +303,7 @@ static CGSSurfaceID attach_gl_context_to_window(CGLContextObj glCtx, return sid; } -static void *gfx_ctx_cgl_init(void *video_driver) +static void *gfx_ctx_cgl_init(video_frame_info_t video_info, void *video_driver) { CGError err; gfx_ctx_cgl_data_t *cgl = (gfx_ctx_cgl_data_t*)calloc(1, sizeof(gfx_ctx_cgl_data_t)); diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index 7a5de56bae..cf18281938 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -213,7 +213,7 @@ void cocoagl_gfx_ctx_update(void) #endif } -static void *cocoagl_gfx_ctx_init(void *video_driver) +static void *cocoagl_gfx_ctx_init(video_frame_info_t video_info, void *video_driver) { (void)video_driver; diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index de7cc361e1..ab1d5b4682 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -169,7 +169,7 @@ static bool gfx_ctx_d3d_bind_api(void *data, #endif } -static void *gfx_ctx_d3d_init(void *video_driver) +static void *gfx_ctx_d3d_init(video_frame_info_t video_info, void *video_driver) { win32_monitor_init(); diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index 4dcc0b48b1..9d68ebd7c8 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -356,7 +356,7 @@ static void gfx_ctx_drm_destroy_resources(gfx_ctx_drm_data_t *drm) g_next_bo = NULL; } -static void *gfx_ctx_drm_init(void *video_driver) +static void *gfx_ctx_drm_init(video_frame_info_t video_info, void *video_driver) { int fd, i; unsigned monitor_index; diff --git a/gfx/drivers_context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c index 8e8b5c478b..4a9d9735cd 100644 --- a/gfx/drivers_context/emscriptenegl_ctx.c +++ b/gfx/drivers_context/emscriptenegl_ctx.c @@ -121,7 +121,7 @@ static void gfx_ctx_emscripten_destroy(void *data) free(data); } -static void *gfx_ctx_emscripten_init(void *video_driver) +static void *gfx_ctx_emscripten_init(video_frame_info_t video_info, void *video_driver) { #ifdef HAVE_EGL unsigned width, height; diff --git a/gfx/drivers_context/gfx_null_ctx.c b/gfx/drivers_context/gfx_null_ctx.c index daa081f616..36078d774a 100644 --- a/gfx/drivers_context/gfx_null_ctx.c +++ b/gfx/drivers_context/gfx_null_ctx.c @@ -127,7 +127,7 @@ static void gfx_ctx_null_bind_hw_render(void *data, bool enable) (void)enable; } -static void *gfx_ctx_null_init(void *video_driver) +static void *gfx_ctx_null_init(video_frame_info_t video_info, void *video_driver) { (void)video_driver; diff --git a/gfx/drivers_context/khr_display_ctx.c b/gfx/drivers_context/khr_display_ctx.c index 5cab4992f8..ced55e6b33 100644 --- a/gfx/drivers_context/khr_display_ctx.c +++ b/gfx/drivers_context/khr_display_ctx.c @@ -52,7 +52,7 @@ static void gfx_ctx_khr_display_get_video_size(void *data, *height = khr->height; } -static void *gfx_ctx_khr_display_init(void *video_driver) +static void *gfx_ctx_khr_display_init(video_frame_info_t video_info, void *video_driver) { khr_display_ctx_data_t *khr = (khr_display_ctx_data_t*)calloc(1, sizeof(*khr)); if (!khr) diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index fec92defe5..475ba08255 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -87,7 +87,7 @@ static void gfx_ctx_mali_fbdev_get_video_size(void *data, *height = mali->height; } -static void *gfx_ctx_mali_fbdev_init(void *video_driver) +static void *gfx_ctx_mali_fbdev_init(video_frame_info_t video_info, void *video_driver) { #ifdef HAVE_EGL EGLint n; diff --git a/gfx/drivers_context/opendingux_fbdev_ctx.c b/gfx/drivers_context/opendingux_fbdev_ctx.c index f740199263..141b3ad54f 100644 --- a/gfx/drivers_context/opendingux_fbdev_ctx.c +++ b/gfx/drivers_context/opendingux_fbdev_ctx.c @@ -56,7 +56,7 @@ static void gfx_ctx_opendingux_destroy(void *data) } } -static void *gfx_ctx_opendingux_init(void *video_driver) +static void *gfx_ctx_opendingux_init(video_frame_info_t video_info, void *video_driver) { #ifdef HAVE_EGL EGLint n; diff --git a/gfx/drivers_context/osmesa_ctx.c b/gfx/drivers_context/osmesa_ctx.c index f21682d291..24caa0ab61 100644 --- a/gfx/drivers_context/osmesa_ctx.c +++ b/gfx/drivers_context/osmesa_ctx.c @@ -140,7 +140,7 @@ static void osmesa_fifo_write(gfx_ctx_osmesa_data_t *osmesa) } } -static void *osmesa_ctx_init(void *video_driver) +static void *osmesa_ctx_init(video_frame_info_t video_info, void *video_driver) { #ifdef HAVE_OSMESA_CREATE_CONTEXT_ATTRIBS const int attribs[] = { diff --git a/gfx/drivers_context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index 555e7c1fb3..5a63a57054 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -225,7 +225,7 @@ static void gfx_ctx_ps3_get_video_size(void *data, #endif } -static void *gfx_ctx_ps3_init(void *video_driver) +static void *gfx_ctx_ps3_init(video_frame_info_t video_info, void *video_driver) { #ifdef HAVE_PSGL PSGLdeviceParameters params; diff --git a/gfx/drivers_context/qnx_ctx.c b/gfx/drivers_context/qnx_ctx.c index 21facaff31..6e3060a904 100644 --- a/gfx/drivers_context/qnx_ctx.c +++ b/gfx/drivers_context/qnx_ctx.c @@ -72,7 +72,7 @@ static void gfx_ctx_qnx_destroy(void *data) free(data); } -static void *gfx_ctx_qnx_init(void *video_driver) +static void *gfx_ctx_qnx_init(video_frame_info_t video_info, void *video_driver) { EGLint n; EGLint major, minor; diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index 9c7a76a26a..2fa338cc1b 100644 --- a/gfx/drivers_context/sdl_gl_ctx.c +++ b/gfx/drivers_context/sdl_gl_ctx.c @@ -73,7 +73,7 @@ static void sdl_ctx_destroy_resources(gfx_ctx_sdl_data_t *sdl) SDL_QuitSubSystem(SDL_INIT_VIDEO); } -static void *sdl_ctx_init(void *video_driver) +static void *sdl_ctx_init(video_frame_info_t video_info, void *video_driver) { gfx_ctx_sdl_data_t *sdl = (gfx_ctx_sdl_data_t*) calloc(1, sizeof(gfx_ctx_sdl_data_t)); diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index 6141fa1880..d5f9b3f8a3 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -157,7 +157,7 @@ static void gfx_ctx_vc_get_video_size(void *data, static void gfx_ctx_vc_destroy(void *data); -static void *gfx_ctx_vc_init(void *video_driver) +static void *gfx_ctx_vc_init(video_frame_info_t video_info, void *video_driver) { VC_DISPMANX_ALPHA_T alpha; EGLint n, major, minor; diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index dc2c7e39e8..e85009b642 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -58,7 +58,7 @@ static void gfx_ctx_vivante_destroy(void *data) } -static void *gfx_ctx_vivante_init(void *video_driver) +static void *gfx_ctx_vivante_init(video_frame_info_t video_info, void *video_driver) { #ifdef HAVE_EGL EGLint n; diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index baa76bb910..9ec79438e5 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -780,7 +780,7 @@ static bool gfx_ctx_wl_get_metrics(void *data, EGL_DEPTH_SIZE, 0 #endif -static void *gfx_ctx_wl_init(void *video_driver) +static void *gfx_ctx_wl_init(video_frame_info_t video_info, void *video_driver) { #ifdef HAVE_OPENGL static const EGLint egl_attribs_gl[] = { diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index 27691a0466..fc6132dbe2 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -426,7 +426,7 @@ static void gfx_ctx_wgl_get_video_size(void *data, } } -static void *gfx_ctx_wgl_init(void *video_driver) +static void *gfx_ctx_wgl_init(video_frame_info_t video_info, void *video_driver) { WNDCLASSEX wndclass = {0}; diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 81a68d94b8..943a415dfd 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -332,7 +332,7 @@ static bool gfx_ctx_x_set_resize(void *data, return false; } -static void *gfx_ctx_x_init(void *data) +static void *gfx_ctx_x_init(video_frame_info_t video_info, void *data) { int nelements = 0; int major = 0; diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 65c7dbb8cd..444287719d 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -101,7 +101,7 @@ static bool gfx_ctx_xegl_set_resize(void *data, return false; } -static void *gfx_ctx_xegl_init(void *video_driver) +static void *gfx_ctx_xegl_init(video_frame_info_t video_info, void *video_driver) { #ifdef HAVE_EGL static const EGLint egl_attribs_gl[] = { diff --git a/gfx/video_context_driver.c b/gfx/video_context_driver.c index a3bd835f74..a3acb683a9 100644 --- a/gfx/video_context_driver.c +++ b/gfx/video_context_driver.c @@ -183,15 +183,19 @@ static const gfx_ctx_driver_t *video_context_driver_init( { if (ctx->bind_api(data, api, major, minor)) { - settings_t *settings = config_get_ptr(); - void *ctx_data = ctx->init(data); + video_frame_info_t video_info; + void *ctx_data = NULL; + + video_driver_build_info(&video_info); + + ctx_data = ctx->init(video_info, data); if (!ctx_data) return NULL; if (ctx->bind_hw_render) ctx->bind_hw_render(ctx_data, - settings->video.shared_context && hw_render_ctx); + video_info.shared_context && hw_render_ctx); video_context_driver_set_data(ctx_data); return ctx; diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index 96b6364001..27d07c2f2b 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -66,7 +66,7 @@ typedef struct gfx_ctx_driver * to hold a pointer to it as the context never outlives the video driver. * * The context driver is responsible for it's own data.*/ - void* (*init)(void *video_driver); + void* (*init)(video_frame_info_t video_info, void *video_driver); void (*destroy)(void *data); /* Which API to bind to. */ diff --git a/gfx/video_driver.c b/gfx/video_driver.c index ff88db0ca5..bd04155171 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2205,6 +2205,7 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->max_swapchain_images = settings->video.max_swapchain_images; video_info->windowed_fullscreen = settings->video.windowed_fullscreen; video_info->monitor_index = settings->video.monitor_index; + video_info->shared_context = settings->video.shared_context; } /** diff --git a/gfx/video_driver.h b/gfx/video_driver.h index e063a56aad..3b76829ee2 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -88,6 +88,7 @@ typedef struct video_info typedef struct video_frame_info { float refresh_rate; + bool shared_context; bool black_frame_insertion; bool hard_sync; unsigned hard_sync_frames;