1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Allow filtering messages by thread.

This commit is contained in:
Bartosz Taudul 2018-08-18 19:57:36 +02:00
parent 59293b1850
commit a4df805746
2 changed files with 71 additions and 20 deletions

View File

@ -4330,6 +4330,43 @@ void View::DrawOptions()
void View::DrawMessages() void View::DrawMessages()
{ {
ImGui::Begin( "Messages", &m_showMessages ); ImGui::Begin( "Messages", &m_showMessages );
#ifdef TRACY_EXTENDED_FONT
auto expand = ImGui::TreeNode( ICON_FA_RANDOM " Visible threads:" );
#else
auto expand = ImGui::TreeNode( "Visible threads:" );
#endif
ImGui::SameLine();
ImGui::TextDisabled( "(%zu)", m_worker.GetThreadData().size() );
if( expand )
{
if( ImGui::SmallButton( "Select all" ) )
{
for( const auto& t : m_worker.GetThreadData() )
{
VisibleMsgThread( t->id ) = true;
}
}
ImGui::SameLine();
if( ImGui::SmallButton( "Unselect all" ) )
{
for( const auto& t : m_worker.GetThreadData() )
{
VisibleMsgThread( t->id ) = false;
}
}
int idx = 0;
for( const auto& t : m_worker.GetThreadData() )
{
ImGui::PushID( idx++ );
ImGui::Checkbox( m_worker.GetThreadString( t->id ), &VisibleMsgThread( t->id ) );
ImGui::PopID();
}
ImGui::TreePop();
}
ImGui::Separator();
ImGui::Columns( 3 ); ImGui::Columns( 3 );
ImGui::Text( "Time" ); ImGui::Text( "Time" );
ImGui::SameLine(); ImGui::SameLine();
@ -4348,6 +4385,8 @@ void View::DrawMessages()
ImGui::Separator(); ImGui::Separator();
for( const auto& v : m_worker.GetMessages() ) for( const auto& v : m_worker.GetMessages() )
{
if( VisibleMsgThread( v->thread ) )
{ {
ImGui::PushID( v ); ImGui::PushID( v );
if( ImGui::Selectable( TimeToString( v->time - m_worker.GetTimeBegin() ), m_msgHighlight == v, ImGuiSelectableFlags_SpanAllColumns ) ) if( ImGui::Selectable( TimeToString( v->time - m_worker.GetTimeBegin() ), m_msgHighlight == v, ImGuiSelectableFlags_SpanAllColumns ) )
@ -4372,6 +4411,7 @@ void View::DrawMessages()
ImGui::TextWrapped( "%s", m_worker.GetString( v->ref ) ); ImGui::TextWrapped( "%s", m_worker.GetString( v->ref ) );
ImGui::NextColumn(); ImGui::NextColumn();
} }
}
ImGui::EndColumns(); ImGui::EndColumns();
ImGui::End(); ImGui::End();
} }

View File

@ -151,6 +151,7 @@ private:
void SmallCallstackButton( const char* name, uint32_t callstack, int& idx ); void SmallCallstackButton( const char* name, uint32_t callstack, int& idx );
flat_hash_map<const void*, bool, nohash<const void*>> m_visible; flat_hash_map<const void*, bool, nohash<const void*>> m_visible;
flat_hash_map<uint64_t, bool, nohash<uint64_t>> m_visibleMsgThread;
flat_hash_map<const void*, bool, nohash<const void*>> m_showFull; flat_hash_map<const void*, bool, nohash<const void*>> m_showFull;
flat_hash_map<const void*, int, nohash<const void*>> m_gpuDrift; flat_hash_map<const void*, int, nohash<const void*>> m_gpuDrift;
@ -164,6 +165,16 @@ private:
return it->second; return it->second;
} }
tracy_force_inline bool& VisibleMsgThread( uint64_t thread )
{
auto it = m_visibleMsgThread.find( thread );
if( it == m_visibleMsgThread.end() )
{
it = m_visibleMsgThread.emplace( thread, true ).first;
}
return it->second;
}
tracy_force_inline bool& ShowFull( const void* ptr ) tracy_force_inline bool& ShowFull( const void* ptr )
{ {
auto it = m_showFull.find( ptr ); auto it = m_showFull.find( ptr );