oxr: mostly implement XR_SESSION_LOSS_PENDING

This is missing support for xrPollEvents, which needs to be handled
separately as it's not properly rigged up throughout Monado yet.
This commit is contained in:
Drew DeVault 2019-09-26 16:25:05 -04:00 committed by Jakob Bornecrantz
parent bffe802449
commit a736812f63
16 changed files with 83 additions and 46 deletions

View file

@ -112,6 +112,7 @@ oxr_xrGetCurrentInteractionProfile(
OXR_VERIFY_ARG_TYPE_AND_NULL(&log, interactionProfile,
XR_TYPE_INTERACTION_PROFILE_STATE);
/* XXX: How do we return XR_SESSION_LOSS_PENDING here? */
return oxr_action_get_current_interaction_profile(
&log, sess, topLevelUserPath, interactionProfile);
}

View file

@ -45,7 +45,7 @@ oxr_xrEnumerateInstanceExtensionProperties(const char *layerName,
OXR_TWO_CALL_HELPER(&log, propertyCapacityInput, propertyCountOutput,
properties, ARRAY_SIZE(extension_properties),
extension_properties);
extension_properties, XR_SUCCESS);
}
XrResult
@ -251,7 +251,7 @@ oxr_xrPathToString(XrInstance instance,
// null termination character (but a extra null byte is always
// reserved).
OXR_TWO_CALL_HELPER(&log, bufferCapacityInput, bufferCountOutput,
buffer, length + 1, str);
buffer, length + 1, str, XR_SUCCESS);
return XR_SUCCESS;
}

View file

