mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 07:54:36 +00:00
Store zone color in source location struct.
This commit is contained in:
parent
7424077d70
commit
e90a86e06e
@ -13,8 +13,8 @@
|
|||||||
#include "TracyProfiler.hpp"
|
#include "TracyProfiler.hpp"
|
||||||
#include "TracyScoped.hpp"
|
#include "TracyScoped.hpp"
|
||||||
|
|
||||||
#define ZoneScoped static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__ }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location, 0 );
|
#define ZoneScoped static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__, 0 }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location );
|
||||||
#define ZoneScopedC( color ) static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__ }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location, color );
|
#define ZoneScopedC( color ) static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__, color }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location );
|
||||||
|
|
||||||
#define FrameMark tracy::Profiler::FrameMark();
|
#define FrameMark tracy::Profiler::FrameMark();
|
||||||
|
|
||||||
|
@ -225,6 +225,7 @@ bool Profiler::SendSourceLocation( uint64_t ptr )
|
|||||||
item.srcloc.file = (uint64_t)srcloc->file;
|
item.srcloc.file = (uint64_t)srcloc->file;
|
||||||
item.srcloc.function = (uint64_t)srcloc->function;
|
item.srcloc.function = (uint64_t)srcloc->function;
|
||||||
item.srcloc.line = srcloc->line;
|
item.srcloc.line = srcloc->line;
|
||||||
|
item.srcloc.color = srcloc->color;
|
||||||
|
|
||||||
const auto sz = QueueDataSize[item.hdr.idx];
|
const auto sz = QueueDataSize[item.hdr.idx];
|
||||||
|
|
||||||
@ -301,7 +302,7 @@ void Profiler::CalibrateTimer()
|
|||||||
class FakeZone
|
class FakeZone
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FakeZone( const SourceLocation* srcloc, uint32_t color ) {}
|
FakeZone( const SourceLocation* srcloc ) {}
|
||||||
~FakeZone() {}
|
~FakeZone() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -315,20 +316,20 @@ 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++ )
|
||||||
{
|
{
|
||||||
static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__ };
|
static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__, 0 };
|
||||||
ScopedZone ___tracy_scoped_zone( &__tracy_source_location, 0 );
|
ScopedZone ___tracy_scoped_zone( &__tracy_source_location );
|
||||||
}
|
}
|
||||||
const auto f0 = GetTime();
|
const auto f0 = GetTime();
|
||||||
for( int i=0; i<Iterations; i++ )
|
for( int i=0; i<Iterations; i++ )
|
||||||
{
|
{
|
||||||
static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__ };
|
static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__, 0 };
|
||||||
FakeZone ___tracy_scoped_zone( &__tracy_source_location, 0 );
|
FakeZone ___tracy_scoped_zone( &__tracy_source_location );
|
||||||
}
|
}
|
||||||
const auto t0 = GetTime();
|
const auto t0 = GetTime();
|
||||||
for( int i=0; i<Iterations; i++ )
|
for( int i=0; i<Iterations; i++ )
|
||||||
{
|
{
|
||||||
static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__ };
|
static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__, 0 };
|
||||||
ScopedZone ___tracy_scoped_zone( &__tracy_source_location, 0 );
|
ScopedZone ___tracy_scoped_zone( &__tracy_source_location );
|
||||||
}
|
}
|
||||||
const auto t1 = GetTime();
|
const auto t1 = GetTime();
|
||||||
const auto dt = t1 - t0;
|
const auto dt = t1 - t0;
|
||||||
|
@ -23,6 +23,7 @@ struct SourceLocation
|
|||||||
const char* function;
|
const char* function;
|
||||||
const char* file;
|
const char* file;
|
||||||
uint32_t line;
|
uint32_t line;
|
||||||
|
uint32_t color;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Profiler
|
class Profiler
|
||||||
|
@ -12,8 +12,8 @@ namespace tracy
|
|||||||
class ScopedZone
|
class ScopedZone
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ScopedZone( const SourceLocation* srcloc, uint32_t color )
|
ScopedZone( const SourceLocation* srcloc )
|
||||||
: m_id( Profiler::ZoneBegin( QueueZoneBegin { Profiler::GetTime(), (uint64_t)srcloc, GetThreadHandle(), color } ) )
|
: m_id( Profiler::ZoneBegin( QueueZoneBegin { Profiler::GetTime(), (uint64_t)srcloc, GetThreadHandle() } ) )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ struct QueueZoneBegin
|
|||||||
int64_t time;
|
int64_t time;
|
||||||
uint64_t srcloc; // ptr
|
uint64_t srcloc; // ptr
|
||||||
uint64_t thread;
|
uint64_t thread;
|
||||||
uint32_t color;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct QueueZoneEnd
|
struct QueueZoneEnd
|
||||||
@ -37,6 +36,7 @@ struct QueueSourceLocation
|
|||||||
uint64_t function; // ptr
|
uint64_t function; // ptr
|
||||||
uint64_t file; // ptr
|
uint64_t file; // ptr
|
||||||
uint32_t line;
|
uint32_t line;
|
||||||
|
uint32_t color;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct QueueHeader
|
struct QueueHeader
|
||||||
|
@ -11,7 +11,6 @@ struct Event
|
|||||||
int64_t start;
|
int64_t start;
|
||||||
int64_t end;
|
int64_t end;
|
||||||
uint64_t srcloc;
|
uint64_t srcloc;
|
||||||
uint32_t color;
|
|
||||||
|
|
||||||
Event* parent;
|
Event* parent;
|
||||||
Vector<Event*> child;
|
Vector<Event*> child;
|
||||||
|
@ -238,7 +238,6 @@ void View::ProcessZoneBegin( uint64_t id, const QueueZoneBegin& ev )
|
|||||||
|
|
||||||
zone->start = ev.time * m_timerMul;
|
zone->start = ev.time * m_timerMul;
|
||||||
zone->srcloc = ev.srcloc;
|
zone->srcloc = ev.srcloc;
|
||||||
zone->color = ev.color;
|
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock( m_lock );
|
std::unique_lock<std::mutex> lock( m_lock );
|
||||||
|
|
||||||
@ -606,6 +605,14 @@ const char* View::GetThreadString( uint64_t id ) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QueueSourceLocation& View::GetSourceLocation( uint64_t srcloc ) const
|
||||||
|
{
|
||||||
|
static const QueueSourceLocation empty = {};
|
||||||
|
const auto it = m_sourceLocation.find( srcloc );
|
||||||
|
if( it == m_sourceLocation.end() ) return empty;
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
|
||||||
void View::Draw()
|
void View::Draw()
|
||||||
{
|
{
|
||||||
s_instance->DrawImpl();
|
s_instance->DrawImpl();
|
||||||
@ -1024,7 +1031,8 @@ 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;
|
auto& srcloc = GetSourceLocation( ev.srcloc );
|
||||||
|
const auto color = srcloc.color != 0 ? ( srcloc.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 )
|
||||||
@ -1037,7 +1045,8 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
|
|||||||
{
|
{
|
||||||
++it;
|
++it;
|
||||||
if( it == zitend ) break;
|
if( it == zitend ) break;
|
||||||
if( (*it)->color != ev.color ) break;
|
auto& srcloc2 = GetSourceLocation( (*it)->srcloc );
|
||||||
|
if( srcloc.color != srcloc2.color ) break;
|
||||||
const auto nend = GetZoneEnd( **it );
|
const auto nend = GetZoneEnd( **it );
|
||||||
const auto pxnext = ( nend - m_zvStart ) * pxns;
|
const auto pxnext = ( nend - m_zvStart ) * pxns;
|
||||||
if( pxnext - px1 >= MinVisSize * 2 ) break;
|
if( pxnext - px1 >= MinVisSize * 2 ) break;
|
||||||
@ -1056,16 +1065,9 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char* func = "???";
|
const auto func = GetString( srcloc.function );
|
||||||
const char* filename = "???";
|
const auto filename = GetString( srcloc.file );
|
||||||
uint32_t line = 0;
|
const auto line = srcloc.line;
|
||||||
auto srcit = m_sourceLocation.find( ev.srcloc );
|
|
||||||
if( srcit != m_sourceLocation.end() )
|
|
||||||
{
|
|
||||||
func = GetString( srcit->second.function );
|
|
||||||
filename = GetString( srcit->second.file );
|
|
||||||
line = srcit->second.line;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto tsz = ImGui::CalcTextSize( func );
|
const auto tsz = ImGui::CalcTextSize( func );
|
||||||
const auto pr0 = ( ev.start - m_zvStart ) * pxns;
|
const auto pr0 = ( ev.start - m_zvStart ) * pxns;
|
||||||
|
@ -72,6 +72,7 @@ private:
|
|||||||
const char* TimeToString( int64_t ns ) const;
|
const char* TimeToString( int64_t ns ) const;
|
||||||
const char* GetString( uint64_t ptr ) const;
|
const char* GetString( uint64_t ptr ) const;
|
||||||
const char* GetThreadString( uint64_t id ) const;
|
const char* GetThreadString( uint64_t id ) const;
|
||||||
|
const QueueSourceLocation& GetSourceLocation( uint64_t srcloc ) const;
|
||||||
|
|
||||||
void DrawImpl();
|
void DrawImpl();
|
||||||
void DrawFrames();
|
void DrawFrames();
|
||||||
|
Loading…
Reference in New Issue
Block a user