Skip to content

Commit f503351

Browse files
committed
Removes mutable member
1 parent b025a1e commit f503351

File tree

3 files changed

+95
-35
lines changed

3 files changed

+95
-35
lines changed

ui/dive_tree_view.cpp

Lines changed: 89 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,101 @@ void DiveFilterModel::applyNewFilterMode(FilterMode new_mode)
5353
if (m_filter_mode == new_mode)
5454
return;
5555

56-
// Clear the collections of draw call indices
57-
m_pm4_draw_call_indices.clear();
58-
5956
beginResetModel();
6057
m_filter_mode = new_mode;
58+
59+
// Only collect the draw call indices if gfxr and pm4 data are present.
60+
if (!m_gfxr_draw_call_indices.empty())
61+
{
62+
// Clear the vector of pm4 draw call indices.
63+
m_pm4_draw_call_indices.clear();
64+
// Recollect pm4 draw call indices when new filter is applied.
65+
CollectPm4DrawCallIndices(QModelIndex());
66+
}
6167
// invalidateFilter() doesn't invalidate all nodes
6268
// begin/endResetModel() will cause a full re-evaluation and rebuild of the proxy's internal
6369
// mapping.
6470
endResetModel();
6571
}
6672

73+
bool DiveFilterModel::IncludeIndex(uint64_t node_index) const
74+
{
75+
Dive::CommandHierarchy::FilterListType
76+
filter_list_type = Dive::CommandHierarchy::kFilterListTypeCount;
77+
78+
switch (m_filter_mode)
79+
{
80+
case kBinningPassOnly:
81+
filter_list_type = Dive::CommandHierarchy::kBinningPassOnly;
82+
break;
83+
case kFirstTilePassOnly:
84+
filter_list_type = Dive::CommandHierarchy::kFirstTilePassOnly;
85+
break;
86+
case kBinningAndFirstTilePass:
87+
filter_list_type = Dive::CommandHierarchy::kBinningAndFirstTilePass;
88+
break;
89+
default:
90+
DIVE_ASSERT(false);
91+
break;
92+
}
93+
94+
const auto &filter_exclude_indices = m_command_hierarchy.GetFilterExcludeIndices(
95+
filter_list_type);
96+
97+
// If the node index is in the exclude list, we exclude the index.
98+
if (filter_exclude_indices.find(node_index) != filter_exclude_indices.end())
99+
{
100+
return false;
101+
}
102+
103+
return true;
104+
}
105+
67106
void DiveFilterModel::SetMode(FilterMode filter_mode)
68107
{
69108
applyNewFilterMode(filter_mode);
70109
}
71110

111+
void DiveFilterModel::CollectPm4DrawCallIndices(const QModelIndex &parent_index)
112+
{
113+
if (!parent_index.isValid())
114+
{
115+
m_pm4_draw_call_indices.clear();
116+
}
117+
else
118+
{
119+
// Check if the current parent node is filtered out.
120+
uint64_t parent_node_index = (uint64_t)parent_index.internalPointer();
121+
122+
if (!IncludeIndex(parent_node_index))
123+
{
124+
return;
125+
}
126+
}
127+
128+
int row_count = sourceModel()->rowCount(parent_index);
129+
for (int row = 0; row < row_count; ++row)
130+
{
131+
QModelIndex index = sourceModel()->index(row, 0, parent_index);
132+
if (index.isValid())
133+
{
134+
uint64_t node_index = (uint64_t)index.internalPointer();
135+
Dive::NodeType node_type = m_command_hierarchy.GetNodeType(node_index);
136+
137+
if (node_type == Dive::NodeType::kDrawDispatchNode)
138+
{
139+
m_pm4_draw_call_indices.push_back(node_index);
140+
}
141+
142+
// Only recurse into children if the current node is not a Vulkan submit node.
143+
if (node_type != Dive::NodeType::kGfxrVulkanSubmitNode)
144+
{
145+
CollectPm4DrawCallIndices(index);
146+
}
147+
}
148+
}
149+
}
150+
72151
void DiveFilterModel::CollectGfxrDrawCallIndices(const QModelIndex &parent_index)
73152
{
74153
if (!parent_index.isValid())
@@ -101,6 +180,12 @@ void DiveFilterModel::CollectGfxrDrawCallIndices(const QModelIndex &parent_index
101180
}
102181
}
103182

183+
void DiveFilterModel::ClearDrawCallIndices()
184+
{
185+
m_pm4_draw_call_indices.clear();
186+
m_gfxr_draw_call_indices.clear();
187+
}
188+
104189
bool DiveFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
105190
{
106191
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
@@ -123,37 +208,7 @@ bool DiveFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceP
123208
return true;
124209
}
125210

126-
Dive::CommandHierarchy::FilterListType
127-
filter_list_type = Dive::CommandHierarchy::kFilterListTypeCount;
128-
switch (m_filter_mode)
129-
{
130-
case kBinningPassOnly:
131-
filter_list_type = Dive::CommandHierarchy::kBinningPassOnly;
132-
break;
133-
case kFirstTilePassOnly:
134-
filter_list_type = Dive::CommandHierarchy::kFirstTilePassOnly;
135-
break;
136-
case kBinningAndFirstTilePass:
137-
filter_list_type = Dive::CommandHierarchy::kBinningAndFirstTilePass;
138-
break;
139-
default:
140-
DIVE_ASSERT(false);
141-
break;
142-
}
143-
const auto &filter_exclude_indices = m_command_hierarchy.GetFilterExcludeIndices(
144-
filter_list_type);
145-
// If the node index is in the exclude list, we hide the row
146-
if (filter_exclude_indices.find(node_index) != filter_exclude_indices.end())
147-
{
148-
return false;
149-
}
150-
151-
if (current_node_type == Dive::NodeType::kDrawDispatchNode)
152-
{
153-
m_pm4_draw_call_indices.push_back(node_index);
154-
}
155-
156-
return true;
211+
return IncludeIndex(node_index);
157212
}
158213

159214
// =================================================================================================

ui/dive_tree_view.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ class DiveFilterModel : public QSortFilterProxyModel
5252
};
5353

5454
DiveFilterModel(const Dive::CommandHierarchy &command_hierarchy, QObject *parent = nullptr);
55+
bool IncludeIndex(uint64_t node_index) const;
5556
void SetMode(FilterMode filter_mode);
57+
void CollectPm4DrawCallIndices(const QModelIndex &parent_index = QModelIndex());
5658
void CollectGfxrDrawCallIndices(const QModelIndex &parent_index = QModelIndex());
57-
void AddPm4DrawCallIndex(uint64_t index) const;
59+
void ClearDrawCallIndices();
5860
const std::vector<uint64_t> &GetPm4DrawCallIndices() { return m_pm4_draw_call_indices; }
5961
const std::vector<uint64_t> &GetGfxrDrawCallIndices() { return m_gfxr_draw_call_indices; }
6062
public slots:

ui/main_window.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,9 @@ bool MainWindow::LoadFile(const std::string &file_name, bool is_temp_file)
904904
// Disconnect the signals for all of the possible tabs.
905905
DisconnectAllTabs();
906906

907+
// Clear vectors of draw call indices as they are only used for a correlated view.
908+
m_filter_model->ClearDrawCallIndices();
909+
907910
if (m_gfxr_capture_loaded)
908911
{
909912
file_loaded = LoadGfxrFile(file_name);

0 commit comments

Comments
 (0)