aboutsummaryrefslogtreecommitdiffstats
path: root/src/xr/quick3dxr/qquick3dxrruntimeinfo.cpp
blob: 4d0e1d01483b64b92ab12fde9160fce1fd81dae1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

#include "qquick3dxrruntimeinfo_p.h"
#include "qquick3dxrmanager_p.h"
#include <QtQuick/QQuickWindow>
#include <rhi/qrhi.h>

#if defined(Q_OS_VISIONOS)
#include "visionos/qquick3dxrmanager_visionos_p.h"
#else
#include "openxr/qquick3dxrmanager_openxr_p.h"
#endif

QT_BEGIN_NAMESPACE

/*!
    \qmltype XrRuntimeInfo
    \inherits Item
    \inqmlmodule QtQuick3D.Xr
    \brief Displays information about the XR runtime.

    This type provides information about the XR runtime, including enabled
    extensions, runtime name, version, graphics API name, and whether multi-view
    rendering is supported.

    \note This type is automatically created by an \l XrView, and it can not be
    manually created.
*/

QQuick3DXrRuntimeInfo::QQuick3DXrRuntimeInfo(QQuick3DXrManager *manager, QObject *parent)
    : QObject(parent),
      m_xrmanager(manager)
{
}

/*!
    \qmlproperty list<string> XrRuntimeInfo::enabledExtensions
    \brief A list of enabled XR extensions.
    \readonly

    This property holds a QStringList containing the names of the
    XR extensions that are currently enabled for the runtime.

    \note This list may vary depending on the runtime implementation and can be
    empty.
*/

QStringList QQuick3DXrRuntimeInfo::enabledExtensions() const
{
    QQuick3DXrManagerPrivate *manager = QQuick3DXrManagerPrivate::get(m_xrmanager);
    return manager ? manager->enabledExtensions() : QStringList{};
}

/*!
    \qmlproperty string XrRuntimeInfo::runtimeName
    \brief The name of the XR runtime.
    \readonly

    This property provides the human-readable name of the XR runtime being
    used.
*/

QString QQuick3DXrRuntimeInfo::runtimeName() const
{
    QQuick3DXrManagerPrivate *manager = QQuick3DXrManagerPrivate::get(m_xrmanager);
    return manager ? manager->runtimeName() : QString{};
}

/*!
    \qmlproperty string XrRuntimeInfo::runtimeVersion
    \brief The version of the XR runtime.
    \readonly

    This property holds the version string of the XR runtime
    (for example, "1.0.0").
*/

QString QQuick3DXrRuntimeInfo::runtimeVersion() const
{
    QQuick3DXrManagerPrivate *manager = QQuick3DXrManagerPrivate::get(m_xrmanager);
    return manager ? manager->runtimeVersion().toString() : QString{};
}

/*!
    \qmlproperty string XrRuntimeInfo::graphicsApiName
    \brief The name of the graphics API used by the XR runtime.
    \readonly

    This property holds the name of the graphics API (for example, "Vulkan") that the
    XR runtime is utilizing.
*/

QString QQuick3DXrRuntimeInfo::graphicsApiName() const
{
    // This matches what Qt Quick's GraphicsInfo would expose to QML, but that
    // does not provide a string. We have seen way too many switch statements
    // in JS for this. So, have a string property here and call it a day.
    if (m_xrmanager->isValid() && m_xrmanager->m_quickWindow) {
        QRhi *rhi = m_xrmanager->m_quickWindow->rhi();
        if (rhi)
            return QString::fromLatin1(rhi->backendName());
    }
    return QLatin1String("Unknown");
}

QT_END_NAMESPACE