diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 894ad5db..3f088a50 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -2729,6 +2729,7 @@ void View::DrawFindZone() ImGui::Separator(); if( ImGui::TreeNode( "Matched source locations" ) ) { + auto prev = m_findZone.selMatch; int idx = 0; for( auto& v : m_findZone.match ) { @@ -2741,6 +2742,11 @@ void View::DrawFindZone() ImGui::PopID(); } ImGui::TreePop(); + + if( m_findZone.selMatch != prev ) + { + m_findZone.ResetThreads(); + } } ImGui::Separator(); @@ -3091,6 +3097,7 @@ void View::DrawFindZone() if( ImGui::IsMouseClicked( 1 ) ) { m_findZone.highlight.active = false; + m_findZone.ResetThreads(); } else if( ImGui::IsMouseClicked( 0 ) ) { @@ -3101,6 +3108,7 @@ void View::DrawFindZone() else if( ImGui::IsMouseDragging( 0, 0 ) ) { m_findZone.highlight.end = t1 > m_findZone.highlight.start ? t1 : t0; + m_findZone.ResetThreads(); } } @@ -3134,24 +3142,45 @@ void View::DrawFindZone() ImGui::TreePop(); } - // TODO -#if 0 ImGui::Separator(); ImGui::Text( "Found zones:" ); - for( size_t i=0; iid ) ); + const auto end = m_worker.GetZoneEndDirect( *ev ); + const auto timespan = end - ev->start; + + if( m_findZone.highlight.active ) + { + const auto s = std::min( m_findZone.highlight.start, m_findZone.highlight.end ); + const auto e = std::max( m_findZone.highlight.start, m_findZone.highlight.end ); + if( timespan < s || timespan > e ) continue; + } + + auto thread = GetZoneThread( *ev ); + if( thread != 0 ) + { + m_findZone.threads[thread].emplace_back( ev ); + } + } + m_findZone.processed = sz; + + int idx = 0; + for( auto& v : m_findZone.threads ) + { + ImGui::PushID( idx++ ); + const bool expand = ImGui::TreeNode( m_worker.GetThreadString( v.first ) ); ImGui::PopID(); ImGui::SameLine(); - ImGui::TextColored( ImVec4( 0.5f, 0.5f, 0.5f, 1.0f ), "(%s)", RealToString( m_findZone.counts[i], true ) ); + ImGui::TextColored( ImVec4( 0.5f, 0.5f, 0.5f, 1.0f ), "(%s)", RealToString( v.second.size(), true ) ); if( expand ) { - ImGui::Columns( 3, m_worker.GetThreadString( v->id ) ); + ImGui::Columns( 3, m_worker.GetThreadString( v.first ) ); ImGui::Separator(); ImGui::Text( "Name" ); ImGui::NextColumn(); @@ -3162,18 +3191,11 @@ void View::DrawFindZone() ImGui::Separator(); uint32_t cnt = 0; - for( auto& ev : v->timeline ) + for( auto& ev : v.second ) { const auto end = m_worker.GetZoneEndDirect( *ev ); const auto timespan = end - ev->start; - if( m_findZone.highlight.active ) - { - const auto s = std::min( m_findZone.highlight.start, m_findZone.highlight.end ); - const auto e = std::max( m_findZone.highlight.start, m_findZone.highlight.end ); - if( timespan < s || timespan > e ) continue; - } - ImGui::PushID( ev ); auto& srcloc = m_worker.GetSourceLocation( ev->srcloc ); @@ -3204,27 +3226,8 @@ void View::DrawFindZone() ImGui::Columns( 1 ); ImGui::Separator(); ImGui::TreePop(); - - m_findZone.counts[i] = cnt; - } - else - { - auto cnt = uint32_t( v->timeline.size() ); - if( m_findZone.highlight.active ) - { - for( auto& ev : v->timeline ) - { - const auto end = m_worker.GetZoneEndDirect( *ev ); - const auto timespan = end - ev->start; - const auto s = std::min( m_findZone.highlight.start, m_findZone.highlight.end ); - const auto e = std::max( m_findZone.highlight.start, m_findZone.highlight.end ); - if( timespan < s || timespan > e ) cnt--; - } - } - m_findZone.counts[i] = cnt; } } -#endif } #endif diff --git a/server/TracyView.hpp b/server/TracyView.hpp index b4e6450c..5b1f483d 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -169,8 +169,9 @@ private: struct { bool show; - std::vector counts; std::vector match; + std::map> threads; + size_t processed; int selMatch = 0; char pattern[1024] = { "" }; bool logVal = false; @@ -180,11 +181,17 @@ private: void Reset() { + ResetThreads(); match.clear(); - counts.clear(); selMatch = 0; highlight.active = false; } + + void ResetThreads() + { + threads.clear(); + processed = 0; + } } m_findZone; };