This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch main
in repository entrance.

View the commit online.

commit 8bc61649ddca6e39fd77b94369c55c0a4af87645
Author: Alastair Poole <[email protected]>
AuthorDate: Wed Dec 2 05:49:41 2026 +0000

    Enable OpenGL by default for the Wayland greeter
    
    Use EFL's wayland_egl engine and default damage and swap behavior. Keep full redraws as the software default and expose ENTRANCE_WAYLAND_FULL_REDRAW for troubleshooting. Let the DRM compositor use EFL's default swap mode, with EVAS_GL_SWAP_MODE=full available for stale pixels.
    
    Retry with plain shared memory on OpenGL startup failure. With Wayland client support, also retry after a first-frame timeout or protocol error. Preserve the opt-in software DMA-BUF path through ENTRANCE_WAYLAND_DMABUF=1.
    
    Advertise explicit format and modifier pairs when available and reject implicit layouts for those formats. Omit XR30, XB30, and selected AMD GFX11 modifiers that failed Evas imports. Set the DMA-BUF attributes version before import.
    
    Log engine selection and DMA-BUF rejection details. Add an optional GBM and libdrm probe for allocation, plane export, and import failures. Document the rendering defaults, fallbacks, and diagnostic settings.
---
 README.md                                  |  17 +--
 src/compositor/README.md                   |  33 ++++--
 src/compositor/bin/e_comp.c                |   6 ++
 src/compositor/bin/e_comp_wl_dmabuf.c      | 166 ++++++++++++++++++++++++++---
 src/compositor/bin/e_pixmap.c              |  40 ++++++-
 src/compositor/bin/meson.build             |  10 +-
 src/compositor/modules/wl_drm/e_mod_main.c |   2 -
 src/greeter/entrance_greeter_main.c        |  61 +++++++++--
 8 files changed, 292 insertions(+), 43 deletions(-)

diff --git a/README.md b/README.md
index 9e0ef8d..f0c1360 100644
--- a/README.md
+++ b/README.md
@@ -80,15 +80,16 @@ To migrate SDDM settings, review PAM service names and move the configuration to
 
 Entrance defaults to Xorg. When configured for Wayland, a default full build
 runs the bundled Enlightenment-based compositor directly on the login seat.
-The greeter repaints the full canvas on each rendered frame to avoid stale
-pixels behind moving gadgets and hides the pointer during the desktop handoff.
-Gadget dragging and progress indicators on a scaled output still need live
-verification.
+The greeter tries EFL OpenGL rendering first and can retry startup with
+software rendering over plain shared memory. The software engine defaults to
+full redraws to avoid stale pixels during gadget dragging. The greeter hides
+the pointer during desktop handoff.
+
+To select software rendering explicitly, add `ELM_ENGINE=wayland_shm` to
+the comma-separated `GreeterEnvironment` setting under `[General]`. To try
+software rendering with DMA-BUF and automatic fallback to plain shared
+memory, use `ENTRANCE_WAYLAND_DMABUF=1` without an explicit engine setting.
 
-The Wayland greeter defaults to EFL software rendering with plain shared
-memory. Set `ENTRANCE_WAYLAND_DMABUF=1` in the greeter environment to try
-DMA-BUF with automatic engine selection. EFL can fall back to shared memory
-during negotiation, and the greeter can retry startup with DMA-BUF disabled.
 The Wayland greeter also disables Evas's AVX2 rendering path by default to
 work around a crash observed while opening a menu. See the [compositor notes](src/compositor/README.md) for rendering and retry details.
 
diff --git a/src/compositor/README.md b/src/compositor/README.md
index 5d769b3..680d2f7 100644
--- a/src/compositor/README.md
+++ b/src/compositor/README.md
@@ -10,8 +10,8 @@ directory. It starts the compositor directly under the greeter account.
 The DRM backend tries OpenGL first and falls back to software if GL canvas
 creation fails. Set `E_COMP_ENGINE=sw` to force software on DRM, or
 `E_WL_FORCE=buffer` for headless development.
-The OpenGL DRM backend defaults to full redraws on each rendered frame.
-An explicit `EVAS_GL_SWAP_MODE` in the compositor environment overrides this.
+The OpenGL DRM backend uses EFL’s default swap mode. Set
+`EVAS_GL_SWAP_MODE=full` in the compositor environment if you see stale pixels.
 
 The greeter startup path skips desktop modules, shortcuts, startup
 applications, and system and authentication helpers. Entrance continues
