diff --git a/src/xrt/auxiliary/util/u_system_helpers.c b/src/xrt/auxiliary/util/u_system_helpers.c index 413d01f6f..6125b73f9 100644 --- a/src/xrt/auxiliary/util/u_system_helpers.c +++ b/src/xrt/auxiliary/util/u_system_helpers.c @@ -1,4 +1,4 @@ -// Copyright 2022, Collabora, Ltd. +// Copyright 2022-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -54,7 +54,9 @@ u_system_devices_allocate(void) } xrt_result_t -u_system_devices_create_from_prober(struct xrt_instance *xinst, struct xrt_system_devices **out_xsysd) +u_system_devices_create_from_prober(struct xrt_instance *xinst, + struct xrt_system_devices **out_xsysd, + struct xrt_space_overseer **out_xso) { xrt_result_t xret; @@ -77,7 +79,7 @@ u_system_devices_create_from_prober(struct xrt_instance *xinst, struct xrt_syste return xret; } - return xrt_prober_create_system(xp, out_xsysd); + return xrt_prober_create_system(xp, out_xsysd, out_xso); } struct xrt_device * diff --git a/src/xrt/auxiliary/util/u_system_helpers.h b/src/xrt/auxiliary/util/u_system_helpers.h index 9d6872dc5..45b461046 100644 --- a/src/xrt/auxiliary/util/u_system_helpers.h +++ b/src/xrt/auxiliary/util/u_system_helpers.h @@ -1,4 +1,4 @@ -// Copyright 2022, Collabora, Ltd. +// Copyright 2022-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -68,7 +68,9 @@ u_system_devices_allocate(void); * @ingroup aux_util */ xrt_result_t -u_system_devices_create_from_prober(struct xrt_instance *xinst, struct xrt_system_devices **out_xsysd); +u_system_devices_create_from_prober(struct xrt_instance *xinst, + struct xrt_system_devices **out_xsysd, + struct xrt_space_overseer **out_xso); /*! * Helper function. diff --git a/src/xrt/include/xrt/xrt_instance.h b/src/xrt/include/xrt/xrt_instance.h index 0aa2c376b..120f2a6a5 100644 --- a/src/xrt/include/xrt/xrt_instance.h +++ b/src/xrt/include/xrt/xrt_instance.h @@ -1,4 +1,4 @@ -// Copyright 2020-2022, Collabora, Ltd. +// Copyright 2020-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -20,6 +20,7 @@ extern "C" { struct xrt_prober; struct xrt_device; +struct xrt_space_overseer; struct xrt_system_devices; struct xrt_system_compositor; @@ -83,6 +84,7 @@ struct xrt_instance */ xrt_result_t (*create_system)(struct xrt_instance *xinst, struct xrt_system_devices **out_xsysd, + struct xrt_space_overseer **out_xso, struct xrt_system_compositor **out_xsysc); /*! @@ -134,9 +136,10 @@ struct xrt_instance static inline xrt_result_t xrt_instance_create_system(struct xrt_instance *xinst, 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_xsysc); + return xinst->create_system(xinst, out_xsysd, out_xso, out_xsysc); } /*! diff --git a/src/xrt/include/xrt/xrt_prober.h b/src/xrt/include/xrt/xrt_prober.h index 53ca68526..1da848ea7 100644 --- a/src/xrt/include/xrt/xrt_prober.h +++ b/src/xrt/include/xrt/xrt_prober.h @@ -1,4 +1,4 @@ -// Copyright 2019-2022, Collabora, Ltd. +// Copyright 2019-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -35,6 +35,7 @@ struct xrt_auto_prober; struct xrt_tracking_factory; struct xrt_builder; struct xrt_system_devices; +struct xrt_space_overseer; struct os_hid_device; /*! @@ -182,10 +183,13 @@ struct xrt_prober * * @param[in] xp Prober self parameter. * @param[out] out_xsysd Return of system devices, the pointed pointer must be NULL. + * @param[out] out_xso Return of the @ref xrt_space_overseer, the pointed pointer must be NULL. * * @note Code consuming this interface should use xrt_prober_create_system() */ - xrt_result_t (*create_system)(struct xrt_prober *xp, struct xrt_system_devices **out_xsysd); + xrt_result_t (*create_system)(struct xrt_prober *xp, + struct xrt_system_devices **out_xsysd, + struct xrt_space_overseer **out_xso); /*! * Iterate through drivers (by ID and auto-probers) checking to see if @@ -365,9 +369,11 @@ xrt_prober_dump(struct xrt_prober *xp) * @public @memberof xrt_prober */ static inline xrt_result_t -xrt_prober_create_system(struct xrt_prober *xp, struct xrt_system_devices **out_xsysd) +xrt_prober_create_system(struct xrt_prober *xp, + struct xrt_system_devices **out_xsysd, + struct xrt_space_overseer **out_xso) { - return xp->create_system(xp, out_xsysd); + return xp->create_system(xp, out_xsysd, out_xso); } /*! @@ -578,13 +584,15 @@ struct xrt_builder * @param[in] xp Prober * @param[in] config JSON config object if found for this setter upper. * @param[out] out_xsysd Return of system devices, the pointed pointer must be NULL. + * @param[out] out_xso Return of the @ref xrt_space_overseer, the pointed pointer must be NULL. * * @note Code consuming this interface should use xrt_builder_open_system() */ xrt_result_t (*open_system)(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, - struct xrt_system_devices **out_xsysd); + struct xrt_system_devices **out_xsysd, + struct xrt_space_overseer **out_xso); /*! * Destroy this setter upper. @@ -621,9 +629,10 @@ static inline xrt_result_t xrt_builder_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, - struct xrt_system_devices **out_xsysd) + struct xrt_system_devices **out_xsysd, + struct xrt_space_overseer **out_xso) { - return xb->open_system(xb, config, xp, out_xsysd); + return xb->open_system(xb, config, xp, out_xsysd, out_xso); } /*! diff --git a/src/xrt/include/xrt/xrt_space.h b/src/xrt/include/xrt/xrt_space.h index 967c0955a..dc75a4884 100644 --- a/src/xrt/include/xrt/xrt_space.h +++ b/src/xrt/include/xrt/xrt_space.h @@ -120,8 +120,12 @@ struct xrt_space_overseer struct xrt_space **out_space); /*! - * Create a space that wraps a device input pose, implicitly make the - * device's tracking space the returned space parent. + * Create a space that wraps the @p xdev input pose described by input + * @p name, implicitly make the device's tracking space the parent of + * the created space. The name pose_space was chosen because while most + * input poses are part of the device, they may also be things tracked + * by the device. The important part is that the space is following the + * pose, that it happens to be attached to device is coincidental. * * @param[in] xso Owning space overseer. * @param[in] xdev Device to get the pose from. diff --git a/src/xrt/ipc/client/ipc_client_instance.c b/src/xrt/ipc/client/ipc_client_instance.c index e5080e206..d6c797360 100644 --- a/src/xrt/ipc/client/ipc_client_instance.c +++ b/src/xrt/ipc/client/ipc_client_instance.c @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -25,8 +25,10 @@ #include "shared/ipc_protocol.h" #include "client/ipc_client.h" + #include "ipc_client_generated.h" + #include #if !defined(XRT_OS_WINDOWS) #include @@ -314,6 +316,7 @@ create_system_compositor(struct ipc_client_instance *ii, static xrt_result_t ipc_client_instance_create_system(struct xrt_instance *xinst, struct xrt_system_devices **out_xsysd, + struct xrt_space_overseer **out_xso, struct xrt_system_compositor **out_xsysc) { struct ipc_client_instance *ii = ipc_client_instance(xinst); @@ -349,6 +352,7 @@ ipc_client_instance_create_system(struct xrt_instance *xinst, // Done here now. if (out_xsysc == NULL) { *out_xsysd = &usysd->base; + *out_xso = ipc_client_space_overseer_create(&ii->ipc_c); return XRT_SUCCESS; } @@ -366,6 +370,7 @@ ipc_client_instance_create_system(struct xrt_instance *xinst, } *out_xsysd = &usysd->base; + *out_xso = ipc_client_space_overseer_create(&ii->ipc_c); *out_xsysc = xsysc; return XRT_SUCCESS; diff --git a/src/xrt/ipc/server/ipc_server_process.c b/src/xrt/ipc/server/ipc_server_process.c index 46dba16b1..b3b3bb5a6 100644 --- a/src/xrt/ipc/server/ipc_server_process.c +++ b/src/xrt/ipc/server/ipc_server_process.c @@ -1,4 +1,4 @@ -// Copyright 2020-2021, Collabora, Ltd. +// Copyright 2020-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -131,6 +131,7 @@ teardown_all(struct ipc_server *s) teardown_idevs(s); + xrt_space_overseer_destroy(&s->xso); xrt_system_devices_destroy(&s->xsysd); xrt_instance_destroy(&s->xinst); @@ -468,7 +469,7 @@ init_all(struct ipc_server *s) return -1; } - xret = xrt_instance_create_system(s->xinst, &s->xsysd, &s->xsysc); + xret = xrt_instance_create_system(s->xinst, &s->xsysd, &s->xso, &s->xsysc); if (xret != XRT_SUCCESS) { IPC_ERROR(s, "Could not create system!"); teardown_all(s); diff --git a/src/xrt/state_trackers/gui/gui_common.h b/src/xrt/state_trackers/gui/gui_common.h index 04769a279..3b62e036a 100644 --- a/src/xrt/state_trackers/gui/gui_common.h +++ b/src/xrt/state_trackers/gui/gui_common.h @@ -47,6 +47,7 @@ struct gui_program struct gui_scene_manager *gsm; struct xrt_system_devices *xsysd; + struct xrt_space_overseer *xso; struct xrt_instance *instance; struct xrt_prober *xp; diff --git a/src/xrt/state_trackers/gui/gui_prober.c b/src/xrt/state_trackers/gui/gui_prober.c index 037ac2848..817f2c652 100644 --- a/src/xrt/state_trackers/gui/gui_prober.c +++ b/src/xrt/state_trackers/gui/gui_prober.c @@ -1,4 +1,4 @@ -// Copyright 2019-2022, Collabora, Ltd. +// Copyright 2019-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -6,10 +6,13 @@ * @author Jakob Bornecrantz */ +#include "xrt/xrt_space.h" #include "xrt/xrt_prober.h" -#include "xrt/xrt_instance.h" #include "xrt/xrt_system.h" +#include "xrt/xrt_instance.h" + #include "util/u_time.h" + #include "gui_common.h" @@ -64,7 +67,7 @@ gui_prober_init(struct gui_program *p) int gui_prober_select(struct gui_program *p) { - xrt_result_t xret = xrt_instance_create_system(p->instance, &p->xsysd, NULL); + xrt_result_t xret = xrt_instance_create_system(p->instance, &p->xsysd, &p->xso, NULL); if (xret != XRT_SUCCESS) { return -1; } @@ -90,6 +93,7 @@ gui_prober_update(struct gui_program *p) void gui_prober_teardown(struct gui_program *p) { + xrt_space_overseer_destroy(&p->xso); xrt_system_devices_destroy(&p->xsysd); xrt_instance_destroy(&p->instance); diff --git a/src/xrt/state_trackers/oxr/oxr_instance.c b/src/xrt/state_trackers/oxr/oxr_instance.c index 82f073b9a..466c66ebe 100644 --- a/src/xrt/state_trackers/oxr/oxr_instance.c +++ b/src/xrt/state_trackers/oxr/oxr_instance.c @@ -1,4 +1,4 @@ -// Copyright 2018-2022, Collabora, Ltd. +// Copyright 2018-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -70,6 +70,7 @@ oxr_instance_destroy(struct oxr_logger *log, struct oxr_handle_base *hb) u_hashset_destroy(&inst->action_sets.name_store); u_hashset_destroy(&inst->action_sets.loc_store); + xrt_space_overseer_destroy(&inst->system.xso); xrt_system_devices_destroy(&inst->system.xsysd); #ifdef XRT_FEATURE_CLIENT_DEBUG_GUI @@ -267,9 +268,9 @@ oxr_instance_create(struct oxr_logger *log, // Create the compositor if we are not headless. if (!inst->extensions.MND_headless) { - xret = xrt_instance_create_system(inst->xinst, &sys->xsysd, &sys->xsysc); + xret = xrt_instance_create_system(inst->xinst, &sys->xsysd, &sys->xso, &sys->xsysc); } else { - xret = xrt_instance_create_system(inst->xinst, &sys->xsysd, NULL); + xret = xrt_instance_create_system(inst->xinst, &sys->xsysd, &sys->xso, NULL); } if (xret != XRT_SUCCESS) { diff --git a/src/xrt/state_trackers/oxr/oxr_objects.h b/src/xrt/state_trackers/oxr/oxr_objects.h index 46dd888a3..cb4a1964a 100644 --- a/src/xrt/state_trackers/oxr/oxr_objects.h +++ b/src/xrt/state_trackers/oxr/oxr_objects.h @@ -9,6 +9,7 @@ #pragma once +#include "xrt/xrt_space.h" #include "xrt/xrt_limits.h" #include "xrt/xrt_system.h" #include "xrt/xrt_device.h" @@ -1296,6 +1297,9 @@ struct oxr_system //! System devices used in all session types. struct xrt_system_devices *xsysd; + //! Space overseer used in all session types. + struct xrt_space_overseer *xso; + //! System compositor, used to create session compositors. struct xrt_system_compositor *xsysc; diff --git a/src/xrt/state_trackers/prober/p_prober.c b/src/xrt/state_trackers/prober/p_prober.c index d8d13fdfc..f5eda48c6 100644 --- a/src/xrt/state_trackers/prober/p_prober.c +++ b/src/xrt/state_trackers/prober/p_prober.c @@ -89,7 +89,7 @@ static int p_dump(struct xrt_prober *xp); static xrt_result_t -p_create_system(struct xrt_prober *xp, struct xrt_system_devices **out_xsysd); +p_create_system(struct xrt_prober *xp, struct xrt_system_devices **out_xsysd, struct xrt_space_overseer **out_xso); static int p_select_device(struct xrt_prober *xp, struct xrt_device **xdevs, size_t xdev_count); @@ -964,7 +964,7 @@ p_dump(struct xrt_prober *xp) } static xrt_result_t -p_create_system(struct xrt_prober *xp, struct xrt_system_devices **out_xsysd) +p_create_system(struct xrt_prober *xp, struct xrt_system_devices **out_xsysd, struct xrt_space_overseer **out_xso) { XRT_TRACE_MARKER(); @@ -1062,7 +1062,7 @@ p_create_system(struct xrt_prober *xp, struct xrt_system_devices **out_xsysd) if (select != NULL) { u_pp(dg, "\n\tUsing builder %s: %s", select->identifier, select->name); - xret = xrt_builder_open_system(select, p->json.root, xp, out_xsysd); + xret = xrt_builder_open_system(select, p->json.root, xp, out_xsysd, out_xso); if (xret == XRT_SUCCESS) { print_system_devices(dg, *out_xsysd); diff --git a/src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp b/src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp index 30296400d..b51eb9ee1 100644 --- a/src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp +++ b/src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp @@ -29,6 +29,7 @@ extern "C" { #include "util/u_builders.h" #include "util/u_hand_tracking.h" +#include "xrt/xrt_space.h" #include "xrt/xrt_system.h" #include "xrt/xrt_defines.h" #include "xrt/xrt_device.h" @@ -1433,6 +1434,7 @@ public: private: struct xrt_instance *m_xinst = NULL; struct xrt_system_devices *m_xsysd = NULL; + struct xrt_space_overseer *m_xso = NULL; struct xrt_device *m_xhmd = NULL; CDeviceDriver_Monado *m_MonadoDeviceDriver = NULL; @@ -1462,7 +1464,7 @@ CServerDriver_Monado::Init(vr::IVRDriverContext *pDriverContext) return vr::VRInitError_Init_HmdNotFound; } - xret = xrt_instance_create_system(m_xinst, &m_xsysd, NULL); + xret = xrt_instance_create_system(m_xinst, &m_xsysd, &m_xso, NULL); if (xret < 0) { ovrd_log("Failed to create system devices\n"); xrt_instance_destroy(&m_xinst); @@ -1470,6 +1472,8 @@ CServerDriver_Monado::Init(vr::IVRDriverContext *pDriverContext) } if (m_xsysd->roles.head == NULL) { ovrd_log("Didn't get a HMD device!\n"); + xrt_space_overseer_destroy(&m_xso); + xrt_system_devices_destroy(&m_xsysd); xrt_instance_destroy(&m_xinst); return vr::VRInitError_Init_HmdNotFound; } @@ -1508,6 +1512,7 @@ CServerDriver_Monado::Cleanup() m_MonadoDeviceDriver = NULL; } + xrt_space_overseer_destroy(&m_xso); xrt_system_devices_destroy(&m_xsysd); m_xhmd = NULL; m_left->m_xdev = NULL; diff --git a/src/xrt/targets/cli/cli_cmd_probe.c b/src/xrt/targets/cli/cli_cmd_probe.c index ed1f124b4..0d58dbcbe 100644 --- a/src/xrt/targets/cli/cli_cmd_probe.c +++ b/src/xrt/targets/cli/cli_cmd_probe.c @@ -1,4 +1,4 @@ -// Copyright 2019, Collabora, Ltd. +// Copyright 2019-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -6,16 +6,17 @@ * @author Jakob Bornecrantz */ -#include -#include - -#include "xrt/xrt_instance.h" +#include "xrt/xrt_space.h" #include "xrt/xrt_system.h" #include "xrt/xrt_device.h" #include "xrt/xrt_prober.h" +#include "xrt/xrt_instance.h" +#include "xrt/xrt_config_drivers.h" + #include "cli_common.h" -#include "xrt/xrt_config_drivers.h" +#include +#include static int do_exit(struct xrt_instance **xi_ptr, int ret) @@ -48,9 +49,11 @@ cli_cmd_probe(int argc, const char **argv) printf(" :: Creating system devices!\n"); struct xrt_system_devices *xsysd = NULL; + struct xrt_space_overseer *xso = NULL; xret = xrt_instance_create_system( // xi, // Instance &xsysd, // System devices. + &xso, // Space overseer. NULL); // System compositor. if (xret != XRT_SUCCESS) { printf("\tCall to xrt_instance_create_system failed! '%i'\n", xret); @@ -114,6 +117,7 @@ cli_cmd_probe(int argc, const char **argv) printf(" :: Destroying probed devices\n"); + xrt_space_overseer_destroy(&xso); xrt_system_devices_destroy(&xsysd); // End of program diff --git a/src/xrt/targets/cli/cli_cmd_test.c b/src/xrt/targets/cli/cli_cmd_test.c index 60f12c373..2f0247ae8 100644 --- a/src/xrt/targets/cli/cli_cmd_test.c +++ b/src/xrt/targets/cli/cli_cmd_test.c @@ -1,4 +1,4 @@ -// Copyright 2019, Collabora, Ltd. +// Copyright 2019-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -6,14 +6,16 @@ * @author Jakob Bornecrantz */ -#include -#include - -#include "xrt/xrt_instance.h" +#include "xrt/xrt_space.h" #include "xrt/xrt_system.h" #include "xrt/xrt_prober.h" +#include "xrt/xrt_instance.h" + #include "cli_common.h" +#include +#include + static int do_exit(struct xrt_instance **xi_ptr, int ret) @@ -74,9 +76,11 @@ cli_cmd_test(int argc, const char **argv) printf(" :: Creating system devices!\n"); struct xrt_system_devices *xsysd = NULL; + struct xrt_space_overseer *xso = NULL; xret = xrt_instance_create_system( // xi, // Instance &xsysd, // System devices. + &xso, // Space Overseer. NULL); // System compositor. if (xret != XRT_SUCCESS) { printf("\tCall to xrt_instance_create_system failed! '%i'\n", xret); @@ -123,6 +127,7 @@ cli_cmd_test(int argc, const char **argv) // End of program printf(" :: All ok, shutting down.\n"); + xrt_space_overseer_destroy(&xso); xrt_system_devices_destroy(&xsysd); // Finally done diff --git a/src/xrt/targets/common/target_builder_legacy.c b/src/xrt/targets/common/target_builder_legacy.c index 2b01f7293..d00c93418 100644 --- a/src/xrt/targets/common/target_builder_legacy.c +++ b/src/xrt/targets/common/target_builder_legacy.c @@ -1,4 +1,4 @@ -// Copyright 2022, Collabora, Ltd. +// Copyright 2022-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -12,6 +12,7 @@ #include "util/u_misc.h" #include "util/u_device.h" +#include "util/u_builders.h" #include "util/u_system_helpers.h" #include "target_builder_interface.h" @@ -106,7 +107,11 @@ legacy_estimate_system(struct xrt_builder *xb, } static xrt_result_t -legacy_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, struct xrt_system_devices **out_xsysd) +legacy_open_system(struct xrt_builder *xb, + cJSON *config, + struct xrt_prober *xp, + struct xrt_system_devices **out_xsysd, + struct xrt_space_overseer **out_xso) { struct u_system_devices *usysd = u_system_devices_allocate(); xrt_result_t xret; @@ -169,6 +174,7 @@ legacy_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, */ *out_xsysd = &usysd->base; + u_builder_create_space_overseer(&usysd->base, out_xso); return XRT_SUCCESS; } diff --git a/src/xrt/targets/common/target_builder_lighthouse.c b/src/xrt/targets/common/target_builder_lighthouse.c index 1e1193921..6cee18086 100644 --- a/src/xrt/targets/common/target_builder_lighthouse.c +++ b/src/xrt/targets/common/target_builder_lighthouse.c @@ -1,4 +1,4 @@ -// Copyright 2022, Collabora, Ltd. +// Copyright 2022-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -524,7 +524,8 @@ static xrt_result_t lighthouse_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, - struct xrt_system_devices **out_xsysd) + struct xrt_system_devices **out_xsysd, + struct xrt_space_overseer **out_xso) { struct lighthouse_system *lhs = (struct lighthouse_system *)xb; lhs->devices = u_system_devices_allocate(); @@ -703,6 +704,7 @@ end: if (result == XRT_SUCCESS) { *out_xsysd = &usysd->base; + u_builder_create_space_overseer(&usysd->base, out_xso); } else { u_system_devices_destroy(&usysd); } diff --git a/src/xrt/targets/common/target_builder_north_star.c b/src/xrt/targets/common/target_builder_north_star.c index 16438ea0e..01b4c5d38 100644 --- a/src/xrt/targets/common/target_builder_north_star.c +++ b/src/xrt/targets/common/target_builder_north_star.c @@ -1,4 +1,4 @@ -// Copyright 2022, Collabora, Ltd. +// Copyright 2022-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -408,7 +408,11 @@ ns_estimate_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, static xrt_result_t -ns_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, struct xrt_system_devices **out_xsysd) +ns_open_system(struct xrt_builder *xb, + cJSON *config, + struct xrt_prober *xp, + struct xrt_system_devices **out_xsysd, + struct xrt_space_overseer **out_xso) { struct ns_builder *nsb = (struct ns_builder *)xb; @@ -547,6 +551,7 @@ ns_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, str end: if (result == XRT_SUCCESS) { *out_xsysd = &usysd->base; + u_builder_create_space_overseer(&usysd->base, out_xso); } else { u_system_devices_destroy(&usysd); } diff --git a/src/xrt/targets/common/target_builder_remote.c b/src/xrt/targets/common/target_builder_remote.c index 707f3c6fe..170c098e2 100644 --- a/src/xrt/targets/common/target_builder_remote.c +++ b/src/xrt/targets/common/target_builder_remote.c @@ -1,4 +1,4 @@ -// Copyright 2022, Collabora, Ltd. +// Copyright 2022-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -71,7 +71,11 @@ remote_estimate_system(struct xrt_builder *xb, } static xrt_result_t -remote_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, struct xrt_system_devices **out_xsysd) +remote_open_system(struct xrt_builder *xb, + cJSON *config, + struct xrt_prober *xp, + struct xrt_system_devices **out_xsysd, + struct xrt_space_overseer **out_xso) { assert(out_xsysd != NULL); assert(*out_xsysd == NULL); @@ -82,7 +86,16 @@ remote_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, port = 4242; } - return r_create_devices(port, out_xsysd); + struct xrt_system_devices *xsysd = NULL; + xrt_result_t xret = r_create_devices(port, &xsysd); + if (xret != XRT_SUCCESS) { + return xret; + } + + *out_xsysd = xsysd; + u_builder_create_space_overseer(xsysd, out_xso); + + return xret; } static void diff --git a/src/xrt/targets/common/target_builder_rgb_tracking.c b/src/xrt/targets/common/target_builder_rgb_tracking.c index 6c14362b4..0cfbc2a82 100644 --- a/src/xrt/targets/common/target_builder_rgb_tracking.c +++ b/src/xrt/targets/common/target_builder_rgb_tracking.c @@ -1,4 +1,4 @@ -// Copyright 2022, Collabora, Ltd. +// Copyright 2022-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -274,7 +274,11 @@ rgb_estimate_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp } static xrt_result_t -rgb_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, struct xrt_system_devices **out_xsysd) +rgb_open_system(struct xrt_builder *xb, + cJSON *config, + struct xrt_prober *xp, + struct xrt_system_devices **out_xsysd, + struct xrt_space_overseer **out_xso) { struct u_builder_search_results results = {0}; struct xrt_prober_device **xpdevs = NULL; @@ -401,6 +405,7 @@ rgb_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, st */ *out_xsysd = &usysd->base; + u_builder_create_space_overseer(&usysd->base, out_xso); return XRT_SUCCESS; } diff --git a/src/xrt/targets/common/target_builder_rift_s.c b/src/xrt/targets/common/target_builder_rift_s.c index d6b0e2a3f..6bf27c1b4 100644 --- a/src/xrt/targets/common/target_builder_rift_s.c +++ b/src/xrt/targets/common/target_builder_rift_s.c @@ -1,4 +1,4 @@ -// Copyright 2019, Collabora, Ltd. +// Copyright 2019-2023, Collabora, Ltd. // Copyright 2022, Jan Schmidt // SPDX-License-Identifier: BSL-1.0 /*! @@ -82,7 +82,11 @@ rift_s_estimate_system(struct xrt_builder *xb, } static xrt_result_t -rift_s_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, struct xrt_system_devices **out_xsysd) +rift_s_open_system(struct xrt_builder *xb, + cJSON *config, + struct xrt_prober *xp, + struct xrt_system_devices **out_xsysd, + struct xrt_space_overseer **out_xso) { struct xrt_prober_device **xpdevs = NULL; size_t xpdev_count = 0; @@ -185,6 +189,7 @@ rift_s_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, #endif *out_xsysd = &usysd->base; + u_builder_create_space_overseer(&usysd->base, out_xso); return XRT_SUCCESS; diff --git a/src/xrt/targets/common/target_builder_simulated.c b/src/xrt/targets/common/target_builder_simulated.c index 086dba80c..2de966910 100644 --- a/src/xrt/targets/common/target_builder_simulated.c +++ b/src/xrt/targets/common/target_builder_simulated.c @@ -92,7 +92,8 @@ static xrt_result_t simulated_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, - struct xrt_system_devices **out_xsysd) + struct xrt_system_devices **out_xsysd, + struct xrt_space_overseer **out_xso) { assert(out_xsysd != NULL); assert(*out_xsysd == NULL); @@ -131,6 +132,7 @@ simulated_open_system(struct xrt_builder *xb, } *out_xsysd = &usysd->base; + u_builder_create_space_overseer(&usysd->base, out_xso); return XRT_SUCCESS; } diff --git a/src/xrt/targets/common/target_builder_simulavr.c b/src/xrt/targets/common/target_builder_simulavr.c index 7d34ae0a6..43c4befb1 100644 --- a/src/xrt/targets/common/target_builder_simulavr.c +++ b/src/xrt/targets/common/target_builder_simulavr.c @@ -1,4 +1,4 @@ -// Copyright 2022, Collabora, Ltd. +// Copyright 2022-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -185,7 +185,11 @@ svr_estimate_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp } static xrt_result_t -svr_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, struct xrt_system_devices **out_xsysd) +svr_open_system(struct xrt_builder *xb, + cJSON *config, + struct xrt_prober *xp, + struct xrt_system_devices **out_xsysd, + struct xrt_space_overseer **out_xso) { struct simula_builder *sb = (struct simula_builder *)xb; struct u_system_devices *usysd = u_system_devices_allocate(); @@ -215,6 +219,7 @@ svr_open_system(struct xrt_builder *xb, cJSON *config, struct xrt_prober *xp, st end: if (result == XRT_SUCCESS) { *out_xsysd = &usysd->base; + u_builder_create_space_overseer(&usysd->base, out_xso); } else { u_system_devices_destroy(&usysd); } diff --git a/src/xrt/targets/common/target_instance.c b/src/xrt/targets/common/target_instance.c index 63ad6d8fc..eb698f716 100644 --- a/src/xrt/targets/common/target_instance.c +++ b/src/xrt/targets/common/target_instance.c @@ -1,4 +1,4 @@ -// Copyright 2020-2022, Collabora, Ltd. +// Copyright 2020-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -6,6 +6,7 @@ * @author Jakob Bornecrantz */ +#include "xrt/xrt_space.h" #include "xrt/xrt_system.h" #include "xrt/xrt_config_build.h" @@ -46,19 +47,23 @@ 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_devices **out_xsysd, + struct xrt_space_overseer **out_xso, struct xrt_system_compositor **out_xsysc) { XRT_TRACE_MARKER(); assert(out_xsysd != NULL); assert(*out_xsysd == NULL); + assert(out_xso != NULL); + assert(*out_xso == NULL); assert(out_xsysc == NULL || *out_xsysc == 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; - xret = u_system_devices_create_from_prober(xinst, &xsysd); + xret = u_system_devices_create_from_prober(xinst, &xsysd, &xso); if (xret != XRT_SUCCESS) { return xret; } @@ -96,11 +101,13 @@ 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; } *out_xsysd = xsysd; + *out_xso = xso; *out_xsysc = xsysc; return xret; diff --git a/src/xrt/targets/common/target_instance_no_comp.c b/src/xrt/targets/common/target_instance_no_comp.c index 9195d99b7..cf4b0eaeb 100644 --- a/src/xrt/targets/common/target_instance_no_comp.c +++ b/src/xrt/targets/common/target_instance_no_comp.c @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -18,15 +18,19 @@ static xrt_result_t t_instance_create_system(struct xrt_instance *xinst, struct xrt_system_devices **out_xsysd, + struct xrt_space_overseer **out_xso, struct xrt_system_compositor **out_xsysc) { XRT_TRACE_MARKER(); struct xrt_system_devices *xsysd = NULL; + struct xrt_space_overseer *xso = NULL; xrt_result_t xret = XRT_SUCCESS; assert(out_xsysd != NULL); assert(*out_xsysd == NULL); + assert(out_xso != NULL); + assert(*out_xso == NULL); assert(out_xsysc == NULL || *out_xsysc == NULL); // Can't create a system compositor. @@ -34,12 +38,13 @@ t_instance_create_system(struct xrt_instance *xinst, return XRT_ERROR_ALLOCATION; } - xret = u_system_devices_create_from_prober(xinst, &xsysd); + xret = u_system_devices_create_from_prober(xinst, &xsysd, &xso); if (xret != XRT_SUCCESS) { return xret; } *out_xsysd = xsysd; + *out_xso = xso; return xret; } diff --git a/src/xrt/targets/sdl_test/sdl_instance.c b/src/xrt/targets/sdl_test/sdl_instance.c index 2fd717496..5d8fc168b 100644 --- a/src/xrt/targets/sdl_test/sdl_instance.c +++ b/src/xrt/targets/sdl_test/sdl_instance.c @@ -1,4 +1,4 @@ -// Copyright 2020-2022, Collabora, Ltd. +// Copyright 2020-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -11,6 +11,7 @@ #include "xrt/xrt_config_drivers.h" #include "util/u_misc.h" +#include "util/u_builders.h" #include "util/u_trace_marker.h" #include "sdl_internal.h" @@ -55,15 +56,19 @@ 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_devices **out_xsysd, + struct xrt_space_overseer **out_xso, struct xrt_system_compositor **out_xsysc) { assert(out_xsysd != NULL); assert(*out_xsysd == NULL); + assert(out_xso != NULL); + assert(*out_xso == NULL); assert(out_xsysc == NULL || *out_xsysc == NULL); struct sdl_program *sp = from_xinst(xinst); *out_xsysd = &sp->xsysd_base; + *out_xso = sp->xso; // Early out if we only want devices. if (out_xsysc == NULL) { @@ -107,6 +112,8 @@ sdl_system_devices_init(struct sdl_program *sp) sp->xsysd_base.xdevs[0] = head; sp->xsysd_base.xdev_count = 1; sp->xsysd_base.roles.head = head; + + u_builder_create_space_overseer(&sp->xsysd_base, &sp->xso); } void diff --git a/src/xrt/targets/sdl_test/sdl_internal.h b/src/xrt/targets/sdl_test/sdl_internal.h index d6b1d6713..c29c96f3b 100644 --- a/src/xrt/targets/sdl_test/sdl_internal.h +++ b/src/xrt/targets/sdl_test/sdl_internal.h @@ -1,4 +1,4 @@ -// Copyright 2020-2022, Collabora, Ltd. +// Copyright 2020-2023, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -130,6 +130,9 @@ struct sdl_program //! System devices base. struct xrt_system_devices xsysd_base; + //! Space overseer, implemented for now using helper code. + struct xrt_space_overseer *xso; + //! SDL compositor struct. struct sdl_compositor c;