summaryrefslogtreecommitdiffstats
path: root/src/render/backend
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2019-09-19 09:57:53 +0200
committerPaul Lemire <paul.lemire@kdab.com>2019-09-25 11:41:37 +0200
commitcca7720e68a3bf64dbf549b06ba13547cb29181c (patch)
tree508738a646160deb682dafba057ca168617cda53 /src/render/backend
parente498e2fc16a09cab315ffaf88eea1679fe2a436d (diff)
Update QComputeCommand to use direct sync
Change-Id: I5e755bbc7e3a948f7f2356d7110ac817ae32616a Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src/render/backend')
-rw-r--r--src/render/backend/computecommand.cpp50
-rw-r--r--src/render/backend/computecommand_p.h3
2 files changed, 26 insertions, 27 deletions
diff --git a/src/render/backend/computecommand.cpp b/src/render/backend/computecommand.cpp
index 7079d0308..386c25fec 100644
--- a/src/render/backend/computecommand.cpp
+++ b/src/render/backend/computecommand.cpp
@@ -73,35 +73,35 @@ void ComputeCommand::cleanup()
m_runType = QComputeCommand::Continuous;
}
-void ComputeCommand::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change)
+void ComputeCommand::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
{
- const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QComputeCommandData>>(change);
- const auto &data = typedChange->data;
- m_workGroups[0] = data.workGroupX;
- m_workGroups[1] = data.workGroupY;
- m_workGroups[2] = data.workGroupZ;
- m_runType = data.runType;
- m_frameCount = data.frameCount;
- markDirty(AbstractRenderer::ComputeDirty);
-}
+ const QComputeCommand *node = qobject_cast<const QComputeCommand *>(frontEnd);
+ if (!node)
+ return;
-void ComputeCommand::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
-{
- Qt3DCore::QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<Qt3DCore::QPropertyUpdatedChange>(e);
- if (e->type() == Qt3DCore::PropertyUpdated) {
- 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("frameCount"))
- m_frameCount = propertyChange->value().toInt();
- else if (propertyChange->propertyName() == QByteArrayLiteral("runType"))
- m_runType = static_cast<QComputeCommand::RunType>(propertyChange->value().toInt());
+ BackendNode::syncFromFrontEnd(frontEnd, firstTime);
+
+ if (m_workGroups[0] != node->workGroupX()) {
+ m_workGroups[0] = node->workGroupX();
+ markDirty(AbstractRenderer::ComputeDirty);
+ }
+ if (m_workGroups[1] != node->workGroupY()) {
+ m_workGroups[1] = node->workGroupY();
+ markDirty(AbstractRenderer::ComputeDirty);
+ }
+ if (m_workGroups[2] != node->workGroupZ()) {
+ m_workGroups[2] = node->workGroupZ();
+ markDirty(AbstractRenderer::ComputeDirty);
+ }
+ if (node->runType() != m_runType) {
+ m_runType = node->runType();
+ markDirty(AbstractRenderer::ComputeDirty);
+ }
+ const QComputeCommandPrivate *d = static_cast<const QComputeCommandPrivate *>(Qt3DCore::QNodePrivate::get(node));
+ if (d->m_frameCount != m_frameCount) {
+ m_frameCount = d->m_frameCount;
markDirty(AbstractRenderer::ComputeDirty);
}
- BackendNode::sceneChangeEvent(e);
}
// Called from buildComputeRenderCommands in a job
diff --git a/src/render/backend/computecommand_p.h b/src/render/backend/computecommand_p.h
index 10e10fd25..dc2069928 100644
--- a/src/render/backend/computecommand_p.h
+++ b/src/render/backend/computecommand_p.h
@@ -69,7 +69,7 @@ public:
~ComputeCommand();
void cleanup();
- void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override;
+ void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override;
inline int x() const Q_DECL_NOTHROW { return m_workGroups[0]; }
inline int y() const Q_DECL_NOTHROW { return m_workGroups[1]; }
@@ -81,7 +81,6 @@ public:
void updateFrameCount();
private:
- void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) override;
int m_workGroups[3];
int m_frameCount;
QComputeCommand::RunType m_runType;