95ce627
From f758908db4e71406e5d437d32e43aabd38a63504 Mon Sep 17 00:00:00 2001
95ce627
From: =?UTF-8?q?Michel=20D=C3=A4nzer?= <michel.daenzer@amd.com>
95ce627
Date: Thu, 9 May 2019 12:35:37 +0200
95ce627
Subject: [PATCH xf86-video-ati] dri3: Always flush glamor before sharing
95ce627
 pixmap storage with clients
95ce627
95ce627
Even if glamor_gbm_bo_from_pixmap / glamor_fd_from_pixmap themselves
95ce627
don't trigger any drawing, there could already be unflushed drawing to
95ce627
the pixmap whose storage we share with a client.
95ce627
95ce627
(Ported from amdgpu commit 4b17533fcb30842caf0035ba593b7d986520cc85)
95ce627
Acked-by: Alex Deucher <alexander.deucher@amd.com>
95ce627
---
95ce627
 src/radeon_dri3.c | 26 +++++---------------------
95ce627
 1 file changed, 5 insertions(+), 21 deletions(-)
95ce627
95ce627
diff --git a/src/radeon_dri3.c b/src/radeon_dri3.c
95ce627
index 73353bf5..f8f91c4b 100644
95ce627
--- a/src/radeon_dri3.c
95ce627
+++ b/src/radeon_dri3.c
95ce627
@@ -220,29 +220,13 @@ static int radeon_dri3_fd_from_pixmap(ScreenPtr screen,
95ce627
 	RADEONInfoPtr info = RADEONPTR(scrn);
95ce627
 
95ce627
 	if (info->use_glamor) {
95ce627
-		Bool need_flush = TRUE;
95ce627
-		int ret = -1;
95ce627
-#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,19,99,904,0)
95ce627
-		struct gbm_bo *gbm_bo = glamor_gbm_bo_from_pixmap(screen, pixmap);
95ce627
+		int ret = glamor_fd_from_pixmap(screen, pixmap, stride, size);
95ce627
 
95ce627
-		if (gbm_bo) {
95ce627
-			ret = gbm_bo_get_fd(gbm_bo);
95ce627
-			gbm_bo_destroy(gbm_bo);
95ce627
-
95ce627
-			if (ret >= 0)
95ce627
-				need_flush = FALSE;
95ce627
-		}
95ce627
-#endif
95ce627
-
95ce627
-		if (ret < 0)
95ce627
-			ret = glamor_fd_from_pixmap(screen, pixmap, stride, size);
95ce627
-
95ce627
-		/* glamor might have needed to reallocate the pixmap storage and
95ce627
-		 * copy the pixmap contents to the new storage. The copy
95ce627
-		 * operation needs to be flushed to the kernel driver before the
95ce627
-		 * client starts using the pixmap storage for direct rendering.
95ce627
+		/* Any pending drawing operations need to be flushed to the
95ce627
+		 * kernel driver before the client starts using the pixmap
95ce627
+		 * storage for direct rendering.
95ce627
 		 */
95ce627
-		if (ret >= 0 && need_flush)
95ce627
+		if (ret >= 0)
95ce627
 			radeon_cs_flush_indirect(scrn);
95ce627
 
95ce627
 		return ret;
95ce627
-- 
95ce627
2.21.0
95ce627