Tree node.
Instance a Tree.
Write scene data to tree.
0: NoSort, 1: Ascending, 2: Descending.
Function of quick sort to PipelineResult.
Function of sort whole tree.
Function of draw whole tree.
Tree node.
Instance a Tree.
Write scene data to tree.
0: NoSort, 1: Ascending, 2: Descending.
Function of quick sort to PipelineResult.
Function of sort whole tree.
Function of draw whole tree.
172 {
174
178 struct TimestampResult
179 {
180 TimestampQuerier::Result result;
181 std::string name;
182 };
183
188 totalResult.
GetData().name =
"Scene ( Viewport 0 )";
189
193 {
195
197
198 const auto rendererResult = totalResult.
AddChild();
199 rendererResult->
GetData().name = rendererName;
200
201 renderer->IterStatistics([&](const std::string& subPassName, const std::shared_ptr<RenderPassStatistics>& statistics) {
202
203 const auto subPassResult = rendererResult->AddChild();
204 subPassResult->GetData().name = subPassName;
205
207
208 TimestampQuerier::Result* res = static_cast<TimestampQuerier::Result*>(result.get());
209 if (res->valid)
210 {
211 subPassResult->GetData().result = *res;
212
213 rendererResult->GetData().result.Combine(res);
214 rendererResult->GetData().result.valid = true;
215
216 totalResult.GetData().result.Combine(res);
217 totalResult.GetData().result.valid = true;
218 }
219 });
220
221 return false;
222 });
223
224 return false;
225 });
226 }
227
228 {
230
231 static ImGuiTableFlags flags = ImGuiTableFlags_BordersV | ImGuiTableFlags_BordersOuterH | ImGuiTableFlags_Resizable | ImGuiTableFlags_NoBordersInBody |
232 ImGuiTableFlags_Sortable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_SortMulti | ImGuiTableFlags_Hideable |
233 ImGuiTableFlags_ScrollY | ImGuiTableFlags_SortTristate;
234 static ImGuiTreeNodeFlags tree_node_flags = ImGuiTreeNodeFlags_SpanAllColumns;
235
239 static int sortState = 0;
240
244 static auto SortTimestampTreeMethod = [](const void* lhs, const void* rhs) -> int {
245
246 const auto l = static_cast<const std::unique_ptr<scl::tree<TimestampResult>>*>(lhs);
247 const auto r = static_cast<const std::unique_ptr<scl::tree<TimestampResult>>*>(rhs);
248
249 ImGuiTableSortSpecs* sort_specs = ImGui::TableGetSortSpecs();
250 if (sortState == ImGuiSortDirection_Ascending)
251 {
252 return ((*l)->GetData().result.timeStamp - (*r)->GetData().result.timeStamp) * 1000;
253 }
254 else
255 {
256 return ((*r)->GetData().result.timeStamp - (*l)->GetData().result.timeStamp) * 1000;
257 }
258 };
259
264
265 if (sortState == 0) return;
266
267 qsort((void*)node->GetChilds().data(), (size_t)node->GetChilds().size(), sizeof(node->GetChilds()[0]), SortTimestampTreeMethod);
268
269 for (auto& child : node->GetChilds())
270 {
271 SortTimestampTree(child.get());
272 }
273 };
274
279
280 if (!node->
GetData().result.valid)
return;
281
282 ImGui::TableNextRow();
283 ImGui::TableNextColumn();
284
285 std::stringstream space;
286 for (uint32_t i = 0; i < depth; i++)
287 {
288 space << " ";
289 }
290
291 ImGui::Text(space.str().c_str());
292 ImGui::SameLine();
293
294 bool hasChild = node->
GetChilds().size() > 0;
295 if (hasChild)
296 {
297 bool open = ImGui::TreeNodeEx(node->
GetData().name.c_str(), tree_node_flags);
298 ImGui::TableNextColumn();
299
300 ImGui::PushStyleColor(ImGuiCol_PlotHistogram, ImVec4(0.0f, 0.8f, 0.0f, 1.0f));
301 ImGui::ProgressBar(root->GetData().result.timeStamp > 0 ? (node->
GetData().result.timeStamp / root->GetData().result.timeStamp) : 0.0f, ImVec2(-FLT_MIN, 2.0f),
"##");
302 ImGui::PopStyleColor();
303 ImGui::SameLine(0.05f);
304 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.8f, 0.8f, 0.8f, 1.0f));
305 ImGui::Text(
"%.2f ms", node->
GetData().result.timeStamp);
306 ImGui::PopStyleColor();
307 if (open)
308 {
309 for (auto& child : node->GetChilds())
310 {
311 DrawTimestampTree(child.get(), depth + 1, root);
312 }
313 ImGui::TreePop();
314 }
315 }
316 else
317 {
318 ImGui::TreeNodeEx(node->
GetData().name.c_str(), tree_node_flags | ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen);
319 ImGui::TableNextColumn();
320
321 ImGui::PushStyleColor(ImGuiCol_PlotHistogram, ImVec4(0.0f, 0.8f, 0.0f, 1.0f));
322 ImGui::ProgressBar(root->GetData().result.timeStamp > 0 ? (node->
GetData().result.timeStamp / root->GetData().result.timeStamp) : 0.0f, ImVec2(-FLT_MIN, 2.0f),
"##");
323 ImGui::PopStyleColor();
324 ImGui::SameLine(0.05f);
325 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.8f, 0.8f, 0.8f, 1.0f));
326 ImGui::Text(
"%.2f ms", node->
GetData().result.timeStamp);
327 ImGui::PopStyleColor();
328 }
329 };
330
331 ImGui::PushStyleVar(ImGuiStyleVar_IndentSpacing, 0.0f);
332 ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0.196f, 0.204f, 0.2f, 1.0f));
333 ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(0.164f, 0.18f, 0.184f, 1.0f));
334 ImGui::PushStyleColor(ImGuiCol_HeaderActive, ImVec4(0.164f, 0.18f, 0.184f, 1.0f));
335 ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.196f, 0.204f, 0.2f, 1.0f));
336
337 if (ImGui::BeginTable("timestampTree", 2, flags))
338 {
339
340 ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_NoHide);
341 ImGui::TableSetupColumn(
"TimeCost", ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_PreferSortDescending,
ImGuiH::GetLineItemSize().x * 3.0f);
342 ImGui::TableHeadersRow();
343
344
345 if (ImGuiTableSortSpecs* sort_specs = ImGui::TableGetSortSpecs())
346 {
347
348 if (sort_specs->SpecsDirty)
349 {
350 sortState = 0;
351
352
353 if (sort_specs->SpecsCount > 0)
354 {
355 sortState = sort_specs->Specs->SortDirection;
356 }
357
358 sort_specs->SpecsDirty = false;
359 }
360 }
361
362 SortTimestampTree(&totalResult);
363 DrawTimestampTree(&totalResult, 0, &totalResult);
364
365 ImGui::EndTable();
366 }
367 ImGui::PopStyleColor(4);
368 ImGui::PopStyleVar();
369 }
370 }
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
static ImVec2 GetLineItemSize()
Get Line Width's Square Size.
StatisticsBits
Statistics types.
static void IterRenderer(T &&fn)
Iter all Renderer.
const std::vector< std::unique_ptr< tree > > & GetChilds() const
Get all this node children.
tree * AddChild(Args &&... args)
Add a child to this tree.