From 0cf115b5dea523c3f36d391d65af50434b7096a5 Mon Sep 17 00:00:00 2001 From: janhsimon Date: Mon, 26 Aug 2024 16:50:16 +0200 Subject: [PATCH] Add error checking when ending the frame --- src/Headset.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Headset.cpp b/src/Headset.cpp index dad7363..d0ffb62 100644 --- a/src/Headset.cpp +++ b/src/Headset.cpp @@ -517,6 +517,18 @@ Headset::BeginFrameResult Headset::beginFrame(uint32_t& swapchainImageIndex) return BeginFrameResult::Error; } + if ((viewState.viewStateFlags & XR_VIEW_STATE_POSITION_VALID_BIT) == 0) + { + util::error(Error::GenericOpenXR); + return BeginFrameResult::Error; + } + + if ((viewState.viewStateFlags & XR_VIEW_STATE_ORIENTATION_VALID_BIT) == 0) + { + util::error(Error::GenericOpenXR); + return BeginFrameResult::Error; + } + // Update the eye render infos, view and projection matrices for (size_t eyeIndex = 0u; eyeIndex < eyeCount; ++eyeIndex) { @@ -566,6 +578,7 @@ void Headset::endFrame() const XrResult result = xrReleaseSwapchainImage(swapchain, &swapchainImageReleaseInfo); if (XR_FAILED(result)) { + util::error(Error::GenericOpenXR); return; } @@ -576,10 +589,7 @@ void Headset::endFrame() const compositionLayerProjection.views = eyeRenderInfos.data(); std::vector layers; - - const bool positionValid = viewState.viewStateFlags & XR_VIEW_STATE_POSITION_VALID_BIT; - const bool orientationValid = viewState.viewStateFlags & XR_VIEW_STATE_ORIENTATION_VALID_BIT; - if (frameState.shouldRender && positionValid && orientationValid) + if (frameState.shouldRender) { layers.push_back(reinterpret_cast(&compositionLayerProjection)); } @@ -592,6 +602,7 @@ void Headset::endFrame() const result = xrEndFrame(session, &frameEndInfo); if (XR_FAILED(result)) { + util::error(Error::GenericOpenXR); return; } }