@@ -19,11 +19,32 @@ to handle authentication and user session startup.
 
 ## Greeter buffer transport
 
+The Wayland login greeter defaults to EFL's `wayland_egl` OpenGL engine.
+If Elementary initialization or window creation fails, it retries once with
+software rendering over plain shared memory. With `ecore-wl2` and
+`wayland-client` support, it also retries after a first-frame timeout or a
+Wayland protocol error. OpenGL uses EFL’s default damage and swap behavior.
+The software engine defaults to full canvas redraws. Set
+`ENTRANCE_WAYLAND_FULL_REDRAW=1` to force full greeter redraws on either
+engine, or `ENTRANCE_WAYLAND_FULL_REDRAW=0` to test partial redraws on software.
+
+The compositor omits `XRGB2101010` (`XR30`) and `XBGR2101010` (`XB30`)
+from DMA-BUF advertisements. Evas rejected imports of both formats on AMD
+GFX11, causing the OpenGL greeter to retry with plain SHM. EGL clients can
+negotiate another advertised format and modifier.
+
+For import diagnostics, add `ENTRANCE_DMABUF_PROBE=1` to the comma-separated
+`[General]` `GreeterEnvironment` setting. At compositor startup the probe
+tests DMA-BUF allocation, plane export, and import on the EGL GPU.
+View results with `journalctl -b -t entrance-compositor -g 'DMA-BUF probe|Client DMA-BUF import accepted|DMA-BUF import rejected'`.
+Startup probe results cover test buffers. Client import logs show which
+buffers the greeter and other Wayland clients submit. The probe requires GBM
+and libdrm at build time and access to the GPU render node at runtime.
+
 EFL's `wayland_shm` engine renders in software and can submit either
-DMA-BUF or plain `wl_shm` buffers. The greeter defaults to plain SHM.
-Set `ENTRANCE_WAYLAND_DMABUF=1` to enable DMA-BUF negotiation with automatic
-engine selection. In that mode the greeter retries once with DMA-BUF
-disabled if initialization or window creation fails, the first Wayland
+DMA-BUF or plain `wl_shm` buffers.
+Set `ENTRANCE_WAYLAND_DMABUF=1` to select the software engine and enable DMA-BUF
+negotiation. In that mode the greeter retries once with DMA-BUF disabled if initialization or window creation fails, the first Wayland
 frame callback times out after 10 seconds, or it exits the event loop with
 a Wayland protocol error. This retry requires the optional `ecore-wl2`
 and `wayland-client` build dependencies. Set
diff --git a/src/compositor/bin/e_comp.c b/src/compositor/bin/e_comp.c
index 22c10ca..45f3e83 100644
--- a/src/compositor/bin/e_comp.c
+++ b/src/compositor/bin/e_comp.c
@@ -1,5 +1,6 @@
 #include "e.h"
 # include "e_comp_wl.h"
+#include <syslog.h>
 
 #define OVER_FLOW 1
 //#define BORDER_ZOOMAPS
@@ -1283,6 +1284,11 @@ e_comp_init(void)
       e_xkb_init();
       module = e_module_new(backend);
       if ((!module) || (!e_module_enable(module))) return EINA_FALSE;
+
+      openlog("entrance-compositor", LOG_PID, LOG_DAEMON);
+      syslog(LOG_INFO, "Wayland backend=%s engine=%s", backend,
+             ecore_evas_engine_name_get(e_comp->ee));
+      closelog();
    }
 
    e_comp->comp_type = E_PIXMAP_TYPE_WL;
diff --git a/src/compositor/bin/e_comp_wl_dmabuf.c b/src/compositor/bin/e_comp_wl_dmabuf.c
index 72517df..f56050b 100644
--- a/src/compositor/bin/e_comp_wl_dmabuf.c
+++ b/src/compositor/bin/e_comp_wl_dmabuf.c
@@ -35,17 +35,26 @@
 #include "e.h"
 
 #include <sys/mman.h>
+#include <syslog.h>
 #include <unistd.h>
 #include <fcntl.h>
 
 #include <assert.h>
 
