Store memory operations in the serial queue.

This commit is contained in:
Bartosz Taudul 2018-04-01 19:53:24 +02:00
parent faeecdd773
commit 860e0e1809

View File

@ -193,29 +193,31 @@ public:
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 );
const auto time = GetTime();
const auto thread = GetThreadHandle();
s_profiler.m_serialLock.lock();
auto item = s_profiler.m_serialQueue.push_next();
MemWrite( &item->hdr.type, QueueType::MemAlloc );
MemWrite( &item->memAlloc.time, GetTime() );
MemWrite( &item->memAlloc.thread, GetThreadHandle() );
MemWrite( &item->memAlloc.time, time );
MemWrite( &item->memAlloc.thread, thread );
MemWrite( &item->memAlloc.ptr, (uint64_t)ptr );
memcpy( &item->memAlloc.size, &size, 6 );
tail.store( magic + 1, std::memory_order_release );
s_profiler.m_serialLock.unlock();
}
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 );
const auto time = GetTime();
const auto thread = GetThreadHandle();
s_profiler.m_serialLock.lock();
auto item = s_profiler.m_serialQueue.push_next();
MemWrite( &item->hdr.type, QueueType::MemFree );
MemWrite( &item->memFree.time, GetTime() );
MemWrite( &item->memFree.thread, GetThreadHandle() );
MemWrite( &item->memFree.time, time );
MemWrite( &item->memFree.thread, thread );
MemWrite( &item->memFree.ptr, (uint64_t)ptr );
tail.store( magic + 1, std::memory_order_release );
s_profiler.m_serialLock.unlock();
}
static bool ShouldExit();