@ -48,7 +48,7 @@ oxr_xrCreateActionSpace(XrSession session,
*space = oxr_space_to_openxr(spc);
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
static const XrReferenceSpaceType session_spaces[] = {
@ -69,7 +69,8 @@ oxr_xrEnumerateReferenceSpaces(XrSession session,
"xrEnumerateReferenceSpaces");
OXR_TWO_CALL_HELPER(&log, spaceCapacityInput, spaceCountOutput, spaces,
ARRAY_SIZE(session_spaces), session_spaces);
ARRAY_SIZE(session_spaces), session_spaces,
oxr_session_success_result(sess));
}
XrResult
@ -109,7 +110,7 @@ oxr_xrCreateReferenceSpace(XrSession session,
*out_space = oxr_space_to_openxr(spc);
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
XrResult

View file

@ -70,7 +70,7 @@ oxr_xrCreateSwapchain(XrSession session,
*out_swapchain = oxr_swapchain_to_openxr(sc);
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
XrResult

View file

@ -23,6 +23,7 @@ struct oxr_event
public:
struct oxr_event *next;
size_t length;
XrResult result;
public:
@ -100,6 +101,7 @@ oxr_event_alloc(struct oxr_logger *log,
event->next = NULL;
event->length = size;
event->result = XR_SUCCESS;
*out_event = event;
@ -123,6 +125,10 @@ oxr_event_push_XrEventDataSessionStateChanged(struct oxr_logger *log,
changed->state = state;
changed->time = time;
event->result = state == XR_SESSION_STATE_LOSS_PENDING
? XR_SESSION_LOSS_PENDING
: XR_SUCCESS;
lock(inst);
push(inst, event);
unlock(inst);
@ -146,5 +152,5 @@ oxr_poll_event(struct oxr_logger *log,
memcpy(eventData, event->ptr(), event->length);
free(event);
return XR_SUCCESS;
return event->result;
}

View file

@ -752,7 +752,7 @@ oxr_session_attach_action_sets(struct oxr_logger *log,
sess->actionsAttached = true;
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
XrResult
@ -809,8 +809,7 @@ oxr_action_sync_data(struct oxr_logger *log,
}
}
//! @todo Implement
return XR_SUCCESS;
return oxr_session_success_focused_result(sess);
}
@ -928,7 +927,7 @@ oxr_action_get_boolean(struct oxr_logger *log,
OXR_ACTION_GET_FILLER(bool);
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
XrResult
@ -957,7 +956,7 @@ oxr_action_get_vector1f(struct oxr_logger *log,
OXR_ACTION_GET_FILLER(vec1);
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
XrResult
@ -986,7 +985,7 @@ oxr_action_get_vector2f(struct oxr_logger *log,
OXR_ACTION_GET_FILLER(vec2);
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
XrResult
@ -1022,7 +1021,7 @@ oxr_action_get_pose(struct oxr_logger *log,
data->isActive |= src->gamepad.current.active;
}
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
@ -1067,7 +1066,7 @@ oxr_action_apply_haptic_feedback(struct oxr_logger *log,
oxr_session_get_source(sess, key, &src);
if (src == NULL) {
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
const XrHapticVibration *data = (const XrHapticVibration *)hapticEvent;
@ -1093,7 +1092,7 @@ oxr_action_apply_haptic_feedback(struct oxr_logger *log,
}
// clang-format on
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
XrResult
@ -1107,7 +1106,7 @@ oxr_action_stop_haptic_feedback(struct oxr_logger *log,
oxr_session_get_source(sess, key, &src);
if (src == NULL) {
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
// clang-format off
@ -1128,5 +1127,5 @@ oxr_action_stop_haptic_feedback(struct oxr_logger *log,
}
// clang-format on
return XR_SUCCESS;
return oxr_session_success_result(sess);
}

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Holds session related functions.
* @brief Holds instance related functions.
* @author Jakob Bornecrantz <jakob@collabora.com>
* @ingroup oxr_main
*/

View file

@ -950,6 +950,32 @@ struct oxr_session
struct oxr_swapchain **);
};
/*!
* Returns XR_SUCCESS or XR_SESSION_LOSS_PENDING as appropriate.
*/
XRT_MAYBE_UNUSED static inline XrResult
oxr_session_success_result(struct oxr_session *session)
{
switch (session->state) {
case XR_SESSION_STATE_LOSS_PENDING: return XR_SESSION_LOSS_PENDING;
default: return XR_SUCCESS;
}
}
/*!
* Returns XR_SUCCESS, XR_SESSION_LOSS_PENDING, or XR_SESSION_NOT_FOCUSED, as
* appropriate.
*/
XRT_MAYBE_UNUSED static inline XrResult
oxr_session_success_focused_result(struct oxr_session *session)
{
switch (session->state) {
case XR_SESSION_STATE_LOSS_PENDING: return XR_SESSION_LOSS_PENDING;
case XR_SESSION_STATE_FOCUSED: return XR_SUCCESS;
default: return XR_SESSION_NOT_FOCUSED;
}
}
/*!
* A single interaction profile.
*/

View file

@ -70,11 +70,12 @@ oxr_session_enumerate_formats(struct oxr_logger *log,
if (formatCountOutput != NULL) {
*formatCountOutput = 0;
}
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
OXR_TWO_CALL_HELPER(log, formatCapacityInput, formatCountOutput,
formats, xc->num_formats, xc->formats);
formats, xc->num_formats, xc->formats,
oxr_session_success_result(sess));
}
XrResult
@ -112,7 +113,7 @@ oxr_session_begin(struct oxr_logger *log,
sess->state = XR_SESSION_STATE_FOCUSED;
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
XrResult
@ -225,7 +226,7 @@ oxr_session_get_view_pose_at(struct oxr_logger *log,
pose->orientation = predicted;
}
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
void
@ -270,7 +271,7 @@ oxr_session_views(struct oxr_logger *log,
// Does this apply for all calls?
if (!baseSpc->is_reference) {
viewState->viewStateFlags = 0;
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
// Start two call handling.
@ -278,7 +279,7 @@ oxr_session_views(struct oxr_logger *log,
*viewCountOutput = num_views;
}
if (viewCapacityInput == 0) {
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
if (viewCapacityInput < num_views) {
return oxr_error(log, XR_ERROR_SIZE_INSUFFICIENT,
@ -338,7 +339,7 @@ oxr_session_views(struct oxr_logger *log,
viewState->viewStateFlags |= XR_VIEW_STATE_POSITION_VALID_BIT;
viewState->viewStateFlags |= XR_VIEW_STATE_ORIENTATION_VALID_BIT;
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
XrResult
@ -362,7 +363,7 @@ oxr_session_frame_wait(struct oxr_logger *log,
frameState->shouldRender = should_render(sess->state);
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
XrResult
@ -382,7 +383,7 @@ oxr_session_frame_begin(struct oxr_logger *log, struct oxr_session *sess)
xc->discard_frame(xc);
}
} else {
ret = XR_SUCCESS;
ret = oxr_session_success_result(sess);
sess->frame_started = true;
}
if (xc != NULL) {
@ -431,7 +432,7 @@ oxr_session_frame_end(struct oxr_logger *log,
if (xc == NULL) {
sess->frame_started = false;
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
/*
@ -442,7 +443,7 @@ oxr_session_frame_end(struct oxr_logger *log,
xc->discard_frame(xc);
sess->frame_started = false;
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
/*
@ -535,7 +536,7 @@ oxr_session_frame_end(struct oxr_logger *log,
sess->frame_started = false;
return XR_SUCCESS;
return oxr_session_success_result(sess);
}
static XrResult

View file

@ -376,5 +376,5 @@ oxr_space_locate(struct oxr_logger *log,
print_pose("\trelation->pose", (struct xrt_pose *)&location->pose);
return XR_SUCCESS;
return oxr_session_success_result(spc->sess);
}

View file

@ -47,7 +47,7 @@ oxr_swapchain_acquire_image(struct oxr_logger *log,
*out_index = index;
return XR_SUCCESS;
return oxr_session_success_result(sc->sess);
}
static XrResult
@ -67,7 +67,7 @@ oxr_swapchain_wait_image(struct oxr_logger *log,
" call to xsc->wait_image failed");
}
return XR_SUCCESS;
return oxr_session_success_result(sc->sess);
}
static XrResult
@ -90,7 +90,7 @@ oxr_swapchain_release_image(struct oxr_logger *log,
sc->released_index = sc->acquired_index;
sc->acquired_index = -1;
return XR_SUCCESS;
return oxr_session_success_result(sc->sess);
}
static XrResult

View file

@ -46,7 +46,7 @@ oxr_swapchain_gl_enumerate_images(struct oxr_logger *log,
gl_imgs[i].image = xsc->images[i];
}
return XR_SUCCESS;
return oxr_session_success_result(sc->sess);
}
XrResult

View file

@ -49,7 +49,7 @@ oxr_swapchain_vk_enumerate_images(struct oxr_logger *log,
vk_imgs[i].image = xscvk->images[i];
}
return XR_SUCCESS;
return oxr_session_success_result(sc->sess);
}
XrResult

View file

@ -219,7 +219,8 @@ oxr_system_enumerate_view_confs(struct oxr_logger *log,
{
OXR_TWO_CALL_HELPER(log, viewConfigurationTypeCapacityInput,
viewConfigurationTypeCountOutput,
viewConfigurationTypes, 1, &sys->view_config_type);
viewConfigurationTypes, 1, &sys->view_config_type,
XR_SUCCESS);
}
XrResult
@ -234,7 +235,7 @@ oxr_system_enumerate_blend_modes(struct oxr_logger *log,
OXR_TWO_CALL_HELPER(log, environmentBlendModeCapacityInput,
environmentBlendModeCountOutput,
environmentBlendModes, sys->num_blend_modes,
sys->blend_modes);
sys->blend_modes, XR_SUCCESS);
}
XrResult
@ -274,5 +275,5 @@ oxr_system_enumerate_view_conf_views(
}
OXR_TWO_CALL_HELPER(log, viewCapacityInput, viewCountOutput, views, 2,
sys->views);
sys->views, XR_SUCCESS);
}

View file

@ -15,7 +15,8 @@ extern "C" {
#endif
#define OXR_TWO_CALL_HELPER(log, cnt_input, cnt_output, output, count, data) \
#define OXR_TWO_CALL_HELPER(log, cnt_input, cnt_output, output, count, data, \
sval) \
do { \
if (cnt_output == NULL) { \
return oxr_error(log, XR_ERROR_VALIDATION_FAILURE, \
@ -24,7 +25,7 @@ extern "C" {
*cnt_output = count; \
\
if (cnt_input == 0) { \
return XR_SUCCESS; \
return sval; \
} \
if (cnt_input < count) { \
return oxr_error(log, XR_ERROR_SIZE_INSUFFICIENT, \
@ -33,7 +34,7 @@ extern "C" {
for (uint32_t i = 0; i < count; i++) { \
(output)[i] = (data)[i]; \
} \
return XR_SUCCESS; \
return sval; \
} while (false)

View file

@ -32,8 +32,8 @@ oxr_vk_get_instance_exts(struct oxr_logger *log,
size_t length = strlen(xrt_gfx_vk_instance_extensions) + 1;
OXR_TWO_CALL_HELPER(log, namesCapacityInput, namesCountOutput,
namesString, length,
xrt_gfx_vk_instance_extensions);
namesString, length, xrt_gfx_vk_instance_extensions,
XR_SUCCESS);
}
XrResult
@ -46,7 +46,8 @@ oxr_vk_get_device_exts(struct oxr_logger *log,
size_t length = strlen(xrt_gfx_vk_device_extensions) + 1;
OXR_TWO_CALL_HELPER(log, namesCapacityInput, namesCountOutput,
namesString, length, xrt_gfx_vk_device_extensions);
namesString, length, xrt_gfx_vk_device_extensions,
XR_SUCCESS);
}
XrResult