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 <ajax@redhat.com> Signed-off-by: Konstantin <ria.freelander@gmail.com>
This commit is contained in:
parent
d5c2a4d3f5
commit
a44a4b0d4d
|
@ -1035,11 +1035,24 @@ glamor_egl_try_gles_api(ScrnInfoPtr scrn)
|
||||||
return TRUE;
|
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
|
Bool
|
||||||
glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
||||||
{
|
{
|
||||||
struct glamor_egl_screen_private *glamor_egl;
|
struct glamor_egl_screen_private *glamor_egl;
|
||||||
const GLubyte *renderer;
|
const GLubyte *renderer;
|
||||||
|
OptionInfoPtr options;
|
||||||
|
const char *api = NULL;
|
||||||
|
Bool es_allowed = TRUE;
|
||||||
|
Bool force_es = FALSE;
|
||||||
|
|
||||||
glamor_egl = calloc(sizeof(*glamor_egl), 1);
|
glamor_egl = calloc(sizeof(*glamor_egl), 1);
|
||||||
if (glamor_egl == NULL)
|
if (glamor_egl == NULL)
|
||||||
|
@ -1047,6 +1060,16 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
||||||
if (xf86GlamorEGLPrivateIndex == -1)
|
if (xf86GlamorEGLPrivateIndex == -1)
|
||||||
xf86GlamorEGLPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
|
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;
|
scrn->privates[xf86GlamorEGLPrivateIndex].ptr = glamor_egl;
|
||||||
glamor_egl->fd = fd;
|
glamor_egl->fd = fd;
|
||||||
glamor_egl->gbm = gbm_create_device(glamor_egl->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_surfaceless_context);
|
||||||
GLAMOR_CHECK_EGL_EXTENSION(KHR_no_config_context);
|
GLAMOR_CHECK_EGL_EXTENSION(KHR_no_config_context);
|
||||||
|
|
||||||
|
if (!force_es) {
|
||||||
if(!glamor_egl_try_big_gl_api(scrn))
|
if(!glamor_egl_try_big_gl_api(scrn))
|
||||||
goto error;
|
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))
|
if(!glamor_egl_try_gles_api(scrn))
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue