aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2022-10-06 16:54:47 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2022-10-07 12:32:00 +0200
commitb25555426eb0255f5831f6d4c482c9710c5b46a3 (patch)
tree36462f11e30c9accfb298165d833417679529af5 /src
parentfcc4ead45ea9d7ccd5cdacaf83238997d4c6fb31 (diff)
sg: Enable hooking into the releaseResources call on the window
...on the correct thread (meaning the render thread if the threaded render loop is used). Task-number: QTBUG-107313 Change-Id: Iad16c84682383337acbd4c055b7aea1a52d98543 Reviewed-by: Andy Nichols <andy.nichols@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquickwindow.cpp26
-rw-r--r--src/quick/scenegraph/qsgcontext_p.h1
-rw-r--r--src/quick/scenegraph/qsgrenderloop.cpp1
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop.cpp2
4 files changed, 20 insertions, 10 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 35b60800b5..58f4966625 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -1146,18 +1146,24 @@ void qtquick_shadereffect_purge_gui_thread_shader_cache();
This function tries to release redundant resources currently held by the QML scene.
Calling this function requests the scene graph to release cached graphics
- resources, such as graphics pipeline objects or shader programs.
-
- \note The releasing of cached graphics resources is not dependent on the
- hint from setPersistentGraphics().
+ resources, such as graphics pipeline objects, shader programs, or image
+ data.
Additionally, depending on the render loop in use, this function may also
- result in the scene graph and all rendering resources to be released. If
- this happens, the sceneGraphInvalidated() signal will be emitted, allowing
- users to clean up their own graphics resources. The
- setPersistentGraphics() and setPersistentSceneGraph() functions can be
- used to prevent this from happening, if handling the cleanup is not feasible
- in the application, at the cost of higher memory usage.
+ result in the scene graph and all window-related rendering resources to be
+ released. If this happens, the sceneGraphInvalidated() signal will be
+ emitted, allowing users to clean up their own graphics resources. The
+ setPersistentGraphics() and setPersistentSceneGraph() functions can be used
+ to prevent this from happening, if handling the cleanup is not feasible in
+ the application, at the cost of higher memory usage.
+
+ \note The releasing of cached graphics resources, such as graphics
+ pipelines or shader programs is not dependent on the persistency hints. The
+ releasing of those will happen regardless of the values of the persistent
+ graphics and scenegraph hints.
+
+ \note This function is not related to the QQuickItem::releaseResources()
+ virtual function.
\sa sceneGraphInvalidated(), setPersistentGraphics(), setPersistentSceneGraph()
*/
diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h
index 9c27573f47..742b3b1448 100644
--- a/src/quick/scenegraph/qsgcontext_p.h
+++ b/src/quick/scenegraph/qsgcontext_p.h
@@ -172,6 +172,7 @@ public:
Q_SIGNALS:
void initialized();
void invalidated();
+ void releaseCachedResourcesRequested();
public Q_SLOTS:
void textureFactoryDestroyed(QObject *o);
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp
index b59d9bd80f..d0b4796aab 100644
--- a/src/quick/scenegraph/qsgrenderloop.cpp
+++ b/src/quick/scenegraph/qsgrenderloop.cpp
@@ -798,6 +798,7 @@ void QSGGuiThreadRenderLoop::releaseResources(QQuickWindow *w)
{
// No full invalidation of the rendercontext, just clear some caches.
QQuickWindowPrivate *d = QQuickWindowPrivate::get(w);
+ emit d->context->releaseCachedResourcesRequested();
if (d->renderer)
d->renderer->releaseCachedResources();
}
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
index e9ea6c9d3b..1acb59e80e 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp
+++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
@@ -381,6 +381,8 @@ bool QSGRenderThread::event(QEvent *e)
qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- not releasing because window is still active");
if (window) {
QQuickWindowPrivate *d = QQuickWindowPrivate::get(window);
+ qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- requesting external renderers such as Quick 3D to release cached resources");
+ emit d->context->releaseCachedResourcesRequested();
if (d->renderer) {
qCDebug(QSG_LOG_RENDERLOOP, QSG_RT_PAD, "- requesting renderer to release cached resources");
d->renderer->releaseCachedResources();