Skip to content

Commit

Permalink
Timeline layer JSON preserves debug label stack (#40)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
solidpixel authored Jan 8, 2025
1 parent db22db2 commit 3d4e02a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 37 deletions.
9 changes: 1 addition & 8 deletions lglpy/timeline/data/raw_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,7 @@ def __init__(self, frame: int, metadata: JSONType):
self.frame = frame
self.tag_id = int(metadata['tid'])

self.label_stack = None
label_stack = metadata.get('label', None)
if label_stack:
self.label_stack = label_stack.split('|')
self.label_stack = metadata.get('label', None)

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

# Extract render stages events from Perfetto data
for packet in protoc.packet:

# Clock sync packet so update clock drift information
if packet.HasField('clock_snapshot'):
config.add_clock_sync_data(packet)
Expand Down
19 changes: 10 additions & 9 deletions source_common/trackers/layer_command_stream.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: MIT
* ----------------------------------------------------------------------------
* Copyright (c) 2024 Arm Limited
* Copyright (c) 2024-2025 Arm Limited
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
Expand Down Expand Up @@ -75,7 +75,7 @@ LCSRenderPass::LCSRenderPass(

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

/* See header for details. */
std::string LCSRenderPass::getContinuationMetadata(
const std::string* debugLabel,
const std::vector<std::string>* debugLabel,
uint64_t tagIDContinuation) const
{
json metadata = {
Expand All @@ -159,7 +159,7 @@ std::string LCSRenderPass::getContinuationMetadata(

/* See header for details. */
std::string LCSRenderPass::getMetadata(
const std::string* debugLabel,
const std::vector<std::string>* debugLabel,
uint64_t tagIDContinuation) const
{
if (tagID)
Expand Down Expand Up @@ -189,7 +189,7 @@ LCSDispatch::LCSDispatch(

/* See header for details. */
std::string LCSDispatch::getMetadata(
const std::string* debugLabel,
const std::vector<std::string>* debugLabel,
uint64_t tagIDContinuation
) const {
UNUSED(tagIDContinuation);
Expand Down Expand Up @@ -227,7 +227,7 @@ LCSTraceRays::LCSTraceRays(

/* See header for details. */
std::string LCSTraceRays::getMetadata(
const std::string* debugLabel,
const std::vector<std::string>* debugLabel,
uint64_t tagIDContinuation
) const {
UNUSED(tagIDContinuation);
Expand Down Expand Up @@ -263,9 +263,10 @@ LCSImageTransfer::LCSImageTransfer(

/* See header for details. */
std::string LCSImageTransfer::getMetadata(
const std::string* debugLabel,
const std::vector<std::string>* debugLabel,
uint64_t tagIDContinuation
) const {
) const
{
UNUSED(tagIDContinuation);

json metadata = {
Expand Down Expand Up @@ -298,7 +299,7 @@ LCSBufferTransfer::LCSBufferTransfer(

/* See header for details. */
std::string LCSBufferTransfer::getMetadata(
const std::string* debugLabel,
const std::vector<std::string>* debugLabel,
uint64_t tagIDContinuation
) const {
UNUSED(tagIDContinuation);
Expand Down
28 changes: 14 additions & 14 deletions source_common/trackers/layer_command_stream.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: MIT
* ----------------------------------------------------------------------------
* Copyright (c) 2022-2024 Arm Limited
* Copyright (c) 2024-2025 Arm Limited
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
Expand All @@ -28,7 +28,7 @@
* The declaration of a replayable layer command stream.
*
* Role summary
* ============s
* ============
*
* These trackers are used to monitor to submission of workloads inside a
* command buffers in a way that they can be iterated by a queue tracker at
Expand Down Expand Up @@ -87,11 +87,11 @@ class LCSWorkload
/**
* @brief Get the metadata for this workload
*
* @param debugLabel The debug label state of the VkQueue at submit time.
* @param debugLabel The debug label stack for the VkQueue at submit time.
* @param tagIDContinuation The ID of the workload if this is a continuation of it.
*/
virtual std::string getMetadata(
const std::string* debugLabel=nullptr,
const std::vector<std::string>* debugLabel=nullptr,
uint64_t tagIDContinuation=0) const = 0;

/**
Expand Down Expand Up @@ -180,26 +180,26 @@ class LCSRenderPass : public LCSWorkload

/* See base class for documentation. */
virtual std::string getMetadata(
const std::string* debugLabel=nullptr,
const std::vector<std::string>* debugLabel=nullptr,
uint64_t tagIDContinuation=0) const;

private:
/**
* @brief Get the metadata for this workload if beginning a new render pass.
*
* @param debugLabel The debug label state of the VkQueue at submit time.
* @param debugLabel The debug label stack of the VkQueue at submit time.
*/
std::string getBeginMetadata(
const std::string* debugLabel=nullptr) const;
const std::vector<std::string>* debugLabel=nullptr) const;

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

/**
Expand Down Expand Up @@ -270,7 +270,7 @@ class LCSDispatch : public LCSWorkload

/* See base class for documentation. */
virtual std::string getMetadata(
const std::string* debugLabel=nullptr,
const std::vector<std::string>* debugLabel=nullptr,
uint64_t tagIDContinuation=0) const;

private:
Expand Down Expand Up @@ -319,7 +319,7 @@ class LCSTraceRays : public LCSWorkload

/* See base class for documentation. */
virtual std::string getMetadata(
const std::string* debugLabel=nullptr,
const std::vector<std::string>* debugLabel=nullptr,
uint64_t tagIDContinuation=0) const;

private:
Expand Down Expand Up @@ -366,7 +366,7 @@ class LCSImageTransfer : public LCSWorkload

/* See base class for documentation. */
virtual std::string getMetadata(
const std::string* debugLabel=nullptr,
const std::vector<std::string>* debugLabel=nullptr,
uint64_t tagIDContinuation=0) const;

private:
Expand Down Expand Up @@ -409,7 +409,7 @@ class LCSBufferTransfer : public LCSWorkload

/* See base class for documentation. */
virtual std::string getMetadata(
const std::string* debugLabel=nullptr,
const std::vector<std::string>* debugLabel=nullptr,
uint64_t tagIDContinuation=0) const;

private:
Expand Down Expand Up @@ -448,7 +448,7 @@ class LCSMarker : public LCSWorkload

/* See base class for documentation. */
virtual std::string getMetadata(
const std::string* debugLabel=nullptr,
const std::vector<std::string>* debugLabel=nullptr,
uint64_t tagIDContinuation=0) const
{
UNUSED(debugLabel);
Expand Down
9 changes: 3 additions & 6 deletions source_common/trackers/queue.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SPDX-License-Identifier: MIT
* ----------------------------------------------------------------------------
* Copyright (c) 2022-2024 Arm Limited
* Copyright (c) 2022-2025 Arm Limited
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
Expand Down Expand Up @@ -61,14 +61,11 @@ void Queue::runSubmitCommandStream(
auto* workload = dynamic_cast<const LCSRenderPass*>(opData);
uint64_t tagID = workload->getTagID();

// Build the debug info
std::string log = joinString(debugStack, "|");

// Workload is a new render pass
if (tagID > 0)
{
assert(lastRenderPassTagID == 0);
callback(workload->getMetadata(&log));
callback(workload->getMetadata(&debugStack));

lastRenderPassTagID = 0;
if (workload->isSuspending())
Expand All @@ -94,7 +91,7 @@ void Queue::runSubmitCommandStream(
{
uint64_t tagID = opData->getTagID();
std::string log = joinString(debugStack, "|");
callback(opData->getMetadata(&log, tagID));
callback(opData->getMetadata(&debugStack, tagID));
}
}
}
Expand Down

0 comments on commit 3d4e02a

Please sign in to comment.