summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2019-01-28 18:00:20 +0100
committerMichel Dänzer <michel.daenzer@amd.com>2019-01-28 18:00:20 +0100
commit77d7abf46446522e686c6b6f1e4857458589ef37 (patch)
tree840a72afd0943a860916de7d21b35c691558bb68
parentb1c01698f577577e4a88bad0ae08fb5d998e7ebb (diff)
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)
-rw-r--r--src/radeon_dri3.c31
1 files 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 <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);