From 13ff41bc2b3b729541a76890d77a7c1a78fc0377 Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 26 Feb 2024 12:56:14 +0100 Subject: [PATCH] OpenXR - Passthrough on the latest QuestOS fixed --- Common/VR/VRBase.h | 1 - Common/VR/VRRenderer.cpp | 27 ++++++++++++++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Common/VR/VRBase.h b/Common/VR/VRBase.h index 6ebfd4a316fe..e8f41d4b6b45 100644 --- a/Common/VR/VRBase.h +++ b/Common/VR/VRBase.h @@ -51,7 +51,6 @@ enum { ovrMaxNumEyes = 2 }; typedef union { XrCompositionLayerProjection Projection; XrCompositionLayerCylinderKHR Cylinder; - XrCompositionLayerPassthroughFB Passthrough; } ovrCompositorLayer_Union; typedef struct { diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index f7ac27945121..2cbe0f52e153 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -22,6 +22,7 @@ XrVector3f hmdorientation; XrPassthroughFB passthrough = XR_NULL_HANDLE; XrPassthroughLayerFB passthroughLayer = XR_NULL_HANDLE; +bool passthroughRunning = false; DECL_PFN(xrCreatePassthroughFB); DECL_PFN(xrDestroyPassthroughFB); DECL_PFN(xrPassthroughStartFB); @@ -257,14 +258,15 @@ void VR_InitRenderer( engine_t* engine, bool multiview ) { } OXR(xrPassthroughStartFB(passthrough)); - OXR(xrPassthroughLayerResumeFB(passthroughLayer)); } initialized = true; } void VR_DestroyRenderer( engine_t* engine ) { if (VR_GetPlatformFlag(VRPlatformFlag::VR_PLATFORM_EXTENSION_PASSTHROUGH)) { - OXR(xrPassthroughLayerPauseFB(passthroughLayer)); + if (passthroughRunning) { + OXR(xrPassthroughLayerPauseFB(passthroughLayer)); + } OXR(xrPassthroughPauseFB(passthrough)); OXR(xrDestroyPassthroughFB(passthrough)); passthrough = XR_NULL_HANDLE; @@ -288,6 +290,16 @@ bool VR_InitFrame( engine_t* engine ) { stageBoundsDirty = false; } + // Update passthrough + if (passthroughRunning != VR_GetConfig(VR_CONFIG_PASSTHROUGH)) { + if (VR_GetConfig(VR_CONFIG_PASSTHROUGH)) { + OXR(xrPassthroughLayerResumeFB(passthroughLayer)); + } else { + OXR(xrPassthroughLayerPauseFB(passthroughLayer)); + } + passthroughRunning = VR_GetConfig(VR_CONFIG_PASSTHROUGH); + } + // NOTE: OpenXR does not use the concept of frame indices. Instead, // XrWaitFrame returns the predicted display time. XrFrameWaitInfo waitFrameInfo = {}; @@ -375,17 +387,6 @@ void VR_EndFrame( engine_t* engine ) { } void VR_FinishFrame( engine_t* engine ) { - - if (VR_GetPlatformFlag(VRPlatformFlag::VR_PLATFORM_EXTENSION_PASSTHROUGH) && VR_GetConfig(VR_CONFIG_PASSTHROUGH)) { - if (passthroughLayer != XR_NULL_HANDLE) { - XrCompositionLayerPassthroughFB passthrough_layer = {XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_FB}; - passthrough_layer.layerHandle = passthroughLayer; - passthrough_layer.flags = XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT; - passthrough_layer.space = XR_NULL_HANDLE; - engine->appState.Layers[engine->appState.LayerCount++].Passthrough = passthrough_layer; - } - } - int vrMode = vrConfig[VR_CONFIG_MODE]; XrCompositionLayerProjectionView projection_layer_elements[2] = {}; if ((vrMode == VR_MODE_MONO_6DOF) || (vrMode == VR_MODE_STEREO_6DOF)) {