From 77d7abf46446522e686c6b6f1e4857458589ef37 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Mon, 28 Jan 2019 18:00:20 +0100 Subject: dri3: Flush if necessary in dri3_fd_from_pixmap To make sure the client can't use the shared pixmap storage for direct rendering first, which could produce garbage. Bugzilla: https://bugs.freedesktop.org/109235 (Ported from amdgpu commit d168532ee739f7e33a2798051e64ba445dd3859f) --- src/radeon_dri3.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/radeon_dri3.c b/src/radeon_dri3.c index 25078bae..73353bf5 100644 --- a/src/radeon_dri3.c +++ b/src/radeon_dri3.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -218,8 +219,34 @@ static int radeon_dri3_fd_from_pixmap(ScreenPtr screen, ScrnInfoPtr scrn = xf86ScreenToScrn(screen); RADEONInfoPtr info = RADEONPTR(scrn); - if (info->use_glamor) - return glamor_fd_from_pixmap(screen, pixmap, stride, size); + if (info->use_glamor) { + Bool need_flush = TRUE; + int ret = -1; +#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,19,99,904,0) + struct gbm_bo *gbm_bo = glamor_gbm_bo_from_pixmap(screen, pixmap); + + if (gbm_bo) { + ret = gbm_bo_get_fd(gbm_bo); + gbm_bo_destroy(gbm_bo); + + if (ret >= 0) + need_flush = FALSE; + } +#endif + + if (ret < 0) + ret = glamor_fd_from_pixmap(screen, pixmap, stride, size); + + /* glamor might have needed to reallocate the pixmap storage and + * copy the pixmap contents to the new storage. The copy + * operation needs to be flushed to the kernel driver before the + * client starts using the pixmap storage for direct rendering. + */ + if (ret >= 0 && need_flush) + radeon_cs_flush_indirect(scrn); + + return ret; + } #endif bo = radeon_get_pixmap_bo(pixmap); -- cgit v1.2.3