mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 04:23:51 +00:00
Custom per-zone name transfer.
This commit is contained in:
parent
ac89c6de33
commit
b29d60056a
@ -12,7 +12,7 @@
|
|||||||
#define ZoneScopedNC(x,y)
|
#define ZoneScopedNC(x,y)
|
||||||
|
|
||||||
#define ZoneText(x,y)
|
#define ZoneText(x,y)
|
||||||
#define ZoneName(x)
|
#define ZoneName(x,y)
|
||||||
|
|
||||||
#define FrameMark
|
#define FrameMark
|
||||||
|
|
||||||
@ -46,6 +46,7 @@
|
|||||||
#define ZoneScopedNC( name, color ) static const tracy::SourceLocation __tracy_source_location { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location );
|
#define ZoneScopedNC( name, color ) static const tracy::SourceLocation __tracy_source_location { name, __FUNCTION__, __FILE__, (uint32_t)__LINE__, color }; tracy::ScopedZone ___tracy_scoped_zone( &__tracy_source_location );
|
||||||
|
|
||||||
#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 FrameMark tracy::Profiler::FrameMark();
|
#define FrameMark tracy::Profiler::FrameMark();
|
||||||
|
|
||||||
|
29
TracyLua.hpp
29
TracyLua.hpp
@ -27,6 +27,8 @@ static inline void LuaRegister( lua_State* L )
|
|||||||
lua_pushcfunction( L, detail::noop );
|
lua_pushcfunction( L, detail::noop );
|
||||||
lua_setfield( L, -2, "ZoneText" );
|
lua_setfield( L, -2, "ZoneText" );
|
||||||
lua_pushcfunction( L, detail::noop );
|
lua_pushcfunction( L, detail::noop );
|
||||||
|
lua_setfield( L, -2, "ZoneName" );
|
||||||
|
lua_pushcfunction( L, detail::noop );
|
||||||
lua_setfield( L, -2, "Message" );
|
lua_setfield( L, -2, "Message" );
|
||||||
lua_setglobal( L, "tracy" );
|
lua_setglobal( L, "tracy" );
|
||||||
}
|
}
|
||||||
@ -67,6 +69,12 @@ static inline void LuaRemove( char* script )
|
|||||||
memset( script, ' ', end - script );
|
memset( script, ' ', end - script );
|
||||||
script = end;
|
script = end;
|
||||||
}
|
}
|
||||||
|
else if( strncmp( script + 10, "Name(", 5 ) == 0 )
|
||||||
|
{
|
||||||
|
auto end = FindEnd( script + 15 );
|
||||||
|
memset( script, ' ', end - script );
|
||||||
|
script = end;
|
||||||
|
}
|
||||||
else if( strncmp( script + 10, "BeginN(", 7 ) == 0 )
|
else if( strncmp( script + 10, "BeginN(", 7 ) == 0 )
|
||||||
{
|
{
|
||||||
auto end = FindEnd( script + 17 );
|
auto end = FindEnd( script + 17 );
|
||||||
@ -247,6 +255,25 @@ static inline int LuaZoneText( lua_State* L )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int LuaZoneName( lua_State* L )
|
||||||
|
{
|
||||||
|
auto txt = lua_tostring( L, 1 );
|
||||||
|
const auto size = strlen( txt );
|
||||||
|
|
||||||
|
Magic magic;
|
||||||
|
auto& token = s_token.ptr;
|
||||||
|
auto ptr = (char*)tracy_malloc( size+1 );
|
||||||
|
memcpy( ptr, txt, size );
|
||||||
|
ptr[size] = '\0';
|
||||||
|
auto& tail = token->get_tail_index();
|
||||||
|
auto item = token->enqueue_begin<moodycamel::CanAlloc>( magic );
|
||||||
|
MemWrite( &item->hdr.type, QueueType::ZoneName );
|
||||||
|
MemWrite( &item->zoneText.thread, GetThreadHandle() );
|
||||||
|
MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
||||||
|
tail.store( magic + 1, std::memory_order_release );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static inline int LuaMessage( lua_State* L )
|
static inline int LuaMessage( lua_State* L )
|
||||||
{
|
{
|
||||||
auto txt = lua_tostring( L, 1 );
|
auto txt = lua_tostring( L, 1 );
|
||||||
@ -280,6 +307,8 @@ static inline void LuaRegister( lua_State* L )
|
|||||||
lua_setfield( L, -2, "ZoneEnd" );
|
lua_setfield( L, -2, "ZoneEnd" );
|
||||||
lua_pushcfunction( L, detail::LuaZoneText );
|
lua_pushcfunction( L, detail::LuaZoneText );
|
||||||
lua_setfield( L, -2, "ZoneText" );
|
lua_setfield( L, -2, "ZoneText" );
|
||||||
|
lua_pushcfunction( L, detail::LuaZoneName );
|
||||||
|
lua_setfield( L, -2, "ZoneName" );
|
||||||
lua_pushcfunction( L, detail::LuaMessage );
|
lua_pushcfunction( L, detail::LuaMessage );
|
||||||
lua_setfield( L, -2, "Message" );
|
lua_setfield( L, -2, "Message" );
|
||||||
lua_setglobal( L, "tracy" );
|
lua_setglobal( L, "tracy" );
|
||||||
|
@ -375,6 +375,7 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
|||||||
switch( (QueueType)idx )
|
switch( (QueueType)idx )
|
||||||
{
|
{
|
||||||
case QueueType::ZoneText:
|
case QueueType::ZoneText:
|
||||||
|
case QueueType::ZoneName:
|
||||||
ptr = MemRead<uint64_t>( &item->zoneText.text );
|
ptr = MemRead<uint64_t>( &item->zoneText.text );
|
||||||
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
||||||
tracy_free( (void*)ptr );
|
tracy_free( (void*)ptr );
|
||||||
|
@ -92,6 +92,21 @@ public:
|
|||||||
tail.store( magic + 1, std::memory_order_release );
|
tail.store( magic + 1, std::memory_order_release );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tracy_force_inline void Name( const char* txt, size_t size )
|
||||||
|
{
|
||||||
|
Magic magic;
|
||||||
|
auto& token = s_token.ptr;
|
||||||
|
auto ptr = (char*)tracy_malloc( size+1 );
|
||||||
|
memcpy( ptr, txt, size );
|
||||||
|
ptr[size] = '\0';
|
||||||
|
auto& tail = token->get_tail_index();
|
||||||
|
auto item = token->enqueue_begin<moodycamel::CanAlloc>( magic );
|
||||||
|
MemWrite( &item->hdr.type, QueueType::ZoneName );
|
||||||
|
MemWrite( &item->zoneText.thread, m_thread );
|
||||||
|
MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
||||||
|
tail.store( magic + 1, std::memory_order_release );
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t m_thread;
|
uint64_t m_thread;
|
||||||
};
|
};
|
||||||
|
@ -9,6 +9,7 @@ namespace tracy
|
|||||||
enum class QueueType : uint8_t
|
enum class QueueType : uint8_t
|
||||||
{
|
{
|
||||||
ZoneText,
|
ZoneText,
|
||||||
|
ZoneName,
|
||||||
Message,
|
Message,
|
||||||
ZoneBeginAllocSrcLoc,
|
ZoneBeginAllocSrcLoc,
|
||||||
CallstackMemory,
|
CallstackMemory,
|
||||||
@ -273,6 +274,7 @@ enum { QueueItemSize = sizeof( QueueItem ) };
|
|||||||
|
|
||||||
static const size_t QueueDataSize[] = {
|
static const size_t QueueDataSize[] = {
|
||||||
sizeof( QueueHeader ) + sizeof( QueueZoneText ),
|
sizeof( QueueHeader ) + sizeof( QueueZoneText ),
|
||||||
|
sizeof( QueueHeader ) + sizeof( QueueZoneText ), // zone name
|
||||||
sizeof( QueueHeader ) + sizeof( QueueMessage ),
|
sizeof( QueueHeader ) + sizeof( QueueMessage ),
|
||||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location
|
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location
|
||||||
sizeof( QueueHeader ) + sizeof( QueueCallstackMemory ),
|
sizeof( QueueHeader ) + sizeof( QueueCallstackMemory ),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user