summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2021-02-04 17:37:51 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-02-05 11:49:28 +0000
commit41f39169108b1e43ccfca32dc73ceaf16d2a41c8 (patch)
tree616af3cc1dd07293ebbf0abca1621088ddafcbbd
parenta16ba29f6fd5a72fc5b30a87eaf78f10ad9a9791 (diff)
Invalidate external renderpass descriptors from Quick3D
Change-Id: I362b35b3d038d4fb24fab0e73cb120027f2308ea Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit 93fe74ca433850e505f8f8940e99f3bf6a6dc050) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp5
-rw-r--r--src/quick/scenegraph/coreapi/qsgrenderer.cpp1
-rw-r--r--src/quick/scenegraph/coreapi/qsgrenderer_p.h13
3 files changed, 19 insertions, 0 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index 903a98c8ed..aa46b5a509 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -959,6 +959,11 @@ static void qsg_wipeBatch(Batch *batch, bool separateIndexBuffer)
Renderer::~Renderer()
{
if (m_rhi) {
+ // If setExternalRenderPassDescriptor() was called, we have to
+ // aggressively invalidate to prevent an object, the lifetime of which
+ // we have no control over, staying in the (per-window) caches.
+ invalidatePipelineCacheDependency(m_external_rp_desc);
+
// Clean up batches and buffers
const bool separateIndexBuffer = m_context->separateIndexBuffer();
for (int i = 0; i < m_opaqueBatches.size(); ++i)
diff --git a/src/quick/scenegraph/coreapi/qsgrenderer.cpp b/src/quick/scenegraph/coreapi/qsgrenderer.cpp
index 00691278c0..4b3cd9f2c1 100644
--- a/src/quick/scenegraph/coreapi/qsgrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrenderer.cpp
@@ -98,6 +98,7 @@ QSGRenderer::QSGRenderer(QSGRenderContext *context)
, m_rt(nullptr)
, m_cb(nullptr)
, m_rp_desc(nullptr)
+ , m_external_rp_desc(nullptr)
, m_node_updater(nullptr)
, m_changed_emitted(false)
, m_is_rendering(false)
diff --git a/src/quick/scenegraph/coreapi/qsgrenderer_p.h b/src/quick/scenegraph/coreapi/qsgrenderer_p.h
index 0c9a424abc..31f00dc738 100644
--- a/src/quick/scenegraph/coreapi/qsgrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgrenderer_p.h
@@ -115,6 +115,18 @@ public:
void setRenderPassDescriptor(QRhiRenderPassDescriptor *rpDesc) { m_rp_desc = rpDesc; }
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;
+ }
+
void setRenderPassRecordingCallbacks(QSGRenderContext::RenderPassCallback start,
QSGRenderContext::RenderPassCallback end,
void *userData)
@@ -150,6 +162,7 @@ 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;