Send lean frame images.

This commit is contained in:
Bartosz Taudul 2020-05-10 20:16:08 +02:00
parent 03b5dfacd6
commit e9f93f5bc7
4 changed files with 25 additions and 19 deletions

View File

@ -1855,6 +1855,8 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
const auto csz = size_t( w * h / 2 ); const auto csz = size_t( w * h / 2 );
SendLongString( ptr, (const char*)ptr, csz, QueueType::FrameImageData ); SendLongString( ptr, (const char*)ptr, csz, QueueType::FrameImageData );
tracy_free( (void*)ptr ); tracy_free( (void*)ptr );
idx++;
MemWrite( &item->hdr.idx, idx );
break; break;
} }
case QueueType::ZoneBegin: case QueueType::ZoneBegin:

View File

@ -28,6 +28,7 @@ enum class QueueType : uint8_t
CallstackSample, CallstackSample,
CallstackSampleLean, CallstackSampleLean,
FrameImage, FrameImage,
FrameImageLean,
ZoneBegin, ZoneBegin,
ZoneBeginCallstack, ZoneBeginCallstack,
ZoneEnd, ZoneEnd,
@ -133,15 +134,19 @@ struct QueueFrameMark
uint64_t name; // ptr uint64_t name; // ptr
}; };
struct QueueFrameImage struct QueueFrameImageLean
{ {
uint64_t image; // ptr
uint64_t frame; uint64_t frame;
uint16_t w; uint16_t w;
uint16_t h; uint16_t h;
uint8_t flip; uint8_t flip;
}; };
struct QueueFrameImage : public QueueFrameImageLean
{
uint64_t image; // ptr
};
struct QueueSourceLocation struct QueueSourceLocation
{ {
uint64_t name; uint64_t name;
@ -437,6 +442,7 @@ struct QueueItem
QueueStringTransfer stringTransfer; QueueStringTransfer stringTransfer;
QueueFrameMark frameMark; QueueFrameMark frameMark;
QueueFrameImage frameImage; QueueFrameImage frameImage;
QueueFrameImage frameImageLean;
QueueSourceLocation srcloc; QueueSourceLocation srcloc;
QueueZoneText zoneText; QueueZoneText zoneText;
QueueLockAnnounce lockAnnounce; QueueLockAnnounce lockAnnounce;
@ -499,7 +505,8 @@ static constexpr size_t QueueDataSize[] = {
sizeof( QueueHeader ), // lean callstack alloc sizeof( QueueHeader ), // lean callstack alloc
sizeof( QueueHeader ) + sizeof( QueueCallstackSample ), // not for network transfer sizeof( QueueHeader ) + sizeof( QueueCallstackSample ), // not for network transfer
sizeof( QueueHeader ) + sizeof( QueueCallstackSampleLean ), sizeof( QueueHeader ) + sizeof( QueueCallstackSampleLean ),
sizeof( QueueHeader ) + sizeof( QueueFrameImage ), sizeof( QueueHeader ) + sizeof( QueueFrameImage ), // not for network transfer
sizeof( QueueHeader ) + sizeof( QueueFrameImageLean ),
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), sizeof( QueueHeader ) + sizeof( QueueZoneBegin ),
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // callstack sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // callstack
sizeof( QueueHeader ) + sizeof( QueueZoneEnd ), sizeof( QueueHeader ) + sizeof( QueueZoneEnd ),

View File

@ -3029,7 +3029,7 @@ void Worker::Exec()
{ {
if( m_pendingStrings != 0 || m_pendingThreads != 0 || m_pendingSourceLocation != 0 || m_pendingCallstackFrames != 0 || if( m_pendingStrings != 0 || m_pendingThreads != 0 || m_pendingSourceLocation != 0 || m_pendingCallstackFrames != 0 ||
!m_pendingCustomStrings.empty() || m_data.plots.IsPending() || m_pendingCallstackPtr != 0 || !m_pendingCustomStrings.empty() || m_data.plots.IsPending() || m_pendingCallstackPtr != 0 ||
m_pendingExternalNames != 0 || m_pendingCallstackSubframes != 0 || !m_pendingFrameImageData.empty() || m_pendingExternalNames != 0 || m_pendingCallstackSubframes != 0 || m_pendingFrameImageData.image != nullptr ||
!m_pendingSymbols.empty() || !m_pendingSymbolCode.empty() || m_pendingCodeInformation != 0 || !m_pendingSymbols.empty() || !m_pendingSymbolCode.empty() || m_pendingCodeInformation != 0 ||
!m_serverQueryQueue.empty() || m_pendingSourceLocationPayload != 0 ) !m_serverQueryQueue.empty() || m_pendingSourceLocationPayload != 0 )
{ {
@ -3703,7 +3703,7 @@ void Worker::AddExternalThreadName( uint64_t ptr, const char* str, size_t sz )
void Worker::AddFrameImageData( uint64_t ptr, const char* data, size_t sz ) void Worker::AddFrameImageData( uint64_t ptr, const char* data, size_t sz )
{ {
assert( m_pendingFrameImageData.find( ptr ) == m_pendingFrameImageData.end() ); assert( m_pendingFrameImageData.image == nullptr );
assert( sz % 8 == 0 ); assert( sz % 8 == 0 );
// Input data buffer cannot be changed, as it is used as LZ4 dictionary. // Input data buffer cannot be changed, as it is used as LZ4 dictionary.
if( m_frameImageBufferSize < sz ) if( m_frameImageBufferSize < sz )
@ -3717,9 +3717,7 @@ void Worker::AddFrameImageData( uint64_t ptr, const char* data, size_t sz )
memcpy( dst, src, sz ); memcpy( dst, src, sz );
m_texcomp.FixOrder( (char*)dst, sz/8 ); m_texcomp.FixOrder( (char*)dst, sz/8 );
m_texcomp.Rdo( (char*)dst, sz/8 ); m_texcomp.Rdo( (char*)dst, sz/8 );
uint32_t csz; m_pendingFrameImageData.image = m_texcomp.Pack( m_frameImageBuffer, sz, m_pendingFrameImageData.csz, m_slab );
auto image = m_texcomp.Pack( m_frameImageBuffer, sz, csz, m_slab );
m_pendingFrameImageData.emplace( ptr, FrameImagePending { image, csz } );
} }
void Worker::AddSymbolCode( uint64_t ptr, const char* data, size_t sz ) void Worker::AddSymbolCode( uint64_t ptr, const char* data, size_t sz )
@ -4070,8 +4068,8 @@ bool Worker::Process( const QueueItem& ev )
case QueueType::FrameMarkMsgEnd: case QueueType::FrameMarkMsgEnd:
ProcessFrameMarkEnd( ev.frameMark ); ProcessFrameMarkEnd( ev.frameMark );
break; break;
case QueueType::FrameImage: case QueueType::FrameImageLean:
ProcessFrameImage( ev.frameImage ); ProcessFrameImage( ev.frameImageLean );
break; break;
case QueueType::SourceLocation: case QueueType::SourceLocation:
AddSourceLocation( ev.srcloc ); AddSourceLocation( ev.srcloc );
@ -4584,16 +4582,15 @@ void Worker::ProcessFrameMarkEnd( const QueueFrameMark& ev )
#endif #endif
} }
void Worker::ProcessFrameImage( const QueueFrameImage& ev ) void Worker::ProcessFrameImage( const QueueFrameImageLean& ev )
{ {
auto it = m_pendingFrameImageData.find( ev.image ); assert( m_pendingFrameImageData.image != nullptr );
assert( it != m_pendingFrameImageData.end() );
auto& frames = m_data.framesBase->frames; auto& frames = m_data.framesBase->frames;
const auto fidx = int64_t( ev.frame ) - int64_t( m_data.frameOffset ) + 1; const auto fidx = int64_t( ev.frame ) - int64_t( m_data.frameOffset ) + 1;
if( m_onDemand && fidx <= 1 ) if( m_onDemand && fidx <= 1 )
{ {
m_pendingFrameImageData.erase( it ); m_pendingFrameImageData.image = nullptr;
return; return;
} }
else if( fidx <= 0 ) else if( fidx <= 0 )
@ -4603,8 +4600,8 @@ void Worker::ProcessFrameImage( const QueueFrameImage& ev )
} }
auto fi = m_slab.Alloc<FrameImage>(); auto fi = m_slab.Alloc<FrameImage>();
fi->ptr = it->second.image; fi->ptr = m_pendingFrameImageData.image;
fi->csz = it->second.csz; fi->csz = m_pendingFrameImageData.csz;
fi->w = ev.w; fi->w = ev.w;
fi->h = ev.h; fi->h = ev.h;
fi->frameRef = uint32_t( fidx ); fi->frameRef = uint32_t( fidx );
@ -4612,7 +4609,7 @@ void Worker::ProcessFrameImage( const QueueFrameImage& ev )
const auto idx = m_data.frameImage.size(); const auto idx = m_data.frameImage.size();
m_data.frameImage.push_back( fi ); m_data.frameImage.push_back( fi );
m_pendingFrameImageData.erase( it ); m_pendingFrameImageData.image = nullptr;
if( fidx >= (int64_t)frames.size() ) if( fidx >= (int64_t)frames.size() )
{ {

View File

@ -566,7 +566,7 @@ private:
tracy_force_inline void ProcessFrameMark( const QueueFrameMark& ev ); tracy_force_inline void ProcessFrameMark( const QueueFrameMark& ev );
tracy_force_inline void ProcessFrameMarkStart( const QueueFrameMark& ev ); tracy_force_inline void ProcessFrameMarkStart( const QueueFrameMark& ev );
tracy_force_inline void ProcessFrameMarkEnd( const QueueFrameMark& ev ); tracy_force_inline void ProcessFrameMarkEnd( const QueueFrameMark& ev );
tracy_force_inline void ProcessFrameImage( const QueueFrameImage& ev ); tracy_force_inline void ProcessFrameImage( const QueueFrameImageLean& ev );
tracy_force_inline void ProcessZoneText( const QueueZoneText& ev ); tracy_force_inline void ProcessZoneText( const QueueZoneText& ev );
tracy_force_inline void ProcessZoneName( const QueueZoneText& ev ); tracy_force_inline void ProcessZoneName( const QueueZoneText& ev );
tracy_force_inline void ProcessLockAnnounce( const QueueLockAnnounce& ev ); tracy_force_inline void ProcessLockAnnounce( const QueueLockAnnounce& ev );
@ -799,7 +799,7 @@ private:
unordered_flat_map<uint64_t, int16_t> m_sourceLocationShrink; unordered_flat_map<uint64_t, int16_t> m_sourceLocationShrink;
unordered_flat_map<uint64_t, ThreadData*> m_threadMap; unordered_flat_map<uint64_t, ThreadData*> m_threadMap;
unordered_flat_map<uint64_t, NextCallstack> m_nextCallstack; unordered_flat_map<uint64_t, NextCallstack> m_nextCallstack;
unordered_flat_map<uint64_t, FrameImagePending> m_pendingFrameImageData; FrameImagePending m_pendingFrameImageData = {};
unordered_flat_map<uint64_t, SymbolPending> m_pendingSymbols; unordered_flat_map<uint64_t, SymbolPending> m_pendingSymbols;
unordered_flat_set<uint64_t> m_pendingSymbolCode; unordered_flat_set<uint64_t> m_pendingSymbolCode;