From 9ddb3bc315adbc0c3951f00458fe05973fd13ef6 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Mon, 30 Sep 2019 15:29:13 +0300 Subject: [PATCH] backend-x11: use DRM formats for EGLConfig Define a specific DRM format for the GL-renderer to render in. It goes through fuzzy matching in egl-glue.c which ensures we get exactly the number of bits for each channel, but does not require an exact format match. This ensures we get the bit depth we expect instead of the first arbitrary EGLConfig. This should not change the current behaviour, because Mesa EGL takes care to order the configs as apps expect. Signed-off-by: Pekka Paalanen --- libweston/backend-x11/x11.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/libweston/backend-x11/x11.c b/libweston/backend-x11/x11.c index 9f58ed41..5498aba3 100644 --- a/libweston/backend-x11/x11.c +++ b/libweston/backend-x11/x11.c @@ -39,6 +39,7 @@ #include #include +#include #include #include #ifdef HAVE_XCB_XKB @@ -72,6 +73,10 @@ #define WINDOW_MAX_WIDTH 8192 #define WINDOW_MAX_HEIGHT 8192 +static const uint32_t x11_formats[] = { + DRM_FORMAT_XRGB8888, +}; + struct x11_backend { struct weston_backend base; struct weston_compositor *compositor; @@ -866,8 +871,8 @@ x11_output_switch_mode(struct weston_output *base, struct weston_mode *mode) (EGLNativeWindowType) output->window, &xid, gl_renderer->opaque_attribs, - NULL, - 0); + x11_formats, + ARRAY_LENGTH(x11_formats)); if (ret < 0) return -1; } @@ -1042,8 +1047,8 @@ x11_output_enable(struct weston_output *base) (EGLNativeWindowType) output->window, &xid, gl_renderer->opaque_attribs, - NULL, - 0); + x11_formats, + ARRAY_LENGTH(x11_formats)); if (ret < 0) goto err; @@ -1810,7 +1815,9 @@ init_gl_renderer(struct x11_backend *b) ret = gl_renderer->display_create(b->compositor, EGL_PLATFORM_X11_KHR, (void *) b->dpy, - gl_renderer->opaque_attribs, NULL, 0); + gl_renderer->opaque_attribs, + x11_formats, + ARRAY_LENGTH(x11_formats)); return ret; }