mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-12 19:31:47 +00:00
Save/load frame images.
This commit is contained in:
parent
6ae4afa0f4
commit
6b2741ccdb
@ -7,7 +7,7 @@ namespace Version
|
|||||||
{
|
{
|
||||||
enum { Major = 0 };
|
enum { Major = 0 };
|
||||||
enum { Minor = 4 };
|
enum { Minor = 4 };
|
||||||
enum { Patch = 8 };
|
enum { Patch = 9 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
|||||||
uint64_t fsz;
|
uint64_t fsz;
|
||||||
f.Read( &fsz, sizeof( fsz ) );
|
f.Read( &fsz, sizeof( fsz ) );
|
||||||
ptr->frames.reserve_exact( fsz, m_slab );
|
ptr->frames.reserve_exact( fsz, m_slab );
|
||||||
if( fileVer >= FileVersion( 0, 4, 2 ) )
|
if( fileVer >= FileVersion( 0, 4, 9 ) )
|
||||||
{
|
{
|
||||||
int64_t refTime = 0;
|
int64_t refTime = 0;
|
||||||
if( ptr->continuous )
|
if( ptr->continuous )
|
||||||
@ -388,6 +388,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
|||||||
{
|
{
|
||||||
ptr->frames[j].start = ReadTimeOffset( f, refTime );
|
ptr->frames[j].start = ReadTimeOffset( f, refTime );
|
||||||
ptr->frames[j].end = -1;
|
ptr->frames[j].end = -1;
|
||||||
|
f.Read( &ptr->frames[j].frameImage, sizeof( int32_t ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -396,6 +397,29 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
|||||||
{
|
{
|
||||||
ptr->frames[j].start = ReadTimeOffset( f, refTime );
|
ptr->frames[j].start = ReadTimeOffset( f, refTime );
|
||||||
ptr->frames[j].end = ReadTimeOffset( f, refTime );
|
ptr->frames[j].end = ReadTimeOffset( f, refTime );
|
||||||
|
f.Read( &ptr->frames[j].frameImage, sizeof( int32_t ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( fileVer >= FileVersion( 0, 4, 2 ) )
|
||||||
|
{
|
||||||
|
int64_t refTime = 0;
|
||||||
|
if( ptr->continuous )
|
||||||
|
{
|
||||||
|
for( uint64_t j=0; j<fsz; j++ )
|
||||||
|
{
|
||||||
|
ptr->frames[j].start = ReadTimeOffset( f, refTime );
|
||||||
|
ptr->frames[j].end = -1;
|
||||||
|
ptr->frames[j].frameImage = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for( uint64_t j=0; j<fsz; j++ )
|
||||||
|
{
|
||||||
|
ptr->frames[j].start = ReadTimeOffset( f, refTime );
|
||||||
|
ptr->frames[j].end = ReadTimeOffset( f, refTime );
|
||||||
|
ptr->frames[j].frameImage = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -407,11 +431,17 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
|||||||
{
|
{
|
||||||
f.Read( &ptr->frames[j].start, sizeof( int64_t ) );
|
f.Read( &ptr->frames[j].start, sizeof( int64_t ) );
|
||||||
ptr->frames[j].end = -1;
|
ptr->frames[j].end = -1;
|
||||||
|
ptr->frames[j].frameImage = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
f.Read( ptr->frames.data(), sizeof( FrameEvent ) * fsz );
|
for( uint64_t j=0; j<fsz; j++ )
|
||||||
|
{
|
||||||
|
f.Read( &ptr->frames[j].start, sizeof( int64_t ) );
|
||||||
|
f.Read( &ptr->frames[j].end, sizeof( int64_t ) );
|
||||||
|
ptr->frames[j].frameImage = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_data.frames.Data()[i] = ptr;
|
m_data.frames.Data()[i] = ptr;
|
||||||
@ -431,6 +461,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
|||||||
{
|
{
|
||||||
f.Read( &ptr->frames[i].start, sizeof( int64_t ) );
|
f.Read( &ptr->frames[i].start, sizeof( int64_t ) );
|
||||||
ptr->frames[i].end = -1;
|
ptr->frames[i].end = -1;
|
||||||
|
ptr->frames[i].frameImage = -1;
|
||||||
}
|
}
|
||||||
m_data.frames.Data().push_back( ptr );
|
m_data.frames.Data().push_back( ptr );
|
||||||
m_data.framesBase = ptr;
|
m_data.framesBase = ptr;
|
||||||
@ -1198,6 +1229,29 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( fileVer >= FileVersion( 0, 4, 9 ) )
|
||||||
|
{
|
||||||
|
if( eventMask & EventType::FrameImages )
|
||||||
|
{
|
||||||
|
f.Read( sz );
|
||||||
|
m_data.frameImage.reserve_exact( sz, m_slab );
|
||||||
|
for( uint64_t i=0; i<sz; i++ )
|
||||||
|
{
|
||||||
|
auto fi = m_slab.Alloc<FrameImage>();
|
||||||
|
f.Read2( fi->w, fi->h );
|
||||||
|
const auto sz = fi->w * fi->h * 4;
|
||||||
|
auto ptr = (char*)m_slab.AllocBig( sz );
|
||||||
|
f.Read( ptr, sz );
|
||||||
|
fi->ptr = ptr;
|
||||||
|
m_data.frameImage[i] = fi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Implement skip, if more data is added after frame image section
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
finishLoading:
|
finishLoading:
|
||||||
s_loadProgress.total.store( 0, std::memory_order_relaxed );
|
s_loadProgress.total.store( 0, std::memory_order_relaxed );
|
||||||
m_loadTime = std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now() - loadStart ).count();
|
m_loadTime = std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now() - loadStart ).count();
|
||||||
@ -4024,6 +4078,7 @@ void Worker::Write( FileWrite& f )
|
|||||||
for( auto& fe : fd->frames )
|
for( auto& fe : fd->frames )
|
||||||
{
|
{
|
||||||
WriteTimeOffset( f, refTime, fe.start );
|
WriteTimeOffset( f, refTime, fe.start );
|
||||||
|
f.Write( &fe.frameImage, sizeof( fe.frameImage ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -4032,6 +4087,7 @@ void Worker::Write( FileWrite& f )
|
|||||||
{
|
{
|
||||||
WriteTimeOffset( f, refTime, fe.start );
|
WriteTimeOffset( f, refTime, fe.start );
|
||||||
WriteTimeOffset( f, refTime, fe.end );
|
WriteTimeOffset( f, refTime, fe.end );
|
||||||
|
f.Write( &fe.frameImage, sizeof( fe.frameImage ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4254,6 +4310,15 @@ void Worker::Write( FileWrite& f )
|
|||||||
f.Write( &frame.second->size, sizeof( frame.second->size ) );
|
f.Write( &frame.second->size, sizeof( frame.second->size ) );
|
||||||
f.Write( frame.second->data, sizeof( CallstackFrame ) * frame.second->size );
|
f.Write( frame.second->data, sizeof( CallstackFrame ) * frame.second->size );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sz = m_data.frameImage.size();
|
||||||
|
f.Write( &sz, sizeof( sz ) );
|
||||||
|
for( auto& fi : m_data.frameImage )
|
||||||
|
{
|
||||||
|
f.Write( &fi->w, sizeof( fi->w ) );
|
||||||
|
f.Write( &fi->h, sizeof( fi->h ) );
|
||||||
|
f.Write( fi->ptr, fi->w * fi->h * 4 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker::WriteTimeline( FileWrite& f, const Vector<ZoneEvent*>& vec, int64_t& refTime )
|
void Worker::WriteTimeline( FileWrite& f, const Vector<ZoneEvent*>& vec, int64_t& refTime )
|
||||||
|
@ -34,6 +34,7 @@ namespace EventType
|
|||||||
Messages = 1 << 1,
|
Messages = 1 << 1,
|
||||||
Plots = 1 << 2,
|
Plots = 1 << 2,
|
||||||
Memory = 1 << 3,
|
Memory = 1 << 3,
|
||||||
|
FrameImages = 1 << 4,
|
||||||
|
|
||||||
None = 0,
|
None = 0,
|
||||||
All = std::numeric_limits<uint32_t>::max()
|
All = std::numeric_limits<uint32_t>::max()
|
||||||
|
Loading…
Reference in New Issue
Block a user