mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Merge pull request #755 from Chekov2k/color
Add support to set color when creating a ScopedZone
This commit is contained in:
commit
ac031e64d6
@ -4261,12 +4261,12 @@ TRACY_API void ___tracy_emit_messageC( const char* txt, size_t size, uint32_t co
|
|||||||
TRACY_API void ___tracy_emit_messageLC( const char* txt, uint32_t color, int callstack ) { tracy::Profiler::MessageColor( txt, color, callstack ); }
|
TRACY_API void ___tracy_emit_messageLC( const char* txt, uint32_t color, int callstack ) { tracy::Profiler::MessageColor( txt, color, callstack ); }
|
||||||
TRACY_API void ___tracy_emit_message_appinfo( const char* txt, size_t size ) { tracy::Profiler::MessageAppInfo( txt, size ); }
|
TRACY_API void ___tracy_emit_message_appinfo( const char* txt, size_t size ) { tracy::Profiler::MessageAppInfo( txt, size ); }
|
||||||
|
|
||||||
TRACY_API uint64_t ___tracy_alloc_srcloc( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz ) {
|
TRACY_API uint64_t ___tracy_alloc_srcloc( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, uint32_t color ) {
|
||||||
return tracy::Profiler::AllocSourceLocation( line, source, sourceSz, function, functionSz );
|
return tracy::Profiler::AllocSourceLocation( line, source, sourceSz, function, functionSz, color );
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACY_API uint64_t ___tracy_alloc_srcloc_name( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz ) {
|
TRACY_API uint64_t ___tracy_alloc_srcloc_name( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, uint32_t color ) {
|
||||||
return tracy::Profiler::AllocSourceLocation( line, source, sourceSz, function, functionSz, name, nameSz );
|
return tracy::Profiler::AllocSourceLocation( line, source, sourceSz, function, functionSz, name, nameSz, color );
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACY_API void ___tracy_emit_gpu_zone_begin( const struct ___tracy_gpu_zone_begin_data data )
|
TRACY_API void ___tracy_emit_gpu_zone_begin( const struct ___tracy_gpu_zone_begin_data data )
|
||||||
|
@ -745,29 +745,29 @@ public:
|
|||||||
// 1b null terminator
|
// 1b null terminator
|
||||||
// nsz zone name (optional)
|
// nsz zone name (optional)
|
||||||
|
|
||||||
static tracy_force_inline uint64_t AllocSourceLocation( uint32_t line, const char* source, const char* function )
|
static tracy_force_inline uint64_t AllocSourceLocation( uint32_t line, const char* source, const char* function, uint32_t color = 0 )
|
||||||
{
|
{
|
||||||
return AllocSourceLocation( line, source, function, nullptr, 0 );
|
return AllocSourceLocation( line, source, function, nullptr, 0, color );
|
||||||
}
|
}
|
||||||
|
|
||||||
static tracy_force_inline uint64_t AllocSourceLocation( uint32_t line, const char* source, const char* function, const char* name, size_t nameSz )
|
static tracy_force_inline uint64_t AllocSourceLocation( uint32_t line, const char* source, const char* function, const char* name, size_t nameSz, uint32_t color = 0 )
|
||||||
{
|
{
|
||||||
return AllocSourceLocation( line, source, strlen(source), function, strlen(function), name, nameSz );
|
return AllocSourceLocation( line, source, strlen(source), function, strlen(function), name, nameSz, color );
|
||||||
}
|
}
|
||||||
|
|
||||||
static tracy_force_inline uint64_t AllocSourceLocation( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz )
|
static tracy_force_inline uint64_t AllocSourceLocation( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, uint32_t color = 0 )
|
||||||
{
|
{
|
||||||
return AllocSourceLocation( line, source, sourceSz, function, functionSz, nullptr, 0 );
|
return AllocSourceLocation( line, source, sourceSz, function, functionSz, nullptr, 0, color );
|
||||||
}
|
}
|
||||||
|
|
||||||
static tracy_force_inline uint64_t AllocSourceLocation( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz )
|
static tracy_force_inline uint64_t AllocSourceLocation( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, uint32_t color = 0 )
|
||||||
{
|
{
|
||||||
const auto sz32 = uint32_t( 2 + 4 + 4 + functionSz + 1 + sourceSz + 1 + nameSz );
|
const auto sz32 = uint32_t( 2 + 4 + 4 + functionSz + 1 + sourceSz + 1 + nameSz );
|
||||||
assert( sz32 <= (std::numeric_limits<uint16_t>::max)() );
|
assert( sz32 <= (std::numeric_limits<uint16_t>::max)() );
|
||||||
const auto sz = uint16_t( sz32 );
|
const auto sz = uint16_t( sz32 );
|
||||||
auto ptr = (char*)tracy_malloc( sz );
|
auto ptr = (char*)tracy_malloc( sz );
|
||||||
memcpy( ptr, &sz, 2 );
|
memcpy( ptr, &sz, 2 );
|
||||||
memset( ptr + 2, 0, 4 );
|
memcpy( ptr + 2, &color, 4 );
|
||||||
memcpy( ptr + 6, &line, 4 );
|
memcpy( ptr + 6, &line, 4 );
|
||||||
memcpy( ptr + 10, function, functionSz );
|
memcpy( ptr + 10, function, functionSz );
|
||||||
ptr[10 + functionSz] = '\0';
|
ptr[10 + functionSz] = '\0';
|
||||||
|
@ -58,7 +58,7 @@ public:
|
|||||||
TracyQueueCommit( zoneBeginThread );
|
TracyQueueCommit( zoneBeginThread );
|
||||||
}
|
}
|
||||||
|
|
||||||
tracy_force_inline ScopedZone( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, bool is_active = true )
|
tracy_force_inline ScopedZone( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, uint32_t color, bool is_active = true )
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
: m_active( is_active && GetProfiler().IsConnected() )
|
: m_active( is_active && GetProfiler().IsConnected() )
|
||||||
#else
|
#else
|
||||||
@ -70,13 +70,15 @@ public:
|
|||||||
m_connectionId = GetProfiler().ConnectionId();
|
m_connectionId = GetProfiler().ConnectionId();
|
||||||
#endif
|
#endif
|
||||||
TracyQueuePrepare( QueueType::ZoneBeginAllocSrcLoc );
|
TracyQueuePrepare( QueueType::ZoneBeginAllocSrcLoc );
|
||||||
const auto srcloc = Profiler::AllocSourceLocation( line, source, sourceSz, function, functionSz, name, nameSz );
|
const auto srcloc = Profiler::AllocSourceLocation( line, source, sourceSz, function, functionSz, name, nameSz, color );
|
||||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
|
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
|
||||||
MemWrite( &item->zoneBegin.srcloc, srcloc );
|
MemWrite( &item->zoneBegin.srcloc, srcloc );
|
||||||
TracyQueueCommit( zoneBeginThread );
|
TracyQueueCommit( zoneBeginThread );
|
||||||
}
|
}
|
||||||
|
|
||||||
tracy_force_inline ScopedZone( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, int depth, bool is_active = true )
|
tracy_force_inline ScopedZone( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, bool is_active = true ) : ScopedZone( line, source, sourceSz, function, functionSz, name, nameSz, static_cast<uint32_t>(0), is_active ) {}
|
||||||
|
|
||||||
|
tracy_force_inline ScopedZone( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, uint32_t color, int depth, bool is_active = true )
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
: m_active( is_active && GetProfiler().IsConnected() )
|
: m_active( is_active && GetProfiler().IsConnected() )
|
||||||
#else
|
#else
|
||||||
@ -90,12 +92,14 @@ public:
|
|||||||
GetProfiler().SendCallstack( depth );
|
GetProfiler().SendCallstack( depth );
|
||||||
|
|
||||||
TracyQueuePrepare( QueueType::ZoneBeginAllocSrcLocCallstack );
|
TracyQueuePrepare( QueueType::ZoneBeginAllocSrcLocCallstack );
|
||||||
const auto srcloc = Profiler::AllocSourceLocation( line, source, sourceSz, function, functionSz, name, nameSz );
|
const auto srcloc = Profiler::AllocSourceLocation( line, source, sourceSz, function, functionSz, name, nameSz, color );
|
||||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
|
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
|
||||||
MemWrite( &item->zoneBegin.srcloc, srcloc );
|
MemWrite( &item->zoneBegin.srcloc, srcloc );
|
||||||
TracyQueueCommit( zoneBeginThread );
|
TracyQueueCommit( zoneBeginThread );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tracy_force_inline ScopedZone( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, int depth, bool is_active = true ) : ScopedZone( line, source, sourceSz, function, functionSz, name, nameSz, 0, depth, is_active ) {}
|
||||||
|
|
||||||
tracy_force_inline ~ScopedZone()
|
tracy_force_inline ~ScopedZone()
|
||||||
{
|
{
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
|
@ -208,8 +208,8 @@ TRACY_API int ___tracy_profiler_started(void);
|
|||||||
# define TracyCIsStarted 1
|
# define TracyCIsStarted 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TRACY_API uint64_t ___tracy_alloc_srcloc( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz );
|
TRACY_API uint64_t ___tracy_alloc_srcloc( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, uint32_t color );
|
||||||
TRACY_API uint64_t ___tracy_alloc_srcloc_name( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz );
|
TRACY_API uint64_t ___tracy_alloc_srcloc_name( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, uint32_t color );
|
||||||
|
|
||||||
TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin( const struct ___tracy_source_location_data* srcloc, int active );
|
TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin( const struct ___tracy_source_location_data* srcloc, int active );
|
||||||
TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin_callstack( const struct ___tracy_source_location_data* srcloc, int depth, int active );
|
TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin_callstack( const struct ___tracy_source_location_data* srcloc, int depth, int active );
|
||||||
|
Loading…
Reference in New Issue
Block a user