From 86b2d8740a330deafe8a9bbf0402705a43efbb42 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 4 Apr 2018 16:16:36 +0100 Subject: [PATCH] glamor: Reallocate pixmap storage without modifiers if necessary If we need a pixmap's storage to be exported to a context in which we aren't aware of modifiers, reallocate the buffer again without modifiers. This makes it possible to run a compositing manager on an old GLX/EGL stack on top of an X server which allocates internal buffer storage using exotic modifiers from modifier-aware GBM/EGL/KMS. Signed-off-by: Daniel Stone Reported-by: Adam Jackson Reviewed-by: Adam Jackson --- glamor/glamor_egl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c index dd6a9a2df..a1e0bc3c9 100644 --- a/glamor/glamor_egl.c +++ b/glamor/glamor_egl.c @@ -250,7 +250,7 @@ glamor_get_name_from_bo(int gbm_fd, struct gbm_bo *bo, int *name) } static Bool -glamor_make_pixmap_exportable(PixmapPtr pixmap) +glamor_make_pixmap_exportable(PixmapPtr pixmap, Bool modifiers_ok) { ScreenPtr screen = pixmap->drawable.pScreen; ScrnInfoPtr scrn = xf86ScreenToScrn(screen); @@ -266,7 +266,8 @@ glamor_make_pixmap_exportable(PixmapPtr pixmap) PixmapPtr exported; GCPtr scratch_gc; - if (pixmap_priv->image) + if (pixmap_priv->image && + (modifiers_ok || !pixmap_priv->used_modifiers)) return TRUE; if (pixmap->drawable.bitsPerPixel != 32) { @@ -282,7 +283,7 @@ glamor_make_pixmap_exportable(PixmapPtr pixmap) format = GBM_FORMAT_ARGB8888; #ifdef GBM_BO_WITH_MODIFIERS - if (glamor_egl->dmabuf_capable) { + if (modifiers_ok && glamor_egl->dmabuf_capable) { uint32_t num_modifiers; uint64_t *modifiers = NULL; @@ -370,7 +371,7 @@ glamor_egl_fds_from_pixmap(ScreenPtr screen, PixmapPtr pixmap, int *fds, int i; #endif - if (!glamor_make_pixmap_exportable(pixmap)) + if (!glamor_make_pixmap_exportable(pixmap, TRUE)) return 0; bo = glamor_gbm_bo_from_pixmap(screen, pixmap); @@ -411,7 +412,7 @@ glamor_egl_fd_name_from_pixmap(ScreenPtr screen, glamor_egl = glamor_egl_get_screen_private(xf86ScreenToScrn(screen)); - if (!glamor_make_pixmap_exportable(pixmap)) + if (!glamor_make_pixmap_exportable(pixmap, FALSE)) goto failure; bo = glamor_gbm_bo_from_pixmap(screen, pixmap);