2020-06-01 20:32:43 +00:00
|
|
|
// Copyright 2018-2020, Collabora, Ltd.
|
2019-03-18 05:52:32 +00:00
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
/*!
|
|
|
|
* @file
|
2019-09-26 20:25:05 +00:00
|
|
|
* @brief Holds instance related functions.
|
2019-03-18 05:52:32 +00:00
|
|
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
|
|
|
* @ingroup oxr_main
|
|
|
|
*/
|
|
|
|
|
2020-07-15 19:11:08 +00:00
|
|
|
#include "xrt/xrt_config_os.h"
|
|
|
|
#include "xrt/xrt_config_build.h"
|
|
|
|
#include "xrt/xrt_instance.h"
|
|
|
|
|
2020-07-15 18:05:52 +00:00
|
|
|
#include "math/m_mathinclude.h"
|
2019-08-31 11:49:04 +00:00
|
|
|
#include "util/u_var.h"
|
2019-03-18 05:52:32 +00:00
|
|
|
#include "util/u_time.h"
|
2019-03-21 20:19:52 +00:00
|
|
|
#include "util/u_misc.h"
|
2019-08-31 11:49:04 +00:00
|
|
|
#include "util/u_debug.h"
|
2020-10-20 16:43:11 +00:00
|
|
|
#include "util/u_git_tag.h"
|
2019-03-18 05:52:32 +00:00
|
|
|
|
2020-08-18 20:33:21 +00:00
|
|
|
#ifdef XRT_OS_ANDROID
|
2020-08-19 20:56:38 +00:00
|
|
|
#include "android/android_globals.h"
|
2020-08-18 20:33:21 +00:00
|
|
|
#endif
|
2019-03-18 05:52:32 +00:00
|
|
|
|
|
|
|
#include "oxr_objects.h"
|
|
|
|
#include "oxr_logger.h"
|
2019-04-05 19:18:03 +00:00
|
|
|
#include "oxr_handle.h"
|
2019-08-19 17:37:50 +00:00
|
|
|
#include "oxr_extension_support.h"
|
2020-07-20 19:53:52 +00:00
|
|
|
#include "oxr_subaction.h"
|
2020-08-18 20:33:21 +00:00
|
|
|
#include "oxr_chain.h"
|
2019-03-18 05:52:32 +00:00
|
|
|
|
2020-06-17 06:36:38 +00:00
|
|
|
#include <sys/types.h>
|
2020-07-15 16:45:01 +00:00
|
|
|
#ifdef XRT_OS_UNIX
|
2020-06-17 06:36:38 +00:00
|
|
|
#include <unistd.h>
|
2020-07-15 16:45:01 +00:00
|
|
|
#endif
|
2020-06-17 06:36:38 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
2019-10-22 10:47:25 +00:00
|
|
|
DEBUG_GET_ONCE_BOOL_OPTION(debug_views, "OXR_DEBUG_VIEWS", false)
|
|
|
|
DEBUG_GET_ONCE_BOOL_OPTION(debug_spaces, "OXR_DEBUG_SPACES", false)
|
|
|
|
DEBUG_GET_ONCE_BOOL_OPTION(debug_bindings, "OXR_DEBUG_BINDINGS", false)
|
|
|
|
DEBUG_GET_ONCE_BOOL_OPTION(lifecycle_verbose, "OXR_LIFECYCLE_VERBOSE", false)
|
|
|
|
|
2019-03-18 05:52:32 +00:00
|
|
|
DEBUG_GET_ONCE_FLOAT_OPTION(lfov_left, "OXR_OVERRIDE_LFOV_LEFT", 0.0f)
|
|
|
|
DEBUG_GET_ONCE_FLOAT_OPTION(lfov_right, "OXR_OVERRIDE_LFOV_RIGHT", 0.0f)
|
|
|
|
DEBUG_GET_ONCE_FLOAT_OPTION(lfov_up, "OXR_OVERRIDE_LFOV_UP", 0.0f)
|
|
|
|
DEBUG_GET_ONCE_FLOAT_OPTION(lfov_down, "OXR_OVERRIDE_LFOV_DOWN", 0.0f)
|
|
|
|
|
2019-10-10 14:36:05 +00:00
|
|
|
/* ---- HACK ---- */
|
|
|
|
extern int
|
|
|
|
oxr_sdl2_hack_create(void **out_hack);
|
|
|
|
|
|
|
|
extern void
|
2020-04-10 09:53:27 +00:00
|
|
|
oxr_sdl2_hack_start(void *hack, struct xrt_instance *xinst);
|
2019-10-10 14:36:05 +00:00
|
|
|
|
|
|
|
extern void
|
2019-11-09 12:44:59 +00:00
|
|
|
oxr_sdl2_hack_stop(void **hack_ptr);
|
2019-10-10 14:36:05 +00:00
|
|
|
/* ---- HACK ---- */
|
|
|
|
|
2019-03-18 05:52:32 +00:00
|
|
|
static inline int32_t
|
|
|
|
radtodeg_for_display(float radians)
|
|
|
|
{
|
|
|
|
return (int32_t)(radians * 180 * M_1_PI);
|
|
|
|
}
|
|
|
|
|
2019-04-05 19:18:03 +00:00
|
|
|
static XrResult
|
|
|
|
oxr_instance_destroy(struct oxr_logger *log, struct oxr_handle_base *hb)
|
|
|
|
{
|
|
|
|
struct oxr_instance *inst = (struct oxr_instance *)hb;
|
|
|
|
|
2020-09-07 13:25:57 +00:00
|
|
|
// Does a null-ptr check.
|
2020-10-04 11:56:27 +00:00
|
|
|
xrt_comp_native_destroy(&inst->system.xcn);
|
2020-09-07 13:25:57 +00:00
|
|
|
|
2019-08-31 11:49:04 +00:00
|
|
|
u_var_remove_root((void *)inst);
|
|
|
|
|
2019-09-02 21:04:13 +00:00
|
|
|
oxr_binding_destroy_all(log, inst);
|
2019-04-05 12:44:21 +00:00
|
|
|
|
2020-05-27 20:04:58 +00:00
|
|
|
oxr_path_destroy(log, inst);
|
2019-04-05 12:44:21 +00:00
|
|
|
|
2020-05-30 22:44:03 +00:00
|
|
|
u_hashset_destroy(&inst->action_sets.name_store);
|
|
|
|
u_hashset_destroy(&inst->action_sets.loc_store);
|
|
|
|
|
2019-07-24 16:15:15 +00:00
|
|
|
for (size_t i = 0; i < inst->system.num_xdevs; i++) {
|
|
|
|
oxr_xdev_destroy(&inst->system.xdevs[i]);
|
|
|
|
}
|
2019-04-05 19:18:03 +00:00
|
|
|
|
2019-10-10 14:36:05 +00:00
|
|
|
/* ---- HACK ---- */
|
2019-11-09 12:44:59 +00:00
|
|
|
oxr_sdl2_hack_stop(&inst->hack);
|
2019-10-10 14:36:05 +00:00
|
|
|
/* ---- HACK ---- */
|
|
|
|
|
2020-04-10 09:53:27 +00:00
|
|
|
xrt_instance_destroy(&inst->xinst);
|
2019-04-05 19:18:03 +00:00
|
|
|
|
2019-11-15 20:30:01 +00:00
|
|
|
// Does null checking and sets to null.
|
|
|
|
time_state_destroy(&inst->timekeeping);
|
2019-04-05 19:18:03 +00:00
|
|
|
|
2020-05-30 12:56:23 +00:00
|
|
|
// Mutex goes last.
|
|
|
|
os_mutex_destroy(&inst->event.mutex);
|
|
|
|
|
2019-04-05 19:18:03 +00:00
|
|
|
free(inst);
|
|
|
|
|
|
|
|
return XR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2019-05-07 12:47:18 +00:00
|
|
|
static void
|
|
|
|
cache_path(struct oxr_logger *log,
|
|
|
|
struct oxr_instance *inst,
|
|
|
|
const char *str,
|
|
|
|
XrPath *out_path)
|
|
|
|
{
|
|
|
|
oxr_path_get_or_create(log, inst, str, strlen(str), out_path);
|
|
|
|
}
|
|
|
|
|
2019-07-24 16:15:15 +00:00
|
|
|
#define NUM_XDEVS 16
|
|
|
|
|
2020-07-07 00:14:29 +00:00
|
|
|
static inline size_t
|
|
|
|
min_size_t(size_t a, size_t b)
|
|
|
|
{
|
|
|
|
return a < b ? a : b;
|
|
|
|
}
|
|
|
|
|
2019-03-18 05:52:32 +00:00
|
|
|
XrResult
|
|
|
|
oxr_instance_create(struct oxr_logger *log,
|
|
|
|
const XrInstanceCreateInfo *createInfo,
|
|
|
|
struct oxr_instance **out_instance)
|
|
|
|
{
|
2019-04-05 19:18:03 +00:00
|
|
|
struct oxr_instance *inst = NULL;
|
2019-07-24 16:15:15 +00:00
|
|
|
struct xrt_device *xdevs[NUM_XDEVS] = {0};
|
2020-05-30 22:44:03 +00:00
|
|
|
int xinst_ret, m_ret, h_ret;
|
2020-08-06 13:05:27 +00:00
|
|
|
xrt_result_t xret;
|
2019-11-09 12:41:43 +00:00
|
|
|
XrResult ret;
|
2019-04-05 12:44:21 +00:00
|
|
|
|
2019-04-05 19:18:03 +00:00
|
|
|
OXR_ALLOCATE_HANDLE_OR_RETURN(log, inst, OXR_XR_DEBUG_INSTANCE,
|
|
|
|
oxr_instance_destroy, NULL);
|
|
|
|
|
2019-10-22 10:47:25 +00:00
|
|
|
inst->lifecycle_verbose = debug_get_bool_option_lifecycle_verbose();
|
|
|
|
inst->debug_spaces = debug_get_bool_option_debug_spaces();
|
|
|
|
inst->debug_views = debug_get_bool_option_debug_views();
|
|
|
|
inst->debug_bindings = debug_get_bool_option_debug_bindings();
|
|
|
|
|
2020-05-30 12:56:23 +00:00
|
|
|
m_ret = os_mutex_init(&inst->event.mutex);
|
|
|
|
if (m_ret < 0) {
|
|
|
|
ret = oxr_error(log, XR_ERROR_RUNTIME_FAILURE,
|
|
|
|
"Failed to init mutex");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-10-10 14:36:05 +00:00
|
|
|
/* ---- HACK ---- */
|
|
|
|
oxr_sdl2_hack_create(&inst->hack);
|
|
|
|
/* ---- HACK ---- */
|
|
|
|
|
2020-05-27 20:04:58 +00:00
|
|
|
ret = oxr_path_init(log, inst);
|
|
|
|
if (ret != XR_SUCCESS) {
|
2020-05-30 12:56:23 +00:00
|
|
|
return ret;
|
2019-04-05 12:44:21 +00:00
|
|
|
}
|
|
|
|
|
2020-05-30 22:44:03 +00:00
|
|
|
h_ret = u_hashset_create(&inst->action_sets.name_store);
|
|
|
|
if (h_ret != 0) {
|
|
|
|
oxr_instance_destroy(log, &inst->handle);
|
|
|
|
return oxr_error(log, XR_ERROR_RUNTIME_FAILURE,
|
|
|
|
"Failed to create name_store hashset");
|
|
|
|
}
|
|
|
|
|
|
|
|
h_ret = u_hashset_create(&inst->action_sets.loc_store);
|
|
|
|
if (h_ret != 0) {
|
|
|
|
oxr_instance_destroy(log, &inst->handle);
|
|
|
|
return oxr_error(log, XR_ERROR_RUNTIME_FAILURE,
|
|
|
|
"Failed to create loc_store hashset");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-07 12:47:18 +00:00
|
|
|
// Cache certain often looked up paths.
|
2020-07-20 19:53:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define CACHE_SUBACTION_PATHS(NAME, NAME_CAPS, PATH) \
|
|
|
|
cache_path(log, inst, PATH, &inst->path_cache.NAME);
|
|
|
|
OXR_FOR_EACH_SUBACTION_PATH_DETAILED(CACHE_SUBACTION_PATHS)
|
|
|
|
|
|
|
|
#undef CACHE_SUBACTION_PATHS
|
2019-09-02 21:04:13 +00:00
|
|
|
// clang-format off
|
2020-07-20 19:53:52 +00:00
|
|
|
|
2019-09-02 21:04:13 +00:00
|
|
|
cache_path(log, inst, "/interaction_profiles/khr/simple_controller", &inst->path_cache.khr_simple_controller);
|
|
|
|
cache_path(log, inst, "/interaction_profiles/google/daydream_controller", &inst->path_cache.google_daydream_controller);
|
|
|
|
cache_path(log, inst, "/interaction_profiles/htc/vive_controller", &inst->path_cache.htc_vive_controller);
|
|
|
|
cache_path(log, inst, "/interaction_profiles/htc/vive_pro", &inst->path_cache.htc_vive_pro);
|
|
|
|
cache_path(log, inst, "/interaction_profiles/microsoft/motion_controller", &inst->path_cache.microsoft_motion_controller);
|
|
|
|
cache_path(log, inst, "/interaction_profiles/microsoft/xbox_controller", &inst->path_cache.microsoft_xbox_controller);
|
|
|
|
cache_path(log, inst, "/interaction_profiles/oculus/go_controller", &inst->path_cache.oculus_go_controller);
|
|
|
|
cache_path(log, inst, "/interaction_profiles/oculus/touch_controller", &inst->path_cache.oculus_touch_controller);
|
|
|
|
cache_path(log, inst, "/interaction_profiles/valve/index_controller", &inst->path_cache.valve_index_controller);
|
2020-07-06 10:31:38 +00:00
|
|
|
cache_path(log, inst, "/interaction_profiles/mndx/ball_on_a_stick_controller", &inst->path_cache.mndx_ball_on_a_stick_controller);
|
2019-09-02 21:04:13 +00:00
|
|
|
// clang-format on
|
2019-05-07 12:47:18 +00:00
|
|
|
|
2020-06-17 06:36:38 +00:00
|
|
|
// fill in our application info - @todo - replicate all createInfo
|
|
|
|
// fields?
|
|
|
|
|
|
|
|
struct xrt_instance_info i_info = {0};
|
|
|
|
snprintf(i_info.application_name,
|
|
|
|
sizeof(inst->xinst->instance_info.application_name), "%s",
|
|
|
|
createInfo->applicationInfo.applicationName);
|
|
|
|
|
2020-08-18 20:33:21 +00:00
|
|
|
#ifdef XRT_OS_ANDROID
|
|
|
|
XrInstanceCreateInfoAndroidKHR const *create_info_android =
|
|
|
|
OXR_GET_INPUT_FROM_CHAIN(createInfo,
|
|
|
|
XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR,
|
|
|
|
XrInstanceCreateInfoAndroidKHR);
|
2020-08-19 20:56:38 +00:00
|
|
|
android_globals_store_vm_and_activity(
|
2020-08-18 20:33:21 +00:00
|
|
|
(struct _JavaVM *)create_info_android->applicationVM,
|
|
|
|
create_info_android->applicationActivity);
|
|
|
|
#endif
|
|
|
|
|
2020-07-08 14:38:49 +00:00
|
|
|
xinst_ret = xrt_instance_create(&i_info, &inst->xinst);
|
2020-04-10 09:53:27 +00:00
|
|
|
if (xinst_ret != 0) {
|
2019-11-09 12:41:43 +00:00
|
|
|
ret = oxr_error(log, XR_ERROR_RUNTIME_FAILURE,
|
|
|
|
"Failed to create prober");
|
|
|
|
oxr_instance_destroy(log, &inst->handle);
|
|
|
|
return ret;
|
2019-05-07 12:47:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-10 09:53:27 +00:00
|
|
|
xinst_ret = xrt_instance_select(inst->xinst, xdevs, NUM_XDEVS);
|
|
|
|
if (xinst_ret != 0) {
|
2019-11-09 12:41:43 +00:00
|
|
|
ret = oxr_error(log, XR_ERROR_RUNTIME_FAILURE,
|
2020-04-10 09:53:27 +00:00
|
|
|
"Failed to select device(s)");
|
2019-11-09 12:41:43 +00:00
|
|
|
oxr_instance_destroy(log, &inst->handle);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2020-07-07 00:14:29 +00:00
|
|
|
struct oxr_system *sys = &inst->system;
|
|
|
|
|
2020-07-22 21:25:49 +00:00
|
|
|
#define POPULATE_ROLES(X) sys->role.X = XRT_DEVICE_ROLE_UNASSIGNED;
|
|
|
|
OXR_FOR_EACH_VALID_SUBACTION_PATH(POPULATE_ROLES)
|
|
|
|
#undef POPULATE_ROLES
|
2020-07-07 00:14:29 +00:00
|
|
|
|
|
|
|
sys->num_xdevs = min_size_t(ARRAY_SIZE(sys->xdevs), NUM_XDEVS);
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < sys->num_xdevs; i++) {
|
|
|
|
sys->xdevs[i] = xdevs[i];
|
|
|
|
}
|
|
|
|
for (size_t i = sys->num_xdevs; i < NUM_XDEVS; i++) {
|
|
|
|
oxr_xdev_destroy(&xdevs[i]);
|
|
|
|
}
|
|
|
|
|
2020-11-06 15:34:29 +00:00
|
|
|
u_device_assign_xdev_roles(xdevs, NUM_XDEVS, &sys->role.head,
|
|
|
|
&sys->role.left, &sys->role.right);
|
2020-07-07 00:14:29 +00:00
|
|
|
|
2019-11-09 12:41:43 +00:00
|
|
|
// Did we find any HMD
|
|
|
|
// @todo Headless with only controllers?
|
2020-07-07 00:14:29 +00:00
|
|
|
struct xrt_device *dev = GET_XDEV_BY_ROLE(sys, head);
|
|
|
|
if (dev == NULL) {
|
2019-11-09 12:41:43 +00:00
|
|
|
ret = oxr_error(log, XR_ERROR_RUNTIME_FAILURE,
|
|
|
|
"Failed to find any HMD device");
|
|
|
|
oxr_instance_destroy(log, &inst->handle);
|
|
|
|
return ret;
|
2019-05-07 12:47:18 +00:00
|
|
|
}
|
2019-03-18 05:52:32 +00:00
|
|
|
|
2020-11-08 23:30:30 +00:00
|
|
|
u_device_setup_tracking_origins(dev, GET_XDEV_BY_ROLE(sys, left),
|
|
|
|
GET_XDEV_BY_ROLE(sys, right));
|
|
|
|
|
2019-03-18 05:52:32 +00:00
|
|
|
const float left_override = debug_get_float_option_lfov_left();
|
|
|
|
if (left_override != 0.0f) {
|
|
|
|
printf(
|
|
|
|
"Overriding left eye angle_left with %f radians (%i°), "
|
|
|
|
"and right eye angle_right with %f radians (%i°)\n",
|
|
|
|
left_override, radtodeg_for_display(left_override),
|
|
|
|
-left_override, radtodeg_for_display(-left_override));
|
2019-05-09 10:54:48 +00:00
|
|
|
dev->hmd->views[0].fov.angle_left = left_override;
|
|
|
|
dev->hmd->views[1].fov.angle_right = -left_override;
|
2019-03-18 05:52:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const float right_override = debug_get_float_option_lfov_right();
|
|
|
|
if (right_override != 0.0f) {
|
|
|
|
printf(
|
|
|
|
"Overriding left eye angle_right with %f radians (%i°), "
|
|
|
|
"and right eye angle_left with %f radians (%i°)\n",
|
|
|
|
right_override, radtodeg_for_display(right_override),
|
|
|
|
-right_override, radtodeg_for_display(-right_override));
|
2019-05-09 10:54:48 +00:00
|
|
|
dev->hmd->views[0].fov.angle_right = right_override;
|
|
|
|
dev->hmd->views[1].fov.angle_left = -right_override;
|
2019-03-18 05:52:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const float up_override = debug_get_float_option_lfov_up();
|
|
|
|
if (up_override != 0.0f) {
|
|
|
|
printf("Overriding both eyes angle_up with %f radians (%i°)\n",
|
|
|
|
up_override, radtodeg_for_display(up_override));
|
2019-05-09 10:54:48 +00:00
|
|
|
dev->hmd->views[0].fov.angle_up = up_override;
|
|
|
|
dev->hmd->views[1].fov.angle_up = up_override;
|
2019-03-18 05:52:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const float down_override = debug_get_float_option_lfov_down();
|
|
|
|
if (down_override != 0.0f) {
|
|
|
|
printf(
|
|
|
|
"Overriding both eyes angle_down with %f radians (%i°)\n",
|
|
|
|
down_override, radtodeg_for_display(down_override));
|
2019-05-09 10:54:48 +00:00
|
|
|
dev->hmd->views[0].fov.angle_down = down_override;
|
|
|
|
dev->hmd->views[1].fov.angle_down = down_override;
|
2019-03-18 05:52:32 +00:00
|
|
|
}
|
|
|
|
|
2019-08-19 17:37:50 +00:00
|
|
|
|
|
|
|
U_ZERO(&inst->extensions);
|
2019-03-23 01:11:14 +00:00
|
|
|
for (uint32_t i = 0; i < createInfo->enabledExtensionCount; ++i) {
|
2019-08-19 17:37:50 +00:00
|
|
|
|
|
|
|
#define ENABLE_EXT(mixed_case, all_caps) \
|
|
|
|
if (strcmp(createInfo->enabledExtensionNames[i], \
|
|
|
|
XR_##all_caps##_EXTENSION_NAME) == 0) { \
|
|
|
|
inst->extensions.mixed_case = true; \
|
|
|
|
continue; \
|
|
|
|
}
|
|
|
|
OXR_EXTENSION_SUPPORT_GENERATE(ENABLE_EXT)
|
|
|
|
// assert(false &&
|
|
|
|
// "Should not be reached - oxr_xrCreateInstance should "
|
|
|
|
// "have failed on unrecognized extension.");
|
2019-03-23 01:11:14 +00:00
|
|
|
}
|
|
|
|
|
2020-08-06 13:05:27 +00:00
|
|
|
// Create the compositor, if we are not headless.
|
|
|
|
if (!inst->extensions.MND_headless) {
|
|
|
|
xret = xrt_instance_create_native_compositor(inst->xinst, dev,
|
|
|
|
&sys->xcn);
|
|
|
|
if (ret < 0 || sys->xcn == NULL) {
|
|
|
|
ret = oxr_error(
|
|
|
|
log, XR_ERROR_INITIALIZATION_FAILED,
|
|
|
|
"Failed to create a native compositor '%i'", xret);
|
|
|
|
oxr_instance_destroy(log, &inst->handle);
|
|
|
|
return ret;
|
|
|
|
}
|
2020-08-26 16:45:35 +00:00
|
|
|
|
|
|
|
// Make sure that the compositor we were given can do all the
|
|
|
|
// things the build config promised.
|
|
|
|
#define CHECK_LAYER_TYPE(NAME, MEMBER_NAME) \
|
|
|
|
do { \
|
|
|
|
if (sys->xcn->base.MEMBER_NAME == NULL) { \
|
|
|
|
ret = oxr_error(log, XR_ERROR_INITIALIZATION_FAILED, \
|
|
|
|
"Logic error: build config " \
|
|
|
|
"advertised support for " NAME \
|
|
|
|
" but compositor does not " \
|
|
|
|
"implement " #MEMBER_NAME); \
|
|
|
|
oxr_instance_destroy(log, &inst->handle); \
|
|
|
|
assert(false && \
|
|
|
|
"Build configured with unsupported layers"); \
|
|
|
|
return ret; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
// Keep this list in sync with types in xrt_config_build.h
|
|
|
|
#ifdef XRT_FEATURE_OPENXR_LAYER_CUBE
|
|
|
|
CHECK_LAYER_TYPE("cube layers", layer_cube);
|
|
|
|
#endif
|
|
|
|
#ifdef XRT_FEATURE_OPENXR_LAYER_CYLINDER
|
|
|
|
CHECK_LAYER_TYPE("cylinder layers", layer_cylinder);
|
|
|
|
#endif
|
|
|
|
#ifdef XRT_FEATURE_OPENXR_LAYER_DEPTH
|
|
|
|
CHECK_LAYER_TYPE("projection layers with depth images",
|
|
|
|
layer_stereo_projection_depth);
|
|
|
|
#endif
|
|
|
|
#ifdef XRT_FEATURE_OPENXR_LAYER_EQUIRECT
|
|
|
|
CHECK_LAYER_TYPE("equirect layers", layer_equirect);
|
|
|
|
#endif
|
|
|
|
#undef CHECK_LAYER_TYPE
|
2020-08-06 13:05:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = oxr_system_fill_in(log, inst, 1, &inst->system);
|
|
|
|
if (ret != XR_SUCCESS) {
|
|
|
|
oxr_instance_destroy(log, &inst->handle);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
inst->timekeeping = time_state_create();
|
|
|
|
|
|
|
|
|
2019-03-18 05:52:32 +00:00
|
|
|
//! @todo check if this (and other creates) failed?
|
|
|
|
|
2019-08-31 11:49:04 +00:00
|
|
|
u_var_add_root((void *)inst, "XrInstance", true);
|
|
|
|
|
2019-10-10 14:36:05 +00:00
|
|
|
/* ---- HACK ---- */
|
2020-04-10 09:53:27 +00:00
|
|
|
oxr_sdl2_hack_start(inst->hack, inst->xinst);
|
2019-10-10 14:36:05 +00:00
|
|
|
/* ---- HACK ---- */
|
|
|
|
|
2019-03-18 05:52:32 +00:00
|
|
|
*out_instance = inst;
|
|
|
|
|
|
|
|
return XR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_instance_get_properties(struct oxr_logger *log,
|
|
|
|
struct oxr_instance *inst,
|
|
|
|
XrInstanceProperties *instanceProperties)
|
|
|
|
{
|
2019-08-01 06:34:33 +00:00
|
|
|
instanceProperties->runtimeVersion = XR_MAKE_VERSION(0, 1, 42);
|
2020-10-20 16:43:11 +00:00
|
|
|
snprintf(instanceProperties->runtimeName, XR_MAX_RUNTIME_NAME_SIZE - 1,
|
|
|
|
"Monado(XRT) by Collabora et al '%s'", u_git_tag);
|
2019-03-18 05:52:32 +00:00
|
|
|
|
|
|
|
return XR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef XR_USE_TIMESPEC
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_instance_convert_time_to_timespec(struct oxr_logger *log,
|
|
|
|
struct oxr_instance *inst,
|
|
|
|
XrTime time,
|
|
|
|
struct timespec *timespecTime)
|
|
|
|
{
|
|
|
|
time_state_to_timespec(inst->timekeeping, time, timespecTime);
|
|
|
|
return XR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_instance_convert_timespec_to_time(struct oxr_logger *log,
|
|
|
|
struct oxr_instance *inst,
|
|
|
|
const struct timespec *timespecTime,
|
|
|
|
XrTime *time)
|
|
|
|
{
|
|
|
|
*time = time_state_from_timespec(inst->timekeeping, timespecTime);
|
|
|
|
return XR_SUCCESS;
|
|
|
|
}
|
|
|
|
#endif // XR_USE_TIMESPEC
|