Send time deltas in GPU time events.

This commit is contained in:
Bartosz Taudul 2019-10-25 19:52:01 +02:00
parent 1ce25d3aef
commit 0f2503d334
6 changed files with 27 additions and 5 deletions

View File

@ -1316,6 +1316,7 @@ void Profiler::Worker()
m_threadCtx = 0; m_threadCtx = 0;
m_refTimeSerial = 0; m_refTimeSerial = 0;
m_refTimeCtx = 0; m_refTimeCtx = 0;
m_refTimeGpu = 0;
#ifdef TRACY_ON_DEMAND #ifdef TRACY_ON_DEMAND
OnDemandPayloadMessage onDemand; OnDemandPayloadMessage onDemand;
@ -1802,6 +1803,14 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
MemWrite( &item->threadWakeup.time, dt ); MemWrite( &item->threadWakeup.time, dt );
break; break;
} }
case QueueType::GpuTime:
{
int64_t t = MemRead<int64_t>( &item->gpuTime.gpuTime );
int64_t dt = t - m_refTimeGpu;
m_refTimeGpu = t;
MemWrite( &item->gpuTime.gpuTime, dt );
break;
}
default: default:
assert( false ); assert( false );
break; break;
@ -1964,6 +1973,14 @@ Profiler::DequeueStatus Profiler::DequeueSerial()
MemWrite( &item->gpuZoneEnd.cpuTime, dt ); MemWrite( &item->gpuZoneEnd.cpuTime, dt );
break; break;
} }
case QueueType::GpuTime:
{
int64_t t = MemRead<int64_t>( &item->gpuTime.gpuTime );
int64_t dt = t - m_refTimeGpu;
m_refTimeGpu = t;
MemWrite( &item->gpuTime.gpuTime, dt );
break;
}
default: default:
assert( false ); assert( false );
break; break;

View File

@ -546,6 +546,7 @@ private:
int64_t m_refTimeThread; int64_t m_refTimeThread;
int64_t m_refTimeSerial; int64_t m_refTimeSerial;
int64_t m_refTimeCtx; int64_t m_refTimeCtx;
int64_t m_refTimeGpu;
void* m_stream; // LZ4_stream_t* void* m_stream; // LZ4_stream_t*
char* m_buffer; char* m_buffer;

View File

@ -9,7 +9,7 @@
namespace tracy namespace tracy
{ {
enum : uint32_t { ProtocolVersion = 20 }; enum : uint32_t { ProtocolVersion = 21 };
enum : uint32_t { BroadcastVersion = 0 }; enum : uint32_t { BroadcastVersion = 0 };
using lz4sz_t = uint32_t; using lz4sz_t = uint32_t;

View File

@ -41,6 +41,7 @@ enum class QueueType : uint8_t
PlotData, PlotData,
ContextSwitch, ContextSwitch,
ThreadWakeup, ThreadWakeup,
GpuTime,
Terminate, Terminate,
KeepAlive, KeepAlive,
ThreadContext, ThreadContext,
@ -57,7 +58,6 @@ enum class QueueType : uint8_t
MessageLiteral, MessageLiteral,
MessageLiteralColor, MessageLiteralColor,
GpuNewContext, GpuNewContext,
GpuTime,
CallstackFrameSize, CallstackFrameSize,
CallstackFrame, CallstackFrame,
SysTimeReport, SysTimeReport,
@ -419,6 +419,7 @@ static const size_t QueueDataSize[] = {
sizeof( QueueHeader ) + sizeof( QueuePlotData ), sizeof( QueueHeader ) + sizeof( QueuePlotData ),
sizeof( QueueHeader ) + sizeof( QueueContextSwitch ), sizeof( QueueHeader ) + sizeof( QueueContextSwitch ),
sizeof( QueueHeader ) + sizeof( QueueThreadWakeup ), sizeof( QueueHeader ) + sizeof( QueueThreadWakeup ),
sizeof( QueueHeader ) + sizeof( QueueGpuTime ),
// above items must be first // above items must be first
sizeof( QueueHeader ), // terminate sizeof( QueueHeader ), // terminate
sizeof( QueueHeader ), // keep alive sizeof( QueueHeader ), // keep alive
@ -436,7 +437,6 @@ static const size_t QueueDataSize[] = {
sizeof( QueueHeader ) + sizeof( QueueMessage ), // literal sizeof( QueueHeader ) + sizeof( QueueMessage ), // literal
sizeof( QueueHeader ) + sizeof( QueueMessageColor ), // literal sizeof( QueueHeader ) + sizeof( QueueMessageColor ), // literal
sizeof( QueueHeader ) + sizeof( QueueGpuNewContext ), sizeof( QueueHeader ) + sizeof( QueueGpuNewContext ),
sizeof( QueueHeader ) + sizeof( QueueGpuTime ),
sizeof( QueueHeader ) + sizeof( QueueCallstackFrameSize ), sizeof( QueueHeader ) + sizeof( QueueCallstackFrameSize ),
sizeof( QueueHeader ) + sizeof( QueueCallstackFrame ), sizeof( QueueHeader ) + sizeof( QueueCallstackFrame ),
sizeof( QueueHeader ) + sizeof( QueueSysTime ), sizeof( QueueHeader ) + sizeof( QueueSysTime ),

View File

@ -4188,14 +4188,17 @@ void Worker::ProcessGpuTime( const QueueGpuTime& ev )
auto ctx = m_gpuCtxMap[ev.context]; auto ctx = m_gpuCtxMap[ev.context];
assert( ctx ); assert( ctx );
const int64_t t = m_refTimeGpu + ev.gpuTime;
m_refTimeGpu = t;
int64_t gpuTime; int64_t gpuTime;
if( ctx->period == 1.f ) if( ctx->period == 1.f )
{ {
gpuTime = ev.gpuTime; gpuTime = t;
} }
else else
{ {
gpuTime = int64_t( double( ctx->period ) * ev.gpuTime ); // precision loss gpuTime = int64_t( double( ctx->period ) * t ); // precision loss
} }
auto zone = ctx->query[ev.queryId]; auto zone = ctx->query[ev.queryId];

View File

@ -622,6 +622,7 @@ private:
int64_t m_refTimeThread = 0; int64_t m_refTimeThread = 0;
int64_t m_refTimeSerial = 0; int64_t m_refTimeSerial = 0;
int64_t m_refTimeCtx = 0; int64_t m_refTimeCtx = 0;
int64_t m_refTimeGpu = 0;
}; };
} }