From cd37974c042fc658ceb067324de12cbcdb48d7dc Mon Sep 17 00:00:00 2001 From: Christoph Haag Date: Thu, 16 Feb 2023 01:03:45 +0100 Subject: [PATCH] xrt: Add swapchain_[dec|inc]_image_count functions --- src/xrt/include/xrt/xrt_compositor.h | 40 +++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/xrt/include/xrt/xrt_compositor.h b/src/xrt/include/xrt/xrt_compositor.h index 1a8b7fdb4..f4c14eed0 100644 --- a/src/xrt/include/xrt/xrt_compositor.h +++ b/src/xrt/include/xrt/xrt_compositor.h @@ -411,7 +411,7 @@ struct xrt_swapchain uint32_t image_count; /*! - * Must have called release_image before calling this function. + * @ref dec_image_use must have been called as often as @ref inc_image_use. */ void (*destroy)(struct xrt_swapchain *xsc); @@ -431,6 +431,18 @@ struct xrt_swapchain */ xrt_result_t (*acquire_image)(struct xrt_swapchain *xsc, uint32_t *out_index); + /*! + * @brief Increments the use counter of a swapchain image. + */ + xrt_result_t (*inc_image_use)(struct xrt_swapchain *xsc, uint32_t index); + + /*! + * @brief Decrements the use counter of a swapchain image. + * + * @ref wait_image will return once the image use counter is 0. + */ + xrt_result_t (*dec_image_use)(struct xrt_swapchain *xsc, uint32_t index); + /*! * Wait until image @p index is available for exclusive use, or until @p timeout_ns expires. * @@ -504,6 +516,32 @@ xrt_swapchain_acquire_image(struct xrt_swapchain *xsc, uint32_t *out_index) return xsc->acquire_image(xsc, out_index); } +/*! + * @copydoc xrt_swapchain::inc_image_use + * + * Helper for calling through the function pointer. + * + * @public @memberof xrt_swapchain + */ +static inline xrt_result_t +xrt_swapchain_inc_image_use(struct xrt_swapchain *xsc, uint32_t index) +{ + return xsc->inc_image_use(xsc, index); +} + +/*! + * @copydoc xrt_swapchain::dec_image_use + * + * Helper for calling through the function pointer. + * + * @public @memberof xrt_swapchain + */ +static inline xrt_result_t +xrt_swapchain_dec_image_use(struct xrt_swapchain *xsc, uint32_t index) +{ + return xsc->dec_image_use(xsc, index); +} + /*! * @copydoc xrt_swapchain::wait_image *