mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-02-05 13:28:16 +00:00
xrt: Add compositor semaphore interface
This commit is contained in:
parent
37354b953c
commit
851224123e
|
@ -535,6 +535,81 @@ xrt_compositor_fence_destroy(struct xrt_compositor_fence **xcf_ptr)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Compositor semaphore.
|
||||
*
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Compositor semaphore used for synchronization, needs to be as capable as a
|
||||
* Vulkan pipeline semaphore.
|
||||
*/
|
||||
struct xrt_compositor_semaphore
|
||||
{
|
||||
/*!
|
||||
* Reference helper.
|
||||
*/
|
||||
struct xrt_reference reference;
|
||||
|
||||
/*!
|
||||
* Does a CPU side wait on the semaphore to reach the given value.
|
||||
*/
|
||||
xrt_result_t (*wait)(struct xrt_compositor_semaphore *xcsem, uint64_t value, uint64_t timeout_ns);
|
||||
|
||||
/*!
|
||||
* Destroys the semaphore.
|
||||
*/
|
||||
void (*destroy)(struct xrt_compositor_semaphore *xcsem);
|
||||
};
|
||||
|
||||
/*!
|
||||
* Update the reference counts on compositor semaphore(s).
|
||||
*
|
||||
* @param[in,out] dst Pointer to a object reference: if the object reference is
|
||||
* non-null will decrement its counter. The reference that
|
||||
* @p dst points to will be set to @p src.
|
||||
* @param[in] src New object for @p dst to refer to (may be null).
|
||||
* If non-null, will have its refcount increased.
|
||||
* @ingroup xrt_iface
|
||||
* @relates xrt_compositor_semaphore
|
||||
*/
|
||||
static inline void
|
||||
xrt_compositor_semaphore_reference(struct xrt_compositor_semaphore **dst, struct xrt_compositor_semaphore *src)
|
||||
{
|
||||
struct xrt_compositor_semaphore *old_dst = *dst;
|
||||
|
||||
if (old_dst == src) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (src) {
|
||||
xrt_reference_inc(&src->reference);
|
||||
}
|
||||
|
||||
*dst = src;
|
||||
|
||||
if (old_dst) {
|
||||
if (xrt_reference_dec(&old_dst->reference)) {
|
||||
old_dst->destroy(old_dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @copydoc xrt_compositor_semaphore::wait
|
||||
*
|
||||
* Helper for calling through the function pointer.
|
||||
*
|
||||
* @public @memberof xrt_compositor_semaphore
|
||||
*/
|
||||
static inline xrt_result_t
|
||||
xrt_compositor_semaphore_wait(struct xrt_compositor_semaphore *xcsem, uint64_t value, uint64_t timeout)
|
||||
{
|
||||
return xcsem->wait(xcsem, value, timeout);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Events.
|
||||
|
@ -677,6 +752,13 @@ struct xrt_compositor
|
|||
xrt_graphics_sync_handle_t handle,
|
||||
struct xrt_compositor_fence **out_xcf);
|
||||
|
||||
/*!
|
||||
* Create a compositor semaphore, also returns a native handle.
|
||||
*/
|
||||
xrt_result_t (*create_semaphore)(struct xrt_compositor *xc,
|
||||
xrt_graphics_sync_handle_t *out_handle,
|
||||
struct xrt_compositor_semaphore **out_xcsem);
|
||||
|
||||
/*!
|
||||
* Poll events from this compositor.
|
||||
*
|
||||
|
@ -943,6 +1025,21 @@ struct xrt_compositor
|
|||
int64_t frame_id,
|
||||
xrt_graphics_sync_handle_t sync_handle);
|
||||
|
||||
/*!
|
||||
* @brief Commits all of the submitted layers, with a semaphore.
|
||||
*
|
||||
* Only after this call will the compositor actually use the layers.
|
||||
* @param xc Self pointer
|
||||
* @param frame_id The frame id this commit is for.
|
||||
* @param xcsem Semaphore that will be signalled when the app GPU
|
||||
* work has completed.
|
||||
* @param value Semaphore value upone completion of GPU work.
|
||||
*/
|
||||
xrt_result_t (*layer_commit_with_semaphore)(struct xrt_compositor *xc,
|
||||
int64_t frame_id,
|
||||
struct xrt_compositor_semaphore *xcsem,
|
||||
uint64_t value);
|
||||
|
||||
/*!
|
||||
* Teardown the compositor.
|
||||
*
|
||||
|
@ -1002,6 +1099,21 @@ xrt_comp_import_fence(struct xrt_compositor *xc,
|
|||
return xc->import_fence(xc, handle, out_xcf);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @copydoc xrt_compositor::create_semaphore
|
||||
*
|
||||
* Helper for calling through the function pointer.
|
||||
*
|
||||
* @public @memberof xrt_compositor
|
||||
*/
|
||||
static inline xrt_result_t
|
||||
xrt_comp_create_semaphore(struct xrt_compositor *xc,
|
||||
xrt_graphics_sync_handle_t *out_handle,
|
||||
struct xrt_compositor_semaphore **out_xcsem)
|
||||
{
|
||||
return xc->create_semaphore(xc, out_handle, out_xcsem);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @copydoc xrt_compositor::poll_events
|
||||
*
|
||||
|
@ -1269,6 +1381,22 @@ xrt_comp_layer_commit(struct xrt_compositor *xc, int64_t frame_id, xrt_graphics_
|
|||
return xc->layer_commit(xc, frame_id, sync_handle);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @copydoc xrt_compositor::layer_commit_with_semaphore
|
||||
*
|
||||
* Helper for calling through the function pointer.
|
||||
*
|
||||
* @public @memberof xrt_compositor
|
||||
*/
|
||||
static inline xrt_result_t
|
||||
xrt_comp_layer_commit_with_semaphore(struct xrt_compositor *xc,
|
||||
int64_t frame_id,
|
||||
struct xrt_compositor_semaphore *xcsem,
|
||||
uint64_t value)
|
||||
{
|
||||
return xc->layer_commit_with_semaphore(xc, frame_id, xcsem, value);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @copydoc xrt_compositor::destroy
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue