aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2019-08-26 15:22:41 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2019-09-08 09:40:49 +0200
commit144d4ec0262680aa9cf7732e3896a836ec126a71 (patch)
treedde015f6732d271b76d688cbf7a0988d00067758
parent81ac3bd856e7c6ead21fc2efc34cdf52cd9196b1 (diff)
Expose renderpass from QSGRendererInterface
Important for Vulkan and (upcoming) examples like vulkanunderqml. Change-Id: I5b6c978f38175eca76efe059aa83bb7158724752 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
-rw-r--r--src/quick/scenegraph/coreapi/qsgrendererinterface.cpp4
-rw-r--r--src/quick/scenegraph/coreapi/qsgrendererinterface.h3
-rw-r--r--src/quick/scenegraph/qsgdefaultrendercontext.cpp3
-rw-r--r--src/quick/scenegraph/qsgdefaultrendercontext_p.h6
-rw-r--r--src/quick/scenegraph/qsgrhisupport.cpp18
5 files changed, 30 insertions, 4 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp b/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp
index e504fe1c62..bc68199e08 100644
--- a/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrendererinterface.cpp
@@ -134,6 +134,10 @@ QT_BEGIN_NAMESPACE
\value VulkanInstanceResource The resource is a pointer to the
QVulkanInstance used by the scenegraph, when applicable.
+
+ \value RenderPassResource The resource is a pointer to the render pass used
+ by the scenegraph, describing the color and depth/stecil attachments and
+ how they are used. For example, a \c{VkRenderPass *}.
*/
/*!
diff --git a/src/quick/scenegraph/coreapi/qsgrendererinterface.h b/src/quick/scenegraph/coreapi/qsgrendererinterface.h
index 3052c81f6c..7aa7d0e769 100644
--- a/src/quick/scenegraph/coreapi/qsgrendererinterface.h
+++ b/src/quick/scenegraph/coreapi/qsgrendererinterface.h
@@ -72,7 +72,8 @@ public:
OpenGLContextResource,
DeviceContextResource,
CommandEncoderResource,
- VulkanInstanceResource
+ VulkanInstanceResource,
+ RenderPassResource
};
enum ShaderType {
diff --git a/src/quick/scenegraph/qsgdefaultrendercontext.cpp b/src/quick/scenegraph/qsgdefaultrendercontext.cpp
index b6f35b8580..4ccaa91cce 100644
--- a/src/quick/scenegraph/qsgdefaultrendercontext.cpp
+++ b/src/quick/scenegraph/qsgdefaultrendercontext.cpp
@@ -68,6 +68,7 @@ QSGDefaultRenderContext::QSGDefaultRenderContext(QSGContext *context)
, m_glAtlasManager(nullptr)
, m_rhiAtlasManager(nullptr)
, m_currentFrameCommandBuffer(nullptr)
+ , m_currentFrameRenderPass(nullptr)
{
}
@@ -239,6 +240,7 @@ void QSGDefaultRenderContext::beginNextRhiFrame(QSGRenderer *renderer, QRhiRende
renderer->setRenderPassRecordingCallbacks(mainPassRecordingStart, mainPassRecordingEnd, callbackUserData);
m_currentFrameCommandBuffer = cb;
+ m_currentFrameRenderPass = rp;
}
void QSGDefaultRenderContext::renderNextRhiFrame(QSGRenderer *renderer)
@@ -250,6 +252,7 @@ void QSGDefaultRenderContext::endNextRhiFrame(QSGRenderer *renderer)
{
Q_UNUSED(renderer);
m_currentFrameCommandBuffer = nullptr;
+ m_currentFrameRenderPass = nullptr;
}
/*!
diff --git a/src/quick/scenegraph/qsgdefaultrendercontext_p.h b/src/quick/scenegraph/qsgdefaultrendercontext_p.h
index 79bc9dd76d..6a3462ae2b 100644
--- a/src/quick/scenegraph/qsgdefaultrendercontext_p.h
+++ b/src/quick/scenegraph/qsgdefaultrendercontext_p.h
@@ -62,6 +62,7 @@ QT_BEGIN_NAMESPACE
class QRhi;
class QRhiCommandBuffer;
+class QRhiRenderPassDescriptor;
class QOpenGLContext;
class QSGMaterialShader;
class QSGMaterialRhiShader;
@@ -145,6 +146,10 @@ public:
// may be null if not in an active frame, but returning null is valid then
return m_currentFrameCommandBuffer;
}
+ QRhiRenderPassDescriptor *currentFrameRenderPass() const {
+ // may be null if not in an active frame, but returning null is valid then
+ return m_currentFrameRenderPass;
+ }
protected:
static QString fontKey(const QRawFont &font);
@@ -160,6 +165,7 @@ protected:
QSGOpenGLAtlasTexture::Manager *m_glAtlasManager;
QSGRhiAtlasTexture::Manager *m_rhiAtlasManager;
QRhiCommandBuffer *m_currentFrameCommandBuffer;
+ QRhiRenderPassDescriptor *m_currentFrameRenderPass;
};
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp
index a92b6b0c84..e050938cc9 100644
--- a/src/quick/scenegraph/qsgrhisupport.cpp
+++ b/src/quick/scenegraph/qsgrhisupport.cpp
@@ -279,12 +279,16 @@ QSurface::SurfaceType QSGRhiSupport::windowSurfaceType() const
}
#if QT_CONFIG(vulkan)
-static const void *qsgrhi_vk_rifResource(QSGRendererInterface::Resource res, const QRhiNativeHandles *nat,
- const QRhiNativeHandles *cbNat)
+static const void *qsgrhi_vk_rifResource(QSGRendererInterface::Resource res,
+ const QRhiNativeHandles *nat,
+ const QRhiNativeHandles *cbNat,
+ const QRhiNativeHandles *rpNat)
{
const QRhiVulkanNativeHandles *vknat = static_cast<const QRhiVulkanNativeHandles *>(nat);
const QRhiVulkanCommandBufferNativeHandles *maybeVkCbNat =
static_cast<const QRhiVulkanCommandBufferNativeHandles *>(cbNat);
+ const QRhiVulkanRenderPassNativeHandles *maybeVkRpNat =
+ static_cast<const QRhiVulkanRenderPassNativeHandles *>(rpNat);
switch (res) {
case QSGRendererInterface::DeviceResource:
@@ -298,6 +302,11 @@ static const void *qsgrhi_vk_rifResource(QSGRendererInterface::Resource res, con
return nullptr;
case QSGRendererInterface::PhysicalDeviceResource:
return &vknat->physDev;
+ case QSGRendererInterface::RenderPassResource:
+ if (maybeVkRpNat)
+ return &maybeVkRpNat->renderPass;
+ else
+ return nullptr;
default:
return nullptr;
}
@@ -376,7 +385,10 @@ const void *QSGRhiSupport::rifResource(QSGRendererInterface::Resource res, const
case QRhi::Vulkan:
{
QRhiCommandBuffer *cb = rc->currentFrameCommandBuffer();
- return qsgrhi_vk_rifResource(res, nat, cb ? cb->nativeHandles() : nullptr);
+ QRhiRenderPassDescriptor *rp = rc->currentFrameRenderPass();
+ return qsgrhi_vk_rifResource(res, nat,
+ cb ? cb->nativeHandles() : nullptr,
+ rp ? rp->nativeHandles() : nullptr);
}
#endif
#if QT_CONFIG(opengl)