From f05d29898d4ef28372a701b7f464c1d6e6c70c45 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Mon, 11 Nov 2019 13:32:48 +0900 Subject: [PATCH] wayland-egl-tizen: Added new API to create render sync fd. New API wl_egl_window_tizen_get_render_sync_fd(struct wl_egl_window*) /** * Create a sync fence fd that can tell render done. * * If eglSwapBuffers works async, it returns fd which tells * when the render job is finished. * This fd can wait asynchronously via poll or select. * * Important * * This requires the following premise: * - After ddk calls libplpl-egl's tpl_surface_dequeue_buffer to get the buffer, * and until it calls tpl_surface_enqueue_buffer, * it is called the gpu rendering job interval. * - Therefore, when using the dma_buf implicit fence, * there is no guarantee that the rendering job is finished * with the fence obtained through this API. * * The fence_fd obtained through this function is one-time available, * can not be reused, so caller must close it when finished using it. * * @param egl_window handle to wl_egl_window. * @return sync fd on success, -1 on failure. */ Change-Id: Ia19f88108cfe8d0e5e6477acbd83a2df173f5507 Signed-off-by: Joonbum Ko --- src/wayland-egl-tizen/wayland-egl-tizen-priv.h | 2 ++ src/wayland-egl-tizen/wayland-egl-tizen.c | 24 +++++++++++++++++++++++- src/wayland-egl-tizen/wayland-egl-tizen.h | 26 ++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/wayland-egl-tizen/wayland-egl-tizen-priv.h b/src/wayland-egl-tizen/wayland-egl-tizen-priv.h index 5b65a70..69df3bc 100644 --- a/src/wayland-egl-tizen/wayland-egl-tizen-priv.h +++ b/src/wayland-egl-tizen/wayland-egl-tizen-priv.h @@ -22,6 +22,7 @@ struct tizen_private { int (*get_rotation_capability)(struct wl_egl_window *, void *); void (*set_frontbuffer_callback)(struct wl_egl_window *, void *, int); void (*set_window_serial_callback)(struct wl_egl_window *, void *, unsigned int); + int (*create_render_sync_fd)(struct wl_egl_window *, void *); }; static struct tizen_private* tizen_private_create() @@ -40,6 +41,7 @@ static struct tizen_private* tizen_private_create() private->get_rotation_capability = NULL; private->set_window_serial_callback = NULL; private->set_frontbuffer_callback = NULL; + private->create_render_sync_fd = NULL; } return private; diff --git a/src/wayland-egl-tizen/wayland-egl-tizen.c b/src/wayland-egl-tizen/wayland-egl-tizen.c index 4c127bc..888f8af 100644 --- a/src/wayland-egl-tizen/wayland-egl-tizen.c +++ b/src/wayland-egl-tizen/wayland-egl-tizen.c @@ -250,4 +250,26 @@ wl_egl_window_tizen_set_window_serial(struct wl_egl_window *egl_window, if (private->set_window_serial_callback) private->set_window_serial_callback(egl_window, egl_window->driver_private, serial); -} \ No newline at end of file +} + +int +wl_egl_window_tizen_create_render_sync_fd(struct wl_egl_window *egl_window) +{ + struct tizen_private *private = NULL; + + if (egl_window == NULL) { + WL_EGL_ERR("egl_window is NULL"); + return -1; + } + + private = egl_window->driver_private; + if (private == NULL) { + WL_EGL_ERR("wl_egl_window(%p) dirver_private is NULL", egl_window); + return -1; + } + + if (private->create_render_sync_fd) + return private->create_render_sync_fd(egl_window, egl_window->driver_private); + + return -1; +} diff --git a/src/wayland-egl-tizen/wayland-egl-tizen.h b/src/wayland-egl-tizen/wayland-egl-tizen.h index b305e27..96127a0 100644 --- a/src/wayland-egl-tizen/wayland-egl-tizen.h +++ b/src/wayland-egl-tizen/wayland-egl-tizen.h @@ -73,6 +73,32 @@ void wl_egl_window_tizen_set_window_serial(struct wl_egl_window *egl_window, unsigned int serial); +/* temporary APIs for testing sync feature */ +/** + * Create a sync fence fd that can tell render done. + * + * If eglSwapBuffers works async, it returns fd which tells + * when the render job is finished. + * This fd can wait asynchronously via poll or select. + * + * Important * + * This requires the following premise: + * - After ddk calls libplpl-egl's tpl_surface_dequeue_buffer to get the buffer, + * and until it calls tpl_surface_enqueue_buffer, + * it is called the gpu rendering job interval. + * - Therefore, when using the dma_buf implicit fence, + * there is no guarantee that the rendering job is finished + * with the fence obtained through this API. + * + * The fence_fd obtained through this function is one-time available, + * can not be reused, so caller must close it when finished using it. + * + * @param egl_window handle to wl_egl_window. + * @return sync fd on success, -1 on failure. + */ +int +wl_egl_window_tizen_create_render_sync_fd(struct wl_egl_window *egl_window); + #ifdef __cplusplus } #endif -- 2.7.4