Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qrhi_platform.h
Go to the documentation of this file.
1// Copyright (C) 2023 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 QRHIPLATFORM_H
5#define QRHIPLATFORM_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is part of the RHI API, with limited compatibility guarantees.
12// Usage of this API may make your code source and binary incompatible with
13// future versions of Qt.
14//
15
16#include <rhi/qrhi.h>
17
18#if QT_CONFIG(opengl)
19#include <QtGui/qsurfaceformat.h>
20#endif
21
22#if QT_CONFIG(vulkan)
23#include <QtGui/qvulkaninstance.h>
24#endif
25
26#if QT_CONFIG(metal) || defined(Q_QDOC)
28Q_FORWARD_DECLARE_OBJC_CLASS(MTLCommandQueue);
29Q_FORWARD_DECLARE_OBJC_CLASS(MTLCommandBuffer);
30Q_FORWARD_DECLARE_OBJC_CLASS(MTLRenderCommandEncoder);
31#endif
32
34
35struct Q_GUI_EXPORT QRhiNullInitParams : public QRhiInitParams
36{
37};
38
39struct Q_GUI_EXPORT QRhiNullNativeHandles : public QRhiNativeHandles
40{
41};
42
43#if QT_CONFIG(opengl) || defined(Q_QDOC)
44
45class QOpenGLContext;
47class QSurface;
48class QWindow;
49
50struct Q_GUI_EXPORT QRhiGles2InitParams : public QRhiInitParams
51{
53
55 QSurface *fallbackSurface = nullptr;
56 QWindow *window = nullptr;
57 QOpenGLContext *shareContext = nullptr;
58
59 static QOffscreenSurface *newFallbackSurface(const QSurfaceFormat &format = QSurfaceFormat::defaultFormat());
60};
61
62struct Q_GUI_EXPORT QRhiGles2NativeHandles : public QRhiNativeHandles
63{
64 QOpenGLContext *context = nullptr;
65};
66
67#endif // opengl/qdoc
68
69#if (QT_CONFIG(vulkan) && __has_include(<vulkan/vulkan.h>)) || defined(Q_QDOC)
70
71struct Q_GUI_EXPORT QRhiVulkanInitParams : public QRhiInitParams
72{
73 QVulkanInstance *inst = nullptr;
74 QWindow *window = nullptr;
75 QByteArrayList deviceExtensions;
76
77 static QByteArrayList preferredInstanceExtensions();
78 static QByteArrayList preferredExtensionsForImportedDevice();
79};
80
81struct Q_GUI_EXPORT QRhiVulkanNativeHandles : public QRhiNativeHandles
82{
83 // to import a physical device (always required)
84 VkPhysicalDevice physDev = VK_NULL_HANDLE;
85 // to import a device and queue
86 VkDevice dev = VK_NULL_HANDLE;
87 quint32 gfxQueueFamilyIdx = 0;
88 quint32 gfxQueueIdx = 0;
89 // and optionally, the mem allocator
90 void *vmemAllocator = nullptr;
91
92 // only for querying (rhi->nativeHandles())
93 VkQueue gfxQueue = VK_NULL_HANDLE;
94 QVulkanInstance *inst = nullptr;
95};
96
98{
99 VkCommandBuffer commandBuffer = VK_NULL_HANDLE;
100};
101
102struct Q_GUI_EXPORT QRhiVulkanRenderPassNativeHandles : public QRhiNativeHandles
103{
104 VkRenderPass renderPass = VK_NULL_HANDLE;
105};
106
107#endif // vulkan/qdoc
108
109#if defined(Q_OS_WIN) || defined(Q_QDOC)
110
111// no d3d includes here, to prevent precompiled header mess due to COM, hence the void pointers
112
113struct Q_GUI_EXPORT QRhiD3D11InitParams : public QRhiInitParams
114{
115 bool enableDebugLayer = false;
116};
117
118struct Q_GUI_EXPORT QRhiD3D11NativeHandles : public QRhiNativeHandles
119{
120 // to import a device and a context
121 void *dev = nullptr;
122 void *context = nullptr;
123 // alternatively, to specify the device feature level and/or the adapter to use
124 int featureLevel = 0;
125 quint32 adapterLuidLow = 0;
126 qint32 adapterLuidHigh = 0;
127};
128
129struct Q_GUI_EXPORT QRhiD3D12InitParams : public QRhiInitParams
130{
131 bool enableDebugLayer = false;
132};
133
134struct Q_GUI_EXPORT QRhiD3D12NativeHandles : public QRhiNativeHandles
135{
136 // to import a device
137 void *dev = nullptr;
138 int minimumFeatureLevel = 0;
139 // to just specify the adapter to use, set these and leave dev set to null
140 quint32 adapterLuidLow = 0;
141 qint32 adapterLuidHigh = 0;
142 // in addition, can specify the command queue to use
143 void *commandQueue = nullptr;
144};
145
146struct Q_GUI_EXPORT QRhiD3D12CommandBufferNativeHandles : public QRhiNativeHandles
147{
148 void *commandList = nullptr; // ID3D12GraphicsCommandList1
149};
150
151#endif // WIN/QDOC
152
153#if QT_CONFIG(metal) || defined(Q_QDOC)
154
155struct Q_GUI_EXPORT QRhiMetalInitParams : public QRhiInitParams
156{
157};
158
159struct Q_GUI_EXPORT QRhiMetalNativeHandles : public QRhiNativeHandles
160{
161 MTLDevice *dev = nullptr;
162 MTLCommandQueue *cmdQueue = nullptr;
163};
164
166{
167 MTLCommandBuffer *commandBuffer = nullptr;
168 MTLRenderCommandEncoder *encoder = nullptr;
169};
170
171#endif // MACOS/IOS/QDOC
172
174
175#endif
\inmodule QtCore
\inmodule QtGui
\inmodule QtGui
\inmodule QtGui
\variable QRhiD3D11InitParams::enableDebugLayer
\inmodule QtGui
\variable QRhiGles2InitParams::format
\variable QRhiMetalNativeHandles::dev
\inmodule QtRhi
\inmodule QtRhi
\variable QRhiVulkanNativeHandles::physDev
\inmodule QtGui
\variable QRhiVulkanInitParams::inst
\variable QRhiVulkanCommandBufferNativeHandles::commandBuffer
The QSurfaceFormat class represents the format of a QSurface. \inmodule QtGui.
static QSurfaceFormat defaultFormat()
Returns the global default surface format.
\inmodule QtGui
Definition qsurface.h:21
The QVulkanInstance class represents a native Vulkan instance, enabling Vulkan rendering onto a QSurf...
\inmodule QtGui
Definition qwindow.h:63
Combined button and popup list for selecting options.
static void * context
#define Q_FORWARD_DECLARE_OBJC_CLASS(classname)
GLint GLsizei GLsizei GLenum format
unsigned int quint32
Definition qtypes.h:50
int qint32
Definition qtypes.h:49
aWidget window() -> setWindowTitle("New Window Title")
[2]
\inmodule QtGui
Definition qrhi.h:1800
\variable QRhiReadbackResult::completed
Definition qrhi.h:800
\inmodule QtGui
\inmodule QtGui