From 73e56fd076aae7bf1d80d8de93d1fb48df4fb8f9 Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Wed, 16 Jul 2025 00:24:40 +0300 Subject: [PATCH] glamor: handle if GBM_BO_USE_SCANOUT is not supported Backport from Xwayland: https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/433 https://gitlab.freedesktop.org/xorg/xserver/-/commit/111d318fc2262c03c289be172696264622e50156 See also: https://forums.developer.nvidia.com/t/gbm-surface-create-fails-if-flags-0/279951 https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3304#note_1983279 https://gitlab.freedesktop.org/xorg/xserver/-/issues/1535 Signed-off-by: stefan11111 --- glamor/glamor_egl.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c index 6b6b78d04..5a8bbb9e8 100644 --- a/glamor/glamor_egl.c +++ b/glamor/glamor_egl.c @@ -393,9 +393,23 @@ glamor_make_pixmap_exportable(PixmapPtr pixmap, Bool modifiers_ok) if (num_modifiers > 0) { #ifdef GBM_BO_WITH_MODIFIERS2 + /* TODO: Is scanout ever used? If so, where? */ bo = gbm_bo_create_with_modifiers2(glamor_egl->gbm, width, height, format, modifiers, num_modifiers, GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT); + if (!bo) { + /* something failed, try again without GBM_BO_USE_SCANOUT */ + /* maybe scanout does work, but modifiers aren't supported */ + /* we handle this case on the fallback path */ + bo = gbm_bo_create_with_modifiers2(glamor_egl->gbm, width, height, + format, modifiers, num_modifiers, + GBM_BO_USE_RENDERING); +#if 0 + if (bo) { + /* TODO: scanout failed, but regular buffer succeeded, maybe log something? */ + } +#endif + } #else bo = gbm_bo_create_with_modifiers(glamor_egl->gbm, width, height, format, modifiers, num_modifiers); @@ -409,12 +423,27 @@ glamor_make_pixmap_exportable(PixmapPtr pixmap, Bool modifiers_ok) if (!bo) { + /* TODO: Is scanout ever used? If so, where? */ bo = gbm_bo_create(glamor_egl->gbm, width, height, format, #ifdef GLAMOR_HAS_GBM_LINEAR (pixmap->usage_hint == CREATE_PIXMAP_USAGE_SHARED ? GBM_BO_USE_LINEAR : 0) | #endif GBM_BO_USE_RENDERING | GBM_BO_USE_SCANOUT); + if (!bo) { + /* something failed, try again without GBM_BO_USE_SCANOUT */ + bo = gbm_bo_create(glamor_egl->gbm, width, height, format, +#ifdef GLAMOR_HAS_GBM_LINEAR + (pixmap->usage_hint == CREATE_PIXMAP_USAGE_SHARED ? + GBM_BO_USE_LINEAR : 0) | + GBM_BO_USE_RENDERING); +#endif +#if 0 + if (bo) { + /* TODO: scanout failed, but regular buffer succeeded, maybe log something? */ + } +#endif + } } if (!bo) {