Skip to content

Commit

Permalink
OpenXR - Passthrough on the latest QuestOS fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
lvonasek committed Feb 26, 2024
1 parent 70cc5da commit 13ff41b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
1 change: 0 additions & 1 deletion Common/VR/VRBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ enum { ovrMaxNumEyes = 2 };
typedef union {
XrCompositionLayerProjection Projection;
XrCompositionLayerCylinderKHR Cylinder;
XrCompositionLayerPassthroughFB Passthrough;
} ovrCompositorLayer_Union;

typedef struct {
Expand Down
27 changes: 14 additions & 13 deletions Common/VR/VRRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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 = {};
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 13ff41b

Please sign in to comment.