diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-01-15 18:38:06 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-01-21 10:19:01 +0100 |
commit | 3fadfb2c3fa7d4b22d0d0269c645c1086fa56619 (patch) | |
tree | a5bf744b7a54a20fb793b25479648e3f94bf1137 /src | |
parent | 6a156540004c9e6260490bacb6544322d22d9d32 (diff) |
Expose the list of preferred instance extensions to rendercontrol users
As all QRhi stuff is private, it needs to have a public counterpart in
Qt Quick in order to fully support the case of Vulkan-based
QQuickRenderControl usage.
Change-Id: Iaf9a7aa56022acd31af6ebf16de6b83a04966ff4
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquickgraphicsconfiguration.cpp | 28 | ||||
-rw-r--r-- | src/quick/items/qquickgraphicsconfiguration.h | 2 | ||||
-rw-r--r-- | src/quick/items/qquickrendercontrol.cpp | 13 |
3 files changed, 38 insertions, 5 deletions
diff --git a/src/quick/items/qquickgraphicsconfiguration.cpp b/src/quick/items/qquickgraphicsconfiguration.cpp index dcdd069d03..4d64cf0827 100644 --- a/src/quick/items/qquickgraphicsconfiguration.cpp +++ b/src/quick/items/qquickgraphicsconfiguration.cpp @@ -39,6 +39,10 @@ #include "qquickgraphicsconfiguration_p.h" +#if QT_CONFIG(vulkan) +#include <QtGui/private/qrhivulkan_p.h> +#endif + QT_BEGIN_NAMESPACE /*! @@ -139,6 +143,30 @@ QQuickGraphicsConfiguration::~QQuickGraphicsConfiguration() } /*! + \return the list of Vulkan instance extensions Qt Quick prefers to + have enabled on the VkInstance. + + In most cases Qt Quick is responsible for creating a QVulkanInstance. This + function is not relevant then. On the other hand, when using + QQuickRenderControl in combination with Vulkan-based rendering, it is the + application's responsibility to create a QVulkanInstance and associate it + with the (offscreen) QQuickWindow. In this case, it is expected that the + application queries the list of instance extensions to enable, and passes + them to QVulkanInstance::setExtensions() before calling + QVulkanInstance::create(). + + \since 6.1 + */ +QByteArrayList QQuickGraphicsConfiguration::preferredInstanceExtensions() +{ +#if QT_CONFIG(vulkan) + return QRhiVulkanInitParams::preferredInstanceExtensions(); +#else + return {}; +#endif +} + +/*! Sets the list of additional \a extensions to enable on the graphics device (such as, the \c VkDevice). diff --git a/src/quick/items/qquickgraphicsconfiguration.h b/src/quick/items/qquickgraphicsconfiguration.h index 1c65d27502..36a14257ce 100644 --- a/src/quick/items/qquickgraphicsconfiguration.h +++ b/src/quick/items/qquickgraphicsconfiguration.h @@ -55,6 +55,8 @@ public: QQuickGraphicsConfiguration(const QQuickGraphicsConfiguration &other); QQuickGraphicsConfiguration &operator=(const QQuickGraphicsConfiguration &other); + static QByteArrayList preferredInstanceExtensions(); + void setDeviceExtensions(const QByteArrayList &extensions); QByteArrayList deviceExtensions() const; diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp index c7a1ad973d..d71af669f0 100644 --- a/src/quick/items/qquickrendercontrol.cpp +++ b/src/quick/items/qquickrendercontrol.cpp @@ -273,10 +273,13 @@ int QQuickRenderControl::samples() const To configure which device extensions to enable (for example, for Vulkan), call QQuickWindow::setGraphicsConfiguration() before this function. - \note When using Vulkan, QQuickRenderControl does not create a - QVulkanInstance automatically. Rather, it is the application's - responsibility to create a suitable QVulkanInstance and - \l{QWindow::setVulkanInstance()}{associate it} with the QQuickWindow. + \note When using Vulkan, QQuickRenderControl does not create a QVulkanInstance + automatically. Rather, it is the application's responsibility to create a + suitable QVulkanInstance and \l{QWindow::setVulkanInstance()}{associate it} with + the QQuickWindow. Before initializing the QVulkanInstance, it is strongly + encouraged to query the list of Qt Quick's desired instance extensions by calling + the static function QQuickGraphicsConfiguration::preferredInstanceExtensions() + and to pass the returned list to QVulkanInstance::setExtensions(). Returns \c true on success, \c false otherwise. @@ -285,7 +288,7 @@ int QQuickRenderControl::samples() const \since 6.0 - \sa QQuickRenderTarget, QQuickGraphicsDevice + \sa QQuickRenderTarget, QQuickGraphicsDevice, QQuickGraphicsConfiguration::preferredInstanceExtensions() */ bool QQuickRenderControl::initialize() { |