Skip to content

Commit

Permalink
Add support for draw tables
Browse files Browse the repository at this point in the history
Previously draw tables would cause the tree to be malformed,
with PM4 packets of the draw table being added to the wrong
IB hierarchy
  • Loading branch information
Shan-Min Chao authored and shanminchao committed Jan 25, 2025
1 parent bf66de2 commit 7266861
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
30 changes: 24 additions & 6 deletions dive_core/command_hierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -797,15 +797,29 @@ bool CommandHierarchyCreator::OnIbStart(uint32_t submit_index,
{
// Create a "binprefix" or "bincommon" field node and set it as the parent
CommandHierarchy::AuxInfo aux_info = CommandHierarchy::AuxInfo::RegFieldNode(false);
uint64_t bin_node_index = AddNode(NodeType::kFieldNode, ib_string_stream.str(), aux_info);
uint64_t node_index = AddNode(NodeType::kFieldNode, ib_string_stream.str(), aux_info);

// Add it as child to packet_node
AddChild(CommandHierarchy::kEngineTopology, m_start_bin_node_index, bin_node_index);
AddChild(CommandHierarchy::kSubmitTopology, m_start_bin_node_index, bin_node_index);
AddChild(CommandHierarchy::kAllEventTopology, m_start_bin_node_index, bin_node_index);
AddChild(CommandHierarchy::kRgpTopology, m_start_bin_node_index, bin_node_index);
AddChild(CommandHierarchy::kEngineTopology, m_start_bin_node_index, node_index);
AddChild(CommandHierarchy::kSubmitTopology, m_start_bin_node_index, node_index);
AddChild(CommandHierarchy::kAllEventTopology, m_start_bin_node_index, node_index);
AddChild(CommandHierarchy::kRgpTopology, m_start_bin_node_index, node_index);

m_shared_node_ib_parent_stack[m_cur_ib_level] = bin_node_index;
m_shared_node_ib_parent_stack[m_cur_ib_level] = node_index;
}
else if (type == IbType::kFixedStrideDrawTable)
{
// Create a "fixed stride draw table" field node and set it as the parent
CommandHierarchy::AuxInfo aux_info = CommandHierarchy::AuxInfo::RegFieldNode(false);
uint64_t node_index = AddNode(NodeType::kFieldNode, ib_string_stream.str(), aux_info);

// Add it as child to packet_node
AddChild(CommandHierarchy::kEngineTopology, m_draw_table_node_index, node_index);
AddChild(CommandHierarchy::kSubmitTopology, m_draw_table_node_index, node_index);
AddChild(CommandHierarchy::kAllEventTopology, m_draw_table_node_index, node_index);
AddChild(CommandHierarchy::kRgpTopology, m_draw_table_node_index, node_index);

m_shared_node_ib_parent_stack[m_cur_ib_level] = node_index;
}

// Create the ib node
Expand Down Expand Up @@ -1026,6 +1040,10 @@ bool CommandHierarchyCreator::OnPacket(const IMemoryManager &mem_manager,
{
m_start_bin_node_index = UINT64_MAX;
}
else if (opcode == CP_FIXED_STRIDE_DRAW_TABLE)
{
m_draw_table_node_index = packet_node_index;
}
else if (opcode == CP_SET_MARKER)
{
PM4_CP_SET_MARKER packet;
Expand Down
3 changes: 3 additions & 0 deletions dive_core/command_hierarchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,9 @@ class CommandHierarchyCreator : public IEmulateCallbacks
// Cache the most recent cp_start_bin, to be appended to later with prefix and common packets
uint64_t m_start_bin_node_index = UINT64_MAX;

// Cache the most recent fixed stride draw table, to be appended to later
uint64_t m_draw_table_node_index = UINT64_MAX;

uint32_t m_num_events = 0; // Number of events so far

bool m_new_event_start = true;
Expand Down

0 comments on commit 7266861

Please sign in to comment.