The open source OpenXR runtime

st/oxr: add quirk to use LOCAL_FLOOR for STAGE

Some applications may request STAGE reference space but lack any
mechanism to recenter.

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2588>

authored by

Patrick Nicolas and committed by
Marge Bot
b129e4b4 eaa3797e

+48 -13
+3
src/xrt/state_trackers/oxr/oxr_instance.c
··· 51 51 DEBUG_GET_ONCE_BOOL_OPTION(debug_bindings, "OXR_DEBUG_BINDINGS", false) 52 52 DEBUG_GET_ONCE_BOOL_OPTION(lifecycle_verbose, "OXR_LIFECYCLE_VERBOSE", false) 53 53 DEBUG_GET_ONCE_TRISTATE_OPTION(parallel_views, "OXR_PARALLEL_VIEWS") 54 + DEBUG_GET_ONCE_BOOL_OPTION(map_stage_to_local_floor, "OXR_RECENTER_STAGE", false) 54 55 55 56 56 57 #ifdef XRT_OS_ANDROID ··· 218 219 } else if (parallel_view == DEBUG_TRISTATE_ON) { 219 220 inst->quirks.parallel_views = true; 220 221 } 222 + 223 + inst->quirks.map_stage_to_local_floor = debug_get_bool_option_map_stage_to_local_floor(); 221 224 } 222 225 223 226 XrResult
+3
src/xrt/state_trackers/oxr/oxr_objects.h
··· 1760 1760 1761 1761 //! For applications that rely on views being parallel, notably some OpenVR games with OpenComposite. 1762 1762 bool parallel_views; 1763 + 1764 + //! For applications that use stage and don't offer recentering. 1765 + bool map_stage_to_local_floor; 1763 1766 } quirks; 1764 1767 1765 1768 //! Debug messengers
+37 -12
src/xrt/state_trackers/oxr/oxr_session.c
··· 94 94 } 95 95 96 96 static XrResult 97 + emit_reference_space_change_pending(struct oxr_logger *log, 98 + struct oxr_session *sess, 99 + struct xrt_session_event_reference_space_change_pending *ref_change, 100 + XrReferenceSpaceType type) 101 + { 102 + struct oxr_instance *inst = sess->sys->inst; 103 + XrTime changeTime = time_state_monotonic_to_ts_ns(inst->timekeeping, ref_change->timestamp_ns); 104 + const XrPosef *poseInPreviousSpace = (XrPosef *)&ref_change->pose_in_previous_space; 105 + bool poseValid = ref_change->pose_valid; 106 + 107 + //! @todo properly handle return (not done yet because requires larger rewrite), 108 + oxr_event_push_XrEventDataReferenceSpaceChangePending( // 109 + log, // log 110 + sess, // sess 111 + type, // referenceSpaceType 112 + changeTime, // changeTime 113 + poseValid, // poseValid 114 + poseInPreviousSpace); // poseInPreviousSpace 115 + 116 + return XR_SUCCESS; 117 + } 118 + 119 + static XrResult 97 120 handle_reference_space_change_pending(struct oxr_logger *log, 98 121 struct oxr_session *sess, 99 122 struct xrt_session_event_reference_space_change_pending *ref_change) ··· 101 124 struct oxr_instance *inst = sess->sys->inst; 102 125 XrReferenceSpaceType type = XR_REFERENCE_SPACE_TYPE_MAX_ENUM; 103 126 127 + if (inst->quirks.map_stage_to_local_floor) { 128 + /* When stage is mapped to local_floor: 129 + * ignore stage changes 130 + * for local_floor changes, send a duplicate envent for stage 131 + * */ 132 + switch (ref_change->ref_type) { 133 + case XRT_SPACE_REFERENCE_TYPE_STAGE: return XR_SUCCESS; 134 + case XRT_SPACE_REFERENCE_TYPE_LOCAL_FLOOR: 135 + emit_reference_space_change_pending(log, sess, ref_change, XR_REFERENCE_SPACE_TYPE_STAGE); 136 + break; 137 + default: break; 138 + } 139 + } 104 140 105 141 switch (ref_change->ref_type) { 106 142 case XRT_SPACE_REFERENCE_TYPE_VIEW: type = XR_REFERENCE_SPACE_TYPE_VIEW; break; ··· 138 174 return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, "invalid reference space type"); 139 175 } 140 176 141 - XrTime changeTime = time_state_monotonic_to_ts_ns(inst->timekeeping, ref_change->timestamp_ns); 142 - const XrPosef *poseInPreviousSpace = (XrPosef *)&ref_change->pose_in_previous_space; 143 - bool poseValid = ref_change->pose_valid; 144 - 145 - //! @todo properly handle return (not done yet because requires larger rewrite), 146 - oxr_event_push_XrEventDataReferenceSpaceChangePending( // 147 - log, // log 148 - sess, // sess 149 - type, // referenceSpaceType 150 - changeTime, // changeTime 151 - poseValid, // poseValid 152 - poseInPreviousSpace); // poseInPreviousSpace 177 + emit_reference_space_change_pending(log, sess, ref_change, type); 153 178 154 179 return XR_SUCCESS; 155 180 }
+5 -1
src/xrt/state_trackers/oxr/oxr_space.c
··· 101 101 case OXR_SPACE_TYPE_REFERENCE_VIEW: xspace = spc->sess->sys->xso->semantic.view; break; 102 102 case OXR_SPACE_TYPE_REFERENCE_LOCAL: xspace = spc->sess->sys->xso->semantic.local; break; 103 103 case OXR_SPACE_TYPE_REFERENCE_LOCAL_FLOOR: xspace = spc->sess->sys->xso->semantic.local_floor; break; 104 - case OXR_SPACE_TYPE_REFERENCE_STAGE: xspace = spc->sess->sys->xso->semantic.stage; break; 104 + case OXR_SPACE_TYPE_REFERENCE_STAGE: 105 + xspace = spc->sess->sys->inst->quirks.map_stage_to_local_floor 106 + ? spc->sess->sys->xso->semantic.local_floor 107 + : spc->sess->sys->xso->semantic.stage; 108 + break; 105 109 case OXR_SPACE_TYPE_REFERENCE_UNBOUNDED_MSFT: xspace = spc->sess->sys->xso->semantic.unbounded; break; 106 110 case OXR_SPACE_TYPE_REFERENCE_COMBINED_EYE_VARJO: xspace = NULL; break; 107 111 case OXR_SPACE_TYPE_REFERENCE_LOCALIZATION_MAP_ML: xspace = NULL; break;