From ac080cda6d9391663f882a4317be78ad89986ee2 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 30 Aug 2017 11:10:08 +0200 Subject: Make releaseResources() free the renderer's shader cache Normally all shader programs from materials are cached in a simple table that is alive as long as the renderer exists, in practice this means being tied to the QQuickWindow which is often the entire lifetime of an application. Use releaseResources(), which is mostly a no-op on the scenegraph level at the moment, to free this cache. Task-number: QTBUG-62392 Change-Id: I279e595874fee1ab4fe0dede0843a3686dea5806 Reviewed-by: Gunnar Sletta --- src/quick/scenegraph/qsgrenderloop.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/quick/scenegraph/qsgrenderloop.cpp') diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index bc65dc1bc3..2c73339b7a 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #include #if QT_CONFIG(opengl) @@ -152,7 +153,7 @@ public: void update(QQuickWindow *window) { maybeUpdate(window); } // identical for this implementation. void handleUpdateRequest(QQuickWindow *); - void releaseResources(QQuickWindow *) { } + void releaseResources(QQuickWindow *) Q_DECL_OVERRIDE; QAnimationDriver *animationDriver() const { return 0; } @@ -505,6 +506,14 @@ QSGContext *QSGGuiThreadRenderLoop::sceneGraphContext() const return sg; } +void QSGGuiThreadRenderLoop::releaseResources(QQuickWindow *w) +{ + // No full invalidation of the rendercontext, just clear some caches. + QQuickWindowPrivate *d = QQuickWindowPrivate::get(w); + if (d->renderer) + d->renderer->releaseCachedResources(); +} + void QSGGuiThreadRenderLoop::handleUpdateRequest(QQuickWindow *window) { renderWindow(window); -- cgit v1.2.3