mirror of
https://github.com/wolfpld/tracy
synced 2025-05-08 16:03:53 +00:00
Display list of matched source locations in search window.
This commit is contained in:
parent
5c1aec723d
commit
2c508c1f79
@ -2673,6 +2673,8 @@ void View::DrawFindZone()
|
|||||||
if( ImGui::Button( "Clear" ) )
|
if( ImGui::Button( "Clear" ) )
|
||||||
{
|
{
|
||||||
m_findZone.result.clear();
|
m_findZone.result.clear();
|
||||||
|
m_findZone.match.clear();
|
||||||
|
m_findZone.matchEnable.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ImGui::TreeNode( "Options" ) )
|
if( ImGui::TreeNode( "Options" ) )
|
||||||
@ -2689,9 +2691,31 @@ void View::DrawFindZone()
|
|||||||
if( findClicked )
|
if( findClicked )
|
||||||
{
|
{
|
||||||
m_findZone.result.clear();
|
m_findZone.result.clear();
|
||||||
|
m_findZone.match.clear();
|
||||||
|
m_findZone.matchEnable.clear();
|
||||||
FindZones();
|
FindZones();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !m_findZone.match.empty() )
|
||||||
|
{
|
||||||
|
ImGui::Separator();
|
||||||
|
if( ImGui::TreeNode( "Matched source locations" ) )
|
||||||
|
{
|
||||||
|
for( size_t i=0; i<m_findZone.match.size(); i++ )
|
||||||
|
{
|
||||||
|
auto& srcloc = m_worker.GetSourceLocation( m_findZone.match[i] );
|
||||||
|
bool tmp = m_findZone.matchEnable[i];
|
||||||
|
ImGui::PushID( (int)i );
|
||||||
|
ImGui::Checkbox( m_worker.GetString( srcloc.name.active ? srcloc.name : srcloc.function ), &tmp );
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::TextColored( ImVec4( 0.5, 0.5, 0.5, 1 ), "%s:%i", m_worker.GetString( srcloc.file ), srcloc.line );
|
||||||
|
ImGui::PopID();
|
||||||
|
m_findZone.matchEnable[i] = tmp;
|
||||||
|
}
|
||||||
|
ImGui::TreePop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( !m_findZone.result.empty() )
|
if( !m_findZone.result.empty() )
|
||||||
{
|
{
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
@ -3237,13 +3261,15 @@ const GpuEvent* View::GetZoneParent( const GpuEvent& zone ) const
|
|||||||
|
|
||||||
void View::FindZones()
|
void View::FindZones()
|
||||||
{
|
{
|
||||||
const auto match = m_worker.GetMatchingSourceLocation( m_findZone.pattern );
|
m_findZone.match = m_worker.GetMatchingSourceLocation( m_findZone.pattern );
|
||||||
if( match.empty() ) return;
|
if( m_findZone.match.empty() ) return;
|
||||||
|
|
||||||
|
m_findZone.matchEnable = std::vector<bool>( m_findZone.match.size(), true );
|
||||||
|
|
||||||
for( const auto& v : m_worker.GetThreadData() )
|
for( const auto& v : m_worker.GetThreadData() )
|
||||||
{
|
{
|
||||||
auto thrOut = std::make_unique<ThreadData>();
|
auto thrOut = std::make_unique<ThreadData>();
|
||||||
FindZones( v->timeline, thrOut->timeline, match, m_findZone.maxDepth );
|
FindZones( v->timeline, thrOut->timeline, m_findZone.maxDepth );
|
||||||
|
|
||||||
if( !thrOut->timeline.empty() )
|
if( !thrOut->timeline.empty() )
|
||||||
{
|
{
|
||||||
@ -3253,21 +3279,21 @@ void View::FindZones()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::FindZones( const Vector<ZoneEvent*>& events, Vector<ZoneEvent*>& out, const std::vector<int32_t>& match, const int maxdepth )
|
void View::FindZones( const Vector<ZoneEvent*>& events, Vector<ZoneEvent*>& out, const int maxdepth )
|
||||||
{
|
{
|
||||||
for( auto& ev : events )
|
for( auto& ev : events )
|
||||||
{
|
{
|
||||||
if( out.size() >= m_findZone.maxZonesPerThread ) break;
|
if( out.size() >= m_findZone.maxZonesPerThread ) break;
|
||||||
if( m_worker.GetZoneEnd( *ev ) == ev->start ) continue;
|
if( m_worker.GetZoneEnd( *ev ) == ev->start ) continue;
|
||||||
|
|
||||||
if( std::find( match.begin(), match.end(), ev->srcloc ) != match.end() )
|
if( std::find( m_findZone.match.begin(), m_findZone.match.end(), ev->srcloc ) != m_findZone.match.end() )
|
||||||
{
|
{
|
||||||
out.push_back( ev );
|
out.push_back( ev );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( maxdepth != 0 )
|
if( maxdepth != 0 )
|
||||||
{
|
{
|
||||||
FindZones( ev->child, out, match, maxdepth - 1 );
|
FindZones( ev->child, out, maxdepth - 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ private:
|
|||||||
const GpuEvent* GetZoneParent( const GpuEvent& zone ) const;
|
const GpuEvent* GetZoneParent( const GpuEvent& zone ) const;
|
||||||
|
|
||||||
void FindZones();
|
void FindZones();
|
||||||
void FindZones( const Vector<ZoneEvent*> &events, Vector<ZoneEvent*> &out, const std::vector<int32_t>& match, const int maxdepth = 0 );
|
void FindZones( const Vector<ZoneEvent*> &events, Vector<ZoneEvent*> &out, const int maxdepth = 0 );
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool& Visible( const T* ptr )
|
bool& Visible( const T* ptr )
|
||||||
@ -163,6 +163,8 @@ private:
|
|||||||
struct {
|
struct {
|
||||||
bool show;
|
bool show;
|
||||||
std::vector<std::unique_ptr<ThreadData>> result;
|
std::vector<std::unique_ptr<ThreadData>> result;
|
||||||
|
std::vector<int32_t> match;
|
||||||
|
std::vector<bool> matchEnable;
|
||||||
char pattern[1024] = { "" };
|
char pattern[1024] = { "" };
|
||||||
int maxZonesPerThread = -1;
|
int maxZonesPerThread = -1;
|
||||||
int maxDepth = -1;
|
int maxDepth = -1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user