1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Add GpuTimeSync event

Allows to resynchronise GPU and CPU timestamps during profiling.
This commit is contained in:
Ivan Molodetskikh
2023-10-22 08:03:58 +04:00
parent 3601576b3f
commit 41fc293043
7 changed files with 67 additions and 1 deletions
+3
View File
@@ -195,6 +195,9 @@ void EventDebug( const QueueItem& ev )
case QueueType::GpuCalibration:
fprintf( f, "ev %i (GpuCalibration)\n", ev.hdr.idx );
break;
case QueueType::GpuTimeSync:
fprintf( f, "ev %i (GpuTimeSync)\n", ev.hdr.idx );
break;
case QueueType::Crash:
fprintf( f, "ev %i (Crash)\n", ev.hdr.idx );
break;
+26
View File
@@ -4589,6 +4589,9 @@ bool Worker::Process( const QueueItem& ev )
case QueueType::GpuCalibration:
ProcessGpuCalibration( ev.gpuCalibration );
break;
case QueueType::GpuTimeSync:
ProcessGpuTimeSync( ev.gpuTimeSync );
break;
case QueueType::GpuContextName:
ProcessGpuContextName( ev.gpuContextName );
break;
@@ -5921,6 +5924,29 @@ void Worker::ProcessGpuCalibration( const QueueGpuCalibration& ev )
ctx->calibratedGpuTime = gpuTime;
ctx->calibratedCpuTime = TscTime( ev.cpuTime );
}
void Worker::ProcessGpuTimeSync( const QueueGpuTimeSync& ev )
{
auto ctx = m_gpuCtxMap[ev.context];
assert( ctx );
int64_t gpuTime;
if( ctx->period == 1.f )
{
gpuTime = ev.gpuTime;
}
else
{
gpuTime = int64_t( double( ctx->period ) * ev.gpuTime ); // precision loss
}
const auto cpuTime = TscTime( ev.cpuTime );
ctx->timeDiff = cpuTime - gpuTime;
ctx->lastGpuTime = 0;
ctx->overflow = 0;
ctx->overflowMul = 0;
}
void Worker::ProcessGpuContextName( const QueueGpuContextName& ev )
{
+1
View File
@@ -722,6 +722,7 @@ private:
tracy_force_inline void ProcessGpuZoneEnd( const QueueGpuZoneEnd& ev, bool serial );
tracy_force_inline void ProcessGpuTime( const QueueGpuTime& ev );
tracy_force_inline void ProcessGpuCalibration( const QueueGpuCalibration& ev );
tracy_force_inline void ProcessGpuTimeSync( const QueueGpuTimeSync& ev );
tracy_force_inline void ProcessGpuContextName( const QueueGpuContextName& ev );
tracy_force_inline MemEvent* ProcessMemAlloc( const QueueMemAlloc& ev );
tracy_force_inline MemEvent* ProcessMemAllocNamed( const QueueMemAlloc& ev );