Move zone trace loop handler to a separate function.

This commit is contained in:
Bartosz Taudul 2018-06-24 15:54:36 +02:00
parent 858628918b
commit fa62603c77

View File

@ -2750,6 +2750,24 @@ void View::DrawInfoWindow()
} }
} }
template<typename T>
void DrawZoneTrace( const std::vector<T>& trace, std::function<void(T)> showZone )
{
if( trace.empty() ) return;
bool expand = ImGui::TreeNode( "Zone trace" );
ImGui::SameLine();
ImGui::TextDisabled( "(%s)", RealToString( trace.size(), true ) );
if( !expand ) return;
for( auto& v : trace )
{
showZone( v );
}
ImGui::TreePop();
}
void View::DrawZoneInfoWindow() void View::DrawZoneInfoWindow()
{ {
auto& ev = *m_zoneInfoWindow; auto& ev = *m_zoneInfoWindow;
@ -2944,16 +2962,8 @@ void View::DrawZoneInfoWindow()
zoneTrace.emplace_back( parent ); zoneTrace.emplace_back( parent );
parent = GetZoneParent( *parent ); parent = GetZoneParent( *parent );
} }
if( !zoneTrace.empty() )
{
bool expand = ImGui::TreeNode( "Zone trace" );
ImGui::SameLine();
ImGui::TextDisabled( "(%s)", RealToString( zoneTrace.size(), true ) );
if( expand )
{
int idx = 0; int idx = 0;
for( auto& v : zoneTrace ) DrawZoneTrace<const ZoneEvent*>( zoneTrace, [&idx, this] ( const ZoneEvent* v ) {
{
const auto& srcloc = m_worker.GetSourceLocation( v->srcloc ); const auto& srcloc = m_worker.GetSourceLocation( v->srcloc );
const auto txt = srcloc.name.active ? m_worker.GetString( srcloc.name ) : m_worker.GetString( srcloc.function ); const auto txt = srcloc.name.active ? m_worker.GetString( srcloc.name ) : m_worker.GetString( srcloc.function );
ImGui::PushID( idx++ ); ImGui::PushID( idx++ );
@ -2975,10 +2985,7 @@ void View::DrawZoneInfoWindow()
} }
ZoneTooltip( *v ); ZoneTooltip( *v );
} }
} } );
ImGui::TreePop();
}
}
if( !ev.child.empty() ) if( !ev.child.empty() )
{ {
@ -3134,16 +3141,8 @@ void View::DrawGpuInfoWindow()
zoneTrace.emplace_back( parent ); zoneTrace.emplace_back( parent );
parent = GetZoneParent( *parent ); parent = GetZoneParent( *parent );
} }
if( !zoneTrace.empty() )
{
bool expand = ImGui::TreeNode( "Zone trace" );
ImGui::SameLine();
ImGui::TextDisabled( "(%s)", RealToString( zoneTrace.size(), true ) );
if( expand )
{
int idx = 0; int idx = 0;
for( auto& v : zoneTrace ) DrawZoneTrace<const GpuEvent*>( zoneTrace, [&idx, this] ( const GpuEvent* v ) {
{
const auto& srcloc = m_worker.GetSourceLocation( v->srcloc ); const auto& srcloc = m_worker.GetSourceLocation( v->srcloc );
const auto txt = srcloc.name.active ? m_worker.GetString( srcloc.name ) : m_worker.GetString( srcloc.function ); const auto txt = srcloc.name.active ? m_worker.GetString( srcloc.name ) : m_worker.GetString( srcloc.function );
ImGui::PushID( idx++ ); ImGui::PushID( idx++ );
@ -3165,10 +3164,7 @@ void View::DrawGpuInfoWindow()
} }
ZoneTooltip( *v ); ZoneTooltip( *v );
} }
} } );
ImGui::TreePop();
}
}
if( !ev.child.empty() ) if( !ev.child.empty() )
{ {