mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Multiple frame sets support.
This commit is contained in:
parent
0b4c2724ce
commit
23dfc2e3fc
@ -24,6 +24,7 @@ enum ServerQuery : uint8_t
|
||||
ServerQuerySourceLocation,
|
||||
ServerQueryPlotName,
|
||||
ServerQueryCallstackFrame,
|
||||
ServerQueryFrameName,
|
||||
};
|
||||
|
||||
enum { WelcomeMessageProgramNameSize = 64 };
|
||||
|
@ -255,6 +255,12 @@ struct MemData
|
||||
PlotData* plot = nullptr;
|
||||
};
|
||||
|
||||
struct FrameData
|
||||
{
|
||||
uint64_t name;
|
||||
Vector<int64_t> frames;
|
||||
};
|
||||
|
||||
struct StringLocation
|
||||
{
|
||||
const char* ptr;
|
||||
|
@ -7,7 +7,7 @@ namespace Version
|
||||
{
|
||||
enum { Major = 0 };
|
||||
enum { Minor = 3 };
|
||||
enum { Patch = 201 };
|
||||
enum { Patch = 202 };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,6 +232,7 @@ View::View( const char* addr )
|
||||
, m_memoryAllocInfoWindow( -1 )
|
||||
, m_memoryAllocHover( -1 )
|
||||
, m_memoryAllocHoverWait( 0 )
|
||||
, m_frames( nullptr )
|
||||
, m_gpuThread( 0 )
|
||||
, m_gpuStart( 0 )
|
||||
, m_gpuEnd( 0 )
|
||||
@ -272,6 +273,7 @@ View::View( FileRead& f )
|
||||
, m_memoryAllocInfoWindow( -1 )
|
||||
, m_memoryAllocHover( -1 )
|
||||
, m_memoryAllocHoverWait( 0 )
|
||||
, m_frames( m_worker.GetFramesBase() )
|
||||
, m_gpuThread( 0 )
|
||||
, m_gpuStart( 0 )
|
||||
, m_gpuEnd( 0 )
|
||||
@ -374,6 +376,8 @@ bool View::DrawImpl()
|
||||
return true;
|
||||
}
|
||||
|
||||
if( !m_frames ) m_frames = m_worker.GetFramesBase();
|
||||
|
||||
const auto th = ImGui::GetTextLineHeight();
|
||||
float bw = 0;
|
||||
for( int i=0; i<MainWindowButtonsCount; i++ )
|
||||
@ -417,11 +421,11 @@ bool View::DrawImpl()
|
||||
ImGui::SameLine();
|
||||
if( ImGui::SmallButton( "<" ) ) ZoomToPrevFrame();
|
||||
ImGui::SameLine();
|
||||
ImGui::Text( "Frames: %s", RealToString( m_worker.GetFrameCount(), true ) );
|
||||
ImGui::Text( "Frames: %s", RealToString( m_worker.GetFrameCount( *m_frames ), true ) );
|
||||
ImGui::SameLine();
|
||||
if( ImGui::SmallButton( ">" ) ) ZoomToNextFrame();
|
||||
ImGui::SameLine();
|
||||
ImGui::Text( "Time span: %-10s View span: %-10s Zones: %-13s Queue delay: %s Timer resolution: %s", TimeToString( m_worker.GetLastTime() - m_worker.GetFrameBegin( 0 ) ), TimeToString( m_zvEnd - m_zvStart ), RealToString( m_worker.GetZoneCount(), true ), TimeToString( m_worker.GetDelay() ), TimeToString( m_worker.GetResolution() ) );
|
||||
ImGui::Text( "Time span: %-10s View span: %-10s Zones: %-13s Queue delay: %s Timer resolution: %s", TimeToString( m_worker.GetLastTime() - m_worker.GetFrameBegin( *m_worker.GetFramesBase(), 0 ) ), TimeToString( m_zvEnd - m_zvStart ), RealToString( m_worker.GetZoneCount(), true ), TimeToString( m_worker.GetDelay() ), TimeToString( m_worker.GetResolution() ) );
|
||||
DrawFrames();
|
||||
DrawZones();
|
||||
ImGui::End();
|
||||
@ -495,10 +499,10 @@ void View::DrawConnection()
|
||||
|
||||
std::lock_guard<TracyMutex> lock( m_worker.GetDataLock() );
|
||||
{
|
||||
const auto sz = m_worker.GetFrameCount();
|
||||
const auto sz = m_worker.GetFrameCount( *m_frames );
|
||||
if( sz > 1 )
|
||||
{
|
||||
const auto dt = m_worker.GetFrameTime( sz - 2 );
|
||||
const auto dt = m_worker.GetFrameTime( *m_frames, sz - 2 );
|
||||
const auto dtm = dt / 1000000.f;
|
||||
const auto fps = 1000.f / dtm;
|
||||
ImGui::Text( "FPS: %6.1f Frame time: %.2f ms", fps, dtm );
|
||||
@ -560,7 +564,7 @@ static int GetFrameGroup( int frameScale )
|
||||
|
||||
void View::DrawFrames()
|
||||
{
|
||||
assert( m_worker.GetFrameCount() != 0 );
|
||||
assert( m_worker.GetFrameCount( *m_frames ) != 0 );
|
||||
|
||||
const auto Height = 40 * ImGui::GetTextLineHeight() / 15.f;
|
||||
|
||||
@ -596,19 +600,19 @@ void View::DrawFrames()
|
||||
|
||||
const int fwidth = GetFrameWidth( m_frameScale );
|
||||
const int group = GetFrameGroup( m_frameScale );
|
||||
const int total = m_worker.GetFrameCount();
|
||||
const int total = m_worker.GetFrameCount( *m_frames );
|
||||
const int onScreen = ( w - 2 ) / fwidth;
|
||||
if( !m_pause )
|
||||
{
|
||||
m_frameStart = ( total < onScreen * group ) ? 0 : total - onScreen * group;
|
||||
m_zvStart = m_worker.GetFrameBegin( std::max( 0, total - 4 ) );
|
||||
m_zvStart = m_worker.GetFrameBegin( *m_frames, std::max( 0, total - 4 ) );
|
||||
if( total == 1 )
|
||||
{
|
||||
m_zvEnd = m_worker.GetLastTime();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_zvEnd = m_worker.GetFrameBegin( total - 1 );
|
||||
m_zvEnd = m_worker.GetFrameBegin( *m_frames, total - 1 );
|
||||
}
|
||||
}
|
||||
|
||||
@ -638,11 +642,11 @@ void View::DrawFrames()
|
||||
ImGui::BeginTooltip();
|
||||
if( group > 1 )
|
||||
{
|
||||
auto f = m_worker.GetFrameTime( sel );
|
||||
auto f = m_worker.GetFrameTime( *m_frames, sel );
|
||||
auto g = std::min( group, total - sel );
|
||||
for( int j=1; j<g; j++ )
|
||||
{
|
||||
f = std::max( f, m_worker.GetFrameTime( sel + j ) );
|
||||
f = std::max( f, m_worker.GetFrameTime( *m_frames, sel + j ) );
|
||||
}
|
||||
|
||||
ImGui::TextDisabled( "Frames:" );
|
||||
@ -658,7 +662,7 @@ void View::DrawFrames()
|
||||
{
|
||||
ImGui::Text( "Tracy initialization" );
|
||||
ImGui::Separator();
|
||||
TextFocused( "Time:", TimeToString( m_worker.GetFrameTime( sel ) ) );
|
||||
TextFocused( "Time:", TimeToString( m_worker.GetFrameTime( *m_frames, sel ) ) );
|
||||
}
|
||||
else if( offset == 0 )
|
||||
{
|
||||
@ -666,13 +670,13 @@ void View::DrawFrames()
|
||||
ImGui::SameLine();
|
||||
ImGui::Text( "%s", RealToString( sel, true ) );
|
||||
ImGui::Separator();
|
||||
TextFocused( "Frame time:", TimeToString( m_worker.GetFrameTime( sel ) ) );
|
||||
TextFocused( "Frame time:", TimeToString( m_worker.GetFrameTime( *m_frames, sel ) ) );
|
||||
}
|
||||
else if( sel == 1 )
|
||||
{
|
||||
ImGui::Text( "Missed frames" );
|
||||
ImGui::Separator();
|
||||
TextFocused( "Time:", TimeToString( m_worker.GetFrameTime( 1 ) ) );
|
||||
TextFocused( "Time:", TimeToString( m_worker.GetFrameTime( *m_frames, 1 ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -680,23 +684,23 @@ void View::DrawFrames()
|
||||
ImGui::SameLine();
|
||||
ImGui::Text( "%s", RealToString( sel + offset - 1, true ) );
|
||||
ImGui::Separator();
|
||||
TextFocused( "Frame time:", TimeToString( m_worker.GetFrameTime( sel ) ) );
|
||||
TextFocused( "Frame time:", TimeToString( m_worker.GetFrameTime( *m_frames, sel ) ) );
|
||||
}
|
||||
}
|
||||
TextFocused( "Time from start of program:", TimeToString( m_worker.GetFrameBegin( sel ) - m_worker.GetFrameBegin( 0 ) ) );
|
||||
TextFocused( "Time from start of program:", TimeToString( m_worker.GetFrameBegin( *m_frames, sel ) - m_worker.GetFrameBegin( *m_worker.GetFramesBase(), 0 ) ) );
|
||||
ImGui::EndTooltip();
|
||||
|
||||
if( ImGui::IsMouseClicked( 0 ) )
|
||||
{
|
||||
m_pause = true;
|
||||
m_zvStart = m_worker.GetFrameBegin( sel );
|
||||
m_zvEnd = m_worker.GetFrameEnd( sel + group - 1 );
|
||||
m_zvStart = m_worker.GetFrameBegin( *m_frames, sel );
|
||||
m_zvEnd = m_worker.GetFrameEnd( *m_frames, sel + group - 1 );
|
||||
if( m_zvStart == m_zvEnd ) m_zvStart--;
|
||||
}
|
||||
else if( ImGui::IsMouseDragging( 0 ) )
|
||||
{
|
||||
m_zvStart = std::min( m_zvStart, m_worker.GetFrameBegin( sel ) );
|
||||
m_zvEnd = std::max( m_zvEnd, m_worker.GetFrameEnd( sel + group - 1 ) );
|
||||
m_zvStart = std::min( m_zvStart, m_worker.GetFrameBegin( *m_frames, sel ) );
|
||||
m_zvEnd = std::max( m_zvEnd, m_worker.GetFrameEnd( *m_frames, sel + group - 1 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -714,14 +718,14 @@ void View::DrawFrames()
|
||||
int i = 0, idx = 0;
|
||||
while( i < onScreen && m_frameStart + idx < total )
|
||||
{
|
||||
auto f = m_worker.GetFrameTime( m_frameStart + idx );
|
||||
auto f = m_worker.GetFrameTime( *m_frames, m_frameStart + idx );
|
||||
int g;
|
||||
if( group > 1 )
|
||||
{
|
||||
g = std::min( group, total - ( m_frameStart + idx ) );
|
||||
for( int j=1; j<g; j++ )
|
||||
{
|
||||
f = std::max( f, m_worker.GetFrameTime( m_frameStart + idx + j ) );
|
||||
f = std::max( f, m_worker.GetFrameTime( *m_frames, m_frameStart + idx + j ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -739,7 +743,7 @@ void View::DrawFrames()
|
||||
idx += group;
|
||||
}
|
||||
|
||||
const std::pair <int, int> zrange = m_worker.GetFrameRange( m_zvStart, m_zvEnd );
|
||||
const std::pair <int, int> zrange = m_worker.GetFrameRange( *m_frames, m_zvStart, m_zvEnd );
|
||||
|
||||
if( zrange.second > m_frameStart && zrange.first < m_frameStart + onScreen * group )
|
||||
{
|
||||
@ -902,7 +906,7 @@ bool View::DrawZoneFrames()
|
||||
if( tw == 0 )
|
||||
{
|
||||
char buf[128];
|
||||
const auto t = m_zvStart - m_worker.GetFrameBegin( 0 );
|
||||
const auto t = m_zvStart - m_worker.GetFrameBegin( *m_worker.GetFramesBase(), 0 );
|
||||
auto txt = TimeToString( t );
|
||||
if( t >= 0 )
|
||||
{
|
||||
@ -935,14 +939,14 @@ bool View::DrawZoneFrames()
|
||||
}
|
||||
}
|
||||
|
||||
const std::pair <int, int> zrange = m_worker.GetFrameRange( m_zvStart, m_zvEnd );
|
||||
const std::pair <int, int> zrange = m_worker.GetFrameRange( *m_frames, m_zvStart, m_zvEnd );
|
||||
if( zrange.first < 0 ) return hover;
|
||||
|
||||
for( int i = zrange.first; i < zrange.second; i++ )
|
||||
{
|
||||
const auto ftime = m_worker.GetFrameTime( i );
|
||||
const auto fbegin = m_worker.GetFrameBegin( i );
|
||||
const auto fend = m_worker.GetFrameEnd( i );
|
||||
const auto ftime = m_worker.GetFrameTime( *m_frames, i );
|
||||
const auto fbegin = m_worker.GetFrameBegin( *m_frames, i );
|
||||
const auto fend = m_worker.GetFrameEnd( *m_frames, i );
|
||||
const auto fsz = pxns * ftime;
|
||||
|
||||
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( ( fbegin - m_zvStart ) * pxns, fy ), wpos + ImVec2( ( fend - m_zvStart ) * pxns, fy + ty ) ) )
|
||||
@ -950,7 +954,7 @@ bool View::DrawZoneFrames()
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text( "%s", GetFrameText( i, ftime, m_worker.GetFrameOffset() ) );
|
||||
ImGui::Separator();
|
||||
TextFocused( "Time from start of program:", TimeToString( m_worker.GetFrameBegin( i ) - m_worker.GetFrameBegin( 0 ) ) );
|
||||
TextFocused( "Time from start of program:", TimeToString( m_worker.GetFrameBegin( *m_frames, i ) - m_worker.GetFrameBegin( *m_worker.GetFramesBase(), 0 ) ) );
|
||||
ImGui::EndTooltip();
|
||||
|
||||
if( ImGui::IsMouseClicked( 2 ) )
|
||||
@ -1000,7 +1004,7 @@ bool View::DrawZoneFrames()
|
||||
}
|
||||
}
|
||||
|
||||
const auto fend = m_worker.GetFrameEnd( zrange.second-1 );
|
||||
const auto fend = m_worker.GetFrameEnd( *m_frames, zrange.second-1 );
|
||||
if( fend == m_zvEnd )
|
||||
{
|
||||
draw->AddLine( wpos + ImVec2( ( fend - m_zvStart ) * pxns, 0 ), wpos + ImVec2( ( fend - m_zvStart ) * pxns, wh ), 0x22FFFFFF );
|
||||
@ -1120,7 +1124,7 @@ void View::DrawZones()
|
||||
const auto t = v->timeline.front()->gpuStart;
|
||||
if( t != std::numeric_limits<int64_t>::max() )
|
||||
{
|
||||
TextFocused( "Appeared at", TimeToString( t - m_worker.GetFrameBegin( 0 ) ) );
|
||||
TextFocused( "Appeared at", TimeToString( t - m_worker.GetFrameBegin( *m_worker.GetFramesBase(), 0 ) ) );
|
||||
}
|
||||
}
|
||||
TextFocused( "Zone count:", RealToString( v->count, true ) );
|
||||
@ -1190,7 +1194,7 @@ void View::DrawZones()
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::Text( "%s", TimeToString( (*it)->time - m_worker.GetFrameBegin( 0 ) ) );
|
||||
ImGui::Text( "%s", TimeToString( (*it)->time - m_worker.GetFrameBegin( *m_worker.GetFramesBase(), 0 ) ) );
|
||||
ImGui::Separator();
|
||||
ImGui::Text( "Message text:" );
|
||||
ImGui::TextColored( ImVec4( 0xCC / 255.f, 0xCC / 255.f, 0x22 / 255.f, 1.f ), "%s", m_worker.GetString( (*it)->ref ) );
|
||||
@ -1231,7 +1235,7 @@ void View::DrawZones()
|
||||
if( !v->timeline.empty() )
|
||||
{
|
||||
ImGui::Separator();
|
||||
TextFocused( "Appeared at", TimeToString( v->timeline.front()->start - m_worker.GetFrameBegin( 0 ) ) );
|
||||
TextFocused( "Appeared at", TimeToString( v->timeline.front()->start - m_worker.GetFrameBegin( *m_worker.GetFramesBase(), 0 ) ) );
|
||||
TextFocused( "Zone count:", RealToString( v->count, true ) );
|
||||
TextFocused( "Top-level zones:", RealToString( v->timeline.size(), true ) );
|
||||
}
|
||||
@ -2869,7 +2873,7 @@ void View::DrawPlotPoint( const ImVec2& wpos, float x, float y, int offset, uint
|
||||
ImGui::TextDisabled( "Address:" );
|
||||
ImGui::SameLine();
|
||||
ImGui::Text( "0x%" PRIx64, ev->ptr );
|
||||
TextFocused( "Appeared at", TimeToString( ev->timeAlloc - m_worker.GetFrameBegin( 0 ) ) );
|
||||
TextFocused( "Appeared at", TimeToString( ev->timeAlloc - m_worker.GetFrameBegin( *m_worker.GetFramesBase(), 0 ) ) );
|
||||
if( change > 0 )
|
||||
{
|
||||
ImGui::SameLine();
|
||||
@ -2881,7 +2885,7 @@ void View::DrawPlotPoint( const ImVec2& wpos, float x, float y, int offset, uint
|
||||
}
|
||||
else
|
||||
{
|
||||
TextFocused( "Freed at", TimeToString( ev->timeFree - m_worker.GetFrameBegin( 0 ) ) );
|
||||
TextFocused( "Freed at", TimeToString( ev->timeFree - m_worker.GetFrameBegin( *m_worker.GetFramesBase(), 0 ) ) );
|
||||
if( change < 0 )
|
||||
{
|
||||
ImGui::SameLine();
|
||||
@ -3111,7 +3115,7 @@ void View::DrawZoneInfoWindow()
|
||||
|
||||
const auto end = m_worker.GetZoneEnd( ev );
|
||||
const auto ztime = end - ev.start;
|
||||
TextFocused( "Time from start of program:", TimeToString( ev.start - m_worker.GetFrameBegin( 0 ) ) );
|
||||
TextFocused( "Time from start of program:", TimeToString( ev.start - m_worker.GetFrameBegin( *m_worker.GetFramesBase(), 0 ) ) );
|
||||
TextFocused( "Execution time:", TimeToString( ztime ) );
|
||||
if( ImGui::IsItemHovered() )
|
||||
{
|
||||
@ -3406,7 +3410,7 @@ void View::DrawGpuInfoWindow()
|
||||
|
||||
const auto end = m_worker.GetZoneEnd( ev );
|
||||
const auto ztime = end - ev.gpuStart;
|
||||
TextFocused( "Time from start of program:", TimeToString( ev.gpuStart - m_worker.GetFrameBegin( 0 ) ) );
|
||||
TextFocused( "Time from start of program:", TimeToString( ev.gpuStart - m_worker.GetFrameBegin( *m_worker.GetFramesBase(), 0 ) ) );
|
||||
TextFocused( "GPU execution time:", TimeToString( ztime ) );
|
||||
TextFocused( "CPU command setup time:", TimeToString( ev.cpuEnd - ev.cpuStart ) );
|
||||
auto ctx = GetZoneCtx( ev );
|
||||
@ -3709,7 +3713,7 @@ void View::DrawMessages()
|
||||
for( const auto& v : m_worker.GetMessages() )
|
||||
{
|
||||
ImGui::PushID( v );
|
||||
if( ImGui::Selectable( TimeToString( v->time - m_worker.GetFrameBegin( 0 ) ), m_msgHighlight == v, ImGuiSelectableFlags_SpanAllColumns ) )
|
||||
if( ImGui::Selectable( TimeToString( v->time - m_worker.GetFrameBegin( *m_worker.GetFramesBase(), 0 ) ), m_msgHighlight == v, ImGuiSelectableFlags_SpanAllColumns ) )
|
||||
{
|
||||
CenterAtTime( v->time );
|
||||
}
|
||||
@ -4492,7 +4496,7 @@ void View::DrawFindZone()
|
||||
const auto timespan = end - ev->start;
|
||||
|
||||
ImGui::PushID( ev );
|
||||
if( ImGui::Selectable( TimeToString( ev->start - m_worker.GetFrameBegin( 0 ) ), m_zoneInfoWindow == ev, ImGuiSelectableFlags_SpanAllColumns ) )
|
||||
if( ImGui::Selectable( TimeToString( ev->start - m_worker.GetFrameBegin( *m_worker.GetFramesBase(), 0 ) ), m_zoneInfoWindow == ev, ImGuiSelectableFlags_SpanAllColumns ) )
|
||||
{
|
||||
ShowZoneInfo( *ev );
|
||||
}
|
||||
@ -5328,7 +5332,7 @@ void View::DrawMemoryAllocWindow()
|
||||
TextFocused( "Address:", buf );
|
||||
TextFocused( "Size:", RealToString( ev.size, true ) );
|
||||
ImGui::Separator();
|
||||
TextFocused( "Appeared at", TimeToString( ev.timeAlloc - m_worker.GetFrameBegin( 0 ) ) );
|
||||
TextFocused( "Appeared at", TimeToString( ev.timeAlloc - m_worker.GetFrameBegin( *m_worker.GetFramesBase(), 0 ) ) );
|
||||
if( ImGui::IsItemClicked() ) CenterAtTime( ev.timeAlloc );
|
||||
ImGui::SameLine(); ImGui::Spacing(); ImGui::SameLine();
|
||||
TextFocused( "Thread:", m_worker.GetThreadString( tidAlloc ) );
|
||||
@ -5345,7 +5349,7 @@ void View::DrawMemoryAllocWindow()
|
||||
}
|
||||
else
|
||||
{
|
||||
TextFocused( "Freed at", TimeToString( ev.timeFree - m_worker.GetFrameBegin( 0 ) ) );
|
||||
TextFocused( "Freed at", TimeToString( ev.timeFree - m_worker.GetFrameBegin( *m_worker.GetFramesBase(), 0 ) ) );
|
||||
if( ImGui::IsItemClicked() ) CenterAtTime( ev.timeFree );
|
||||
ImGui::SameLine(); ImGui::Spacing(); ImGui::SameLine();
|
||||
TextFocused( "Thread:", m_worker.GetThreadString( tidFree ) );
|
||||
@ -5520,7 +5524,7 @@ void View::ListMemData( T ptr, T end, std::function<void(T&)> DrawAddress, const
|
||||
ImGui::Text( "%s", RealToString( v->size, true ) );
|
||||
ImGui::NextColumn();
|
||||
ImGui::PushID( idx++ );
|
||||
if( ImGui::Selectable( TimeToString( v->timeAlloc - m_worker.GetFrameBegin( 0 ) ) ) )
|
||||
if( ImGui::Selectable( TimeToString( v->timeAlloc - m_worker.GetFrameBegin( *m_worker.GetFramesBase(), 0 ) ) ) )
|
||||
{
|
||||
CenterAtTime( v->timeAlloc );
|
||||
}
|
||||
@ -6129,14 +6133,14 @@ void View::ZoomToRange( int64_t start, int64_t end )
|
||||
|
||||
void View::ZoomToPrevFrame()
|
||||
{
|
||||
if( m_zvStart >= m_worker.GetFrameBegin( 0 ) )
|
||||
if( m_zvStart >= m_worker.GetFrameBegin( *m_frames, 0 ) )
|
||||
{
|
||||
auto frame = m_worker.GetFrameRange( m_zvStart, m_zvStart ).first;
|
||||
auto frame = m_worker.GetFrameRange( *m_frames, m_zvStart, m_zvStart ).first;
|
||||
if( frame > 0 )
|
||||
{
|
||||
frame--;
|
||||
const auto fbegin = m_worker.GetFrameBegin( frame );
|
||||
const auto fend = m_worker.GetFrameEnd( frame );
|
||||
const auto fbegin = m_worker.GetFrameBegin( *m_frames, frame );
|
||||
const auto fend = m_worker.GetFrameEnd( *m_frames, frame );
|
||||
ZoomToRange( fbegin, fend );
|
||||
}
|
||||
}
|
||||
@ -6145,20 +6149,20 @@ void View::ZoomToPrevFrame()
|
||||
void View::ZoomToNextFrame()
|
||||
{
|
||||
int frame;
|
||||
if( m_zvStart < m_worker.GetFrameBegin( 0 ) )
|
||||
if( m_zvStart < m_worker.GetFrameBegin( *m_frames, 0 ) )
|
||||
{
|
||||
frame = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
frame = m_worker.GetFrameRange( m_zvStart, m_zvStart ).first;
|
||||
frame = m_worker.GetFrameRange( *m_frames, m_zvStart, m_zvStart ).first;
|
||||
if( frame == -1 ) return;
|
||||
}
|
||||
frame++;
|
||||
if( frame >= m_worker.GetFrameCount() ) return;
|
||||
if( frame >= m_worker.GetFrameCount( *m_frames ) ) return;
|
||||
|
||||
const auto fbegin = m_worker.GetFrameBegin( frame );
|
||||
const auto fend = m_worker.GetFrameEnd( frame );
|
||||
const auto fbegin = m_worker.GetFrameBegin( *m_frames, frame );
|
||||
const auto fend = m_worker.GetFrameEnd( *m_frames, frame );
|
||||
ZoomToRange( fbegin, fend );
|
||||
}
|
||||
|
||||
|
@ -194,6 +194,7 @@ private:
|
||||
int64_t m_memoryAllocInfoWindow;
|
||||
int64_t m_memoryAllocHover;
|
||||
int m_memoryAllocHoverWait;
|
||||
const FrameData* m_frames;
|
||||
|
||||
Region m_highlight;
|
||||
Region m_highlightZoom;
|
||||
|
@ -276,9 +276,34 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
||||
m_captureName = std::string( tmp, tmp+sz );
|
||||
}
|
||||
|
||||
if( fileVer >= FileVersion( 0, 3, 202 ) )
|
||||
{
|
||||
f.Read( sz );
|
||||
m_data.frames.reserve_and_use( sz );
|
||||
f.Read( m_data.frames.data(), sizeof( uint64_t ) * sz );
|
||||
m_data.frames.Data().reserve_and_use( sz );
|
||||
for( uint64_t i=0; i<sz; i++ )
|
||||
{
|
||||
auto ptr = m_slab.AllocInit<FrameData>();
|
||||
f.Read( &ptr->name, sizeof( ptr->name ) );
|
||||
uint64_t fsz;
|
||||
f.Read( &fsz, sizeof( fsz ) );
|
||||
ptr->frames.reserve_and_use( fsz );
|
||||
f.Read( ptr->frames.data(), sizeof( int64_t ) * fsz );
|
||||
m_data.frames.Data()[i] = ptr;
|
||||
}
|
||||
|
||||
m_data.framesBase = m_data.frames.Data()[0];
|
||||
assert( m_data.framesBase->name == 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
auto ptr = m_slab.AllocInit<FrameData>();
|
||||
ptr->name = 0;
|
||||
f.Read( sz );
|
||||
ptr->frames.reserve_and_use( sz );
|
||||
f.Read( ptr->frames.data(), sizeof( uint64_t ) * sz );
|
||||
m_data.frames.Data().push_back( ptr );
|
||||
m_data.framesBase = ptr;
|
||||
}
|
||||
|
||||
flat_hash_map<uint64_t, const char*, nohash<uint64_t>> pointerMap;
|
||||
|
||||
@ -825,31 +850,35 @@ Worker::~Worker()
|
||||
{
|
||||
v->~PlotData();
|
||||
}
|
||||
for( auto& v : m_data.frames.Data() )
|
||||
{
|
||||
v->~FrameData();
|
||||
}
|
||||
}
|
||||
|
||||
int64_t Worker::GetFrameTime( size_t idx ) const
|
||||
int64_t Worker::GetFrameTime( const FrameData& fd, size_t idx ) const
|
||||
{
|
||||
if( idx < m_data.frames.size() - 1 )
|
||||
if( idx < fd.frames.size() - 1 )
|
||||
{
|
||||
return m_data.frames[idx+1] - m_data.frames[idx];
|
||||
return fd.frames[idx+1] - fd.frames[idx];
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_data.lastTime == 0 ? 0 : m_data.lastTime - m_data.frames.back();
|
||||
return m_data.lastTime == 0 ? 0 : m_data.lastTime - fd.frames.back();
|
||||
}
|
||||
}
|
||||
|
||||
int64_t Worker::GetFrameBegin( size_t idx ) const
|
||||
int64_t Worker::GetFrameBegin( const FrameData& fd, size_t idx ) const
|
||||
{
|
||||
assert( idx < m_data.frames.size() );
|
||||
return m_data.frames[idx];
|
||||
assert( idx < fd.frames.size() );
|
||||
return fd.frames[idx];
|
||||
}
|
||||
|
||||
int64_t Worker::GetFrameEnd( size_t idx ) const
|
||||
int64_t Worker::GetFrameEnd( const FrameData& fd, size_t idx ) const
|
||||
{
|
||||
if( idx < m_data.frames.size() - 1 )
|
||||
if( idx < fd.frames.size() - 1 )
|
||||
{
|
||||
return m_data.frames[idx+1];
|
||||
return fd.frames[idx+1];
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -857,15 +886,15 @@ int64_t Worker::GetFrameEnd( size_t idx ) const
|
||||
}
|
||||
}
|
||||
|
||||
std::pair <int, int> Worker::GetFrameRange( int64_t from, int64_t to )
|
||||
std::pair <int, int> Worker::GetFrameRange( const FrameData& fd, int64_t from, int64_t to )
|
||||
{
|
||||
const auto zitbegin = std::lower_bound( m_data.frames.begin(), m_data.frames.end(), from );
|
||||
if( zitbegin == m_data.frames.end() ) return std::make_pair( -1, -1 );
|
||||
const auto zitend = std::lower_bound( zitbegin, m_data.frames.end(), to );
|
||||
const auto zitbegin = std::lower_bound( fd.frames.begin(), fd.frames.end(), from );
|
||||
if( zitbegin == fd.frames.end() ) return std::make_pair( -1, -1 );
|
||||
const auto zitend = std::lower_bound( zitbegin, fd.frames.end(), to );
|
||||
|
||||
int zbegin = std::distance( m_data.frames.begin(), zitbegin );
|
||||
int zbegin = std::distance( fd.frames.begin(), zitbegin );
|
||||
if( zbegin > 0 && *zitbegin != from) --zbegin;
|
||||
const int zend = std::distance( m_data.frames.begin(), zitend );
|
||||
const int zend = std::distance( fd.frames.begin(), zitend );
|
||||
|
||||
return std::make_pair( zbegin, zend );
|
||||
}
|
||||
@ -1098,13 +1127,24 @@ void Worker::Exec()
|
||||
uint64_t bytes = 0;
|
||||
uint64_t decBytes = 0;
|
||||
|
||||
m_data.framesBase = m_data.frames.Retrieve( 0, [this] ( uint64_t name ) {
|
||||
auto fd = m_slab.AllocInit<FrameData>();
|
||||
fd->name = name;
|
||||
return fd;
|
||||
}, [this] ( uint64_t name ) {
|
||||
assert( name == 0 );
|
||||
char tmp[6] = "Frame";
|
||||
HandleFrameName( name, tmp, 5 );
|
||||
} );
|
||||
|
||||
{
|
||||
WelcomeMessage welcome;
|
||||
if( !m_sock.Read( &welcome, sizeof( welcome ), &tv, ShouldExit ) ) goto close;
|
||||
m_timerMul = welcome.timerMul;
|
||||
m_data.frames.push_back( TscTime( welcome.initBegin ) );
|
||||
m_data.frames.push_back( TscTime( welcome.initEnd ) );
|
||||
m_data.lastTime = m_data.frames.back();
|
||||
const auto initEnd = TscTime( welcome.initEnd );
|
||||
m_data.framesBase->frames.push_back( TscTime( welcome.initBegin ) );
|
||||
m_data.framesBase->frames.push_back( initEnd );
|
||||
m_data.lastTime = initEnd;
|
||||
m_delay = TscTime( welcome.delay );
|
||||
m_resolution = TscTime( welcome.resolution );
|
||||
m_onDemand = welcome.onDemand;
|
||||
@ -1873,11 +1913,17 @@ void Worker::ProcessZoneEnd( const QueueZoneEnd& ev )
|
||||
|
||||
void Worker::ProcessFrameMark( const QueueFrameMark& ev )
|
||||
{
|
||||
assert( !m_data.frames.empty() );
|
||||
const auto lastframe = m_data.frames.back();
|
||||
auto fd = m_data.frames.Retrieve( ev.name, [this] ( uint64_t name ) {
|
||||
auto fd = m_slab.AllocInit<FrameData>();
|
||||
fd->name = name;
|
||||
return fd;
|
||||
}, [this] ( uint64_t name ) {
|
||||
ServerQuery( ServerQueryFrameName, name );
|
||||
} );
|
||||
|
||||
const auto time = TscTime( ev.time );
|
||||
assert( lastframe < time );
|
||||
m_data.frames.push_back_non_empty( time );
|
||||
assert( fd->frames.empty() || fd->frames.back() < time );
|
||||
fd->frames.push_back( time );
|
||||
m_data.lastTime = std::max( m_data.lastTime, time );
|
||||
}
|
||||
|
||||
@ -2429,7 +2475,7 @@ void Worker::CreateMemAllocPlot()
|
||||
m_data.memory.plot = m_slab.AllocInit<PlotData>();
|
||||
m_data.memory.plot->name = 0;
|
||||
m_data.memory.plot->type = PlotType::Memory;
|
||||
m_data.memory.plot->data.push_back( { GetFrameBegin( 0 ), 0. } );
|
||||
m_data.memory.plot->data.push_back( { GetFrameBegin( *m_data.framesBase, 0 ), 0. } );
|
||||
m_data.plots.Data().push_back( m_data.memory.plot );
|
||||
}
|
||||
|
||||
@ -2463,7 +2509,7 @@ void Worker::ReconstructMemAllocPlot()
|
||||
double usage = 0;
|
||||
|
||||
auto ptr = plot->data.data();
|
||||
ptr->time = GetFrameBegin( 0 );
|
||||
ptr->time = GetFrameBegin( *m_data.framesBase, 0 );
|
||||
ptr->val = 0;
|
||||
ptr++;
|
||||
|
||||
@ -2747,9 +2793,15 @@ void Worker::Write( FileWrite& f )
|
||||
f.Write( &sz, sizeof( sz ) );
|
||||
f.Write( m_captureName.c_str(), sz );
|
||||
|
||||
sz = m_data.frames.size();
|
||||
sz = m_data.frames.Data().size();
|
||||
f.Write( &sz, sizeof( sz ) );
|
||||
f.Write( m_data.frames.data(), sizeof( uint64_t ) * sz );
|
||||
for( auto& fd : m_data.frames.Data() )
|
||||
{
|
||||
f.Write( &fd->name, sizeof( fd->name ) );
|
||||
sz = fd->frames.size();
|
||||
f.Write( &sz, sizeof( sz ) );
|
||||
f.Write( fd->frames.data(), sizeof( int64_t ) * sz );
|
||||
}
|
||||
|
||||
sz = m_data.stringData.size();
|
||||
f.Write( &sz, sizeof( sz ) );
|
||||
|
@ -101,7 +101,8 @@ private:
|
||||
DataBlock() : zonesCnt( 0 ), lastTime( 0 ), frameOffset( 0 ), threadLast( std::numeric_limits<uint64_t>::max(), 0 ) {}
|
||||
|
||||
TracyMutex lock;
|
||||
Vector<int64_t> frames;
|
||||
StringDiscovery<FrameData*> frames;
|
||||
FrameData* framesBase;
|
||||
Vector<GpuCtxData*> gpuData;
|
||||
Vector<MessageData*> messages;
|
||||
StringDiscovery<PlotData*> plots;
|
||||
@ -177,15 +178,16 @@ public:
|
||||
int64_t GetResolution() const { return m_resolution; }
|
||||
|
||||
TracyMutex& GetDataLock() { return m_data.lock; }
|
||||
size_t GetFrameCount() const { return m_data.frames.size(); }
|
||||
size_t GetFrameCount( const FrameData& fd ) const { return fd.frames.size(); }
|
||||
int64_t GetLastTime() const { return m_data.lastTime; }
|
||||
uint64_t GetZoneCount() const { return m_data.zonesCnt; }
|
||||
uint64_t GetFrameOffset() const { return m_data.frameOffset; }
|
||||
const FrameData* GetFramesBase() const { return m_data.framesBase; }
|
||||
|
||||
int64_t GetFrameTime( size_t idx ) const;
|
||||
int64_t GetFrameBegin( size_t idx ) const;
|
||||
int64_t GetFrameEnd( size_t idx ) const;
|
||||
std::pair <int, int> GetFrameRange( int64_t from, int64_t to );
|
||||
int64_t GetFrameTime( const FrameData& fd, size_t idx ) const;
|
||||
int64_t GetFrameBegin( const FrameData& fd, size_t idx ) const;
|
||||
int64_t GetFrameEnd( const FrameData& fd, size_t idx ) const;
|
||||
std::pair <int, int> GetFrameRange( const FrameData& fd, int64_t from, int64_t to );
|
||||
|
||||
const std::map<uint32_t, LockMap>& GetLockMap() const { return m_data.lockMap; }
|
||||
const Vector<MessageData*>& GetMessages() const { return m_data.messages; }
|
||||
|
Loading…
Reference in New Issue
Block a user