diff --git a/Tracy.hpp b/Tracy.hpp index d8ed519b..bfc1e81c 100644 --- a/Tracy.hpp +++ b/Tracy.hpp @@ -57,6 +57,9 @@ #define TracyMessage( txt, size ) tracy::Profiler::Message( txt, size ); #define TracyMessageL( txt ) tracy::Profiler::Message( txt ); +#define TracyAlloc( ptr, size ) tracy::Profiler::MemAlloc( ptr, size ); +#define TracyFree( ptr ) tracy::Profiler::MemFree( ptr ); + #endif #endif diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index 1666d0c9..ea3af51c 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -186,6 +186,33 @@ public: tail.store( magic + 1, std::memory_order_release ); } + static tracy_force_inline void MemAlloc( const void* ptr, size_t size ) + { + Magic magic; + auto& token = s_token.ptr; + auto& tail = token->get_tail_index(); + auto item = token->enqueue_begin( magic ); + MemWrite( &item->hdr.type, QueueType::MemAlloc ); + MemWrite( &item->memAlloc.time, GetTime() ); + MemWrite( &item->memAlloc.thread, GetThreadHandle() ); + MemWrite( &item->memAlloc.ptr, (uint64_t)ptr ); + memcpy( &item->memAlloc.size, &size, 6 ); + tail.store( magic + 1, std::memory_order_release ); + } + + static tracy_force_inline void MemFree( const void* ptr ) + { + Magic magic; + auto& token = s_token.ptr; + auto& tail = token->get_tail_index(); + auto item = token->enqueue_begin( magic ); + MemWrite( &item->hdr.type, QueueType::MemFree ); + MemWrite( &item->memFree.time, GetTime() ); + MemWrite( &item->memFree.thread, GetThreadHandle() ); + MemWrite( &item->memFree.ptr, (uint64_t)ptr ); + tail.store( magic + 1, std::memory_order_release ); + } + static bool ShouldExit(); private: diff --git a/common/TracyQueue.hpp b/common/TracyQueue.hpp index 0762f39c..69c0f6b6 100644 --- a/common/TracyQueue.hpp +++ b/common/TracyQueue.hpp @@ -31,6 +31,8 @@ enum class QueueType : uint8_t GpuZoneEnd, GpuTime, GpuResync, + MemAlloc, + MemFree, StringData, ThreadName, CustomStringData, @@ -187,6 +189,21 @@ struct QueueGpuResync uint16_t context; }; +struct QueueMemAlloc +{ + int64_t time; + uint64_t thread; + uint64_t ptr; + char size[6]; +}; + +struct QueueMemFree +{ + int64_t time; + uint64_t thread; + uint64_t ptr; +}; + struct QueueHeader { union @@ -219,6 +236,8 @@ struct QueueItem QueueGpuZoneEnd gpuZoneEnd; QueueGpuTime gpuTime; QueueGpuResync gpuResync; + QueueMemAlloc memAlloc; + QueueMemFree memFree; }; }; @@ -251,6 +270,8 @@ static const size_t QueueDataSize[] = { sizeof( QueueHeader ) + sizeof( QueueGpuZoneEnd ), sizeof( QueueHeader ) + sizeof( QueueGpuTime ), sizeof( QueueHeader ) + sizeof( QueueGpuResync ), + sizeof( QueueHeader ) + sizeof( QueueMemAlloc ), + sizeof( QueueHeader ) + sizeof( QueueMemFree ), // keep all QueueStringTransfer below sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // string data sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // thread name diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 43463b1d..8f090755 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -1200,6 +1200,10 @@ void Worker::Process( const QueueItem& ev ) case QueueType::GpuResync: ProcessGpuResync( ev.gpuResync ); break; + case QueueType::MemAlloc: + break; + case QueueType::MemFree: + break; case QueueType::Terminate: m_terminate = true; break;