From d5a4c693d8bf93a14fc7aa687cd1adc03c85e5fc Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 17 Jun 2018 18:49:56 +0200 Subject: [PATCH] Take GPU timestamp period into account. --- server/TracyWorker.cpp | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 4e9a88b3..605518e3 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -1765,8 +1765,18 @@ void Worker::ProcessGpuNewContext( const QueueGpuNewContext& ev ) { assert( m_gpuCtxMap.find( ev.context ) == m_gpuCtxMap.end() ); + int64_t gpuTime; + if( ev.period == 1.f ) + { + gpuTime = ev.gpuTime; + } + else + { + gpuTime = int64_t( double( ev.period ) * ev.gpuTime ); // precision loss + } + auto gpu = m_slab.AllocInit(); - gpu->timeDiff = TscTime( ev.cpuTime ) - ev.gpuTime; + gpu->timeDiff = TscTime( ev.cpuTime ) - gpuTime; gpu->thread = ev.thread; gpu->accuracyBits = ev.accuracyBits; gpu->period = ev.period; @@ -1825,16 +1835,26 @@ void Worker::ProcessGpuTime( const QueueGpuTime& ev ) assert( it != m_gpuCtxMap.end() ); auto ctx = it->second; + int64_t gpuTime; + if( ctx->period == 1.f ) + { + gpuTime = ev.gpuTime; + } + else + { + gpuTime = int64_t( double( ctx->period ) * ev.gpuTime ); // precision loss + } + auto zone = ctx->queue.front(); if( zone->gpuStart == std::numeric_limits::max() ) { - zone->gpuStart = ctx->timeDiff + ev.gpuTime; + zone->gpuStart = ctx->timeDiff + gpuTime; m_data.lastTime = std::max( m_data.lastTime, zone->gpuStart ); ctx->count++; } else { - zone->gpuEnd = ctx->timeDiff + ev.gpuTime; + zone->gpuEnd = ctx->timeDiff + gpuTime; m_data.lastTime = std::max( m_data.lastTime, zone->gpuEnd ); } @@ -1858,7 +1878,17 @@ void Worker::ProcessGpuResync( const QueueGpuResync& ev ) assert( it != m_gpuCtxMap.end() ); auto ctx = it->second; - const auto timeDiff = TscTime( ev.cpuTime ) - ev.gpuTime; + int64_t gpuTime; + if( ctx->period == 1.f ) + { + gpuTime = ev.gpuTime; + } + else + { + gpuTime = int64_t( double( ctx->period ) * ev.gpuTime ); // precision loss + } + + const auto timeDiff = TscTime( ev.cpuTime ) - gpuTime; if( ctx->queue.empty() ) {