From 23b882df08c492821af8f77b586f366b68252f59 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 28 May 2020 13:13:31 +0100 Subject: [PATCH] st/oxr: Write out pose values on failure, better say which layer failed and also check projection layer poses --- doc/changes/state_trackers/mr.350.1.md | 2 ++ doc/changes/state_trackers/mr.350.2.md | 2 ++ src/xrt/state_trackers/oxr/oxr_session.c | 37 +++++++++++++++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 doc/changes/state_trackers/mr.350.1.md create mode 100644 doc/changes/state_trackers/mr.350.2.md diff --git a/doc/changes/state_trackers/mr.350.1.md b/doc/changes/state_trackers/mr.350.1.md new file mode 100644 index 000000000..b772aad12 --- /dev/null +++ b/doc/changes/state_trackers/mr.350.1.md @@ -0,0 +1,2 @@ +OpenXR: Give better error messages on invalid poses in quad layers instead of +using the simple macro. diff --git a/doc/changes/state_trackers/mr.350.2.md b/doc/changes/state_trackers/mr.350.2.md new file mode 100644 index 000000000..fb9104d49 --- /dev/null +++ b/doc/changes/state_trackers/mr.350.2.md @@ -0,0 +1,2 @@ +OpenXR: Validate poses for project layer views, using the same expressive error +messages as the quad layers. diff --git a/src/xrt/state_trackers/oxr/oxr_session.c b/src/xrt/state_trackers/oxr/oxr_session.c index fd500ccc9..fcbd98a27 100644 --- a/src/xrt/state_trackers/oxr/oxr_session.c +++ b/src/xrt/state_trackers/oxr/oxr_session.c @@ -489,7 +489,21 @@ verify_quad_layer(struct xrt_compositor *xc, return ret; } - OXR_VERIFY_POSE(log, quad->pose); + if (!math_quat_validate((struct xrt_quat *)&quad->pose.orientation)) { + XrQuaternionf *q = &quad->pose.orientation; + return oxr_error(log, XR_ERROR_POSE_INVALID, + "(frameEndInfo->layers[%u]->pose.orientation " + "== {%f %f %f %f}) is not a valid quat", + layer_index, q->x, q->y, q->z, q->w); + } + + if (!math_vec3_validate((struct xrt_vec3 *)&quad->pose.position)) { + XrVector3f *p = &quad->pose.position; + return oxr_error(log, XR_ERROR_POSE_INVALID, + "(frameEndInfo->layers[%u]->pose.position " + "== {%f %f %f}) is not valid", + layer_index, p->x, p->y, p->z); + } if (quad->subImage.imageArrayIndex > 0 && sc->swapchain->array_size <= quad->subImage.imageArrayIndex) { @@ -553,6 +567,27 @@ verify_projection_layer(struct xrt_compositor *xc, // Check for valid swapchain states. for (uint32_t i = 0; i < proj->viewCount; i++) { //! @todo More validation? + if (!math_quat_validate( + (struct xrt_quat *)&proj->views[i].pose.orientation)) { + const XrQuaternionf *q = + &proj->views[i].pose.orientation; + return oxr_error( + log, XR_ERROR_POSE_INVALID, + "(frameEndInfo->layers[%u]->views[%i]->pose." + "orientation == {%f %f %f %f}) is not a valid quat", + layer_index, i, q->x, q->y, q->z, q->w); + } + + if (!math_vec3_validate( + (struct xrt_vec3 *)&proj->views[i].pose.position)) { + const XrVector3f *p = &proj->views[i].pose.position; + return oxr_error( + log, XR_ERROR_POSE_INVALID, + "(frameEndInfo->layers[%u]->views[%i]->pose." + "position == {%f %f %f}) is not valid", + layer_index, i, p->x, p->y, p->z); + } + struct oxr_swapchain *sc = XRT_CAST_OXR_HANDLE_TO_PTR( struct oxr_swapchain *, proj->views[i].subImage.swapchain);