mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
CPU-side GPU event transfer.
This commit is contained in:
@@ -94,6 +94,22 @@ enum { LockEventSize = sizeof( LockEvent ) };
|
||||
enum { MaxLockThreads = sizeof( LockEvent::waitList ) * 8 };
|
||||
static_assert( std::numeric_limits<decltype(LockEvent::lockCount)>::max() >= MaxLockThreads, "Not enough space for lock count." );
|
||||
|
||||
|
||||
struct GpuEvent
|
||||
{
|
||||
int64_t cpuStart;
|
||||
int64_t cpuEnd;
|
||||
int64_t gpuStart;
|
||||
int64_t gpuEnd;
|
||||
int32_t srcloc;
|
||||
uint64_t name;
|
||||
uint64_t thread;
|
||||
|
||||
Vector<GpuEvent*> child;
|
||||
};
|
||||
|
||||
enum { GpuEventSize = sizeof( GpuEvent ) };
|
||||
|
||||
#pragma pack()
|
||||
|
||||
|
||||
@@ -115,6 +131,9 @@ struct ThreadData
|
||||
struct GpuCtxData
|
||||
{
|
||||
int64_t timeDiff;
|
||||
Vector<GpuEvent*> timeline;
|
||||
Vector<GpuEvent*> stack;
|
||||
Vector<GpuEvent*> queue;
|
||||
};
|
||||
|
||||
struct LockMap
|
||||
|
||||
+53
-1
@@ -591,6 +591,12 @@ void View::Process( const QueueItem& ev )
|
||||
case QueueType::GpuNewContext:
|
||||
ProcessGpuNewContext( ev.gpuNewContext );
|
||||
break;
|
||||
case QueueType::GpuZoneBegin:
|
||||
ProcessGpuZoneBegin( ev.gpuZoneBegin );
|
||||
break;
|
||||
case QueueType::GpuZoneEnd:
|
||||
ProcessGpuZoneEnd( ev.gpuZoneEnd );
|
||||
break;
|
||||
case QueueType::Terminate:
|
||||
m_terminate = true;
|
||||
break;
|
||||
@@ -850,12 +856,58 @@ void View::ProcessMessageLiteral( const QueueMessage& ev )
|
||||
void View::ProcessGpuNewContext( const QueueGpuNewContext& ev )
|
||||
{
|
||||
assert( ev.context == m_gpuData.size() );
|
||||
auto gpu = m_slab.Alloc<GpuCtxData>();
|
||||
auto gpu = m_slab.AllocInit<GpuCtxData>();
|
||||
gpu->timeDiff = int64_t( ev.cputime * m_timerMul - ev.gputime );
|
||||
std::lock_guard<std::mutex> lock( m_lock );
|
||||
m_gpuData.push_back( gpu );
|
||||
}
|
||||
|
||||
void View::ProcessGpuZoneBegin( const QueueGpuZoneBegin& ev )
|
||||
{
|
||||
assert( m_gpuData.size() >= ev.context );
|
||||
auto ctx = m_gpuData[ev.context];
|
||||
|
||||
CheckString( ev.name );
|
||||
CheckSourceLocation( ev.srcloc );
|
||||
|
||||
auto zone = m_slab.AllocInit<GpuEvent>();
|
||||
zone->cpuStart = ev.cpuTime;
|
||||
zone->cpuEnd = -1;
|
||||
zone->gpuStart = std::numeric_limits<int64_t>::max();
|
||||
zone->gpuEnd = -1;
|
||||
zone->name = ev.name;
|
||||
zone->srcloc = ev.srcloc;
|
||||
zone->thread = 0;
|
||||
|
||||
auto timeline = &ctx->timeline;
|
||||
if( !ctx->stack.empty() )
|
||||
{
|
||||
timeline = &ctx->stack.back()->child;
|
||||
}
|
||||
|
||||
m_lock.lock();
|
||||
timeline->push_back( zone );
|
||||
m_lock.unlock();
|
||||
|
||||
ctx->stack.push_back( zone );
|
||||
ctx->queue.push_back( zone );
|
||||
}
|
||||
|
||||
void View::ProcessGpuZoneEnd( const QueueGpuZoneEnd& ev )
|
||||
{
|
||||
assert( m_gpuData.size() >= ev.context );
|
||||
auto ctx = m_gpuData[ev.context];
|
||||
|
||||
assert( !ctx->stack.empty() );
|
||||
auto zone = ctx->stack.back();
|
||||
ctx->stack.pop_back();
|
||||
ctx->queue.push_back( zone );
|
||||
|
||||
std::lock_guard<std::mutex> lock( m_lock );
|
||||
zone->cpuEnd = ev.cpuTime;
|
||||
zone->thread = ev.thread;
|
||||
}
|
||||
|
||||
void View::CheckString( uint64_t ptr )
|
||||
{
|
||||
if( m_strings.find( ptr ) != m_strings.end() ) return;
|
||||
|
||||
@@ -68,6 +68,8 @@ private:
|
||||
void ProcessMessage( const QueueMessage& ev );
|
||||
void ProcessMessageLiteral( const QueueMessage& ev );
|
||||
void ProcessGpuNewContext( const QueueGpuNewContext& ev );
|
||||
void ProcessGpuZoneBegin( const QueueGpuZoneBegin& ev );
|
||||
void ProcessGpuZoneEnd( const QueueGpuZoneEnd& ev );
|
||||
|
||||
void CheckString( uint64_t ptr );
|
||||
void CheckThreadString( uint64_t id );
|
||||
|
||||
Reference in New Issue
Block a user