diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2015-12-04 10:40:02 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2015-12-07 19:07:03 +0000 |
commit | 2bf03c849a5a85d2963c81fe162459b5be1d4865 (patch) | |
tree | e8108da7162bacdef9506dcb6bb9ec453716f964 /src/render | |
parent | 4db53c73453094a9a68e8ff7194b1bd99f2bc4cb (diff) |
BackendNode for QComputeDispatch
Change-Id: I41a027b073ee5cb253f7b37244ad887acff4f909
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/framegraph/dispatchcompute.cpp | 92 | ||||
-rw-r--r-- | src/render/framegraph/dispatchcompute_p.h | 81 | ||||
-rw-r--r-- | src/render/framegraph/framegraph.pri | 6 | ||||
-rw-r--r-- | src/render/framegraph/framegraphnode_p.h | 3 |
4 files changed, 179 insertions, 3 deletions
diff --git a/src/render/framegraph/dispatchcompute.cpp b/src/render/framegraph/dispatchcompute.cpp new file mode 100644 index 000000000..3197a1d4a --- /dev/null +++ b/src/render/framegraph/dispatchcompute.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** 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 "dispatchcompute_p.h" +#include <Qt3DCore/qscenepropertychange.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +namespace Render { + +DispatchCompute::DispatchCompute() + : FrameGraphNode(FrameGraphNode::ComputeDispatch) +{ + m_workGroups[0] = 1; + m_workGroups[1] = 1; + m_workGroups[2] = 1; +} + +DispatchCompute::~DispatchCompute() +{ +} + +void DispatchCompute::cleanup() +{ + m_workGroups[0] = 1; + m_workGroups[1] = 1; + m_workGroups[2] = 1; +} + +void DispatchCompute::updateFromPeer(Qt3DCore::QNode *peer) +{ + QDispatchCompute *computeDispatch = static_cast<QDispatchCompute *>(peer); + m_workGroups[0] = computeDispatch->workGroupX(); + m_workGroups[1] = computeDispatch->workGroupY(); + m_workGroups[2] = computeDispatch->workGroupZ(); +} + +void DispatchCompute::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) +{ + if (e->type() == Qt3DCore::NodeUpdated) { + Qt3DCore::QScenePropertyChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QScenePropertyChange>(e); + if (propertyChange->propertyName() == QByteArrayLiteral("workGroupX")) + m_workGroups[0] = propertyChange->value().toInt(); + else if (propertyChange->propertyName() == QByteArrayLiteral("workGroupY")) + m_workGroups[1] = propertyChange->value().toInt(); + else if (propertyChange->propertyName() == QByteArrayLiteral("workGroupZ")) + m_workGroups[2] = propertyChange->value().toInt(); + else if (propertyChange->propertyName() == QByteArrayLiteral("enabled")) + setEnabled(propertyChange->value().toBool()); + } +} + +} // Render + +} // Qt3DRender + +QT_END_NAMESPACE diff --git a/src/render/framegraph/dispatchcompute_p.h b/src/render/framegraph/dispatchcompute_p.h new file mode 100644 index 000000000..7a90f980a --- /dev/null +++ b/src/render/framegraph/dispatchcompute_p.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). +** Contact: http://www.qt-project.org/legal +** +** 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 QT3DRENDER_RENDER_DISPATCHCOMPUTE_H +#define QT3DRENDER_RENDER_DISPATCHCOMPUTE_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/framegraphnode_p.h> +#include <Qt3DRender/qdispatchcompute.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DRender { + +namespace Render { + +class DispatchCompute : public FrameGraphNode +{ +public: + DispatchCompute(); + ~DispatchCompute(); + + void cleanup(); + + void updateFromPeer(Qt3DCore::QNode *peer) Q_DECL_OVERRIDE; + void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) Q_DECL_OVERRIDE; + +private: + int m_workGroups[3]; +}; + +} // Render + +} // Qt3DRender + +QT_END_NAMESPACE + +#endif // QT3DRENDER_RENDER_DISPATCHCOMPUTE_H diff --git a/src/render/framegraph/framegraph.pri b/src/render/framegraph/framegraph.pri index c69da622c..422825629 100644 --- a/src/render/framegraph/framegraph.pri +++ b/src/render/framegraph/framegraph.pri @@ -47,7 +47,8 @@ HEADERS += \ $$PWD/qlighting.h \ $$PWD/qlighting_p.h \ $$PWD/lighting_p.h \ - $$PWD/qdispatchcompute.h + $$PWD/qdispatchcompute.h \ + $$PWD/dispatchcompute_p.h SOURCES += \ $$PWD/cameraselectornode.cpp \ @@ -82,4 +83,5 @@ SOURCES += \ $$PWD/frustumculling.cpp \ $$PWD/qlighting.cpp \ $$PWD/lighting.cpp \ - $$PWD/qdispatchcompute.cpp + $$PWD/qdispatchcompute.cpp \ + $$PWD/dispatchcompute.cpp diff --git a/src/render/framegraph/framegraphnode_p.h b/src/render/framegraph/framegraphnode_p.h index b068b103a..764314438 100644 --- a/src/render/framegraph/framegraphnode_p.h +++ b/src/render/framegraph/framegraphnode_p.h @@ -82,7 +82,8 @@ public: StateSet, NoDraw, FrustumCulling, - Lighting + Lighting, + ComputeDispatch }; FrameGraphNodeType nodeType() const { return m_nodeType; } |