1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QOPENXRGRAPHICSVULKAN_H
5#define QOPENXRGRAPHICSVULKAN_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
19#include <QtQuick3DXr/private/qabstractopenxrgraphics_p.h>
20#include <QtQuick3DXr/private/qopenxrplatform_p.h>
21#include <QtGui/QVulkanInstance>
22#include <QtQuick/QQuickGraphicsConfiguration>
23
24QT_BEGIN_NAMESPACE
25
26class QRhiTexture;
27
28class QOpenXRGraphicsVulkan : public QAbstractOpenXRGraphics
29{
30public:
31 QOpenXRGraphicsVulkan();
32
33 const char *extensionName() const override;
34 bool isExtensionSupported(const QVector<XrExtensionProperties> &extensions) const override;
35 const XrBaseInStructure *handle() const override;
36 bool setupGraphics(const XrInstance &instance, XrSystemId &systemId, const QQuickGraphicsConfiguration &quickConfig) override;
37 bool finializeGraphics(QRhi *rhi) override;
38 int64_t colorSwapchainFormat(const QVector<int64_t> &swapchainFormats) const override;
39 int64_t depthSwapchainFormat(const QVector<int64_t> &swapchainFormats) const override;
40 QVector<XrSwapchainImageBaseHeader*> allocateSwapchainImages(int count, XrSwapchain swapchain) override;
41 QQuickRenderTarget renderTarget(const XrSwapchainSubImage &subImage, const XrSwapchainImageBaseHeader *swapchainImage,
42 quint64 swapchainFormat, int samples, int arraySize,
43 const XrSwapchainImageBaseHeader *depthSwapchainImage, quint64 depthSwapchainFormat) const override;
44 void setupWindow(QQuickWindow *quickWindow) override;
45 QRhi *rhi() const override { return m_rhi; }
46 void releaseResources() override;
47
48private:
49 QVulkanInstance m_vulkanInstance;
50 VkDevice m_vulkanDevice;
51 VkPhysicalDevice m_vulkanPhysicalDevice;
52 VkQueue m_vulkanCommandQueue;
53 QQuickGraphicsConfiguration m_graphicsConfiguration;
54 int m_queueFamilyIndex = -1;
55 XrGraphicsBindingVulkanKHR m_graphicsBinding{};
56 QMap<XrSwapchain, QVector<XrSwapchainImageVulkanKHR>> m_swapchainImageBuffer;
57 QRhi *m_rhi = nullptr;
58 mutable QRhiTexture *m_depthTexture = nullptr;
59};
60
61QT_END_NAMESPACE
62
63#endif // QOPENXRGRAPHICSVULKAN_H
64

source code of qtquick3d/src/xr/quick3dxr/openxr/qopenxrgraphics_vulkan_p.h