mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Memory allocations tracker.
This commit is contained in:
parent
7a35e8facc
commit
991fc6bd95
@ -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
|
||||
|
@ -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<moodycamel::CanAlloc>( 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<moodycamel::CanAlloc>( 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:
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user