| 1 | // Copyright (C) 2020 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QQUICKGRAPHICSDEVICE_H |
| 5 | #define QQUICKGRAPHICSDEVICE_H |
| 6 | |
| 7 | #include <QtQuick/qtquickglobal.h> |
| 8 | |
| 9 | #if QT_CONFIG(vulkan) |
| 10 | #include <QtGui/qvulkaninstance.h> |
| 11 | #endif |
| 12 | |
| 13 | #if QT_CONFIG(metal) || defined(Q_QDOC) |
| 14 | Q_FORWARD_DECLARE_OBJC_CLASS(MTLDevice); |
| 15 | Q_FORWARD_DECLARE_OBJC_CLASS(MTLCommandQueue); |
| 16 | #endif |
| 17 | |
| 18 | QT_BEGIN_NAMESPACE |
| 19 | |
| 20 | class QQuickGraphicsDevicePrivate; |
| 21 | class QOpenGLContext; |
| 22 | class QRhi; |
| 23 | class QRhiAdapter; |
| 24 | |
| 25 | class Q_QUICK_EXPORT QQuickGraphicsDevice |
| 26 | { |
| 27 | public: |
| 28 | QQuickGraphicsDevice(); |
| 29 | ~QQuickGraphicsDevice(); |
| 30 | QQuickGraphicsDevice(const QQuickGraphicsDevice &other); |
| 31 | QQuickGraphicsDevice &operator=(const QQuickGraphicsDevice &other); |
| 32 | |
| 33 | bool isNull() const; |
| 34 | |
| 35 | #if QT_CONFIG(opengl) || defined(Q_QDOC) |
| 36 | static QQuickGraphicsDevice fromOpenGLContext(QOpenGLContext *context); |
| 37 | #endif |
| 38 | |
| 39 | #if defined(Q_OS_WIN) || defined(Q_QDOC) |
| 40 | static QQuickGraphicsDevice fromAdapter(quint32 adapterLuidLow, qint32 adapterLuidHigh, int featureLevel = 0); |
| 41 | static QQuickGraphicsDevice fromDeviceAndContext(void *device, void *context); |
| 42 | #endif |
| 43 | |
| 44 | #if QT_CONFIG(metal) || defined(Q_QDOC) |
| 45 | static QQuickGraphicsDevice fromDeviceAndCommandQueue(MTLDevice *device, MTLCommandQueue *commandQueue); |
| 46 | #endif |
| 47 | |
| 48 | #if QT_CONFIG(vulkan) || defined(Q_QDOC) |
| 49 | static QQuickGraphicsDevice fromPhysicalDevice(VkPhysicalDevice physicalDevice); |
| 50 | static QQuickGraphicsDevice fromDeviceObjects(VkPhysicalDevice physicalDevice, VkDevice device, int queueFamilyIndex, int queueIndex = 0); |
| 51 | #endif |
| 52 | |
| 53 | static QQuickGraphicsDevice fromRhi(QRhi *rhi); |
| 54 | static QQuickGraphicsDevice fromRhiAdapter(QRhiAdapter *adapter); |
| 55 | |
| 56 | private: |
| 57 | void detach(); |
| 58 | QQuickGraphicsDevicePrivate *d; |
| 59 | friend class QQuickGraphicsDevicePrivate; |
| 60 | }; |
| 61 | |
| 62 | QT_END_NAMESPACE |
| 63 | |
| 64 | #endif // QQUICKGRAPHICSDEVICE_H |
| 65 |
