Monado OpenXR Runtime
oxr_session.c File Reference

Holds session related functions. More...

#include "oxr_frame_sync.h"
#include "xrt/xrt_device.h"
#include "xrt/xrt_session.h"
#include "xrt/xrt_config_build.h"
#include "xrt/xrt_config_have.h"
#include "xrt/xrt_gfx_xlib.h"
#include "os/os_time.h"
#include "util/u_debug.h"
#include "util/u_misc.h"
#include "util/u_time.h"
#include "util/u_visibility_mask.h"
#include "util/u_verify.h"
#include "math/m_api.h"
#include "math/m_mathinclude.h"
#include "math/m_space.h"
#include "oxr_objects.h"
#include "oxr_logger.h"
#include "oxr_two_call.h"
#include "oxr_handle.h"
#include "oxr_chain.h"
#include "oxr_api_verify.h"
#include "oxr_pretty_print.h"
#include "oxr_conversions.h"
#include "oxr_xret.h"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
Include dependency graph for oxr_session.c:

Macros

#define OXR_CHECK_XSYSC(LOG, SYS)
 
#define OXR_CREATE_XRT_SESSION_AND_NATIVE_COMPOSITOR(LOG, XSI, SESS)
 
#define OXR_SESSION_ALLOCATE_AND_INIT(LOG, SYS, GFX_TYPE, OUT)
 

Functions

static bool should_render (XrSessionState state)
 
static XRT_MAYBE_UNUSED const char * to_string (XrSessionState state)
 
static XrResult handle_reference_space_change_pending (struct oxr_logger *log, struct oxr_session *sess, struct xrt_session_event_reference_space_change_pending *ref_change)
 
void oxr_session_change_state (struct oxr_logger *log, struct oxr_session *sess, XrSessionState state, XrTime time)
 Change the state of the session, queues a event. More...
 
XrResult oxr_session_enumerate_formats (struct oxr_logger *log, struct oxr_session *sess, uint32_t formatCapacityInput, uint32_t *formatCountOutput, int64_t *formats)
 
XrResult oxr_session_begin (struct oxr_logger *log, struct oxr_session *sess, const XrSessionBeginInfo *beginInfo)
 
XrResult oxr_session_end (struct oxr_logger *log, struct oxr_session *sess)
 
XrResult oxr_session_request_exit (struct oxr_logger *log, struct oxr_session *sess)
 
XrResult oxr_session_poll (struct oxr_logger *log, struct oxr_session *sess)
 
static XrViewStateFlags xrt_to_view_state_flags (enum xrt_space_relation_flags flags)
 
static void adjust_fov (const struct xrt_fov *original_fov, const struct xrt_quat *original_rotation, struct xrt_fov *adjusted_fov)
 
XrResult oxr_session_locate_views (struct oxr_logger *log, struct oxr_session *sess, const XrViewLocateInfo *viewLocateInfo, XrViewState *viewState, uint32_t viewCapacityInput, uint32_t *viewCountOutput, XrView *views)
 
static double ns_to_ms (int64_t ns)
 
static double ts_ms (struct oxr_session *sess)
 
static XrResult do_wait_frame_and_checks (struct oxr_logger *log, struct oxr_session *sess, int64_t *out_frame_id, int64_t *out_predicted_display_time, int64_t *out_predicted_display_period, XrTime *out_converted_time)
 
XrResult oxr_session_frame_wait (struct oxr_logger *log, struct oxr_session *sess, XrFrameState *frameState)
 
XrResult oxr_session_frame_begin (struct oxr_logger *log, struct oxr_session *sess)
 
static XrResult oxr_session_destroy (struct oxr_logger *log, struct oxr_handle_base *hb)
 
static XrResult oxr_session_allocate_and_init (struct oxr_logger *log, struct oxr_system *sys, enum oxr_session_graphics_ext gfx_ext, struct oxr_session **out_session)
 
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)
 
XrResult oxr_session_create (struct oxr_logger *log, struct oxr_system *sys, const XrSessionCreateInfo *createInfo, struct oxr_session **out_session)
 
