mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +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 "TracyScoped.hpp"
|
||||
|
||||
#define ZoneScoped static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__ }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location, 0 );
|
||||
#define ZoneScopedC( color ) static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__ }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location, color );
|
||||
#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__, color }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location );
|
||||
|
||||
#define FrameMark tracy::Profiler::FrameMark();
|
||||
|
||||
|
@ -225,6 +225,7 @@ bool Profiler::SendSourceLocation( uint64_t ptr )
|
||||
item.srcloc.file = (uint64_t)srcloc->file;
|
||||
item.srcloc.function = (uint64_t)srcloc->function;
|
||||
item.srcloc.line = srcloc->line;
|
||||
item.srcloc.color = srcloc->color;
|
||||
|
||||
const auto sz = QueueDataSize[item.hdr.idx];
|
||||
|
||||
@ -301,7 +302,7 @@ void Profiler::CalibrateTimer()
|
||||
class FakeZone
|
||||
{
|
||||
public:
|
||||
FakeZone( const SourceLocation* srcloc, uint32_t color ) {}
|
||||
FakeZone( const SourceLocation* srcloc ) {}
|
||||
~FakeZone() {}
|
||||
|
||||
private:
|
||||
@ -315,20 +316,20 @@ void Profiler::CalibrateDelay()
|
||||
static_assert( Events * 2 < QueuePrealloc, "Delay calibration loop will allocate memory in queue" );
|
||||
for( int i=0; i<Iterations; i++ )
|
||||
{
|
||||
static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__ };
|
||||
ScopedZone ___tracy_scoped_zone( &__tracy_source_location, 0 );
|
||||
static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__, 0 };
|
||||
ScopedZone ___tracy_scoped_zone( &__tracy_source_location );
|
||||
}
|
||||
const auto f0 = GetTime();
|
||||
for( int i=0; i<Iterations; i++ )
|
||||
{
|
||||
static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__ };
|
||||
FakeZone ___tracy_scoped_zone( &__tracy_source_location, 0 );
|
||||
static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__, 0 };
|
||||
FakeZone ___tracy_scoped_zone( &__tracy_source_location );
|
||||
}
|
||||
const auto t0 = GetTime();
|
||||
for( int i=0; i<Iterations; i++ )
|
||||
{
|
||||
static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__ };
|
||||
ScopedZone ___tracy_scoped_zone( &__tracy_source_location, 0 );
|
||||
static const tracy::SourceLocation __tracy_source_location { __FUNCTION__, __FILE__, __LINE__, 0 };
|
||||
ScopedZone ___tracy_scoped_zone( &__tracy_source_location );
|
||||
}
|
||||
const auto t1 = GetTime();
|
||||
const auto dt = t1 - t0;
|
||||
|
@ -23,6 +23,7 @@ struct SourceLocation
|
||||
const char* function;
|
||||
const char* file;
|
||||
uint32_t line;
|
||||
uint32_t color;
|
||||
};
|
||||
|
||||
class Profiler
|
||||
|
@ -12,8 +12,8 @@ namespace tracy
|
||||
class ScopedZone
|
||||
{
|
||||
public:
|
||||
ScopedZone( const SourceLocation* srcloc, uint32_t color )
|
||||
: m_id( Profiler::ZoneBegin( QueueZoneBegin { Profiler::GetTime(), (uint64_t)srcloc, GetThreadHandle(), color } ) )
|
||||
ScopedZone( const SourceLocation* srcloc )
|
||||
: m_id( Profiler::ZoneBegin( QueueZoneBegin { Profiler::GetTime(), (uint64_t)srcloc, GetThreadHandle() } ) )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@ struct QueueZoneBegin
|
||||
int64_t time;
|
||||
uint64_t srcloc; // ptr
|
||||
uint64_t thread;
|
||||
uint32_t color;
|
||||
};
|
||||
|
||||
struct QueueZoneEnd
|
||||
@ -37,6 +36,7 @@ struct QueueSourceLocation
|
||||
uint64_t function; // ptr
|
||||
uint64_t file; // ptr
|
||||
uint32_t line;
|
||||
uint32_t color;
|
||||
};
|
||||
|
||||
struct QueueHeader
|
||||
|
@ -11,7 +11,6 @@ struct Event
|
||||
int64_t start;
|
||||
int64_t end;
|
||||
uint64_t srcloc;
|
||||
uint32_t color;
|
||||
|
||||
Event* parent;
|
||||
Vector<Event*> child;
|
||||
|
@ -238,7 +238,6 @@ void View::ProcessZoneBegin( uint64_t id, const QueueZoneBegin& ev )
|
||||
|
||||
zone->start = ev.time * m_timerMul;
|
||||
zone->srcloc = ev.srcloc;
|
||||
zone->color = ev.color;
|
||||
|
||||
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()
|
||||
{
|
||||
s_instance->DrawImpl();
|
||||
@ -1024,7 +1031,8 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
|
||||
while( it < zitend )
|
||||
{
|
||||
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 zsz = ( ev.end - ev.start ) * pxns;
|
||||
if( zsz < MinVisSize )
|
||||
@ -1037,7 +1045,8 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
|
||||
{
|
||||
++it;
|
||||
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 pxnext = ( nend - m_zvStart ) * pxns;
|
||||
if( pxnext - px1 >= MinVisSize * 2 ) break;
|
||||
@ -1056,16 +1065,9 @@ int View::DrawZoneLevel( const Vector<Event*>& vec, bool hover, double pxns, con
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* func = "???";
|
||||
const char* filename = "???";
|
||||
uint32_t line = 0;
|
||||
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 func = GetString( srcloc.function );
|
||||
const auto filename = GetString( srcloc.file );
|
||||
const auto line = srcloc.line;
|
||||
|
||||
const auto tsz = ImGui::CalcTextSize( func );
|
||||
const auto pr0 = ( ev.start - m_zvStart ) * pxns;
|
||||
|
@ -72,6 +72,7 @@ private:
|
||||
const char* TimeToString( int64_t ns ) const;
|
||||
const char* GetString( uint64_t ptr ) const;
|
||||
const char* GetThreadString( uint64_t id ) const;
|
||||
const QueueSourceLocation& GetSourceLocation( uint64_t srcloc ) const;
|
||||
|
||||
void DrawImpl();
|
||||
void DrawFrames();
|
||||
|
Loading…
Reference in New Issue
Block a user