+#ifdef HAVE_DMABUF_PROBE
+# include <gbm.h>
+# include <xf86drm.h>
+#endif
+
 #include "linux-dmabuf-unstable-v1-server-protocol.h"
 
 #ifndef DRM_FORMAT_MOD_LINEAR
 # define DRM_FORMAT_MOD_LINEAR 0
 #endif
 
+/* Version of the DMA-BUF attributes passed to Evas. */
+#define DMABUF_ATTRIBUTES_VERSION 1
+
 /* Defined in e_comp_wl.c, which is where the Evas_GL handle lives. Declared
  * here rather than in a header for the same reason e_pixmap.c declares its two
  * siblings that way: they are one wire between two files in the same binary. */
@@ -209,7 +218,8 @@ _dmabuf_advertised_build(void)
         if (!e_pixmap_dmabuf_modifiers_query(formats[i], &modifiers,
                                              &num_modifiers))
           num_modifiers = 0;
-        grown = realloc(dmabuf_advertised, (n + num_modifiers + 1) *
+        grown = realloc(dmabuf_advertised,
+                        (n + (num_modifiers ? num_modifiers : 1)) *
                         sizeof(Dmabuf_Advertised));
         if (!grown)
           {
@@ -217,12 +227,18 @@ _dmabuf_advertised_build(void)
              break;
           }
         dmabuf_advertised = grown;
-        dmabuf_advertised[n].format = formats[i];
-        dmabuf_advertised[n++].modifier = DRM_FORMAT_MOD_INVALID;
-        for (j = 0; j < num_modifiers; j++)
+        if (num_modifiers == 0)
           {
              dmabuf_advertised[n].format = formats[i];
-             dmabuf_advertised[n++].modifier = modifiers[j];
+             dmabuf_advertised[n++].modifier = DRM_FORMAT_MOD_INVALID;
+          }
+        else
+          {
+             for (j = 0; j < num_modifiers; j++)
+               {
+                  dmabuf_advertised[n].format = formats[i];
+                  dmabuf_advertised[n++].modifier = modifiers[j];
+               }
           }
         free(modifiers);
      }
@@ -230,9 +246,11 @@ _dmabuf_advertised_build(void)
    dmabuf_advertised_num = n;
 }
 
-/* Whether a buffer with format and modifier is one E advertised. A buffer
- * made without modifiers carries DRM_FORMAT_MOD_INVALID, and one with an
- * advertised format and no modifier of its own may be linear. */
+/* Whether a buffer with format and modifier is one E advertised. A buffer made
+ * without modifiers carries DRM_FORMAT_MOD_INVALID. If explicit modifiers were
+ * advertised for a format, clients must use one of those exact modifiers;
+ * accepting implicit buffers beside explicit feedback lets clients allocate
+ * layouts the compositor never promised it could import. */
 static Eina_Bool
 _dmabuf_advertised(uint32_t format, uint64_t modifier)
 {
@@ -248,7 +266,9 @@ _dmabuf_advertised(uint32_t format, uint64_t modifier)
         if (dmabuf_advertised[i].modifier != DRM_FORMAT_MOD_INVALID)
           explicit = EINA_TRUE;
      }
-   return known && (!explicit) && (modifier == DRM_FORMAT_MOD_LINEAR);
+   if (explicit) return EINA_FALSE;
+   return known && ((modifier == DRM_FORMAT_MOD_LINEAR) ||
+                    (modifier == DRM_FORMAT_MOD_INVALID));
 }
 
 static void
@@ -298,7 +318,7 @@ params_create_common(struct wl_client *client, struct wl_resource *params_resour
           }
      }
 
-   buffer->attributes.version = 1;
+   buffer->attributes.version = DMABUF_ATTRIBUTES_VERSION;
    buffer->attributes.width = width;
    buffer->attributes.height = height;
    buffer->attributes.format = format;
