7#include <QtGui/qtguiglobal.h>
10#pragma qt_no_master_include
11#pragma qt_sync_skip_header_check
14#if QT_CONFIG(vulkan) || defined(Q_QDOC)
16#include <QtGui/qvulkaninstance.h>
17#include <QtGui/qwindow.h>
18#include <QtGui/qimage.h>
19#include <QtGui/qmatrix4x4.h>
20#include <QtCore/qset.h>
24typedef void* VkCommandPool;
25typedef void* VkRenderPass;
26typedef void* VkCommandBuffer;
27typedef void* VkFramebuffer;
28typedef int VkPhysicalDeviceProperties;
30typedef int VkQueueFamilyProperties;
31typedef int VkDeviceQueueCreateInfo;
33typedef int VkSampleCountFlagBits;
38class QVulkanWindowPrivate;
40class Q_GUI_EXPORT QVulkanWindowRenderer
43 virtual ~QVulkanWindowRenderer();
45 virtual void preInitResources();
46 virtual void initResources();
47 virtual void initSwapChainResources();
48 virtual void releaseSwapChainResources();
49 virtual void releaseResources();
51 virtual void startNextFrame() = 0;
53 virtual void physicalDeviceLost();
54 virtual void logicalDeviceLost();
58typedef struct VkPhysicalDeviceFeatures2 {
59 VkStructureType sType;
61 VkPhysicalDeviceFeatures features;
62} VkPhysicalDeviceFeatures2;
65class Q_GUI_EXPORT QVulkanWindow :
public QWindow
68 Q_DECLARE_PRIVATE(QVulkanWindow)
72 PersistentResources = 0x01
74 Q_DECLARE_FLAGS(Flags, Flag)
76 explicit QVulkanWindow(QWindow *parent =
nullptr);
79 void setFlags(Flags flags);
82 QList<VkPhysicalDeviceProperties> availablePhysicalDevices();
83 void setPhysicalDeviceIndex(
int idx);
85 QVulkanInfoVector<QVulkanExtension> supportedDeviceExtensions();
86 void setDeviceExtensions(
const QByteArrayList &extensions);
88 typedef std::function<
void(VkPhysicalDeviceFeatures &)> EnabledFeaturesModifier;
89 void setEnabledFeaturesModifier(
const EnabledFeaturesModifier &modifier);
90 typedef std::function<
void(VkPhysicalDeviceFeatures2 &)> EnabledFeatures2Modifier;
91 void setEnabledFeaturesModifier(EnabledFeatures2Modifier modifier);
93 void setPreferredColorFormats(
const QList<VkFormat> &formats);
95 QList<
int> supportedSampleCounts();
96 void setSampleCount(
int sampleCount);
98 typedef std::function<
void(
const VkQueueFamilyProperties *, uint32_t,
99 QList<VkDeviceQueueCreateInfo> &)>
100 QueueCreateInfoModifier;
101 void setQueueCreateInfoModifier(
const QueueCreateInfoModifier &modifier);
103 bool isValid()
const;
105 virtual QVulkanWindowRenderer *createRenderer();
108 VkPhysicalDevice physicalDevice()
const;
109 const VkPhysicalDeviceProperties *physicalDeviceProperties()
const;
110 VkDevice device()
const;
111 VkQueue graphicsQueue()
const;
112 uint32_t graphicsQueueFamilyIndex()
const;
113 VkCommandPool graphicsCommandPool()
const;
114 uint32_t hostVisibleMemoryIndex()
const;
115 uint32_t deviceLocalMemoryIndex()
const;
116 VkRenderPass defaultRenderPass()
const;
118 VkFormat colorFormat()
const;
119 VkFormat depthStencilFormat()
const;
120 QSize swapChainImageSize()
const;
122 VkCommandBuffer currentCommandBuffer()
const;
123 VkFramebuffer currentFramebuffer()
const;
124 int currentFrame()
const;
126 static const int MAX_CONCURRENT_FRAME_COUNT = 3;
127 int concurrentFrameCount()
const;
129 int swapChainImageCount()
const;
130 int currentSwapChainImageIndex()
const;
131 VkImage swapChainImage(
int idx)
const;
132 VkImageView swapChainImageView(
int idx)
const;
133 VkImage depthStencilImage()
const;
134 VkImageView depthStencilImageView()
const;
136 VkSampleCountFlagBits sampleCountFlagBits()
const;
137 VkImage msaaColorImage(
int idx)
const;
138 VkImageView msaaColorImageView(
int idx)
const;
140 bool supportsGrab()
const;
143 QMatrix4x4 clipCorrectionMatrix();
146 void frameGrabbed(
const QImage &image);
149 void exposeEvent(QExposeEvent *) override;
150 void resizeEvent(QResizeEvent *) override;
151 bool event(QEvent *) override;
154 Q_DISABLE_COPY(QVulkanWindow)
157Q_DECLARE_OPERATORS_FOR_FLAGS(QVulkanWindow::Flags)