diff --git a/general.h b/general.h index 044ff55e54..4974b57621 100644 --- a/general.h +++ b/general.h @@ -155,6 +155,7 @@ struct settings struct { char driver[32]; + char gl_context[32]; float xscale; float yscale; bool fullscreen; diff --git a/gfx/context/drm_egl_ctx.c b/gfx/context/drm_egl_ctx.c index 6172dcb10b..0fd295240f 100644 --- a/gfx/context/drm_egl_ctx.c +++ b/gfx/context/drm_egl_ctx.c @@ -630,6 +630,6 @@ const gfx_ctx_driver_t gfx_ctx_drm_egl = { gfx_ctx_init_egl_image_buffer, gfx_ctx_write_egl_image, NULL, - "drm-egl", + "kms-egl", }; diff --git a/gfx/context/xegl_ctx.c b/gfx/context/xegl_ctx.c index 85b8b7d591..e4bd6f76d1 100644 --- a/gfx/context/xegl_ctx.c +++ b/gfx/context/xegl_ctx.c @@ -369,7 +369,7 @@ static bool gfx_ctx_set_video_mode( if (true_full) { - RARCH_LOG("[GLX]: Using true fullscreen.\n"); + RARCH_LOG("[X/EGL]: Using true fullscreen.\n"); XMapRaised(g_dpy, g_win); } else if (fullscreen) // We attempted true fullscreen, but failed. Attempt using windowed fullscreen. @@ -455,7 +455,7 @@ static void gfx_ctx_destroy(void) g_screen = x11_get_xinerama_monitor(g_dpy, x, y, target.width, target.height); - RARCH_LOG("[GLX]: Saved monitor #%u.\n", g_screen); + RARCH_LOG("[X/EGL]: Saved monitor #%u.\n", g_screen); #endif XUnmapWindow(g_dpy, g_win); diff --git a/gfx/gl.c b/gfx/gl.c index 019c383d02..4748f12c53 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -1569,6 +1569,45 @@ static void gl_init_pbo_readback(void *data) #endif } +static const gfx_ctx_driver_t *gl_get_context(void) +{ +#ifdef HAVE_OPENGLES + enum gfx_ctx_api api = GFX_CTX_OPENGL_ES_API; + const char *api_name = "OpenGL ES"; +#else + enum gfx_ctx_api api = GFX_CTX_OPENGL_API; + const char *api_name = "OpenGL"; +#endif + + if (*g_settings.video.gl_context) + { + const gfx_ctx_driver_t *ctx = gfx_ctx_find_driver(g_settings.video.gl_context); + if (ctx) + { + if (!ctx->bind_api(api)) + { + RARCH_ERR("Failed to bind API %s to context %s.\n", api_name, g_settings.video.gl_context); + return NULL; + } + + if (!ctx->init()) + { + RARCH_ERR("Failed to init GL context: %s.\n", ctx->ident); + return NULL; + } + } + else + { + RARCH_ERR("Didn't find GL context: %s.\n", g_settings.video.gl_context); + return NULL; + } + + return ctx; + } + else + return gfx_ctx_init_first(api); +} + static void *gl_init(const video_info_t *video, const input_driver_t **input, void **input_data) { #ifdef _WIN32 @@ -1589,11 +1628,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo if (!gl) return NULL; -#ifdef HAVE_OPENGLES - gl->ctx_driver = gfx_ctx_init_first(GFX_CTX_OPENGL_ES_API); -#else - gl->ctx_driver = gfx_ctx_init_first(GFX_CTX_OPENGL_API); -#endif + gl->ctx_driver = gl_get_context(); if (!gl->ctx_driver) { free(gl); diff --git a/retroarch.cfg b/retroarch.cfg index 22248ce2cf..9285288f0b 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -40,6 +40,11 @@ # Video driver to use. "gl", "xvideo", "sdl" # video_driver = "gl" +# Which OpenGL context implementation to use. +# Possible ones for desktop are: glx, x-egl, kms-egl, sdl-gl, wgl. +# By default, tries to use first suitable driver. +# video_gl_context = + # Windowed xscale and yscale # (Real x res: base_size * xscale * aspect_ratio, real y res: base_size * yscale) # video_xscale = 3.0 diff --git a/settings.c b/settings.c index 83093c3e13..4e6576e845 100644 --- a/settings.c +++ b/settings.c @@ -648,6 +648,7 @@ bool config_load_file(const char *path) CONFIG_GET_STRING(audio.resampler, "audio_resampler"); CONFIG_GET_STRING(video.driver, "video_driver"); + CONFIG_GET_STRING(video.gl_context, "video_gl_context"); CONFIG_GET_STRING(audio.driver, "audio_driver"); CONFIG_GET_PATH(audio.dsp_plugin, "audio_dsp_plugin"); CONFIG_GET_STRING(input.driver, "input_driver");