From 8b4c9655e81282beb1690494c285b9be57abda2a Mon Sep 17 00:00:00 2001 From: Vivek Trivedi Date: Wed, 20 Sep 2023 12:37:34 -0700 Subject: [PATCH] IGL : Adding support to use Composition layer quad for reprojection in desktop XrApp. Summary: Adding support to reproject xr render output to a quad in XrApp. Reviewed By: EricGriffith Differential Revision: D49377639 fbshipit-source-id: 9b1d903600ae6a0fc9803ee4d1dc9c4f373af7cf --- shell/openxr/desktop/XrApp.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/shell/openxr/desktop/XrApp.cpp b/shell/openxr/desktop/XrApp.cpp index e36ca35c3a..83bc9de8dd 100644 --- a/shell/openxr/desktop/XrApp.cpp +++ b/shell/openxr/desktop/XrApp.cpp @@ -515,6 +515,18 @@ void XrApp::render() { } void XrApp::endFrame(XrFrameState frameState) { +#ifdef USE_COMPOSITION_LAYER_QUAD + XrCompositionLayerQuad layer{}; + layer.next = nullptr; + layer.type = XR_TYPE_COMPOSITION_LAYER_QUAD; + layer.layerFlags = XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT; + layer.space = stageSpace_; + layer.eyeVisibility = XR_EYE_VISIBILITY_BOTH; + memset(&layer.subImage, 0, sizeof(XrSwapchainSubImage)); + layer.pose = {{0.f, 0.f, 0.f, 1.f}, {0.f, 0.f, 0.f}}; + layer.size = {1.f, 1.f}; +#endif + std::array projectionViews; std::array depthInfos; @@ -561,10 +573,18 @@ void XrApp::endFrame(XrFrameState frameState) { depthInfos[i].maxDepth = appParams.depthParams.maxDepth; depthInfos[i].nearZ = appParams.depthParams.nearZ; depthInfos[i].farZ = appParams.depthParams.farZ; +#ifdef USE_COMPOSITION_LAYER_QUAD + layer.subImage = projectionViews[0].subImage; +#endif } const XrCompositionLayerBaseHeader* const layers[] = { - (const XrCompositionLayerBaseHeader*)&projection}; +#ifdef USE_COMPOSITION_LAYER_QUAD + (const XrCompositionLayerBaseHeader*)&layer +#else + (const XrCompositionLayerBaseHeader*)&projection +#endif + }; XrFrameEndInfo endFrameInfo = { XR_TYPE_FRAME_END_INFO,