st/oxr: Implement xrGetReferenceSpaceBoundsRect

This commit is contained in:
Yu Li 2024-03-21 15:03:32 +08:00 committed by Simon Zeni
parent 143ff5a0ac
commit 6f35a3a51d
4 changed files with 45 additions and 5 deletions

View file

@ -155,6 +155,7 @@ oxr_xrGetReferenceSpaceBoundsRect(XrSession session, XrReferenceSpaceType refere
struct oxr_session *sess;
struct oxr_logger log;
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess, "xrGetReferenceSpaceBoundsRect");
OXR_VERIFY_SESSION_NOT_LOST(&log, sess);
OXR_VERIFY_ARG_NOT_NULL(&log, bounds);
ret = is_reference_space_type_valid(&log, sess->sys, "referenceSpaceType", referenceSpaceType);
@ -167,11 +168,7 @@ oxr_xrGetReferenceSpaceBoundsRect(XrSession session, XrReferenceSpaceType refere
return ret;
}
bounds->width = 0.0;
bounds->height = 0.0;
// Silently return that the bounds aren't available.
return XR_SPACE_BOUNDS_UNAVAILABLE;
return oxr_space_get_reference_bounds_rect(&log, sess, referenceSpaceType, bounds);
}
XRAPI_ATTR XrResult XRAPI_CALL

View file

@ -136,6 +136,23 @@ oxr_ref_space_to_xrt(enum oxr_space_type space_type)
return XRT_SPACE_REFERENCE_TYPE_INVALID;
}
static inline enum xrt_reference_space_type
xr_ref_space_to_xrt(XrReferenceSpaceType space_type)
{
switch (space_type) {
case XR_REFERENCE_SPACE_TYPE_VIEW: return XRT_SPACE_REFERENCE_TYPE_VIEW;
case XR_REFERENCE_SPACE_TYPE_LOCAL: return XRT_SPACE_REFERENCE_TYPE_LOCAL;
case XR_REFERENCE_SPACE_TYPE_LOCAL_FLOOR_EXT: return XRT_SPACE_REFERENCE_TYPE_LOCAL_FLOOR;
case XR_REFERENCE_SPACE_TYPE_STAGE: return XRT_SPACE_REFERENCE_TYPE_STAGE;
case XR_REFERENCE_SPACE_TYPE_UNBOUNDED_MSFT: return XRT_SPACE_REFERENCE_TYPE_UNBOUNDED;
case XR_REFERENCE_SPACE_TYPE_COMBINED_EYE_VARJO: return XRT_SPACE_REFERENCE_TYPE_INVALID;
case XR_REFERENCE_SPACE_TYPE_LOCALIZATION_MAP_ML: return XRT_SPACE_REFERENCE_TYPE_INVALID;
case XR_REFERENCE_SPACE_TYPE_MAX_ENUM: return XRT_SPACE_REFERENCE_TYPE_INVALID;
}
return XRT_SPACE_REFERENCE_TYPE_INVALID;
}
/*
*

View file

@ -829,6 +829,12 @@ oxr_space_action_create(struct oxr_logger *log,
const XrActionSpaceCreateInfo *createInfo,
struct oxr_space **out_space);
XrResult
oxr_space_get_reference_bounds_rect(struct oxr_logger *log,
struct oxr_session *sess,
XrReferenceSpaceType referenceSpaceType,
XrExtent2Df *bounds);
XrResult
oxr_space_reference_create(struct oxr_logger *log,
struct oxr_session *sess,

View file

@ -23,6 +23,7 @@
#include "oxr_chain.h"
#include "oxr_pretty_print.h"
#include "oxr_conversions.h"
#include "oxr_xret.h"
#include <stdio.h>
#include <stdlib.h>
@ -161,6 +162,25 @@ oxr_space_action_create(struct oxr_logger *log,
return XR_SUCCESS;
}
XrResult
oxr_space_get_reference_bounds_rect(struct oxr_logger *log,
struct oxr_session *sess,
XrReferenceSpaceType referenceSpaceType,
XrExtent2Df *bounds)
{
struct xrt_compositor *xc = &sess->xcn->base;
enum xrt_reference_space_type reference_space_type = xr_ref_space_to_xrt(referenceSpaceType);
xrt_result_t xret = xrt_comp_get_reference_bounds_rect(xc, reference_space_type, (struct xrt_vec2 *)bounds);
if (xret == XRT_ERROR_COMPOSITOR_FUNCTION_NOT_IMPLEMENTED || xret == XRT_SPACE_BOUNDS_UNAVAILABLE) {
return XR_SPACE_BOUNDS_UNAVAILABLE;
}
OXR_CHECK_XRET(log, sess, xret, oxr_space_get_reference_bounds_rect);
return oxr_session_success_result(sess);
}
XrResult
oxr_space_reference_create(struct oxr_logger *log,
struct oxr_session *sess,