2017-09-12 23:33:50 +00:00
|
|
|
#ifndef __TRACYVIEW_HPP__
|
|
|
|
#define __TRACYVIEW_HPP__
|
|
|
|
|
|
|
|
#include <atomic>
|
2018-04-02 00:19:46 +00:00
|
|
|
#include <functional>
|
2017-10-24 20:30:43 +00:00
|
|
|
#include <map>
|
2017-09-12 23:33:50 +00:00
|
|
|
#include <string>
|
|
|
|
#include <thread>
|
2017-09-14 00:00:13 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2018-08-05 14:45:34 +00:00
|
|
|
#include "TracyDecayValue.hpp"
|
2017-09-15 18:17:39 +00:00
|
|
|
#include "TracyVector.hpp"
|
2018-02-13 13:57:47 +00:00
|
|
|
#include "TracyWorker.hpp"
|
2017-11-15 22:15:59 +00:00
|
|
|
#include "tracy_flat_hash_map.hpp"
|
2017-09-12 23:33:50 +00:00
|
|
|
|
2017-09-23 22:07:06 +00:00
|
|
|
struct ImVec2;
|
|
|
|
|
2017-09-12 23:33:50 +00:00
|
|
|
namespace tracy
|
|
|
|
{
|
|
|
|
|
2017-09-13 21:40:28 +00:00
|
|
|
struct QueueItem;
|
2017-09-30 14:58:02 +00:00
|
|
|
class FileRead;
|
2017-09-13 21:40:28 +00:00
|
|
|
|
2017-09-12 23:33:50 +00:00
|
|
|
class View
|
|
|
|
{
|
2017-11-27 21:41:30 +00:00
|
|
|
struct Animation
|
|
|
|
{
|
|
|
|
bool active = false;
|
|
|
|
int64_t start0, start1;
|
|
|
|
int64_t end0, end1;
|
|
|
|
double progress;
|
|
|
|
double lenMod;
|
|
|
|
};
|
|
|
|
|
2018-03-04 21:21:35 +00:00
|
|
|
struct Region
|
|
|
|
{
|
|
|
|
bool active = false;
|
|
|
|
int64_t start;
|
|
|
|
int64_t end;
|
|
|
|
};
|
|
|
|
|
2017-09-12 23:33:50 +00:00
|
|
|
public:
|
|
|
|
View() : View( "127.0.0.1" ) {}
|
|
|
|
View( const char* addr );
|
2017-09-30 14:58:02 +00:00
|
|
|
View( FileRead& f );
|
2017-09-12 23:33:50 +00:00
|
|
|
~View();
|
|
|
|
|
2018-04-29 23:16:08 +00:00
|
|
|
static bool Draw();
|
2017-09-13 00:08:35 +00:00
|
|
|
|
2017-09-12 23:33:50 +00:00
|
|
|
private:
|
2017-10-22 11:56:05 +00:00
|
|
|
enum class Namespace : uint8_t
|
|
|
|
{
|
|
|
|
Full,
|
|
|
|
Mid,
|
|
|
|
Short
|
|
|
|
};
|
|
|
|
|
|
|
|
const char* ShortenNamespace( const char* name ) const;
|
|
|
|
|
2018-01-17 11:49:50 +00:00
|
|
|
void DrawHelpMarker( const char* desc ) const;
|
|
|
|
|
2017-11-25 14:45:16 +00:00
|
|
|
void DrawTextContrast( ImDrawList* draw, const ImVec2& pos, uint32_t color, const char* text );
|
|
|
|
|
2018-04-29 23:16:08 +00:00
|
|
|
bool DrawImpl();
|
2017-09-30 12:37:21 +00:00
|
|
|
void DrawConnection();
|
2017-09-18 00:37:25 +00:00
|
|
|
void DrawFrames();
|
2018-08-04 19:10:03 +00:00
|
|
|
bool DrawZoneFramesHeader();
|
|
|
|
bool DrawZoneFrames( const FrameData& frames );
|
2017-09-20 22:57:26 +00:00
|
|
|
void DrawZones();
|
2018-04-20 21:19:04 +00:00
|
|
|
int DispatchZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth, float yMin, float yMax );
|
|
|
|
int DrawZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth, float yMin, float yMax );
|
|
|
|
int SkipZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth, float yMin, float yMax );
|
2018-06-27 23:12:25 +00:00
|
|
|
int DispatchGpuZoneLevel( const Vector<GpuEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth, uint64_t thread, float yMin, float yMax, int64_t begin, int drift );
|
|
|
|
int DrawGpuZoneLevel( const Vector<GpuEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth, uint64_t thread, float yMin, float yMax, int64_t begin, int drift );
|
|
|
|
int SkipGpuZoneLevel( const Vector<GpuEvent*>& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth, uint64_t thread, float yMin, float yMax, int64_t begin, int drift );
|
2018-04-20 20:53:15 +00:00
|
|
|
int DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos, int offset, LockHighlight& highlight, float yMin, float yMax );
|
2018-04-20 21:00:26 +00:00
|
|
|
int DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, float yMin, float yMax );
|
2018-06-28 22:38:56 +00:00
|
|
|
void DrawPlotPoint( const ImVec2& wpos, float x, float y, int offset, uint32_t color, bool hover, bool hasPrev, const PlotItem* item, double prev, bool merged, PlotType type, float PlotHeight );
|
|
|
|
void DrawPlotPoint( const ImVec2& wpos, float x, float y, int offset, uint32_t color, bool hover, bool hasPrev, double val, double prev, bool merged, float PlotHeight );
|
2017-10-13 11:32:23 +00:00
|
|
|
void DrawOptions();
|
2017-10-14 12:36:30 +00:00
|
|
|
void DrawMessages();
|
2018-01-17 11:49:50 +00:00
|
|
|
void DrawFindZone();
|
2018-03-24 13:40:48 +00:00
|
|
|
void DrawStatistics();
|
2018-04-01 18:34:21 +00:00
|
|
|
void DrawMemory();
|
2018-04-21 22:52:33 +00:00
|
|
|
void DrawCompare();
|
2018-06-20 11:23:08 +00:00
|
|
|
void DrawCallstackWindow();
|
2018-07-17 21:03:03 +00:00
|
|
|
void DrawMemoryAllocWindow();
|
2017-09-15 00:30:22 +00:00
|
|
|
|
2018-04-02 00:19:46 +00:00
|
|
|
template<class T>
|
2018-07-17 21:13:56 +00:00
|
|
|
void ListMemData( T ptr, T end, std::function<void(T&)> DrawAddress, const char* id = nullptr );
|
2018-04-02 00:19:46 +00:00
|
|
|
|
2017-11-12 00:25:44 +00:00
|
|
|
void DrawInfoWindow();
|
|
|
|
void DrawZoneInfoWindow();
|
|
|
|
void DrawGpuInfoWindow();
|
|
|
|
|
2017-10-12 20:27:17 +00:00
|
|
|
void HandleZoneViewMouse( int64_t timespan, const ImVec2& wpos, float w, double& pxns );
|
|
|
|
|
2017-10-22 13:37:24 +00:00
|
|
|
uint32_t GetZoneColor( const ZoneEvent& ev );
|
2017-11-11 21:56:05 +00:00
|
|
|
uint32_t GetZoneColor( const GpuEvent& ev );
|
2017-10-22 13:37:24 +00:00
|
|
|
uint32_t GetZoneHighlight( const ZoneEvent& ev, bool migration );
|
2017-11-11 21:56:05 +00:00
|
|
|
uint32_t GetZoneHighlight( const GpuEvent& ev );
|
2017-10-22 13:37:24 +00:00
|
|
|
float GetZoneThickness( const ZoneEvent& ev );
|
2017-11-11 21:56:05 +00:00
|
|
|
float GetZoneThickness( const GpuEvent& ev );
|
2017-10-01 17:31:22 +00:00
|
|
|
|
2017-10-22 13:37:24 +00:00
|
|
|
void ZoomToZone( const ZoneEvent& ev );
|
2017-11-11 21:56:05 +00:00
|
|
|
void ZoomToZone( const GpuEvent& ev );
|
2017-11-27 21:12:26 +00:00
|
|
|
void ZoomToRange( int64_t start, int64_t end );
|
2018-06-02 20:27:35 +00:00
|
|
|
void ZoomToPrevFrame();
|
|
|
|
void ZoomToNextFrame();
|
2018-06-22 18:21:02 +00:00
|
|
|
void CenterAtTime( int64_t t );
|
2017-11-27 21:12:26 +00:00
|
|
|
|
2018-05-02 17:23:46 +00:00
|
|
|
void ShowZoneInfo( const ZoneEvent& ev );
|
|
|
|
void ShowZoneInfo( const GpuEvent& ev, uint64_t thread );
|
|
|
|
|
2017-10-22 13:37:24 +00:00
|
|
|
void ZoneTooltip( const ZoneEvent& ev );
|
2017-11-11 21:56:05 +00:00
|
|
|
void ZoneTooltip( const GpuEvent& ev );
|
2018-06-19 20:19:33 +00:00
|
|
|
void CallstackTooltip( uint32_t idx );
|
|
|
|
|
2017-10-22 14:15:27 +00:00
|
|
|
const ZoneEvent* GetZoneParent( const ZoneEvent& zone ) const;
|
2017-11-12 00:25:44 +00:00
|
|
|
const GpuEvent* GetZoneParent( const GpuEvent& zone ) const;
|
2018-03-18 15:38:42 +00:00
|
|
|
uint64_t GetZoneThread( const ZoneEvent& zone ) const;
|
2018-03-19 15:11:37 +00:00
|
|
|
uint64_t GetZoneThread( const GpuEvent& zone ) const;
|
2018-06-27 23:07:21 +00:00
|
|
|
const GpuCtxData* GetZoneCtx( const GpuEvent& zone ) const;
|
2018-04-01 19:47:08 +00:00
|
|
|
const ZoneEvent* FindZoneAtTime( uint64_t thread, int64_t time ) const;
|
2018-08-04 19:19:24 +00:00
|
|
|
const char* GetFrameText( const FrameData& fd, int i, uint64_t ftime, uint64_t offset ) const;
|
2017-09-29 19:57:00 +00:00
|
|
|
|
2018-03-18 11:55:54 +00:00
|
|
|
#ifndef TRACY_NO_STATISTICS
|
2018-01-17 11:49:50 +00:00
|
|
|
void FindZones();
|
2018-04-21 22:52:33 +00:00
|
|
|
void FindZonesCompare();
|
2018-03-18 11:55:54 +00:00
|
|
|
#endif
|
2018-01-17 11:49:50 +00:00
|
|
|
|
2018-05-01 15:26:34 +00:00
|
|
|
std::pair<int8_t*, size_t> GetMemoryPages() const;
|
2018-04-28 13:49:51 +00:00
|
|
|
const char* GetPlotName( const PlotData* plot ) const;
|
2018-04-02 16:14:59 +00:00
|
|
|
|
2018-07-17 20:53:38 +00:00
|
|
|
void SmallCallstackButton( const char* name, uint32_t callstack, int& idx );
|
|
|
|
|
2018-03-20 14:33:38 +00:00
|
|
|
flat_hash_map<const void*, bool, nohash<const void*>> m_visible;
|
|
|
|
flat_hash_map<const void*, bool, nohash<const void*>> m_showFull;
|
2018-06-27 23:08:08 +00:00
|
|
|
flat_hash_map<const void*, int, nohash<const void*>> m_gpuDrift;
|
2018-03-20 14:33:38 +00:00
|
|
|
|
|
|
|
tracy_force_inline bool& Visible( const void* ptr )
|
2018-02-13 13:57:47 +00:00
|
|
|
{
|
2018-03-20 14:33:38 +00:00
|
|
|
auto it = m_visible.find( ptr );
|
|
|
|
if( it == m_visible.end() )
|
2018-02-13 13:57:47 +00:00
|
|
|
{
|
2018-03-20 14:33:38 +00:00
|
|
|
it = m_visible.emplace( ptr, true ).first;
|
2018-02-13 13:57:47 +00:00
|
|
|
}
|
2018-03-20 14:33:38 +00:00
|
|
|
return it->second;
|
2018-02-13 13:57:47 +00:00
|
|
|
}
|
2017-09-30 14:20:08 +00:00
|
|
|
|
2018-03-20 14:33:38 +00:00
|
|
|
tracy_force_inline bool& ShowFull( const void* ptr )
|
2018-02-13 13:57:47 +00:00
|
|
|
{
|
2018-03-20 14:33:38 +00:00
|
|
|
auto it = m_showFull.find( ptr );
|
|
|
|
if( it == m_showFull.end() )
|
2018-02-13 13:57:47 +00:00
|
|
|
{
|
2018-03-20 14:33:38 +00:00
|
|
|
it = m_showFull.emplace( ptr, true ).first;
|
2018-02-13 13:57:47 +00:00
|
|
|
}
|
2018-03-20 14:33:38 +00:00
|
|
|
return it->second;
|
2018-02-13 13:57:47 +00:00
|
|
|
}
|
2017-09-12 23:33:50 +00:00
|
|
|
|
2018-06-27 23:08:08 +00:00
|
|
|
tracy_force_inline int& GpuDrift( const void* ptr )
|
|
|
|
{
|
|
|
|
auto it = m_gpuDrift.find( ptr );
|
|
|
|
if( it == m_gpuDrift.end() )
|
|
|
|
{
|
|
|
|
it = m_gpuDrift.emplace( ptr, 0 ).first;
|
|
|
|
}
|
|
|
|
return it->second;
|
|
|
|
}
|
|
|
|
|
2018-02-13 13:57:47 +00:00
|
|
|
Worker m_worker;
|
2017-09-30 14:58:02 +00:00
|
|
|
bool m_staticView;
|
2017-09-12 23:54:22 +00:00
|
|
|
|
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
|
|
|
|
2017-09-20 23:13:23 +00:00
|
|
|
int64_t m_zvStart;
|
|
|
|
int64_t m_zvEnd;
|
2017-12-09 19:05:34 +00:00
|
|
|
int64_t m_lastTime;
|
2017-09-24 14:10:28 +00:00
|
|
|
|
2017-10-01 17:58:53 +00:00
|
|
|
int8_t m_lastCpu;
|
|
|
|
|
2017-10-28 19:50:06 +00:00
|
|
|
int m_zvHeight;
|
|
|
|
int m_zvScroll;
|
2017-10-12 20:27:17 +00:00
|
|
|
|
2017-10-22 13:37:24 +00:00
|
|
|
const ZoneEvent* m_zoneInfoWindow;
|
|
|
|
const ZoneEvent* m_zoneHighlight;
|
2018-08-05 14:45:34 +00:00
|
|
|
DecayValue<uint64_t> m_zoneSrcLocHighlight;
|
2017-10-08 21:03:38 +00:00
|
|
|
LockHighlight m_lockHighlight;
|
2018-08-05 14:45:34 +00:00
|
|
|
DecayValue<const MessageData*> m_msgHighlight;
|
2018-08-05 14:57:21 +00:00
|
|
|
const MessageData* m_msgToFocus;
|
2017-11-12 00:25:44 +00:00
|
|
|
const GpuEvent* m_gpuInfoWindow;
|
2017-11-12 00:28:07 +00:00
|
|
|
const GpuEvent* m_gpuHighlight;
|
2017-11-13 23:48:26 +00:00
|
|
|
uint64_t m_gpuInfoWindowThread;
|
2018-06-20 11:23:08 +00:00
|
|
|
uint32_t m_callstackInfoWindow;
|
2018-07-19 13:43:45 +00:00
|
|
|
int64_t m_memoryAllocInfoWindow;
|
|
|
|
int64_t m_memoryAllocHover;
|
|
|
|
int m_memoryAllocHoverWait;
|
2018-08-04 17:47:09 +00:00
|
|
|
const FrameData* m_frames;
|
2017-10-13 11:32:23 +00:00
|
|
|
|
2018-03-04 21:21:35 +00:00
|
|
|
Region m_highlight;
|
2018-07-29 18:15:49 +00:00
|
|
|
Region m_highlightZoom;
|
2017-10-15 14:42:56 +00:00
|
|
|
|
2017-11-11 22:13:54 +00:00
|
|
|
uint64_t m_gpuThread;
|
|
|
|
int64_t m_gpuStart;
|
|
|
|
int64_t m_gpuEnd;
|
|
|
|
|
2017-10-13 11:32:23 +00:00
|
|
|
bool m_showOptions;
|
2017-10-14 12:36:30 +00:00
|
|
|
bool m_showMessages;
|
2018-03-24 13:40:48 +00:00
|
|
|
bool m_showStatistics;
|
2017-11-11 21:56:05 +00:00
|
|
|
bool m_drawGpuZones;
|
2017-10-13 11:32:23 +00:00
|
|
|
bool m_drawZones;
|
|
|
|
bool m_drawLocks;
|
2017-10-13 12:54:32 +00:00
|
|
|
bool m_drawPlots;
|
2017-10-22 11:32:27 +00:00
|
|
|
bool m_onlyContendedLocks;
|
2018-06-05 22:47:16 +00:00
|
|
|
|
2018-03-24 16:28:10 +00:00
|
|
|
int m_statSort;
|
2018-06-05 22:47:16 +00:00
|
|
|
bool m_statSelf;
|
2017-10-18 16:48:51 +00:00
|
|
|
|
2017-10-22 11:56:05 +00:00
|
|
|
Namespace m_namespace;
|
2017-11-27 21:41:30 +00:00
|
|
|
Animation m_zoomAnim;
|
2017-10-22 11:56:05 +00:00
|
|
|
|
2018-05-02 17:23:46 +00:00
|
|
|
Vector<const ZoneEvent*> m_zoneInfoStack;
|
|
|
|
Vector<const GpuEvent*> m_gpuInfoStack;
|
|
|
|
|
2018-07-21 18:26:13 +00:00
|
|
|
struct FindZone {
|
2018-03-20 13:37:58 +00:00
|
|
|
enum : uint64_t { Unselected = std::numeric_limits<uint64_t>::max() - 1 };
|
2018-07-21 18:26:13 +00:00
|
|
|
enum class GroupBy : int { Thread, UserText, Callstack };
|
2018-07-21 21:58:50 +00:00
|
|
|
enum class SortBy : int { Order, Count, Time };
|
2018-03-20 13:37:58 +00:00
|
|
|
|
2018-07-21 21:53:11 +00:00
|
|
|
struct Group
|
|
|
|
{
|
|
|
|
Vector<ZoneEvent*> zones;
|
|
|
|
int64_t time = 0;
|
|
|
|
};
|
|
|
|
|
2018-04-01 19:24:30 +00:00
|
|
|
bool show = false;
|
2018-03-18 15:07:07 +00:00
|
|
|
std::vector<int32_t> match;
|
2018-07-21 21:53:11 +00:00
|
|
|
std::map<uint64_t, Group> groups;
|
2018-03-18 15:41:58 +00:00
|
|
|
size_t processed;
|
2018-03-18 15:07:07 +00:00
|
|
|
int selMatch = 0;
|
2018-07-21 21:41:50 +00:00
|
|
|
uint64_t selGroup = Unselected;
|
2018-04-01 19:24:30 +00:00
|
|
|
char pattern[1024] = {};
|
2018-02-16 12:28:40 +00:00
|
|
|
bool logVal = false;
|
2018-04-21 20:21:15 +00:00
|
|
|
bool logTime = true;
|
2018-03-05 19:15:18 +00:00
|
|
|
bool cumulateTime = false;
|
2018-07-21 18:26:13 +00:00
|
|
|
GroupBy groupBy = GroupBy::Thread;
|
2018-07-21 21:58:50 +00:00
|
|
|
SortBy sortBy = SortBy::Order;
|
2018-03-04 21:52:36 +00:00
|
|
|
Region highlight;
|
2018-06-06 21:06:00 +00:00
|
|
|
int64_t numBins = -1;
|
|
|
|
std::unique_ptr<int64_t[]> bins, binTime, selBin;
|
2018-03-04 21:52:36 +00:00
|
|
|
|
|
|
|
void Reset()
|
|
|
|
{
|
2018-07-21 21:41:50 +00:00
|
|
|
ResetGroups();
|
2018-03-04 21:52:36 +00:00
|
|
|
match.clear();
|
2018-03-18 15:07:07 +00:00
|
|
|
selMatch = 0;
|
2018-07-21 21:41:50 +00:00
|
|
|
selGroup = Unselected;
|
2018-03-04 21:52:36 +00:00
|
|
|
highlight.active = false;
|
|
|
|
}
|
2018-03-18 15:41:58 +00:00
|
|
|
|
2018-07-21 21:41:50 +00:00
|
|
|
void ResetGroups()
|
2018-03-18 15:41:58 +00:00
|
|
|
{
|
2018-07-21 21:41:50 +00:00
|
|
|
groups.clear();
|
2018-03-18 15:41:58 +00:00
|
|
|
processed = 0;
|
|
|
|
}
|
2018-04-05 17:30:32 +00:00
|
|
|
|
|
|
|
void ShowZone( int32_t srcloc, const char* name )
|
|
|
|
{
|
|
|
|
show = true;
|
|
|
|
Reset();
|
|
|
|
match.emplace_back( srcloc );
|
|
|
|
strcpy( pattern, name );
|
|
|
|
}
|
2018-01-17 11:49:50 +00:00
|
|
|
} m_findZone;
|
2018-04-01 19:24:30 +00:00
|
|
|
|
2018-07-21 18:26:13 +00:00
|
|
|
tracy_force_inline uint64_t GetSelectionTarget( const Worker::ZoneThreadData& ev, FindZone::GroupBy groupBy ) const;
|
|
|
|
|
2018-06-06 21:09:46 +00:00
|
|
|
struct CompVal
|
|
|
|
{
|
|
|
|
double v0;
|
|
|
|
double v1;
|
|
|
|
};
|
|
|
|
|
2018-04-21 22:52:33 +00:00
|
|
|
struct {
|
|
|
|
bool show = false;
|
|
|
|
std::unique_ptr<Worker> second;
|
2018-07-28 16:47:33 +00:00
|
|
|
std::thread loadThread;
|
2018-04-21 22:52:33 +00:00
|
|
|
int badVer = 0;
|
|
|
|
char pattern[1024] = {};
|
|
|
|
std::vector<int32_t> match[2];
|
|
|
|
int selMatch[2] = { 0, 0 };
|
|
|
|
bool logVal = false;
|
|
|
|
bool logTime = true;
|
|
|
|
bool cumulateTime = false;
|
2018-04-22 00:19:22 +00:00
|
|
|
bool normalize = false;
|
2018-06-06 21:09:46 +00:00
|
|
|
int64_t numBins = -1;
|
|
|
|
std::unique_ptr<CompVal[]> bins, binTime;
|
2018-04-21 22:52:33 +00:00
|
|
|
|
|
|
|
void Reset()
|
|
|
|
{
|
|
|
|
for( int i=0; i<2; i++ )
|
|
|
|
{
|
|
|
|
match[i].clear();
|
|
|
|
selMatch[i] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} m_compare;
|
|
|
|
|
2018-04-01 19:24:30 +00:00
|
|
|
struct {
|
|
|
|
bool show = false;
|
|
|
|
char pattern[1024] = {};
|
|
|
|
uint64_t ptrFind = 0;
|
2018-04-02 14:07:33 +00:00
|
|
|
bool restrictTime = false;
|
2018-04-01 19:24:30 +00:00
|
|
|
} m_memInfo;
|
2017-09-12 23:33:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|