forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -5,7 +5,6 @@ if (WITH_TESTS)
|
||||
endif()
|
||||
|
||||
add_qtc_library(Tracing
|
||||
CONDITION Qt5_VERSION VERSION_LESS 6.0.0
|
||||
FEATURE_INFO
|
||||
DEPENDS Utils Qt5::Qml Qt5::Quick
|
||||
PUBLIC_DEPENDS Qt5::Widgets
|
||||
|
||||
@@ -29,8 +29,11 @@
|
||||
#include <QString>
|
||||
#include <QOpenGLContext>
|
||||
#include <QOffscreenSurface>
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QSGEngine>
|
||||
#include <QSGAbstractRenderer>
|
||||
#endif // < Qt 6
|
||||
|
||||
namespace Timeline {
|
||||
|
||||
@@ -59,6 +62,7 @@ void runSceneGraphTest(QSGNode *node)
|
||||
|
||||
QVERIFY(context.makeCurrent(&surface));
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QSGEngine engine;
|
||||
QSGRootNode root;
|
||||
root.appendChildNode(node);
|
||||
@@ -74,6 +78,7 @@ void runSceneGraphTest(QSGNode *node)
|
||||
|
||||
// Unfortunately we cannot check the results of the rendering. But at least we know the shaders
|
||||
// have not crashed here.
|
||||
#endif // < Qt 6
|
||||
|
||||
context.doneCurrent();
|
||||
}
|
||||
|
||||
@@ -259,16 +259,16 @@ OpaqueColoredPoint2DWithSize *OpaqueColoredPoint2DWithSize::fromVertexData(QSGGe
|
||||
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_ASSERT(attributes[2].position == 2);
|
||||
Q_ASSERT(attributes[2].tupleSize == 1);
|
||||
Q_ASSERT(attributes[2].type == GL_FLOAT);
|
||||
Q_ASSERT(attributes[2].type == QSGGeometry::FloatType);
|
||||
Q_ASSERT(attributes[3].position == 3);
|
||||
Q_ASSERT(attributes[3].tupleSize == 4);
|
||||
Q_ASSERT(attributes[3].type == GL_UNSIGNED_BYTE);
|
||||
Q_ASSERT(attributes[3].type == QSGGeometry::UnsignedByteType);
|
||||
Q_UNUSED(attributes)
|
||||
return static_cast<OpaqueColoredPoint2DWithSize *>(geometry->vertexData());
|
||||
}
|
||||
@@ -358,10 +358,10 @@ static qint64 endTime(const TimelineModel *model, const TimelineRenderState *par
|
||||
const QSGGeometry::AttributeSet &OpaqueColoredPoint2DWithSize::attributes()
|
||||
{
|
||||
static QSGGeometry::Attribute data[] = {
|
||||
QSGGeometry::Attribute::create(0, 2, GL_FLOAT, true),
|
||||
QSGGeometry::Attribute::create(1, 2, GL_FLOAT),
|
||||
QSGGeometry::Attribute::create(2, 1, GL_FLOAT),
|
||||
QSGGeometry::Attribute::create(3, 4, GL_UNSIGNED_BYTE)
|
||||
QSGGeometry::Attribute::create(0, 2, QSGGeometry::FloatType, true),
|
||||
QSGGeometry::Attribute::create(1, 2, QSGGeometry::FloatType),
|
||||
QSGGeometry::Attribute::create(2, 1, QSGGeometry::FloatType),
|
||||
QSGGeometry::Attribute::create(3, 4, QSGGeometry::UnsignedByteType)
|
||||
};
|
||||
static QSGGeometry::AttributeSet attrs = {
|
||||
4,
|
||||
@@ -436,12 +436,19 @@ class TimelineItemsMaterialShader : public QSGMaterialShader
|
||||
public:
|
||||
TimelineItemsMaterialShader();
|
||||
|
||||
#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;
|
||||
int m_scale_id;
|
||||
@@ -453,10 +460,16 @@ private:
|
||||
TimelineItemsMaterialShader::TimelineItemsMaterialShader()
|
||||
: QSGMaterialShader()
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/tracing/timelineitems.vert"));
|
||||
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/tracing/timelineitems.frag"));
|
||||
#else // < Qt 6
|
||||
setShaderFileName(VertexStage, ":/tracing/timelineitems.vert");
|
||||
setShaderFileName(FragmentStage, ":/tracing/timelineitems.frag");
|
||||
#endif // < Qt 6
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
void TimelineItemsMaterialShader::updateState(const RenderState &state, QSGMaterial *newMaterial,
|
||||
QSGMaterial *)
|
||||
{
|
||||
@@ -469,7 +482,19 @@ void TimelineItemsMaterialShader::updateState(const RenderState &state, QSGMater
|
||||
program()->setUniformValue(m_z_range_id, GLfloat(1.0));
|
||||
}
|
||||
}
|
||||
#else // < Qt 6
|
||||
bool TimelineItemsMaterialShader::updateUniformData(RenderState &state,
|
||||
QSGMaterial *newMaterial, QSGMaterial *)
|
||||
{
|
||||
// TODO: Make this work
|
||||
if (state.isMatrixDirty()) {
|
||||
TimelineItemsMaterial *material = static_cast<TimelineItemsMaterial *>(newMaterial);
|
||||
}
|
||||
return state.isMatrixDirty();
|
||||
}
|
||||
#endif // < Qt 6
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
char const *const *TimelineItemsMaterialShader::attributeNames() const
|
||||
{
|
||||
static const char *const attr[] = {"vertexCoord", "rectSize", "selectionId", "vertexColor", nullptr};
|
||||
@@ -484,7 +509,7 @@ void TimelineItemsMaterialShader::initialize()
|
||||
m_selected_item_id = program()->uniformLocation("selectedItem");
|
||||
m_z_range_id = program()->uniformLocation("_qt_zRange");
|
||||
}
|
||||
|
||||
#endif // < Qt 6
|
||||
|
||||
TimelineItemsMaterial::TimelineItemsMaterial() : m_selectedItem(-1)
|
||||
{
|
||||
@@ -527,10 +552,19 @@ QSGMaterialType *TimelineItemsMaterial::type() const
|
||||
return &type;
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QSGMaterialShader *TimelineItemsMaterial::createShader() const
|
||||
{
|
||||
return new TimelineItemsMaterialShader;
|
||||
}
|
||||
#else // < Qt 6
|
||||
QSGMaterialShader *TimelineItemsMaterial::createShader(
|
||||
QSGRendererInterface::RenderMode renderMode) const
|
||||
{
|
||||
Q_UNUSED(renderMode);
|
||||
return new TimelineItemsMaterialShader;
|
||||
}
|
||||
#endif // < Qt 6
|
||||
|
||||
TimelineItemsRenderPassState::TimelineItemsRenderPassState(const TimelineModel *model) :
|
||||
m_indexFrom(std::numeric_limits<int>::max()), m_indexTo(-1)
|
||||
|
||||
@@ -45,7 +45,11 @@ public:
|
||||
void setSelectionColor(QColor selectionColor);
|
||||
|
||||
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
|
||||
|
||||
private:
|
||||
QVector2D m_scale;
|
||||
|
||||
@@ -40,7 +40,11 @@ class NotesMaterial : public QSGMaterial
|
||||
{
|
||||
public:
|
||||
QSGMaterialType *type() const final;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QSGMaterialShader *createShader() const final;
|
||||
#else // < Qt 6
|
||||
QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const final;
|
||||
#endif // < Qt 6
|
||||
};
|
||||
|
||||
struct NotesGeometry
|
||||
@@ -79,8 +83,8 @@ private:
|
||||
const QSGGeometry::AttributeSet &NotesGeometry::point2DWithDistanceFromTop()
|
||||
{
|
||||
static QSGGeometry::Attribute data[] = {
|
||||
QSGGeometry::Attribute::create(0, 2, GL_FLOAT, true),
|
||||
QSGGeometry::Attribute::create(1, 1, GL_FLOAT),
|
||||
QSGGeometry::Attribute::create(0, 2, QSGGeometry::FloatType, true),
|
||||
QSGGeometry::Attribute::create(1, 1, QSGGeometry::FloatType),
|
||||
};
|
||||
static QSGGeometry::AttributeSet attrs = {
|
||||
2,
|
||||
@@ -197,7 +201,7 @@ QSGGeometry *NotesGeometry::createGeometry(QVector<int> &ids, const TimelineMode
|
||||
QSGGeometry *geometry = new QSGGeometry(point2DWithDistanceFromTop(),
|
||||
ids.count() * 2);
|
||||
Q_ASSERT(geometry->vertexData());
|
||||
geometry->setDrawingMode(GL_LINES);
|
||||
geometry->setDrawingMode(QSGGeometry::DrawLines);
|
||||
geometry->setLineWidth(3);
|
||||
Point2DWithDistanceFromTop *v =
|
||||
static_cast<Point2DWithDistanceFromTop *>(geometry->vertexData());
|
||||
@@ -220,12 +224,19 @@ class NotesMaterialShader : public QSGMaterialShader
|
||||
public:
|
||||
NotesMaterialShader();
|
||||
|
||||
#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 *newMaterial, QSGMaterial *oldMaterial) override;
|
||||
#endif // < Qt 6
|
||||
|
||||
private:
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
void initialize() override;
|
||||
#endif // < Qt 6
|
||||
|
||||
int m_matrix_id;
|
||||
int m_z_range_id;
|
||||
@@ -235,10 +246,16 @@ private:
|
||||
NotesMaterialShader::NotesMaterialShader()
|
||||
: QSGMaterialShader()
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
setShaderSourceFile(QOpenGLShader::Vertex, QStringLiteral(":/tracing/notes.vert"));
|
||||
setShaderSourceFile(QOpenGLShader::Fragment, QStringLiteral(":/tracing/notes.frag"));
|
||||
#else // < Qt 6
|
||||
setShaderFileName(VertexStage, ":/tracing/notes.vert");
|
||||
setShaderFileName(FragmentStage, ":/tracing/notes.frag");
|
||||
#endif // < Qt 6
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
void NotesMaterialShader::updateState(const RenderState &state, QSGMaterial *, QSGMaterial *)
|
||||
{
|
||||
if (state.isMatrixDirty()) {
|
||||
@@ -250,7 +267,16 @@ void NotesMaterialShader::updateState(const RenderState &state, QSGMaterial *, Q
|
||||
program()->setUniformValue(m_color_id, notesColor);
|
||||
}
|
||||
}
|
||||
#else // < Qt 6
|
||||
bool NotesMaterialShader::updateUniformData(QSGMaterialShader::RenderState &state, QSGMaterial *, QSGMaterial *)
|
||||
{
|
||||
if (state.isMatrixDirty()) {
|
||||
}
|
||||
return state.isMatrixDirty();
|
||||
}
|
||||
#endif // < Qt 6
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
char const *const *NotesMaterialShader::attributeNames() const
|
||||
{
|
||||
static const char *const attr[] = {"vertexCoord", "distanceFromTop", nullptr};
|
||||
@@ -263,6 +289,7 @@ void NotesMaterialShader::initialize()
|
||||
m_z_range_id = program()->uniformLocation("_qt_zRange");
|
||||
m_color_id = program()->uniformLocation("notesColor");
|
||||
}
|
||||
#endif // < Qt 6
|
||||
|
||||
QSGMaterialType *NotesMaterial::type() const
|
||||
{
|
||||
@@ -270,10 +297,18 @@ QSGMaterialType *NotesMaterial::type() const
|
||||
return &type;
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QSGMaterialShader *NotesMaterial::createShader() const
|
||||
{
|
||||
return new NotesMaterialShader;
|
||||
}
|
||||
#else // < Qt 6
|
||||
QSGMaterialShader *NotesMaterial::createShader(QSGRendererInterface::RenderMode renderMode) const
|
||||
{
|
||||
Q_UNUSED(renderMode);
|
||||
return new NotesMaterialShader;
|
||||
}
|
||||
#endif // < Qt 6
|
||||
|
||||
void Point2DWithDistanceFromTop::set(float nx, float ny, float nd)
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ QSGGeometryNode *createSelectionNode(QSGMaterial *material)
|
||||
selectionNode->setFlag(QSGNode::OwnsMaterial, false);
|
||||
QSGGeometry *geometry = new QSGGeometry(OpaqueColoredPoint2DWithSize::attributes(), 4);
|
||||
Q_ASSERT(geometry->vertexData());
|
||||
geometry->setDrawingMode(GL_TRIANGLE_STRIP);
|
||||
geometry->setDrawingMode(QSGGeometry::DrawTriangleStrip);
|
||||
OpaqueColoredPoint2DWithSize *v = OpaqueColoredPoint2DWithSize::fromVertexData(geometry);
|
||||
for (int i = 0; i < 4; ++i)
|
||||
v[i].set(0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
Reference in New Issue
Block a user