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/frontend | |
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/frontend')
-rw-r--r-- | src/render/frontend/qrenderaspect.cpp | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/render/frontend/qrenderaspect.cpp b/src/render/frontend/qrenderaspect.cpp index a0b8ab8f3..f9aa4ba96 100644 --- a/src/render/frontend/qrenderaspect.cpp +++ b/src/render/frontend/qrenderaspect.cpp @@ -168,6 +168,8 @@ #include <Qt3DRender/private/job_common_p.h> #include <Qt3DRender/private/pickeventfilter_p.h> #include <Qt3DRender/private/loadbufferjob_p.h> +#include <Qt3DRender/private/techniquemanager_p.h> +#include <Qt3DRender/private/qgraphicsapifilter_p.h> #include <private/qrenderpluginfactory_p.h> #include <private/qrenderplugin_p.h> @@ -190,6 +192,81 @@ QT_BEGIN_NAMESPACE using namespace Qt3DCore; +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; + }; + + return formatNode(n); +} + +QString dumpNodeFilters(const QString &filterType, const QVector<Qt3DRender::QFilterKey*> &filters) { + QString res; + + 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 <%2>")).arg(filterType, kv.join(QLatin1String(", "))); + + return res; +} + +QStringList dumpSGFilterState(Qt3DRender::Render::TechniqueManager *manager, + const Qt3DRender::GraphicsApiFilterData *contextData, + const Qt3DCore::QNode *n, int level = 0) +{ + using namespace Qt3DRender; + + QStringList reply; + const auto *entity = qobject_cast<const Qt3DCore::QEntity *>(n); + if (entity != nullptr) { + QString res = dumpNode(entity); + auto materials = entity->componentsOfType<QMaterial>(); + if (materials.size() && materials.front()->effect()) { + auto m = materials.front(); + const auto techniques = m->effect()->techniques(); + for (auto t: m->effect()->techniques()) { + auto apiFilter = t->graphicsApiFilter(); + if (apiFilter) { + auto backendTechnique = manager->lookupResource(t->id()); + if (backendTechnique && + !(*contextData == *backendTechnique->graphicsApiFilter())) + continue; // skip technique that doesn't match current renderer + } + + QStringList filters; + filters += dumpNodeFilters(QLatin1String("T"), t->filterKeys()); + + const auto &renderPasses = t->renderPasses(); + for (auto r: renderPasses) + filters += dumpNodeFilters(QLatin1String("RP"), r->filterKeys()); + + if (filters.size()) + res += QLatin1String(" [ %1 ]").arg(filters.join(QLatin1String(" "))); + } + } + reply += res.rightJustified(res.length() + level * 2, ' '); + level++; + } + + const auto children = n->childNodes(); + for (auto *child: children) + reply += dumpSGFilterState(manager, contextData, child, level); + + return reply; +} + +} namespace Qt3DRender { #define CreateSynchronizerJobPtr(lambda, type) \ @@ -686,6 +763,12 @@ QVariant QRenderAspect::executeCommand(const QStringList &args) return Qt3DRender::QFrameGraphNodePrivate::get(fg)->dumpFrameGraph(); if (args.front() == QLatin1String("framepaths")) return Qt3DRender::QFrameGraphNodePrivate::get(fg)->dumpFrameGraphPaths().join(QLatin1String("\n")); + if (args.front() == QLatin1String("filterstates")) { + auto res = Qt3DRender::QFrameGraphNodePrivate::get(fg)->dumpFrameGraphFilterState().join(QLatin1String("\n")); + res += dumpSGFilterState(d->m_nodeManagers->techniqueManager(), + d->m_renderer->contextInfo(), d->m_root).join(QLatin1String("\n")); + return res; + } } if (args.front() == QLatin1String("scenegraph")) return droot->dumpSceneGraph(); |