aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/tracing
diff options
context:
space:
mode:
authorAlessandro Portale <[email protected]>2021-07-13 19:23:39 +0200
committerAlessandro Portale <[email protected]>2021-08-11 08:04:32 +0000
commit84a017051693bab44a96f92fb4fd3f0c60264800 (patch)
tree3c10b67df854b712a39263c2ab1f4d6557b035e8 /src/libs/tracing
parentf95d6c6009ae2d2bd905daaa4d69edd9bbe7ae97 (diff)
Tracing/QmlProfiler: Prepare for porting of shaders to Qt 6
This change touches up the shader handling code in Tracing and QmlProfiler in order to pave the way for the pending porting of the shaders to Qt 6. - Use QSGGeometry::Attribute::createWithAttributeType instead of QSGGeometry::Attribute::create - Undefine some fields that are unused in Qt 6 - Add a couple of comments to document the relation between C++ variables and shader attributes - Extract some code into functions Change-Id: I0e7119484b6190a415a5c2d2a0bbd6465088cf19 Reviewed-by: Henning Gründl <[email protected]>
Diffstat (limited to 'src/libs/tracing')
-rw-r--r--src/libs/tracing/timelineitemsrenderpass.cpp33
-rw-r--r--src/libs/tracing/timelineitemsrenderpass.h8
-rw-r--r--src/libs/tracing/timelinenotesrenderpass.cpp46
3 files changed, 48 insertions, 39 deletions
diff --git a/src/libs/tracing/timelineitemsrenderpass.cpp b/src/libs/tracing/timelineitemsrenderpass.cpp
index 9911382240a..344810d81d4 100644
--- a/src/libs/tracing/timelineitemsrenderpass.cpp
+++ b/src/libs/tracing/timelineitemsrenderpass.cpp
@@ -357,14 +357,22 @@ static qint64 endTime(const TimelineModel *model, const TimelineRenderState *par
const QSGGeometry::AttributeSet &OpaqueColoredPoint2DWithSize::attributes()
{
- static QSGGeometry::Attribute data[] = {
- 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 const QSGGeometry::Attribute data[] = {
+ // vec4 vertexCoord
+ QSGGeometry::Attribute::createWithAttributeType(0, 2, QSGGeometry::FloatType,
+ QSGGeometry::PositionAttribute),
+ // vec2 rectSize
+ QSGGeometry::Attribute::createWithAttributeType(1, 2, QSGGeometry::FloatType,
+ QSGGeometry::UnknownAttribute),
+ // float selectionId
+ QSGGeometry::Attribute::createWithAttributeType(2, 1, QSGGeometry::FloatType,
+ QSGGeometry::UnknownAttribute),
+ // vec4 vertexColor
+ QSGGeometry::Attribute::createWithAttributeType(3, 4, QSGGeometry::UnsignedByteType,
+ QSGGeometry::ColorAttribute),
};
- static QSGGeometry::AttributeSet attrs = {
- 4,
+ static const QSGGeometry::AttributeSet attrs = {
+ sizeof(data) / sizeof(data[0]),
sizeof(OpaqueColoredPoint2DWithSize),
data
};
@@ -448,13 +456,13 @@ public:
private:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void initialize() override;
-#endif // < Qt 6
int m_matrix_id;
int m_scale_id;
int m_selection_color_id;
int m_selected_item_id;
int m_z_range_id;
+#endif // < Qt 6
};
TimelineItemsMaterialShader::TimelineItemsMaterialShader()
@@ -556,17 +564,12 @@ QSGMaterialType *TimelineItemsMaterial::type() const
#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
+QSGMaterialShader *TimelineItemsMaterial::createShader(QSGRendererInterface::RenderMode) const
+#endif // < Qt 6
{
- Q_UNUSED(renderMode);
return new TimelineItemsMaterialShader;
}
-#endif // < Qt 6
TimelineItemsRenderPassState::TimelineItemsRenderPassState(const TimelineModel *model) :
m_indexFrom(std::numeric_limits<int>::max()), m_indexTo(-1)
diff --git a/src/libs/tracing/timelineitemsrenderpass.h b/src/libs/tracing/timelineitemsrenderpass.h
index 807f0ed5518..9d52be9ac71 100644
--- a/src/libs/tracing/timelineitemsrenderpass.h
+++ b/src/libs/tracing/timelineitemsrenderpass.h
@@ -48,7 +48,7 @@ public:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QSGMaterialShader *createShader() const override;
#else
- QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
+ QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const override;
#endif // < Qt 6
private:
@@ -83,8 +83,10 @@ public:
static OpaqueColoredPoint2DWithSize *fromVertexData(QSGGeometry *geometry);
private:
- float x, y, w, h, id;
- unsigned char r, g, b, a;
+ float x, y; // vec4 vertexCoord
+ float w, h; // vec2 rectSize
+ float id; // float selectionId
+ unsigned char r, g, b, a; // vec4 vertexColor
void setCommon(const OpaqueColoredPoint2DWithSize *master);
void setLeft(const OpaqueColoredPoint2DWithSize *master);
diff --git a/src/libs/tracing/timelinenotesrenderpass.cpp b/src/libs/tracing/timelinenotesrenderpass.cpp
index 90a10ca4602..e71366e74eb 100644
--- a/src/libs/tracing/timelinenotesrenderpass.cpp
+++ b/src/libs/tracing/timelinenotesrenderpass.cpp
@@ -32,7 +32,8 @@
namespace Timeline {
struct Point2DWithDistanceFromTop {
- float x, y, d;
+ float x, y; // vec4 vertexCoord
+ float d; // float distanceFromTop
void set(float nx, float ny, float nd);
};
@@ -43,7 +44,7 @@ public:
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QSGMaterialShader *createShader() const final;
#else // < Qt 6
- QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const final;
+ QSGMaterialShader *createShader(QSGRendererInterface::RenderMode) const final;
#endif // < Qt 6
};
@@ -82,12 +83,16 @@ private:
const QSGGeometry::AttributeSet &NotesGeometry::point2DWithDistanceFromTop()
{
- static QSGGeometry::Attribute data[] = {
- QSGGeometry::Attribute::create(0, 2, QSGGeometry::FloatType, true),
- QSGGeometry::Attribute::create(1, 1, QSGGeometry::FloatType),
+ static const QSGGeometry::Attribute data[] = {
+ // vec4 vertexCoord
+ QSGGeometry::Attribute::createWithAttributeType(0, 2, QSGGeometry::FloatType,
+ QSGGeometry::PositionAttribute),
+ // float distanceFromTop
+ QSGGeometry::Attribute::createWithAttributeType(1, 1, QSGGeometry::FloatType,
+ QSGGeometry::UnknownAttribute),
};
- static QSGGeometry::AttributeSet attrs = {
- 2,
+ static const QSGGeometry::AttributeSet attrs = {
+ sizeof(data) / sizeof(data[0]),
sizeof(Point2DWithDistanceFromTop),
data
};
@@ -229,18 +234,17 @@ public:
QSGMaterial *oldEffect) override;
char const *const *attributeNames() const override;
#else // < Qt 6
- bool updateUniformData(RenderState &state,
- QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override;
+ bool updateUniformData(RenderState &state, QSGMaterial *, QSGMaterial *) 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;
int m_color_id;
+#endif // < Qt 6
};
NotesMaterialShader::NotesMaterialShader()
@@ -255,20 +259,24 @@ NotesMaterialShader::NotesMaterialShader()
#endif // < Qt 6
}
+static QColor notesColor()
+{
+ return Utils::creatorTheme()
+ ? Utils::creatorTheme()->color(Utils::Theme::Timeline_HighlightColor)
+ : QColor(255, 165, 0);
+}
+
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void NotesMaterialShader::updateState(const RenderState &state, QSGMaterial *, QSGMaterial *)
{
if (state.isMatrixDirty()) {
program()->setUniformValue(m_matrix_id, state.combinedMatrix());
program()->setUniformValue(m_z_range_id, GLfloat(1.0));
- const QColor notesColor = Utils::creatorTheme()
- ? Utils::creatorTheme()->color(Utils::Theme::Timeline_HighlightColor)
- : QColor(255, 165, 0);
- program()->setUniformValue(m_color_id, notesColor);
+ program()->setUniformValue(m_color_id, notesColor());
}
}
#else // < Qt 6
-bool NotesMaterialShader::updateUniformData(QSGMaterialShader::RenderState &state, QSGMaterial *, QSGMaterial *)
+bool NotesMaterialShader::updateUniformData(RenderState &state, QSGMaterial *, QSGMaterial *)
{
if (state.isMatrixDirty()) {
}
@@ -299,16 +307,12 @@ QSGMaterialType *NotesMaterial::type() const
#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
+QSGMaterialShader *NotesMaterial::createShader(QSGRendererInterface::RenderMode) const
+#endif // < Qt 6
{
- Q_UNUSED(renderMode);
return new NotesMaterialShader;
}
-#endif // < Qt 6
void Point2DWithDistanceFromTop::set(float nx, float ny, float nd)
{