mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Use SPSC queue for frame images.
This commit is contained in:
+10
-11
@@ -8,6 +8,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#include "tracy_concurrentqueue.h"
|
||||
#include "tracy_readerwriterqueue.h"
|
||||
#include "TracyCallstack.hpp"
|
||||
#include "TracySysTime.hpp"
|
||||
#include "TracyFastVector.hpp"
|
||||
@@ -243,15 +244,14 @@ public:
|
||||
auto ptr = (char*)tracy_malloc( sz );
|
||||
memcpy( ptr, image, sz );
|
||||
|
||||
profiler.m_fiLock.lock();
|
||||
auto fi = profiler.m_fiQueue.prepare_next();
|
||||
fi->image = ptr;
|
||||
fi->frame = uint32_t( profiler.m_frameCount.load( std::memory_order_relaxed ) - offset );
|
||||
fi->w = w;
|
||||
fi->h = h;
|
||||
fi->flip = flip;
|
||||
profiler.m_fiQueue.commit_next();
|
||||
profiler.m_fiLock.unlock();
|
||||
profiler.m_fiQueue.emplace( FrameImageQueueItem {
|
||||
ptr,
|
||||
uint32_t( profiler.m_frameCount.load( std::memory_order_relaxed ) - offset ),
|
||||
w,
|
||||
h,
|
||||
0,
|
||||
flip
|
||||
} );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -810,8 +810,7 @@ private:
|
||||
TracyMutex m_serialLock;
|
||||
|
||||
#ifndef TRACY_NO_FRAME_IMAGE
|
||||
FastVector<FrameImageQueueItem> m_fiQueue, m_fiDequeue;
|
||||
TracyMutex m_fiLock;
|
||||
ReaderWriterQueue<FrameImageQueueItem> m_fiQueue;
|
||||
#endif
|
||||
|
||||
std::atomic<uint64_t> m_frameCount;
|
||||
|
||||
Reference in New Issue
Block a user