diff --git a/profiler/src/profiler/TracyView.hpp b/profiler/src/profiler/TracyView.hpp index 975b48ea..3c2a41a8 100644 --- a/profiler/src/profiler/TracyView.hpp +++ b/profiler/src/profiler/TracyView.hpp @@ -381,6 +381,7 @@ private: unordered_flat_map m_visibleMsgThread; unordered_flat_map m_waitStackThread; + unordered_flat_map m_flameGraphThread; unordered_flat_map m_gpuDrift; unordered_flat_map m_plotView; Vector m_threadOrder; @@ -406,6 +407,16 @@ private: return it->second; } + tracy_force_inline bool& FlameGraphThread( uint64_t thread ) + { + auto it = m_flameGraphThread.find( thread ); + if( it == m_flameGraphThread.end() ) + { + it = m_flameGraphThread.emplace( thread, true ).first; + } + return it->second; + } + tracy_force_inline int& GpuDrift( const void* ptr ) { auto it = m_gpuDrift.find( ptr ); diff --git a/profiler/src/profiler/TracyView_FlameGraph.cpp b/profiler/src/profiler/TracyView_FlameGraph.cpp index 8d7f8fe1..597b63df 100644 --- a/profiler/src/profiler/TracyView_FlameGraph.cpp +++ b/profiler/src/profiler/TracyView_FlameGraph.cpp @@ -291,6 +291,60 @@ void View::DrawFlameGraph() ImGui::RadioButton( ICON_FA_EYE_DROPPER " Sampling", &m_flameMode, 1 ); } + auto expand = ImGui::TreeNode( ICON_FA_SHUFFLE " Visible threads:" ); + ImGui::SameLine(); + size_t visibleThreads = 0; + size_t tsz = 0; + for( const auto& t : m_threadOrder ) + { + if( FlameGraphThread( t->id ) ) visibleThreads++; + tsz++; + } + if( visibleThreads == tsz ) + { + ImGui::TextDisabled( "(%zu)", tsz ); + } + else + { + ImGui::TextDisabled( "(%zu/%zu)", visibleThreads, tsz ); + } + if( expand ) + { + ImGui::SameLine(); + if( ImGui::SmallButton( "Select all" ) ) + { + for( const auto& t : m_threadOrder ) + { + FlameGraphThread( t->id ) = true; + } + } + ImGui::SameLine(); + if( ImGui::SmallButton( "Unselect all" ) ) + { + for( const auto& t : m_threadOrder ) + { + FlameGraphThread( t->id ) = false; + } + } + + int idx = 0; + for( const auto& t : m_threadOrder ) + { + ImGui::PushID( idx++ ); + const auto threadColor = GetThreadColor( t->id, 0 ); + SmallColorBox( threadColor ); + ImGui::SameLine(); + SmallCheckbox( m_worker.GetThreadName( t->id ), &FlameGraphThread( t->id ) ); + ImGui::PopID(); + if( t->isFiber ) + { + ImGui::SameLine(); + TextColoredUnformatted( ImVec4( 0.2f, 0.6f, 0.2f, 1.f ), "Fiber" ); + } + } + ImGui::TreePop(); + } + ImGui::Separator(); ImGui::PopStyleVar(); @@ -298,11 +352,17 @@ void View::DrawFlameGraph() if( m_flameMode == 0 ) { - for( auto& thread : m_worker.GetThreadData() ) BuildFlameGraph( m_worker, data, thread->timeline ); + for( auto& thread : m_worker.GetThreadData() ) + { + if( FlameGraphThread( thread->id ) ) BuildFlameGraph( m_worker, data, thread->timeline ); + } } else { - for( auto& thread : m_worker.GetThreadData() ) BuildFlameGraph( m_worker, data, thread->samples ); + for( auto& thread : m_worker.GetThreadData() ) + { + if( FlameGraphThread( thread->id ) ) BuildFlameGraph( m_worker, data, thread->samples ); + } } SortFlameGraph( data );