Add GPU context name transfer to the protocol.

This commit is contained in:
Bartosz Taudul 2021-01-31 18:46:42 +01:00
parent dba35cfa21
commit 7f5810dfd6
2 changed files with 40 additions and 0 deletions

View File

@ -1828,9 +1828,14 @@ static void FreeAssociatedMemory( const QueueItem& item )
ptr = MemRead<uint64_t>( &item.lockNameFat.name ); ptr = MemRead<uint64_t>( &item.lockNameFat.name );
tracy_free( (void*)ptr ); tracy_free( (void*)ptr );
break; break;
case QueueType::GpuContextName:
ptr = MemRead<uint64_t>( &item.gpuContextNameFat.ptr );
tracy_free( (void*)ptr );
break;
#endif #endif
#ifdef TRACY_ON_DEMAND #ifdef TRACY_ON_DEMAND
case QueueType::MessageAppInfo: case QueueType::MessageAppInfo:
case QueueType::GpuContextName:
// Don't free memory associated with deferred messages. // Don't free memory associated with deferred messages.
break; break;
#endif #endif
@ -2029,6 +2034,16 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
MemWrite( &item->gpuZoneEnd.cpuTime, dt ); MemWrite( &item->gpuZoneEnd.cpuTime, dt );
break; break;
} }
case QueueType::GpuContextName:
{
ptr = MemRead<uint64_t>( &item->gpuContextNameFat.ptr );
uint16_t size = MemRead<uint16_t>( &item->gpuContextNameFat.size );
SendSingleString( (const char*)ptr, size );
#ifndef TRACY_ON_DEMAND
tracy_free( (void*)ptr );
#endif
break;
}
case QueueType::PlotData: case QueueType::PlotData:
{ {
int64_t t = MemRead<int64_t>( &item->plotData.time ); int64_t t = MemRead<int64_t>( &item->plotData.time );
@ -2279,6 +2294,16 @@ Profiler::DequeueStatus Profiler::DequeueSerial()
MemWrite( &item->gpuTime.gpuTime, dt ); MemWrite( &item->gpuTime.gpuTime, dt );
break; break;
} }
case QueueType::GpuContextName:
{
ptr = MemRead<uint64_t>( &item->gpuContextNameFat.ptr );
uint16_t size = MemRead<uint16_t>( &item->gpuContextNameFat.size );
SendSingleString( (const char*)ptr, size );
#ifndef TRACY_ON_DEMAND
tracy_free( (void*)ptr );
#endif
break;
}
default: default:
assert( false ); assert( false );
break; break;

View File

@ -54,6 +54,7 @@ enum class QueueType : uint8_t
ContextSwitch, ContextSwitch,
ThreadWakeup, ThreadWakeup,
GpuTime, GpuTime,
GpuContextName,
Terminate, Terminate,
KeepAlive, KeepAlive,
ThreadContext, ThreadContext,
@ -357,6 +358,17 @@ struct QueueGpuCalibration
uint8_t context; uint8_t context;
}; };
struct QueueGpuContextName
{
uint8_t context;
};
struct QueueGpuContextNameFat : public QueueGpuContextName
{
uint64_t ptr;
uint16_t size;
};
struct QueueMemNamePayload struct QueueMemNamePayload
{ {
uint64_t name; uint64_t name;
@ -534,6 +546,8 @@ struct QueueItem
QueueGpuZoneEnd gpuZoneEnd; QueueGpuZoneEnd gpuZoneEnd;
QueueGpuTime gpuTime; QueueGpuTime gpuTime;
QueueGpuCalibration gpuCalibration; QueueGpuCalibration gpuCalibration;
QueueGpuContextName gpuContextName;
QueueGpuContextNameFat gpuContextNameFat;
QueueMemAlloc memAlloc; QueueMemAlloc memAlloc;
QueueMemFree memFree; QueueMemFree memFree;
QueueMemNamePayload memName; QueueMemNamePayload memName;
@ -607,6 +621,7 @@ static constexpr size_t QueueDataSize[] = {
sizeof( QueueHeader ) + sizeof( QueueContextSwitch ), sizeof( QueueHeader ) + sizeof( QueueContextSwitch ),
sizeof( QueueHeader ) + sizeof( QueueThreadWakeup ), sizeof( QueueHeader ) + sizeof( QueueThreadWakeup ),
sizeof( QueueHeader ) + sizeof( QueueGpuTime ), sizeof( QueueHeader ) + sizeof( QueueGpuTime ),
sizeof( QueueHeader ) + sizeof( QueueGpuContextName ),
// above items must be first // above items must be first
sizeof( QueueHeader ), // terminate sizeof( QueueHeader ), // terminate
sizeof( QueueHeader ), // keep alive sizeof( QueueHeader ), // keep alive