From a6709c70e0dec6bd38ca08327ba8f3274cd17c3d Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 26 Jun 2023 17:26:56 +0200 Subject: [PATCH] OpenXR - Code cleanup --- Common/VR/VRFramebuffer.cpp | 11 +---------- Common/VR/VRRenderer.cpp | 13 +++++-------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/Common/VR/VRFramebuffer.cpp b/Common/VR/VRFramebuffer.cpp index 4f53b9eb25..ce1c0271f3 100644 --- a/Common/VR/VRFramebuffer.cpp +++ b/Common/VR/VRFramebuffer.cpp @@ -323,17 +323,8 @@ void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer) { XrSwapchainImageWaitInfo waitInfo; waitInfo.type = XR_TYPE_SWAPCHAIN_IMAGE_WAIT_INFO; waitInfo.next = NULL; - waitInfo.timeout = 1000000; /* timeout in nanoseconds */ + waitInfo.timeout = XR_INFINITE_DURATION; XrResult res = xrWaitSwapchainImage(frameBuffer->ColorSwapChain.Handle, &waitInfo); - int i = 0; - while ((res != XR_SUCCESS) && (i < 10)) { - res = xrWaitSwapchainImage(frameBuffer->ColorSwapChain.Handle, &waitInfo); - i++; - ALOGV( - " Retry xrWaitSwapchainImage %d times due to XR_TIMEOUT_EXPIRED (duration %f micro seconds)", - i, - waitInfo.timeout * (1E-9)); - } frameBuffer->Acquired = res == XR_SUCCESS; ovrFramebuffer_SetCurrent(frameBuffer); diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 6c22312311..4fcec61803 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -327,7 +327,11 @@ bool VR_InitFrame( engine_t* engine ) { projectionCapacityInput, &projectionCountOutput, projections)); - // + if ((viewState.viewStateFlags & XR_VIEW_STATE_POSITION_VALID_BIT) == 0 || + (viewState.viewStateFlags & XR_VIEW_STATE_ORIENTATION_VALID_BIT) == 0) { + return false; // There is no valid tracking poses for the views. + } + fov = {}; for (int eye = 0; eye < ovrMaxNumEyes; eye++) { @@ -486,14 +490,7 @@ void VR_FinishFrame( engine_t* engine ) { endFrameInfo.environmentBlendMode = XR_ENVIRONMENT_BLEND_MODE_OPAQUE; endFrameInfo.layerCount = engine->appState.LayerCount; endFrameInfo.layers = layers; - OXR(xrEndFrame(engine->appState.Session, &endFrameInfo)); - int instances = engine->appState.Renderer.Multiview ? 1 : ovrMaxNumEyes; - for (int i = 0; i < instances; i++) { - ovrFramebuffer* frameBuffer = &engine->appState.Renderer.FrameBuffer[instances]; - frameBuffer->TextureSwapChainIndex++; - frameBuffer->TextureSwapChainIndex %= frameBuffer->TextureSwapChainLength; - } } int VR_GetConfig( VRConfig config ) {