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 QVKKHRDISPLAYVULKANINSTANCE_H
5#define QVKKHRDISPLAYVULKANINSTANCE_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/private/qbasicvulkanplatforminstance_p.h>
19#include <QtCore/qsize.h>
20
21QT_BEGIN_NAMESPACE
22
23class QVkKhrDisplayVulkanInstance : public QBasicPlatformVulkanInstance
24{
25public:
26 QVkKhrDisplayVulkanInstance(QVulkanInstance *instance);
27
28 void createOrAdoptInstance() override;
29 bool supportsPresent(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, QWindow *window) override;
30 void presentAboutToBeQueued(QWindow *window) override;
31
32 VkSurfaceKHR createSurface(QWindow *window);
33
34 QSize displaySize() const { return QSize(int(m_width), int(m_height)); }
35
36 using CreatedCallback = void (*)(QVkKhrDisplayVulkanInstance *, void *);
37 void setCreatedCallback(CreatedCallback callback, void *userData) {
38 m_createdCallback = callback;
39 m_createdCallbackUserData = userData;
40 }
41
42private:
43 bool chooseDisplay();
44
45 QVulkanInstance *m_instance;
46 VkPhysicalDevice m_physDev = VK_NULL_HANDLE;
47 PFN_vkEnumeratePhysicalDevices m_enumeratePhysicalDevices = nullptr;
48 PFN_vkGetPhysicalDeviceSurfaceSupportKHR m_getPhysicalDeviceSurfaceSupportKHR = nullptr;
49#if VK_KHR_display
50 PFN_vkGetPhysicalDeviceDisplayPropertiesKHR m_getPhysicalDeviceDisplayPropertiesKHR = nullptr;
51 PFN_vkGetDisplayModePropertiesKHR m_getDisplayModePropertiesKHR = nullptr;
52 PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR m_getPhysicalDeviceDisplayPlanePropertiesKHR = nullptr;
53 PFN_vkGetDisplayPlaneSupportedDisplaysKHR m_getDisplayPlaneSupportedDisplaysKHR = nullptr;
54 PFN_vkGetDisplayPlaneCapabilitiesKHR m_getDisplayPlaneCapabilitiesKHR = nullptr;
55 PFN_vkCreateDisplayPlaneSurfaceKHR m_createDisplayPlaneSurfaceKHR = nullptr;
56#endif
57
58 CreatedCallback m_createdCallback = nullptr;
59 void *m_createdCallbackUserData = nullptr;
60 VkDisplayKHR m_display = VK_NULL_HANDLE;
61 VkDisplayModeKHR m_displayMode = VK_NULL_HANDLE;
62 uint32_t m_width = 0;
63 uint32_t m_height = 0;
64 uint32_t m_planeIndex = UINT_MAX;
65 uint32_t m_planeStackIndex = UINT_MAX;
66};
67
68QT_END_NAMESPACE
69
70#endif
71

source code of qtbase/src/plugins/platforms/vkkhrdisplay/qvkkhrdisplayvulkaninstance.h