mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 12:23:53 +00:00
Implement transfer of integral values for zones.
This commit is contained in:
parent
1bcde1f2ff
commit
2b304581cf
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#define ZoneText(x,y)
|
#define ZoneText(x,y)
|
||||||
#define ZoneName(x,y)
|
#define ZoneName(x,y)
|
||||||
|
#define ZoneValue(x)
|
||||||
|
|
||||||
#define FrameMark
|
#define FrameMark
|
||||||
#define FrameMarkNamed(x)
|
#define FrameMarkNamed(x)
|
||||||
@ -93,6 +94,7 @@
|
|||||||
|
|
||||||
#define ZoneText( txt, size ) ___tracy_scoped_zone.Text( txt, size );
|
#define ZoneText( txt, size ) ___tracy_scoped_zone.Text( txt, size );
|
||||||
#define ZoneName( txt, size ) ___tracy_scoped_zone.Name( txt, size );
|
#define ZoneName( txt, size ) ___tracy_scoped_zone.Name( txt, size );
|
||||||
|
#define ZoneValue( value ) ___tracy_scoped_zone.Value( value );
|
||||||
|
|
||||||
#define FrameMark tracy::Profiler::SendFrameMark( nullptr );
|
#define FrameMark tracy::Profiler::SendFrameMark( nullptr );
|
||||||
#define FrameMarkNamed( name ) tracy::Profiler::SendFrameMark( name );
|
#define FrameMarkNamed( name ) tracy::Profiler::SendFrameMark( name );
|
||||||
|
3
TracyC.h
3
TracyC.h
@ -22,6 +22,7 @@ typedef const void* TracyCZoneCtx;
|
|||||||
#define TracyCZoneEnd(c)
|
#define TracyCZoneEnd(c)
|
||||||
#define TracyCZoneText(c,x,y)
|
#define TracyCZoneText(c,x,y)
|
||||||
#define TracyCZoneName(c,x,y)
|
#define TracyCZoneName(c,x,y)
|
||||||
|
#define TracyCZoneValue(c,x)
|
||||||
|
|
||||||
#define TracyCAlloc(x,y)
|
#define TracyCAlloc(x,y)
|
||||||
#define TracyCFree(x)
|
#define TracyCFree(x)
|
||||||
@ -90,6 +91,7 @@ TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin_alloc_callstack( uint64_t srclo
|
|||||||
TRACY_API void ___tracy_emit_zone_end( TracyCZoneCtx ctx );
|
TRACY_API void ___tracy_emit_zone_end( TracyCZoneCtx ctx );
|
||||||
TRACY_API void ___tracy_emit_zone_text( TracyCZoneCtx ctx, const char* txt, size_t size );
|
TRACY_API void ___tracy_emit_zone_text( TracyCZoneCtx ctx, const char* txt, size_t size );
|
||||||
TRACY_API void ___tracy_emit_zone_name( TracyCZoneCtx ctx, const char* txt, size_t size );
|
TRACY_API void ___tracy_emit_zone_name( TracyCZoneCtx ctx, const char* txt, size_t size );
|
||||||
|
TRACY_API void ___tracy_emit_zone_value( TracyCZoneCtx ctx, uint64_t value );
|
||||||
|
|
||||||
#if defined TRACY_HAS_CALLSTACK && defined TRACY_CALLSTACK
|
#if defined TRACY_HAS_CALLSTACK && defined TRACY_CALLSTACK
|
||||||
# define TracyCZone( ctx, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,__LINE__) = { NULL, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,__LINE__), TRACY_CALLSTACK, active );
|
# define TracyCZone( ctx, active ) static const struct ___tracy_source_location_data TracyConcat(__tracy_source_location,__LINE__) = { NULL, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 }; TracyCZoneCtx ctx = ___tracy_emit_zone_begin_callstack( &TracyConcat(__tracy_source_location,__LINE__), TRACY_CALLSTACK, active );
|
||||||
@ -107,6 +109,7 @@ TRACY_API void ___tracy_emit_zone_name( TracyCZoneCtx ctx, const char* txt, size
|
|||||||
|
|
||||||
#define TracyCZoneText( ctx, txt, size ) ___tracy_emit_zone_text( ctx, txt, size );
|
#define TracyCZoneText( ctx, txt, size ) ___tracy_emit_zone_text( ctx, txt, size );
|
||||||
#define TracyCZoneName( ctx, txt, size ) ___tracy_emit_zone_name( ctx, txt, size );
|
#define TracyCZoneName( ctx, txt, size ) ___tracy_emit_zone_name( ctx, txt, size );
|
||||||
|
#define TracyCZoneValue( ctx, value ) ___tracy_emit_zone_value( ctx, value );
|
||||||
|
|
||||||
|
|
||||||
TRACY_API void ___tracy_emit_memory_alloc( const void* ptr, size_t size );
|
TRACY_API void ___tracy_emit_memory_alloc( const void* ptr, size_t size );
|
||||||
|
@ -3033,6 +3033,23 @@ TRACY_API void ___tracy_emit_zone_name( TracyCZoneCtx ctx, const char* txt, size
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRACY_API void ___tracy_emit_zone_value( TracyCZoneCtx ctx, uint64_t value )
|
||||||
|
{
|
||||||
|
if( !ctx.active ) return;
|
||||||
|
#ifndef TRACY_NO_VERIFY
|
||||||
|
{
|
||||||
|
TracyLfqPrepareC( tracy::QueueType::ZoneValidation );
|
||||||
|
tracy::MemWrite( &item->zoneValidation.id, ctx.id );
|
||||||
|
TracyLfqCommitC;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
TracyLfqPrepareC( tracy::QueueType::ZoneValue );
|
||||||
|
tracy::MemWrite( &item->zoneValue.value, value );
|
||||||
|
TracyLfqCommitC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TRACY_API void ___tracy_emit_memory_alloc( const void* ptr, size_t size ) { tracy::Profiler::MemAlloc( ptr, size ); }
|
TRACY_API void ___tracy_emit_memory_alloc( const void* ptr, size_t size ) { tracy::Profiler::MemAlloc( ptr, size ); }
|
||||||
TRACY_API void ___tracy_emit_memory_alloc_callstack( const void* ptr, size_t size, int depth ) { tracy::Profiler::MemAllocCallstack( ptr, size, depth ); }
|
TRACY_API void ___tracy_emit_memory_alloc_callstack( const void* ptr, size_t size, int depth ) { tracy::Profiler::MemAllocCallstack( ptr, size, depth ); }
|
||||||
TRACY_API void ___tracy_emit_memory_free( const void* ptr ) { tracy::Profiler::MemFree( ptr ); }
|
TRACY_API void ___tracy_emit_memory_free( const void* ptr ) { tracy::Profiler::MemFree( ptr ); }
|
||||||
|
@ -90,6 +90,17 @@ public:
|
|||||||
TracyLfqCommit;
|
TracyLfqCommit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tracy_force_inline void Value( uint64_t value )
|
||||||
|
{
|
||||||
|
if( !m_active ) return;
|
||||||
|
#ifdef TRACY_ON_DEMAND
|
||||||
|
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
||||||
|
#endif
|
||||||
|
TracyLfqPrepare( QueueType::ZoneValue );
|
||||||
|
MemWrite( &item->zoneValue.value, value );
|
||||||
|
TracyLfqCommit;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const bool m_active;
|
const bool m_active;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ namespace tracy
|
|||||||
|
|
||||||
constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; }
|
constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; }
|
||||||
|
|
||||||
enum : uint32_t { ProtocolVersion = 31 };
|
enum : uint32_t { ProtocolVersion = 32 };
|
||||||
enum : uint32_t { BroadcastVersion = 1 };
|
enum : uint32_t { BroadcastVersion = 1 };
|
||||||
|
|
||||||
using lz4sz_t = uint32_t;
|
using lz4sz_t = uint32_t;
|
||||||
|
@ -59,6 +59,7 @@ enum class QueueType : uint8_t
|
|||||||
Crash,
|
Crash,
|
||||||
CrashReport,
|
CrashReport,
|
||||||
ZoneValidation,
|
ZoneValidation,
|
||||||
|
ZoneValue,
|
||||||
FrameMarkMsg,
|
FrameMarkMsg,
|
||||||
FrameMarkMsgStart,
|
FrameMarkMsgStart,
|
||||||
FrameMarkMsgEnd,
|
FrameMarkMsgEnd,
|
||||||
@ -123,6 +124,11 @@ struct QueueZoneValidation
|
|||||||
uint32_t id;
|
uint32_t id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct QueueZoneValue
|
||||||
|
{
|
||||||
|
uint64_t value;
|
||||||
|
};
|
||||||
|
|
||||||
struct QueueStringTransfer
|
struct QueueStringTransfer
|
||||||
{
|
{
|
||||||
uint64_t ptr;
|
uint64_t ptr;
|
||||||
@ -439,6 +445,7 @@ struct QueueItem
|
|||||||
QueueZoneBeginLean zoneBeginLean;
|
QueueZoneBeginLean zoneBeginLean;
|
||||||
QueueZoneEnd zoneEnd;
|
QueueZoneEnd zoneEnd;
|
||||||
QueueZoneValidation zoneValidation;
|
QueueZoneValidation zoneValidation;
|
||||||
|
QueueZoneValue zoneValue;
|
||||||
QueueStringTransfer stringTransfer;
|
QueueStringTransfer stringTransfer;
|
||||||
QueueFrameMark frameMark;
|
QueueFrameMark frameMark;
|
||||||
QueueFrameImage frameImage;
|
QueueFrameImage frameImage;
|
||||||
@ -538,6 +545,7 @@ static constexpr size_t QueueDataSize[] = {
|
|||||||
sizeof( QueueHeader ), // crash
|
sizeof( QueueHeader ), // crash
|
||||||
sizeof( QueueHeader ) + sizeof( QueueCrashReport ),
|
sizeof( QueueHeader ) + sizeof( QueueCrashReport ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueZoneValidation ),
|
sizeof( QueueHeader ) + sizeof( QueueZoneValidation ),
|
||||||
|
sizeof( QueueHeader ) + sizeof( QueueZoneValue ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueFrameMark ), // continuous frames
|
sizeof( QueueHeader ) + sizeof( QueueFrameMark ), // continuous frames
|
||||||
sizeof( QueueHeader ) + sizeof( QueueFrameMark ), // start
|
sizeof( QueueHeader ) + sizeof( QueueFrameMark ), // start
|
||||||
sizeof( QueueHeader ) + sizeof( QueueFrameMark ), // end
|
sizeof( QueueHeader ) + sizeof( QueueFrameMark ), // end
|
||||||
|
@ -4156,6 +4156,9 @@ bool Worker::Process( const QueueItem& ev )
|
|||||||
case QueueType::ZoneName:
|
case QueueType::ZoneName:
|
||||||
ProcessZoneName( ev.zoneText );
|
ProcessZoneName( ev.zoneText );
|
||||||
break;
|
break;
|
||||||
|
case QueueType::ZoneValue:
|
||||||
|
ProcessZoneValue( ev.zoneValue );
|
||||||
|
break;
|
||||||
case QueueType::LockAnnounce:
|
case QueueType::LockAnnounce:
|
||||||
ProcessLockAnnounce( ev.lockAnnounce );
|
ProcessLockAnnounce( ev.lockAnnounce );
|
||||||
break;
|
break;
|
||||||
@ -4758,6 +4761,38 @@ void Worker::ProcessZoneName( const QueueZoneText& ev )
|
|||||||
m_pendingCustomStrings.erase( it );
|
m_pendingCustomStrings.erase( it );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Worker::ProcessZoneValue( const QueueZoneValue& ev )
|
||||||
|
{
|
||||||
|
char tmp[32];
|
||||||
|
const auto tsz = sprintf( tmp, "%" PRIu64, ev.value );
|
||||||
|
|
||||||
|
auto td = RetrieveThread( m_threadCtx );
|
||||||
|
if( !td || td->stack.empty() || td->nextZoneId != td->zoneIdStack.back() )
|
||||||
|
{
|
||||||
|
ZoneTextFailure( m_threadCtx );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
td->nextZoneId = 0;
|
||||||
|
auto& stack = td->stack;
|
||||||
|
auto zone = stack.back();
|
||||||
|
auto& extra = RequestZoneExtra( *zone );
|
||||||
|
if( !extra.text.Active() )
|
||||||
|
{
|
||||||
|
extra.text = StringIdx( StoreString( tmp, tsz ).idx );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const auto str0 = GetString( extra.text );
|
||||||
|
const auto len0 = strlen( str0 );
|
||||||
|
char* buf = (char*)alloca( len0+tsz+1 );
|
||||||
|
memcpy( buf, str0, len0 );
|
||||||
|
buf[len0] = '\n';
|
||||||
|
memcpy( buf+len0+1, tmp, tsz );
|
||||||
|
extra.text = StringIdx( StoreString( buf, len0+tsz+1 ).idx );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Worker::ProcessLockAnnounce( const QueueLockAnnounce& ev )
|
void Worker::ProcessLockAnnounce( const QueueLockAnnounce& ev )
|
||||||
{
|
{
|
||||||
auto it = m_data.lockMap.find( ev.id );
|
auto it = m_data.lockMap.find( ev.id );
|
||||||
|
@ -576,6 +576,7 @@ private:
|
|||||||
tracy_force_inline void ProcessFrameImage( const QueueFrameImageLean& ev );
|
tracy_force_inline void ProcessFrameImage( const QueueFrameImageLean& ev );
|
||||||
tracy_force_inline void ProcessZoneText( const QueueZoneText& ev );
|
tracy_force_inline void ProcessZoneText( const QueueZoneText& ev );
|
||||||
tracy_force_inline void ProcessZoneName( const QueueZoneText& ev );
|
tracy_force_inline void ProcessZoneName( const QueueZoneText& ev );
|
||||||
|
tracy_force_inline void ProcessZoneValue( const QueueZoneValue& ev );
|
||||||
tracy_force_inline void ProcessLockAnnounce( const QueueLockAnnounce& ev );
|
tracy_force_inline void ProcessLockAnnounce( const QueueLockAnnounce& ev );
|
||||||
tracy_force_inline void ProcessLockTerminate( const QueueLockTerminate& ev );
|
tracy_force_inline void ProcessLockTerminate( const QueueLockTerminate& ev );
|
||||||
tracy_force_inline void ProcessLockWait( const QueueLockWait& ev );
|
tracy_force_inline void ProcessLockWait( const QueueLockWait& ev );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user