From 7f5810dfd625adad8ad86859b65ea56efed03884 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 31 Jan 2021 18:46:42 +0100 Subject: [PATCH] Add GPU context name transfer to the protocol. --- client/TracyProfiler.cpp | 25 +++++++++++++++++++++++++ common/TracyQueue.hpp | 15 +++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 5435f583..bf48c92e 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -1828,9 +1828,14 @@ static void FreeAssociatedMemory( const QueueItem& item ) ptr = MemRead( &item.lockNameFat.name ); tracy_free( (void*)ptr ); break; + case QueueType::GpuContextName: + ptr = MemRead( &item.gpuContextNameFat.ptr ); + tracy_free( (void*)ptr ); + break; #endif #ifdef TRACY_ON_DEMAND case QueueType::MessageAppInfo: + case QueueType::GpuContextName: // Don't free memory associated with deferred messages. break; #endif @@ -2029,6 +2034,16 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token ) MemWrite( &item->gpuZoneEnd.cpuTime, dt ); break; } + case QueueType::GpuContextName: + { + ptr = MemRead( &item->gpuContextNameFat.ptr ); + uint16_t size = MemRead( &item->gpuContextNameFat.size ); + SendSingleString( (const char*)ptr, size ); +#ifndef TRACY_ON_DEMAND + tracy_free( (void*)ptr ); +#endif + break; + } case QueueType::PlotData: { int64_t t = MemRead( &item->plotData.time ); @@ -2279,6 +2294,16 @@ Profiler::DequeueStatus Profiler::DequeueSerial() MemWrite( &item->gpuTime.gpuTime, dt ); break; } + case QueueType::GpuContextName: + { + ptr = MemRead( &item->gpuContextNameFat.ptr ); + uint16_t size = MemRead( &item->gpuContextNameFat.size ); + SendSingleString( (const char*)ptr, size ); +#ifndef TRACY_ON_DEMAND + tracy_free( (void*)ptr ); +#endif + break; + } default: assert( false ); break; diff --git a/common/TracyQueue.hpp b/common/TracyQueue.hpp index bce4eed0..3b6c6ac3 100644 --- a/common/TracyQueue.hpp +++ b/common/TracyQueue.hpp @@ -54,6 +54,7 @@ enum class QueueType : uint8_t ContextSwitch, ThreadWakeup, GpuTime, + GpuContextName, Terminate, KeepAlive, ThreadContext, @@ -357,6 +358,17 @@ struct QueueGpuCalibration uint8_t context; }; +struct QueueGpuContextName +{ + uint8_t context; +}; + +struct QueueGpuContextNameFat : public QueueGpuContextName +{ + uint64_t ptr; + uint16_t size; +}; + struct QueueMemNamePayload { uint64_t name; @@ -534,6 +546,8 @@ struct QueueItem QueueGpuZoneEnd gpuZoneEnd; QueueGpuTime gpuTime; QueueGpuCalibration gpuCalibration; + QueueGpuContextName gpuContextName; + QueueGpuContextNameFat gpuContextNameFat; QueueMemAlloc memAlloc; QueueMemFree memFree; QueueMemNamePayload memName; @@ -607,6 +621,7 @@ static constexpr size_t QueueDataSize[] = { sizeof( QueueHeader ) + sizeof( QueueContextSwitch ), sizeof( QueueHeader ) + sizeof( QueueThreadWakeup ), sizeof( QueueHeader ) + sizeof( QueueGpuTime ), + sizeof( QueueHeader ) + sizeof( QueueGpuContextName ), // above items must be first sizeof( QueueHeader ), // terminate sizeof( QueueHeader ), // keep alive