diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-08-30 11:10:08 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-09-04 11:00:14 +0000 |
commit | ac080cda6d9391663f882a4317be78ad89986ee2 (patch) | |
tree | d6f8dc1a91b240ea03f36f3137cdb55486083d4c /src/quick/scenegraph/qsgrenderloop.cpp | |
parent | d031e8f7b51a28a9c609f40a6245657f303277f2 (diff) |
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 <gunnar@crimson.no>
Diffstat (limited to 'src/quick/scenegraph/qsgrenderloop.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgrenderloop.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
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 <QtQuick/QQuickWindow> #include <QtQuick/private/qquickwindow_p.h> #include <QtQuick/private/qsgcontext_p.h> +#include <QtQuick/private/qsgrenderer_p.h> #include <private/qquickprofiler_p.h> #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); |