aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/coreapi/qsgrenderer_p.h
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2021-09-15 14:07:15 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2021-09-24 11:53:42 +0200
commit70bf4b44eec066d2692b6deac42fc801e32b477a (patch)
tree06aaaa3abc5851cedf8da93ccb6128e0334e1aec /src/quick/scenegraph/coreapi/qsgrenderer_p.h
parent23f8f821f3d6c9041dd95ddb5d8bffd8fc8b64ef (diff)
Get rid of renderpass descriptor objects from the pipeline cache keys
Follow what we did to the srb: instead of storing an object reference, store an opaque blob to test for compatibility. This works even if the object is destroyed in the meantime. Thus, the annoying and error-prone invalidatePipelineCacheDependency() goes away, finally. All this works because creating a QRhiGraphicsPipeline with a given QRhiRenderPassDescriptor only needs the renderpass object for building (as in create()). Afterwards the object can be destroyed, even. The pipeline is still usable with any render targets that have a _compatible_ rp descriptor. Therefore, it is ideal if there is a way to test for this compatibility without having to have the original object around for ever. Relies on enablers (most importantly, QRhiRenderPassDescriptor::serializedFormat()) added to QRhi in qtbase. While not necessarily obvious, the real benefit here is significant performance gains in certain situations: consider rendering a scene to a given render target, then to another one, then yet another one, for example via QQuickRenderControl. We no longer have to do aggressive purging of the pipelines just because a QRhiRenderPassDescriptor some of the recently created pipelines may be associated with is going to disappear. Rather, everything can stay as-is, there are no crashes due to dangling pointers in the pipeline cache keys. The majority of cases involve highly compatible render targets (e.g. rendering into textures of the same format), so reuse is highly beneficial. Change-Id: I8ad4bfcb3c7e66c7364c91a749e2a2e6837b4f1a Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit 5e3de6aa6083f0cf312e60dc4fc9a7d999bc6c90)
Diffstat (limited to 'src/quick/scenegraph/coreapi/qsgrenderer_p.h')
-rw-r--r--src/quick/scenegraph/coreapi/qsgrenderer_p.h13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgrenderer_p.h b/src/quick/scenegraph/coreapi/qsgrenderer_p.h
index 31f00dc738..9f1ab6a99b 100644
--- a/src/quick/scenegraph/coreapi/qsgrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgrenderer_p.h
@@ -97,7 +97,6 @@ public:
virtual void setVisualizationMode(const QByteArray &) { }
virtual bool hasVisualizationModeWithContinuousUpdate() const { return false; }
virtual void releaseCachedResources() { }
- virtual void invalidatePipelineCacheDependency(QRhiRenderPassDescriptor *) { }
void clearChangedFlag() { m_changed_emitted = false; }
@@ -116,15 +115,8 @@ public:
QRhiRenderPassDescriptor *renderPassDescriptor() const { return m_rp_desc; }
void setExternalRenderPassDescriptor(QRhiRenderPassDescriptor *rpDesc) {
- if (m_external_rp_desc) {
- // Changes will be rare in practice - one has to construct a
- // dynamic Quick 3D scene with reparenting involved for that. Play
- // nice nonetheless and invalidate as soon as possible.
- if (m_external_rp_desc != rpDesc)
- invalidatePipelineCacheDependency(m_external_rp_desc);
- }
- m_rp_desc = rpDesc;
- m_external_rp_desc = rpDesc;
+ // no differentiation needed anymore
+ setRenderPassDescriptor(rpDesc);
}
void setRenderPassRecordingCallbacks(QSGRenderContext::RenderPassCallback start,
@@ -162,7 +154,6 @@ protected:
QRhiRenderTarget *m_rt;
QRhiCommandBuffer *m_cb;
QRhiRenderPassDescriptor *m_rp_desc;
- QRhiRenderPassDescriptor *m_external_rp_desc;
struct {
QSGRenderContext::RenderPassCallback start = nullptr;
QSGRenderContext::RenderPassCallback end = nullptr;