void xrt_to_xr_pose (struct xrt_pose *xrt_pose, XrPosef *xr_pose)
 
XrResult oxr_session_hand_joints (struct oxr_logger *log, struct oxr_hand_tracker *hand_tracker, const XrHandJointsLocateInfoEXT *locateInfo, XrHandJointLocationsEXT *locations)
 
XrResult oxr_get_base_body_pose (struct oxr_logger *log, const struct xrt_body_joint_set *body_joint_set, struct oxr_space *base_spc, struct xrt_device *body_xdev, XrTime at_time, struct xrt_space_relation *out_base_body)
 
static enum xrt_output_name xr_hand_to_force_feedback_output (XrHandEXT hand)
 
XrResult oxr_session_apply_force_feedback (struct oxr_logger *log, struct oxr_hand_tracker *hand_tracker, const XrForceFeedbackCurlApplyLocationsMNDX *locations)
 

Detailed Description

Macro Definition Documentation

◆ OXR_CHECK_XSYSC

#define OXR_CHECK_XSYSC (   LOG,
  SYS 
)
Value:
do { \
if (sys->xsysc == NULL) { \
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
" Can not use graphics bindings when have asked to not create graphics"); \
} \
} while (false)
XrResult oxr_error(struct oxr_logger *logger, XrResult result, const char *fmt,...)
Definition: oxr_logger.c:203

◆ OXR_CREATE_XRT_SESSION_AND_NATIVE_COMPOSITOR

#define OXR_CREATE_XRT_SESSION_AND_NATIVE_COMPOSITOR (   LOG,
  XSI,
  SESS 
)
Value:
do { \
if ((SESS)->sys->xsysc == NULL) { \
return oxr_error((LOG), XR_ERROR_RUNTIME_FAILURE, \
"The system compositor wasn't created, can't create native compositor!"); \
} \
xrt_result_t xret = xrt_system_create_session((SESS)->sys->xsys, (XSI), &(SESS)->xs, &(SESS)->xcn); \
return oxr_error((LOG), XR_ERROR_LIMIT_REACHED, "Per instance multi-session not supported."); \
} \
if (xret != XRT_SUCCESS) { \
return oxr_error((LOG), XR_ERROR_RUNTIME_FAILURE, \
"Failed to create xrt_session and xrt_compositor_native! '%i'", xret); \
} \
if ((SESS)->sys->xsysc->xmcc != NULL) { \
xrt_syscomp_set_state((SESS)->sys->xsysc, &(SESS)->xcn->base, true, true); \
xrt_syscomp_set_z_order((SESS)->sys->xsysc, &(SESS)->xcn->base, 0); \
} \
} while (false)
@ XRT_ERROR_MULTI_SESSION_NOT_IMPLEMENTED
Multiple not supported on this layer level (IPC, compositor).
Definition: xrt_results.h:102
@ XRT_SUCCESS
The operation succeeded.
Definition: xrt_results.h:26
static xrt_result_t xrt_system_create_session(struct xrt_system *xsys, const struct xrt_session_info *xsi, struct xrt_session **out_xs, struct xrt_compositor_native **out_xcn)
Create a xrt_session and optionally a xrt_compositor_native for this system.
Definition: xrt_system.h:98

◆ OXR_SESSION_ALLOCATE_AND_INIT

#define OXR_SESSION_ALLOCATE_AND_INIT (   LOG,
  SYS,
  GFX_TYPE,
  OUT 
)
Value:
do { \
XrResult ret = oxr_session_allocate_and_init(LOG, SYS, GFX_TYPE, &OUT); \
if (ret != XR_SUCCESS) { \
return ret; \
} \
} while (0)

Function Documentation

◆ handle_reference_space_change_pending()

static XrResult handle_reference_space_change_pending ( struct oxr_logger log,
struct oxr_session sess,
struct xrt_session_event_reference_space_change_pending ref_change 
)
static
Todo:
properly handle return (not done yet because requires larger rewrite),