aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2023-10-11 16:01:41 +0300
committerTarja Sundqvist <tarja.sundqvist@qt.io>2023-10-11 16:01:41 +0300
commitd29b769a7f9b0c106fc58c9fadd7c41379d14776 (patch)
treeca1bbef0fd1a9f70df2e169f423d2df7b975a4be
parent18711bd8a1df79c3fbbfc408aa3478eed0772988 (diff)
parentb080877ad24bbb36335ae820f8c5fcd95d037def (diff)
Merge remote-tracking branch 'origin/tqtc/lts-5.15.12' into tqtc/lts-5.15-opensourcev5.15.12-lts-lgpl
-rw-r--r--.qmake.conf2
-rw-r--r--src/assetimport/qssgmeshutilities.cpp1
-rw-r--r--src/quick3d/qquick3dcustommaterial.cpp16
-rw-r--r--src/quick3d/qquick3deffect.cpp16
-rw-r--r--src/quick3d/qquick3dscenemanager.cpp4
-rw-r--r--src/quick3d/qquick3dtexture.cpp17
-rw-r--r--src/quick3d/qquick3dviewport.cpp2
-rw-r--r--src/runtimerender/graphobjects/qssgrendercustommaterial_p.h2
-rw-r--r--src/runtimerender/graphobjects/qssgrendereffect_p.h2
-rw-r--r--src/runtimerender/qssgrendereffectsystem.cpp2
10 files changed, 58 insertions, 6 deletions
diff --git a/.qmake.conf b/.qmake.conf
index 9228cbd1..356e9c7c 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -3,4 +3,4 @@ load(qt_build_config)
CONFIG += warning_clean
DEFINES += QT_NO_FOREACH
-MODULE_VERSION = 5.15.11
+MODULE_VERSION = 5.15.12
diff --git a/src/assetimport/qssgmeshutilities.cpp b/src/assetimport/qssgmeshutilities.cpp
index 09894374..a17bc4a0 100644
--- a/src/assetimport/qssgmeshutilities.cpp
+++ b/src/assetimport/qssgmeshutilities.cpp
@@ -739,6 +739,7 @@ MultiLoadResult Mesh::loadMulti(QIODevice &inStream, quint32 inId)
inStream.seek(static_cast<qint64>(fileOffset));
retval = load(inStream);
endFunction:
+ free(theHeader);
return MultiLoadResult(retval, theId);
}
diff --git a/src/quick3d/qquick3dcustommaterial.cpp b/src/quick3d/qquick3dcustommaterial.cpp
index b0b5377e..9534146e 100644
--- a/src/quick3d/qquick3dcustommaterial.cpp
+++ b/src/quick3d/qquick3dcustommaterial.cpp
@@ -512,6 +512,22 @@ QSSGRenderGraphObject *QQuick3DCustomMaterial::updateSpatialNode(QSSGRenderGraph
}
}
+ // We need to mark the commands that we allocated since they will need to be deallocted when the customMaterial is deleted.
+ // We achieve this by filtering on the command type.
+ qDeleteAll(customMaterial->commandsToDelete);
+ customMaterial->commandsToDelete.clear();
+ for (auto command : customMaterial->commands) {
+ if (command->m_type != dynamic::CommandType::AllocateBuffer &&
+ command->m_type != dynamic::CommandType::ApplyBufferValue &&
+ command->m_type != dynamic::CommandType::ApplyBlitFramebuffer &&
+ command->m_type != dynamic::CommandType::ApplyBlending &&
+ command->m_type != dynamic::CommandType::ApplyRenderState &&
+ command->m_type != dynamic::CommandType::ApplyCullMode &&
+ command->m_type != dynamic::CommandType::ApplyDepthValue &&
+ command->m_type != dynamic::CommandType::ApplyValue)
+ customMaterial->commandsToDelete.insert(command);
+ }
+
QQuick3DMaterial::updateSpatialNode(customMaterial);
if (m_dirtyAttributes & Dirty::PropertyDirty) {
diff --git a/src/quick3d/qquick3deffect.cpp b/src/quick3d/qquick3deffect.cpp
index 37fb0d26..0064795c 100644
--- a/src/quick3d/qquick3deffect.cpp
+++ b/src/quick3d/qquick3deffect.cpp
@@ -387,6 +387,22 @@ QSSGRenderGraphObject *QQuick3DEffect::updateSpatialNode(QSSGRenderGraphObject *
}
}
+ // We need to mark the commands that we allocated since they will need to be deallocted when the customMaterial is deleted.
+ // We achieve this by filtering on the command type.
+ qDeleteAll(effectNode->commandsToDelete);
+ effectNode->commandsToDelete.clear();
+ for (auto command : effectNode->commands) {
+ if (command->m_type != dynamic::CommandType::AllocateBuffer &&
+ command->m_type != dynamic::CommandType::ApplyBufferValue &&
+ command->m_type != dynamic::CommandType::ApplyBlitFramebuffer &&
+ command->m_type != dynamic::CommandType::ApplyBlending &&
+ command->m_type != dynamic::CommandType::ApplyRenderState &&
+ command->m_type != dynamic::CommandType::ApplyCullMode &&
+ command->m_type != dynamic::CommandType::ApplyDepthValue &&
+ command->m_type != dynamic::CommandType::ApplyValue)
+ effectNode->commandsToDelete.insert(command);
+ }
+
if (m_dirtyAttributes & Dirty::PropertyDirty) {
for (const auto &prop : qAsConst(effectNode->properties)) {
auto p = metaObject()->property(prop.pid);
diff --git a/src/quick3d/qquick3dscenemanager.cpp b/src/quick3d/qquick3dscenemanager.cpp
index d4fcf511..dcb560a3 100644
--- a/src/quick3d/qquick3dscenemanager.cpp
+++ b/src/quick3d/qquick3dscenemanager.cpp
@@ -47,6 +47,7 @@ QQuick3DSceneManager::QQuick3DSceneManager(QObject *parent)
QQuick3DSceneManager::~QQuick3DSceneManager()
{
+ cleanupNodes();
}
void QQuick3DSceneManager::setWindow(QQuickWindow *window)
@@ -73,6 +74,9 @@ void QQuick3DSceneManager::cleanup(QSSGRenderGraphObject *item)
{
Q_ASSERT(!cleanupNodeList.contains(item));
cleanupNodeList.append(item);
+
+ if (auto front = m_nodeMap[item])
+ QQuick3DObjectPrivate::get(front)->spatialNode = nullptr;
}
void QQuick3DSceneManager::polishItems()
diff --git a/src/quick3d/qquick3dtexture.cpp b/src/quick3d/qquick3dtexture.cpp
index dbc717d9..4cd11c2d 100644
--- a/src/quick3d/qquick3dtexture.cpp
+++ b/src/quick3d/qquick3dtexture.cpp
@@ -577,11 +577,14 @@ QSSGRenderGraphObject *QQuick3DTexture::updateSpatialNode(QSSGRenderGraphObject
imageNode->m_qsgTexture = provider->texture();
disconnect(m_textureProviderConnection);
- m_textureProviderConnection = connect(provider, &QSGTextureProvider::textureChanged, this, [provider, imageNode] () {
+ m_textureProviderConnection = connect(provider, &QSGTextureProvider::textureChanged, this, [this, provider] () {
// called on the render thread, if there is one; while not
// obvious, the gui thread is blocked too because one can
// get here only from either the textureProvider() call
// above, or from QQuickImage::updatePaintNode()
+ auto imageNode = static_cast<QSSGRenderImage *>(QQuick3DObjectPrivate::get(this)->spatialNode);
+ if (!imageNode)
+ return;
imageNode->m_qsgTexture = provider->texture();
// the QSGTexture may be different now, go through loadRenderImage() again
imageNode->m_flags.setFlag(QSSGRenderImage::Flag::Dirty);
@@ -607,13 +610,17 @@ QSSGRenderGraphObject *QQuick3DTexture::updateSpatialNode(QSSGRenderGraphObject
// This eliminates, or in the worst case reduces, the ugly effects of not
// having a texture ready when rendering the 3D scene.
- m_textureUpdateConnection = connect(sourcePrivate->window, &QQuickWindow::afterSynchronizing, this, [this, imageNode, sourceItem]() {
+ m_textureUpdateConnection = connect(sourcePrivate->window, &QQuickWindow::afterSynchronizing, this, [this, sourceItem]() {
// Called on the render thread with gui blocked (if there is a render thread, that is).
if (m_sourceItem != sourceItem) {
disconnect(m_textureProviderConnection);
disconnect(m_textureUpdateConnection);
return;
}
+ auto imageNode = static_cast<QSSGRenderImage *>(QQuick3DObjectPrivate::get(this)->spatialNode);
+ if (!imageNode)
+ return;
+
if (QSGDynamicTexture *t = qobject_cast<QSGDynamicTexture *>(imageNode->m_qsgTexture)) {
if (t->updateTexture())
update(); // safe because the gui thread is blocked
@@ -642,7 +649,11 @@ QSSGRenderGraphObject *QQuick3DTexture::updateSpatialNode(QSSGRenderGraphObject
// The earliest next point where we can do anything is
// after the scenegraph's QQuickItem sync round has completed.
- connect(window, &QQuickWindow::afterSynchronizing, this, [this, imageNode, window]() {
+ connect(window, &QQuickWindow::afterSynchronizing, this, [this, window]() {
+ auto imageNode = static_cast<QSSGRenderImage *>(QQuick3DObjectPrivate::get(this)->spatialNode);
+ if (!imageNode)
+ return;
+
// Called on the render thread with gui blocked (if there is a render thread, that is).
disconnect(window, &QQuickWindow::afterSynchronizing, this, nullptr);
if (m_layer) {
diff --git a/src/quick3d/qquick3dviewport.cpp b/src/quick3d/qquick3dviewport.cpp
index dec626d7..05cd2207 100644
--- a/src/quick3d/qquick3dviewport.cpp
+++ b/src/quick3d/qquick3dviewport.cpp
@@ -96,7 +96,7 @@ QQuick3DViewport::QQuick3DViewport(QQuickItem *parent)
m_sceneRoot = new QQuick3DSceneRootNode(this);
m_environment = new QQuick3DSceneEnvironment(m_sceneRoot);
m_renderStats = new QQuick3DRenderStats(m_sceneRoot);
- QSharedPointer<QQuick3DSceneManager> sceneManager(new QQuick3DSceneManager(m_sceneRoot));
+ QSharedPointer<QQuick3DSceneManager> sceneManager(new QQuick3DSceneManager());
QQuick3DObjectPrivate::get(m_sceneRoot)->refSceneManager(sceneManager);
connect(QQuick3DObjectPrivate::get(m_sceneRoot)->sceneManager.data(), &QQuick3DSceneManager::needsUpdate,
this, &QQuickItem::update);
diff --git a/src/runtimerender/graphobjects/qssgrendercustommaterial_p.h b/src/runtimerender/graphobjects/qssgrendercustommaterial_p.h
index c45c2bea..4001c868 100644
--- a/src/runtimerender/graphobjects/qssgrendercustommaterial_p.h
+++ b/src/runtimerender/graphobjects/qssgrendercustommaterial_p.h
@@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE
struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRenderCustomMaterial : public QSSGRenderGraphObject
{
QSSGRenderCustomMaterial() : QSSGRenderGraphObject(Type::CustomMaterial) {}
+ ~QSSGRenderCustomMaterial() { qDeleteAll(commandsToDelete); }
struct TextureProperty
{
@@ -92,6 +93,7 @@ struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRenderCustomMaterial : public QSSGRende
QMap<QByteArray, QByteArray> shaders;
QVector<dynamic::QSSGCommand *> commands;
+ QSet<dynamic::QSSGCommand *> commandsToDelete;
// IMPORTANT: These flags matches the key produced by a MDL export file
enum class MaterialShaderKeyValues
diff --git a/src/runtimerender/graphobjects/qssgrendereffect_p.h b/src/runtimerender/graphobjects/qssgrendereffect_p.h
index d24c91db..e3090e30 100644
--- a/src/runtimerender/graphobjects/qssgrendereffect_p.h
+++ b/src/runtimerender/graphobjects/qssgrendereffect_p.h
@@ -109,6 +109,8 @@ struct Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRenderEffect : public QSSGRenderGraphOb
Q_DECLARE_FLAGS(Flags, Flag)
QVector<dynamic::QSSGCommand *> commands;
+ QSet<dynamic::QSSGCommand *> commandsToDelete;
+
Flags flags;
const char *className = nullptr;
diff --git a/src/runtimerender/qssgrendereffectsystem.cpp b/src/runtimerender/qssgrendereffectsystem.cpp
index 32ed8354..fae3ea54 100644
--- a/src/runtimerender/qssgrendereffectsystem.cpp
+++ b/src/runtimerender/qssgrendereffectsystem.cpp
@@ -426,7 +426,7 @@ QSSGEffectRenderArgument::QSSGEffectRenderArgument(QSSGRenderEffect *inEffect,
{
}
-QSSGRenderEffect::~QSSGRenderEffect() {}
+QSSGRenderEffect::~QSSGRenderEffect() { qDeleteAll(commandsToDelete); }
QSSGEffectSystem::QSSGEffectSystem(QSSGRenderContextInterface *inContext) : m_context(inContext)
{