mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-23 14:54:34 +00:00
Store frame images in queue.
This commit is contained in:
parent
fc106079c5
commit
f565e11976
@ -953,6 +953,8 @@ Profiler::Profiler()
|
|||||||
, m_lz4Buf( (char*)tracy_malloc( LZ4Size + sizeof( lz4sz_t ) ) )
|
, m_lz4Buf( (char*)tracy_malloc( LZ4Size + sizeof( lz4sz_t ) ) )
|
||||||
, m_serialQueue( 1024*1024 )
|
, m_serialQueue( 1024*1024 )
|
||||||
, m_serialDequeue( 1024*1024 )
|
, m_serialDequeue( 1024*1024 )
|
||||||
|
, m_fiQueue( 16 )
|
||||||
|
, m_fiDequeue( 16 )
|
||||||
, m_etc1Buf( nullptr )
|
, m_etc1Buf( nullptr )
|
||||||
, m_etc1BufSize( 0 )
|
, m_etc1BufSize( 0 )
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
|
@ -89,6 +89,16 @@ extern int64_t (*GetTimeImpl)();
|
|||||||
|
|
||||||
class Profiler
|
class Profiler
|
||||||
{
|
{
|
||||||
|
struct FrameImageQueueItem
|
||||||
|
{
|
||||||
|
void* image;
|
||||||
|
int64_t time;
|
||||||
|
uint16_t w;
|
||||||
|
uint16_t h;
|
||||||
|
uint8_t offset;
|
||||||
|
bool flip;
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Profiler();
|
Profiler();
|
||||||
~Profiler();
|
~Profiler();
|
||||||
@ -175,24 +185,25 @@ public:
|
|||||||
|
|
||||||
static tracy_force_inline void SendFrameImage( void* image, uint16_t w, uint16_t h, uint8_t offset, bool flip )
|
static tracy_force_inline void SendFrameImage( void* image, uint16_t w, uint16_t h, uint8_t offset, bool flip )
|
||||||
{
|
{
|
||||||
|
auto& profiler = GetProfiler();
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( !GetProfiler().IsConnected() ) return;
|
if( !profiler.IsConnected() ) return;
|
||||||
#endif
|
#endif
|
||||||
|
const auto time = GetTime();
|
||||||
const auto sz = size_t( w ) * size_t( h ) * 4;
|
const auto sz = size_t( w ) * size_t( h ) * 4;
|
||||||
Magic magic;
|
|
||||||
auto token = GetToken();
|
|
||||||
auto ptr = (char*)tracy_malloc( sz );
|
auto ptr = (char*)tracy_malloc( sz );
|
||||||
memcpy( ptr, image, sz );
|
memcpy( ptr, image, sz );
|
||||||
auto& tail = token->get_tail_index();
|
|
||||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
profiler.m_fiLock.lock();
|
||||||
MemWrite( &item->hdr.type, QueueType::FrameImage );
|
auto fi = profiler.m_fiQueue.prepare_next();
|
||||||
MemWrite( &item->frameImage.image, (uint64_t)ptr );
|
fi->image = ptr;
|
||||||
MemWrite( &item->frameImage.w, w );
|
fi->time = time;
|
||||||
MemWrite( &item->frameImage.h, h );
|
fi->w = w;
|
||||||
MemWrite( &item->frameImage.offset, offset );
|
fi->h = h;
|
||||||
uint8_t _flip = flip;
|
fi->offset = offset;
|
||||||
MemWrite( &item->frameImage.flip, _flip );
|
fi->flip = flip;
|
||||||
tail.store( magic + 1, std::memory_order_release );
|
profiler.m_fiQueue.commit_next();
|
||||||
|
profiler.m_fiLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static tracy_force_inline void PlotData( const char* name, int64_t val )
|
static tracy_force_inline void PlotData( const char* name, int64_t val )
|
||||||
@ -537,6 +548,9 @@ private:
|
|||||||
FastVector<QueueItem> m_serialQueue, m_serialDequeue;
|
FastVector<QueueItem> m_serialQueue, m_serialDequeue;
|
||||||
TracyMutex m_serialLock;
|
TracyMutex m_serialLock;
|
||||||
|
|
||||||
|
FastVector<FrameImageQueueItem> m_fiQueue, m_fiDequeue;
|
||||||
|
TracyMutex m_fiLock;
|
||||||
|
|
||||||
char* m_etc1Buf;
|
char* m_etc1Buf;
|
||||||
size_t m_etc1BufSize;
|
size_t m_etc1BufSize;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user