From 2325eb727a61308e6b0da7eb77afc39440dbeb46 Mon Sep 17 00:00:00 2001 From: Joonbum Ko Date: Fri, 27 Jan 2023 20:08:05 +0900 Subject: [PATCH] Add new API checks if fence sync is available /** * Check the surface can support fence sync mechanism. * * It is recommended that checking fence sync is available * for every frame because the results may change depending on * frontbuffer rendering is activated or not. * * @param surface surface to check fence sync is available. * @return TPL_TRUE if tpl_surface can support it. */ tpl_bool_t tpl_surface_fence_sync_is_available(tpl_surface_t *surface); - This API helps DDK to determine whether to deliver the acquire_fence to signal the render complete when call the surface_enqueue. - In backend where waiting fence is not implemented, the result of fixed to TPL_FALSE will be returned. - The result from the backend with the waiting fence implementation depends on whether the frontbuffer rendering is activated. Change-Id: I779718fdc7e8efc7890e17b0d4df4d81974a7907 Signed-off-by: Joonbum Ko --- src/tpl.h | 13 +++++++++++++ src/tpl_internal.h | 1 + src/tpl_surface.c | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/src/tpl.h b/src/tpl.h index 7250315..aea3770 100644 --- a/src/tpl.h +++ b/src/tpl.h @@ -842,6 +842,19 @@ tpl_surface_cancel_dequeued_buffer(tpl_surface_t *surface, tbm_surface_h tbm_surface); /** + * Check the surface can support fence sync mechanism. + * + * It is recommended that checking fence sync is available + * for every frame because the results may change depending on + * frontbuffer rendering is activated or not. + * + * @param surface surface to check fence sync is available. + * @return TPL_TRUE if tpl_surface can support it. + */ +tpl_bool_t +tpl_surface_fence_sync_is_available(tpl_surface_t *surface); + +/** * Present mode types. * * @TPL_DISPLAY_MODE_IMMEDIATE_KHR: The presentation engine does not wait for diff --git a/src/tpl_internal.h b/src/tpl_internal.h index 0fa3988..3f31a45 100755 --- a/src/tpl_internal.h +++ b/src/tpl_internal.h @@ -113,6 +113,7 @@ struct _tpl_surface_backend { tpl_result_t (*set_post_interval)(tpl_surface_t *surface, int post_interval); void (*get_size)(tpl_surface_t *surface, int *width, int *height); + tpl_bool_t (*fence_sync_is_available)(tpl_surface_t *surface); }; struct _tpl_object { diff --git a/src/tpl_surface.c b/src/tpl_surface.c index e05009e..9bed148 100755 --- a/src/tpl_surface.c +++ b/src/tpl_surface.c @@ -572,3 +572,22 @@ tpl_surface_set_rotation_capability(tpl_surface_t *surface, tpl_bool_t set) return ret; } + +tpl_bool_t +tpl_surface_fence_sync_is_available(tpl_surface_t *surface) +{ + tpl_bool_t ret = TPL_FALSE; + + if (!surface || (surface->type != TPL_SURFACE_TYPE_WINDOW)) { + TPL_ERR("Invalid surface!"); + return ret; + } + + TPL_OBJECT_LOCK(surface); + if (surface->backend.fence_sync_is_available) + ret = surface->backend.fence_sync_is_available(surface); + + TPL_OBJECT_UNLOCK(surface); + + return ret; +} -- 2.7.4