1// Copyright (C) 2017 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#include <private/qvulkanfunctions_p.h>
5
6QT_BEGIN_NAMESPACE
7
8/*!
9 \class QVulkanFunctions
10 \since 5.10
11 \ingroup painting-3D
12 \inmodule QtGui
13 \wrapper
14
15 \brief The QVulkanFunctions class provides cross-platform access to the
16 instance level core Vulkan 1.2 API.
17
18 Qt and Qt applications do not link to any Vulkan libraries by default.
19 Instead, all functions are resolved dynamically at run time. Each
20 QVulkanInstance provides a QVulkanFunctions object retrievable via
21 QVulkanInstance::functions(). This does not contain device level functions
22 in order to avoid the potential overhead of an internal dispatching.
23 Instead, functions that rely on a device, or a dispatchable child object of
24 a device, are exposed via QVulkanDeviceFunctions and
25 QVulkanInstance::deviceFunctions(). QVulkanFunctions and
26 QVulkanDeviceFunctions together provides access to the full core Vulkan
27 API, excluding any extensions.
28
29 \note QVulkanFunctions instances cannot be constructed directly.
30
31 The typical usage is the following:
32
33 \snippet code/src_gui_vulkan_qvulkanfunctions.cpp 0
34
35 \note Windowing system interface (WSI) specifics and extensions are
36 excluded. This class only covers core Vulkan commands, with the exception
37 of instance creation, destruction, and function resolving, since such
38 functionality is covered by QVulkanInstance itself.
39
40 To access additional functions, applications can use
41 QVulkanInstance::getInstanceProcAddr() and vkGetDeviceProcAddr().
42 Applications can also decide to link to a Vulkan library directly, as
43 platforms with an appropriate loader will typically export function symbols
44 for the core commands. See
45 \l{https://www.khronos.org/registry/vulkan/specs/1.0/man/html/vkGetInstanceProcAddr.html}{the
46 man page for vkGetInstanceProcAddr} for more information.
47
48 \note The member function prototypes for Vulkan 1.1 and 1.2 commands are
49 ifdefed with the appropriate \c{VK_VERSION_1_x} that is defined by the
50 Vulkan headers. Therefore these functions will only be callable by an
51 application when the system's (on which the application is built) Vulkan
52 header is new enough and it contains 1.1 and 1.2 Vulkan API definitions.
53 When building Qt from source, this has an additional consequence: the
54 Vulkan headers on the build environment must also be 1.1 and 1.2 capable in
55 order to get a Qt build that supports resolving the 1.1 and 1.2 API
56 commands. If either of these conditions is not met, applications will only
57 be able to call the Vulkan 1.0 commands through QVulkanFunctions and
58 QVulkanDeviceFunctions.
59
60 \sa QVulkanInstance, QVulkanDeviceFunctions, QWindow::setVulkanInstance(), QWindow::setSurfaceType()
61*/
62
63/*!
64 \class QVulkanDeviceFunctions
65 \since 5.10
66 \ingroup painting-3D
67 \inmodule QtGui
68 \wrapper
69
70 \brief The QVulkanDeviceFunctions class provides cross-platform access to
71 the device level core Vulkan 1.2 API.
72
73 Qt and Qt applications do not link to any Vulkan libraries by default.
74 Instead, all functions are resolved dynamically at run time. Each
75 QVulkanInstance provides a QVulkanFunctions object retrievable via
76 QVulkanInstance::functions(). This does not contain device level functions
77 in order to avoid the potential overhead of an internal dispatching.
78 Instead, functions that rely on a device, or a dispatchable child object of
79 a device, are exposed via QVulkanDeviceFunctions and
80 QVulkanInstance::deviceFunctions(). QVulkanFunctions and
81 QVulkanDeviceFunctions together provides access to the full core Vulkan
82 API, excluding any extensions.
83
84 \note QVulkanDeviceFunctions instances cannot be constructed directly.
85
86 The typical usage is the following:
87
88 \snippet code/src_gui_vulkan_qvulkanfunctions.cpp 1
89
90 The QVulkanDeviceFunctions object specific to the provided VkDevice is
91 created when QVulkanInstance::deviceFunctions() is first called with the
92 device in question. The object is then cached internally.
93
94 To access additional functions, applications can use
95 QVulkanInstance::getInstanceProcAddr() and vkGetDeviceProcAddr().
96 Applications can also decide to link to a Vulkan library directly, as many
97 implementations export function symbols for the core commands. See
98 \l{https://www.khronos.org/registry/vulkan/specs/1.0/man/html/vkGetInstanceProcAddr.html}{the
99 man page for vkGetInstanceProcAddr} for more information.
100
101 \sa QVulkanInstance, QVulkanFunctions, QWindow::setVulkanInstance(), QWindow::setSurfaceType()
102*/
103
104/*
105 Constructs a new QVulkanFunctions for \a inst.
106 \internal
107 */
108QVulkanFunctions::QVulkanFunctions(QVulkanInstance *inst)
109 : d_ptr(new QVulkanFunctionsPrivate(inst))
110{
111}
112
113/*
114 Destructor.
115 */
116QVulkanFunctions::~QVulkanFunctions()
117{
118}
119
120/*
121 Constructs a new QVulkanDeviceFunctions for \a inst and the given \a device.
122 \internal
123 */
124QVulkanDeviceFunctions::QVulkanDeviceFunctions(QVulkanInstance *inst, VkDevice device)
125 : d_ptr(new QVulkanDeviceFunctionsPrivate(inst, device))
126{
127}
128
129/*
130 Destructor.
131 */
132QVulkanDeviceFunctions::~QVulkanDeviceFunctions()
133{
134}
135
136QT_END_NAMESPACE
137

source code of qtbase/src/gui/vulkan/qvulkanfunctions.cpp