mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Adapt WriteTimeline() to magic vectors.
This commit is contained in:
parent
4eb8acc973
commit
672093cf0e
@ -5855,28 +5855,42 @@ void Worker::WriteTimeline( FileWrite& f, const Vector<short_ptr<ZoneEvent>>& ve
|
|||||||
{
|
{
|
||||||
uint64_t sz = vec.size();
|
uint64_t sz = vec.size();
|
||||||
f.Write( &sz, sizeof( sz ) );
|
f.Write( &sz, sizeof( sz ) );
|
||||||
|
if( vec.is_magic() )
|
||||||
for( auto& v : vec )
|
|
||||||
{
|
{
|
||||||
int16_t srcloc = v->SrcLoc();
|
WriteTimelineImpl<VectorAdapterDirect<ZoneEvent>>( f, *(Vector<ZoneEvent>*)( &vec ), refTime );
|
||||||
f.Write( &srcloc, sizeof( srcloc ) );
|
}
|
||||||
int64_t start = v->Start();
|
else
|
||||||
WriteTimeOffset( f, refTime, start );
|
{
|
||||||
f.Write( &v->text, sizeof( v->text ) );
|
WriteTimelineImpl<VectorAdapterPointer<ZoneEvent>>( f, vec, refTime );
|
||||||
f.Write( &v->callstack, sizeof( v->callstack ) );
|
}
|
||||||
f.Write( &v->name, sizeof( v->name ) );
|
}
|
||||||
|
|
||||||
if( v->Child() < 0 )
|
template<typename Adapter, typename V>
|
||||||
|
void Worker::WriteTimelineImpl( FileWrite& f, const V& vec, int64_t& refTime )
|
||||||
|
{
|
||||||
|
Adapter a;
|
||||||
|
for( auto& val : vec )
|
||||||
|
{
|
||||||
|
auto& v = a(val);
|
||||||
|
int16_t srcloc = v.SrcLoc();
|
||||||
|
f.Write( &srcloc, sizeof( srcloc ) );
|
||||||
|
int64_t start = v.Start();
|
||||||
|
WriteTimeOffset( f, refTime, start );
|
||||||
|
f.Write( &v.text, sizeof( v.text ) );
|
||||||
|
f.Write( &v.callstack, sizeof( v.callstack ) );
|
||||||
|
f.Write( &v.name, sizeof( v.name ) );
|
||||||
|
|
||||||
|
if( v.Child() < 0 )
|
||||||
{
|
{
|
||||||
sz = 0;
|
const uint64_t sz = 0;
|
||||||
f.Write( &sz, sizeof( sz ) );
|
f.Write( &sz, sizeof( sz ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WriteTimeline( f, GetZoneChildren( v->Child() ), refTime );
|
WriteTimeline( f, GetZoneChildren( v.Child() ), refTime );
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteTimeOffset( f, refTime, v->End() );
|
WriteTimeOffset( f, refTime, v.End() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5884,29 +5898,43 @@ void Worker::WriteTimeline( FileWrite& f, const Vector<short_ptr<GpuEvent>>& vec
|
|||||||
{
|
{
|
||||||
uint64_t sz = vec.size();
|
uint64_t sz = vec.size();
|
||||||
f.Write( &sz, sizeof( sz ) );
|
f.Write( &sz, sizeof( sz ) );
|
||||||
|
if( vec.is_magic() )
|
||||||
for( auto& v : vec )
|
|
||||||
{
|
{
|
||||||
WriteTimeOffset( f, refTime, v->CpuStart() );
|
WriteTimelineImpl<VectorAdapterDirect<GpuEvent>>( f, *(Vector<GpuEvent>*)( &vec ), refTime, refGpuTime );
|
||||||
WriteTimeOffset( f, refGpuTime, v->GpuStart() );
|
}
|
||||||
const int16_t srcloc = v->SrcLoc();
|
else
|
||||||
|
{
|
||||||
|
WriteTimelineImpl<VectorAdapterPointer<GpuEvent>>( f, vec, refTime, refGpuTime );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Adapter, typename V>
|
||||||
|
void Worker::WriteTimelineImpl( FileWrite& f, const V& vec, int64_t& refTime, int64_t& refGpuTime )
|
||||||
|
{
|
||||||
|
Adapter a;
|
||||||
|
for( auto& val : vec )
|
||||||
|
{
|
||||||
|
auto& v = a(val);
|
||||||
|
WriteTimeOffset( f, refTime, v.CpuStart() );
|
||||||
|
WriteTimeOffset( f, refGpuTime, v.GpuStart() );
|
||||||
|
const int16_t srcloc = v.SrcLoc();
|
||||||
f.Write( &srcloc, sizeof( srcloc ) );
|
f.Write( &srcloc, sizeof( srcloc ) );
|
||||||
f.Write( &v->callstack, sizeof( v->callstack ) );
|
f.Write( &v.callstack, sizeof( v.callstack ) );
|
||||||
const uint16_t thread = v->Thread();
|
const uint16_t thread = v.Thread();
|
||||||
f.Write( &thread, sizeof( thread ) );
|
f.Write( &thread, sizeof( thread ) );
|
||||||
|
|
||||||
if( v->Child() < 0 )
|
if( v.Child() < 0 )
|
||||||
{
|
{
|
||||||
sz = 0;
|
const uint64_t sz = 0;
|
||||||
f.Write( &sz, sizeof( sz ) );
|
f.Write( &sz, sizeof( sz ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WriteTimeline( f, GetGpuChildren( v->Child() ), refTime, refGpuTime );
|
WriteTimeline( f, GetGpuChildren( v.Child() ), refTime, refGpuTime );
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteTimeOffset( f, refTime, v->CpuEnd() );
|
WriteTimeOffset( f, refTime, v.CpuEnd() );
|
||||||
WriteTimeOffset( f, refGpuTime, v->GpuEnd() );
|
WriteTimeOffset( f, refGpuTime, v.GpuEnd() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -589,8 +589,12 @@ private:
|
|||||||
void ReadTimeline( FileRead& f, Vector<short_ptr<GpuEvent>>& vec, uint64_t size, int64_t& refTime, int64_t& refGpuTime, int32_t& childIdx );
|
void ReadTimeline( FileRead& f, Vector<short_ptr<GpuEvent>>& vec, uint64_t size, int64_t& refTime, int64_t& refGpuTime, int32_t& childIdx );
|
||||||
void ReadTimelinePre0510( FileRead& f, Vector<short_ptr<GpuEvent>>& vec, uint64_t size, int64_t& refTime, int64_t& refGpuTime, int fileVer );
|
void ReadTimelinePre0510( FileRead& f, Vector<short_ptr<GpuEvent>>& vec, uint64_t size, int64_t& refTime, int64_t& refGpuTime, int fileVer );
|
||||||
|
|
||||||
void WriteTimeline( FileWrite& f, const Vector<short_ptr<ZoneEvent>>& vec, int64_t& refTime );
|
tracy_force_inline void WriteTimeline( FileWrite& f, const Vector<short_ptr<ZoneEvent>>& vec, int64_t& refTime );
|
||||||
void WriteTimeline( FileWrite& f, const Vector<short_ptr<GpuEvent>>& vec, int64_t& refTime, int64_t& refGpuTime );
|
tracy_force_inline void WriteTimeline( FileWrite& f, const Vector<short_ptr<GpuEvent>>& vec, int64_t& refTime, int64_t& refGpuTime );
|
||||||
|
template<typename Adapter, typename V>
|
||||||
|
void WriteTimelineImpl( FileWrite& f, const V& vec, int64_t& refTime );
|
||||||
|
template<typename Adapter, typename V>
|
||||||
|
void WriteTimelineImpl( FileWrite& f, const V& vec, int64_t& refTime, int64_t& refGpuTime );
|
||||||
|
|
||||||
int64_t TscTime( int64_t tsc ) { return int64_t( tsc * m_timerMul ); }
|
int64_t TscTime( int64_t tsc ) { return int64_t( tsc * m_timerMul ); }
|
||||||
int64_t TscTime( uint64_t tsc ) { return int64_t( tsc * m_timerMul ); }
|
int64_t TscTime( uint64_t tsc ) { return int64_t( tsc * m_timerMul ); }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user