2017-09-12 23:33:50 +00:00
|
|
|
#ifndef __TRACYVIEW_HPP__
|
|
|
|
#define __TRACYVIEW_HPP__
|
|
|
|
|
|
|
|
#include <atomic>
|
2017-09-14 00:00:13 +00:00
|
|
|
#include <mutex>
|
2017-09-12 23:33:50 +00:00
|
|
|
#include <string>
|
|
|
|
#include <thread>
|
2017-09-14 00:00:13 +00:00
|
|
|
#include <unordered_map>
|
2017-09-14 00:16:51 +00:00
|
|
|
#include <unordered_set>
|
2017-09-14 00:00:13 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2017-09-17 11:10:42 +00:00
|
|
|
#include "../common/tracy_lz4.hpp"
|
2017-09-14 00:15:04 +00:00
|
|
|
#include "../common/TracySocket.hpp"
|
2017-09-14 00:00:13 +00:00
|
|
|
#include "../common/TracyQueue.hpp"
|
|
|
|
#include "TracyEvent.hpp"
|
2017-09-15 17:56:55 +00:00
|
|
|
#include "TracySlab.hpp"
|
2017-09-15 18:17:39 +00:00
|
|
|
#include "TracyVector.hpp"
|
2017-09-12 23:33:50 +00:00
|
|
|
|
|
|
|
namespace tracy
|
|
|
|
{
|
|
|
|
|
2017-09-13 21:40:28 +00:00
|
|
|
struct QueueItem;
|
|
|
|
|
2017-09-12 23:33:50 +00:00
|
|
|
class View
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
View() : View( "127.0.0.1" ) {}
|
|
|
|
View( const char* addr );
|
|
|
|
~View();
|
|
|
|
|
2017-09-13 00:08:35 +00:00
|
|
|
static bool ShouldExit();
|
2017-09-15 00:30:22 +00:00
|
|
|
static void Draw();
|
2017-09-13 00:08:35 +00:00
|
|
|
|
2017-09-12 23:33:50 +00:00
|
|
|
private:
|
|
|
|
void Worker();
|
|
|
|
|
2017-09-14 17:44:49 +00:00
|
|
|
void DispatchProcess( const QueueItem& ev );
|
|
|
|
void DispatchProcess( const QueueItem& ev, const char*& ptr );
|
|
|
|
|
|
|
|
void Process( const QueueItem& ev );
|
2017-09-14 00:00:13 +00:00
|
|
|
void ProcessZoneBegin( uint64_t id, const QueueZoneBegin& ev );
|
|
|
|
void ProcessZoneEnd( uint64_t id, const QueueZoneEnd& ev );
|
2017-09-15 22:40:51 +00:00
|
|
|
void ProcessFrameMark( uint64_t id );
|
2017-09-14 00:00:13 +00:00
|
|
|
|
2017-09-14 00:16:51 +00:00
|
|
|
void CheckString( uint64_t ptr );
|
2017-09-14 17:43:40 +00:00
|
|
|
void AddString( uint64_t ptr, std::string&& str );
|
2017-09-14 00:16:51 +00:00
|
|
|
|
2017-09-15 17:56:55 +00:00
|
|
|
void NewZone( Event* zone );
|
|
|
|
void UpdateZone( Event* zone );
|
2017-09-14 19:05:01 +00:00
|
|
|
|
2017-09-18 19:26:22 +00:00
|
|
|
uint64_t GetFrameTime( size_t idx ) const;
|
|
|
|
uint64_t GetLastTime() const;
|
2017-09-18 20:11:38 +00:00
|
|
|
const char* TimeToString( uint64_t ns ) const;
|
2017-09-18 00:22:59 +00:00
|
|
|
|
2017-09-15 00:30:22 +00:00
|
|
|
void DrawImpl();
|
2017-09-18 00:37:25 +00:00
|
|
|
void DrawFrames();
|
2017-09-15 00:30:22 +00:00
|
|
|
|
2017-09-12 23:33:50 +00:00
|
|
|
std::string m_addr;
|
|
|
|
|
2017-09-14 00:15:04 +00:00
|
|
|
Socket m_sock;
|
2017-09-12 23:33:50 +00:00
|
|
|
std::thread m_thread;
|
|
|
|
std::atomic<bool> m_shutdown;
|
2017-09-17 22:31:09 +00:00
|
|
|
std::atomic<bool> m_connected;
|
2017-09-20 18:38:12 +00:00
|
|
|
std::atomic<bool> m_hasData;
|
2017-09-12 23:54:22 +00:00
|
|
|
|
2017-09-14 17:43:40 +00:00
|
|
|
// this block must be locked
|
2017-09-14 00:00:13 +00:00
|
|
|
std::mutex m_lock;
|
2017-09-15 18:17:39 +00:00
|
|
|
Vector<Event*> m_timeline;
|
2017-09-15 22:40:51 +00:00
|
|
|
Vector<uint64_t> m_frames;
|
2017-09-14 00:16:51 +00:00
|
|
|
std::unordered_map<uint64_t, std::string> m_strings;
|
2017-09-14 00:00:13 +00:00
|
|
|
|
2017-09-15 18:31:59 +00:00
|
|
|
std::mutex m_mbpslock;
|
|
|
|
std::vector<float> m_mbps;
|
|
|
|
|
2017-09-14 00:00:13 +00:00
|
|
|
// not used for vis - no need to lock
|
|
|
|
std::unordered_map<uint64_t, QueueZoneEnd> m_pendingEndZone;
|
2017-09-15 17:56:55 +00:00
|
|
|
std::unordered_map<uint64_t, Event*> m_openZones;
|
2017-09-14 00:16:51 +00:00
|
|
|
std::unordered_set<uint64_t> m_pendingStrings;
|
2017-09-15 17:56:55 +00:00
|
|
|
|
|
|
|
Slab<EventSize*1024*1024> m_slab;
|
2017-09-17 11:10:42 +00:00
|
|
|
|
|
|
|
LZ4_streamDecode_t* m_stream;
|
|
|
|
char* m_buffer;
|
|
|
|
int m_bufferOffset;
|
2017-09-18 00:37:25 +00:00
|
|
|
|
|
|
|
int m_frameScale;
|
2017-09-18 22:26:40 +00:00
|
|
|
bool m_pause;
|
|
|
|
int m_frameStart;
|
2017-09-20 19:21:21 +00:00
|
|
|
|
|
|
|
uint64_t m_zvStart;
|
|
|
|
uint64_t m_zvEnd;
|
2017-09-12 23:33:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|