summaryrefslogtreecommitdiffstats
path: root/src/render
diff options
context:
space:
mode:
authorMike Krus <mike.krus@kdab.com>2020-02-09 08:54:07 +0000
committerMike Krus <mike.krus@kdab.com>2020-02-11 12:50:13 +0000
commit83d81bc82eb7ca8d2ed113aac14f9a2d0a40a362 (patch)
treef75d87c176a18feefe7cedd89ddecd8f490893c3 /src/render
parentc86ffa60f07d7ee77f835ad4d8383b599dd9886e (diff)
Remove buffer functor API
Change-Id: I78cc60ff634f909111b891d5b9716e19cae35f3b Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render')
-rw-r--r--src/render/frontend/qrenderaspect.cpp2
-rw-r--r--src/render/geometry/buffer.cpp19
-rw-r--r--src/render/geometry/buffer_p.h4
-rw-r--r--src/render/geometry/geometry.pri1
-rw-r--r--src/render/geometry/qbuffer.cpp115
-rw-r--r--src/render/geometry/qbuffer.h5
-rw-r--r--src/render/geometry/qbuffer_p.h2
-rw-r--r--src/render/geometry/qbufferdatagenerator.h68
-rw-r--r--src/render/jobs/jobs.pri2
9 files changed, 2 insertions, 216 deletions
diff --git a/src/render/frontend/qrenderaspect.cpp b/src/render/frontend/qrenderaspect.cpp
index 61567854f..fa6416199 100644
--- a/src/render/frontend/qrenderaspect.cpp
+++ b/src/render/frontend/qrenderaspect.cpp
@@ -499,7 +499,7 @@ QVector<Qt3DCore::QAspectJobPtr> QRenderAspect::jobsToExecute(qint64 time)
// Create jobs that will get executed by the threadpool
QVector<QAspectJobPtr> jobs;
- // 1 LoadBufferJobs, GeometryJobs, SceneLoaderJobs, LoadTextureJobs
+ // 1 GeometryJobs, SceneLoaderJobs, LoadTextureJobs
// 2 CalculateBoundingVolumeJob (depends on LoadBuffer)
// 3 WorldTransformJob
// 4 UpdateBoundingVolume, FramePreparationJob (depend on WorlTransformJob)
diff --git a/src/render/geometry/buffer.cpp b/src/render/geometry/buffer.cpp
index 3ffcd25bc..4d3d5c1aa 100644
--- a/src/render/geometry/buffer.cpp
+++ b/src/render/geometry/buffer.cpp
@@ -69,7 +69,6 @@ void Buffer::cleanup()
m_usage = QBuffer::StaticDraw;
m_data.clear();
m_bufferUpdates.clear();
- m_functor.reset();
m_bufferDirty = false;
m_syncData = false;
m_access = QBuffer::Write;
@@ -81,14 +80,6 @@ void Buffer::setManager(BufferManager *manager)
m_manager = manager;
}
-void Buffer::executeFunctor()
-{
- Q_ASSERT(m_functor);
- m_data = (*m_functor)();
- // Request data to be loaded
- forceDataUpload();
-}
-
//Called from th sendBufferJob
void Buffer::updateDataFromGPUToCPU(QByteArray data)
{
@@ -126,16 +117,6 @@ void Buffer::syncFromFrontEnd(const QNode *frontEnd, bool firstTime)
m_bufferDirty = true;
}
{
- QBufferDataGeneratorPtr newGenerator = node->dataGenerator();
- bool dirty = (newGenerator && m_functor && !(*newGenerator == *m_functor)) ||
- (newGenerator.isNull() && !m_functor.isNull()) ||
- (!newGenerator.isNull() && m_functor.isNull());
- m_bufferDirty |= dirty;
- m_functor = newGenerator;
- if (m_functor && m_manager != nullptr)
- m_manager->addDirtyBuffer(peerId());
- }
- {
const QVariant v = node->property("QT3D_updateData");
// Make sure we record data if it's the first time we are called
diff --git a/src/render/geometry/buffer_p.h b/src/render/geometry/buffer_p.h
index ed51c01d8..41a525fc2 100644
--- a/src/render/geometry/buffer_p.h
+++ b/src/render/geometry/buffer_p.h
@@ -54,7 +54,6 @@
#include <QtCore>
#include <Qt3DRender/private/backendnode_p.h>
#include <Qt3DRender/qbuffer.h>
-#include <Qt3DRender/qbufferdatagenerator.h>
QT_BEGIN_NAMESPACE
@@ -76,13 +75,11 @@ public:
void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
void setManager(BufferManager *manager);
- void executeFunctor();
void updateDataFromGPUToCPU(QByteArray data);
inline QBuffer::UsageType usage() const { return m_usage; }
inline QByteArray data() const { return m_data; }
inline QVector<Qt3DRender::QBufferUpdate> &pendingBufferUpdates() { return m_bufferUpdates; }
inline bool isDirty() const { return m_bufferDirty; }
- inline QBufferDataGeneratorPtr dataGenerator() const { return m_functor; }
inline bool isSyncData() const { return m_syncData; }
inline QBuffer::AccessType access() const { return m_access; }
void unsetDirty();
@@ -96,7 +93,6 @@ private:
bool m_bufferDirty;
bool m_syncData;
QBuffer::AccessType m_access;
- QBufferDataGeneratorPtr m_functor;
BufferManager *m_manager;
};
diff --git a/src/render/geometry/geometry.pri b/src/render/geometry/geometry.pri
index 63a18f24e..efc245fba 100644
--- a/src/render/geometry/geometry.pri
+++ b/src/render/geometry/geometry.pri
@@ -18,7 +18,6 @@ HEADERS += \
$$PWD/qmesh_p.h \
$$PWD/qattribute_p.h \
$$PWD/qattribute.h \
- $$PWD/qbufferdatagenerator.h \
$$PWD/armature_p.h \
$$PWD/skeleton_p.h \
$$PWD/gltfskeletonloader_p.h \
diff --git a/src/render/geometry/qbuffer.cpp b/src/render/geometry/qbuffer.cpp
index 646670ad1..dc2833158 100644
--- a/src/render/geometry/qbuffer.cpp
+++ b/src/render/geometry/qbuffer.cpp
@@ -109,12 +109,7 @@ void QBufferPrivate::setData(const QByteArray &data)
* \brief Provides a data store for raw data to later be used as vertices or
* uniforms.
*
- * Data can either be provided directly using QBuffer::setData() or by
- * specifying a generator with QBuffer::setDataGenerator() and providing a
- * Qt3DRender::QBufferDataGeneratorPtr.
- *
- * When using a generator the data will be loaded asynchronously in a job. The
- * loaded data can be read back if the QBuffer::syncData flag is set to true.
+ * Data can be provided directly using QBuffer::setData().
*/
/*!
@@ -130,93 +125,6 @@ void QBufferPrivate::setData(const QByteArray &data)
*/
/*!
- \class Qt3DRender::QBufferDataGenerator
- \inmodule Qt3DRender
-
- \inherits Qt3DRender::QAbstractFunctor
-
- \brief Provides a mechanism to generate buffer data from a job.
-
- The Qt3DRender::QBufferDataGenerator should be subclassed to provide a way
- to fill the data of a Qt3DRender::QBuffer. Such functors are executed at
- runtime in a Qt 3D job (likely in parallel with many other jobs). When
- providing a functor you must implement the operator() which will be called
- to generate the actual data. You must make sure that you have stored copies
- of anything you might need for it to execute properly. You should also
- implement the operator==. It will be used to compare with other functors
- and based on that allow the renderer to decide if a new functor should be
- executed or not.
-
- \note functors are useful when you can build data from a few set of
- attributes (e.g: building a sphere from a radius property). If you already
- have access to the buffer data, using Qt3DRender::QBuffer::setData() is
- likely more efficient.
-
- \code
-
- QByteArray createSphereMeshVertexData(float radius, int rings, int slices)
- {
- ...
- }
-
- class SphereVertexDataFunctor : public QBufferDataGenerator
- {
- public:
- SphereVertexDataFunctor(int rings, int slices, float radius)
- : m_rings(rings)
- , m_slices(slices)
- , m_radius(radius)
- {}
-
- QByteArray operator ()() override
- {
- return createSphereMeshVertexData(m_radius, m_rings, m_slices);
- }
-
- bool operator ==(const QBufferDataGenerator &other) const override
- {
- const SphereVertexDataFunctor *otherFunctor = functor_cast<SphereVertexDataFunctor>(&other);
- if (otherFunctor != nullptr)
- return (otherFunctor->m_rings == m_rings &&
- otherFunctor->m_slices == m_slices &&
- otherFunctor->m_radius == m_radius);
- return false;
- }
-
- QT3D_FUNCTOR(SphereVertexDataFunctor)
-
- private:
- int m_rings;
- int m_slices;
- float m_radius;
- };
-
- \endcode
-
- The QT3D_FUNCTOR macro should be added when subclassing. This allows you to
- use functor_cast in your comparison operator to make sure that the other
- functor is of the same type as the one your are trying to compare against.
-*/
-
-/*!
- \fn Qt3DRender::QBufferDataGenerator::operator()()
-
- Should be implemented to return the buffer data as a QByteArray when called.
- */
-
-/*!
- \fn Qt3DRender::QBufferDataGenerator::operator ==(const QBufferDataGenerator &other) const
-
- Should be reimplemented to return true when two generators (the one you are
- comparing against and the \a other generator) are identical,
- false otherwise.
-
- \note The renderer uses this comparison to decide whether data for a buffer
- needs to be reuploaded or not when the functor on a Qt3DRender::QBuffer
- changes.
- */
-
-/*!
* \enum QBuffer::BufferType
*
* The type of the buffer.
@@ -383,27 +291,6 @@ QBuffer::BufferType QBuffer::type() const
}
/*!
- * Sets the buffer \a functor.
- */
-void QBuffer::setDataGenerator(const QBufferDataGeneratorPtr &functor)
-{
- Q_D(QBuffer);
- if (functor && d->m_functor && *functor == *d->m_functor)
- return;
- d->m_functor = functor;
- d->update();
-}
-
-/*!
- * \return the buffer functor.
- */
-QBufferDataGeneratorPtr QBuffer::dataGenerator() const
-{
- Q_D(const QBuffer);
- return d->m_functor;
-}
-
-/*!
* \property QBuffer::syncData
*
* Holds the syncData flag. When syncData is true, this will force data created
diff --git a/src/render/geometry/qbuffer.h b/src/render/geometry/qbuffer.h
index 6b18063ee..a4de25eae 100644
--- a/src/render/geometry/qbuffer.h
+++ b/src/render/geometry/qbuffer.h
@@ -50,8 +50,6 @@ QT_BEGIN_NAMESPACE
namespace Qt3DRender {
class QBufferPrivate;
-class QBufferDataGenerator;
-typedef QSharedPointer<QBufferDataGenerator> QBufferDataGeneratorPtr;
class Q_3DRENDERSHARED_EXPORT QBuffer : public Qt3DCore::QNode
{
@@ -107,9 +105,6 @@ public:
void setData(const QByteArray &bytes);
QByteArray data() const;
- Q3D_DECL_DEPRECATED void setDataGenerator(const QBufferDataGeneratorPtr &functor);
- Q3D_DECL_DEPRECATED QBufferDataGeneratorPtr dataGenerator() const;
-
Q_INVOKABLE void updateData(int offset, const QByteArray &bytes);
public Q_SLOTS:
diff --git a/src/render/geometry/qbuffer_p.h b/src/render/geometry/qbuffer_p.h
index 0b948cff3..082249d3c 100644
--- a/src/render/geometry/qbuffer_p.h
+++ b/src/render/geometry/qbuffer_p.h
@@ -53,7 +53,6 @@
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DRender/qbuffer.h>
-#include <Qt3DRender/qbufferdatagenerator.h>
#include <Qt3DRender/qt3drender_global.h>
#include <private/qnode_p.h>
#include <QByteArray>
@@ -72,7 +71,6 @@ public:
QByteArray m_data;
QBuffer::BufferType m_type;
QBuffer::UsageType m_usage;
- QBufferDataGeneratorPtr m_functor;
bool m_syncData;
QBuffer::AccessType m_access;
diff --git a/src/render/geometry/qbufferdatagenerator.h b/src/render/geometry/qbufferdatagenerator.h
deleted file mode 100644
index aea6eaef5..000000000
--- a/src/render/geometry/qbufferdatagenerator.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 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_QBUFFERDATAGENERATOR
-#define QT3DRENDER_QBUFFERDATAGENERATOR
-
-#include <Qt3DRender/qt3drender_global.h>
-#include <Qt3DRender/qabstractfunctor.h>
-#include <QtCore/QSharedPointer>
-
-QT_BEGIN_NAMESPACE
-
-namespace Qt3DRender {
-
-class Q_3DRENDERSHARED_EXPORT QBufferDataGenerator : public QAbstractFunctor
-{
-public:
- virtual ~QBufferDataGenerator() {}
- virtual QByteArray operator()() = 0;
- virtual bool operator ==(const QBufferDataGenerator &other) const = 0;
-};
-
-typedef QSharedPointer<QBufferDataGenerator> QBufferDataGeneratorPtr;
-
-} // namespace Qt3DRender
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(Qt3DRender::QBufferDataGeneratorPtr) // LCOV_EXCL_LINE
-
-#endif // QT3DRENDER_QBUFFERDATAGENERATOR
-
diff --git a/src/render/jobs/jobs.pri b/src/render/jobs/jobs.pri
index 07d6f4799..97ad32557 100644
--- a/src/render/jobs/jobs.pri
+++ b/src/render/jobs/jobs.pri
@@ -4,7 +4,6 @@ HEADERS += \
$$PWD/updateworldtransformjob_p.h \
$$PWD/loadscenejob_p.h \
$$PWD/framecleanupjob_p.h \
- $$PWD/loadbufferjob_p.h \
$$PWD/loadgeometryjob_p.h \
$$PWD/calcboundingvolumejob_p.h \
$$PWD/pickboundingvolumejob_p.h \
@@ -34,7 +33,6 @@ SOURCES += \
$$PWD/updateworldtransformjob.cpp \
$$PWD/loadscenejob.cpp \
$$PWD/framecleanupjob.cpp \
- $$PWD/loadbufferjob.cpp \
$$PWD/loadgeometryjob.cpp \
$$PWD/calcboundingvolumejob.cpp \
$$PWD/pickboundingvolumejob.cpp \