1 | // Copyright (C) 2021 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 QBASICVULKANPLATFORMINSTANCE_P_H |
5 | #define QBASICVULKANPLATFORMINSTANCE_P_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 <QtGui/qtguiglobal.h> |
19 | |
20 | #include <QtCore/QLibrary> |
21 | #include <qpa/qplatformvulkaninstance.h> |
22 | #include <private/qglobal_p.h> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class Q_GUI_EXPORT QBasicPlatformVulkanInstance : public QPlatformVulkanInstance |
27 | { |
28 | public: |
29 | QBasicPlatformVulkanInstance(); |
30 | ~QBasicPlatformVulkanInstance(); |
31 | |
32 | QVulkanInfoVector<QVulkanLayer> supportedLayers() const override; |
33 | QVulkanInfoVector<QVulkanExtension> supportedExtensions() const override; |
34 | QVersionNumber supportedApiVersion() const override; |
35 | bool isValid() const override; |
36 | VkResult errorCode() const override; |
37 | VkInstance vkInstance() const override; |
38 | QByteArrayList enabledLayers() const override; |
39 | QByteArrayList enabledExtensions() const override; |
40 | PFN_vkVoidFunction getInstanceProcAddr(const char *name) override; |
41 | bool supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window) override; |
42 | void setDebugFilters(const QList<QVulkanInstance::DebugFilter> &filters) override; |
43 | void setDebugUtilsFilters(const QList<QVulkanInstance::DebugUtilsFilter> &filters) override; |
44 | |
45 | void destroySurface(VkSurfaceKHR surface) const; |
46 | const QList<QVulkanInstance::DebugFilter> *debugFilters() const { return &m_debugFilters; } |
47 | const QList<QVulkanInstance::DebugUtilsFilter> *debugUtilsFilters() const { return &m_debugUtilsFilters; } |
48 | |
49 | protected: |
50 | void loadVulkanLibrary(const QString &defaultLibraryName, int defaultLibraryVersion = -1); |
51 | void init(QLibrary *lib); |
52 | void initInstance(QVulkanInstance *instance, const QByteArrayList &extraExts); |
53 | |
54 | VkInstance m_vkInst = VK_NULL_HANDLE; |
55 | PFN_vkGetInstanceProcAddr m_vkGetInstanceProcAddr = nullptr; |
56 | PFN_vkGetPhysicalDeviceSurfaceSupportKHR m_getPhysDevSurfaceSupport; |
57 | PFN_vkDestroySurfaceKHR m_destroySurface; |
58 | |
59 | private: |
60 | void setupDebugOutput(); |
61 | |
62 | std::unique_ptr<QLibrary> m_vulkanLib; |
63 | |
64 | bool m_ownsVkInst = false; |
65 | VkResult m_errorCode = VK_SUCCESS; |
66 | QVulkanInfoVector<QVulkanLayer> m_supportedLayers; |
67 | QVulkanInfoVector<QVulkanExtension> m_supportedExtensions; |
68 | QVersionNumber m_supportedApiVersion; |
69 | QByteArrayList m_enabledLayers; |
70 | QByteArrayList m_enabledExtensions; |
71 | |
72 | PFN_vkCreateInstance m_vkCreateInstance; |
73 | PFN_vkEnumerateInstanceLayerProperties m_vkEnumerateInstanceLayerProperties; |
74 | PFN_vkEnumerateInstanceExtensionProperties m_vkEnumerateInstanceExtensionProperties; |
75 | |
76 | PFN_vkDestroyInstance m_vkDestroyInstance; |
77 | |
78 | #ifdef VK_EXT_debug_utils |
79 | VkDebugUtilsMessengerEXT m_debugMessenger = VK_NULL_HANDLE; |
80 | PFN_vkDestroyDebugUtilsMessengerEXT m_vkDestroyDebugUtilsMessengerEXT; |
81 | #endif |
82 | QList<QVulkanInstance::DebugFilter> m_debugFilters; |
83 | QList<QVulkanInstance::DebugUtilsFilter> m_debugUtilsFilters; |
84 | }; |
85 | |
86 | QT_END_NAMESPACE |
87 | |
88 | #endif // QBASICVULKANPLATFORMINSTANCE_P_H |
89 |