Commit 683151c3 authored by Paul Lemire's avatar Paul Lemire Committed by Qt CI Bot
Browse files

Merge "FrameGraphNode: mark dirty on cleanup"

parents 972e6465 92f29f85
......@@ -123,6 +123,7 @@ QVector<FrameGraphNode *> FrameGraphNode::children() const
void FrameGraphNode::cleanup()
{
setParentId({});
markDirty(AbstractRenderer::FrameGraphDirty);
}
void FrameGraphNode::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
......
......@@ -130,8 +130,10 @@ void Buffer::syncFromFrontEnd(const QNode *frontEnd, bool firstTime)
if (!node)
return;
if (firstTime && m_manager != nullptr)
if (firstTime && m_manager != nullptr) {
m_manager->addBufferReference(peerId());
m_bufferDirty = true;
}
m_syncData = node->isSyncData();
m_access = node->accessType();
......
......@@ -329,7 +329,7 @@ void QBuffer::setData(const QByteArray &bytes)
Q_D(QBuffer);
if (bytes != d->m_data) {
d->m_data = bytes;
Qt3DCore::QNodePrivate::get(this)->update();
d->update();
emit dataChanged(bytes);
}
}
......
......@@ -113,25 +113,39 @@ private Q_SLOTS:
// GIVEN
Qt3DRender::QBuffer frontendBuffer;
frontendBuffer.setUsage(Qt3DRender::QBuffer::DynamicCopy);
frontendBuffer.setData(QByteArrayLiteral("C7KR4"));
frontendBuffer.setDataGenerator(Qt3DRender::QBufferDataGeneratorPtr(new TestFunctor(73)));
// WHEN
backendBuffer.setManager(&bufferManager);
backendBuffer.setRenderer(&renderer);
simulateInitializationSync(&frontendBuffer, &backendBuffer);
frontendBuffer.updateData(2, QByteArrayLiteral("LS5"));
// THEN
QCOMPARE(backendBuffer.isDirty(), true);
QCOMPARE(backendBuffer.usage(), Qt3DRender::QBuffer::StaticDraw);
QVERIFY(backendBuffer.data().isEmpty());
QVERIFY(backendBuffer.dataGenerator().isNull());
QVERIFY(backendBuffer.pendingBufferUpdates().empty());
// WHEN
frontendBuffer.setUsage(Qt3DRender::QBuffer::DynamicCopy);
frontendBuffer.setData(QByteArrayLiteral("C7KR4"));
frontendBuffer.setDataGenerator(Qt3DRender::QBufferDataGeneratorPtr(new TestFunctor(73)));
backendBuffer.syncFromFrontEnd(&frontendBuffer, false);
// THEN
QCOMPARE(backendBuffer.usage(), Qt3DRender::QBuffer::DynamicCopy);
QCOMPARE(backendBuffer.isDirty(), true);
QCOMPARE(backendBuffer.data(), QByteArrayLiteral("C7LS5"));
QCOMPARE(backendBuffer.data(), QByteArrayLiteral("C7KR4"));
QVERIFY(!backendBuffer.dataGenerator().isNull());
QVERIFY(!backendBuffer.pendingBufferUpdates().empty());
// WHEN
frontendBuffer.updateData(2, QByteArrayLiteral("LS5"));
backendBuffer.syncFromFrontEnd(&frontendBuffer, false);
// THEN
QCOMPARE(backendBuffer.isDirty(), true);
QCOMPARE(backendBuffer.data(), QByteArrayLiteral("C7LS5"));
// WHEN
backendBuffer.cleanup();
......
......@@ -266,6 +266,24 @@ private Q_SLOTS:
}
}
void checCleanupMarksDirty()
{
// GIVEN
TestRenderer renderer;
Qt3DRender::Render::FrameGraphNode *backendFGNode = new MyFrameGraphNode();
backendFGNode->setRenderer(&renderer);
// THEN
QVERIFY(renderer.dirtyBits() == 0);
// WHEN
backendFGNode->cleanup();
// THEN
QVERIFY(renderer.dirtyBits() & Qt3DRender::Render::AbstractRenderer::FrameGraphDirty);
}
};
QTEST_MAIN(tst_FrameGraphNode)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment