| From de6dfab2d936cbce13fb4711125b4fb38989ca12 Mon Sep 17 00:00:00 2001 |
| From: David Riley <davidriley@chromium.org> |
| Date: Mon, 11 May 2020 17:16:56 -0700 |
| Subject: [PATCH] xwayland: Fall back to gbm_bo_create if no modifiers are |
| available. |
| |
| As of Mesa commit 4e3a7dcf6ee4946c46ae8b35e7883a49859ef6fb |
| (gallium: enable EGL_EXT_image_dma_buf_import_modifiers unconditionally) |
| Xwayland uses the gbm_bo_create_with_modifiers even if there are no |
| modifiers available. Fall back to the old case where usage flags |
| are provided if modifiers are not available. |
| |
| Without this change a suboptimal buffer might be allocated which |
| could result in extra copies of buffers for scanout. |
| |
| Signed-off-by: David Riley <davidriley@chromium.org> |
| --- |
| hw/xwayland/xwayland-glamor-gbm.c | 12 +++++++----- |
| 1 file changed, 7 insertions(+), 5 deletions(-) |
| |
| diff --git a/hw/xwayland/xwayland-glamor-gbm.c b/hw/xwayland/xwayland-glamor-gbm.c |
| index 80655fd16..17bfa7236 100644 |
| --- a/hw/xwayland/xwayland-glamor-gbm.c |
| +++ b/hw/xwayland/xwayland-glamor-gbm.c |
| @@ -216,7 +216,7 @@ xwl_glamor_gbm_create_pixmap(ScreenPtr screen, |
| { |
| struct xwl_screen *xwl_screen = xwl_screen_get(screen); |
| struct xwl_gbm_private *xwl_gbm = xwl_gbm_get(xwl_screen); |
| - struct gbm_bo *bo; |
| + struct gbm_bo *bo = NULL; |
| PixmapPtr pixmap = NULL; |
| |
| if (width > 0 && height > 0 && depth >= 15 && |
| @@ -231,13 +231,15 @@ xwl_glamor_gbm_create_pixmap(ScreenPtr screen, |
| uint64_t *modifiers = NULL; |
| |
| glamor_get_modifiers(screen, format, &num_modifiers, &modifiers); |
| - bo = gbm_bo_create_with_modifiers(xwl_gbm->gbm, width, height, |
| - format, modifiers, num_modifiers); |
| + if (num_modifiers) { |
| + bo = gbm_bo_create_with_modifiers(xwl_gbm->gbm, width, height, |
| + format, modifiers, |
| + num_modifiers); |
| + } |
| free(modifiers); |
| } |
| - else |
| #endif |
| - { |
| + if (!bo) { |
| bo = gbm_bo_create(xwl_gbm->gbm, width, height, format, |
| GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); |
| } |
| -- |
| 2.26.2.645.ge9eca65c58-goog |
| |