From b3ae038c32870a4a1bb42b6e1cf2ebedc8b7bc8d Mon Sep 17 00:00:00 2001 From: Alex Goins Date: Mon, 5 Oct 2020 18:19:52 -0500 Subject: [PATCH] glamor: Update pixmap's devKind when making it exportable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When making a pixmap exportable, glamor will currently create a temporary exported pixmap backed by a GBM bo, with the devKind updated to the stride of the bo. However, when the backing of the exported pixmap is swapped into the original, the devKind of the original is not updated. Some GBM bos may get implicitly padded, in which case the devKind of the pixmap will not match the stride of the backing bo. For example, an 800x600 pixmap will have a devKind of 3200, but the bo's stride will be 3328. This can cause corruption with PRIME, when the sink uses the wrong stride to display the shared pixmap. This commit changes glamor_make_pixmap_exportable() to update the devKind of the original pixmap after it swaps exported pixmap's backing into it, keeping everything consistent. Fixes issue #1018. Signed-off-by: Alex Goins Signed-off-by: Aaron Plattner Reviewed-by: Michel Dänzer (cherry picked from commit 7a7e55c5c1d6461a9f4d9a4e0129c1c6e1fd3d66) --- glamor/glamor_egl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c index ce8cbfaf4..4120c2e7d 100644 --- a/glamor/glamor_egl.c +++ b/glamor/glamor_egl.c @@ -350,6 +350,9 @@ glamor_make_pixmap_exportable(PixmapPtr pixmap, Bool modifiers_ok) */ glamor_egl_exchange_buffers(pixmap, exported); + /* Swap the devKind into the original pixmap, reflecting the bo's stride */ + screen->ModifyPixmapHeader(pixmap, 0, 0, 0, 0, exported->devKind, NULL); + screen->DestroyPixmap(exported); return TRUE;