[PATCH weston v2 2/4] gl-renderer: Add support for fence sync extensions
Alexandros Frantzis
alexandros.frantzis at collabora.com
Tue Sep 19 11:59:09 UTC 2017
Check for the EGL_KHR_fence_sync and EGL_ANDROID_native_fence_sync
extensions and get pointers to required extension functions.
These extensions allow us to acquire GPU timestamp information
asynchronously, and are required by the upcoming work to add
rendering begin/end timepoints to the weston timeline.
Signed-off-by: Alexandros Frantzis <alexandros.frantzis at collabora.com>
---
Changes in v2:
- Added Signed-off-by.
- Clarified purpose of commit in commit message.
- Added fallback EGL definitions.
libweston/gl-renderer.c | 16 ++++++++++++++++
shared/weston-egl-ext.h | 16 ++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c
index 5768f05a..c2e88a65 100644
--- a/libweston/gl-renderer.c
+++ b/libweston/gl-renderer.c
@@ -231,6 +231,11 @@ struct gl_renderer {
int has_dmabuf_import_modifiers;
PFNEGLQUERYDMABUFFORMATSEXTPROC query_dmabuf_formats;
PFNEGLQUERYDMABUFMODIFIERSEXTPROC query_dmabuf_modifiers;
+
+ int has_native_fence_sync;
+ PFNEGLCREATESYNCKHRPROC create_sync;
+ PFNEGLDESTROYSYNCKHRPROC destroy_sync;
+ PFNEGLDUPNATIVEFENCEFDANDROIDPROC dup_native_fence_fd;
};
static PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL;
@@ -3028,6 +3033,17 @@ gl_renderer_setup_egl_extensions(struct weston_compositor *ec)
if (weston_check_egl_extension(extensions, "GL_EXT_texture_rg"))
gr->has_gl_texture_rg = 1;
+ if (weston_check_egl_extension(extensions, "EGL_KHR_fence_sync") &&
+ weston_check_egl_extension(extensions, "EGL_ANDROID_native_fence_sync")) {
+ gr->create_sync =
+ (void *) eglGetProcAddress("eglCreateSyncKHR");
+ gr->destroy_sync =
+ (void *) eglGetProcAddress("eglDestroySyncKHR");
+ gr->dup_native_fence_fd =
+ (void *) eglGetProcAddress("eglDupNativeFenceFDANDROID");
+ gr->has_native_fence_sync = 1;
+ }
+
renderer_setup_egl_client_extensions(gr);
return 0;
diff --git a/shared/weston-egl-ext.h b/shared/weston-egl-ext.h
index ffea438b..8aacbd01 100644
--- a/shared/weston-egl-ext.h
+++ b/shared/weston-egl-ext.h
@@ -176,6 +176,22 @@ typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) (EGLD
#define EGL_PLATFORM_X11_KHR 0x31D5
#endif
+#ifndef EGL_KHR_cl_event2
+#define EGL_KHR_cl_event2 1
+typedef void *EGLSyncKHR;
+#endif /* EGL_KHR_cl_event2 */
+
+#ifndef EGL_KHR_fence_sync
+#define EGL_KHR_fence_sync 1
+typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync);
+#endif /* EGL_KHR_fence_sync */
+
+#ifndef EGL_ANDROID_native_fence_sync
+#define EGL_ANDROID_native_fence_sync 1
+typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy, EGLSyncKHR sync);
+#endif /* EGL_ANDROID_native_fence_sync */
+
#else /* ENABLE_EGL */
/* EGL platform definition are keept to allow compositor-xx.c to build */
--
2.14.1
More information about the wayland-devel
mailing list