From 55606527fae522b11d9e720e3d16b9fb3cfa0de1 Mon Sep 17 00:00:00 2001 From: Christoph Haag Date: Thu, 27 Jan 2022 12:04:14 +0100 Subject: [PATCH] openxr: call xrBeginFrame even if shouldRender == true ``` As long as the session is running, the application should keep running the frame loop to maintain the frame synchronization to the runtime, even if this requires calling xrEndFrame with all layers omitted. ``` In OpenXRDevice::end_frame() we return early after calling xrEndFrame with 0 layers submitted if shouldRender is false. This early return still requires us to have called xrBeginFrame. --- drivers/openxr/openxr_device.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/openxr/openxr_device.cpp b/drivers/openxr/openxr_device.cpp index 2457cda174f4..5e550d0bb6dd 100644 --- a/drivers/openxr/openxr_device.cpp +++ b/drivers/openxr/openxr_device.cpp @@ -1660,17 +1660,19 @@ void OpenXRDevice::pre_render() { #endif } - if (frame_state.shouldRender) { - // let's start our frame.. - XrFrameBeginInfo frame_begin_info = { - XR_TYPE_FRAME_BEGIN_INFO, // type - nullptr // next - }; - result = xrBeginFrame(session, &frame_begin_info); - if (XR_FAILED(result)) { - print_line("OpenXR: failed to being frame [", get_error_string(result), "]"); - return; - } + if (!frame_state.shouldRender) { + // TODO: Tell godot not do render VR to save resources. + } + + // let's start our frame.. + XrFrameBeginInfo frame_begin_info = { + XR_TYPE_FRAME_BEGIN_INFO, // type + nullptr // next + }; + result = xrBeginFrame(session, &frame_begin_info); + if (XR_FAILED(result)) { + print_line("OpenXR: failed to being frame [", get_error_string(result), "]"); + return; } }