The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

st/oxr: Support XrEventDataReferenceSpaceChangePending events

+119
+33
src/xrt/state_trackers/oxr/oxr_event.c
··· 130 130 XrEventDataInteractionProfileChanged *changed = (XrEventDataInteractionProfileChanged *)type; 131 131 return changed->session == session; 132 132 } 133 + case XR_TYPE_EVENT_DATA_REFERENCE_SPACE_CHANGE_PENDING: { 134 + XrEventDataReferenceSpaceChangePending *pending = (XrEventDataReferenceSpaceChangePending *)type; 135 + return pending->session == session; 136 + } 133 137 default: return false; 134 138 } 135 139 } ··· 178 182 179 183 changed->type = XR_TYPE_EVENT_DATA_INTERACTION_PROFILE_CHANGED; 180 184 changed->session = oxr_session_to_openxr(sess); 185 + 186 + lock(inst); 187 + push(inst, event); 188 + unlock(inst); 189 + 190 + return XR_SUCCESS; 191 + } 192 + 193 + XrResult 194 + oxr_event_push_XrEventDataReferenceSpaceChangePending(struct oxr_logger *log, 195 + struct oxr_session *sess, 196 + XrReferenceSpaceType referenceSpaceType, 197 + XrTime changeTime, 198 + XrBool32 poseValid, 199 + const XrPosef *poseInPreviousSpace) 200 + { 201 + struct oxr_instance *inst = sess->sys->inst; 202 + XrEventDataReferenceSpaceChangePending *pending; 203 + struct oxr_event *event = NULL; 204 + 205 + ALLOC(log, inst, &event, &pending); 206 + 207 + pending->type = XR_TYPE_EVENT_DATA_REFERENCE_SPACE_CHANGE_PENDING; 208 + pending->session = oxr_session_to_openxr(sess); 209 + pending->referenceSpaceType = referenceSpaceType; 210 + pending->changeTime = changeTime; 211 + pending->poseValid = poseValid; 212 + pending->poseInPreviousSpace = *poseInPreviousSpace; 213 + event->result = XR_SUCCESS; 181 214 182 215 lock(inst); 183 216 push(inst, event);
+8
src/xrt/state_trackers/oxr/oxr_objects.h
··· 944 944 XrResult 945 945 oxr_event_push_XrEventDataInteractionProfileChanged(struct oxr_logger *log, struct oxr_session *sess); 946 946 947 + XrResult 948 + oxr_event_push_XrEventDataReferenceSpaceChangePending(struct oxr_logger *log, 949 + struct oxr_session *sess, 950 + XrReferenceSpaceType referenceSpaceType, 951 + XrTime changeTime, 952 + XrBool32 poseValid, 953 + const XrPosef *poseInPreviousSpace); 954 + 947 955 #ifdef OXR_HAVE_FB_display_refresh_rate 948 956 XrResult 949 957 oxr_event_push_XrEventDataDisplayRefreshRateChangedFB(struct oxr_logger *log,
+78
src/xrt/state_trackers/oxr/oxr_session.c
··· 55 55 DEBUG_GET_ONCE_NUM_OPTION(wait_frame_sleep, "OXR_DEBUG_WAIT_FRAME_EXTRA_SLEEP_MS", 0) 56 56 DEBUG_GET_ONCE_BOOL_OPTION(frame_timing_spew, "OXR_FRAME_TIMING_SPEW", false) 57 57 58 + 59 + /* 60 + * 61 + * Helpers. 62 + * 63 + */ 64 + 58 65 static bool 59 66 should_render(XrSessionState state) 60 67 { ··· 83 90 default: return ""; 84 91 } 85 92 } 93 + 94 + static XrResult 95 + handle_reference_space_change_pending(struct oxr_logger *log, 96 + struct oxr_session *sess, 97 + struct xrt_session_event_reference_space_change_pending *ref_change) 98 + { 99 + struct oxr_instance *inst = sess->sys->inst; 100 + XrReferenceSpaceType type = XR_REFERENCE_SPACE_TYPE_MAX_ENUM; 101 + 102 + 103 + switch (ref_change->ref_type) { 104 + case XRT_SPACE_REFERENCE_TYPE_VIEW: type = XR_REFERENCE_SPACE_TYPE_VIEW; break; 105 + case XRT_SPACE_REFERENCE_TYPE_LOCAL: type = XR_REFERENCE_SPACE_TYPE_LOCAL; break; 106 + case XRT_SPACE_REFERENCE_TYPE_STAGE: type = XR_REFERENCE_SPACE_TYPE_STAGE; break; 107 + case XRT_SPACE_REFERENCE_TYPE_LOCAL_FLOOR: 108 + #ifdef OXR_HAVE_EXT_local_floor 109 + if (inst->extensions.EXT_local_floor) { 110 + type = XR_REFERENCE_SPACE_TYPE_LOCAL_FLOOR_EXT; 111 + break; 112 + } else { 113 + // Silently ignored, extension not enabled. 114 + return XR_SUCCESS; 115 + } 116 + #else 117 + // Silently ignored, not compiled with this extension supported. 118 + return XR_SUCCESS; 119 + #endif 120 + case XRT_SPACE_REFERENCE_TYPE_UNBOUNDED: 121 + #ifdef OXR_HAVE_MSFT_unbounded_reference_space 122 + if (inst->extensions.MSFT_unbounded_reference_space) { 123 + type = XR_REFERENCE_SPACE_TYPE_UNBOUNDED_MSFT; 124 + break; 125 + } else { 126 + // Silently ignored, extension not enabled. 127 + return XR_SUCCESS; 128 + } 129 + #else 130 + // Silently ignored, not compiled with this extension supported. 131 + return XR_SUCCESS; 132 + #endif 133 + } 134 + 135 + if (type == XR_REFERENCE_SPACE_TYPE_MAX_ENUM) { 136 + return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, "invalid reference space type"); 137 + } 138 + 139 + XrTime changeTime = time_state_monotonic_to_ts_ns(inst->timekeeping, ref_change->timestamp_ns); 140 + const XrPosef *poseInPreviousSpace = (XrPosef *)&ref_change->pose_in_previous_space; 141 + bool poseValid = ref_change->pose_valid; 142 + 143 + //! @todo properly handle return (not done yet because requires larger rewrite), 144 + oxr_event_push_XrEventDataReferenceSpaceChangePending( // 145 + log, // log 146 + sess, // sess 147 + type, // referenceSpaceType 148 + changeTime, // changeTime 149 + poseValid, // poseValid 150 + poseInPreviousSpace); // poseInPreviousSpace 151 + 152 + return XR_SUCCESS; 153 + } 154 + 155 + 156 + /* 157 + * 158 + * 'Exported' functions. 159 + * 160 + */ 86 161 87 162 void 88 163 oxr_session_change_state(struct oxr_logger *log, struct oxr_session *sess, XrSessionState state, XrTime time) ··· 284 359 xse.display.from_display_refresh_rate_hz, // 285 360 xse.display.to_display_refresh_rate_hz); // 286 361 #endif 362 + break; 363 + case XRT_SESSION_EVENT_REFERENCE_SPACE_CHANGE_PENDING: 364 + handle_reference_space_change_pending(log, sess, &xse.ref_change); 287 365 break; 288 366 default: U_LOG_W("unhandled event type! %d", xse.type); break; 289 367 }