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 TracyMessage( txt, size ) tracy::Profiler::Message( txt, size );
|
||||||
#define TracyMessageL( txt ) tracy::Profiler::Message( txt );
|
#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
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -186,6 +186,33 @@ public:
|
|||||||
tail.store( magic + 1, std::memory_order_release );
|
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();
|
static bool ShouldExit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -31,6 +31,8 @@ enum class QueueType : uint8_t
|
|||||||
GpuZoneEnd,
|
GpuZoneEnd,
|
||||||
GpuTime,
|
GpuTime,
|
||||||
GpuResync,
|
GpuResync,
|
||||||
|
MemAlloc,
|
||||||
|
MemFree,
|
||||||
StringData,
|
StringData,
|
||||||
ThreadName,
|
ThreadName,
|
||||||
CustomStringData,
|
CustomStringData,
|
||||||
@ -187,6 +189,21 @@ struct QueueGpuResync
|
|||||||
uint16_t context;
|
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
|
struct QueueHeader
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
@ -219,6 +236,8 @@ struct QueueItem
|
|||||||
QueueGpuZoneEnd gpuZoneEnd;
|
QueueGpuZoneEnd gpuZoneEnd;
|
||||||
QueueGpuTime gpuTime;
|
QueueGpuTime gpuTime;
|
||||||
QueueGpuResync gpuResync;
|
QueueGpuResync gpuResync;
|
||||||
|
QueueMemAlloc memAlloc;
|
||||||
|
QueueMemFree memFree;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -251,6 +270,8 @@ static const size_t QueueDataSize[] = {
|
|||||||
sizeof( QueueHeader ) + sizeof( QueueGpuZoneEnd ),
|
sizeof( QueueHeader ) + sizeof( QueueGpuZoneEnd ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueGpuTime ),
|
sizeof( QueueHeader ) + sizeof( QueueGpuTime ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueGpuResync ),
|
sizeof( QueueHeader ) + sizeof( QueueGpuResync ),
|
||||||
|
sizeof( QueueHeader ) + sizeof( QueueMemAlloc ),
|
||||||
|
sizeof( QueueHeader ) + sizeof( QueueMemFree ),
|
||||||
// keep all QueueStringTransfer below
|
// keep all QueueStringTransfer below
|
||||||
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // string data
|
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // string data
|
||||||
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // thread name
|
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // thread name
|
||||||
|
@ -1200,6 +1200,10 @@ void Worker::Process( const QueueItem& ev )
|
|||||||
case QueueType::GpuResync:
|
case QueueType::GpuResync:
|
||||||
ProcessGpuResync( ev.gpuResync );
|
ProcessGpuResync( ev.gpuResync );
|
||||||
break;
|
break;
|
||||||
|
case QueueType::MemAlloc:
|
||||||
|
break;
|
||||||
|
case QueueType::MemFree:
|
||||||
|
break;
|
||||||
case QueueType::Terminate:
|
case QueueType::Terminate:
|
||||||
m_terminate = true;
|
m_terminate = true;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user