summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2019-08-26 15:19:59 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2019-08-29 10:22:41 +0200
commit2d7fc7a1527211fb9e41310b3ea75ba6d61cee8d (patch)
treecd04e3ee1b8cd7eb577915dd5a5b2b7379c7251d /src/gui/rhi
parentd6551fe125209f11445936a90ce2a4207a183917 (diff)
rhi: vulkan: Expose the VkRenderPass via the usual mechanisms
Qt Quick in turn will expose it via QSGRendererInterface. Essential when adding custom Vulkan rendering into a Qt Quick application because the custom pipeline state objects will need to reference a VkRenderPass. Change-Id: Idf4092cfc3937830fb8123164081059b0d8d030e Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/gui/rhi')
-rw-r--r--src/gui/rhi/qrhi.cpp16
-rw-r--r--src/gui/rhi/qrhi_p.h2
-rw-r--r--src/gui/rhi/qrhivulkan.cpp13
-rw-r--r--src/gui/rhi/qrhivulkan_p.h5
-rw-r--r--src/gui/rhi/qrhivulkan_p_p.h2
5 files changed, 38 insertions, 0 deletions
diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp
index 1076b21c1e..0f4b3d675a 100644
--- a/src/gui/rhi/qrhi.cpp
+++ b/src/gui/rhi/qrhi.cpp
@@ -2246,6 +2246,10 @@ QRhiResource::Type QRhiSampler::resourceType() const
\internal
\inmodule QtGui
\brief Render pass resource.
+
+ A render pass, if such a concept exists in the underlying graphics API, is
+ a collection of attachments (color, depth, stencil) and describes how those
+ attachments are used.
*/
/*!
@@ -2265,6 +2269,18 @@ QRhiResource::Type QRhiRenderPassDescriptor::resourceType() const
}
/*!
+ \return a pointer to a backend-specific QRhiNativeHandles subclass, such as
+ QRhiVulkanRenderPassNativeHandles. The returned value is null when exposing
+ the underlying native resources is not supported by the backend.
+
+ \sa QRhiVulkanRenderPassNativeHandles
+ */
+const QRhiNativeHandles *QRhiRenderPassDescriptor::nativeHandles()
+{
+ return nullptr;
+}
+
+/*!
\class QRhiRenderTarget
\internal
\inmodule QtGui
diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h
index df30817ef4..51c60f1831 100644
--- a/src/gui/rhi/qrhi_p.h
+++ b/src/gui/rhi/qrhi_p.h
@@ -843,6 +843,8 @@ class Q_GUI_EXPORT QRhiRenderPassDescriptor : public QRhiResource
public:
QRhiResource::Type resourceType() const override;
+ virtual const QRhiNativeHandles *nativeHandles();
+
protected:
QRhiRenderPassDescriptor(QRhiImplementation *rhi);
};
diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp
index 321fd92f88..a0f32252cf 100644
--- a/src/gui/rhi/qrhivulkan.cpp
+++ b/src/gui/rhi/qrhivulkan.cpp
@@ -182,6 +182,13 @@ QT_BEGIN_NAMESPACE
\l{QRhi::endOffsrceenFrame()}{endOffscreenFrame()} pair.
*/
+/*!
+ \class QRhiVulkanRenderPassNativeHandles
+ \internal
+ \inmodule QtGui
+ \brief Holds the Vulkan render pass object backing a QRhiRenderPassDescriptor.
+ */
+
static inline VkDeviceSize aligned(VkDeviceSize v, VkDeviceSize byteAlign)
{
return (v + byteAlign - 1) & ~(byteAlign - 1);
@@ -5098,6 +5105,12 @@ void QVkRenderPassDescriptor::release()
rhiD->unregisterResource(this);
}
+const QRhiNativeHandles *QVkRenderPassDescriptor::nativeHandles()
+{
+ nativeHandlesStruct.renderPass = rp;
+ return &nativeHandlesStruct;
+}
+
QVkReferenceRenderTarget::QVkReferenceRenderTarget(QRhiImplementation *rhi)
: QRhiRenderTarget(rhi)
{
diff --git a/src/gui/rhi/qrhivulkan_p.h b/src/gui/rhi/qrhivulkan_p.h
index 545ef5ad72..ff19c7a54e 100644
--- a/src/gui/rhi/qrhivulkan_p.h
+++ b/src/gui/rhi/qrhivulkan_p.h
@@ -80,6 +80,11 @@ struct Q_GUI_EXPORT QRhiVulkanCommandBufferNativeHandles : public QRhiNativeHand
VkCommandBuffer commandBuffer = VK_NULL_HANDLE;
};
+struct Q_GUI_EXPORT QRhiVulkanRenderPassNativeHandles : public QRhiNativeHandles
+{
+ VkRenderPass renderPass = VK_NULL_HANDLE;
+};
+
QT_END_NAMESPACE
#endif
diff --git a/src/gui/rhi/qrhivulkan_p_p.h b/src/gui/rhi/qrhivulkan_p_p.h
index 31e0eaa585..e2ea8fec2a 100644
--- a/src/gui/rhi/qrhivulkan_p_p.h
+++ b/src/gui/rhi/qrhivulkan_p_p.h
@@ -171,9 +171,11 @@ struct QVkRenderPassDescriptor : public QRhiRenderPassDescriptor
QVkRenderPassDescriptor(QRhiImplementation *rhi);
~QVkRenderPassDescriptor();
void release() override;
+ const QRhiNativeHandles *nativeHandles() override;
VkRenderPass rp = VK_NULL_HANDLE;
bool ownsRp = false;
+ QRhiVulkanRenderPassNativeHandles nativeHandlesStruct;
int lastActiveFrameSlot = -1;
};