Skip to content

Commit 25694b6

Browse files
committed
QmlDebug: Support QtQuick3D profiler events
The client definitions should provide the same event types as the service definitions. Adapt the code for reading and writing the events from Qt Creator. Change-Id: Ib714304a5b56f7d1bd9c1f53656554b9705f630b Reviewed-by: Sami Shalayel <[email protected]> Reviewed-by: Ulf Hermann <[email protected]> Reviewed-by: Antti Määttä <[email protected]>
1 parent fbcc2a2 commit 25694b6

File tree

5 files changed

+53
-2
lines changed

5 files changed

+53
-2
lines changed

src/qmldebug/qqmlprofilerclientdefinitions_p.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ enum Message {
3131
SceneGraphFrame,
3232
MemoryAllocation,
3333
DebugMessage,
34+
Quick3DFrame,
3435

3536
MaximumMessage
3637
};
@@ -91,6 +92,22 @@ enum MemoryType {
9192
SmallItem
9293
};
9394

95+
enum Quick3DFrameType {
96+
Quick3DRenderFrame, // Render Thread
97+
Quick3DSynchronizeFrame,
98+
Quick3DPrepareFrame,
99+
Quick3DMeshLoad,
100+
Quick3DCustomMeshLoad,
101+
Quick3DTextureLoad,
102+
Quick3DGenerateShader,
103+
Quick3DLoadShader,
104+
Quick3DParticleUpdate, // GUI Thread
105+
Quick3DRenderCall, // Render Thread
106+
Quick3DRenderPass, // Render Thread
107+
Quick3DEventData, // N/A
108+
MaximumQuick3DFrameType,
109+
};
110+
94111
enum ProfileFeature {
95112
ProfileJavaScript,
96113
ProfileMemory,
@@ -104,6 +121,7 @@ enum ProfileFeature {
104121
ProfileHandlingSignal,
105122
ProfileInputEvents,
106123
ProfileDebugMessages,
124+
ProfileQuick3D,
107125

108126
MaximumProfileFeature
109127
};

src/qmldebug/qqmlprofilereventtype.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ QDataStream &operator>>(QDataStream &stream, QQmlProfilerEventType &type)
1717
>> type.m_detailType;
1818
type.m_message = static_cast<Message>(message);
1919
type.m_rangeType = static_cast<RangeType>(rangeType);
20+
21+
// If the trace is from before Quick3D events were introduced, the value that's now
22+
// Quick3DFrame is MaximumMessage and denoted a range. Check for that.
23+
if (type.m_message == Quick3DFrame && type.m_rangeType != MaximumRangeType)
24+
type.m_message = MaximumMessage;
25+
2026
return stream;
2127
}
2228

@@ -49,6 +55,8 @@ ProfileFeature QQmlProfilerEventType::feature() const
4955
return ProfileMemory;
5056
case DebugMessage:
5157
return ProfileDebugMessages;
58+
case Quick3DFrame:
59+
return ProfileQuick3D;
5260
default:
5361
break;
5462
}

src/qmldebug/qqmlprofilerqtdwriter.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ static const char *MESSAGE_STRINGS[] = {
4242
"PixmapCache",
4343
"SceneGraph",
4444
"MemoryAllocation",
45-
"DebugMessage"
45+
"DebugMessage",
46+
"Quick3D", // Not "Quick3DFrame" unfortunately. See precedence in Qt Creator.
4647
};
4748

4849
Q_STATIC_ASSERT(sizeof(MESSAGE_STRINGS) == MaximumMessage * sizeof(const char *));
@@ -197,6 +198,9 @@ void QQmlProfilerQtdWriter::addEventType(const QQmlProfilerEventType &type)
197198
case DebugMessage:
198199
displayName = QString::fromLatin1("DebugMessage:%1").arg(type.detailType());
199200
break;
201+
case Quick3DFrame:
202+
displayName = QString::fromLatin1("Quick3DFrame:%1").arg(type.detailType());
203+
break;
200204
case MaximumMessage: {
201205
const QQmlProfilerEventLocation eventLocation = type.location();
202206
// generate hash

src/qmldebug/qqmlprofilertypedevent.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,26 @@ QDataStream &operator>>(QDataStream &stream, QQmlProfilerTypedEvent &event)
175175
event.event.setRangeStage(RangeEnd);
176176
break;
177177
}
178+
case Quick3DFrame: {
179+
QVarLengthArray<qint64> params;
180+
qint64 param = 0;
181+
QByteArray str;
182+
if (subtype == Quick3DEventData) {
183+
stream >> str;
184+
} else {
185+
while (!stream.atEnd()) {
186+
stream >> param;
187+
params.push_back(param);
188+
}
189+
}
190+
191+
event.type = QQmlProfilerEventType(
192+
static_cast<Message>(messageType),
193+
MaximumRangeType, subtype);
194+
event.type.setData(QString::fromUtf8(str));
195+
event.event.setNumbers<QVarLengthArray<qint64>, qint64>(params);
196+
break;
197+
}
178198
default:
179199
event.event.setNumbers<char>({});
180200
event.type = QQmlProfilerEventType(

tools/qmlprofiler/qmlprofilerapplication.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ static const char *features[] = {
4646
"binding",
4747
"handlingsignal",
4848
"inputevents",
49-
"debugmessages"
49+
"debugmessages",
50+
"quick3d",
5051
};
5152

5253
Q_STATIC_ASSERT(sizeof(features) == MaximumProfileFeature * sizeof(char *));

0 commit comments

Comments
 (0)