summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2019-01-09 17:24:11 +0100
committerMichel Dänzer <michel@daenzer.net>2019-01-11 18:04:26 +0100
commitd168532ee739f7e33a2798051e64ba445dd3859f (patch)
treec76f0d165bb4892e49d9aa96f928bb6114327ede /src
parent2058c4c469b172d4a3b0443f75466d84281a64c7 (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 Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'src')
-rw-r--r--src/amdgpu_dri3.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/amdgpu_dri3.c b/src/amdgpu_dri3.c
index 84a03dc..7f1745e 100644
--- a/src/amdgpu_dri3.c
+++ b/src/amdgpu_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>
@@ -219,8 +220,34 @@ static int amdgpu_dri3_fd_from_pixmap(ScreenPtr screen,
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
AMDGPUInfoPtr info = AMDGPUPTR(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)
+ amdgpu_glamor_flush(scrn);
+
+ return ret;
+ }
#endif
bo = amdgpu_get_pixmap_bo(pixmap);