1 From 372b9c4edd42b67827b75863b978091ba5cff5cd Mon Sep 17 00:00:00 2001
2 From: Marius Vlad <marius.vlad@collabora.com>
3 Date: Thu, 17 Oct 2024 17:25:41 +0300
4 Subject: [PATCH 1/2] backend/wayland_egl: Add a fallback eglConfig
6 This seems to aid flutter-auto at displaying an image on agl-rdp
7 with software rendering, and on agl-kvm with virgl. Makes uses of a fallback
8 eGLConfig (< 24 bit) and tries to use that one rather than the default one (24-bit).
11 Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
13 cmake/config_common.h.in | 17 ++++++++++++++++-
14 shell/backend/wayland_egl/egl.cc | 23 ++++++++++++++++++++---
15 2 files changed, 36 insertions(+), 4 deletions(-)
17 diff --git a/cmake/config_common.h.in b/cmake/config_common.h.in
18 index 07ce9b7..2c54c67 100644
19 --- a/cmake/config_common.h.in
20 +++ b/cmake/config_common.h.in
21 @@ -155,6 +155,21 @@ static constexpr std::array<EGLint, 27> kEglConfigAttribs = {{
26 +static constexpr std::array<EGLint, 27> kEglConfigAttribsFallBack = {{
28 + EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
29 + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
35 + EGL_NONE // termination sentinel
40 // All vkCreate* functions take an optional allocator. For now, we select the
41 // default allocator by passing in a null pointer, and we highlight the argument
42 // by using the VKALLOC constant.
43 @@ -181,4 +196,4 @@ constexpr struct VkAllocationCallbacks* VKALLOC = nullptr;
44 #cmakedefine01 ENV32BIT
45 #cmakedefine01 ENV64BIT
47 -#endif //CONFIG_COMMON_H_
48 \ No newline at end of file
49 +#endif //CONFIG_COMMON_H_
50 diff --git a/shell/backend/wayland_egl/egl.cc b/shell/backend/wayland_egl/egl.cc
51 index 99555d6..70164ba 100644
52 --- a/shell/backend/wayland_egl/egl.cc
53 +++ b/shell/backend/wayland_egl/egl.cc
54 @@ -62,11 +62,28 @@ Egl::Egl(void* native_display, int buffer_size, bool debug)
59 if (m_config == nullptr) {
60 - spdlog::critical("did not find config with buffer size {}", m_buffer_size);
62 + // try with the fallback one
63 + spdlog::critical("Could not use default EGLConfig trying with fallback.");
64 + ret = eglChooseConfig(m_dpy, kEglConfigAttribsFallBack.data(), configs,
66 + assert(ret && n >= 1);
68 + for (EGLint i = 0; i < n; i++) {
69 + eglGetConfigAttrib(m_dpy, configs[i], EGL_BUFFER_SIZE, &size);
70 + SPDLOG_DEBUG("Buffer size for config {} is {}", i, size);
71 + if (m_buffer_size <= size) {
72 + memcpy(&m_config, &configs[i], sizeof(EGLConfig));
76 + if (m_config == nullptr) {
77 + spdlog::critical("did not find config with buffer size {}",
84 m_context = eglCreateContext(m_dpy, m_config, EGL_NO_CONTEXT,
85 kEglContextAttribs.data());