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()
{
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::Text( "Time" );
ImGui::SameLine();
@ -4349,28 +4386,31 @@ void View::DrawMessages()
for( const auto& v : m_worker.GetMessages() )
{
ImGui::PushID( v );
if( ImGui::Selectable( TimeToString( v->time - m_worker.GetTimeBegin() ), m_msgHighlight == v, ImGuiSelectableFlags_SpanAllColumns ) )
if( VisibleMsgThread( v->thread ) )
{
CenterAtTime( v->time );
ImGui::PushID( v );
if( ImGui::Selectable( TimeToString( v->time - m_worker.GetTimeBegin() ), m_msgHighlight == v, ImGuiSelectableFlags_SpanAllColumns ) )
{
CenterAtTime( v->time );
}
if( ImGui::IsItemHovered() )
{
m_msgHighlight = v;
}
if( m_msgToFocus == v )
{
ImGui::SetScrollHere();
m_msgToFocus = nullptr;
}
ImGui::PopID();
ImGui::NextColumn();
ImGui::Text( "%s", m_worker.GetThreadString( v->thread ) );
ImGui::SameLine();
ImGui::TextDisabled( "(0x%" PRIX64 ")", v->thread );
ImGui::NextColumn();
ImGui::TextWrapped( "%s", m_worker.GetString( v->ref ) );
ImGui::NextColumn();
}
if( ImGui::IsItemHovered() )
{
m_msgHighlight = v;
}
if( m_msgToFocus == v )
{
ImGui::SetScrollHere();
m_msgToFocus = nullptr;
}
ImGui::PopID();
ImGui::NextColumn();
ImGui::Text( "%s", m_worker.GetThreadString( v->thread ) );
ImGui::SameLine();
ImGui::TextDisabled( "(0x%" PRIX64 ")", v->thread );
ImGui::NextColumn();
ImGui::TextWrapped( "%s", m_worker.GetString( v->ref ) );
ImGui::NextColumn();
}
ImGui::EndColumns();
ImGui::End();

View File

@ -151,6 +151,7 @@ private:
void SmallCallstackButton( const char* name, uint32_t callstack, int& idx );
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*, int, nohash<const void*>> m_gpuDrift;
@ -164,6 +165,16 @@ private:
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 )
{
auto it = m_showFull.find( ptr );