Skip to content

Commit 0cf115b

Browse files
committed
Add error checking when ending the frame
1 parent 230e476 commit 0cf115b

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/Headset.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,18 @@ Headset::BeginFrameResult Headset::beginFrame(uint32_t& swapchainImageIndex)
517517
return BeginFrameResult::Error;
518518
}
519519

520+
if ((viewState.viewStateFlags & XR_VIEW_STATE_POSITION_VALID_BIT) == 0)
521+
{
522+
util::error(Error::GenericOpenXR);
523+
return BeginFrameResult::Error;
524+
}
525+
526+
if ((viewState.viewStateFlags & XR_VIEW_STATE_ORIENTATION_VALID_BIT) == 0)
527+
{
528+
util::error(Error::GenericOpenXR);
529+
return BeginFrameResult::Error;
530+
}
531+
520532
// Update the eye render infos, view and projection matrices
521533
for (size_t eyeIndex = 0u; eyeIndex < eyeCount; ++eyeIndex)
522534
{
@@ -566,6 +578,7 @@ void Headset::endFrame() const
566578
XrResult result = xrReleaseSwapchainImage(swapchain, &swapchainImageReleaseInfo);
567579
if (XR_FAILED(result))
568580
{
581+
util::error(Error::GenericOpenXR);
569582
return;
570583
}
571584

@@ -576,10 +589,7 @@ void Headset::endFrame() const
576589
compositionLayerProjection.views = eyeRenderInfos.data();
577590

578591
std::vector<XrCompositionLayerBaseHeader*> layers;
579-
580-
const bool positionValid = viewState.viewStateFlags & XR_VIEW_STATE_POSITION_VALID_BIT;
581-
const bool orientationValid = viewState.viewStateFlags & XR_VIEW_STATE_ORIENTATION_VALID_BIT;
582-
if (frameState.shouldRender && positionValid && orientationValid)
592+
if (frameState.shouldRender)
583593
{
584594
layers.push_back(reinterpret_cast<XrCompositionLayerBaseHeader*>(&compositionLayerProjection));
585595
}
@@ -592,6 +602,7 @@ void Headset::endFrame() const
592602
result = xrEndFrame(session, &frameEndInfo);
593603
if (XR_FAILED(result))
594604
{
605+
util::error(Error::GenericOpenXR);
595606
return;
596607
}
597608
}

0 commit comments

Comments
 (0)