summaryrefslogtreecommitdiffstats
path: root/src/render/framegraph/qmemorybarrier.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/render/framegraph/qmemorybarrier.cpp')
-rw-r--r--src/render/framegraph/qmemorybarrier.cpp160
1 files changed, 160 insertions, 0 deletions
diff --git a/src/render/framegraph/qmemorybarrier.cpp b/src/render/framegraph/qmemorybarrier.cpp
new file mode 100644
index 000000000..37df337a5
--- /dev/null
+++ b/src/render/framegraph/qmemorybarrier.cpp
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 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 "qmemorybarrier.h"
+#include "qmemorybarrier_p.h"
+#include <Qt3DRender/qframegraphnodecreatedchange.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace Qt3DRender {
+
+/*!
+ \class Qt3DRender::QMemoryBarrier
+ \inmodule Qt3DRender
+ \since 5.9
+ \ingroup framegraph
+ \brief Class to emplace a memory barrier
+
+ A Qt3DRender::QMemoryBarrier FrameGraph node is used to emplace a specific
+ memory barrier at a specific time of the rendering. This is required to
+ properly synchronize drawing and compute commands on the GPU.
+
+ The barrier defines the ordering of memory operations issued by a prior
+ command. This means that if command1 is manipulating a buffer that is to be
+ used as a vertex attribute buffer in a following command2, then the memory
+ barrier should be placed after command1 and setting the appropriate barrier
+ type for vertex attribute buffer.
+
+ For OpenGL rendering, this page gives more info about the
+ \l {https://www.opengl.org/wiki/Memory_Model}{Memory Model}
+ */
+
+/*!
+ \qmltype MemoryBarrier
+ \inqmlmodule Qt3D.Render
+ \instantiates Qt3DRender::QMemoryBarrier
+ \inherits FrameGraphNode
+ \since 5.9
+ \brief Class to place a memory barrier
+
+ A MemoryBarrier FrameGraph node is used to emplace a specific
+ memory barrier at a specific time of the rendering. This is required to
+ properly synchronize drawing and compute commands on the GPU.
+
+ The barrier defines the ordering of memory operations issued by a prior
+ command. This means that if command1 is manipulating a buffer that is to be
+ used as a vertex attribute buffer in a following command2, then the memory
+ barrier should be placed after command1 and setting the appropriate barrier
+ type for vertex attribute buffer.
+
+ For OpenGL rendering, this page gives more info about the
+ \l {https://www.opengl.org/wiki/Memory_Model}{Memory Model}
+*/
+
+/*!
+ \enum QMemoryBarrier::BarrierType
+
+ This enum type describes types of buffer to be cleared.
+ \value None
+ \value ElementArrayBarrier
+ \value UniformBarrier
+ \value TextureFetchBarrier
+ \value ShaderImageAccessBarrier
+ \value CommandBarrier
+ \value PixelBufferBarrier
+ \value TextureUpdateBarrier
+ \value BufferUpdateBarrier
+ \value FrameBufferBarrier
+ \value TransformFeedbackBarrier
+ \value AtomicCounterBarrier
+ \value ShaderStorageBarrier
+ \value QueryBufferBarrier
+ \value AllBarrier
+*/
+
+
+QMemoryBarrierPrivate::QMemoryBarrierPrivate()
+ : QFrameGraphNodePrivate()
+ , m_barrierTypes(QMemoryBarrier::None)
+{
+}
+
+QMemoryBarrier::QMemoryBarrier(Qt3DCore::QNode *parent)
+ : QFrameGraphNode(*new QMemoryBarrierPrivate(), parent)
+{
+}
+
+QMemoryBarrier::~QMemoryBarrier()
+{
+}
+
+void QMemoryBarrier::setBarrierTypes(QMemoryBarrier::BarrierTypes barrierTypes)
+{
+ Q_D(QMemoryBarrier);
+ if (barrierTypes != d->m_barrierTypes) {
+ d->m_barrierTypes = barrierTypes;
+ emit barrierTypesChanged(barrierTypes);
+ }
+}
+
+QMemoryBarrier::BarrierTypes QMemoryBarrier::barrierTypes() const
+{
+ Q_D(const QMemoryBarrier);
+ return d->m_barrierTypes;
+}
+
+QMemoryBarrier::QMemoryBarrier(QMemoryBarrierPrivate &dd, Qt3DCore::QNode *parent)
+ : QFrameGraphNode(dd, parent)
+{
+}
+
+Qt3DCore::QNodeCreatedChangeBasePtr QMemoryBarrier::createNodeCreationChange() const
+{
+ auto creationChange = QFrameGraphNodeCreatedChangePtr<QMemoryBarrierData>::create(this);
+ QMemoryBarrierData &data = creationChange->data;
+ Q_D(const QMemoryBarrier);
+ data.barrierTypes = d->m_barrierTypes;
+ return creationChange;
+}
+
+
+} // Qt3DRender
+
+QT_END_NAMESPACE