backend-wayland: use DRM formats for EGLConfig
authorPekka Paalanen <pekka.paalanen@collabora.com>
Mon, 30 Sep 2019 12:21:19 +0000 (15:21 +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-wayland/wayland.c

index 9c76f2b30b09ff455121a2b0744cfd69813a812d..d5a60bcf0144f7641f5cb2001a80a05a61151f6b 100644 (file)
@@ -38,6 +38,7 @@
 #include <sys/mman.h>
 #include <linux/input.h>
 
+#include <drm_fourcc.h>
 #include <wayland-client.h>
 #include <wayland-cursor.h>
 
 
 #define WINDOW_TITLE "Weston Compositor"
 
+static const uint32_t wayland_formats[] = {
+       DRM_FORMAT_ARGB8888,
+};
+
 struct wayland_backend {
        struct weston_backend base;
        struct weston_compositor *compositor;
@@ -775,8 +780,8 @@ wayland_output_init_gl_renderer(struct wayland_output *output)
                                              output->gl.egl_window,
                                              output->gl.egl_window,
                                              gl_renderer->alpha_attribs,
-                                             NULL,
-                                             0) < 0)
+                                             wayland_formats,
+                                             ARRAY_LENGTH(wayland_formats)) < 0)
                goto cleanup_window;
 
        return 0;
@@ -2770,8 +2775,8 @@ wayland_backend_create(struct weston_compositor *compositor,
                                                EGL_PLATFORM_WAYLAND_KHR,
                                                b->parent.wl_display,
                                                gl_renderer->alpha_attribs,
-                                               NULL,
-                                               0) < 0) {
+                                               wayland_formats,
+                                               ARRAY_LENGTH(wayland_formats)) < 0) {
                        weston_log("Failed to initialize the GL renderer; "
                                   "falling back to pixman.\n");
                        b->use_pixman = true;