--- /dev/null
+From 372b9c4edd42b67827b75863b978091ba5cff5cd Mon Sep 17 00:00:00 2001
+From: Marius Vlad <marius.vlad@collabora.com>
+Date: Thu, 17 Oct 2024 17:25:41 +0300
+Subject: [PATCH 1/2] backend/wayland_egl: Add a fallback eglConfig
+
+This seems to aid flutter-auto at displaying an image on agl-rdp
+with software rendering, and on agl-kvm with virgl. Makes uses of a fallback
+eGLConfig (< 24 bit) and tries to use that one rather than the default one (24-bit).
+
+Bug-AGL: SPEC-5260
+Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
+---
+ cmake/config_common.h.in | 17 ++++++++++++++++-
+ shell/backend/wayland_egl/egl.cc | 23 ++++++++++++++++++++---
+ 2 files changed, 36 insertions(+), 4 deletions(-)
+
+diff --git a/cmake/config_common.h.in b/cmake/config_common.h.in
+index 07ce9b7..2c54c67 100644
+--- a/cmake/config_common.h.in
++++ b/cmake/config_common.h.in
+@@ -155,6 +155,21 @@ static constexpr std::array<EGLint, 27> kEglConfigAttribs = {{
+ // clang-format on
+ }};
+
++
++static constexpr std::array<EGLint, 27> kEglConfigAttribsFallBack = {{
++ // clang-format off
++ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
++ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
++
++ EGL_RED_SIZE, 1,
++ EGL_GREEN_SIZE, 1,
++ EGL_BLUE_SIZE, 1,
++ EGL_ALPHA_SIZE, 2,
++ EGL_NONE // termination sentinel
++ // clang-format on
++}};
++
++
+ // All vkCreate* functions take an optional allocator. For now, we select the
+ // default allocator by passing in a null pointer, and we highlight the argument
+ // by using the VKALLOC constant.
+@@ -181,4 +196,4 @@ constexpr struct VkAllocationCallbacks* VKALLOC = nullptr;
+ #cmakedefine01 ENV32BIT
+ #cmakedefine01 ENV64BIT
+
+-#endif //CONFIG_COMMON_H_
+\ No newline at end of file
++#endif //CONFIG_COMMON_H_
+diff --git a/shell/backend/wayland_egl/egl.cc b/shell/backend/wayland_egl/egl.cc
+index 99555d6..70164ba 100644
+--- a/shell/backend/wayland_egl/egl.cc
++++ b/shell/backend/wayland_egl/egl.cc
+@@ -62,11 +62,28 @@ Egl::Egl(void* native_display, int buffer_size, bool debug)
+ break;
+ }
+ }
+- free(configs);
+ if (m_config == nullptr) {
+- spdlog::critical("did not find config with buffer size {}", m_buffer_size);
+- assert(false);
++ // try with the fallback one
++ spdlog::critical("Could not use default EGLConfig trying with fallback.");
++ ret = eglChooseConfig(m_dpy, kEglConfigAttribsFallBack.data(), configs,
++ count, &n);
++ assert(ret && n >= 1);
++
++ for (EGLint i = 0; i < n; i++) {
++ eglGetConfigAttrib(m_dpy, configs[i], EGL_BUFFER_SIZE, &size);
++ SPDLOG_DEBUG("Buffer size for config {} is {}", i, size);
++ if (m_buffer_size <= size) {
++ memcpy(&m_config, &configs[i], sizeof(EGLConfig));
++ break;
++ }
++ }
++ if (m_config == nullptr) {
++ spdlog::critical("did not find config with buffer size {}",
++ m_buffer_size);
++ assert(false);
++ }
+ }
++ free(configs);
+
+ m_context = eglCreateContext(m_dpy, m_config, EGL_NO_CONTEXT,
+ kEglContextAttribs.data());
+--
+2.43.0
+