From 2d7fc7a1527211fb9e41310b3ea75ba6d61cee8d Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 26 Aug 2019 15:19:59 +0200 Subject: 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 --- src/gui/rhi/qrhi.cpp | 16 ++++++++++++++++ src/gui/rhi/qrhi_p.h | 2 ++ src/gui/rhi/qrhivulkan.cpp | 13 +++++++++++++ src/gui/rhi/qrhivulkan_p.h | 5 +++++ src/gui/rhi/qrhivulkan_p_p.h | 2 ++ 5 files changed, 38 insertions(+) (limited to 'src/gui/rhi') 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. */ /*! @@ -2264,6 +2268,18 @@ QRhiResource::Type QRhiRenderPassDescriptor::resourceType() const return RenderPassDescriptor; } +/*! + \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 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; }; -- cgit v1.2.3