From 692fcc225fb227f5f0153b0e4f377032a8686a2c Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 7 Sep 2024 18:05:36 +0200 Subject: [PATCH] Add flame graph window. --- profiler/CMakeLists.txt | 1 + profiler/src/profiler/TracyView.cpp | 3 +++ profiler/src/profiler/TracyView.hpp | 2 ++ profiler/src/profiler/TracyView_FlameGraph.cpp | 14 ++++++++++++++ 4 files changed, 20 insertions(+) create mode 100644 profiler/src/profiler/TracyView_FlameGraph.cpp diff --git a/profiler/CMakeLists.txt b/profiler/CMakeLists.txt index 928aec3f..2993dee6 100644 --- a/profiler/CMakeLists.txt +++ b/profiler/CMakeLists.txt @@ -55,6 +55,7 @@ set(SERVER_FILES TracyView_ContextSwitch.cpp TracyView_CpuData.cpp TracyView_FindZone.cpp + TracyView_FlameGraph.cpp TracyView_FrameOverview.cpp TracyView_FrameTimeline.cpp TracyView_FrameTree.cpp diff --git a/profiler/src/profiler/TracyView.cpp b/profiler/src/profiler/TracyView.cpp index d12527ac..53135edb 100644 --- a/profiler/src/profiler/TracyView.cpp +++ b/profiler/src/profiler/TracyView.cpp @@ -880,6 +880,8 @@ bool View::DrawImpl() ImGui::SameLine(); ToggleButton( ICON_FA_ARROW_UP_WIDE_SHORT " Statistics", m_showStatistics ); ImGui::SameLine(); + ToggleButton( ICON_FA_FIRE_FLAME_CURVED " Flame", m_showFlameGraph ); + ImGui::SameLine(); ToggleButton( ICON_FA_MEMORY " Memory", m_memInfo.show ); ImGui::SameLine(); ToggleButton( ICON_FA_SCALE_BALANCED " Compare", m_compare.show ); @@ -1123,6 +1125,7 @@ bool View::DrawImpl() if( m_sampleParents.symAddr != 0 ) DrawSampleParents(); if( m_showRanges ) DrawRanges(); if( m_showWaitStacks ) DrawWaitStacks(); + if( m_showFlameGraph ) DrawFlameGraph(); if( m_setRangePopup.active ) { diff --git a/profiler/src/profiler/TracyView.hpp b/profiler/src/profiler/TracyView.hpp index 02526614..5b64cb10 100644 --- a/profiler/src/profiler/TracyView.hpp +++ b/profiler/src/profiler/TracyView.hpp @@ -271,6 +271,7 @@ private: void DrawRangeEntry( Range& range, const char* label, uint32_t color, const char* popupLabel, int id ); void DrawSourceTooltip( const char* filename, uint32_t line, int before = 3, int after = 3, bool separateTooltip = true ); void DrawWaitStacks(); + void DrawFlameGraph(); void ListMemData( std::vector& vec, const std::function& DrawAddress, int64_t startTime = -1, uint64_t pool = 0 ); @@ -488,6 +489,7 @@ private: bool m_showCpuDataWindow = false; bool m_showAnnotationList = false; bool m_showWaitStacks = false; + bool m_showFlameGraph = false; AccumulationMode m_statAccumulationMode = AccumulationMode::SelfOnly; bool m_statSampleTime = true; diff --git a/profiler/src/profiler/TracyView_FlameGraph.cpp b/profiler/src/profiler/TracyView_FlameGraph.cpp new file mode 100644 index 00000000..17212da4 --- /dev/null +++ b/profiler/src/profiler/TracyView_FlameGraph.cpp @@ -0,0 +1,14 @@ +#include "TracyView.hpp" + +namespace tracy +{ + +void View::DrawFlameGraph() +{ + const auto scale = GetScale(); + ImGui::SetNextWindowSize( ImVec2( 1400 * scale, 800 * scale ), ImGuiCond_FirstUseEver ); + ImGui::Begin( "Flame graph", &m_showFlameGraph, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse ); + ImGui::End(); +} + +}