mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-30 01:04:36 +00:00
Allow adding custom colors to zones.
This commit is contained in:
parent
93fc85a639
commit
519cb8dff3
@ -4,6 +4,8 @@
|
|||||||
#ifdef TRACY_DISABLE
|
#ifdef TRACY_DISABLE
|
||||||
|
|
||||||
#define ZoneScoped
|
#define ZoneScoped
|
||||||
|
#define ZoneScopedC(x)
|
||||||
|
|
||||||
#define FrameMark
|
#define FrameMark
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -11,7 +13,9 @@
|
|||||||
#include "TracyProfiler.hpp"
|
#include "TracyProfiler.hpp"
|
||||||
#include "TracyScoped.hpp"
|
#include "TracyScoped.hpp"
|
||||||
|
|
||||||
#define ZoneScoped tracy::ScopedZone ___tracy_scoped_zone( __FILE__, __FUNCTION__, __LINE__ );
|
#define ZoneScoped tracy::ScopedZone ___tracy_scoped_zone( __FILE__, __FUNCTION__, __LINE__, 0 );
|
||||||
|
#define ZoneScopedC( color ) tracy::ScopedZone ___tracy_scoped_zone( __FILE__, __FUNCTION__, __LINE__, color );
|
||||||
|
|
||||||
#define FrameMark tracy::Profiler::FrameMark();
|
#define FrameMark tracy::Profiler::FrameMark();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -288,7 +288,7 @@ void Profiler::CalibrateTimer()
|
|||||||
class FakeZone
|
class FakeZone
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FakeZone( const char* file, const char* function, uint32_t line ) {}
|
FakeZone( const char* file, const char* function, uint32_t line, uint32_t color ) {}
|
||||||
~FakeZone() {}
|
~FakeZone() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -302,17 +302,17 @@ void Profiler::CalibrateDelay()
|
|||||||
static_assert( Events * 2 < QueuePrealloc, "Delay calibration loop will allocate memory in queue" );
|
static_assert( Events * 2 < QueuePrealloc, "Delay calibration loop will allocate memory in queue" );
|
||||||
for( int i=0; i<Iterations; i++ )
|
for( int i=0; i<Iterations; i++ )
|
||||||
{
|
{
|
||||||
ScopedZone ___tracy_scoped_zone( __FILE__, __FUNCTION__, __LINE__ );
|
ScopedZone ___tracy_scoped_zone( __FILE__, __FUNCTION__, __LINE__, 0 );
|
||||||
}
|
}
|
||||||
const auto f0 = GetTime();
|
const auto f0 = GetTime();
|
||||||
for( int i=0; i<Iterations; i++ )
|
for( int i=0; i<Iterations; i++ )
|
||||||
{
|
{
|
||||||
FakeZone ___tracy_scoped_zone( __FILE__, __FUNCTION__, __LINE__ );
|
FakeZone ___tracy_scoped_zone( __FILE__, __FUNCTION__, __LINE__, 0 );
|
||||||
}
|
}
|
||||||
const auto t0 = GetTime();
|
const auto t0 = GetTime();
|
||||||
for( int i=0; i<Iterations; i++ )
|
for( int i=0; i<Iterations; i++ )
|
||||||
{
|
{
|
||||||
ScopedZone ___tracy_scoped_zone( __FILE__, __FUNCTION__, __LINE__ );
|
ScopedZone ___tracy_scoped_zone( __FILE__, __FUNCTION__, __LINE__, 0 );
|
||||||
}
|
}
|
||||||
const auto t1 = GetTime();
|
const auto t1 = GetTime();
|
||||||
const auto dt = t1 - t0;
|
const auto dt = t1 - t0;
|
||||||
|
@ -12,8 +12,8 @@ namespace tracy
|
|||||||
class ScopedZone
|
class ScopedZone
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScopedZone( const char* file, const char* function, uint32_t line )
|
ScopedZone( const char* file, const char* function, uint32_t line, uint32_t color )
|
||||||
: m_id( Profiler::ZoneBegin( QueueZoneBegin { Profiler::GetTime(), (uint64_t)file, (uint64_t)function, line, GetThreadHandle() } ) )
|
: m_id( Profiler::ZoneBegin( QueueZoneBegin { Profiler::GetTime(), (uint64_t)file, (uint64_t)function, line, GetThreadHandle(), color } ) )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ struct QueueZoneBegin
|
|||||||
uint64_t function; // ptr
|
uint64_t function; // ptr
|
||||||
uint32_t line;
|
uint32_t line;
|
||||||
uint64_t thread;
|
uint64_t thread;
|
||||||
|
uint32_t color;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct QueueZoneEnd
|
struct QueueZoneEnd
|
||||||
|
@ -11,6 +11,7 @@ struct Event
|
|||||||
int64_t start;
|
int64_t start;
|
||||||
int64_t end;
|
int64_t end;
|
||||||
uint32_t srcloc;
|
uint32_t srcloc;
|
||||||
|
uint32_t color;
|
||||||
|
|
||||||
Event* parent;
|
Event* parent;
|
||||||
Vector<Event*> child;
|
Vector<Event*> child;
|
||||||
|
@ -232,6 +232,7 @@ void View::ProcessZoneBegin( uint64_t id, const QueueZoneBegin& ev )
|
|||||||
CheckString( ev.function );
|
CheckString( ev.function );
|
||||||
CheckThreadString( ev.thread );
|
CheckThreadString( ev.thread );
|
||||||
zone->start = ev.time;
|
zone->start = ev.time;
|
||||||
|
zone->color = ev.color;
|
||||||
|
|
||||||
SourceLocation srcloc { ev.filename, ev.function, ev.line };
|
SourceLocation srcloc { ev.filename, ev.function, ev.line };
|
||||||
auto lit = m_locationRef.find( srcloc );
|
auto lit = m_locationRef.find( srcloc );
|
||||||
@ -1007,6 +1008,7 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
|
|||||||
while( it < zitend )
|
while( it < zitend )
|
||||||
{
|
{
|
||||||
auto& ev = **it;
|
auto& ev = **it;
|
||||||
|
const auto color = ev.color != 0 ? ( ev.color | 0xFF000000 ) : 0xDDDD6666;
|
||||||
const auto end = GetZoneEnd( ev );
|
const auto end = GetZoneEnd( ev );
|
||||||
const auto zsz = ( ev.end - ev.start ) * pxns;
|
const auto zsz = ( ev.end - ev.start ) * pxns;
|
||||||
if( zsz < MinVisSize )
|
if( zsz < MinVisSize )
|
||||||
@ -1026,7 +1028,7 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
|
|||||||
rend = nend;
|
rend = nend;
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
draw->AddRectFilled( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( px1, double( w + 10 ) ), offset + ostep ), 0xDDDD6666, 2.f );
|
draw->AddRectFilled( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( px1, double( w + 10 ) ), offset + ostep ), color, 2.f );
|
||||||
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( px1, double( w + 10 ) ), offset + ostep ) ) )
|
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( std::max( px0, -10.0 ), offset ), wpos + ImVec2( std::min( px1, double( w + 10 ) ), offset + ostep ) ) )
|
||||||
{
|
{
|
||||||
ImGui::BeginTooltip();
|
ImGui::BeginTooltip();
|
||||||
@ -1044,7 +1046,7 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
|
|||||||
const auto pr1 = ( end - m_zvStart ) * pxns;
|
const auto pr1 = ( end - m_zvStart ) * pxns;
|
||||||
const auto px0 = std::max( pr0, -10.0 );
|
const auto px0 = std::max( pr0, -10.0 );
|
||||||
const auto px1 = std::min( pr1, double( w + 10 ) );
|
const auto px1 = std::min( pr1, double( w + 10 ) );
|
||||||
draw->AddRectFilled( wpos + ImVec2( px0, offset ), wpos + ImVec2( px1, offset + tsz.y ), 0xDDDD6666, 2.f );
|
draw->AddRectFilled( wpos + ImVec2( px0, offset ), wpos + ImVec2( px1, offset + tsz.y ), color, 2.f );
|
||||||
draw->AddRect( wpos + ImVec2( px0, offset ), wpos + ImVec2( px1, offset + tsz.y ), 0xAAAAAAAA, 2.f );
|
draw->AddRect( wpos + ImVec2( px0, offset ), wpos + ImVec2( px1, offset + tsz.y ), 0xAAAAAAAA, 2.f );
|
||||||
if( dsz >= MinVisSize )
|
if( dsz >= MinVisSize )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user