summaryrefslogtreecommitdiffstats
path: root/src/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/render')
-rw-r--r--src/render/framegraph/debugoverlay.cpp60
-rw-r--r--src/render/framegraph/debugoverlay_p.h75
-rw-r--r--src/render/framegraph/framegraph.pri9
-rw-r--r--src/render/framegraph/framegraphnode_p.h3
-rw-r--r--src/render/framegraph/qdebugoverlay.cpp67
-rw-r--r--src/render/framegraph/qdebugoverlay.h63
-rw-r--r--src/render/framegraph/qdebugoverlay_p.h73
-rw-r--r--src/render/frontend/qrenderaspect.cpp5
-rw-r--r--src/render/renderers/opengl/debug/debug.pri10
-rw-r--r--src/render/renderers/opengl/debug/imguirenderer.cpp717
-rw-r--r--src/render/renderers/opengl/debug/imguirenderer_p.h132
-rw-r--r--src/render/renderers/opengl/jobs/renderviewjobutils.cpp5
-rw-r--r--src/render/renderers/opengl/opengl.pri2
-rw-r--r--src/render/renderers/opengl/renderer/renderer.cpp71
-rw-r--r--src/render/renderers/opengl/renderer/renderer_p.h13
-rw-r--r--src/render/renderers/opengl/renderer/renderview.cpp1
-rw-r--r--src/render/renderers/opengl/renderer/renderview_p.h3
17 files changed, 1276 insertions, 33 deletions
diff --git a/src/render/framegraph/debugoverlay.cpp b/src/render/framegraph/debugoverlay.cpp
new file mode 100644
index 000000000..2d2a1e63b
--- /dev/null
+++ b/src/render/framegraph/debugoverlay.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <Qt3DRender/private/qdebugoverlay_p.h>
+#include <Qt3DRender/private/debugoverlay_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Render {
+
+DebugOverlay::DebugOverlay()
+ : FrameGraphNode(FrameGraphNode::DebugOverlay, QBackendNode::ReadWrite)
+{
+
+}
+
+} //Render
+
+} //Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/framegraph/debugoverlay_p.h b/src/render/framegraph/debugoverlay_p.h
new file mode 100644
index 000000000..a2045ffbe
--- /dev/null
+++ b/src/render/framegraph/debugoverlay_p.h
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DEBUGOVERLAY_P_H
+#define DEBUGOVERLAY_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <Qt3DRender/private/qdebugoverlay_p.h>
+#include <Qt3DRender/private/framegraphnode_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+namespace Render {
+
+class Q_AUTOTEST_EXPORT DebugOverlay : public FrameGraphNode
+{
+public:
+ DebugOverlay();
+};
+
+} //Render
+
+} //Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // DEBUGOVERLAY_P_H
diff --git a/src/render/framegraph/framegraph.pri b/src/render/framegraph/framegraph.pri
index bb833422f..a622bd281 100644
--- a/src/render/framegraph/framegraph.pri
+++ b/src/render/framegraph/framegraph.pri
@@ -69,7 +69,10 @@ HEADERS += \
$$PWD/nopicking_p.h \
$$PWD/qsubtreeenabler.h \
$$PWD/qsubtreeenabler_p.h \
- $$PWD/subtreeenabler_p.h
+ $$PWD/subtreeenabler_p.h \
+ $$PWD/qdebugoverlay.h \
+ $$PWD/qdebugoverlay_p.h \
+ $$PWD/debugoverlay_p.h
SOURCES += \
$$PWD/cameraselectornode.cpp \
@@ -119,4 +122,6 @@ SOURCES += \
$$PWD/qnopicking.cpp \
$$PWD/nopicking.cpp \
$$PWD/qsubtreeenabler.cpp \
- $$PWD/subtreeenabler.cpp
+ $$PWD/subtreeenabler.cpp \
+ $$PWD/qdebugoverlay.cpp \
+ $$PWD/debugoverlay.cpp
diff --git a/src/render/framegraph/framegraphnode_p.h b/src/render/framegraph/framegraphnode_p.h
index 846dc8060..55bede5fd 100644
--- a/src/render/framegraph/framegraphnode_p.h
+++ b/src/render/framegraph/framegraphnode_p.h
@@ -104,7 +104,8 @@ public:
BlitFramebuffer,
SetFence,
WaitFence,
- NoPicking
+ NoPicking,
+ DebugOverlay,
};
FrameGraphNodeType nodeType() const { return m_nodeType; }
diff --git a/src/render/framegraph/qdebugoverlay.cpp b/src/render/framegraph/qdebugoverlay.cpp
new file mode 100644
index 000000000..d82ae88ba
--- /dev/null
+++ b/src/render/framegraph/qdebugoverlay.cpp
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdebugoverlay.h"
+#include "qdebugoverlay_p.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+/*!
+ * \internal
+ */
+QDebugOverlayPrivate::QDebugOverlayPrivate()
+ : QFrameGraphNodePrivate()
+{
+}
+
+/*!
+ * \internal
+ */
+QDebugOverlayPrivate::~QDebugOverlayPrivate() = default;
+
+/*!
+ * The constructor creates an instance with the specified \a parent.
+ */
+QDebugOverlay::QDebugOverlay(Qt3DCore::QNode *parent)
+ : QFrameGraphNode(*new QDebugOverlayPrivate, parent)
+{
+}
+
+} // Qt3DRender
+
+QT_END_NAMESPACE
diff --git a/src/render/framegraph/qdebugoverlay.h b/src/render/framegraph/qdebugoverlay.h
new file mode 100644
index 000000000..1d115fc2e
--- /dev/null
+++ b/src/render/framegraph/qdebugoverlay.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDEBUGOVERLOAY_H
+#define QDEBUGOVERLOAY_H
+
+#include <Qt3DRender/QFrameGraphNode>
+#include <QtGui/QImage>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QDebugOverlayPrivate;
+
+class Q_3DRENDERSHARED_EXPORT QDebugOverlay : public QFrameGraphNode
+{
+ Q_OBJECT
+public:
+ explicit QDebugOverlay(Qt3DCore::QNode *parent = nullptr);
+
+private:
+ Q_DECLARE_PRIVATE(QDebugOverlay)
+};
+
+} // Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QDEBUGOVERLOAY_H
diff --git a/src/render/framegraph/qdebugoverlay_p.h b/src/render/framegraph/qdebugoverlay_p.h
new file mode 100644
index 000000000..f8c34655a
--- /dev/null
+++ b/src/render/framegraph/qdebugoverlay_p.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDEBUGOVERLAY_P_H
+#define QDEBUGOVERLAY_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <Qt3DRender/qdebugoverlay.h>
+#include <Qt3DRender/private/qframegraphnode_p.h>
+
+#include <QtCore/qmutex.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QDebugOverlayPrivate : public QFrameGraphNodePrivate
+{
+public:
+ QDebugOverlayPrivate();
+ ~QDebugOverlayPrivate();
+
+ Q_DECLARE_PUBLIC(QDebugOverlay)
+};
+
+} // Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QDEBUGOVERLAY_P_H
diff --git a/src/render/frontend/qrenderaspect.cpp b/src/render/frontend/qrenderaspect.cpp
index d48eb4dd3..a65f66fd7 100644
--- a/src/render/frontend/qrenderaspect.cpp
+++ b/src/render/frontend/qrenderaspect.cpp
@@ -92,6 +92,7 @@
#include <Qt3DRender/qwaitfence.h>
#include <Qt3DRender/qshaderimage.h>
#include <Qt3DRender/qsubtreeenabler.h>
+#include <Qt3DRender/qdebugoverlay.h>
#include <Qt3DCore/qarmature.h>
#include <Qt3DCore/qjoint.h>
#include <Qt3DCore/qskeletonloader.h>
@@ -159,6 +160,7 @@
#include <Qt3DRender/private/setfence_p.h>
#include <Qt3DRender/private/waitfence_p.h>
#include <Qt3DRender/private/shaderimage_p.h>
+#include <Qt3DRender/private/debugoverlay_p.h>
#include <private/qrenderpluginfactory_p.h>
#include <private/qrenderplugin_p.h>
@@ -330,6 +332,7 @@ void QRenderAspectPrivate::registerBackendTypes()
q->registerBackendType<QWaitFence, true>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::WaitFence, QWaitFence> >::create(m_renderer));
q->registerBackendType<QNoPicking, true>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::NoPicking, QNoPicking> >::create(m_renderer));
q->registerBackendType<QSubtreeEnabler, true>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::SubtreeEnabler, QSubtreeEnabler> >::create(m_renderer));
+ q->registerBackendType<QDebugOverlay, true>(QSharedPointer<Render::FrameGraphNodeFunctor<Render::DebugOverlay, QDebugOverlay> >::create(m_renderer));
// Picking
q->registerBackendType<QObjectPicker, true>(QSharedPointer<Render::NodeFunctor<Render::ObjectPicker, Render::ObjectPickerManager> >::create(m_renderer));
@@ -404,6 +407,7 @@ void QRenderAspectPrivate::unregisterBackendTypes()
unregisterBackendType<QSetFence>();
unregisterBackendType<QWaitFence>();
unregisterBackendType<QSubtreeEnabler>();
+ unregisterBackendType<QDebugOverlay>();
// Picking
unregisterBackendType<QObjectPicker>();
@@ -565,7 +569,6 @@ QVariant QRenderAspect::executeCommand(const QStringList &args)
}
if (args.front() == QLatin1String("scenegraph"))
return droot->dumpSceneGraph();
- return {};
}
return d->m_renderer->executeCommand(args);
diff --git a/src/render/renderers/opengl/debug/debug.pri b/src/render/renderers/opengl/debug/debug.pri
new file mode 100644
index 000000000..c5153bbf7
--- /dev/null
+++ b/src/render/renderers/opengl/debug/debug.pri
@@ -0,0 +1,10 @@
+INCLUDEPATH += $$PWD
+
+include($$QT3D_ROOT/src/3rdparty/imgui/imgui.pri)
+
+HEADERS += \
+ $$PWD/imguirenderer_p.h \
+ $$PWD/imconfig.h
+
+SOURCES += \
+ $$PWD/imguirenderer.cpp
diff --git a/src/render/renderers/opengl/debug/imguirenderer.cpp b/src/render/renderers/opengl/debug/imguirenderer.cpp
new file mode 100644
index 000000000..d2a1cb925
--- /dev/null
+++ b/src/render/renderers/opengl/debug/imguirenderer.cpp
@@ -0,0 +1,717 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ * Based on https://github.com/seanchas116/qtimgui/
+ *
+ * MIT License https://github.com/seanchas116/qtimgui/blob/master/LICENSE
+ *
+ */
+
+#include "imguirenderer_p.h"
+#include <Qt3DRender/private/renderview_p.h>
+#include <Qt3DRender/private/renderer_p.h>
+#include <Qt3DRender/private/geometryrenderermanager_p.h>
+
+#include <QDateTime>
+#include <QGuiApplication>
+#include <QMouseEvent>
+#include <QClipboard>
+#include <QCursor>
+#include <QOpenGLExtraFunctions>
+
+#include "imgui.h"
+
+#ifndef GL_VERTEX_ARRAY_BINDING
+// just for building on some platforms, won't run anyway as this requires GL/ES > 2
+#define GL_VERTEX_ARRAY_BINDING 0x85B5
+#endif
+
+QT_BEGIN_NAMESPACE
+
+using namespace Qt3DRender;
+using namespace Render;
+using namespace Render::Debug;
+
+namespace {
+
+ const QHash<int, ImGuiKey> keyMap = {
+ { Qt::Key_Tab, ImGuiKey_Tab },
+ { Qt::Key_Left, ImGuiKey_LeftArrow },
+ { Qt::Key_Right, ImGuiKey_RightArrow },
+ { Qt::Key_Up, ImGuiKey_UpArrow },
+ { Qt::Key_Down, ImGuiKey_DownArrow },
+ { Qt::Key_PageUp, ImGuiKey_PageUp },
+ { Qt::Key_PageDown, ImGuiKey_PageDown },
+ { Qt::Key_Home, ImGuiKey_Home },
+ { Qt::Key_End, ImGuiKey_End },
+ { Qt::Key_Delete, ImGuiKey_Delete },
+ { Qt::Key_Backspace, ImGuiKey_Backspace },
+ { Qt::Key_Enter, ImGuiKey_Enter },
+ { Qt::Key_Escape, ImGuiKey_Escape },
+ { Qt::Key_A, ImGuiKey_A },
+ { Qt::Key_C, ImGuiKey_C },
+ { Qt::Key_V, ImGuiKey_V },
+ { Qt::Key_X, ImGuiKey_X },
+ { Qt::Key_Y, ImGuiKey_Y },
+ { Qt::Key_Z, ImGuiKey_Z },
+ };
+
+ QByteArray g_currentClipboardText;
+
+ // doesn't handle primitive restart when using indexes
+ int vertexToPrimitiveCount(Qt3DRender::QGeometryRenderer::PrimitiveType primitiveType, int numVertices) {
+ int nPrimitives = 0;
+ switch (primitiveType) {
+ case QGeometryRenderer::Points:
+ case QGeometryRenderer::LineLoop: nPrimitives += numVertices; break;
+ case QGeometryRenderer::Triangles: nPrimitives += numVertices / 3; break;
+ case QGeometryRenderer::Lines: nPrimitives += numVertices / 2; break;
+ case QGeometryRenderer::TriangleFan:
+ case QGeometryRenderer::TriangleStrip:
+ case QGeometryRenderer::LineStrip: nPrimitives += numVertices - 1; break;
+ case QGeometryRenderer::TrianglesAdjacency: nPrimitives += numVertices / 6; break;
+ case QGeometryRenderer::TriangleStripAdjacency:
+ case QGeometryRenderer::LineStripAdjacency: nPrimitives += numVertices / 2 - 1; break;
+ case QGeometryRenderer::LinesAdjacency: nPrimitives += numVertices / 4; break;
+ case QGeometryRenderer::Patches: nPrimitives += 1;
+ }
+ return nPrimitives;
+ }
+
+ const char *primitiveTypeName(Qt3DRender::QGeometryRenderer::PrimitiveType primitiveType) {
+ switch (primitiveType) {
+ case QGeometryRenderer::Points: return "Points";
+ case QGeometryRenderer::LineLoop: return "LineLoop";
+ case QGeometryRenderer::Triangles: return "Triangles";
+ case QGeometryRenderer::TrianglesAdjacency: return "TriangleAdjacency";
+ case QGeometryRenderer::TriangleFan: return "TriangleFan";
+ case QGeometryRenderer::TriangleStrip: return "TriangleStrip";
+ case QGeometryRenderer::TriangleStripAdjacency: return "TriangleStringAdjacency";
+ case QGeometryRenderer::LineStrip: return "LineStrip";
+ case QGeometryRenderer::LineStripAdjacency: return "LineStripAdjacency";
+ case QGeometryRenderer::Lines: return "Lines";
+ case QGeometryRenderer::LinesAdjacency: return "LinesAdjacency";
+ case QGeometryRenderer::Patches: return "Patches";
+ }
+ return "";
+ }
+}
+
+ImGuiRenderer::ImGuiRenderer(Renderer *renderer)
+ : m_renderer(renderer)
+{
+ ImGui::CreateContext();
+
+ ImGuiIO &io = ImGui::GetIO();
+ for (ImGuiKey key : keyMap.values())
+ io.KeyMap[key] = key;
+
+#ifndef QT_NO_CLIPBOARD
+ io.SetClipboardTextFn = [](void *user_data, const char *text) {
+ Q_UNUSED(user_data)
+ QGuiApplication::clipboard()->setText(QString::fromLatin1(text));
+ };
+ io.GetClipboardTextFn = [](void *user_data) {
+ Q_UNUSED(user_data)
+ g_currentClipboardText = QGuiApplication::clipboard()->text().toUtf8();
+ return static_cast<const char *>(g_currentClipboardText.data());
+ };
+#endif
+
+ std::fill(std::begin(m_fpsLog), std::end(m_fpsLog), 0.f);
+ std::fill(std::begin(m_jobsLog), std::end(m_jobsLog), 0.f);
+ m_fpsRange.first = m_fpsRange.second = 0.f;
+ m_jobsRange.first = m_jobsRange.second = 0.f;
+}
+
+void ImGuiRenderer::renderDebugOverlay(const QVector<RenderView *> &renderViews, const RenderView *renderView, int jobsInLastFrame)
+{
+ if (!newFrame(renderView))
+ return;
+
+ const int renderViewsCount = renderViews.size();
+
+ int logIndex = qMin(IMGUI_PERF_LOG_SIZE - 1, ImGui::GetFrameCount());
+ if (logIndex == IMGUI_PERF_LOG_SIZE - 1) {
+ std::rotate(std::begin(m_fpsLog), std::begin(m_fpsLog) + 1, std::end(m_fpsLog));
+ std::rotate(std::begin(m_jobsLog), std::begin(m_jobsLog) + 1, std::end(m_jobsLog));
+ }
+ m_fpsLog[logIndex] = ImGui::GetIO().Framerate;
+ m_fpsRange.first = m_fpsRange.second = 0.f;
+ for (float v: m_fpsLog) {
+ m_fpsRange.first = qMin(m_fpsRange.first, qMax(v - 5.f, 0.f));
+ m_fpsRange.second = qMax(m_fpsRange.second, v + 2.f);
+ }
+ m_jobsLog[logIndex] = jobsInLastFrame;
+ m_jobsRange.first = m_jobsRange.second = 0.f;
+ for (float v: m_jobsLog) {
+ m_jobsRange.first = qMin(m_jobsRange.first, qMax(v - 5.f, 0.f));
+ m_jobsRange.second = qMax(m_jobsRange.second, v + 2.f);
+ }
+
+ {
+ bool pj = m_renderer->services()->systemInformation()->isTraceEnabled();
+ bool pg = m_renderer->services()->systemInformation()->isGraphicsTraceEnabled();
+
+ ImGui::Begin("Qt3D Profiling");
+ char caption[50];
+ sprintf(caption, "Avg %.3f ms/frame (%.1f FPS)", static_cast<double>(1000.0f / ImGui::GetIO().Framerate), static_cast<double>(ImGui::GetIO().Framerate));
+ ImGui::PlotLines("FPS", m_fpsLog, logIndex + 1, 0, caption, m_fpsRange.first, m_fpsRange.second, ImVec2(0, 80));
+ ImGui::PlotHistogram("Jobs", m_jobsLog, logIndex + 1, 0, nullptr, m_jobsRange.first, m_jobsRange.second, ImVec2(0, 80));
+ ImGui::Text("Profiling: ");
+ ImGui::SameLine();
+ if (ImGui::Checkbox("Jobs", &pj))
+ QMetaObject::invokeMethod(m_renderer->services()->systemInformation(), "setTraceEnabled", Qt::QueuedConnection, Q_ARG(bool, pj));
+ ImGui::SameLine();
+ if (ImGui::Checkbox("GL", &pg))
+ QMetaObject::invokeMethod(m_renderer->services()->systemInformation(), "setGraphicsTraceEnabled", Qt::QueuedConnection, Q_ARG(bool, pg));
+ ImGui::SameLine();
+ if (ImGui::Button("Reveal"))
+ QMetaObject::invokeMethod(m_renderer->services()->systemInformation(), "revealLogFolder", Qt::QueuedConnection);
+
+ int nCommands = 0;
+ int nVertices = 0;
+ int nPrimitives = 0;
+ QSet<HGeometryRenderer> inUseGeometries;
+ QSet<Qt3DCore::QNodeId> inUseTextures;
+ for (int j=0; j<renderViewsCount; j++) {
+ const auto &commands = renderViews.at(j)->commands();
+ nCommands += commands.size();
+ for (int k=0; k<commands.size(); k++) {
+ const RenderCommand &command = commands.at(k);
+ if (command.m_type != RenderCommand::Draw)
+ continue;
+ nVertices += command.m_primitiveCount;
+ nPrimitives += vertexToPrimitiveCount(command.m_primitiveType, command.m_primitiveCount);
+ inUseGeometries.insert(command.m_geometryRenderer);
+ const auto &textures = command.m_parameterPack.textures();
+ for (const auto &ns: textures)
+ inUseTextures.insert(ns.nodeId);
+ }
+ }
+
+ auto columnNumber = [](int i) {
+ if (i == 0)
+ ImGui::Text("--");
+ else
+ ImGui::Text(" %d", i);
+ ImGui::NextColumn();
+ };
+ auto column2Numbers = [](int i, int of) {
+ if (of == 0)
+ ImGui::Text("--");
+ else
+ ImGui::Text(" %d of %d", i, of);
+ ImGui::NextColumn();
+ };
+
+ ImGui::Columns(5);
+ ImGui::Separator();
+ for (auto s: {"Jobs", "RV", "Cmds", "Verts", "Prims"}) {
+ ImGui::Text("#%s", s);
+ ImGui::NextColumn();
+ }
+ for (auto s: {jobsInLastFrame, renderViewsCount, nCommands, nVertices, nPrimitives})
+ columnNumber(s);
+
+ ImGui::Columns(3);
+ ImGui::Separator();
+ for (auto s: {"Entities", "Geometries", "Textures"}) {
+ ImGui::Text("#%s", s);
+ ImGui::NextColumn();
+ }
+ columnNumber(m_renderer->nodeManagers()->renderNodesManager()->count());
+ column2Numbers(inUseGeometries.size(), m_renderer->nodeManagers()->geometryRendererManager()->count());
+ column2Numbers(inUseTextures.size(), m_renderer->nodeManagers()->textureManager()->count());
+
+ ImGui::Columns(1);
+ ImGui::Separator();
+
+ ImGui::AlignTextToFramePadding();
+ ImGui::Text("Show:");
+ ImGui::SameLine();
+ if (ImGui::Button("GL Info"))
+ m_showGLInfoWindow = !m_showGLInfoWindow;
+ ImGui::SameLine();
+ if (ImGui::Button("Render Views"))
+ m_showRenderDetailsWindow = !m_showRenderDetailsWindow;
+
+ ImGui::AlignTextToFramePadding();
+ ImGui::Text("Dump:");
+ ImGui::SameLine();
+ if (ImGui::Button("SceneGraph##1"))
+ QMetaObject::invokeMethod(m_renderer->services()->systemInformation(), "dumpCommand",
+ Qt::QueuedConnection, Q_ARG(QString, QLatin1String("render scenegraph")));
+ ImGui::SameLine();
+ if (ImGui::Button("FrameGraph##1"))
+ QMetaObject::invokeMethod(m_renderer->services()->systemInformation(), "dumpCommand",
+ Qt::QueuedConnection, Q_ARG(QString, QLatin1String("render framegraph")));
+ ImGui::SameLine();
+ if (ImGui::Button("FrameGraph Paths##1"))
+ QMetaObject::invokeMethod(m_renderer->services()->systemInformation(), "dumpCommand",
+ Qt::QueuedConnection, Q_ARG(QString, QLatin1String("render framepaths")));
+
+ ImGui::End();
+
+ if (m_showGLInfoWindow)
+ showGLInfo();
+ if (m_showRenderDetailsWindow)
+ showRenderDetails(renderViews);
+ }
+
+ ImGui::Render();
+ renderDrawList(ImGui::GetDrawData());
+}
+
+void ImGuiRenderer::showGLInfo()
+{
+ const GraphicsApiFilterData *contextInfo = m_renderer->submissionContext()->contextInfo();
+
+ ImGui::Begin("Open GL Details", &m_showGLInfoWindow);
+
+ ImGui::Text("API: %s %d.%d", contextInfo->m_api == QGraphicsApiFilter::OpenGL ? "OpenGL" : "OpenGLES"
+ , contextInfo->m_major, contextInfo->m_minor);
+ if (contextInfo->m_api == QGraphicsApiFilter::OpenGL)
+ ImGui::Text("Profile: %s", contextInfo->m_profile == QGraphicsApiFilter::CoreProfile ? "Core" :
+ contextInfo->m_profile == QGraphicsApiFilter::CompatibilityProfile ? "Compatibity" : "Node");
+
+ // TODO show capabilities
+ GLint maxTextureSize, maxTextureUnits;
+ m_funcs->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
+ m_funcs->glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
+ ImGui::Text("Texture max size: %d Units: %d", maxTextureSize, maxTextureUnits);
+
+ if (ImGui::Button("Dump"))
+ QMetaObject::invokeMethod(m_renderer->services()->systemInformation(), "dumpCommand",
+ Qt::QueuedConnection, Q_ARG(QString, QLatin1String("render glinfo")));
+
+ ImGui::End();
+}
+
+void ImGuiRenderer::showRenderDetails(const QVector<RenderView *> &renderViews)
+{
+ ImGui::Begin("Render Views", &m_showRenderDetailsWindow);
+
+ int i = 1;
+ for (const RenderView *view: renderViews) {
+ QString label(QLatin1String("View ") + QString::number(i++));
+ if (ImGui::TreeNode(label.toLatin1().data())) {
+ ImGui::Text("Viewport: (%.1f, %.1f, %.1f, %.1f)", view->viewport().x(), view->viewport().y(),
+ view->viewport().width(), view->viewport().height());
+ ImGui::Text("Surface Size: (%d, %d)", view->surfaceSize().width(), view->surfaceSize().height());
+ ImGui::Text("Pixel Ratio: %.1f", view->devicePixelRatio());
+ ImGui::Text("No Draw: %s", view->noDraw() ? "TRUE" : "FALSE");
+ ImGui::Text("Frustum Culling: %s", view->frustumCulling() ? "TRUE" : "FALSE");
+ ImGui::Text("Compute: %s", view->isCompute() ? "TRUE" : "FALSE");
+ ImGui::Text("Clear Depth Value: %f", static_cast<double>(view->clearDepthValue()));
+ ImGui::Text("Clear Stencil Value: %d", view->clearStencilValue());
+ int j = 1;
+ const auto commands = view->commands();
+ for (const RenderCommand &command: commands) {
+ QString label(QLatin1String("Command ") + QString::number(j++));
+ if (ImGui::TreeNode(label.toLatin1().data())) {
+ ImGui::Text("Primitive Type: %s %s", primitiveTypeName(command.m_primitiveType),
+ command.m_drawIndexed ? "(indexed)" : "");
+ ImGui::Text("# Vertices: %d", command.m_primitiveCount);
+ ImGui::Text("# Primitives: %d", vertexToPrimitiveCount(command.m_primitiveType, command.m_primitiveCount));
+ ImGui::Text("# Instances: %d", command.m_instanceCount);
+ ImGui::TreePop();
+ }
+ }
+ ImGui::TreePop();
+ ImGui::Separator();
+ }
+ }
+
+ if (ImGui::Button("Dump"))
+ QMetaObject::invokeMethod(m_renderer->services()->systemInformation(), "dumpCommand",
+ Qt::QueuedConnection, Q_ARG(QString, QLatin1String("render rendercommands")));
+ ImGui::End();
+}
+
+void ImGuiRenderer::renderDrawList(ImDrawData *draw_data)
+{
+ // Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
+ ImGuiIO& io = ImGui::GetIO();
+ int fb_width = int(io.DisplaySize.x * io.DisplayFramebufferScale.x);
+ int fb_height = int(io.DisplaySize.y * io.DisplayFramebufferScale.y);
+ if (fb_width == 0 || fb_height == 0)
+ return;
+ draw_data->ScaleClipRects(io.DisplayFramebufferScale);
+
+ // Backup GL state
+ GLint last_active_texture; m_funcs->glGetIntegerv(GL_ACTIVE_TEXTURE, &last_active_texture);
+ m_funcs->glActiveTexture(GL_TEXTURE0);
+ GLint last_program; m_funcs->glGetIntegerv(GL_CURRENT_PROGRAM, &last_program);
+ GLint last_texture; m_funcs->glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ GLint last_array_buffer; m_funcs->glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
+ GLint last_element_array_buffer; m_funcs->glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_element_array_buffer);
+ GLint last_vertex_array; m_funcs->glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
+ GLint last_blend_src_rgb; m_funcs->glGetIntegerv(GL_BLEND_SRC_RGB, &last_blend_src_rgb);
+ GLint last_blend_dst_rgb; m_funcs->glGetIntegerv(GL_BLEND_DST_RGB, &last_blend_dst_rgb);
+ GLint last_blend_src_alpha; m_funcs->glGetIntegerv(GL_BLEND_SRC_ALPHA, &last_blend_src_alpha);
+ GLint last_blend_dst_alpha; m_funcs->glGetIntegerv(GL_BLEND_DST_ALPHA, &last_blend_dst_alpha);
+ GLint last_blend_equation_rgb; m_funcs->glGetIntegerv(GL_BLEND_EQUATION_RGB, &last_blend_equation_rgb);
+ GLint last_blend_equation_alpha; m_funcs->glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &last_blend_equation_alpha);
+ GLint last_viewport[4]; m_funcs->glGetIntegerv(GL_VIEWPORT, last_viewport);
+ GLint last_scissor_box[4]; m_funcs->glGetIntegerv(GL_SCISSOR_BOX, last_scissor_box);
+ GLboolean last_enable_blend = m_funcs->glIsEnabled(GL_BLEND);
+ GLboolean last_enable_cull_face = m_funcs->glIsEnabled(GL_CULL_FACE);
+ GLboolean last_enable_depth_test = m_funcs->glIsEnabled(GL_DEPTH_TEST);
+ GLboolean last_enable_scissor_test = m_funcs->glIsEnabled(GL_SCISSOR_TEST);
+
+ // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled
+ m_funcs->glEnable(GL_BLEND);
+ m_funcs->glBlendEquation(GL_FUNC_ADD);
+ m_funcs->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ m_funcs->glDisable(GL_CULL_FACE);
+ m_funcs->glDisable(GL_DEPTH_TEST);
+ m_funcs->glEnable(GL_SCISSOR_TEST);
+
+ // Setup viewport, orthographic projection matrix
+ m_funcs->glViewport(0, 0, static_cast<GLsizei>(fb_width), static_cast<GLsizei>(fb_height));
+ const float ortho_projection[4][4] = {
+ { 2.0f/io.DisplaySize.x, 0.0f, 0.0f, 0.0f },
+ { 0.0f, 2.0f/-io.DisplaySize.y, 0.0f, 0.0f },
+ { 0.0f, 0.0f, -1.0f, 0.0f },
+ {-1.0f, 1.0f, 0.0f, 1.0f },
+ };
+ m_funcs->glUseProgram(m_shaderHandle);
+ m_funcs->glUniform1i(m_attribLocationTex, 0);
+ m_funcs->glUniformMatrix4fv(m_attribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
+ m_funcs->glBindVertexArray(m_vaoHandle);
+
+ for (int n = 0; n < draw_data->CmdListsCount; n++) {
+ const ImDrawList* cmd_list = draw_data->CmdLists[n];
+ const ImDrawIdx* idx_buffer_offset = nullptr;
+
+ m_funcs->glBindBuffer(GL_ARRAY_BUFFER, m_vboHandle);
+ m_funcs->glBufferData(GL_ARRAY_BUFFER, static_cast<GLsizeiptr>(cmd_list->VtxBuffer.Size) * sizeof(ImDrawVert), static_cast<const GLvoid*>(cmd_list->VtxBuffer.Data), GL_STREAM_DRAW);
+
+ m_funcs->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_elementsHandle);
+ m_funcs->glBufferData(GL_ELEMENT_ARRAY_BUFFER, static_cast<GLsizeiptr>(cmd_list->IdxBuffer.Size) * sizeof(ImDrawIdx), static_cast<const GLvoid*>(cmd_list->IdxBuffer.Data), GL_STREAM_DRAW);
+
+ for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) {
+ const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
+ if (pcmd->UserCallback) {
+ pcmd->UserCallback(cmd_list, pcmd);
+ } else {
+ m_funcs->glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
+ m_funcs->glScissor(static_cast<int>(pcmd->ClipRect.x), static_cast<int>(fb_height - pcmd->ClipRect.w),
+ static_cast<int>(pcmd->ClipRect.z - pcmd->ClipRect.x), static_cast<int>(pcmd->ClipRect.w - pcmd->ClipRect.y));
+ m_funcs->glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(pcmd->ElemCount), sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);
+ }
+ idx_buffer_offset += pcmd->ElemCount;
+ }
+ }
+
+ // Restore modified GL state
+ m_funcs->glUseProgram(last_program);
+ m_funcs->glBindTexture(GL_TEXTURE_2D, last_texture);
+ m_funcs->glActiveTexture(last_active_texture);
+ m_funcs->glBindVertexArray(last_vertex_array);
+ m_funcs->glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
+ m_funcs->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, last_element_array_buffer);
+ m_funcs->glBlendEquationSeparate(last_blend_equation_rgb, last_blend_equation_alpha);
+ m_funcs->glBlendFuncSeparate(last_blend_src_rgb, last_blend_dst_rgb, last_blend_src_alpha, last_blend_dst_alpha);
+ if (last_enable_blend)
+ m_funcs->glEnable(GL_BLEND); else m_funcs->glDisable(GL_BLEND);
+ if (last_enable_cull_face)
+ m_funcs->glEnable(GL_CULL_FACE); else m_funcs->glDisable(GL_CULL_FACE);
+ if (last_enable_depth_test)
+ m_funcs->glEnable(GL_DEPTH_TEST); else m_funcs->glDisable(GL_DEPTH_TEST);
+ if (last_enable_scissor_test)
+ m_funcs->glEnable(GL_SCISSOR_TEST); else m_funcs->glDisable(GL_SCISSOR_TEST);
+ m_funcs->glViewport(last_viewport[0], last_viewport[1], static_cast<GLsizei>(last_viewport[2]), static_cast<GLsizei>(last_viewport[3]));
+ m_funcs->glScissor(last_scissor_box[0], last_scissor_box[1], static_cast<GLsizei>(last_scissor_box[2]), static_cast<GLsizei>(last_scissor_box[3]));
+}
+
+bool ImGuiRenderer::createFontsTexture()
+{
+ // Build texture atlas
+ ImGuiIO& io = ImGui::GetIO();
+ unsigned char* pixels;
+ int width, height;
+ io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // Load as RGBA 32-bits (75% of the memory is wasted, but default font is so small) because it is more likely to be compatible with user's existing shaders. If your ImTextureId represent a higher-level concept than just a GL texture id, consider calling GetTexDataAsAlpha8() instead to save on GPU memory.
+
+ // Upload texture to graphics system
+ GLint last_texture;
+ m_funcs->glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ m_funcs->glGenTextures(1, &m_fontTexture);
+ m_funcs->glBindTexture(GL_TEXTURE_2D, m_fontTexture);
+ m_funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ m_funcs->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ m_funcs->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
+
+ // Store our identifier
+ io.Fonts->TexID = (void *)(intptr_t)m_fontTexture;
+
+ // Restore state
+ m_funcs->glBindTexture(GL_TEXTURE_2D, last_texture);
+
+ return true;
+}
+
+bool ImGuiRenderer::createDeviceObjects()
+{
+ auto *glContext = m_renderer->submissionContext()->openGLContext();
+ if (glContext->format().majorVersion() < 3) {
+ qWarning() << "Qt3D Profiling overlay requires GL or GL ES >= 3";
+ return false;
+ }
+
+ // Backup GL state
+ GLint last_texture, last_array_buffer, last_vertex_array;
+ m_funcs->glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_texture);
+ m_funcs->glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_array_buffer);
+ m_funcs->glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vertex_array);
+
+ const GLchar *vertex_shader =
+ "#version 330\n"
+ "uniform mat4 ProjMtx;\n"
+ "in vec2 Position;\n"
+ "in vec2 UV;\n"
+ "in vec4 Color;\n"
+ "out vec2 Frag_UV;\n"
+ "out vec4 Frag_Color;\n"
+ "void main()\n"
+ "{\n"
+ " Frag_UV = UV;\n"
+ " Frag_Color = Color;\n"
+ " gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
+ "}\n";
+
+ const GLchar* fragment_shader =
+ "#version 330\n"
+ "uniform sampler2D Texture;\n"
+ "in vec2 Frag_UV;\n"
+ "in vec4 Frag_Color;\n"
+ "out vec4 Out_Color;\n"
+ "void main()\n"
+ "{\n"
+ " Out_Color = Frag_Color * texture(Texture, Frag_UV.st);\n"
+ "}\n";
+
+ const GLchar *vertex_shader_es3 =
+ "#version 110\n"
+ "uniform mat4 ProjMtx;\n"
+ "in vec2 Position;\n"
+ "in vec2 UV;\n"
+ "in vec4 Color;\n"
+ "out vec2 Frag_UV;\n"
+ "out vec4 Frag_Color;\n"
+ "void main()\n"
+ "{\n"
+ " Frag_UV = UV;\n"
+ " Frag_Color = Color;\n"
+ " gl_Position = ProjMtx * vec4(Position.xy, 0, 1);\n"
+ "}\n";
+
+ const GLchar* fragment_shader_es3 =
+ "#version 110\n"
+ "uniform sampler2D Texture;\n"
+ "in vec2 Frag_UV;\n"
+ "in vec4 Frag_Color;\n"
+ "void main()\n"
+ "{\n"
+ " gl_FragColor = Frag_Color * texture2D(Texture, Frag_UV.st);\n"
+ "}\n";
+
+// m_shaderHandle = m_funcs->glCreateProgram();
+// m_vertHandle = m_funcs->glCreateShader(GL_VERTEX_SHADER);
+// m_fragHandle = m_funcs->glCreateShader(GL_FRAGMENT_SHADER);
+// auto *glContext = m_renderer->submissionContext()->openGLContext();
+// m_funcs->glShaderSource(m_vertHandle, 1, &vertex_shader, nullptr);
+// m_funcs->glShaderSource(m_fragHandle, 1, &fragment_shader, nullptr);
+// m_funcs->glCompileShader(m_vertHandle);
+// m_funcs->glCompileShader(m_fragHandle);
+// m_funcs->glAttachShader(m_shaderHandle, m_vertHandle);
+// m_funcs->glAttachShader(m_shaderHandle, m_fragHandle);
+// m_funcs->glLinkProgram(m_shaderHandle);
+
+ QString logs;
+ m_shader = new QOpenGLShaderProgram(this);
+ if (glContext->isOpenGLES()) {
+ if (!m_shader->addShaderFromSourceCode(QOpenGLShader::Vertex, vertex_shader_es3))
+ logs += m_shader->log();
+ if (!m_shader->addShaderFromSourceCode(QOpenGLShader::Fragment, fragment_shader_es3))
+ logs += m_shader->log();
+ } else {
+ if (!m_shader->addShaderFromSourceCode(QOpenGLShader::Vertex, vertex_shader))
+ logs += m_shader->log();
+ if (!m_shader->addShaderFromSourceCode(QOpenGLShader::Fragment, fragment_shader))
+ logs += m_shader->log();
+ }
+ m_shader->link();
+ logs += m_shader->log();
+ if (!logs.isEmpty())
+ qWarning() << logs;
+ m_shaderHandle = m_shader->programId();
+
+ m_attribLocationTex = m_funcs->glGetUniformLocation(m_shaderHandle, "Texture");
+ m_attribLocationProjMtx = m_funcs->glGetUniformLocation(m_shaderHandle, "ProjMtx");
+ m_attribLocationPosition = m_funcs->glGetAttribLocation(m_shaderHandle, "Position");
+ m_attribLocationUV = m_funcs->glGetAttribLocation(m_shaderHandle, "UV");
+ m_attribLocationColor = m_funcs->glGetAttribLocation(m_shaderHandle, "Color");
+
+ m_funcs->glGenBuffers(1, &m_vboHandle);
+ m_funcs->glGenBuffers(1, &m_elementsHandle);
+
+ m_funcs->glGenVertexArrays(1, &m_vaoHandle);
+ m_funcs->glBindVertexArray(m_vaoHandle);
+ m_funcs->glBindBuffer(GL_ARRAY_BUFFER, m_vboHandle);
+ m_funcs->glEnableVertexAttribArray(m_attribLocationPosition);
+ m_funcs->glEnableVertexAttribArray(m_attribLocationUV);
+ m_funcs->glEnableVertexAttribArray(m_attribLocationColor);
+
+#define OFFSETOF(TYPE, ELEMENT) (reinterpret_cast<size_t>(&((static_cast<TYPE *>(nullptr))->ELEMENT)))
+ m_funcs->glVertexAttribPointer(m_attribLocationPosition, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), reinterpret_cast<GLvoid*>(OFFSETOF(ImDrawVert, pos)));
+ m_funcs->glVertexAttribPointer(m_attribLocationUV, 2, GL_FLOAT, GL_FALSE, sizeof(ImDrawVert), reinterpret_cast<GLvoid*>(OFFSETOF(ImDrawVert, uv)));
+ m_funcs->glVertexAttribPointer(m_attribLocationColor, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(ImDrawVert), reinterpret_cast<GLvoid*>(OFFSETOF(ImDrawVert, col)));
+#undef OFFSETOF
+
+ createFontsTexture();
+
+ // Restore modified GL state
+ m_funcs->glBindTexture(GL_TEXTURE_2D, last_texture);
+ m_funcs->glBindBuffer(GL_ARRAY_BUFFER, last_array_buffer);
+ m_funcs->glBindVertexArray(last_vertex_array);
+
+ return true;
+}
+
+bool ImGuiRenderer::newFrame(const RenderView *renderView)
+{
+ if (!m_funcs)
+ m_funcs = m_renderer->submissionContext()->openGLContext()->extraFunctions();
+ if (!m_fontTexture)
+ createDeviceObjects();
+ if (!m_shader)
+ return false;
+
+ ImGuiIO& io = ImGui::GetIO();
+
+ // Setup display size (every frame to accommodate for window resizing)
+ io.DisplaySize = ImVec2(renderView->surfaceSize().width() / renderView->devicePixelRatio(), renderView->surfaceSize().height() / renderView->devicePixelRatio());
+ io.DisplayFramebufferScale = ImVec2(renderView->devicePixelRatio(), renderView->devicePixelRatio());
+
+ // Setup time step
+ double current_time = QDateTime::currentMSecsSinceEpoch() / 1000.;
+ io.DeltaTime = m_time > 0.0 ? static_cast<float>(current_time - m_time) : 1.0f / 60.0f;
+ if (io.DeltaTime == 0.f)
+ io.DeltaTime = 1.0f / 60.0f;
+ m_time = current_time;
+
+ // Setup inputs
+ for (int i = 0; i < 3; i++)
+ io.MouseDown[i] = m_mousePressed[i];
+
+ io.MouseWheelH = m_mouseWheelH;
+ io.MouseWheel = m_mouseWheel;
+ m_mouseWheelH = 0;
+ m_mouseWheel = 0;
+
+ // Start the frame
+ ImGui::NewFrame();
+ return true;
+}
+
+void ImGuiRenderer::onMouseChange(QMouseEvent *event)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ io.MousePos = ImVec2(event->pos().x(), event->pos().y());
+ m_mousePressed[0] = event->buttons() & Qt::LeftButton;
+ m_mousePressed[1] = event->buttons() & Qt::RightButton;
+ m_mousePressed[2] = event->buttons() & Qt::MiddleButton;
+}
+
+void ImGuiRenderer::onWheel(QWheelEvent *event)
+{
+ // 5 lines per unit
+ m_mouseWheelH += event->pixelDelta().x() / (ImGui::GetTextLineHeight());
+ m_mouseWheel += event->pixelDelta().y() / (5.f * ImGui::GetTextLineHeight());
+}
+
+void ImGuiRenderer::onKeyPressRelease(QKeyEvent *event)
+{
+ ImGuiIO& io = ImGui::GetIO();
+ if (keyMap.contains(event->key()))
+ io.KeysDown[keyMap[event->key()]] = event->type() == QEvent::KeyPress;
+
+ if (event->type() == QEvent::KeyPress) {
+ QString text = event->text();
+ if (text.size() == 1)
+ io.AddInputCharacter(static_cast<ImWchar>(text.at(0).unicode()));
+ }
+
+#ifdef Q_OS_DARWIN
+ io.KeyCtrl = event->modifiers() & Qt::MetaModifier;
+ io.KeyShift = event->modifiers() & Qt::ShiftModifier;
+ io.KeyAlt = event->modifiers() & Qt::AltModifier;
+ io.KeySuper = event->modifiers() & Qt::ControlModifier; // Command key
+#else
+ io.KeyCtrl = event->modifiers() & Qt::ControlModifier;
+ io.KeyShift = event->modifiers() & Qt::ShiftModifier;
+ io.KeyAlt = event->modifiers() & Qt::AltModifier;
+ io.KeySuper = event->modifiers() & Qt::MetaModifier;
+#endif
+}
+
+void ImGuiRenderer::processEvent(QEvent *event)
+{
+ switch (event->type()) {
+ case QEvent::MouseMove:
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ this->onMouseChange(static_cast<QMouseEvent *>(event));
+ break;
+ case QEvent::Wheel:
+ this->onWheel(static_cast<QWheelEvent *>(event));
+ break;
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ this->onKeyPressRelease(static_cast<QKeyEvent *>(event));
+ break;
+ default:
+ break;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/render/renderers/opengl/debug/imguirenderer_p.h b/src/render/renderers/opengl/debug/imguirenderer_p.h
new file mode 100644
index 000000000..091e53897
--- /dev/null
+++ b/src/render/renderers/opengl/debug/imguirenderer_p.h
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 Klaralvdalens Datakonsult AB (KDAB).
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the Qt3D module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT3D_RENDER_GL_IMGUIRENDER_H_
+#define QT3D_RENDER_GL_IMGUIRENDER_H_
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QObject>
+#include <QOpenGLFunctions>
+#include <QPoint>
+#include <memory>
+
+struct ImDrawData;
+
+QT_BEGIN_NAMESPACE
+
+class QMouseEvent;
+class QWheelEvent;
+class QKeyEvent;
+class QOpenGLExtraFunctions;
+class QOpenGLShaderProgram;
+
+namespace Qt3DCore {
+class QServiceLocator;
+}
+
+namespace Qt3DRender {
+namespace Render {
+
+class RenderView;
+class Renderer;
+
+namespace Debug {
+
+#define IMGUI_PERF_LOG_SIZE 30
+
+class ImGuiRenderer : public QObject {
+ Q_OBJECT
+public:
+ ImGuiRenderer(Qt3DRender::Render::Renderer *renderer);
+
+ void processEvent(QEvent *event);
+ void renderDebugOverlay(const QVector<Render::RenderView *> &renderViews, const Render::RenderView *renderView, int jobsInLastFrame);
+
+private:
+ bool newFrame(const RenderView *renderView);
+ void renderDrawList(ImDrawData *draw_data);
+ void onMouseChange(QMouseEvent *event);
+ void onWheel(QWheelEvent *event);
+ void onKeyPressRelease(QKeyEvent *event);
+ void showGLInfo();
+ void showRenderDetails(const QVector<Render::RenderView *> &renderViews);
+
+ bool createFontsTexture();
+ bool createDeviceObjects();
+
+ double m_time = 0.;
+ bool m_mousePressed[3] = { false, false, false };
+ float m_mouseWheel;
+ float m_mouseWheelH;
+ GLuint m_fontTexture = 0;
+ GLuint m_shaderHandle = 0, m_vertHandle = 0, m_fragHandle = 0;
+ int m_attribLocationTex = 0, m_attribLocationProjMtx = 0;
+ int m_attribLocationPosition = 0, m_attribLocationUV = 0, m_attribLocationColor = 0;
+ unsigned int m_vboHandle = 0, m_vaoHandle = 0, m_elementsHandle = 0;
+
+ Renderer *m_renderer;
+ QOpenGLExtraFunctions *m_funcs = nullptr;
+ QOpenGLShaderProgram *m_shader = nullptr;
+
+ bool m_showGLInfoWindow = false;
+ bool m_showRenderDetailsWindow = false;
+
+ float m_fpsLog[IMGUI_PERF_LOG_SIZE];
+ float m_jobsLog[IMGUI_PERF_LOG_SIZE];
+ std::pair<float, float> m_fpsRange;
+ std::pair<float, float> m_jobsRange;
+};
+
+} // namespace Debug
+} // namespace Render
+} // namespace Qt3DRender
+
+QT_END_NAMESPACE
+
+#endif // QT3D_RENDER_GL_IMGUIRENDER_H_
diff --git a/src/render/renderers/opengl/jobs/renderviewjobutils.cpp b/src/render/renderers/opengl/jobs/renderviewjobutils.cpp
index 39917fb58..16d449d4a 100644
--- a/src/render/renderers/opengl/jobs/renderviewjobutils.cpp
+++ b/src/render/renderers/opengl/jobs/renderviewjobutils.cpp
@@ -236,6 +236,11 @@ void setRenderViewConfigFromFrameGraphLeafNode(RenderView *rv, const FrameGraphN
}
break;
}
+
+ case FrameGraphNode::DebugOverlay:
+ rv->setShowDebugOverlay(true);
+ break;
+
case FrameGraphNode::RenderCapture: {
auto *renderCapture = const_cast<Render::RenderCapture *>(
static_cast<const Render::RenderCapture *>(node));
diff --git a/src/render/renderers/opengl/opengl.pri b/src/render/renderers/opengl/opengl.pri
index 908c23c80..f72f2d1a5 100644
--- a/src/render/renderers/opengl/opengl.pri
+++ b/src/render/renderers/opengl/opengl.pri
@@ -6,6 +6,8 @@ include (textures/textures.pri)
include (graphicshelpers/graphicshelpers.pri)
include (renderstates/renderstates.pri)
+!integrity: include (debug/debug.pri)
+
gcov {
QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage
QMAKE_LFLAGS += -fprofile-arcs -ftest-coverage
diff --git a/src/render/renderers/opengl/renderer/renderer.cpp b/src/render/renderers/opengl/renderer/renderer.cpp
index bc8e5b205..b5b61b027 100644
--- a/src/render/renderers/opengl/renderer/renderer.cpp
+++ b/src/render/renderers/opengl/renderer/renderer.cpp
@@ -95,6 +95,9 @@
#include <Qt3DRender/private/qshaderprogram_p.h>
#include <Qt3DRender/private/filterentitybycomponentjob_p.h>
#include <Qt3DRender/private/commandexecuter_p.h>
+#ifndef Q_OS_INTEGRITY
+#include <Qt3DRender/private/imguirenderer_p.h>
+#endif
#include <Qt3DRender/qcameralens.h>
#include <Qt3DCore/private/qeventfilterservice_p.h>
@@ -279,6 +282,8 @@ Renderer::Renderer(QRenderAspect::RenderType type)
, m_offscreenHelper(nullptr)
, m_commandExecuter(new Qt3DRender::Debug::CommandExecuter(this))
, m_shouldSwapBuffers(true)
+ , m_imGuiRenderer(nullptr)
+ , m_jobsInLastFrame(0)
{
// Set renderer as running - it will wait in the context of the
// RenderThread for RenderViews to be submitted
@@ -330,6 +335,10 @@ Renderer::~Renderer()
if (!m_ownedContext)
QObject::disconnect(m_contextConnection);
+
+#ifndef Q_OS_INTEGRITY
+ delete m_imGuiRenderer;
+#endif
}
void Renderer::dumpInfo() const
@@ -1485,6 +1494,7 @@ Renderer::ViewSubmissionResultData Renderer::submitRenderViews(const QVector<Ren
}
QSurface *lastUsedSurface = nullptr;
+ bool imGuiOverlayShown = false;
for (int i = 0; i < renderViewsCount; ++i) {
// Initialize GraphicsContext for drawing
// If the RenderView has a RenderStateSet defined
@@ -1668,6 +1678,22 @@ Renderer::ViewSubmissionResultData Renderer::submitRenderViews(const QVector<Ren
interpolationMethod);
}
+#ifndef Q_OS_INTEGRITY
+ if (!imGuiOverlayShown && renderView->showDebugOverlay()) {
+ imGuiOverlayShown = true;
+ if (!m_imGuiRenderer)
+ m_imGuiRenderer = new Debug::ImGuiRenderer(this);
+
+ {
+ QMutexLocker l(&m_frameEventsMutex);
+ for (auto &keyEvent: m_frameKeyEvents)
+ m_imGuiRenderer->processEvent(&keyEvent);
+ for (auto &mouseEvent: m_frameMouseEvents)
+ m_imGuiRenderer->processEvent(&mouseEvent.second);
+ }
+ m_imGuiRenderer->renderDebugOverlay(renderViews, renderView, m_jobsInLastFrame);
+ }
+#endif
frameElapsed = timer.elapsed() - frameElapsed;
qCDebug(Rendering) << Q_FUNC_INFO << "Submitted Renderview " << i + 1 << "/" << renderViewsCount << "in " << frameElapsed << "ms";
@@ -1742,6 +1768,7 @@ void Renderer::skipNextFrame()
void Renderer::jobsDone(Qt3DCore::QAspectManager *manager)
{
// called in main thread once all jobs are done running
+ m_jobsInLastFrame = manager->jobsInLastFrame();
// sync captured renders to frontend
const QVector<Qt3DCore::QNodeId> pendingCaptureIds = std::move(m_pendingRenderCaptureSendRequests);
@@ -1761,6 +1788,24 @@ void Renderer::jobsDone(Qt3DCore::QAspectManager *manager)
// Jobs we may have to run even if no rendering will happen
QVector<QAspectJobPtr> Renderer::preRenderingJobs()
{
+ {
+ QMutexLocker l(&m_frameEventsMutex);
+ m_frameMouseEvents = m_pickEventFilter->pendingMouseEvents();
+ m_frameKeyEvents = m_pickEventFilter->pendingKeyEvents();
+ }
+
+ // Set values on picking jobs
+ RenderSettings *renderSetting = settings();
+ if (renderSetting != nullptr) {
+ m_pickBoundingVolumeJob->setRenderSettings(renderSetting);
+ m_pickBoundingVolumeJob->setFrameGraphRoot(frameGraphRoot());
+ m_pickBoundingVolumeJob->setMouseEvents(m_frameMouseEvents);
+ m_pickBoundingVolumeJob->setKeyEvents(m_frameKeyEvents);
+
+ m_rayCastingJob->setRenderSettings(renderSetting);
+ m_rayCastingJob->setFrameGraphRoot(frameGraphRoot());
+ }
+
QVector<QAspectJobPtr> jobs;
// Do we need to notify frontend about fence change?
@@ -1941,27 +1986,11 @@ QVector<Qt3DCore::QAspectJobPtr> Renderer::renderBinJobs()
QAspectJobPtr Renderer::pickBoundingVolumeJob()
{
- // Set values on pickBoundingVolumeJob
- RenderSettings *renderSetting = settings();
- if (renderSetting != nullptr) {
- m_pickBoundingVolumeJob->setRenderSettings(renderSetting);
- m_pickBoundingVolumeJob->setFrameGraphRoot(frameGraphRoot());
- m_pickBoundingVolumeJob->setMouseEvents(pendingPickingEvents());
- m_pickBoundingVolumeJob->setKeyEvents(pendingKeyEvents());
- }
-
return m_pickBoundingVolumeJob;
}
QAspectJobPtr Renderer::rayCastingJob()
{
- // Set values on rayCastingJob
- RenderSettings *renderSetting = settings();
- if (renderSetting != nullptr) {
- m_rayCastingJob->setRenderSettings(renderSetting);
- m_rayCastingJob->setFrameGraphRoot(frameGraphRoot());
- }
-
return m_rayCastingJob;
}
@@ -2311,16 +2340,6 @@ void Renderer::cleanGraphicsResources()
}
}
-QList<QPair<QObject *, QMouseEvent>> Renderer::pendingPickingEvents() const
-{
- return m_pickEventFilter->pendingMouseEvents();
-}
-
-QList<QKeyEvent> Renderer::pendingKeyEvents() const
-{
- return m_pickEventFilter->pendingKeyEvents();
-}
-
const GraphicsApiFilterData *Renderer::contextInfo() const
{
return m_submissionContext->contextInfo();
diff --git a/src/render/renderers/opengl/renderer/renderer_p.h b/src/render/renderers/opengl/renderer/renderer_p.h
index a281eb28b..48e4a5e3d 100644
--- a/src/render/renderers/opengl/renderer/renderer_p.h
+++ b/src/render/renderers/opengl/renderer/renderer_p.h
@@ -167,6 +167,10 @@ using FilterEntityByComponentJobPtr = QSharedPointer<FilterEntityByComponentJob<
using ComputableEntityFilterPtr = FilterEntityByComponentJobPtr<Render::ComputeCommand, Render::Material>;
using RenderableEntityFilterPtr = FilterEntityByComponentJobPtr<Render::GeometryRenderer, Render::Material>;
+namespace Debug {
+class ImGuiRenderer;
+}
+
class Q_3DRENDERSHARED_PRIVATE_EXPORT Renderer : public AbstractRenderer
{
public:
@@ -282,9 +286,6 @@ public:
inline RenderStateSet *defaultRenderState() const { return m_defaultRenderStateSet; }
- QList<QPair<QObject*, QMouseEvent>> pendingPickingEvents() const;
- QList<QKeyEvent> pendingKeyEvents() const;
-
void enqueueRenderView(RenderView *renderView, int submitOrder);
bool isReadyToSubmit();
@@ -445,6 +446,12 @@ private:
QVector<FrameGraphNode *> m_frameGraphLeaves;
QScreen *m_screen = nullptr;
+
+ Debug::ImGuiRenderer *m_imGuiRenderer;
+ QList<QPair<QObject *, QMouseEvent>> m_frameMouseEvents;
+ QList<QKeyEvent> m_frameKeyEvents;
+ QMutex m_frameEventsMutex;
+ int m_jobsInLastFrame;
};
} // namespace Render
diff --git a/src/render/renderers/opengl/renderer/renderview.cpp b/src/render/renderers/opengl/renderer/renderview.cpp
index 60ebc2193..f34015455 100644
--- a/src/render/renderers/opengl/renderer/renderview.cpp
+++ b/src/render/renderers/opengl/renderer/renderview.cpp
@@ -250,6 +250,7 @@ RenderView::RenderView()
, m_noDraw(false)
, m_compute(false)
, m_frustumCulling(false)
+ , m_showDebugOverlay(false)
, m_memoryBarrier(QMemoryBarrier::None)
, m_environmentLight(nullptr)
{
diff --git a/src/render/renderers/opengl/renderer/renderview_p.h b/src/render/renderers/opengl/renderer/renderview_p.h
index c7dc37a2c..6f31e40ef 100644
--- a/src/render/renderers/opengl/renderer/renderview_p.h
+++ b/src/render/renderers/opengl/renderer/renderview_p.h
@@ -201,6 +201,8 @@ public:
const int *computeWorkGroups() const Q_DECL_NOTHROW { return m_workGroups; }
inline bool frustumCulling() const Q_DECL_NOTHROW { return m_frustumCulling; }
void setFrustumCulling(bool frustumCulling) Q_DECL_NOTHROW { m_frustumCulling = frustumCulling; }
+ bool showDebugOverlay() const Q_DECL_NOTHROW { return m_showDebugOverlay; }
+ void setShowDebugOverlay(bool showDebugOverlay) Q_DECL_NOTHROW { m_showDebugOverlay = showDebugOverlay; }
inline void setMaterialParameterTable(const MaterialParameterGathererData &parameters) Q_DECL_NOTHROW { m_parameters = parameters; }
@@ -334,6 +336,7 @@ private:
bool m_noDraw:1;
bool m_compute:1;
bool m_frustumCulling:1;
+ bool m_showDebugOverlay:1;
int m_workGroups[3];
QMemoryBarrier::Operations m_memoryBarrier;
QVector<Qt3DCore::QNodeId> m_insertFenceIds;