summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Krus <mike.krus@kdab.com>2020-01-07 17:14:28 +0000
committerMike Krus <mike.krus@kdab.com>2020-01-09 12:55:29 +0000
commit35919326b4c1b7803cd68a38c4d7d3c8d710a04a (patch)
treec4a4e1624e0e61bfe525ec6dc376172186e38eb7
parent1fa9c59f7eda5f8435ecb961a55c9a60cd4f7c67 (diff)
Add commands to dump frame graph and scene graph
prints to the console, also dump the list of paths in the frame graph to help understand render views. Change-Id: Ic4756e09545971b224a239fafc6667b0ca3d4572 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
-rw-r--r--src/core/nodes/qentity.cpp50
-rw-r--r--src/core/nodes/qentity_p.h1
-rw-r--r--src/core/services/qsysteminformationservice.cpp2
-rw-r--r--src/render/framegraph/qframegraphnode.cpp59
-rw-r--r--src/render/framegraph/qframegraphnode_p.h3
-rw-r--r--src/render/frontend/qrenderaspect.cpp18
6 files changed, 132 insertions, 1 deletions
diff --git a/src/core/nodes/qentity.cpp b/src/core/nodes/qentity.cpp
index 93601901f..1199dfc4b 100644
--- a/src/core/nodes/qentity.cpp
+++ b/src/core/nodes/qentity.cpp
@@ -53,6 +53,50 @@
QT_BEGIN_NAMESPACE
+namespace {
+
+QString dumpNode(const Qt3DCore::QEntity *n) {
+ auto formatNode = [](const Qt3DCore::QNode *n) {
+ QString res = QString(QLatin1String("%1{%2}"))
+ .arg(QLatin1String(n->metaObject()->className()))
+ .arg(n->id().id());
+ if (!n->objectName().isEmpty())
+ res += QString(QLatin1String(" (%1)")).arg(n->objectName());
+ if (!n->isEnabled())
+ res += QLatin1String(" [D]");
+ return res;
+ };
+
+ QString res = formatNode(n);
+ const auto &components = n->components();
+ if (components.size()) {
+ QStringList componentNames;
+ for (const auto &c : components)
+ componentNames += formatNode(c);
+ res += QString(QLatin1String(" [ %1 ]")).arg(componentNames.join(QLatin1String(", ")));
+ }
+
+ return res;
+}
+
+QStringList dumpSG(const Qt3DCore::QEntity *n, int level = 0)
+{
+ QStringList reply;
+ QString res = dumpNode(n);
+ reply += res.rightJustified(res.length() + level * 2, ' ');
+
+ const auto children = n->childNodes();
+ for (auto *child: children) {
+ auto *childFGNode = qobject_cast<Qt3DCore::QEntity *>(child);
+ if (childFGNode != nullptr)
+ reply += dumpSG(childFGNode, level + 1);
+ }
+
+ return reply;
+}
+
+}
+
namespace Qt3DCore {
/*!
@@ -244,6 +288,12 @@ QNodeId QEntityPrivate::parentEntityId() const
return m_parentEntityId;
}
+QString QEntityPrivate::dumpSceneGraph() const
+{
+ Q_Q(const QEntity);
+ return dumpSG(q).join('\n');
+}
+
QNodeCreatedChangeBasePtr QEntity::createNodeCreationChange() const
{
auto creationChange = QNodeCreatedChangePtr<QEntityData>::create(this);
diff --git a/src/core/nodes/qentity_p.h b/src/core/nodes/qentity_p.h
index 803754c87..992f81931 100644
--- a/src/core/nodes/qentity_p.h
+++ b/src/core/nodes/qentity_p.h
@@ -82,6 +82,7 @@ public :
return typedComponents;
}
+ QString dumpSceneGraph() const;
void removeDestroyedComponent(QComponent *comp);
QComponentVector m_components;
diff --git a/src/core/services/qsysteminformationservice.cpp b/src/core/services/qsysteminformationservice.cpp
index 212038eea..87cc08e59 100644
--- a/src/core/services/qsysteminformationservice.cpp
+++ b/src/core/services/qsysteminformationservice.cpp
@@ -430,7 +430,7 @@ void QSystemInformationService::dumpCommand(const QString &command)
return;
}
}
- qWarning() << res;
+ qWarning() << qPrintable(res.toString());
}
}
diff --git a/src/render/framegraph/qframegraphnode.cpp b/src/render/framegraph/qframegraphnode.cpp
index 2390cb1c9..f49f6433a 100644
--- a/src/render/framegraph/qframegraphnode.cpp
+++ b/src/render/framegraph/qframegraphnode.cpp
@@ -49,6 +49,51 @@ using namespace Qt3DCore;
QT_BEGIN_NAMESPACE
+namespace {
+
+QString dumpNode(const Qt3DRender::QFrameGraphNode *n) {
+ QString res = QLatin1String(n->metaObject()->className());
+ if (!n->objectName().isEmpty())
+ res += QString(QLatin1String(" (%1)")).arg(n->objectName());
+ if (!n->isEnabled())
+ res += QLatin1String(" [D]");
+ return res;
+}
+
+QStringList dumpFG(const Qt3DRender::QFrameGraphNode *n, int level = 0)
+{
+ QStringList reply;
+ QString res = dumpNode(n);
+ reply += res.rightJustified(res.length() + level * 2, ' ');
+
+ const auto children = n->childNodes();
+ for (auto *child: children) {
+ auto *childFGNode = qobject_cast<Qt3DRender::QFrameGraphNode *>(child);
+ if (childFGNode != nullptr)
+ reply += dumpFG(childFGNode, level + 1);
+ }
+
+ return reply;
+}
+
+void dumpFGPaths(const Qt3DRender::QFrameGraphNode *n, QStringList &result, QStringList parents = {})
+{
+ parents += dumpNode(n);
+
+ const auto children = n->childNodes();
+ if (children.length()) {
+ for (auto *child: children) {
+ auto *childFGNode = qobject_cast<Qt3DRender::QFrameGraphNode *>(child);
+ if (childFGNode != nullptr)
+ dumpFGPaths(childFGNode, result, parents);
+ }
+ } else {
+ result << QLatin1String("[ ") + parents.join(QLatin1String(", ")) + QLatin1String(" ]");
+ }
+}
+
+}
+
namespace Qt3DRender {
QFrameGraphNodePrivate::QFrameGraphNodePrivate()
@@ -240,6 +285,20 @@ QVector<QFrameGraphNode *> QFrameGraphNodePrivate::childFrameGraphNodes() const
return result;
}
+QString QFrameGraphNodePrivate::dumpFrameGraph() const
+{
+ Q_Q(const QFrameGraphNode);
+ return dumpFG(q).join('\n');
+}
+
+QStringList QFrameGraphNodePrivate::dumpFrameGraphPaths() const
+{
+ Q_Q(const QFrameGraphNode);
+ QStringList result;
+ dumpFGPaths(q, result);
+ return result;
+}
+
/*! \internal */
QFrameGraphNode::QFrameGraphNode(QFrameGraphNodePrivate &dd, QNode *parent)
: QNode(dd, parent)
diff --git a/src/render/framegraph/qframegraphnode_p.h b/src/render/framegraph/qframegraphnode_p.h
index c03017638..4d9516b88 100644
--- a/src/render/framegraph/qframegraphnode_p.h
+++ b/src/render/framegraph/qframegraphnode_p.h
@@ -70,6 +70,9 @@ public:
static QFrameGraphNodePrivate *get(QFrameGraphNode *node) { return node->d_func(); }
static const QFrameGraphNodePrivate *get(const QFrameGraphNode *node) { return node->d_func(); }
+ QString dumpFrameGraph() const;
+ QStringList dumpFrameGraphPaths() const;
+
Q_DECLARE_PUBLIC(QFrameGraphNode)
};
diff --git a/src/render/frontend/qrenderaspect.cpp b/src/render/frontend/qrenderaspect.cpp
index 7a51fa0e7..d48eb4dd3 100644
--- a/src/render/frontend/qrenderaspect.cpp
+++ b/src/render/frontend/qrenderaspect.cpp
@@ -169,6 +169,8 @@
#include <Qt3DCore/qnode.h>
#include <Qt3DCore/QAspectEngine>
#include <Qt3DCore/private/qservicelocator_p.h>
+#include <Qt3DCore/private/qscene_p.h>
+#include <Qt3DCore/private/qentity_p.h>
#include <QThread>
#include <QOpenGLContext>
@@ -550,6 +552,22 @@ QVector<Qt3DCore::QAspectJobPtr> QRenderAspect::jobsToExecute(qint64 time)
QVariant QRenderAspect::executeCommand(const QStringList &args)
{
Q_D(QRenderAspect);
+
+ if (args.size() == 1) {
+ Render::RenderSettings *settings = d->m_renderer->settings();
+ auto *droot = static_cast<Qt3DCore::QEntityPrivate *>(Qt3DCore::QNodePrivate::get(d->m_root));
+ auto *fg = qobject_cast<Qt3DRender::QFrameGraphNode *>(droot->m_scene->lookupNode(settings->activeFrameGraphID()));
+ if (fg) {
+ if (args.front() == QLatin1String("framegraph"))
+ return Qt3DRender::QFrameGraphNodePrivate::get(fg)->dumpFrameGraph();
+ if (args.front() == QLatin1String("framepaths"))
+ return Qt3DRender::QFrameGraphNodePrivate::get(fg)->dumpFrameGraphPaths().join(QLatin1String("\n"));
+ }
+ if (args.front() == QLatin1String("scenegraph"))
+ return droot->dumpSceneGraph();
+ return {};
+ }
+
return d->m_renderer->executeCommand(args);
}