From 1d73256f136834ca771c842ade484bdf283379ed Mon Sep 17 00:00:00 2001 From: muracodex Date: Sat, 13 Jun 2026 15:58:42 -0600 Subject: [PATCH] fix(graphics): add EGL_BAD_MATCH fallback without modifier When capturing from displays that report format modifiers incompatible with the GPU's EGL implementation (e.g. USB/DisplayLink monitors), eglCreateImage() fails with EGL_BAD_MATCH (0x3009). This change retries the DMA-BUF import without the format modifier when the initial attempt fails with EGL_BAD_MATCH, falling back to a linear/modifier-less import that is universally supported. Fixes the 'Couldn't import RGB Image: 00003009' error that causes streaming to show only static/interference on affected displays. --- src/platform/linux/graphics.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/platform/linux/graphics.cpp b/src/platform/linux/graphics.cpp index 6cc2eb3bc3e..1963d766ba9 100644 --- a/src/platform/linux/graphics.cpp +++ b/src/platform/linux/graphics.cpp @@ -594,7 +594,7 @@ namespace egl { } std::optional import_source(display_t::pointer egl_display, const surface_descriptor_t &xrgb) { - auto attribs = surface_descriptor_to_egl_attribs(xrgb); + const auto attribs = surface_descriptor_to_egl_attribs(xrgb); rgb_t rgb { egl_display, @@ -603,9 +603,29 @@ namespace egl { }; if (!rgb->xrgb8) { - BOOST_LOG(error) << "Couldn't import RGB Image: "sv << util::hex(eglGetError()).to_string_view(); + auto err = eglGetError(); + + // Fallback: retry without modifier if GPU rejects the display's format modifier + // Some displays (e.g. USB/DisplayLink) report modifiers the GPU cannot handle + if (err == EGL_BAD_MATCH && xrgb.modifier != DRM_FORMAT_MOD_INVALID) { + surface_descriptor_t xrgb_linear = xrgb; + xrgb_linear.modifier = DRM_FORMAT_MOD_INVALID; + auto attribs_linear = surface_descriptor_to_egl_attribs(xrgb_linear); + + rgb = { + egl_display, + eglCreateImage(egl_display, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, nullptr, attribs_linear.data()), + gl::tex_t::make(1) + }; - return std::nullopt; + if (!rgb->xrgb8) { + BOOST_LOG(error) << "Couldn't import RGB Image: "sv << util::hex(err).to_string_view(); + return std::nullopt; + } + } else { + BOOST_LOG(error) << "Couldn't import RGB Image: "sv << util::hex(err).to_string_view(); + return std::nullopt; + } } gl::ctx.BindTexture(GL_TEXTURE_2D, rgb->tex[0]);