Implement direct children search.

This commit is contained in:
Bartosz Taudul 2022-07-23 13:31:41 +02:00
parent 57f03dfe9a
commit f7598d2431
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
3 changed files with 23 additions and 5 deletions

View File

@ -291,6 +291,7 @@ private:
const ZoneEvent* GetZoneParent( const ZoneEvent& zone ) const;
const ZoneEvent* GetZoneParent( const ZoneEvent& zone, uint64_t tid ) const;
const ZoneEvent* GetZoneChild( const ZoneEvent& zone, int64_t time ) const;
bool IsZoneReentry( const ZoneEvent& zone ) const;
bool IsZoneReentry( const ZoneEvent& zone, uint64_t tid ) const;
const GpuEvent* GetZoneParent( const GpuEvent& zone ) const;

View File

@ -194,6 +194,27 @@ const ZoneEvent* View::FindZoneAtTime( uint64_t thread, int64_t time ) const
}
}
const ZoneEvent* View::GetZoneChild( const ZoneEvent& zone, int64_t time ) const
{
if( !zone.HasChildren() ) return nullptr;
auto& children = m_worker.GetZoneChildren( zone.Child() );
if( children.is_magic() )
{
auto& vec = *((Vector<ZoneEvent>*)&children);
auto it = std::upper_bound( vec.begin(), vec.end(), time, [] ( const auto& l, const auto& r ) { return l < r.Start(); } );
if( it != vec.begin() ) --it;
if( it->Start() > time || ( it->IsEndValid() && it->End() < time ) ) return nullptr;
return it;
}
else
{
auto it = std::upper_bound( children.begin(), children.end(), time, [] ( const auto& l, const auto& r ) { return l < r->Start(); } );
if( it != children.begin() ) --it;
if( (*it)->Start() > time || ( (*it)->IsEndValid() && (*it)->End() < time ) ) return nullptr;
return *it;
}
}
const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone ) const
{
#ifndef TRACY_NO_STATISTICS

View File

@ -881,11 +881,7 @@ void View::DrawZoneInfoWindow()
ImGui::TableHeadersRow();
do
{
if( m_messagesExcludeChildren )
{
auto msgzone = FindZoneAtTime( tid, (*msgit)->time );
if( msgzone != &ev ) continue;
}
if( m_messagesExcludeChildren && GetZoneChild( ev, (*msgit)->time ) ) continue;
ImGui::PushID( *msgit );
ImGui::TableNextRow();
ImGui::TableNextColumn();