Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qopenxrmanager_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QOPENXRMANAGER_H
5#define QOPENXRMANAGER_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/QObject>
19#include <QtCore/QMap>
20#include <QtCore/QVersionNumber>
21#if defined(Q_NO_TEMPORARY_DISABLE_XR_API)
22#include <QtQuick3DXr/private/qabstractopenxrgraphics_p.h>
23#endif // Q_NO_TEMPORARY_DISABLE_XR_API
24#include <QtQuick3DXr/private/qopenxranimationdriver_p.h>
25#include <QtQml/QQmlEngine>
26#include <QtQml/QQmlComponent>
27
28#include <QtGui/private/qtgui-config_p.h>
29#if QT_CONFIG(graphicsframecapture)
30#include <QtGui/private/qgraphicsframecapture_p.h>
31#endif
32
33#ifdef XR_USE_PLATFORM_ANDROID
34# include <QtCore/QJniObject>
35#endif
36
37#if defined(Q_OS_VISIONOS)
38# include <QtQuick3DXr/private/qquick3dxrvisionosrendermanager_p.h>
39#endif
40
42
43class QQuickWindow;
45class QQuick3DNode;
48class QOpenXRView;
49class QOpenXROrigin;
52class QRhiTexture;
53
54class QOpenXRManager : public QObject
55{
57public:
58 explicit QOpenXRManager(QObject *parent = nullptr);
60
61 bool isReady() const;
62
63 bool initialize();
64 void teardown();
65
66 bool isValid() const;
67
69
70 QString errorString() const { return m_errorString; }
71
72 void setSamples(int samples);
73
74private Q_SLOTS:
75 void update();
76
81 void frameReady(QRhiTexture *colorBuffer);
83
84protected:
85 bool event(QEvent *e) override;
86
87private:
88#if defined(Q_NO_TEMPORARY_DISABLE_XR_API)
89 void destroySwapchain();
90 void setErrorString(XrResult result, const char *callName);
91 void checkXrExtensions(const char* layerName, int indent = 0);
92 void checkXrLayers();
93
94 XrResult createXrInstance();
95 void checkXrInstance();
96
97 void setupDebugMessenger();
98
99 XrResult initializeSystem();
100
101 void checkViewConfiguration();
102 bool checkXrResult(const XrResult &result);
103 void checkEnvironmentBlendMode(XrViewConfigurationType type);
104#endif // Q_NO_TEMPORARY_DISABLE_XR_API
105 bool setupGraphics();
106
107#if defined(Q_NO_TEMPORARY_DISABLE_XR_API)
108 void checkReferenceSpaces();
109 bool isReferenceSpaceAvailable(XrReferenceSpaceType type);
110
111 bool setupAppSpace();
112 void updateAppSpace(XrTime predictedDisplayTime);
113 bool setupViewSpace();
114 bool resetEmulatedFloorHeight(XrTime predictedDisplayTime);
115
116 void createSwapchains();
117#endif // Q_NO_TEMPORARY_DISABLE_XR_API
118
119 void processXrEvents();
120#if defined(Q_NO_TEMPORARY_DISABLE_XR_API)
121 void pollEvents(bool *exitRenderLoop, bool *requestRestart);
122 void pollActions();
123#endif // Q_NO_TEMPORARY_DISABLE_XR_API
124 void renderFrame();
125#if defined(Q_NO_TEMPORARY_DISABLE_XR_API)
126 bool renderLayer(XrTime predictedDisplayTime,
127 XrDuration predictedDisplayPeriod,
128 XrCompositionLayerProjection &layer);
129 void doRender(const XrSwapchainSubImage &subImage,
130 const XrSwapchainImageBaseHeader *swapchainImage,
131 const XrSwapchainImageBaseHeader *depthSwapchainImage = nullptr);
132#endif // Q_NO_TEMPORARY_DISABLE_XR_API
133
134 void preSetupQuickScene();
135 bool setupQuickScene();
136#if defined(Q_NO_TEMPORARY_DISABLE_XR_API)
137 void updateCameraHelper(QOpenXREyeCamera *camera, const XrCompositionLayerProjectionView &layerView);
138 void updateCameraNonMultiview(int eye, const XrCompositionLayerProjectionView &layerView);
139 void updateCameraMultiview(int projectionLayerViewStartIndex, int count);
140#endif // Q_NO_TEMPORARY_DISABLE_XR_API
141 void checkOrigin();
142
143 bool supportsPassthrough() const;
144
145#if defined(Q_NO_TEMPORARY_DISABLE_XR_API)
146 void setupMetaQuestColorSpaces();
147 void setupMetaQuestRefreshRates();
148 void setupMetaQuestFoveation();
149
150 // Passthrough
151 XrPassthroughFB m_passthroughFeature{XR_NULL_HANDLE};
152 void createMetaQuestPassthrough();
153 void destroyMetaQuestPassthrough();
154 void startMetaQuestPassthrough();
155 void pauseMetaQuestPassthrough();
156
157 XrPassthroughLayerFB m_passthroughLayer{XR_NULL_HANDLE};
158 void createMetaQuestPassthroughLayer();
159 void destroyMetaQuestPassthroughLayer();
160 void pauseMetaQuestPassthroughLayer();
161 void resumeMetaQuestPassthroughLayer();
162
163 XrInstance m_instance{XR_NULL_HANDLE};
164 XrSession m_session{XR_NULL_HANDLE};
165 XrSpace m_appSpace{XR_NULL_HANDLE};
166 XrReferenceSpaceType m_requestedReferenceSpace = XR_REFERENCE_SPACE_TYPE_STAGE;
167 XrReferenceSpaceType m_referenceSpace = XR_REFERENCE_SPACE_TYPE_LOCAL;
168 bool m_isEmulatingLocalFloor = false;
169 bool m_isFloorResetPending = false;
170 XrSpace m_viewSpace{XR_NULL_HANDLE};
171 XrFormFactor m_formFactor{XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY};
172 XrViewConfigurationType m_viewConfigType{XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO};
173 XrEnvironmentBlendMode m_environmentBlendMode{XR_ENVIRONMENT_BLEND_MODE_OPAQUE};
174 XrSystemId m_systemId{XR_NULL_SYSTEM_ID};
175
176 QVector<XrReferenceSpaceType> m_availableReferenceSpace;
177
178#ifdef XR_EXT_debug_utils
179 XrDebugUtilsMessengerEXT m_debugMessenger = XR_NULL_HANDLE;
180 PFN_xrDestroyDebugUtilsMessengerEXT m_xrDestroyDebugUtilsMessengerEXT = nullptr;
181#endif
182
183 QAbstractOpenXRGraphics *m_graphics = nullptr;
184#endif // Q_NO_TEMPORARY_DISABLE_XR_API
185
186 QQuickWindow *m_quickWindow = nullptr;
187 QQuickRenderControl *m_renderControl = nullptr;
188 QQuick3DViewport *m_vrViewport = nullptr;
189 QOpenXROrigin *m_xrOrigin = nullptr;
190#if defined(Q_NO_TEMPORARY_DISABLE_XR_API)
191 QOpenXRInputManager *m_inputManager = nullptr;
192#endif // Q_NO_TEMPORARY_DISABLE_XR_API
193
194 QOpenXRAnimationDriver *m_animationDriver = nullptr;
195#if defined(Q_NO_TEMPORARY_DISABLE_XR_API)
196 XrTime m_previousTime = 0;
197
198 struct Swapchain {
199 XrSwapchain handle;
202 quint32 arraySize;
203 };
204#endif // Q_NO_TEMPORARY_DISABLE_XR_API
205
206 bool m_multiviewRendering = false;
207#if defined(Q_NO_TEMPORARY_DISABLE_XR_API)
208 QVector<XrViewConfigurationView> m_configViews;
209 QVector<XrCompositionLayerProjectionView> m_projectionLayerViews;
210 QVector<XrCompositionLayerDepthInfoKHR> m_layerDepthInfos;
211 QVector<Swapchain> m_swapchains;
212 QVector<Swapchain> m_depthSwapchains;
213 QMap<XrSwapchain, QVector<XrSwapchainImageBaseHeader*>> m_swapchainImages;
214 QMap<XrSwapchain, QVector<XrSwapchainImageBaseHeader*>> m_depthSwapchainImages;
215 QVector<XrView> m_views;
216#endif // Q_NO_TEMPORARY_DISABLE_XR_API
217 int64_t m_colorSwapchainFormat = -1;
218 int64_t m_depthSwapchainFormat = -1;
219 int m_samples = 1;
220
221#if defined(Q_NO_TEMPORARY_DISABLE_XR_API)
222 // Application's current lifecycle state according to the runtime
223 XrSessionState m_sessionState{XR_SESSION_STATE_UNKNOWN};
224#endif // Q_NO_TEMPORARY_DISABLE_XR_API
225 bool m_sessionRunning{false};
226
227#if defined(Q_NO_TEMPORARY_DISABLE_XR_API)
228 XrEventDataBuffer m_eventDataBuffer;
229#endif // Q_NO_TEMPORARY_DISABLE_XR_API
230
231 bool m_enablePassthrough = false;
232 bool m_passthroughSupported = false;
233#if defined(Q_NO_TEMPORARY_DISABLE_XR_API)
234 bool m_spaceExtensionSupported = false;
235 QOpenXRSpaceExtension *m_spaceExtension = nullptr;
236 bool m_colorspaceExtensionSupported = false;
237 bool m_displayRefreshRateExtensionSupported = false;
238 bool m_foveationExtensionSupported = false;
239 XrFoveationLevelFB m_foveationLevel = XR_FOVEATION_LEVEL_HIGH_FB;
240 bool m_compositionLayerDepthSupported = false;
241 bool m_submitLayerDepth = false;
242 bool m_handtrackingExtensionSupported = false;
243 bool m_handtrackingAimExtensionSupported = false;
244
245#ifdef XR_USE_PLATFORM_ANDROID
246 QJniObject m_androidActivity;
247#endif // XR_USE_PLATFORM_ANDROID
248#endif // Q_NO_TEMPORARY_DISABLE_XR_API
249
250 QString m_errorString;
251 QString m_runtimeName;
252 QVersionNumber m_runtimeVersion;
253 QStringList m_enabledApiLayers;
254 QStringList m_enabledExtensions;
255
256#if defined(Q_NO_TEMPORARY_DISABLE_XR_API)
257#if QT_CONFIG(graphicsframecapture)
258 std::unique_ptr<QGraphicsFrameCapture> m_frameCapture;
259#endif
260#endif // Q_NO_TEMPORARY_DISABLE_XR_API
261
262#if defined(Q_OS_VISIONOS)
263 QQuick3DXRVisionOSRenderManager *m_visionOSRenderManager = nullptr;
264#endif
265
266 friend class QOpenXRView;
267 friend class QOpenXRRuntimeInfo;
268};
269
271
272#endif // QOPENXRMANAGER_H
AVFCameraSession * m_session
\inmodule QtCore
Definition qcoreevent.h:45
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
void setPassthroughEnabled(bool enabled)
void sessionEnded()
void referenceSpaceChanged()
void setSamples(int samples)
QString errorString() const
void initialized()
bool isValid() const
void xrOriginChanged()
QOpenXRManager(QObject *parent=nullptr)
bool isReady() const
void frameReady(QRhiTexture *colorBuffer)
The QQuickRenderControl class provides a mechanism for rendering the Qt Quick scenegraph onto an offs...
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtGui
Definition qrhi.h:895
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtCore
QCamera * camera
Definition camera.cpp:19
Combined button and popup list for selecting options.
EGLOutputLayerEXT layer
GLuint64 GLenum void * handle
GLsizei samples
GLint GLsizei GLsizei height
GLenum GLenum GLsizei count
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLint GLsizei width
GLenum type
struct _cl_event * event
GLuint64EXT * result
[6]
#define Q_OBJECT
#define Q_SLOTS
#define Q_SIGNALS
unsigned int quint32
Definition qtypes.h:50