summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMike Krus <mike.krus@kdab.com>2020-01-16 16:48:21 +0000
committerMike Krus <mike.krus@kdab.com>2020-01-20 13:04:19 +0000
commit4ae7cc93b503cc31272f0b55c84410af30aea8b9 (patch)
tree3eeba8a9295be900daf0ddd60bf079082379fc86 /src
parent34165446cd03a659eaea83d25dfdb91a22c0e2c5 (diff)
Add QRenderCapabilities to query GL about what is supported
Change-Id: I7981e7e4b514e5d15d66c82351f1ab2fe160d20d Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/quick3d/imports/render/qt3dquick3drenderplugin.cpp3
-rw-r--r--src/render/backend/rendersettings.cpp12
-rw-r--r--src/render/backend/rendersettings_p.h2
-rw-r--r--src/render/frontend/qrendercapabilities.cpp431
-rw-r--r--src/render/frontend/qrendercapabilities.h144
-rw-r--r--src/render/frontend/qrendercapabilities_p.h105
-rw-r--r--src/render/frontend/qrendersettings.cpp21
-rw-r--r--src/render/frontend/qrendersettings.h4
-rw-r--r--src/render/frontend/qrendersettings_p.h2
-rw-r--r--src/render/frontend/render-frontend.pri7
-rw-r--r--src/render/renderers/opengl/debug/imguirenderer.cpp25
-rw-r--r--src/render/renderers/opengl/debug/imguirenderer_p.h4
-rw-r--r--src/render/renderers/opengl/renderer/renderer.cpp5
13 files changed, 738 insertions, 27 deletions
diff --git a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp
index e16314c8e..e47d28f7c 100644
--- a/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp
+++ b/src/quick3d/imports/render/qt3dquick3drenderplugin.cpp
@@ -119,6 +119,7 @@
#include <Qt3DRender/qnopicking.h>
#include <Qt3DRender/qshaderimage.h>
#include <Qt3DRender/qsubtreeenabler.h>
+#include <Qt3DRender/qrendercapabilities.h>
#include <QtGui/qwindow.h>
@@ -169,7 +170,9 @@ void Qt3DQuick3DRenderPlugin::registerTypes(const char *uri)
// Renderer setttings
qmlRegisterType<Qt3DRender::QRenderSettings>(uri, 2, 0, "RenderSettings");
+ qmlRegisterType<Qt3DRender::QRenderSettings, 15>(uri, 2, 15, "RenderSettings");
qmlRegisterType<Qt3DRender::QPickingSettings>(uri, 2, 0, "PickingSettings");
+ qmlRegisterUncreatableType<Qt3DRender::QRenderCapabilities>(uri, 2, 15, "RenderCapabilities", "Only available as a property of RenderSettings");
// @uri Qt3D.Render
Qt3DRender::Quick::registerExtendedType<Qt3DRender::QSceneLoader, Qt3DRender::Render::Quick::Quick3DScene>("QSceneLoader", "Qt3D.Render/SceneLoader", uri, 2, 0, "SceneLoader");
diff --git a/src/render/backend/rendersettings.cpp b/src/render/backend/rendersettings.cpp
index 5aeaa2563..3af617bfc 100644
--- a/src/render/backend/rendersettings.cpp
+++ b/src/render/backend/rendersettings.cpp
@@ -42,6 +42,7 @@
#include <Qt3DRender/QFrameGraphNode>
#include <Qt3DRender/private/abstractrenderer_p.h>
#include <Qt3DRender/private/qrendersettings_p.h>
+#include <Qt3DRender/private/qrendercapabilities_p.h>
QT_BEGIN_NAMESPACE
@@ -87,7 +88,7 @@ void RenderSettings::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firs
m_pickResultMode = ncnode->pickingSettings()->pickResultMode();
}
- if (ncnode->pickingSettings()->worldSpaceTolerance() != m_pickWorldSpaceTolerance) {
+ if (!qFuzzyCompare(ncnode->pickingSettings()->worldSpaceTolerance(), m_pickWorldSpaceTolerance)) {
m_pickWorldSpaceTolerance = ncnode->pickingSettings()->worldSpaceTolerance();
}
@@ -95,6 +96,9 @@ void RenderSettings::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firs
m_faceOrientationPickingMode = ncnode->pickingSettings()->faceOrientationPickingMode();
}
+ if (firstTime)
+ m_capabilities = QRenderCapabilitiesPrivate::get(const_cast<QRenderSettings *>(node)->renderCapabilities())->toString();
+
// Either because something above as changed or if QRenderSettingsPrivate::invalidFrame()
// was called
markDirty(AbstractRenderer::AllDirty);
@@ -107,7 +111,7 @@ RenderSettingsFunctor::RenderSettingsFunctor(AbstractRenderer *renderer)
Qt3DCore::QBackendNode *RenderSettingsFunctor::create(const Qt3DCore::QNodeCreatedChangeBasePtr &change) const
{
- Q_UNUSED(change);
+ Q_UNUSED(change)
if (m_renderer->settings() != nullptr) {
qWarning() << "Renderer settings already exists";
return nullptr;
@@ -121,13 +125,13 @@ Qt3DCore::QBackendNode *RenderSettingsFunctor::create(const Qt3DCore::QNodeCreat
Qt3DCore::QBackendNode *RenderSettingsFunctor::get(Qt3DCore::QNodeId id) const
{
- Q_UNUSED(id);
+ Q_UNUSED(id)
return m_renderer->settings();
}
void RenderSettingsFunctor::destroy(Qt3DCore::QNodeId id) const
{
- Q_UNUSED(id);
+ Q_UNUSED(id)
// Deletes the old settings object
auto settings = m_renderer->settings();
if (settings && settings->peerId() == id) {
diff --git a/src/render/backend/rendersettings_p.h b/src/render/backend/rendersettings_p.h
index 1c8c0ca72..317fca957 100644
--- a/src/render/backend/rendersettings_p.h
+++ b/src/render/backend/rendersettings_p.h
@@ -75,6 +75,7 @@ public:
QPickingSettings::PickResultMode pickResultMode() const { return m_pickResultMode; }
QPickingSettings::FaceOrientationPickingMode faceOrientationPickingMode() const { return m_faceOrientationPickingMode; }
float pickWorldSpaceTolerance() const { return m_pickWorldSpaceTolerance; }
+ QString capabilities() const { return m_capabilities; }
// For unit test purposes
void setActiveFrameGraphId(Qt3DCore::QNodeId frameGraphNodeId) { m_activeFrameGraph = frameGraphNodeId; }
@@ -86,6 +87,7 @@ private:
QPickingSettings::FaceOrientationPickingMode m_faceOrientationPickingMode;
float m_pickWorldSpaceTolerance;
Qt3DCore::QNodeId m_activeFrameGraph;
+ QString m_capabilities;
};
class RenderSettingsFunctor : public Qt3DCore::QBackendNodeMapper
diff --git a/src/render/frontend/qrendercapabilities.cpp b/src/render/frontend/qrendercapabilities.cpp
new file mode 100644
index 000000000..f614a528c
--- /dev/null
+++ b/src/render/frontend/qrendercapabilities.cpp
@@ -0,0 +1,431 @@
+/****************************************************************************
+**
+** 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 "qrendercapabilities.h"
+#include "qrendercapabilities_p.h"
+
+#include <QOffscreenSurface>
+#include <QOpenGLContext>
+#include <QOpenGLFunctions>
+#include <QOpenGLExtraFunctions>
+#include <QSet>
+#include <QDebug>
+
+#ifndef GL_MAX_UNIFORM_BLOCK_SIZE
+#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30
+#endif
+
+#ifndef GL_MAX_UNIFORM_BLOCK_SIZE
+#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30
+#endif
+
+#ifndef GL_MAX_SAMPLES
+#define GL_MAX_SAMPLES 0x8D57
+#endif
+
+#ifndef GL_MAX_UNIFORM_BUFFER_BINDINGS
+#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F
+#endif
+
+#ifndef GL_MAX_UNIFORM_BLOCK_SIZE
+#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30
+#endif
+
+#ifndef GL_MAX_ARRAY_TEXTURE_LAYERS
+#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF
+#endif
+
+#ifndef GL_MAX_IMAGE_UNITS
+#define GL_MAX_IMAGE_UNITS 0x8F38
+#endif
+
+#ifndef GL_MAX_SHADER_STORAGE_BLOCK_SIZE
+#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE
+#endif
+
+#ifndef GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS
+#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD
+#endif
+
+#ifndef GL_MAX_COMPUTE_WORK_GROUP_SIZE
+#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF
+#endif
+
+#ifndef GL_MAX_COMPUTE_WORK_GROUP_COUNT
+#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE
+#endif
+
+#ifndef GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS
+#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB
+#endif
+
+#ifndef GL_MAX_COMPUTE_SHARED_MEMORY_SIZE
+#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262
+#endif
+
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+/*!
+ \class Qt3DRender::QRenderCapabilities
+ \brief The QRenderCapabilities class holds settings related to available rendering engines
+ */
+
+/*!
+ \qmltype RenderCapabilities
+ \brief The QRenderCapabilities class holds settings related to available rendering engines
+ \since 5.15
+ \inqmlmodule Qt3D.Render
+ \instantiates Qt3DRender::QRenderCapabilities
+ */
+
+
+/*! \internal */
+QRenderCapabilitiesPrivate::QRenderCapabilitiesPrivate()
+ : QObjectPrivate()
+ , m_valid(false)
+{
+ QOffscreenSurface offscreen;
+ QOpenGLContext ctx;
+
+ offscreen.setFormat(QSurfaceFormat::defaultFormat());
+ offscreen.create();
+ Q_ASSERT_X(offscreen.isValid(), Q_FUNC_INFO, "Unable to create offscreen surface to gather capabilities");
+
+ ctx.setFormat(QSurfaceFormat::defaultFormat());
+ if (ctx.create()) {
+ m_valid = true;
+ ctx.makeCurrent(&offscreen);
+ const QSurfaceFormat format = ctx.format();
+ auto funcs = ctx.functions();
+
+ if (ctx.isOpenGLES())
+ m_api = QRenderCapabilities::OpenGLES;
+ else
+ m_api = QRenderCapabilities::OpenGL;
+ m_profile = static_cast<QRenderCapabilities::Profile>(format.profile());
+ m_majorVersion = format.majorVersion();
+ m_minorVersion = format.minorVersion();
+ const QSet<QByteArray> extensions = ctx.extensions();
+ std::transform(std::begin(extensions), std::end(extensions), std::back_inserter(m_extensions), [](const QByteArray &e) {
+ return QLatin1String(e.data());
+ });
+ std::sort(std::begin(m_extensions), std::end(m_extensions));
+ m_vendor = QString::fromUtf8(reinterpret_cast<const char *>(funcs->glGetString(GL_VENDOR)));
+ m_renderer = QString::fromUtf8(reinterpret_cast<const char *>(funcs->glGetString(GL_RENDERER)));
+ m_version = QString::fromUtf8(reinterpret_cast<const char *>(funcs->glGetString(GL_VERSION)));
+ m_glslVersion = QString::fromUtf8(reinterpret_cast<const char *>(funcs->glGetString(GL_SHADING_LANGUAGE_VERSION)));
+
+ funcs->glGetIntegerv(GL_MAX_SAMPLES, &m_maxSamples);
+ funcs->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m_maxTextureSize);
+ funcs->glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &m_maxTextureUnits);
+
+ if (m_majorVersion >= 3) {
+ if (m_minorVersion >= 1) {
+ m_supportsUBO = true;
+ funcs->glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &m_maxUBOSize);
+ funcs->glGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &m_maxUBOBindings);
+ }
+
+ funcs->glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &m_maxTextureLayers);
+ }
+ if ((m_api == QRenderCapabilities::OpenGL && m_majorVersion >= 4 && m_minorVersion >= 3) ||
+ (m_api == QRenderCapabilities::OpenGLES && m_majorVersion >= 3 && m_minorVersion >= 2)) {
+ m_supportsSSBO = true;
+ m_supportCompute = true;
+ m_supportsImageStore = true;
+ funcs->glGetIntegerv(GL_MAX_IMAGE_UNITS, &m_maxImageUnits);
+ m_supportsSSBO = true;
+ funcs->glGetIntegerv(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &m_maxSSBOSize);
+ funcs->glGetIntegerv(GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS, &m_maxSSBOBindings);
+
+ QOpenGLExtraFunctions *exfunc = nullptr;
+ if ((exfunc = ctx.extraFunctions()) != nullptr) {
+ for (int i = 0; i < 3; ++i) {
+ exfunc->glGetIntegeri_v( GL_MAX_COMPUTE_WORK_GROUP_SIZE, i, &m_maxWorkGroupSize[i] );
+ exfunc->glGetIntegeri_v( GL_MAX_COMPUTE_WORK_GROUP_COUNT, i, &m_maxWorkGroupCount[i] );
+ }
+ }
+
+ funcs->glGetIntegerv( GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS, &m_maxComputeInvocations );
+ funcs->glGetIntegerv( GL_MAX_COMPUTE_SHARED_MEMORY_SIZE, &m_maxComputeSharedMemorySize );
+ }
+
+ // TextureUnitCount, ImageUnitCount, ComputeSupport, ImageSupport, SSBO Support, UBO Support, extensions, Max RenderTargetCount would be a good start
+ }
+}
+
+const QRenderCapabilitiesPrivate *QRenderCapabilitiesPrivate::get(const QRenderCapabilities *q)
+{
+ return q->d_func();
+}
+
+QString QRenderCapabilitiesPrivate::toString() const
+{
+ QString res;
+
+ res += QString(QLatin1String("Vendor: %1\nRenderer: %2\nDriver Version: %3\nGL Version: %4.%5 (%6 Profile)\nGLSL Version: %7\n"))
+ .arg(m_vendor, m_renderer, m_version)
+ .arg(m_majorVersion).arg(m_minorVersion)
+ .arg(m_profile == QRenderCapabilities::CoreProfile ? QLatin1String("Core") : (m_profile == QRenderCapabilities::CompatibilityProfile ? QLatin1String("Compatibility") : QLatin1String("No")))
+ .arg(m_glslVersion);
+ res += QString(QLatin1String("Extensions:\n %1\n")).arg(m_extensions.join(QLatin1String("\n ")));
+ res += QString(QLatin1String("Max Texture Size: %1\nMax Texture Units: %2\nMax Texture Layers: %3\n")).arg(m_maxTextureSize).arg(m_maxTextureUnits).arg(m_maxTextureLayers);
+ res += QString(QLatin1String("Supports UBO: %1\n")).arg(m_supportsUBO ? QLatin1String("True") : QLatin1String("False"));
+ if (m_supportsUBO)
+ res += QString(QLatin1String(" Max UBO Size: %1\n Max UBO Bindings: %2\n")).arg(m_maxUBOSize).arg(m_maxUBOBindings);
+ res += QString(QLatin1String("Supports SSBO: %1\n")).arg(m_supportsSSBO ? QLatin1String("True") : QLatin1String("False"));
+ if (m_supportsSSBO)
+ res += QString(QLatin1String(" Max SSBO Size: %1\n Max SSBO Bindings: %2\n")).arg(m_maxSSBOSize).arg(m_maxSSBOBindings);
+ res += QString(QLatin1String("Supports Image Store: %1\n")).arg(m_supportsImageStore ? QLatin1String("True") : QLatin1String("False"));
+ if (m_supportsImageStore)
+ res += QString(QLatin1String(" Max Image Units: %1\n")).arg(m_maxImageUnits);
+ res += QString(QLatin1String("Supports Compute Shaders: %1\n")).arg(m_supportCompute ? QLatin1String("True") : QLatin1String("False"));
+ if (m_supportCompute)
+ res += QString(QLatin1String(" Max Work Group Size: %1, %2, %3\n Max Work Group Count: %4, %5, %6\n Max Invocations: %6\n Max Shared Memory Size: %7\n"))
+ .arg(m_maxWorkGroupSize[0]).arg(m_maxWorkGroupSize[1]).arg(m_maxWorkGroupSize[2])
+ .arg(m_maxWorkGroupCount[0]).arg(m_maxWorkGroupCount[1]).arg(m_maxWorkGroupCount[2])
+ .arg(m_maxComputeInvocations).arg(m_maxComputeSharedMemorySize);
+ return res;
+}
+
+
+QRenderCapabilities::QRenderCapabilities(QObject *parent)
+ : QObject(*new QRenderCapabilitiesPrivate, parent)
+{
+
+}
+
+/*! \internal */
+QRenderCapabilities::~QRenderCapabilities()
+{
+}
+
+
+bool QRenderCapabilities::isValid() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_valid;
+}
+
+QRenderCapabilities::API QRenderCapabilities::api() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_api;
+}
+
+QRenderCapabilities::Profile QRenderCapabilities::profile() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_profile;
+}
+
+int QRenderCapabilities::majorVersion() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_majorVersion;
+}
+
+int QRenderCapabilities::minorVersion() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_minorVersion;
+}
+
+QStringList QRenderCapabilities::extensions() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_extensions;
+}
+
+QString QRenderCapabilities::vendor() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_vendor;
+}
+
+QString QRenderCapabilities::renderer() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_renderer;
+}
+
+QString QRenderCapabilities::driverVersion() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_version;
+}
+
+QString QRenderCapabilities::glslVersion() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_glslVersion;
+}
+
+int QRenderCapabilities::maxSamples() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_maxSamples;
+}
+
+int QRenderCapabilities::maxTextureSize() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_maxTextureSize;
+}
+
+int QRenderCapabilities::maxTextureUnits() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_maxTextureUnits;
+}
+
+int QRenderCapabilities::maxTextureLayers() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_maxTextureLayers;
+}
+
+bool QRenderCapabilities::supportsUBO() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_supportsUBO;
+}
+
+int QRenderCapabilities::maxUBOSize() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_maxUBOSize;
+}
+
+int QRenderCapabilities::maxUBOBindings() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_maxUBOBindings;
+}
+
+bool QRenderCapabilities::supportsSSBO() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_supportsSSBO;
+}
+
+int QRenderCapabilities::maxSSBOSize() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_maxSSBOSize;
+}
+
+int QRenderCapabilities::maxSSBOBindings() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_maxSSBOBindings;
+}
+
+bool QRenderCapabilities::supportsImageStore() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_supportsImageStore;
+}
+
+int QRenderCapabilities::maxImageUnits() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_maxImageUnits;
+}
+
+bool QRenderCapabilities::supportsCompute() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_supportCompute;
+}
+
+int QRenderCapabilities::maxWorkGroupCountX() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_maxWorkGroupCount[0];
+}
+
+int QRenderCapabilities::maxWorkGroupCountY() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_maxWorkGroupCount[1];
+}
+
+int QRenderCapabilities::maxWorkGroupCountZ() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_maxWorkGroupCount[2];
+}
+
+int QRenderCapabilities::maxWorkGroupSizeX() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_maxWorkGroupSize[0];
+}
+
+int QRenderCapabilities::maxWorkGroupSizeY() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_maxWorkGroupSize[1];
+}
+
+int QRenderCapabilities::maxWorkGroupSizeZ() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_maxWorkGroupSize[2];
+}
+
+int QRenderCapabilities::maxComputeInvocations() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_maxComputeInvocations;
+}
+
+int QRenderCapabilities::maxComputeSharedMemorySize() const
+{
+ Q_D(const QRenderCapabilities);
+ return d->m_maxComputeSharedMemorySize;
+}
+
+} // namespace Qt3Drender
+
+QT_END_NAMESPACE
diff --git a/src/render/frontend/qrendercapabilities.h b/src/render/frontend/qrendercapabilities.h
new file mode 100644
index 000000000..cbbb5a23d
--- /dev/null
+++ b/src/render/frontend/qrendercapabilities.h
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** 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 QT3DRENDER_QRENDERCAPABILITIES_H
+#define QT3DRENDER_QRENDERCAPABILITIES_H
+
+#include <QObject>
+#include <QSurfaceFormat>
+#include <Qt3DRender/qt3drender_global.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class QRenderCapabilitiesPrivate;
+
+class Q_3DRENDERSHARED_EXPORT QRenderCapabilities : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(bool valid READ isValid CONSTANT)
+ Q_PROPERTY(API api READ api CONSTANT)
+ Q_PROPERTY(Profile profile READ profile CONSTANT)
+ Q_PROPERTY(int majorVersion READ majorVersion CONSTANT)
+ Q_PROPERTY(int minorVersion READ minorVersion CONSTANT)
+ Q_PROPERTY(QStringList extensions READ extensions CONSTANT)
+ Q_PROPERTY(QString vendor READ vendor CONSTANT)
+ Q_PROPERTY(QString renderer READ renderer CONSTANT)
+ Q_PROPERTY(QString driverVersion READ driverVersion CONSTANT)
+ Q_PROPERTY(QString glslVersion READ glslVersion CONSTANT)
+ Q_PROPERTY(int maxSamples READ maxSamples CONSTANT)
+ Q_PROPERTY(int maxTextureSize READ maxTextureSize CONSTANT)
+ Q_PROPERTY(int maxTextureUnits READ maxTextureUnits CONSTANT)
+ Q_PROPERTY(int maxTextureLayers READ maxTextureLayers CONSTANT)
+ Q_PROPERTY(bool supportsUBO READ supportsUBO CONSTANT)
+ Q_PROPERTY(int maxUBOSize READ maxUBOSize CONSTANT)
+ Q_PROPERTY(int maxUBOBindings READ maxUBOBindings CONSTANT)
+ Q_PROPERTY(bool supportsSSBO READ supportsSSBO CONSTANT)
+ Q_PROPERTY(int maxSSBOSize READ maxSSBOSize CONSTANT)
+ Q_PROPERTY(int maxSSBOBindings READ maxSSBOBindings CONSTANT)
+ Q_PROPERTY(bool supportsImageStore READ supportsImageStore CONSTANT)
+ Q_PROPERTY(int maxImageUnits READ maxImageUnits CONSTANT)
+ Q_PROPERTY(bool supportsCompute READ supportsCompute CONSTANT)
+ Q_PROPERTY(int maxWorkGroupCountX READ maxWorkGroupCountX CONSTANT)
+ Q_PROPERTY(int maxWorkGroupCountY READ maxWorkGroupCountY CONSTANT)
+ Q_PROPERTY(int maxWorkGroupCountZ READ maxWorkGroupCountZ CONSTANT)
+ Q_PROPERTY(int maxWorkGroupSizeX READ maxWorkGroupSizeX CONSTANT)
+ Q_PROPERTY(int maxWorkGroupSizeY READ maxWorkGroupSizeY CONSTANT)
+ Q_PROPERTY(int maxWorkGroupSizeZ READ maxWorkGroupSizeZ CONSTANT)
+ Q_PROPERTY(int maxComputeInvocations READ maxComputeInvocations CONSTANT)
+ Q_PROPERTY(int maxComputeSharedMemorySize READ maxComputeSharedMemorySize CONSTANT)
+public:
+ enum API {
+ OpenGL = QSurfaceFormat::OpenGL,
+ OpenGLES = QSurfaceFormat::OpenGLES,
+ };
+ Q_ENUM(API)
+
+ enum Profile {
+ NoProfile = QSurfaceFormat::NoProfile,
+ CoreProfile = QSurfaceFormat::CoreProfile,
+ CompatibilityProfile = QSurfaceFormat::CompatibilityProfile
+ };
+ Q_ENUM(Profile)
+
+ explicit QRenderCapabilities(QObject *parent = nullptr);
+ ~QRenderCapabilities();
+
+ bool isValid() const;
+ API api() const;
+ Profile profile() const;
+ int majorVersion() const;
+ int minorVersion() const;
+ QStringList extensions() const;
+ QString vendor() const;
+ QString renderer() const;
+ QString driverVersion() const;
+ QString glslVersion() const;
+ int maxSamples() const;
+ int maxTextureSize() const;
+ int maxTextureUnits() const;
+ int maxTextureLayers() const;
+ bool supportsUBO() const;
+ int maxUBOSize() const;
+ int maxUBOBindings() const;
+ bool supportsSSBO() const;
+ int maxSSBOSize() const;
+ int maxSSBOBindings() const;
+ bool supportsImageStore() const;
+ int maxImageUnits() const;
+ bool supportsCompute() const;
+ int maxWorkGroupCountX() const;
+ int maxWorkGroupCountY() const;
+ int maxWorkGroupCountZ() const;
+ int maxWorkGroupSizeX() const;
+ int maxWorkGroupSizeY() const;
+ int maxWorkGroupSizeZ() const;
+ int maxComputeInvocations() const;
+ int maxComputeSharedMemorySize() const;
+
+protected:
+ Q_DECLARE_PRIVATE(QRenderCapabilities)
+};
+
+} // namespace Qt3Drender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_QRENDERCAPABILITIES_H
diff --git a/src/render/frontend/qrendercapabilities_p.h b/src/render/frontend/qrendercapabilities_p.h
new file mode 100644
index 000000000..0a91808d2
--- /dev/null
+++ b/src/render/frontend/qrendercapabilities_p.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** 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 QT3DRENDER_QRENDERCAPABILITIES_P_H
+#define QT3DRENDER_QRENDERCAPABILITIES_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 <QtCore/private/qobject_p.h>
+#include <Qt3DRender/qrendercapabilities.h>
+#include <Qt3DRender/private/qt3drender_global_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+class Q_3DRENDERSHARED_PRIVATE_EXPORT QRenderCapabilitiesPrivate : public QObjectPrivate
+{
+public:
+ QRenderCapabilitiesPrivate();
+
+ Q_DECLARE_PUBLIC(QRenderCapabilities)
+ static const QRenderCapabilitiesPrivate *get(const QRenderCapabilities *q);
+
+ bool m_valid;
+ QRenderCapabilities::API m_api = QRenderCapabilities::OpenGL;
+ QRenderCapabilities::Profile m_profile = QRenderCapabilities::NoProfile;
+ int m_majorVersion = 0;
+ int m_minorVersion = 0;
+ QStringList m_extensions;
+ QString m_vendor;
+ QString m_renderer;
+ QString m_version;
+ QString m_glslVersion;
+ int m_maxSamples = 0;
+ int m_maxTextureSize = 0;
+ int m_maxTextureUnits = 0;
+ int m_maxTextureLayers = 0;
+ bool m_supportsUBO = false;
+ int m_maxUBOSize = 0;
+ int m_maxUBOBindings = 0;
+ bool m_supportsSSBO = false;
+ int m_maxSSBOSize = 0;
+ int m_maxSSBOBindings = 0;
+ bool m_supportsImageStore = false;
+ int m_maxImageUnits = 0;
+ bool m_supportCompute = false;
+ int m_maxWorkGroupCount[3] = { 0, 0, 0 };
+ int m_maxWorkGroupSize[3] = { 0, 0, 0 };
+ int m_maxComputeInvocations = 0;
+ int m_maxComputeSharedMemorySize = 0;
+
+ QString toString() const;
+};
+
+} // namespace Qt3Drender
+
+QT_END_NAMESPACE
+
+#endif // QT3DRENDER_QRENDERCAPABILITIES_P_H
diff --git a/src/render/frontend/qrendersettings.cpp b/src/render/frontend/qrendersettings.cpp
index 491d3e442..179df151a 100644
--- a/src/render/frontend/qrendersettings.cpp
+++ b/src/render/frontend/qrendersettings.cpp
@@ -39,6 +39,7 @@
#include "qrendersettings.h"
#include "qrendersettings_p.h"
+#include "qrendercapabilities.h"
#include "qframegraphnode.h"
#include "qrendersurfaceselector.h"
#include "qrendersurfaceselector_p.h"
@@ -142,6 +143,26 @@ QRenderSettings::~QRenderSettings()
}
/*!
+ \qmlproperty RenderCapabilities RenderSettings::renderCapabilities
+
+ Holds the details of the supported rendering engine
+
+ \readonly
+*/
+/*!
+ \property QRenderSettings::renderCapabilities
+
+ Holds the details of the supported rendering engine
+
+ \readonly
+*/
+QRenderCapabilities *QRenderSettings::renderCapabilities()
+{
+ Q_D(QRenderSettings);
+ return &(d->m_renderCapabilities);
+}
+
+/*!
\qmlproperty PickingSettings RenderSettings::pickingSettings
Holds the current pick settings for the \l{Qt 3D Render Framegraph}{FrameGraph}.
diff --git a/src/render/frontend/qrendersettings.h b/src/render/frontend/qrendersettings.h
index 9d2baa58b..1b4d68de9 100644
--- a/src/render/frontend/qrendersettings.h
+++ b/src/render/frontend/qrendersettings.h
@@ -49,12 +49,13 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
class QFrameGraphNode;
+class QRenderCapabilities;
class QRenderSettingsPrivate;
class Q_3DRENDERSHARED_EXPORT QRenderSettings : public Qt3DCore::QComponent
{
Q_OBJECT
-
+ Q_PROPERTY(Qt3DRender::QRenderCapabilities* renderCapabilities READ renderCapabilities CONSTANT REVISION 15)
Q_PROPERTY(Qt3DRender::QPickingSettings* pickingSettings READ pickingSettings CONSTANT)
Q_PROPERTY(RenderPolicy renderPolicy READ renderPolicy WRITE setRenderPolicy NOTIFY renderPolicyChanged)
Q_PROPERTY(Qt3DRender::QFrameGraphNode *activeFrameGraph READ activeFrameGraph WRITE setActiveFrameGraph NOTIFY activeFrameGraphChanged)
@@ -70,6 +71,7 @@ public:
};
Q_ENUM(RenderPolicy) // LCOV_EXCL_LINE
+ QRenderCapabilities* renderCapabilities();
QPickingSettings* pickingSettings();
QFrameGraphNode *activeFrameGraph() const;
RenderPolicy renderPolicy() const;
diff --git a/src/render/frontend/qrendersettings_p.h b/src/render/frontend/qrendersettings_p.h
index 88f91810a..85ba2d7cf 100644
--- a/src/render/frontend/qrendersettings_p.h
+++ b/src/render/frontend/qrendersettings_p.h
@@ -54,6 +54,7 @@
#include <Qt3DCore/private/qcomponent_p.h>
#include <Qt3DRender/qrendersettings.h>
#include <Qt3DRender/qpickingsettings.h>
+#include <Qt3DRender/qrendercapabilities.h>
#include <Qt3DRender/private/qt3drender_global_p.h>
QT_BEGIN_NAMESPACE
@@ -70,6 +71,7 @@ public:
QPickingSettings m_pickingSettings;
QFrameGraphNode *m_activeFrameGraph;
QRenderSettings::RenderPolicy m_renderPolicy;
+ QRenderCapabilities m_renderCapabilities;
void invalidateFrame();
diff --git a/src/render/frontend/render-frontend.pri b/src/render/frontend/render-frontend.pri
index 0153e9c97..694b5cfc1 100644
--- a/src/render/frontend/render-frontend.pri
+++ b/src/render/frontend/render-frontend.pri
@@ -28,7 +28,9 @@ HEADERS += \
$$PWD/qrenderplugin_p.h \
$$PWD/qrenderpluginfactory_p.h \
$$PWD/qrenderpluginfactoryif_p.h \
- $$PWD/qlevelofdetailboundingsphere.h
+ $$PWD/qlevelofdetailboundingsphere.h \
+ $$PWD/qrendercapabilities.h \
+ $$PWD/qrendercapabilities_p.h
SOURCES += \
$$PWD/qabstractfunctor.cpp \
@@ -46,5 +48,6 @@ SOURCES += \
$$PWD/qcomputecommand.cpp \
$$PWD/qrenderpluginfactory.cpp \
$$PWD/qrenderpluginfactoryif.cpp \
- $$PWD/qlevelofdetailboundingsphere.cpp
+ $$PWD/qlevelofdetailboundingsphere.cpp \
+ $$PWD/qrendercapabilities.cpp
diff --git a/src/render/renderers/opengl/debug/imguirenderer.cpp b/src/render/renderers/opengl/debug/imguirenderer.cpp
index d2a1cb925..f432970e4 100644
--- a/src/render/renderers/opengl/debug/imguirenderer.cpp
+++ b/src/render/renderers/opengl/debug/imguirenderer.cpp
@@ -300,28 +300,15 @@ void ImGuiRenderer::renderDebugOverlay(const QVector<RenderView *> &renderViews,
renderDrawList(ImGui::GetDrawData());
}
-void ImGuiRenderer::showGLInfo()
+void ImGuiRenderer::setCapabilities(const QString &capabilities)
{
- const GraphicsApiFilterData *contextInfo = m_renderer->submissionContext()->contextInfo();
+ m_capabilities = capabilities.toLatin1();
+}
+void ImGuiRenderer::showGLInfo()
+{
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::Text("%s", m_capabilities.data());
ImGui::End();
}
diff --git a/src/render/renderers/opengl/debug/imguirenderer_p.h b/src/render/renderers/opengl/debug/imguirenderer_p.h
index 091e53897..e574574be 100644
--- a/src/render/renderers/opengl/debug/imguirenderer_p.h
+++ b/src/render/renderers/opengl/debug/imguirenderer_p.h
@@ -88,6 +88,8 @@ public:
void processEvent(QEvent *event);
void renderDebugOverlay(const QVector<Render::RenderView *> &renderViews, const Render::RenderView *renderView, int jobsInLastFrame);
+ void setCapabilities(const QString &capabilities);
+
private:
bool newFrame(const RenderView *renderView);
void renderDrawList(ImDrawData *draw_data);
@@ -121,6 +123,8 @@ private:
float m_jobsLog[IMGUI_PERF_LOG_SIZE];
std::pair<float, float> m_fpsRange;
std::pair<float, float> m_jobsRange;
+
+ QByteArray m_capabilities;
};
} // namespace Debug
diff --git a/src/render/renderers/opengl/renderer/renderer.cpp b/src/render/renderers/opengl/renderer/renderer.cpp
index b5b61b027..a65e3c7ff 100644
--- a/src/render/renderers/opengl/renderer/renderer.cpp
+++ b/src/render/renderers/opengl/renderer/renderer.cpp
@@ -1681,8 +1681,11 @@ Renderer::ViewSubmissionResultData Renderer::submitRenderViews(const QVector<Ren
#ifndef Q_OS_INTEGRITY
if (!imGuiOverlayShown && renderView->showDebugOverlay()) {
imGuiOverlayShown = true;
- if (!m_imGuiRenderer)
+ if (!m_imGuiRenderer) {
m_imGuiRenderer = new Debug::ImGuiRenderer(this);
+ if (m_settings)
+ m_imGuiRenderer->setCapabilities(m_settings->capabilities());
+ }
{
QMutexLocker l(&m_frameEventsMutex);