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

Use proper frame names.

This commit is contained in:
Bartosz Taudul 2018-08-04 21:19:24 +02:00
parent aad3e941e5
commit 1ea1cd57b3
2 changed files with 24 additions and 16 deletions

View File

@ -850,24 +850,31 @@ void View::HandleZoneViewMouse( int64_t timespan, const ImVec2& wpos, float w, d
} }
} }
static const char* GetFrameText( int i, uint64_t ftime, uint64_t offset ) const char* View::GetFrameText( const FrameData& fd, int i, uint64_t ftime, uint64_t offset ) const
{ {
static char buf[128]; static char buf[1024];
if( i == 0 ) if( fd.name == 0 )
{ {
sprintf( buf, "Tracy init (%s)", TimeToString( ftime ) ); if( i == 0 )
} {
else if( offset == 0 ) sprintf( buf, "Tracy init (%s)", TimeToString( ftime ) );
{ }
sprintf( buf, "Frame %s (%s)", RealToString( i, true ), TimeToString( ftime ) ); else if( offset == 0 )
} {
else if( i == 1 ) sprintf( buf, "Frame %s (%s)", RealToString( i, true ), TimeToString( ftime ) );
{ }
sprintf( buf, "Missed frames (%s)", TimeToString( ftime ) ); else if( i == 1 )
{
sprintf( buf, "Missed frames (%s)", TimeToString( ftime ) );
}
else
{
sprintf( buf, "Frame %s (%s)", RealToString( i + offset - 1, true ), TimeToString( ftime ) );
}
} }
else else
{ {
sprintf( buf, "Frame %s (%s)", RealToString( i + offset - 1, true ), TimeToString( ftime ) ); sprintf( buf, "%s %s (%s)", m_worker.GetString( fd.name ), RealToString( i, true ), TimeToString( ftime ) );
} }
return buf; return buf;
} }
@ -968,7 +975,7 @@ bool View::DrawZoneFrames( const FrameData& frames )
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( ( fbegin - m_zvStart ) * pxns, 0 ), wpos + ImVec2( ( fend - m_zvStart ) * pxns, ty ) ) ) if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( ( fbegin - m_zvStart ) * pxns, 0 ), wpos + ImVec2( ( fend - m_zvStart ) * pxns, ty ) ) )
{ {
ImGui::BeginTooltip(); ImGui::BeginTooltip();
ImGui::Text( "%s", GetFrameText( i, ftime, m_worker.GetFrameOffset() ) ); ImGui::Text( "%s", GetFrameText( frames, i, ftime, m_worker.GetFrameOffset() ) );
ImGui::Separator(); ImGui::Separator();
TextFocused( "Time from start of program:", TimeToString( m_worker.GetFrameBegin( frames, i ) - m_worker.GetTimeBegin() ) ); TextFocused( "Time from start of program:", TimeToString( m_worker.GetFrameBegin( frames, i ) - m_worker.GetTimeBegin() ) );
ImGui::EndTooltip(); ImGui::EndTooltip();
@ -988,9 +995,9 @@ bool View::DrawZoneFrames( const FrameData& frames )
if( fsz >= 5 ) if( fsz >= 5 )
{ {
auto buf = GetFrameText( i, ftime, m_worker.GetFrameOffset() ); auto buf = GetFrameText( frames, i, ftime, m_worker.GetFrameOffset() );
auto tx = ImGui::CalcTextSize( buf ).x; auto tx = ImGui::CalcTextSize( buf ).x;
uint32_t color = i == 0 ? 0xFF4444FF : 0xFFFFFFFF; uint32_t color = ( frames.name == 0 && i == 0 ) ? 0xFF4444FF : 0xFFFFFFFF;
if( fsz - 5 <= tx ) if( fsz - 5 <= tx )
{ {

View File

@ -121,6 +121,7 @@ private:
uint64_t GetZoneThread( const GpuEvent& zone ) const; uint64_t GetZoneThread( const GpuEvent& zone ) const;
const GpuCtxData* GetZoneCtx( const GpuEvent& zone ) const; const GpuCtxData* GetZoneCtx( const GpuEvent& zone ) const;
const ZoneEvent* FindZoneAtTime( uint64_t thread, int64_t time ) const; const ZoneEvent* FindZoneAtTime( uint64_t thread, int64_t time ) const;
const char* GetFrameText( const FrameData& fd, int i, uint64_t ftime, uint64_t offset ) const;
#ifndef TRACY_NO_STATISTICS #ifndef TRACY_NO_STATISTICS
void FindZones(); void FindZones();