Store thread id of GPU events.

This commit is contained in:
Bartosz Taudul 2018-06-17 19:05:22 +02:00
parent cfd7ac3957
commit bb0631585c
3 changed files with 32 additions and 1 deletions

View File

@ -131,6 +131,7 @@ struct GpuEvent
int64_t gpuStart; int64_t gpuStart;
int64_t gpuEnd; int64_t gpuEnd;
int32_t srcloc; int32_t srcloc;
uint16_t thread;
// This must be last. All above is read/saved as-is. // This must be last. All above is read/saved as-is.
Vector<GpuEvent*> child; Vector<GpuEvent*> child;

View File

@ -499,12 +499,13 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
if( fileVer <= FileVersion( 0, 3, 1 ) ) if( fileVer <= FileVersion( 0, 3, 1 ) )
{ {
ctx->period = 1.f; ctx->period = 1.f;
ReadTimelinePre032( f, ctx->timeline );
} }
else else
{ {
f.Read( ctx->period ); f.Read( ctx->period );
ReadTimeline( f, ctx->timeline );
} }
ReadTimeline( f, ctx->timeline );
m_data.gpuData.push_back_no_space_check( ctx ); m_data.gpuData.push_back_no_space_check( ctx );
} }
@ -1803,6 +1804,7 @@ void Worker::ProcessGpuZoneBegin( const QueueGpuZoneBegin& ev )
zone->gpuStart = std::numeric_limits<int64_t>::max(); zone->gpuStart = std::numeric_limits<int64_t>::max();
zone->gpuEnd = -1; zone->gpuEnd = -1;
zone->srcloc = ShrinkSourceLocation( ev.srcloc ); zone->srcloc = ShrinkSourceLocation( ev.srcloc );
zone->thread = CompressThread( ev.thread );
m_data.lastTime = std::max( m_data.lastTime, zone->cpuStart ); m_data.lastTime = std::max( m_data.lastTime, zone->cpuStart );
@ -2113,6 +2115,16 @@ void Worker::ReadTimeline( FileRead& f, Vector<GpuEvent*>& vec )
} }
} }
void Worker::ReadTimelinePre032( FileRead& f, Vector<GpuEvent*>& vec )
{
uint64_t sz;
f.Read( sz );
if( sz != 0 )
{
ReadTimelinePre032( f, vec, sz );
}
}
void Worker::ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread, uint64_t size ) void Worker::ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread, uint64_t size )
{ {
assert( size != 0 ); assert( size != 0 );
@ -2170,6 +2182,22 @@ void Worker::ReadTimeline( FileRead& f, Vector<GpuEvent*>& vec, uint64_t size )
} }
} }
void Worker::ReadTimelinePre032( FileRead& f, Vector<GpuEvent*>& vec, uint64_t size )
{
assert( size != 0 );
vec.reserve_non_zero( size );
for( uint64_t i=0; i<size; i++ )
{
auto zone = m_slab.AllocInit<GpuEvent>();
vec.push_back_no_space_check( zone );
f.Read( zone, 36 );
zone->thread = 0;
ReadTimelinePre032( f, zone->child );
}
}
void Worker::Write( FileWrite& f ) void Worker::Write( FileWrite& f )
{ {
f.Write( FileHeader, sizeof( FileHeader ) ); f.Write( FileHeader, sizeof( FileHeader ) );

View File

@ -251,9 +251,11 @@ private:
tracy_force_inline void ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread ); tracy_force_inline void ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread );
tracy_force_inline void ReadTimeline( FileRead& f, Vector<GpuEvent*>& vec ); tracy_force_inline void ReadTimeline( FileRead& f, Vector<GpuEvent*>& vec );
tracy_force_inline void ReadTimelinePre032( FileRead& f, Vector<GpuEvent*>& vec );
void ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread, uint64_t size ); void ReadTimeline( FileRead& f, Vector<ZoneEvent*>& vec, uint16_t thread, uint64_t size );
void ReadTimeline( FileRead& f, Vector<GpuEvent*>& vec, uint64_t size ); void ReadTimeline( FileRead& f, Vector<GpuEvent*>& vec, uint64_t size );
void ReadTimelinePre032( FileRead& f, Vector<GpuEvent*>& vec, uint64_t size );
void WriteTimeline( FileWrite& f, const Vector<ZoneEvent*>& vec ); void WriteTimeline( FileWrite& f, const Vector<ZoneEvent*>& vec );
void WriteTimeline( FileWrite& f, const Vector<GpuEvent*>& vec ); void WriteTimeline( FileWrite& f, const Vector<GpuEvent*>& vec );