summaryrefslogtreecommitdiff
path: root/hw/xwayland/xwayland-glamor.c
diff options
context:
space:
mode:
authorErik Kurzinger <ekurzinger@nvidia.com>2023-08-15 15:32:47 -0700
committerOlivier Fourdan <fourdan@gmail.com>2024-04-09 06:11:03 +0000
commit87bf2cafcc27e609e4a75d0596682c2619f3f1dc (patch)
tree1ffe24b9bc15c1ca4190f9c718291b461207085d /hw/xwayland/xwayland-glamor.c
parent6f85ce4d4eeaa7070b9c2cf4536d35cd14d22090 (diff)
xwayland: add support for wp_linux_drm_syncobj_v1
This protocol allows for explicit synchronization of GPU operations by Wayland clients and the compositor. Xwayland can make use of this to ensure any rendering it initiates has completed before the target image is accessed by the compositor, without having to rely on kernel-level implicit synchronization. Furthermore, for X11 clients that also support explicit synchronization using the mechanisms exposed in the DRI3 and Present extensions, this Wayland protocol allows us to simply forward the timeline, acquire, and release points directly to the compositor, ideally avoiding any premature stalls in the presentation pipeline. Signed-off-by: Erik Kurzinger <ekurzinger@nvidia.com> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/967>
Diffstat (limited to 'hw/xwayland/xwayland-glamor.c')
-rw-r--r--hw/xwayland/xwayland-glamor.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/hw/xwayland/xwayland-glamor.c b/hw/xwayland/xwayland-glamor.c
index eb15eea2d..f03366437 100644
--- a/hw/xwayland/xwayland-glamor.c
+++ b/hw/xwayland/xwayland-glamor.c
@@ -41,6 +41,7 @@
#include "drm-client-protocol.h"
#include "linux-dmabuf-unstable-v1-client-protocol.h"
+#include "linux-drm-syncobj-v1-client-protocol.h"
#include "xwayland-dmabuf.h"
#include "xwayland-glamor.h"
@@ -111,6 +112,8 @@ xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
xwl_screen_set_drm_interface(xwl_screen, id, version);
else if (strcmp(interface, zwp_linux_dmabuf_v1_interface.name) == 0)
xwl_screen_set_dmabuf_interface(xwl_screen, id, version);
+ else if (strcmp(interface, wp_linux_drm_syncobj_manager_v1_interface.name) == 0)
+ xwl_screen_set_syncobj_interface(xwl_screen, id, version);
}
static Bool
@@ -293,6 +296,27 @@ xwl_glamor_get_fence(struct xwl_screen *xwl_screen)
return fence_fd;
}
+void
+xwl_glamor_wait_fence(struct xwl_screen *xwl_screen, int fence_fd)
+{
+ EGLint attribs[3];
+ EGLSyncKHR sync;
+
+ if (!xwl_screen->glamor)
+ return;
+
+ xwl_glamor_egl_make_current(xwl_screen);
+
+ attribs[0] = EGL_SYNC_NATIVE_FENCE_FD_ANDROID;
+ attribs[1] = fence_fd;
+ attribs[2] = EGL_NONE;
+ sync = eglCreateSyncKHR(xwl_screen->egl_display, EGL_SYNC_NATIVE_FENCE_ANDROID, attribs);
+ if (sync != EGL_NO_SYNC_KHR) {
+ eglWaitSyncKHR(xwl_screen->egl_display, sync, 0);
+ eglDestroySyncKHR(xwl_screen->egl_display, sync);
+ }
+}
+
Bool
xwl_glamor_init(struct xwl_screen *xwl_screen)
{