st/oxr: support XrEventDataVisibilityMaskChangedKHR for visibility mask

This commit is contained in:
Qichang Sun 2024-05-21 16:42:33 +08:00 committed by Qichang Sun
parent 92a18718ae
commit 7fd2a8cce8
4 changed files with 50 additions and 0 deletions

View file

@ -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;
};
/*!

View file

@ -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)
{

View file

@ -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

View file

@ -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;
}
}