diff options
author | Mike Krus <mike.krus@kdab.com> | 2020-03-22 09:35:01 +0000 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2020-03-26 09:21:19 +0000 |
commit | 4d1ca5a7afc78ad4676d54ff168170bd7abe7273 (patch) | |
tree | 5525f6917cfc57e8cb12ddd037ad9a35a54490ba /src/render/framegraph/qframegraphnode.cpp | |
parent | e742b02e1d5c8384d6c5a10039719989c32beb42 (diff) |
Add ability to dump filter states
Add button in overlay UI to dump:
- the details of technique and render pass filters in the render views
- the details of technique and render pass keys in the scene graph
This is useful to understand why some objects are not rendered.
Change-Id: I57a284081ec986e49e90c979042cc0c17ee0d1cf
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render/framegraph/qframegraphnode.cpp')
-rw-r--r-- | src/render/framegraph/qframegraphnode.cpp | 68 |
1 files changed, 66 insertions, 2 deletions
diff --git a/src/render/framegraph/qframegraphnode.cpp b/src/render/framegraph/qframegraphnode.cpp index d34e9d02f..6cddf543b 100644 --- a/src/render/framegraph/qframegraphnode.cpp +++ b/src/render/framegraph/qframegraphnode.cpp @@ -40,6 +40,9 @@ #include "qframegraphnode.h" #include "qframegraphnode_p.h" #include <Qt3DRender/qframegraphnodecreatedchange.h> +#include <Qt3DRender/qfilterkey.h> +#include <Qt3DRender/qtechniquefilter.h> +#include <Qt3DRender/qrenderpassfilter.h> #include <Qt3DCore/QNode> #include <QVector> @@ -60,6 +63,20 @@ QString dumpNode(const Qt3DRender::QFrameGraphNode *n) { return res; } +QString dumpNodeFilters(const Qt3DRender::QFrameGraphNode *n, const QVector<Qt3DRender::QFilterKey*> &filters) { + QString res = QLatin1String(n->metaObject()->className()); + if (!n->objectName().isEmpty()) + res += QString(QLatin1String(" (%1)")).arg(n->objectName()); + + QStringList kv; + for (auto filter: filters) + kv.push_back(QString(QLatin1String("%1: %2")).arg(filter->name(), filter->value().toString())); + if (kv.size()) + res += QString(QLatin1String(" <%1>")).arg(kv.join(QLatin1String(", "))); + + return res; +} + QStringList dumpFG(const Qt3DCore::QNode *n, int level = 0) { QStringList reply; @@ -133,14 +150,53 @@ void dumpFGPaths(const Qt3DRender::QFrameGraphNode *n, QStringList &result) findFGLeaves(rootHFg, fgLeaves); // Traverse back to root + int rv = 1; for (const Qt3DRender::QFrameGraphNode *fgNode : fgLeaves) { QStringList parents; while (fgNode != nullptr) { parents.prepend(dumpNode(fgNode)); fgNode = fgNode->parentFrameGraphNode(); } - if (parents.size()) - result << QLatin1String("[ ") + parents.join(QLatin1String(", ")) + QLatin1String(" ]"); + if (parents.size()) { + result << QString(QLatin1String("%1 [ %2 ]")).arg(QString::number(rv), parents.join(QLatin1String(", "))); + ++rv; + } + } +} + +void dumpFGFilterState(const Qt3DRender::QFrameGraphNode *n, QStringList &result) +{ + // Build FG node hierarchy + const HierarchyFGNodePtr rootHFg = buildFGHierarchy(n); + + // Gather FG leaves + QVector<const Qt3DRender::QFrameGraphNode *> fgLeaves; + findFGLeaves(rootHFg, fgLeaves); + + // Traverse back to root + int rv = 1; + for (const Qt3DRender::QFrameGraphNode *fgNode : fgLeaves) { + int parents = 0; + QStringList filters; + while (fgNode != nullptr) { + ++parents; + if (fgNode->isEnabled()) { + auto techniqueFilter = qobject_cast<const Qt3DRender::QTechniqueFilter *>(fgNode); + if (techniqueFilter && techniqueFilter->matchAll().size()) + filters.prepend(dumpNodeFilters(techniqueFilter, techniqueFilter->matchAll())); + auto renderPassFilter = qobject_cast<const Qt3DRender::QRenderPassFilter *>(fgNode); + if (renderPassFilter) + filters.prepend(dumpNodeFilters(renderPassFilter, renderPassFilter->matchAny())); + } + fgNode = fgNode->parentFrameGraphNode(); + } + if (parents) { + if (filters.size()) + result << QString(QLatin1String("%1 [ %2 ]")).arg(QString::number(rv), filters.join(QLatin1String(", "))); + else + result << QString(QObject::tr("%1 [ No Filters ]")).arg(rv); + ++rv; + } } } @@ -351,6 +407,14 @@ QStringList QFrameGraphNodePrivate::dumpFrameGraphPaths() const return result; } +QStringList QFrameGraphNodePrivate::dumpFrameGraphFilterState() const +{ + Q_Q(const QFrameGraphNode); + QStringList result; + dumpFGFilterState(q, result); + return result; +} + /*! \internal */ QFrameGraphNode::QFrameGraphNode(QFrameGraphNodePrivate &dd, QNode *parent) : QNode(dd, parent) |