[PATCH xf86-video-ati 1/7] dri3: Flush if necessary in dri3_fd_from_pixmap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Michel Dänzer <michel.daenzer@xxxxxxx>

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)

Signed-off-by: Michel Dänzer <michel.daenzer@xxxxxxx>
---
 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 25078bae1..73353bf51 100644
--- a/src/radeon_dri3.c
+++ b/src/radeon_dri3.c
@@ -37,6 +37,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <gbm.h>
 #include <errno.h>
 #include <libgen.h>
 
@@ -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);
-- 
2.20.1

_______________________________________________
amd-gfx mailing list
amd-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/amd-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux