mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-02-14 01:30:07 +00:00
xrt: Return xrt_system when creating system
This commit is contained in:
parent
5d64b1d447
commit
7806993e1f
src/xrt
include/xrt
ipc
state_trackers
targets
|
@ -22,6 +22,7 @@ extern "C" {
|
|||
struct xrt_prober;
|
||||
struct xrt_device;
|
||||
struct xrt_space_overseer;
|
||||
struct xrt_system;
|
||||
struct xrt_system_devices;
|
||||
struct xrt_system_compositor;
|
||||
|
||||
|
@ -81,12 +82,14 @@ struct xrt_instance
|
|||
* @note Code consuming this interface should use xrt_instance_create_system()
|
||||
*
|
||||
* @param xinst Pointer to self
|
||||
* @param[out] out_xsys Return of system, required.
|
||||
* @param[out] out_xsysd Return of devices, required.
|
||||
* @param[out] out_xsysc Return of system compositor, optional.
|
||||
*
|
||||
* @see xrt_prober::probe, xrt_prober::select, xrt_gfx_provider_create_native
|
||||
*/
|
||||
xrt_result_t (*create_system)(struct xrt_instance *xinst,
|
||||
struct xrt_system **out_xsys,
|
||||
struct xrt_system_devices **out_xsysd,
|
||||
struct xrt_space_overseer **out_xso,
|
||||
struct xrt_system_compositor **out_xsysc);
|
||||
|
@ -139,11 +142,12 @@ struct xrt_instance
|
|||
*/
|
||||
static inline xrt_result_t
|
||||
xrt_instance_create_system(struct xrt_instance *xinst,
|
||||
struct xrt_system **out_xsys,
|
||||
struct xrt_system_devices **out_xsysd,
|
||||
struct xrt_space_overseer **out_xso,
|
||||
struct xrt_system_compositor **out_xsysc)
|
||||
{
|
||||
return xinst->create_system(xinst, out_xsysd, out_xso, out_xsysc);
|
||||
return xinst->create_system(xinst, out_xsys, out_xsysd, out_xso, out_xsysc);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -130,6 +130,7 @@ err_xina:
|
|||
|
||||
static xrt_result_t
|
||||
ipc_client_instance_create_system(struct xrt_instance *xinst,
|
||||
struct xrt_system **out_xsys,
|
||||
struct xrt_system_devices **out_xsysd,
|
||||
struct xrt_space_overseer **out_xso,
|
||||
struct xrt_system_compositor **out_xsysc)
|
||||
|
@ -137,12 +138,17 @@ ipc_client_instance_create_system(struct xrt_instance *xinst,
|
|||
struct ipc_client_instance *ii = ipc_client_instance(xinst);
|
||||
xrt_result_t xret = XRT_SUCCESS;
|
||||
|
||||
assert(out_xsys != NULL);
|
||||
assert(*out_xsys == NULL);
|
||||
assert(out_xsysd != NULL);
|
||||
assert(*out_xsysd == NULL);
|
||||
assert(out_xsysc == NULL || *out_xsysc == NULL);
|
||||
|
||||
struct xrt_system_devices *xsysd = NULL;
|
||||
struct xrt_system_compositor *xsysc = NULL;
|
||||
|
||||
// Allocate a helper xrt_system_devices struct.
|
||||
struct xrt_system_devices *xsysd = ipc_client_system_devices_create(&ii->ipc_c);
|
||||
xsysd = ipc_client_system_devices_create(&ii->ipc_c);
|
||||
|
||||
// Take the devices from this instance.
|
||||
for (uint32_t i = 0; i < ii->xdev_count; i++) {
|
||||
|
@ -167,29 +173,36 @@ ipc_client_instance_create_system(struct xrt_instance *xinst,
|
|||
|
||||
// Done here now.
|
||||
if (out_xsysc == NULL) {
|
||||
*out_xsysd = xsysd;
|
||||
*out_xso = ipc_client_space_overseer_create(&ii->ipc_c);
|
||||
return XRT_SUCCESS;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (xsysd->static_roles.head == NULL) {
|
||||
IPC_ERROR((&ii->ipc_c), "No head device found but asking for system compositor!");
|
||||
xrt_system_devices_destroy(&xsysd);
|
||||
return XRT_ERROR_IPC_FAILURE;
|
||||
xret = XRT_ERROR_IPC_FAILURE;
|
||||
goto err_destroy;
|
||||
}
|
||||
|
||||
struct xrt_system_compositor *xsysc = NULL;
|
||||
xret = create_system_compositor(ii, xsysd->static_roles.head, &xsysc);
|
||||
if (xret != XRT_SUCCESS) {
|
||||
xrt_system_devices_destroy(&xsysd);
|
||||
return xret;
|
||||
goto err_destroy;
|
||||
}
|
||||
|
||||
out:
|
||||
*out_xsys = ipc_client_system_create(&ii->ipc_c, xsysc);
|
||||
*out_xsysd = xsysd;
|
||||
*out_xso = ipc_client_space_overseer_create(&ii->ipc_c);
|
||||
*out_xsysc = xsysc;
|
||||
|
||||
if (xsysc != NULL) {
|
||||
assert(out_xsysc != NULL);
|
||||
*out_xsysc = xsysc;
|
||||
}
|
||||
|
||||
return XRT_SUCCESS;
|
||||
|
||||
err_destroy:
|
||||
xrt_system_devices_destroy(&xsysd);
|
||||
|
||||
return xret;
|
||||
}
|
||||
|
||||
static xrt_result_t
|
||||
|
|
|
@ -320,6 +320,9 @@ struct ipc_server
|
|||
|
||||
struct u_debug_gui *debug_gui;
|
||||
|
||||
//! The @ref xrt_iface level system.
|
||||
struct xrt_system *xsys;
|
||||
|
||||
//! System devices.
|
||||
struct xrt_system_devices *xsysd;
|
||||
|
||||
|
|
|
@ -135,6 +135,7 @@ teardown_all(struct ipc_server *s)
|
|||
|
||||
xrt_space_overseer_destroy(&s->xso);
|
||||
xrt_system_devices_destroy(&s->xsysd);
|
||||
xrt_system_destroy(&s->xsys);
|
||||
|
||||
xrt_instance_destroy(&s->xinst);
|
||||
|
||||
|
@ -484,7 +485,7 @@ init_all(struct ipc_server *s)
|
|||
return -1;
|
||||
}
|
||||
|
||||
xret = xrt_instance_create_system(s->xinst, &s->xsysd, &s->xso, &s->xsysc);
|
||||
xret = xrt_instance_create_system(s->xinst, &s->xsys, &s->xsysd, &s->xso, &s->xsysc);
|
||||
if (xret != XRT_SUCCESS) {
|
||||
IPC_ERROR(s, "Could not create system!");
|
||||
teardown_all(s);
|
||||
|
|
|
@ -46,6 +46,7 @@ struct gui_program
|
|||
|
||||
struct gui_scene_manager *gsm;
|
||||
|
||||
struct xrt_system *xsys;
|
||||
struct xrt_system_devices *xsysd;
|
||||
struct xrt_space_overseer *xso;
|
||||
struct xrt_instance *instance;
|
||||
|
|
|
@ -72,7 +72,7 @@ gui_prober_select(struct gui_program *p)
|
|||
{
|
||||
XRT_TRACE_MARKER();
|
||||
|
||||
xrt_result_t xret = xrt_instance_create_system(p->instance, &p->xsysd, &p->xso, NULL);
|
||||
xrt_result_t xret = xrt_instance_create_system(p->instance, &p->xsys, &p->xsysd, &p->xso, NULL);
|
||||
if (xret != XRT_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -104,6 +104,7 @@ gui_prober_teardown(struct gui_program *p)
|
|||
|
||||
xrt_space_overseer_destroy(&p->xso);
|
||||
xrt_system_devices_destroy(&p->xsysd);
|
||||
xrt_system_destroy(&p->xsys);
|
||||
|
||||
xrt_instance_destroy(&p->instance);
|
||||
}
|
||||
|
|
|
@ -316,9 +316,9 @@ oxr_instance_create(struct oxr_logger *log,
|
|||
|
||||
// Create the system.
|
||||
if (should_create_compositor) {
|
||||
xret = xrt_instance_create_system(inst->xinst, &sys->xsysd, &sys->xso, &sys->xsysc);
|
||||
xret = xrt_instance_create_system(inst->xinst, &sys->xsys, &sys->xsysd, &sys->xso, &sys->xsysc);
|
||||
} else {
|
||||
xret = xrt_instance_create_system(inst->xinst, &sys->xsysd, &sys->xso, NULL);
|
||||
xret = xrt_instance_create_system(inst->xinst, &sys->xsys, &sys->xsysd, &sys->xso, NULL);
|
||||
}
|
||||
|
||||
if (xret != XRT_SUCCESS) {
|
||||
|
|
|
@ -1273,6 +1273,9 @@ struct oxr_system
|
|||
{
|
||||
struct oxr_instance *inst;
|
||||
|
||||
//! The @ref xrt_iface level system.
|
||||
struct xrt_system *xsys;
|
||||
|
||||
//! System devices used in all session types.
|
||||
struct xrt_system_devices *xsysd;
|
||||
|
||||
|
|
|
@ -1440,6 +1440,7 @@ public:
|
|||
|
||||
private:
|
||||
struct xrt_instance *m_xinst = NULL;
|
||||
struct xrt_system *m_xsys = NULL;
|
||||
struct xrt_system_devices *m_xsysd = NULL;
|
||||
struct xrt_space_overseer *m_xso = NULL;
|
||||
struct xrt_device *m_xhmd = NULL;
|
||||
|
@ -1471,7 +1472,7 @@ CServerDriver_Monado::Init(vr::IVRDriverContext *pDriverContext)
|
|||
return vr::VRInitError_Init_HmdNotFound;
|
||||
}
|
||||
|
||||
xret = xrt_instance_create_system(m_xinst, &m_xsysd, &m_xso, NULL);
|
||||
xret = xrt_instance_create_system(m_xinst, &m_xsys, &m_xsysd, &m_xso, NULL);
|
||||
if (xret < 0) {
|
||||
ovrd_log("Failed to create system devices\n");
|
||||
xrt_instance_destroy(&m_xinst);
|
||||
|
@ -1481,6 +1482,7 @@ CServerDriver_Monado::Init(vr::IVRDriverContext *pDriverContext)
|
|||
ovrd_log("Didn't get a HMD device!\n");
|
||||
xrt_space_overseer_destroy(&m_xso);
|
||||
xrt_system_devices_destroy(&m_xsysd);
|
||||
xrt_system_destroy(&m_xsys);
|
||||
xrt_instance_destroy(&m_xinst);
|
||||
return vr::VRInitError_Init_HmdNotFound;
|
||||
}
|
||||
|
@ -1530,6 +1532,7 @@ CServerDriver_Monado::Cleanup()
|
|||
|
||||
xrt_space_overseer_destroy(&m_xso);
|
||||
xrt_system_devices_destroy(&m_xsysd);
|
||||
xrt_system_destroy(&m_xsys);
|
||||
m_xhmd = NULL;
|
||||
m_left->m_xdev = NULL;
|
||||
m_right->m_xdev = NULL;
|
||||
|
|
|
@ -48,10 +48,12 @@ cli_cmd_probe(int argc, const char **argv)
|
|||
// Need to prime the prober with devices before dumping and listing.
|
||||
printf(" :: Creating system devices!\n");
|
||||
|
||||
struct xrt_system *xsys = NULL;
|
||||
struct xrt_system_devices *xsysd = NULL;
|
||||
struct xrt_space_overseer *xso = NULL;
|
||||
xret = xrt_instance_create_system( //
|
||||
xi, // Instance
|
||||
&xsys, // System
|
||||
&xsysd, // System devices.
|
||||
&xso, // Space overseer.
|
||||
NULL); // System compositor.
|
||||
|
@ -119,6 +121,7 @@ cli_cmd_probe(int argc, const char **argv)
|
|||
|
||||
xrt_space_overseer_destroy(&xso);
|
||||
xrt_system_devices_destroy(&xsysd);
|
||||
xrt_system_destroy(&xsys);
|
||||
|
||||
// End of program
|
||||
printf(" :: All ok, shutting down.\n");
|
||||
|
|
|
@ -75,10 +75,12 @@ cli_cmd_test(int argc, const char **argv)
|
|||
// (multiple) devices.
|
||||
printf(" :: Creating system devices!\n");
|
||||
|
||||
struct xrt_system *xsys = NULL;
|
||||
struct xrt_system_devices *xsysd = NULL;
|
||||
struct xrt_space_overseer *xso = NULL;
|
||||
xret = xrt_instance_create_system( //
|
||||
xi, // Instance
|
||||
&xsys, // System
|
||||
&xsysd, // System devices.
|
||||
&xso, // Space Overseer.
|
||||
NULL); // System compositor.
|
||||
|
@ -141,6 +143,7 @@ cli_cmd_test(int argc, const char **argv)
|
|||
|
||||
xrt_space_overseer_destroy(&xso);
|
||||
xrt_system_devices_destroy(&xsysd);
|
||||
xrt_system_destroy(&xsys);
|
||||
|
||||
// Finally done
|
||||
return do_exit(&xi, 0);
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "os/os_time.h"
|
||||
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_system.h"
|
||||
#include "util/u_trace_marker.h"
|
||||
#include "util/u_system_helpers.h"
|
||||
|
||||
|
@ -46,23 +47,30 @@ null_compositor_create_system(struct xrt_device *xdev, struct xrt_system_composi
|
|||
|
||||
static xrt_result_t
|
||||
t_instance_create_system(struct xrt_instance *xinst,
|
||||
struct xrt_system **out_xsys,
|
||||
struct xrt_system_devices **out_xsysd,
|
||||
struct xrt_space_overseer **out_xso,
|
||||
struct xrt_system_compositor **out_xsysc)
|
||||
{
|
||||
XRT_TRACE_MARKER();
|
||||
|
||||
assert(out_xsys != NULL);
|
||||
assert(*out_xsys == NULL);
|
||||
assert(out_xsysd != NULL);
|
||||
assert(*out_xsysd == NULL);
|
||||
assert(out_xso != NULL);
|
||||
assert(*out_xso == NULL);
|
||||
assert(out_xsysc == NULL || *out_xsysc == NULL);
|
||||
|
||||
struct u_system *usys = NULL;
|
||||
struct xrt_system_compositor *xsysc = NULL;
|
||||
struct xrt_space_overseer *xso = NULL;
|
||||
struct xrt_system_devices *xsysd = NULL;
|
||||
xrt_result_t xret = XRT_SUCCESS;
|
||||
|
||||
usys = u_system_create();
|
||||
assert(usys != NULL); // Should never fail.
|
||||
|
||||
xret = u_system_devices_create_from_prober(xinst, &xsysd, &xso);
|
||||
if (xret != XRT_SUCCESS) {
|
||||
return xret;
|
||||
|
@ -70,8 +78,7 @@ t_instance_create_system(struct xrt_instance *xinst,
|
|||
|
||||
// Early out if we only want devices.
|
||||
if (out_xsysc == NULL) {
|
||||
*out_xsysd = xsysd;
|
||||
return XRT_SUCCESS;
|
||||
goto out;
|
||||
}
|
||||
|
||||
struct xrt_device *head = xsysd->static_roles.head;
|
||||
|
@ -101,14 +108,29 @@ t_instance_create_system(struct xrt_instance *xinst,
|
|||
#endif
|
||||
|
||||
if (xret != XRT_SUCCESS) {
|
||||
xrt_space_overseer_destroy(&xso);
|
||||
xrt_system_devices_destroy(&xsysd);
|
||||
return xret;
|
||||
goto err_destroy;
|
||||
}
|
||||
|
||||
out:
|
||||
*out_xsys = &usys->base;
|
||||
*out_xsysd = xsysd;
|
||||
*out_xso = xso;
|
||||
*out_xsysc = xsysc;
|
||||
|
||||
if (xsysc != NULL) {
|
||||
// Tell the system about the system compositor.
|
||||
u_system_set_system_compositor(usys, xsysc);
|
||||
|
||||
assert(out_xsysc != NULL);
|
||||
*out_xsysc = xsysc;
|
||||
}
|
||||
|
||||
return xret;
|
||||
|
||||
|
||||
err_destroy:
|
||||
xrt_space_overseer_destroy(&xso);
|
||||
xrt_system_devices_destroy(&xsysd);
|
||||
u_system_destroy(&usys);
|
||||
|
||||
return xret;
|
||||
}
|
||||
|
|
|
@ -8,8 +8,11 @@
|
|||
*/
|
||||
|
||||
#include "xrt/xrt_system.h"
|
||||
|
||||
#include "util/u_system.h"
|
||||
#include "util/u_trace_marker.h"
|
||||
#include "util/u_system_helpers.h"
|
||||
|
||||
#include "target_instance_parts.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -17,12 +20,14 @@
|
|||
|
||||
static xrt_result_t
|
||||
t_instance_create_system(struct xrt_instance *xinst,
|
||||
struct xrt_system **out_xsys,
|
||||
struct xrt_system_devices **out_xsysd,
|
||||
struct xrt_space_overseer **out_xso,
|
||||
struct xrt_system_compositor **out_xsysc)
|
||||
{
|
||||
XRT_TRACE_MARKER();
|
||||
|
||||
struct u_system *usys = NULL;
|
||||
struct xrt_system_devices *xsysd = NULL;
|
||||
struct xrt_space_overseer *xso = NULL;
|
||||
xrt_result_t xret = XRT_SUCCESS;
|
||||
|
@ -38,11 +43,16 @@ t_instance_create_system(struct xrt_instance *xinst,
|
|||
return XRT_ERROR_ALLOCATION;
|
||||
}
|
||||
|
||||
usys = u_system_create();
|
||||
assert(usys != NULL); // Should never fail.
|
||||
|
||||
xret = u_system_devices_create_from_prober(xinst, &xsysd, &xso);
|
||||
if (xret != XRT_SUCCESS) {
|
||||
u_system_destroy(&usys);
|
||||
return xret;
|
||||
}
|
||||
|
||||
*out_xsys = &usys->base;
|
||||
*out_xsysd = xsysd;
|
||||
*out_xso = xso;
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "xrt/xrt_config_drivers.h"
|
||||
|
||||
#include "util/u_misc.h"
|
||||
#include "util/u_system.h"
|
||||
#include "util/u_builders.h"
|
||||
#include "util/u_trace_marker.h"
|
||||
|
||||
|
@ -66,18 +67,26 @@ sdl_instance_get_prober(struct xrt_instance *xinst, struct xrt_prober **out_xp)
|
|||
|
||||
static xrt_result_t
|
||||
sdl_instance_create_system(struct xrt_instance *xinst,
|
||||
struct xrt_system **out_xsys,
|
||||
struct xrt_system_devices **out_xsysd,
|
||||
struct xrt_space_overseer **out_xso,
|
||||
struct xrt_system_compositor **out_xsysc)
|
||||
{
|
||||
assert(out_xsys != NULL);
|
||||
assert(*out_xsys == NULL);
|
||||
assert(out_xsysd != NULL);
|
||||
assert(*out_xsysd == NULL);
|
||||
assert(out_xso != NULL);
|
||||
assert(*out_xso == NULL);
|
||||
assert(out_xsysc == NULL || *out_xsysc == NULL);
|
||||
|
||||
// Use system helper.
|
||||
struct u_system *usys = u_system_create();
|
||||
assert(usys != NULL); // Should never fail.
|
||||
|
||||
struct sdl_program *sp = from_xinst(xinst);
|
||||
|
||||
*out_xsys = &usys->base;
|
||||
*out_xsysd = &sp->xsysd_base;
|
||||
*out_xso = sp->xso;
|
||||
|
||||
|
@ -86,7 +95,13 @@ sdl_instance_create_system(struct xrt_instance *xinst,
|
|||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
sdl_compositor_create_system(sp, out_xsysc);
|
||||
struct xrt_system_compositor *xsysc = NULL;
|
||||
sdl_compositor_create_system(sp, &xsysc);
|
||||
|
||||
// Tell the system about the system compositor.
|
||||
u_system_set_system_compositor(usys, xsysc);
|
||||
|
||||
*out_xsysc = xsysc;
|
||||
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue