xrt: Remove prepare function from xrt_compositor

This commit is contained in:
Jakob Bornecrantz 2021-01-20 13:06:40 +00:00
parent 2b8c835b68
commit afea93f297
10 changed files with 45 additions and 95 deletions

View file

@ -1,3 +1,4 @@
xrt: Introduce `xrt_system_compositor`, it is basically a analogous to
`XrSystemID` but instead of being a fully fledged xrt_system this is only the
compositor part of it.
compositor part of it. Also fold the `prepare_session` function into the create
native compositor function to simplify the interface.

View file

@ -81,16 +81,6 @@ client_gl_swapchain_release_image(struct xrt_swapchain *xsc, uint32_t index)
*
*/
static xrt_result_t
client_gl_compositor_prepare_session(struct xrt_compositor *xc, const struct xrt_session_prepare_info *xspi)
{
struct client_gl_compositor *c = client_gl_compositor(xc);
// Pipe down call into native compositor.
return xrt_comp_prepare_session(&c->xcn->base, xspi);
}
static xrt_result_t
client_gl_compositor_begin_session(struct xrt_compositor *xc, enum xrt_view_type type)
{
@ -447,7 +437,6 @@ client_gl_compositor_init(struct client_gl_compositor *c,
client_gl_insert_fence_func insert_fence)
{
c->base.base.create_swapchain = client_gl_swapchain_create;
c->base.base.prepare_session = client_gl_compositor_prepare_session;
c->base.base.begin_session = client_gl_compositor_begin_session;
c->base.base.end_session = client_gl_compositor_end_session;
c->base.base.wait_frame = client_gl_compositor_wait_frame;

View file

@ -162,15 +162,6 @@ client_vk_compositor_destroy(struct xrt_compositor *xc)
free(c);
}
static xrt_result_t
client_vk_compositor_prepare_session(struct xrt_compositor *xc, const struct xrt_session_prepare_info *xspi)
{
struct client_vk_compositor *c = client_vk_compositor(xc);
// Pipe down call into native compositor.
return xrt_comp_prepare_session(&c->xcn->base, xspi);
}
static xrt_result_t
client_vk_compositor_begin_session(struct xrt_compositor *xc, enum xrt_view_type type)
{
@ -520,7 +511,6 @@ client_vk_compositor_create(struct xrt_compositor_native *xcn,
struct client_vk_compositor *c = U_TYPED_CALLOC(struct client_vk_compositor);
c->base.base.create_swapchain = client_vk_swapchain_create;
c->base.base.prepare_session = client_vk_compositor_prepare_session;
c->base.base.begin_session = client_vk_compositor_begin_session;
c->base.base.end_session = client_vk_compositor_end_session;
c->base.base.wait_frame = client_vk_compositor_wait_frame;

View file

@ -95,17 +95,6 @@ ts_ms()
*
*/
static xrt_result_t
compositor_prepare_session(struct xrt_compositor *xc, const struct xrt_session_prepare_info *xspi)
{
struct comp_compositor *c = comp_compositor(xc);
COMP_DEBUG(c, "PREPARE_SESSION");
c->state = COMP_STATE_PREPARED;
return XRT_SUCCESS;
}
static xrt_result_t
compositor_begin_session(struct xrt_compositor *xc, enum xrt_view_type type)
{
@ -578,7 +567,9 @@ compositor_destroy(struct xrt_compositor *xc)
*/
static xrt_result_t
system_compositor_create_native_compositor(struct xrt_system_compositor *xsc, struct xrt_compositor_native **out_xcn)
system_compositor_create_native_compositor(struct xrt_system_compositor *xsc,
const struct xrt_session_info *xsi,
struct xrt_compositor_native **out_xcn)
{
struct comp_compositor *c = container_of(xsc, struct comp_compositor, system);
@ -589,6 +580,7 @@ system_compositor_create_native_compositor(struct xrt_system_compositor *xsc, st
}
c->compositor_created = true;
c->state = COMP_STATE_PREPARED;
*out_xcn = &c->base;
return XRT_SUCCESS;
@ -1348,7 +1340,6 @@ xrt_gfx_provider_create_system(struct xrt_device *xdev, struct xrt_system_compos
c->base.base.create_swapchain = comp_swapchain_create;
c->base.base.import_swapchain = comp_swapchain_import;
c->base.base.prepare_session = compositor_prepare_session;
c->base.base.begin_session = compositor_begin_session;
c->base.base.end_session = compositor_end_session;
c->base.base.wait_frame = compositor_wait_frame;

View file

@ -513,9 +513,9 @@ struct xrt_swapchain_create_info
};
/*!
* Session prepare information, mostly overlay extension data.
* Session information, mostly overlay extension data.
*/
struct xrt_session_prepare_info
struct xrt_session_info
{
bool is_overlay;
uint64_t flags;
@ -574,11 +574,6 @@ struct xrt_compositor
*/
xrt_result_t (*poll_events)(struct xrt_compositor *xc, union xrt_compositor_event *out_xce);
/*!
* This function is implicit in the OpenXR spec but made explicit here.
*/
xrt_result_t (*prepare_session)(struct xrt_compositor *xc, const struct xrt_session_prepare_info *xspi);
/*!
* See xrBeginSession.
*/
@ -791,19 +786,6 @@ xrt_comp_poll_events(struct xrt_compositor *xc, union xrt_compositor_event *out_
return xc->poll_events(xc, out_xce);
}
/*!
* @copydoc xrt_compositor::prepare_session
*
* Helper for calling through the function pointer.
*
* @public @memberof xrt_compositor
*/
static inline xrt_result_t
xrt_comp_prepare_session(struct xrt_compositor *xc, const struct xrt_session_prepare_info *xspi)
{
return xc->prepare_session(xc, xspi);
}
/*!
* @copydoc xrt_compositor::begin_session
*
@ -1325,6 +1307,7 @@ struct xrt_system_compositor
* if this is the case.
*/
xrt_result_t (*create_native_compositor)(struct xrt_system_compositor *xsc,
const struct xrt_session_info *xsi,
struct xrt_compositor_native **out_xcn);
/*!
@ -1343,9 +1326,11 @@ struct xrt_system_compositor
* @public @memberof xrt_system_compositor
*/
static inline xrt_result_t
xrt_syscomp_create_native_compositor(struct xrt_system_compositor *xsc, struct xrt_compositor_native **out_xcn)
xrt_syscomp_create_native_compositor(struct xrt_system_compositor *xsc,
const struct xrt_session_info *xsi,
struct xrt_compositor_native **out_xcn)
{
return xsc->create_native_compositor(xsc, out_xcn);
return xsc->create_native_compositor(xsc, xsi, out_xcn);
}
/*!

View file

@ -346,17 +346,6 @@ ipc_compositor_swapchain_import(struct xrt_compositor *xc,
return swapchain_server_import(icc, info, native_images, num_images, out_xsc);
}
static xrt_result_t
ipc_compositor_prepare_session(struct xrt_compositor *xc, const struct xrt_session_prepare_info *xspi)
{
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
IPC_TRACE(icc->ipc_c, "IPC: compositor create session");
IPC_CALL_CHK(ipc_call_session_create(icc->ipc_c, xspi));
return res;
}
static xrt_result_t
ipc_compositor_poll_events(struct xrt_compositor *xc, union xrt_compositor_event *out_xce)
{
@ -783,7 +772,9 @@ ipc_compositor_images_destroy(struct xrt_image_native_allocator *xina)
*/
xrt_result_t
ipc_syscomp_create_native_compositor(struct xrt_system_compositor *xsc, struct xrt_compositor_native **out_xcn)
ipc_syscomp_create_native_compositor(struct xrt_system_compositor *xsc,
const struct xrt_session_info *xsi,
struct xrt_compositor_native **out_xcn)
{
struct ipc_client_compositor *icc = container_of(xsc, struct ipc_client_compositor, system);
@ -794,6 +785,8 @@ ipc_syscomp_create_native_compositor(struct xrt_system_compositor *xsc, struct x
icc->compositor_created = true;
*out_xcn = &icc->base;
IPC_CALL_CHK(ipc_call_session_create(icc->ipc_c, xsi));
return XRT_SUCCESS;
}
@ -828,7 +821,6 @@ ipc_client_create_system_compositor(struct ipc_connection *ipc_c,
c->base.base.create_swapchain = ipc_compositor_swapchain_create;
c->base.base.import_swapchain = ipc_compositor_swapchain_import;
c->base.base.prepare_session = ipc_compositor_prepare_session;
c->base.base.begin_session = ipc_compositor_begin_session;
c->base.base.end_session = ipc_compositor_end_session;
c->base.base.wait_frame = ipc_compositor_wait_frame;

View file

@ -90,15 +90,15 @@ ipc_handle_system_compositor_get_info(volatile struct ipc_client_state *ics,
}
xrt_result_t
ipc_handle_session_create(volatile struct ipc_client_state *ics, const struct xrt_session_prepare_info *xspi)
ipc_handle_session_create(volatile struct ipc_client_state *ics, const struct xrt_session_info *xsi)
{
ics->client_state.session_active = false;
ics->client_state.session_overlay = false;
ics->client_state.session_visible = false;
if (xspi->is_overlay) {
if (xsi->is_overlay) {
ics->client_state.session_overlay = true;
ics->client_state.z_order = xspi->z_order;
ics->client_state.z_order = xsi->z_order;
}
update_server_state(ics->server);

View file

@ -554,7 +554,12 @@ init_all(struct ipc_server *s)
return ret;
}
ret = xrt_syscomp_create_native_compositor(s->xsysc, &s->xcn);
struct xrt_session_info xsi = {
.is_overlay = false,
.flags = 0,
.z_order = 0,
};
ret = xrt_syscomp_create_native_compositor(s->xsysc, &xsi, &s->xcn);
if (ret < 0) {
teardown_all(s);
return ret;

View file

@ -58,7 +58,7 @@
"session_create": {
"in": [
{"name": "overlay_info", "type": "const struct xrt_session_prepare_info"}
{"name": "overlay_info", "type": "const struct xrt_session_info"}
]
},

View file

@ -1942,9 +1942,9 @@ oxr_session_destroy(struct oxr_logger *log, struct oxr_handle_base *hb)
}
#define OXR_ALLOCATE_NATIVE_COMPOSITOR(LOG, SESS) \
#define OXR_ALLOCATE_NATIVE_COMPOSITOR(LOG, XSI, SESS) \
do { \
xrt_result_t xret = xrt_syscomp_create_native_compositor((SESS)->sys->xsysc, &(SESS)->xcn); \
xrt_result_t xret = xrt_syscomp_create_native_compositor((SESS)->sys->xsysc, (XSI), &(SESS)->xcn); \
if (xret == XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED) { \
return oxr_error((LOG), XR_ERROR_LIMIT_REACHED, "Per instance multi-session not supported."); \
} else if (xret != XRT_SUCCESS) { \
@ -1967,6 +1967,7 @@ static XrResult
oxr_session_create_impl(struct oxr_logger *log,
struct oxr_system *sys,
const XrSessionCreateInfo *createInfo,
const struct xrt_session_info *xsi,
struct oxr_session **out_session)
{
#if defined(XR_USE_PLATFORM_XLIB) && defined(XR_USE_GRAPHICS_API_OPENGL)
@ -1980,7 +1981,7 @@ oxr_session_create_impl(struct oxr_logger *log,
}
OXR_SESSION_ALLOCATE(log, sys, *out_session);
OXR_ALLOCATE_NATIVE_COMPOSITOR(log, *out_session);
OXR_ALLOCATE_NATIVE_COMPOSITOR(log, xsi, *out_session);
return oxr_session_populate_gl_xlib(log, sys, opengl_xlib, *out_session);
}
#endif
@ -1997,7 +1998,7 @@ oxr_session_create_impl(struct oxr_logger *log,
}
OXR_SESSION_ALLOCATE(log, sys, *out_session);
OXR_ALLOCATE_NATIVE_COMPOSITOR(log, *out_session);
OXR_ALLOCATE_NATIVE_COMPOSITOR(log, xsi, *out_session);
return oxr_session_populate_gles_android(log, sys, opengles_android, *out_session);
}
#endif
@ -2013,7 +2014,7 @@ oxr_session_create_impl(struct oxr_logger *log,
}
OXR_SESSION_ALLOCATE(log, sys, *out_session);
OXR_ALLOCATE_NATIVE_COMPOSITOR(log, *out_session);
OXR_ALLOCATE_NATIVE_COMPOSITOR(log, xsi, *out_session);
return oxr_session_populate_vk(log, sys, vulkan, *out_session);
}
#endif
@ -2029,7 +2030,7 @@ oxr_session_create_impl(struct oxr_logger *log,
}
OXR_SESSION_ALLOCATE(log, sys, *out_session);
OXR_ALLOCATE_NATIVE_COMPOSITOR(log, *out_session);
OXR_ALLOCATE_NATIVE_COMPOSITOR(log, xsi, *out_session);
return oxr_session_populate_egl(log, sys, egl, *out_session);
}
#endif
@ -2061,8 +2062,17 @@ oxr_session_create(struct oxr_logger *log,
{
struct oxr_session *sess = NULL;
struct xrt_session_info xsi = {0};
const XrSessionCreateInfoOverlayEXTX *overlay_info = OXR_GET_INPUT_FROM_CHAIN(
createInfo, XR_TYPE_SESSION_CREATE_INFO_OVERLAY_EXTX, XrSessionCreateInfoOverlayEXTX);
if (overlay_info) {
xsi.is_overlay = true;
xsi.flags = overlay_info->createFlags;
xsi.z_order = overlay_info->sessionLayersPlacement;
}
/* Try allocating and populating. */
XrResult ret = oxr_session_create_impl(log, sys, createInfo, &sess);
XrResult ret = oxr_session_create_impl(log, sys, createInfo, &xsi, &sess);
if (ret != XR_SUCCESS) {
if (sess != NULL) {
/* clean up allocation first */
@ -2079,19 +2089,6 @@ oxr_session_create(struct oxr_logger *log,
sess->active_wait_frames = 0;
os_mutex_init(&sess->active_wait_frames_lock);
struct xrt_compositor *xc = sess->compositor;
if (xc != NULL) {
struct xrt_session_prepare_info xspi = {0};
const XrSessionCreateInfoOverlayEXTX *overlay_info = OXR_GET_INPUT_FROM_CHAIN(
createInfo, XR_TYPE_SESSION_CREATE_INFO_OVERLAY_EXTX, XrSessionCreateInfoOverlayEXTX);
if (overlay_info) {
xspi.is_overlay = true;
xspi.flags = overlay_info->createFlags;
xspi.z_order = overlay_info->sessionLayersPlacement;
}
xrt_comp_prepare_session(xc, &xspi);
}
sess->ipd_meters = debug_get_num_option_ipd() / 1000.0f;
sess->frame_timing_spew = debug_get_bool_option_frame_timing_spew();