@@ -387,16 +407,32 @@ params_create_common(struct wl_client *client, struct wl_resource *params_resour
 
    if (!e_pixmap_dmabuf_test(buffer))
      {
-        WRN("DMA-BUF import rejected: %dx%d, fourcc %#08x, modifier %#llx, %d planes",
+        openlog("entrance-compositor", LOG_PID, LOG_DAEMON);
+        syslog(LOG_WARNING, "DMA-BUF import rejected: %dx%d, fourcc %#08x, modifier %#llx, %d planes",
             width, height, format,
             (unsigned long long)buffer->attributes.modifier[0],
             buffer->attributes.n_planes);
         for (i = 0; i < buffer->attributes.n_planes; i++)
-          WRN("DMA-BUF plane %d: offset %u, stride %u",
+          syslog(LOG_WARNING, "DMA-BUF plane %d: offset %u, stride %u",
               i, buffer->attributes.offset[i], buffer->attributes.stride[i]);
+        closelog();
         goto err_failed;
      }
 
+   {
+      const char *probe = getenv("ENTRANCE_DMABUF_PROBE");
+
+      if (probe && !strcmp(probe, "1"))
+        {
+           openlog("entrance-compositor", LOG_PID, LOG_DAEMON);
+           syslog(LOG_INFO, "Client DMA-BUF import accepted: %dx%d, fourcc %#08x, modifier %#llx, %d planes",
+                  width, height, format,
+                  (unsigned long long)buffer->attributes.modifier[0],
+                  buffer->attributes.n_planes);
+           closelog();
+        }
+   }
+
    buffer->buffer_resource =
      wl_resource_create(client, &wl_buffer_interface, 1, buffer_id);
    if (!buffer->buffer_resource)
@@ -913,7 +949,8 @@ bind_linux_dmabuf(struct wl_client *client, void *data, uint32_t version, uint32
 
    for (i = 0; i < num_formats; i++)
      {
-        e_pixmap_dmabuf_modifiers_query(formats[i], &modifiers, &num_modifiers);
+        if (!e_pixmap_dmabuf_modifiers_query(formats[i], &modifiers, &num_modifiers))
+          continue;
 
         /* send DRM_FORMAT_MOD_INVALID token when no modifiers are supported
          * for this format */
@@ -946,6 +983,94 @@ bind_linux_dmabuf(struct wl_client *client, void *data, uint32_t version, uint32
    free(formats);
 }
 
+#ifdef HAVE_DMABUF_PROBE
+static void
+_dmabuf_probe_format(struct gbm_device *gbm, uint32_t format, uint64_t modifier)
+{
+   struct linux_dmabuf_buffer buffer = {0};
+   struct dmabuf_attributes *attr = &buffer.attributes;
+   struct gbm_bo *bo;
+   uint64_t actual_modifier = DRM_FORMAT_MOD_INVALID;
+   const char *result = "allocation failed";
+   int i, exported = 0;
+
+   if (modifier == DRM_FORMAT_MOD_INVALID)
+     bo = gbm_bo_create(gbm, 109, 274, format, GBM_BO_USE_RENDERING);
+   else
+     bo = gbm_bo_create_with_modifiers2(gbm, 109, 274, format, &modifier, 1,
+                                        GBM_BO_USE_RENDERING);
+   if (bo)
+     {
+        actual_modifier = gbm_bo_get_modifier(bo);
+        attr->version = DMABUF_ATTRIBUTES_VERSION;
+        attr->width = gbm_bo_get_width(bo);
+        attr->height = gbm_bo_get_height(bo);
+        attr->format = format;
+        attr->n_planes = gbm_bo_get_plane_count(bo);
+        result = "plane export failed";
+        if ((attr->n_planes > 0) && (attr->n_planes <= MAX_DMABUF_PLANES))
+          {
+             for (i = 0; i < attr->n_planes; i++)
+               {
+                  attr->fd[i] = gbm_bo_get_fd_for_plane(bo, i);
+                  if (attr->fd[i] < 0) break;
+                  exported++;
+                  attr->offset[i] = gbm_bo_get_offset(bo, i);
+                  attr->stride[i] = gbm_bo_get_stride_for_plane(bo, i);
+                  attr->modifier[i] = actual_modifier;
+               }
+             if (exported == attr->n_planes)
+               result = e_pixmap_dmabuf_test(&buffer) ? "import accepted" : "import rejected";
+          }
+     }
+
+   syslog(LOG_INFO, "DMA-BUF probe %c%c%c%c %s: %s, requested modifier 0x%llx, actual modifier 0x%llx, %d planes",
+          (int)(format & 0xff), (int)((format >> 8) & 0xff),
+          (int)((format >> 16) & 0xff), (int)(format >> 24),
+          modifier == DRM_FORMAT_MOD_INVALID ? "GBM default" : "explicit modifier", result,
+          (unsigned long long)modifier, (unsigned long long)actual_modifier,
+          attr->n_planes);
+   for (i = 0; i < exported; i++)
+     close(attr->fd[i]);
+   if (bo) gbm_bo_destroy(bo);
+}
+
+static void
+_dmabuf_probe_formats(uint64_t device)
+{
+   static const uint32_t formats[] = {
+      GBM_FORMAT_XRGB8888, GBM_FORMAT_ARGB8888,
+      GBM_FORMAT_XBGR8888, GBM_FORMAT_ABGR8888,
+      GBM_FORMAT_XRGB2101010, GBM_FORMAT_XBGR2101010, GBM_FORMAT_ARGB2101010
+   };
+   drmDevicePtr drm = NULL;
+   struct gbm_device *gbm = NULL;
+   int fd = -1;
+   unsigned int i;
+
+   if (device && (drmGetDeviceFromDevId((dev_t)device, 0, &drm) == 0) &&
+       (drm->available_nodes & (1 << DRM_NODE_RENDER)))
+     fd = open(drm->nodes[DRM_NODE_RENDER], O_RDWR | O_CLOEXEC);
+   if (fd >= 0) gbm = gbm_create_device(fd);
+   if (gbm)
+     {
+        for (i = 0; i < sizeof(formats) / sizeof(formats[0]); i++)
+          {
+             _dmabuf_probe_format(gbm, formats[i], DRM_FORMAT_MOD_INVALID);
+             _dmabuf_probe_format(gbm, formats[i], DRM_FORMAT_MOD_LINEAR);
+          }
+        /* Modifiers reported by rejected AR30 client buffers. */
+        _dmabuf_probe_format(gbm, GBM_FORMAT_ARGB2101010, UINT64_C(0x200000010401b04));
+        _dmabuf_probe_format(gbm, GBM_FORMAT_ARGB2101010, UINT64_C(0x200000010401604));
+        gbm_device_destroy(gbm);
+     }
+   else
+     syslog(LOG_WARNING, "DMA-BUF probe unavailable: could not open a GBM device on the EGL GPU");
+   if (fd >= 0) close(fd);
+   if (drm) drmFreeDevice(&drm);
+}
+#endif
+
 /** Advertise linux_dmabuf support
  *
  * Calling this initializes the zwp_linux_dmabuf protocol support, so that
@@ -960,6 +1085,7 @@ bind_linux_dmabuf(struct wl_client *client, void *data, uint32_t version, uint32
 EINTERN int
 linux_dmabuf_setup(struct wl_display *display)
 {
+   const char *probe = getenv("ENTRANCE_DMABUF_PROBE");
    int version = 3;
 
    /* A client that sees the global prefers it to shm, so offering an import
@@ -987,6 +1113,20 @@ linux_dmabuf_setup(struct wl_display *display)
    else
      dmabuf_main_device = 0;
 
+   if (probe && !strcmp(probe, "1"))
+     {
+        openlog("entrance-compositor", LOG_PID, LOG_DAEMON);
+#ifdef HAVE_DMABUF_PROBE
+        uint64_t device = 0;
+
+        e_comp_wl_query_dmabuf_device(&device);
+        _dmabuf_probe_formats(device);
+#else
+        syslog(LOG_WARNING, "DMA-BUF probe unavailable: built without GBM/libdrm probe support");
+#endif
+        closelog();
+     }
+
    if (!wl_global_create(display, &zwp_linux_dmabuf_v1_interface, version,
                          NULL, bind_linux_dmabuf))
      return -1;
diff --git a/src/compositor/bin/e_pixmap.c b/src/compositor/bin/e_pixmap.c
index 0a7a02a..7dd6e04 100644
--- a/src/compositor/bin/e_pixmap.c
+++ b/src/compositor/bin/e_pixmap.c
@@ -976,7 +976,7 @@ e_pixmap_dmabuf_test(struct linux_dmabuf_buffer *dmabuf)
 {
    Evas_Native_Surface ns;
    Evas_Object *test;
-   Eina_Bool ret;
+   Evas_Load_Error error;
    int size;
    void *data;
 
@@ -988,11 +988,17 @@ e_pixmap_dmabuf_test(struct linux_dmabuf_buffer *dmabuf)
    ns.data.wl_dmabuf.resource = NULL;
    test = evas_object_image_add(e_comp->evas);
    evas_object_image_native_surface_set(test, &ns);
-   ret = evas_object_image_load_error_get(test) == EVAS_LOAD_ERROR_NONE;
+   error = evas_object_image_load_error_get(test);
    evas_object_del(test);
 
-   if (e_comp->gl || !ret)
-      return ret;
+   if (error != EVAS_LOAD_ERROR_NONE)
+     {
+        ERR("DMA-BUF Evas import failed: %s (%d), fourcc %#08x, modifier %#llx",
+            evas_load_error_str(error), error, dmabuf->attributes.format,
+            (unsigned long long)dmabuf->attributes.modifier[0]);
+        return EINA_FALSE;
+     }
+   if (e_comp->gl) return EINA_TRUE;
 
    /* This is only legit for ARGB8888 */
    size = dmabuf->attributes.height * dmabuf->attributes.stride[0];
@@ -1028,12 +1034,21 @@ extern Eina_Bool e_comp_wl_query_dmabuf_modifiers(int format, int max_modifiers,
 static Eina_Bool
 _e_pixmap_dmabuf_modifiers_usable(int format, uint64_t **modifiers, int *num_modifiers)
 {
+   /* Linux DRM modifier encoding: AMD vendor 0x02, GFX11 tile
+    * version 0x04, and DCC at bit 13. */
+   const uint64_t amd_gfx11_dcc_mask = UINT64_C(0xff000000000020ff);
+   const uint64_t amd_gfx11_dcc = UINT64_C(0x0200000000002004);
    Eina_Bool *external = NULL;
    uint64_t *mods = NULL;
    int num = 0, i, keep = 0;
 
    *modifiers = NULL;
    *num_modifiers = 0;
+   /* Evas has rejected both 10-bit XRGB and XBGR imports on GFX11,
+    * disconnecting EGL clients that use create_immed. */
+   if ((format == E_PIXMAP_FOURCC('X', 'R', '3', '0')) ||
+       (format == E_PIXMAP_FOURCC('X', 'B', '3', '0')))
+     return EINA_FALSE;
    if ((!e_comp_wl_query_dmabuf_modifiers(format, 0, NULL, NULL, &num)) ||
        (num <= 0))
      return EINA_TRUE;
@@ -1047,7 +1062,22 @@ _e_pixmap_dmabuf_modifiers_usable(int format, uint64_t **modifiers, int *num_mod
         return EINA_TRUE;
      }
    for (i = 0; i < num; i++)
-     if (!external[i]) mods[keep++] = mods[i];
+     {
+        if (external[i]) continue;
+        /* EGL advertises GFX11 DCC even on stacks where Evas fails to
+         * import the buffer with its auxiliary compression plane. A
+         * failed create_immed disconnects the client. */
+        if ((mods[i] & amd_gfx11_dcc_mask) == amd_gfx11_dcc) continue;
+        /* The greeter's ARGB8888 EGL buffer also failed with this layout. */
+        if ((format == DRM_FORMAT_ARGB8888) &&
+            (mods[i] == UINT64_C(0x0200000010401b04))) continue;
+        /* These AMD AR30 layouts failed an Evas probe or client import. */
+        if ((format == E_PIXMAP_FOURCC('A', 'R', '3', '0')) &&
+            ((mods[i] == UINT64_C(0x0200000010401b04)) ||
+             (mods[i] == UINT64_C(0x0200000010401604)) ||
+             (mods[i] == UINT64_C(0x0200000000000a04)))) continue;
+        mods[keep++] = mods[i];
+     }
    free(external);
    if (!keep)
      {
diff --git a/src/compositor/bin/meson.build b/src/compositor/bin/meson.build
index 5cbe9ef..7dd0886 100644
--- a/src/compositor/bin/meson.build
+++ b/src/compositor/bin/meson.build
@@ -98,11 +98,19 @@ src += [
   wayland_proto_h
 ]
 deps_e += dep_wayland
+dep_dmabuf_probe_gbm = dependency('gbm', version: '>=21.3', required: false)
+dep_dmabuf_probe_drm = dependency('libdrm', required: false)
+if dep_dmabuf_probe_gbm.found() and dep_dmabuf_probe_drm.found()
+  deps_e += [dep_dmabuf_probe_gbm, dep_dmabuf_probe_drm]
+  compositor_bin_c_args = ['-DHAVE_DMABUF_PROBE']
+else
+  compositor_bin_c_args = []
+endif
 
 executable('entrance_compositor', src,
            include_directories: include_directories('.', '..'),
            dependencies       : deps_e,
-           c_args             : compositor_c_args + ['-DE_LOGGING=1'],
+           c_args             : compositor_c_args + compositor_bin_c_args + ['-DE_LOGGING=1'],
            override_options   : ['c_std=gnu99'],
            link_args          : compositor_link_args + ['-rdynamic'],
            install_dir        : dir_bin,
diff --git a/src/compositor/modules/wl_drm/e_mod_main.c b/src/compositor/modules/wl_drm/e_mod_main.c
index 8f9f31c..1f93c51 100644
--- a/src/compositor/modules/wl_drm/e_mod_main.c
+++ b/src/compositor/modules/wl_drm/e_mod_main.c
@@ -951,8 +951,6 @@ e_modapi_init(E_Module *m)
 
    if (!software)
      {
-        /* Redraw the output without relying on retained EGL buffer contents. */
-        setenv("EVAS_GL_SWAP_MODE", "full", 0);
         e_comp->ee = ecore_evas_new("gl_drm", 0, 0, 1, 1, NULL);
         if (!e_comp->ee)
           WRN("Could not create a GL DRM canvas. Trying software DRM.");
diff --git a/src/greeter/entrance_greeter_main.c b/src/greeter/entrance_greeter_main.c
index 25453c1..357d58f 100644
--- a/src/greeter/entrance_greeter_main.c
+++ b/src/greeter/entrance_greeter_main.c
@@ -22,6 +22,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <syslog.h>
 #include <unistd.h>
 
 static void
@@ -106,7 +107,7 @@ _register_theme_fonts(const char *preview_theme)
 }
 
 static Eina_Bool
-_configure_engine(Eina_Bool preview)
+_configure_engine(Eina_Bool preview, Eina_Bool *try_gl)
 {
    const char *session_type, *display;
    Eina_Bool wayland, x11_display, try_dmabuf = EINA_FALSE;
@@ -126,10 +127,15 @@ _configure_engine(Eina_Bool preview)
 #ifdef ENTRANCE_HAVE_ECORE_WL2
              try_dmabuf = !getenv("EVAS_WAYLAND_SHM_DISABLE_DMABUF");
 #endif
+             /* An explicit DMA-BUF request selects the software engine. */
+             *try_gl = !preview && (!dmabuf || strcmp(dmabuf, "1"));
           }
         /* Evas's AVX2 color blend crashed while drawing a translucent menu. */
         setenv("EINA_CPU_DISABLE", "avx2", 0);
-        setenv("ELM_ENGINE", "wayland_shm", 0);
+        setenv("ELM_ENGINE", *try_gl ? "wayland_egl" : "wayland_shm", 0);
+        const char *full_redraw = getenv("ENTRANCE_WAYLAND_FULL_REDRAW");
+        if (full_redraw && !strcmp(full_redraw, "1"))
+          setenv("EVAS_GL_SWAP_MODE", "full", 0);
         /* Let timer-driven canvas damage render while Wayland is idle. */
         setenv("ECORE_EVAS_RENDER_NOSYNC", "1", 0);
      }
@@ -635,6 +641,17 @@ _retry_wayland_shm(char **argv)
    return 1;
 }
 
+static int
+_retry_wayland_software(char **argv)
+{
+   fputs("Entrance greeter could not render with Wayland OpenGL. Retrying with SHM.\n", stderr);
+   if (setenv("ELM_ENGINE", "wayland_shm", 1) == 0 &&
+       setenv("EVAS_WAYLAND_SHM_DISABLE_DMABUF", "1", 1) == 0)
+     execvp(argv[0], argv);
+   perror("Could not restart the Entrance greeter");
+   return 1;
+}
+
 int
 main(int argc, char **argv)
 {
@@ -642,6 +659,7 @@ main(int argc, char **argv)
    char *theme, *socket, *scale, *language, *keyboard_layout = NULL;
    int result, idle_steps = ENTRANCE_IDLE_DEFAULT_STEPS;
    Eina_Bool help, version, preview, animations, try_dmabuf, retry_shm = EINA_FALSE;
+   Eina_Bool try_gl = EINA_FALSE, retry_software = EINA_FALSE;
    Ecore_Getopt_Value values[12];
 
    help = EINA_FALSE;
@@ -681,10 +699,13 @@ main(int argc, char **argv)
      }
 
    setlocale(LC_ALL, "");
-   try_dmabuf = _configure_engine(preview);
+   try_dmabuf = _configure_engine(preview, &try_gl);
    _register_theme_fonts(preview ? theme : NULL);
    if (elm_init(1, argv) <= 0)
-      return try_dmabuf ? _retry_wayland_shm(argv) : 1;
+     {
+        if (try_gl) return _retry_wayland_software(argv);
+        return try_dmabuf ? _retry_wayland_shm(argv) : 1;
+     }
 
    entrance_greeter_i18n_init(preview);
    if (!entrance_greeter_language_set(language ? language : ""))
@@ -697,8 +718,11 @@ main(int argc, char **argv)
         Ecore_Evas *canvas = ecore_evas_ecore_evas_get(evas_object_evas_get(window));
         const char *engine = canvas ? ecore_evas_engine_name_get(canvas) : NULL;
 
+        const char *full_redraw = getenv("ENTRANCE_WAYLAND_FULL_REDRAW");
+
         if (engine) fprintf(stderr, "Entrance greeter engine: %s\n", engine);
-        if (!preview && engine && !strncmp(engine, "wayland_", sizeof("wayland_") - 1))
+        if (!preview && engine && !strncmp(engine, "wayland_", sizeof("wayland_") - 1) &&
+            (full_redraw ? !strcmp(full_redraw, "1") : !strcmp(engine, "wayland_shm")))
            evas_event_callback_add(evas_object_evas_get(window), EVAS_CALLBACK_RENDER_PRE,
                                    _wayland_frame_damage, NULL);
         elm_win_autodel_set(window, EINA_FALSE);
@@ -708,7 +732,8 @@ main(int argc, char **argv)
         Wayland_Startup startup = {0};
         Ecore_Wl2_Frame_Cb_Handle *frame = NULL;
 
-        if (try_dmabuf && engine && !strcmp(engine, "wayland_shm"))
+        if (engine && ((try_gl && !strcmp(engine, "wayland_egl")) ||
+                       (try_dmabuf && !strcmp(engine, "wayland_shm"))))
           {
              Ecore_Wl2_Window *wl_window = ecore_evas_wayland2_window_get(canvas);
 
@@ -729,18 +754,38 @@ main(int argc, char **argv)
 #ifdef ENTRANCE_HAVE_ECORE_WL2
         if (startup.timer) ecore_timer_del(startup.timer);
         if (frame) ecore_wl2_window_frame_callback_del(frame);
-        retry_shm = startup.retry ||
-          (startup.display && wl_display_get_error(startup.display) == EPROTO);
+        Eina_Bool protocol_error = startup.display &&
+          wl_display_get_error(startup.display) == EPROTO;
+        if (startup.retry || protocol_error)
+          {
+             openlog("entrance-greeter", LOG_PID, LOG_DAEMON);
+             if (protocol_error)
+               {
+                  const struct wl_interface *interface = NULL;
+                  uint32_t object_id = 0;
+                  uint32_t code = wl_display_get_protocol_error(startup.display,
+                                                               &interface, &object_id);
+                  syslog(LOG_WARNING, "Wayland engine=%s protocol error interface=%s object=%u code=%u",
+                         engine, interface ? interface->name : "unknown", object_id, code);
+               }
+             else
+               syslog(LOG_WARNING, "Wayland engine=%s first frame timed out after 10 seconds", engine);
+             closelog();
+             retry_software = try_gl;
+             retry_shm = try_dmabuf;
+          }
 #endif
      }
    else
      {
         fputs("Could not create the Elementary greeter window.\n", stderr);
+        retry_software = try_gl;
         retry_shm = try_dmabuf;
      }
 
    elm_shutdown();
    entrance_greeter_i18n_shutdown();
 
+   if (retry_software) return _retry_wayland_software(argv);
    return retry_shm ? _retry_wayland_shm(argv) : result;
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to