diff options
author | Alessandro Portale <alessandro.portale@qt.io> | 2021-06-09 11:36:10 +0200 |
---|---|---|
committer | Alessandro Portale <alessandro.portale@qt.io> | 2021-06-09 15:30:21 +0000 |
commit | 43c5944571601e49ac8dc29491a5000e92f16aaa (patch) | |
tree | deb63c4fff3f7d620666d966b94b882a9d53c9df /src/plugins/qmlprofiler | |
parent | 370410aca06e75139414ae1f5cd34efa541e5c1b (diff) |
Tracing/QmlProfiler/CtfVisualizer/PerfProfiler: Compile with Qt 6
This makes the tracing lib, its tests and the three plugins which depend
on the lib compile with Qt 6.
The rectangles are not yet shown most likely because some OpenGL
specific code was #ifdef-ed for Qt 6. That code needs to be
reimplemented on top of the new Scenegraph API, using the RHI instead of
direct OpenGL in a follow-up patch.
An assertion failure in QQuickWidget::createFramebufferObject() needs to
be fixed as-well.
The code still builds and runs assertion free (and the autotests pass)
when built against Qt 5.
Task-number: QTCREATORBUG-20575
Change-Id: I47ebb477823de2f0d27329dac7c292a466cea1d7
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/plugins/qmlprofiler')
4 files changed, 60 insertions, 10 deletions
diff --git a/src/plugins/qmlprofiler/inputeventsmodel.cpp b/src/plugins/qmlprofiler/inputeventsmodel.cpp index 386b57806ad..5e2b7cb7652 100644 --- a/src/plugins/qmlprofiler/inputeventsmodel.cpp +++ b/src/plugins/qmlprofiler/inputeventsmodel.cpp @@ -72,7 +72,12 @@ QVariantList InputEventsModel::labels() const QMetaEnum InputEventsModel::metaEnum(const char *name) { - return staticQtMetaObject.enumerator(staticQtMetaObject.indexOfEnumerator(name)); + return +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + staticQtMetaObject.enumerator(staticQtMetaObject.indexOfEnumerator(name)); +#else // < Qt 6 + Qt::staticMetaObject.enumerator(Qt::staticMetaObject.indexOfEnumerator(name)); +#endif // < Qt 6 } QVariantMap InputEventsModel::details(int index) const diff --git a/src/plugins/qmlprofiler/qmlprofilerbindingloopsrenderpass.cpp b/src/plugins/qmlprofiler/qmlprofilerbindingloopsrenderpass.cpp index f7eaab21a2d..892f384b6ad 100644 --- a/src/plugins/qmlprofiler/qmlprofilerbindingloopsrenderpass.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerbindingloopsrenderpass.cpp @@ -34,7 +34,11 @@ namespace Internal { class BindingLoopMaterial : public QSGMaterial { public: QSGMaterialType *type() const override; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QSGMaterialShader *createShader() const override; +#else + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override; +#endif // < Qt 6 BindingLoopMaterial(); }; @@ -196,8 +200,8 @@ Timeline::TimelineRenderPass::State *QmlProfilerBindingLoopsRenderPass::update( const QSGGeometry::AttributeSet &BindlingLoopsGeometry::point2DWithOffset() { static QSGGeometry::Attribute data[] = { - QSGGeometry::Attribute::create(0, 2, GL_FLOAT, true), - QSGGeometry::Attribute::create(1, 2, GL_FLOAT), + QSGGeometry::Attribute::create(0, 2, QSGGeometry::FloatType, true), + QSGGeometry::Attribute::create(1, 2, QSGGeometry::FloatType), }; static QSGGeometry::AttributeSet attrs = { 2, @@ -215,10 +219,10 @@ Point2DWithOffset *BindlingLoopsGeometry::vertexData() const QSGGeometry::Attribute *attributes = geometry->attributes(); Q_ASSERT(attributes[0].position == 0); Q_ASSERT(attributes[0].tupleSize == 2); - Q_ASSERT(attributes[0].type == GL_FLOAT); + Q_ASSERT(attributes[0].type == QSGGeometry::FloatType); Q_ASSERT(attributes[1].position == 1); Q_ASSERT(attributes[1].tupleSize == 2); - Q_ASSERT(attributes[1].type == GL_FLOAT); + Q_ASSERT(attributes[1].type == QSGGeometry::FloatType); Q_UNUSED(attributes) return static_cast<Point2DWithOffset *>(geometry->vertexData()); } @@ -290,12 +294,19 @@ class BindingLoopMaterialShader : public QSGMaterialShader public: BindingLoopMaterialShader(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void updateState(const RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override; char const *const *attributeNames() const override; +#else // < Qt 6 + bool updateUniformData(RenderState &state, QSGMaterial *newEffect, + QSGMaterial *oldEffect) override; +#endif // < Qt 6 private: +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void initialize() override; +#endif // < Qt 6 int m_matrix_id = 0; int m_z_range_id = 0; @@ -305,10 +316,16 @@ private: BindingLoopMaterialShader::BindingLoopMaterialShader() : QSGMaterialShader() { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/qmlprofiler/bindingloops.vert")); setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/qmlprofiler/bindingloops.frag")); +#else // < Qt 6 + setShaderFileName(VertexStage, ":/qmlprofiler/bindingloops.vert"); + setShaderFileName(FragmentStage, ":/qmlprofiler/bindingloops.frag"); +#endif // < Qt 6 } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) void BindingLoopMaterialShader::updateState(const RenderState &state, QSGMaterial *, QSGMaterial *) { if (state.isMatrixDirty()) { @@ -319,7 +336,19 @@ void BindingLoopMaterialShader::updateState(const RenderState &state, QSGMateria Utils::creatorTheme()->color(Utils::Theme::Timeline_HighlightColor)); } } +#else // < Qt 6 +bool BindingLoopMaterialShader::updateUniformData(RenderState &state, + QSGMaterial *newMaterial, QSGMaterial *) +{ + // TODO: Make this work + if (state.isMatrixDirty()) { + BindingLoopMaterial *material = static_cast<BindingLoopMaterial *>(newMaterial); + } + return state.isMatrixDirty(); +} +#endif // < Qt 6 +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) char const *const *BindingLoopMaterialShader::attributeNames() const { static const char *const attr[] = {"vertexCoord", "postScaleOffset", nullptr}; @@ -332,7 +361,7 @@ void BindingLoopMaterialShader::initialize() m_z_range_id = program()->uniformLocation("_qt_zRange"); m_color_id = program()->uniformLocation("bindingLoopsColor"); } - +#endif // < Qt 6 BindingLoopMaterial::BindingLoopMaterial() { @@ -345,10 +374,19 @@ QSGMaterialType *BindingLoopMaterial::type() const return &type; } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QSGMaterialShader *BindingLoopMaterial::createShader() const { return new BindingLoopMaterialShader; } +#else // < Qt 6 +QSGMaterialShader *BindingLoopMaterial::createShader( + QSGRendererInterface::RenderMode renderMode) const +{ + Q_UNUSED(renderMode); + return new BindingLoopMaterialShader; +} +#endif // < Qt 6 void Point2DWithOffset::set(float nx, float ny, float nx2, float ny2) { diff --git a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp index c994c377192..e2531e9fe81 100644 --- a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp @@ -152,7 +152,7 @@ void QmlProfilerTraceFile::loadQtd(QIODevice *device) while (validVersion && !stream.atEnd() && !stream.hasError() && !isCanceled()) { QXmlStreamReader::TokenType token = stream.readNext(); - const QStringRef elementName = stream.name(); + const QStringView elementName = stream.name(); switch (token) { case QXmlStreamReader::StartDocument : continue; case QXmlStreamReader::StartElement : { @@ -327,7 +327,7 @@ void QmlProfilerTraceFile::loadEventTypes(QXmlStreamReader &stream) while (!stream.atEnd() && !stream.hasError() && !isCanceled()) { QXmlStreamReader::TokenType token = stream.readNext(); - const QStringRef elementName = stream.name(); + const QStringView elementName = stream.name(); switch (token) { case QXmlStreamReader::StartElement: { @@ -503,7 +503,7 @@ void QmlProfilerTraceFile::loadEvents(QXmlStreamReader &stream) while (!stream.atEnd() && !stream.hasError() && !isCanceled()) { QXmlStreamReader::TokenType token = stream.readNext(); - const QStringRef elementName = stream.name(); + const QStringView elementName = stream.name(); switch (token) { case QXmlStreamReader::StartElement: { @@ -588,7 +588,7 @@ void QmlProfilerTraceFile::loadNotes(QXmlStreamReader &stream) while (!stream.atEnd() && !stream.hasError() && !isCanceled()) { QXmlStreamReader::TokenType token = stream.readNext(); - const QStringRef elementName = stream.name(); + const QStringView elementName = stream.name(); switch (token) { case QXmlStreamReader::StartElement: { diff --git a/src/plugins/qmlprofiler/tests/qmlprofilerbindingloopsrenderpass_test.cpp b/src/plugins/qmlprofiler/tests/qmlprofilerbindingloopsrenderpass_test.cpp index 0ff9af14b3d..642720f34b0 100644 --- a/src/plugins/qmlprofiler/tests/qmlprofilerbindingloopsrenderpass_test.cpp +++ b/src/plugins/qmlprofiler/tests/qmlprofilerbindingloopsrenderpass_test.cpp @@ -119,11 +119,18 @@ void QmlProfilerBindingLoopsRenderPassTest::testUpdate() QCOMPARE(node->geometry()->vertexCount(), 7 * 18); QVERIFY(material2 != nullptr); QCOMPARE(material1->type(), material2->type()); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QSGMaterialShader *shader1 = material1->createShader(); QVERIFY(shader1 != nullptr); QSGMaterialShader *shader2 = material2->createShader(); QVERIFY(shader2 != nullptr); QCOMPARE(shader1->attributeNames(), shader2->attributeNames()); +#else // < Qt 6 + QSGMaterialShader *shader1 = material1->createShader(QSGRendererInterface::RenderMode2D); + QVERIFY(shader1 != 0); + QSGMaterialShader *shader2 = material2->createShader(QSGRendererInterface::RenderMode2D); + QVERIFY(shader2 != 0); +#endif // < Qt 6 delete shader1; delete shader2; |