Extract frame number getter.

This commit is contained in:
Bartosz Taudul 2019-08-26 19:01:51 +02:00
parent 00b26c1acf
commit 3e4d3efbdb
2 changed files with 28 additions and 6 deletions

View File

@ -998,6 +998,7 @@ void View::DrawFrames()
} }
else else
{ {
const auto fnum = GetFrameNumber( *m_frames, sel, m_worker.GetFrameOffset() );
m_frameHover = sel; m_frameHover = sel;
if( m_frames->name == 0 ) if( m_frames->name == 0 )
{ {
@ -1012,7 +1013,7 @@ void View::DrawFrames()
{ {
TextDisabledUnformatted( "Frame:" ); TextDisabledUnformatted( "Frame:" );
ImGui::SameLine(); ImGui::SameLine();
ImGui::TextUnformatted( RealToString( sel, true ) ); ImGui::TextUnformatted( RealToString( fnum, true ) );
ImGui::Separator(); ImGui::Separator();
const auto frameTime = m_worker.GetFrameTime( *m_frames, sel ); const auto frameTime = m_worker.GetFrameTime( *m_frames, sel );
TextFocused( "Frame time:", TimeToString( frameTime ) ); TextFocused( "Frame time:", TimeToString( frameTime ) );
@ -1029,7 +1030,7 @@ void View::DrawFrames()
{ {
TextDisabledUnformatted( "Frame:" ); TextDisabledUnformatted( "Frame:" );
ImGui::SameLine(); ImGui::SameLine();
ImGui::TextUnformatted( RealToString( sel + offset - 1, true ) ); ImGui::TextUnformatted( RealToString( fnum, true ) );
ImGui::Separator(); ImGui::Separator();
const auto frameTime = m_worker.GetFrameTime( *m_frames, sel ); const auto frameTime = m_worker.GetFrameTime( *m_frames, sel );
TextFocused( "Frame time:", TimeToString( frameTime ) ); TextFocused( "Frame time:", TimeToString( frameTime ) );
@ -1041,7 +1042,7 @@ void View::DrawFrames()
{ {
ImGui::TextDisabled( "%s:", m_worker.GetString( m_frames->name ) ); ImGui::TextDisabled( "%s:", m_worker.GetString( m_frames->name ) );
ImGui::SameLine(); ImGui::SameLine();
ImGui::TextUnformatted( RealToString( sel + 1, true ) ); ImGui::TextUnformatted( RealToString( fnum, true ) );
ImGui::Separator(); ImGui::Separator();
const auto frameTime = m_worker.GetFrameTime( *m_frames, sel ); const auto frameTime = m_worker.GetFrameTime( *m_frames, sel );
TextFocused( "Frame time:", TimeToString( frameTime ) ); TextFocused( "Frame time:", TimeToString( frameTime ) );
@ -1269,8 +1270,28 @@ void View::HandleZoneViewMouse( int64_t timespan, const ImVec2& wpos, float w, d
} }
} }
uint64_t View::GetFrameNumber( const FrameData& fd, int i, uint64_t offset ) const
{
if( fd.name == 0 )
{
if( offset == 0 )
{
return i;
}
else
{
return i + offset - 1;
}
}
else
{
return i + 1;
}
}
const char* View::GetFrameText( const FrameData& fd, int i, uint64_t ftime, uint64_t offset ) const const char* View::GetFrameText( const FrameData& fd, int i, uint64_t ftime, uint64_t offset ) const
{ {
const auto fnum = GetFrameNumber( fd, i, offset );
static char buf[1024]; static char buf[1024];
if( fd.name == 0 ) if( fd.name == 0 )
{ {
@ -1280,7 +1301,7 @@ const char* View::GetFrameText( const FrameData& fd, int i, uint64_t ftime, uint
} }
else if( offset == 0 ) else if( offset == 0 )
{ {
sprintf( buf, "Frame %s (%s)", RealToString( i, true ), TimeToString( ftime ) ); sprintf( buf, "Frame %s (%s)", RealToString( fnum, true ), TimeToString( ftime ) );
} }
else if( i == 1 ) else if( i == 1 )
{ {
@ -1288,12 +1309,12 @@ const char* View::GetFrameText( const FrameData& fd, int i, uint64_t ftime, uint
} }
else else
{ {
sprintf( buf, "Frame %s (%s)", RealToString( i + offset - 1, true ), TimeToString( ftime ) ); sprintf( buf, "Frame %s (%s)", RealToString( fnum, true ), TimeToString( ftime ) );
} }
} }
else else
{ {
sprintf( buf, "%s %s (%s)", m_worker.GetString( fd.name ), RealToString( i + 1, true ), TimeToString( ftime ) ); sprintf( buf, "%s %s (%s)", m_worker.GetString( fd.name ), RealToString( fnum, true ), TimeToString( ftime ) );
} }
return buf; return buf;
} }

View File

@ -181,6 +181,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;
uint64_t GetFrameNumber( const FrameData& fd, int i, uint64_t offset ) const;
const char* GetFrameText( const FrameData& fd, int i, uint64_t ftime, uint64_t offset ) const; const char* GetFrameText( const FrameData& fd, int i, uint64_t ftime, uint64_t offset ) const;
#ifndef TRACY_NO_STATISTICS #ifndef TRACY_NO_STATISTICS