From a44a4b0d4de267eb66f4aa33c84a4e9288fb7c01 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Thu, 21 Sep 2023 18:06:14 +0300 Subject: [PATCH] glamor_egl: add RenderingAPI option This allows to choose between Glamor on OpenGL and Glamor on OpenGL ES via an option. Reviewed-by: Adam Jackson Signed-off-by: Konstantin --- glamor/glamor_egl.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c index 65cf1ecf5..e70711e67 100644 --- a/glamor/glamor_egl.c +++ b/glamor/glamor_egl.c @@ -1035,11 +1035,24 @@ glamor_egl_try_gles_api(ScrnInfoPtr scrn) return TRUE; } +enum { + GLAMOREGLOPT_RENDERING_API, +}; + +static const OptionInfoRec GlamorEGLOptions[] = { + { GLAMOREGLOPT_RENDERING_API, "RenderingAPI", OPTV_STRING, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE }, +}; + Bool glamor_egl_init(ScrnInfoPtr scrn, int fd) { struct glamor_egl_screen_private *glamor_egl; const GLubyte *renderer; + OptionInfoPtr options; + const char *api = NULL; + Bool es_allowed = TRUE; + Bool force_es = FALSE; glamor_egl = calloc(sizeof(*glamor_egl), 1); if (glamor_egl == NULL) @@ -1047,6 +1060,16 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd) if (xf86GlamorEGLPrivateIndex == -1) xf86GlamorEGLPrivateIndex = xf86AllocateScrnInfoPrivateIndex(); + options = xnfalloc(sizeof(GlamorEGLOptions)); + memcpy(options, GlamorEGLOptions, sizeof(GlamorEGLOptions)); + xf86ProcessOptions(scrn->scrnIndex, scrn->options, options); + api = xf86GetOptValString(options, GLAMOREGLOPT_RENDERING_API); + if (api && !strncasecmp(api, "es", 2)) + force_es = TRUE; + else if (api && !strncasecmp(api, "gl", 2)) + es_allowed = FALSE; + free(options); + scrn->privates[xf86GlamorEGLPrivateIndex].ptr = glamor_egl; glamor_egl->fd = fd; glamor_egl->gbm = gbm_create_device(glamor_egl->fd); @@ -1084,10 +1107,12 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd) GLAMOR_CHECK_EGL_EXTENSION(KHR_surfaceless_context); GLAMOR_CHECK_EGL_EXTENSION(KHR_no_config_context); - if(!glamor_egl_try_big_gl_api(scrn)) - goto error; + if (!force_es) { + if(!glamor_egl_try_big_gl_api(scrn)) + goto error; + } - if (glamor_egl->context == EGL_NO_CONTEXT) { + if (glamor_egl->context == EGL_NO_CONTEXT && es_allowed) { if(!glamor_egl_try_gles_api(scrn)) goto error; }