Process named memory allocations.

This commit is contained in:
Bartosz Taudul 2020-09-24 01:23:10 +02:00
parent e99534cad7
commit 5a6c8b4696
2 changed files with 84 additions and 0 deletions

View File

@ -4092,15 +4092,27 @@ bool Worker::Process( const QueueItem& ev )
case QueueType::MemAlloc:
ProcessMemAlloc( ev.memAlloc );
break;
case QueueType::MemAllocNamed:
ProcessMemAllocNamed( ev.memAlloc );
break;
case QueueType::MemFree:
ProcessMemFree( ev.memFree );
break;
case QueueType::MemFreeNamed:
ProcessMemFreeNamed( ev.memFree );
break;
case QueueType::MemAllocCallstack:
ProcessMemAllocCallstack( ev.memAlloc );
break;
case QueueType::MemAllocCallstackNamed:
ProcessMemAllocCallstackNamed( ev.memAlloc );
break;
case QueueType::MemFreeCallstack:
ProcessMemFreeCallstack( ev.memFree );
break;
case QueueType::MemFreeCallstackNamed:
ProcessMemFreeCallstackNamed( ev.memFree );
break;
case QueueType::CallstackMemory:
ProcessCallstackMemory();
break;
@ -5262,12 +5274,40 @@ void Worker::ProcessMemAlloc( const QueueMemAlloc& ev )
ProcessMemAllocImpl( 0, *m_data.memory, ev );
}
void Worker::ProcessMemAllocNamed( const QueueMemAlloc& ev )
{
assert( m_memNamePayload != 0 );
auto memname = m_memNamePayload;
m_memNamePayload = 0;
auto it = m_data.memNameMap.find( memname );
if( it == m_data.memNameMap.end() )
{
CheckString( memname );
it = m_data.memNameMap.emplace( memname, m_slab.AllocInit<MemData>() ).first;
}
ProcessMemAllocImpl( memname, *it->second, ev );
}
bool Worker::ProcessMemFree( const QueueMemFree& ev )
{
assert( m_memNamePayload == 0 );
return ProcessMemFreeImpl( 0, *m_data.memory, ev );
}
bool Worker::ProcessMemFreeNamed( const QueueMemFree& ev )
{
assert( m_memNamePayload != 0 );
auto memname = m_memNamePayload;
m_memNamePayload = 0;
auto it = m_data.memNameMap.find( memname );
if( it == m_data.memNameMap.end() )
{
CheckString( memname );
it = m_data.memNameMap.emplace( memname, m_slab.AllocInit<MemData>() ).first;
}
return ProcessMemFreeImpl( memname, *it->second, ev );
}
void Worker::ProcessMemAllocCallstack( const QueueMemAlloc& ev )
{
m_lastMemActionData = m_data.memory;
@ -5276,6 +5316,23 @@ void Worker::ProcessMemAllocCallstack( const QueueMemAlloc& ev )
m_lastMemActionWasAlloc = true;
}
void Worker::ProcessMemAllocCallstackNamed( const QueueMemAlloc& ev )
{
assert( m_memNamePayload != 0 );
auto memname = m_memNamePayload;
m_memNamePayload = 0;
auto it = m_data.memNameMap.find( memname );
if( it == m_data.memNameMap.end() )
{
CheckString( memname );
it = m_data.memNameMap.emplace( memname, m_slab.AllocInit<MemData>() ).first;
}
m_lastMemActionData = it->second;
m_lastMemActionCallstack = it->second->data.size();
ProcessMemAllocImpl( memname, *it->second, ev );
m_lastMemActionWasAlloc = true;
}
void Worker::ProcessMemFreeCallstack( const QueueMemFree& ev )
{
if( ProcessMemFree( ev ) )
@ -5290,6 +5347,29 @@ void Worker::ProcessMemFreeCallstack( const QueueMemFree& ev )
}
}
void Worker::ProcessMemFreeCallstackNamed( const QueueMemFree& ev )
{
assert( m_memNamePayload != 0 );
auto memname = m_memNamePayload;
m_memNamePayload = 0;
auto it = m_data.memNameMap.find( memname );
if( it == m_data.memNameMap.end() )
{
CheckString( memname );
it = m_data.memNameMap.emplace( memname, m_slab.AllocInit<MemData>() ).first;
}
if( ProcessMemFreeImpl( memname, *it->second, ev ) )
{
m_lastMemActionData = it->second;
m_lastMemActionCallstack = it->second->frees.back();
m_lastMemActionWasAlloc = false;
}
else
{
m_lastMemActionCallstack = std::numeric_limits<uint64_t>::max();
}
}
void Worker::ProcessCallstackMemory()
{
assert( m_pendingCallstackPtr != 0 );

View File

@ -653,9 +653,13 @@ private:
tracy_force_inline void ProcessGpuTime( const QueueGpuTime& ev );
tracy_force_inline void ProcessGpuCalibration( const QueueGpuCalibration& ev );
tracy_force_inline void ProcessMemAlloc( const QueueMemAlloc& ev );
tracy_force_inline void ProcessMemAllocNamed( const QueueMemAlloc& ev );
tracy_force_inline bool ProcessMemFree( const QueueMemFree& ev );
tracy_force_inline bool ProcessMemFreeNamed( const QueueMemFree& ev );
tracy_force_inline void ProcessMemAllocCallstack( const QueueMemAlloc& ev );
tracy_force_inline void ProcessMemAllocCallstackNamed( const QueueMemAlloc& ev );
tracy_force_inline void ProcessMemFreeCallstack( const QueueMemFree& ev );
tracy_force_inline void ProcessMemFreeCallstackNamed( const QueueMemFree& ev );
tracy_force_inline void ProcessCallstackMemory();
tracy_force_inline void ProcessCallstack();
tracy_force_inline void ProcessCallstackAlloc();