diff --git a/src/xrt/include/xrt/xrt_session.h b/src/xrt/include/xrt/xrt_session.h index df4fe8f1f..aed5321aa 100644 --- a/src/xrt/include/xrt/xrt_session.h +++ b/src/xrt/include/xrt/xrt_session.h @@ -61,6 +61,9 @@ enum xrt_session_event_type //! The passthrough state of the session has changed XRT_SESSION_EVENT_PASSTHRU_STATE_CHANGE = 8, + + // ! The visibility mask of given view has changed + XRT_SESSION_EVENT_VISIBILITY_MASK_CHANGE = 9 }; /*! @@ -164,6 +167,15 @@ struct xrt_session_event_passthrough_state_change enum xrt_passthrough_state state; }; +/*! + * Visibility mask changed event + */ +struct xrt_session_event_visibility_mask_change +{ + enum xrt_session_event_type type; + uint32_t view_index; +}; + /*! * Union of all session events, used to return multiple events through one call. * Each event struct must start with a @ref xrt_session_event_type field. @@ -181,6 +193,7 @@ union xrt_session_event { struct xrt_session_event_reference_space_change_pending ref_change; struct xrt_session_event_perf_change performance; struct xrt_session_event_passthrough_state_change passthru; + struct xrt_session_event_visibility_mask_change mask_change; }; /*! diff --git a/src/xrt/state_trackers/oxr/oxr_event.c b/src/xrt/state_trackers/oxr/oxr_event.c index d9b3dc8dc..5e79430c9 100644 --- a/src/xrt/state_trackers/oxr/oxr_event.c +++ b/src/xrt/state_trackers/oxr/oxr_event.c @@ -318,6 +318,31 @@ oxr_event_push_XrEventDataPassthroughStateChangedFB(struct oxr_logger *log, } #endif // OXR_HAVE_FB_passthrough +#ifdef OXR_HAVE_KHR_visibility_mask +XrResult +oxr_event_push_XrEventDataVisibilityMaskChangedKHR(struct oxr_logger *log, + struct oxr_session *sess, + XrViewConfigurationType viewConfigurationType, + uint32_t viewIndex) +{ + struct oxr_instance *inst = sess->sys->inst; + XrEventDataVisibilityMaskChangedKHR *changed; + struct oxr_event *event = NULL; + + ALLOC(log, inst, &event, &changed); + changed->type = XR_TYPE_EVENT_DATA_VISIBILITY_MASK_CHANGED_KHR; + changed->session = oxr_session_to_openxr(sess); + changed->viewConfigurationType = viewConfigurationType; + changed->viewIndex = viewIndex; + event->result = XR_SUCCESS; + lock(inst); + push(inst, event); + unlock(inst); + + return XR_SUCCESS; +} +#endif // OXR_HAVE_KHR_visibility_mask + XrResult oxr_event_remove_session_events(struct oxr_logger *log, struct oxr_session *sess) { diff --git a/src/xrt/state_trackers/oxr/oxr_objects.h b/src/xrt/state_trackers/oxr/oxr_objects.h index 9eb3485aa..9ee873756 100644 --- a/src/xrt/state_trackers/oxr/oxr_objects.h +++ b/src/xrt/state_trackers/oxr/oxr_objects.h @@ -824,6 +824,12 @@ oxr_session_get_visibility_mask(struct oxr_logger *log, XrVisibilityMaskTypeKHR visibilityMaskType, uint32_t viewIndex, XrVisibilityMaskKHR *visibilityMask); + +XrResult +oxr_event_push_XrEventDataVisibilityMaskChangedKHR(struct oxr_logger *log, + struct oxr_session *sess, + XrViewConfigurationType viewConfigurationType, + uint32_t viewIndex); #endif // OXR_HAVE_KHR_visibility_mask #ifdef OXR_HAVE_EXT_performance_settings diff --git a/src/xrt/state_trackers/oxr/oxr_session.c b/src/xrt/state_trackers/oxr/oxr_session.c index 09cc1cc22..dffadc1f6 100644 --- a/src/xrt/state_trackers/oxr/oxr_session.c +++ b/src/xrt/state_trackers/oxr/oxr_session.c @@ -403,6 +403,12 @@ oxr_session_poll(struct oxr_logger *log, struct oxr_session *sess) log, sess, xrt_to_passthrough_state_flags(xse.passthru.state)); #endif // OXR_HAVE_FB_passthrough break; + case XRT_SESSION_EVENT_VISIBILITY_MASK_CHANGE: +#ifdef OXR_HAVE_KHR_visibility_mask + oxr_event_push_XrEventDataVisibilityMaskChangedKHR(log, sess, sess->sys->view_config_type, + xse.mask_change.view_index); +#endif // OXR_HAVE_KHR_visibility_mask + break; default: U_LOG_W("unhandled event type! %d", xse.type); break; } }