backend-x11: use DRM formats for EGLConfig
authorPekka Paalanen <pekka.paalanen@collabora.com>
Mon, 30 Sep 2019 12:29:13 +0000 (15:29 +0300)
committerPekka Paalanen <pekka.paalanen@collabora.com>
Fri, 4 Oct 2019 09:17:18 +0000 (12:17 +0300)
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 <pekka.paalanen@collabora.com>
libweston/backend-x11/x11.c

index 9f58ed417fcbb628fc9a5d2d8eaa3857833501a5..5498aba3e6394acd39256dad13a071490c2fb746 100644 (file)
@@ -39,6 +39,7 @@
 #include <sys/shm.h>
 #include <linux/input.h>
 
+#include <drm_fourcc.h>
 #include <xcb/xcb.h>
 #include <xcb/shm.h>
 #ifdef HAVE_XCB_XKB
 #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;
 }