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
+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 )
{