Skip to content

Commit 3d4e02a

Browse files
authored
Timeline layer JSON preserves debug label stack (#40)
This PR changes the timeline JSON protocol to emit the debug labels as a list representing the debug label stack, avoiding the need to implement delimiter character escape codes.
1 parent db22db2 commit 3d4e02a

File tree

4 files changed

+28
-37
lines changed

4 files changed

+28
-37
lines changed

lglpy/timeline/data/raw_trace.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,7 @@ def __init__(self, frame: int, metadata: JSONType):
200200
self.frame = frame
201201
self.tag_id = int(metadata['tid'])
202202

203-
self.label_stack = None
204-
label_stack = metadata.get('label', None)
205-
if label_stack:
206-
self.label_stack = label_stack.split('|')
203+
self.label_stack = metadata.get('label', None)
207204

208205
def get_perfetto_tag_id(self) -> str:
209206
'''
@@ -310,9 +307,6 @@ class MetadataBufferTransfer(MetadataWorkload):
310307
Parsed GPU Timeline layer payload for a transfer that writes a buffer.
311308
312309
Attributes:
313-
frame: The frame index in the application.
314-
tag_id: The unique workload tag ID to cross-reference with Perfetto.
315-
label_stack: Debug label stack, or None if no user labels.
316310
subtype: Specific type of the transfer.
317311
byte_count: Number of bytes written, or -1 if unknown.
318312
'''
@@ -641,7 +635,6 @@ def load_perfetto_from_file(
641635

642636
# Extract render stages events from Perfetto data
643637
for packet in protoc.packet:
644-
645638
# Clock sync packet so update clock drift information
646639
if packet.HasField('clock_snapshot'):
647640
config.add_clock_sync_data(packet)

source_common/trackers/layer_command_stream.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* SPDX-License-Identifier: MIT
33
* ----------------------------------------------------------------------------
4-
* Copyright (c) 2024 Arm Limited
4+
* Copyright (c) 2024-2025 Arm Limited
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to
@@ -75,7 +75,7 @@ LCSRenderPass::LCSRenderPass(
7575

7676
/* See header for details. */
7777
std::string LCSRenderPass::getBeginMetadata(
78-
const std::string* debugLabel) const
78+
const std::vector<std::string>* debugLabel) const
7979
{
8080
// Draw count for a multi-submit command buffer cannot be reliably
8181
// associated with a single tagID if restartable across command buffer
@@ -140,7 +140,7 @@ std::string LCSRenderPass::getBeginMetadata(
140140

141141
/* See header for details. */
142142
std::string LCSRenderPass::getContinuationMetadata(
143-
const std::string* debugLabel,
143+
const std::vector<std::string>* debugLabel,
144144
uint64_t tagIDContinuation) const
145145
{
146146
json metadata = {
@@ -159,7 +159,7 @@ std::string LCSRenderPass::getContinuationMetadata(
159159

160160
/* See header for details. */
161161
std::string LCSRenderPass::getMetadata(
162-
const std::string* debugLabel,
162+
const std::vector<std::string>* debugLabel,
163163
uint64_t tagIDContinuation) const
164164
{
165165
if (tagID)
@@ -189,7 +189,7 @@ LCSDispatch::LCSDispatch(
189189

190190
/* See header for details. */
191191
std::string LCSDispatch::getMetadata(
192-
const std::string* debugLabel,
192+
const std::vector<std::string>* debugLabel,
193193
uint64_t tagIDContinuation
194194
) const {
195195
UNUSED(tagIDContinuation);
@@ -227,7 +227,7 @@ LCSTraceRays::LCSTraceRays(
227227

228228
/* See header for details. */
229229
std::string LCSTraceRays::getMetadata(
230-
const std::string* debugLabel,
230+
const std::vector<std::string>* debugLabel,
231231
uint64_t tagIDContinuation
232232
) const {
233233
UNUSED(tagIDContinuation);
@@ -263,9 +263,10 @@ LCSImageTransfer::LCSImageTransfer(
263263

264264
/* See header for details. */
265265
std::string LCSImageTransfer::getMetadata(
266-
const std::string* debugLabel,
266+
const std::vector<std::string>* debugLabel,
267267
uint64_t tagIDContinuation
268-
) const {
268+
) const
269+
{
269270
UNUSED(tagIDContinuation);
270271

271272
json metadata = {
@@ -298,7 +299,7 @@ LCSBufferTransfer::LCSBufferTransfer(
298299

299300
/* See header for details. */
300301
std::string LCSBufferTransfer::getMetadata(
301-
const std::string* debugLabel,
302+
const std::vector<std::string>* debugLabel,
302303
uint64_t tagIDContinuation
303304
) const {
304305
UNUSED(tagIDContinuation);

source_common/trackers/layer_command_stream.hpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* SPDX-License-Identifier: MIT
33
* ----------------------------------------------------------------------------
4-
* Copyright (c) 2022-2024 Arm Limited
4+
* Copyright (c) 2024-2025 Arm Limited
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to
@@ -28,7 +28,7 @@
2828
* The declaration of a replayable layer command stream.
2929
*
3030
* Role summary
31-
* ============s
31+
* ============
3232
*
3333
* These trackers are used to monitor to submission of workloads inside a
3434
* command buffers in a way that they can be iterated by a queue tracker at
@@ -87,11 +87,11 @@ class LCSWorkload
8787
/**
8888
* @brief Get the metadata for this workload
8989
*
90-
* @param debugLabel The debug label state of the VkQueue at submit time.
90+
* @param debugLabel The debug label stack for the VkQueue at submit time.
9191
* @param tagIDContinuation The ID of the workload if this is a continuation of it.
9292
*/
9393
virtual std::string getMetadata(
94-
const std::string* debugLabel=nullptr,
94+
const std::vector<std::string>* debugLabel=nullptr,
9595
uint64_t tagIDContinuation=0) const = 0;
9696

9797
/**
@@ -180,26 +180,26 @@ class LCSRenderPass : public LCSWorkload
180180

181181
/* See base class for documentation. */
182182
virtual std::string getMetadata(
183-
const std::string* debugLabel=nullptr,
183+
const std::vector<std::string>* debugLabel=nullptr,
184184
uint64_t tagIDContinuation=0) const;
185185

186186
private:
187187
/**
188188
* @brief Get the metadata for this workload if beginning a new render pass.
189189
*
190-
* @param debugLabel The debug label state of the VkQueue at submit time.
190+
* @param debugLabel The debug label stack of the VkQueue at submit time.
191191
*/
192192
std::string getBeginMetadata(
193-
const std::string* debugLabel=nullptr) const;
193+
const std::vector<std::string>* debugLabel=nullptr) const;
194194

195195
/**
196196
* @brief Get the metadata for this workload if continuing an existing render pass.
197197
*
198-
* @param debugLabel The debug label state of the VkQueue at submit time.
198+
* @param debugLabel The debug label stack of the VkQueue at submit time.
199199
* @param tagIDContinuation The ID of the workload if this is a continuation of it.
200200
*/
201201
std::string getContinuationMetadata(
202-
const std::string* debugLabel=nullptr,
202+
const std::vector<std::string>* debugLabel=nullptr,
203203
uint64_t tagIDContinuation=0) const;
204204

205205
/**
@@ -270,7 +270,7 @@ class LCSDispatch : public LCSWorkload
270270

271271
/* See base class for documentation. */
272272
virtual std::string getMetadata(
273-
const std::string* debugLabel=nullptr,
273+
const std::vector<std::string>* debugLabel=nullptr,
274274
uint64_t tagIDContinuation=0) const;
275275

276276
private:
@@ -319,7 +319,7 @@ class LCSTraceRays : public LCSWorkload
319319

320320
/* See base class for documentation. */
321321
virtual std::string getMetadata(
322-
const std::string* debugLabel=nullptr,
322+
const std::vector<std::string>* debugLabel=nullptr,
323323
uint64_t tagIDContinuation=0) const;
324324

325325
private:
@@ -366,7 +366,7 @@ class LCSImageTransfer : public LCSWorkload
366366

367367
/* See base class for documentation. */
368368
virtual std::string getMetadata(
369-
const std::string* debugLabel=nullptr,
369+
const std::vector<std::string>* debugLabel=nullptr,
370370
uint64_t tagIDContinuation=0) const;
371371

372372
private:
@@ -409,7 +409,7 @@ class LCSBufferTransfer : public LCSWorkload
409409

410410
/* See base class for documentation. */
411411
virtual std::string getMetadata(
412-
const std::string* debugLabel=nullptr,
412+
const std::vector<std::string>* debugLabel=nullptr,
413413
uint64_t tagIDContinuation=0) const;
414414

415415
private:
@@ -448,7 +448,7 @@ class LCSMarker : public LCSWorkload
448448

449449
/* See base class for documentation. */
450450
virtual std::string getMetadata(
451-
const std::string* debugLabel=nullptr,
451+
const std::vector<std::string>* debugLabel=nullptr,
452452
uint64_t tagIDContinuation=0) const
453453
{
454454
UNUSED(debugLabel);

source_common/trackers/queue.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* SPDX-License-Identifier: MIT
33
* ----------------------------------------------------------------------------
4-
* Copyright (c) 2022-2024 Arm Limited
4+
* Copyright (c) 2022-2025 Arm Limited
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to
@@ -61,14 +61,11 @@ void Queue::runSubmitCommandStream(
6161
auto* workload = dynamic_cast<const LCSRenderPass*>(opData);
6262
uint64_t tagID = workload->getTagID();
6363

64-
// Build the debug info
65-
std::string log = joinString(debugStack, "|");
66-
6764
// Workload is a new render pass
6865
if (tagID > 0)
6966
{
7067
assert(lastRenderPassTagID == 0);
71-
callback(workload->getMetadata(&log));
68+
callback(workload->getMetadata(&debugStack));
7269

7370
lastRenderPassTagID = 0;
7471
if (workload->isSuspending())
@@ -94,7 +91,7 @@ void Queue::runSubmitCommandStream(
9491
{
9592
uint64_t tagID = opData->getTagID();
9693
std::string log = joinString(debugStack, "|");
97-
callback(opData->getMetadata(&log, tagID));
94+
callback(opData->getMetadata(&debugStack, tagID));
9895
}
9996
}
10097
}

0 commit comments

Comments
 (0)