glamor_egl: add support of GlxVendorLibrary option

Same semantics as in glxdri2.c, and same purpose.

Signed-off-by: Konstantin <ria.freelander@gmail.com>
This commit is contained in:
Konstantin 2023-10-10 17:36:50 +03:00
parent a987fc7c36
commit a449bb4c5d

View File

@ -59,6 +59,7 @@ struct glamor_egl_screen_private {
int fd; int fd;
struct gbm_device *gbm; struct gbm_device *gbm;
int dmabuf_capable; int dmabuf_capable;
Bool force_vendor; /* if GLVND vendor is forced from options */
CloseScreenProcPtr saved_close_screen; CloseScreenProcPtr saved_close_screen;
DestroyPixmapProcPtr saved_destroy_pixmap; DestroyPixmapProcPtr saved_destroy_pixmap;
@ -904,10 +905,13 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
glamor_ctx->make_current = glamor_egl_make_current; glamor_ctx->make_current = glamor_egl_make_current;
gbm_backend_name = gbm_device_get_backend_name(glamor_egl->gbm); /* Use dynamic logic only if vendor is not forced via xorg.conf */
/* Mesa uses "drm" as backend name, in that case, just do nothing */ if (!glamor_egl->force_vendor) {
if (gbm_backend_name && strcmp(gbm_backend_name, "drm") != 0) gbm_backend_name = gbm_device_get_backend_name(glamor_egl->gbm);
glamor_set_glvnd_vendor(screen, gbm_backend_name); /* Mesa uses "drm" as backend name, in that case, just do nothing */
if (gbm_backend_name && strcmp(gbm_backend_name, "drm") != 0)
glamor_set_glvnd_vendor(screen, gbm_backend_name);
}
#ifdef DRI3 #ifdef DRI3
/* Tell the core that we have the interfaces for import/export /* Tell the core that we have the interfaces for import/export
* of pixmaps. * of pixmaps.
@ -1061,10 +1065,12 @@ glamor_egl_try_gles_api(ScrnInfoPtr scrn)
enum { enum {
GLAMOREGLOPT_RENDERING_API, GLAMOREGLOPT_RENDERING_API,
GLAMOREGLOPT_VENDOR_LIBRARY
}; };
static const OptionInfoRec GlamorEGLOptions[] = { static const OptionInfoRec GlamorEGLOptions[] = {
{ GLAMOREGLOPT_RENDERING_API, "RenderingAPI", OPTV_STRING, {0}, FALSE }, { GLAMOREGLOPT_RENDERING_API, "RenderingAPI", OPTV_STRING, {0}, FALSE },
{ GLAMOREGLOPT_VENDOR_LIBRARY, "GlxVendorLibrary", OPTV_STRING, {0}, FALSE },
{ -1, NULL, OPTV_NONE, {0}, FALSE }, { -1, NULL, OPTV_NONE, {0}, FALSE },
}; };
@ -1077,6 +1083,7 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
const char *api = NULL; const char *api = NULL;
Bool es_allowed = TRUE; Bool es_allowed = TRUE;
Bool force_es = FALSE; Bool force_es = FALSE;
const char *glvnd_vendor = NULL;
glamor_egl = calloc(sizeof(*glamor_egl), 1); glamor_egl = calloc(sizeof(*glamor_egl), 1);
if (glamor_egl == NULL) if (glamor_egl == NULL)
@ -1087,6 +1094,11 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
options = xnfalloc(sizeof(GlamorEGLOptions)); options = xnfalloc(sizeof(GlamorEGLOptions));
memcpy(options, GlamorEGLOptions, sizeof(GlamorEGLOptions)); memcpy(options, GlamorEGLOptions, sizeof(GlamorEGLOptions));
xf86ProcessOptions(scrn->scrnIndex, scrn->options, options); xf86ProcessOptions(scrn->scrnIndex, scrn->options, options);
glvnd_vendor = xf86GetOptValString(options, GLAMOREGLOPT_VENDOR_LIBRARY);
if (glvnd_vendor) {
glamor_set_glvnd_vendor(xf86ScrnToScreen(scrn), glvnd_vendor);
glamor_egl->force_vendor = TRUE;
}
api = xf86GetOptValString(options, GLAMOREGLOPT_RENDERING_API); api = xf86GetOptValString(options, GLAMOREGLOPT_RENDERING_API);
if (api && !strncasecmp(api, "es", 2)) if (api && !strncasecmp(api, "es", 2))
force_es = TRUE; force_es = TRUE;