From 3900890ef453c3f79f6fdf986c2bc837a9aef004 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 1 May 2026 20:38:49 +0200 Subject: [PATCH] Show visible threads list in columns. Options list is excluded, as that's drag-n-drop, and that's too much complication. --- .../src/profiler/TracyView_ContextSwitch.cpp | 17 +++++++++++++++++ profiler/src/profiler/TracyView_FlameGraph.cpp | 14 ++++++++++++++ profiler/src/profiler/TracyView_Messages.cpp | 18 ++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/profiler/src/profiler/TracyView_ContextSwitch.cpp b/profiler/src/profiler/TracyView_ContextSwitch.cpp index 54ae3f36..5b98092d 100644 --- a/profiler/src/profiler/TracyView_ContextSwitch.cpp +++ b/profiler/src/profiler/TracyView_ContextSwitch.cpp @@ -509,10 +509,26 @@ void View::DrawWaitStacks() threadsChanged = true; } + const auto& style = ImGui::GetStyle(); + const auto cntWidth = ImGui::CalcTextSize( "(1234)" ).x; + float probe = 0; + for( auto& t : m_threadOrder ) + { + if( t->ctxSwitchSamples.empty() ) continue; + float w = ImGui::GetFrameHeight() * 2 + ImGui::CalcTextSize( m_worker.GetThreadName( t->id ) ).x + cntWidth + style.ItemSpacing.x * 3; + if( crash.thread == t->id ) w += style.ItemSpacing.x + ImGui::CalcTextSize( ICON_FA_SKULL " Crashed" ).x; + if( t->isFiber ) w += style.ItemSpacing.x + ImGui::CalcTextSize( "Fiber" ).x; + probe = std::max( probe, w ); + } + const auto MinWidth = std::max( 150 * GetScale(), probe ); + const int cols = std::max( 1, int( ImGui::GetContentRegionAvail().x / MinWidth ) ); + int idx = 0; + ImGui::BeginTable( "##waitstackthreadcols", cols, ImGuiTableFlags_NoSavedSettings ); for( const auto& t : m_threadOrder ) { if( t->ctxSwitchSamples.empty() ) continue; + ImGui::TableNextColumn(); ImGui::PushID( idx++ ); const auto threadColor = GetThreadColor( t->id, 0 ); SmallColorBox( threadColor ); @@ -535,6 +551,7 @@ void View::DrawWaitStacks() TextColoredUnformatted( ImVec4( 0.2f, 0.6f, 0.2f, 1.f ), "Fiber" ); } } + ImGui::EndTable(); ImGui::TreePop(); } if( threadsChanged ) m_waitStack = 0; diff --git a/profiler/src/profiler/TracyView_FlameGraph.cpp b/profiler/src/profiler/TracyView_FlameGraph.cpp index 63530c0f..c6fb99da 100644 --- a/profiler/src/profiler/TracyView_FlameGraph.cpp +++ b/profiler/src/profiler/TracyView_FlameGraph.cpp @@ -837,9 +837,22 @@ void View::DrawFlameGraph() m_flameGraphInvariant.Reset(); } + const auto& style = ImGui::GetStyle(); + float probe = 0; + for( auto& t : td ) + { + float w = ImGui::GetFrameHeight() * 2 + ImGui::CalcTextSize( m_worker.GetThreadName( t->id ) ).x + style.ItemSpacing.x * 2; + if( t->isFiber ) w += style.ItemSpacing.x + ImGui::CalcTextSize( "Fiber" ).x; + probe = std::max( probe, w ); + } + const auto MinWidth = std::max( 150 * GetScale(), probe ); + const int cols = std::max( 1, int( ImGui::GetContentRegionAvail().x / MinWidth ) ); + int idx = 0; + ImGui::BeginTable( "##flamegraphthreadcols", cols, ImGuiTableFlags_NoSavedSettings ); for( const auto& t : td ) { + ImGui::TableNextColumn(); ImGui::PushID( idx++ ); const auto threadColor = GetThreadColor( t->id, 0 ); SmallColorBox( threadColor ); @@ -852,6 +865,7 @@ void View::DrawFlameGraph() TextColoredUnformatted( ImVec4( 0.2f, 0.6f, 0.2f, 1.f ), "Fiber" ); } } + ImGui::EndTable(); ImGui::TreePop(); } diff --git a/profiler/src/profiler/TracyView_Messages.cpp b/profiler/src/profiler/TracyView_Messages.cpp index 015e5531..8e10f3a0 100644 --- a/profiler/src/profiler/TracyView_Messages.cpp +++ b/profiler/src/profiler/TracyView_Messages.cpp @@ -196,10 +196,27 @@ void View::DrawMessages() if( expand ) { auto& crash = m_worker.GetCrashEvent(); + + const auto& style = ImGui::GetStyle(); + const auto cntWidth = ImGui::CalcTextSize( "(1234)" ).x; + float probe = 0; + for( auto& t : m_threadOrder ) + { + if( t->messages.empty() ) continue; + float w = ImGui::GetFrameHeight() * 2 + ImGui::CalcTextSize( m_worker.GetThreadName( t->id ) ).x + cntWidth + style.ItemSpacing.x * 3; + if( crash.thread == t->id ) w += style.ItemSpacing.x + ImGui::CalcTextSize( ICON_FA_SKULL " Crashed" ).x; + if( t->isFiber ) w += style.ItemSpacing.x + ImGui::CalcTextSize( "Fiber" ).x; + probe = std::max( probe, w ); + } + const auto MinWidth = std::max( 150 * GetScale(), probe ); + const int cols = std::max( 1, int( ImGui::GetContentRegionAvail().x / MinWidth ) ); + int idx = 0; + ImGui::BeginTable( "##msgthreadcols", cols, ImGuiTableFlags_NoSavedSettings ); for( const auto& t : m_threadOrder ) { if( t->messages.empty() ) continue; + ImGui::TableNextColumn(); ImGui::PushID( idx++ ); const auto threadColor = GetThreadColor( t->id, 0 ); SmallColorBox( threadColor ); @@ -222,6 +239,7 @@ void View::DrawMessages() TextColoredUnformatted( ImVec4( 0.2f, 0.6f, 0.2f, 1.f ), "Fiber" ); } } + ImGui::EndTable(); ImGui::TreePop(); }