mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 04:23:51 +00:00
Preserve zone text, zone name string length.
This commit is contained in:
parent
986a2a79da
commit
9d01fa86ab
15
TracyLua.hpp
15
TracyLua.hpp
@ -125,6 +125,7 @@ static inline void LuaRemove( char* script )
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
#include "common/TracyColor.hpp"
|
#include "common/TracyColor.hpp"
|
||||||
#include "common/TracyAlign.hpp"
|
#include "common/TracyAlign.hpp"
|
||||||
@ -328,12 +329,13 @@ static inline int LuaZoneText( lua_State* L )
|
|||||||
|
|
||||||
auto txt = lua_tostring( L, 1 );
|
auto txt = lua_tostring( L, 1 );
|
||||||
const auto size = strlen( txt );
|
const auto size = strlen( txt );
|
||||||
|
assert( size < std::numeric_limits<uint16_t>::max() );
|
||||||
|
|
||||||
auto ptr = (char*)tracy_malloc( size+1 );
|
auto ptr = (char*)tracy_malloc( size );
|
||||||
memcpy( ptr, txt, size );
|
memcpy( ptr, txt, size );
|
||||||
ptr[size] = '\0';
|
|
||||||
TracyLfqPrepare( QueueType::ZoneText );
|
TracyLfqPrepare( QueueType::ZoneText );
|
||||||
MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
MemWrite( &item->zoneTextFat.text, (uint64_t)ptr );
|
||||||
|
MemWrite( &item->zoneTextFat.size, (uint16_t)size );
|
||||||
TracyLfqCommit;
|
TracyLfqCommit;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -351,12 +353,13 @@ static inline int LuaZoneName( lua_State* L )
|
|||||||
|
|
||||||
auto txt = lua_tostring( L, 1 );
|
auto txt = lua_tostring( L, 1 );
|
||||||
const auto size = strlen( txt );
|
const auto size = strlen( txt );
|
||||||
|
assert( size < std::numeric_limits<uint16_t>::max() );
|
||||||
|
|
||||||
auto ptr = (char*)tracy_malloc( size+1 );
|
auto ptr = (char*)tracy_malloc( size );
|
||||||
memcpy( ptr, txt, size );
|
memcpy( ptr, txt, size );
|
||||||
ptr[size] = '\0';
|
|
||||||
TracyLfqPrepare( QueueType::ZoneName );
|
TracyLfqPrepare( QueueType::ZoneName );
|
||||||
MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
MemWrite( &item->zoneTextFat.text, (uint64_t)ptr );
|
||||||
|
MemWrite( &item->zoneTextFat.size, (uint16_t)size );
|
||||||
TracyLfqCommit;
|
TracyLfqCommit;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1825,6 +1825,7 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
|||||||
while( sz-- > 0 )
|
while( sz-- > 0 )
|
||||||
{
|
{
|
||||||
uint64_t ptr;
|
uint64_t ptr;
|
||||||
|
uint16_t size;
|
||||||
auto idx = MemRead<uint8_t>( &item->hdr.idx );
|
auto idx = MemRead<uint8_t>( &item->hdr.idx );
|
||||||
if( idx < (int)QueueType::Terminate )
|
if( idx < (int)QueueType::Terminate )
|
||||||
{
|
{
|
||||||
@ -1832,8 +1833,9 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
|||||||
{
|
{
|
||||||
case QueueType::ZoneText:
|
case QueueType::ZoneText:
|
||||||
case QueueType::ZoneName:
|
case QueueType::ZoneName:
|
||||||
ptr = MemRead<uint64_t>( &item->zoneText.text );
|
ptr = MemRead<uint64_t>( &item->zoneTextFat.text );
|
||||||
SendString( ptr, (const char*)ptr, QueueType::CustomStringData );
|
size = MemRead<uint16_t>( &item->zoneTextFat.size );
|
||||||
|
SendString( ptr, (const char*)ptr, size, QueueType::CustomStringData );
|
||||||
tracy_free( (void*)ptr );
|
tracy_free( (void*)ptr );
|
||||||
break;
|
break;
|
||||||
case QueueType::Message:
|
case QueueType::Message:
|
||||||
@ -3046,10 +3048,10 @@ 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 )
|
||||||
{
|
{
|
||||||
|
assert( size < std::numeric_limits<uint16_t>::max() );
|
||||||
if( !ctx.active ) return;
|
if( !ctx.active ) return;
|
||||||
auto ptr = (char*)tracy::tracy_malloc( size+1 );
|
auto ptr = (char*)tracy::tracy_malloc( size );
|
||||||
memcpy( ptr, txt, size );
|
memcpy( ptr, txt, size );
|
||||||
ptr[size] = '\0';
|
|
||||||
#ifndef TRACY_NO_VERIFY
|
#ifndef TRACY_NO_VERIFY
|
||||||
{
|
{
|
||||||
TracyLfqPrepareC( tracy::QueueType::ZoneValidation );
|
TracyLfqPrepareC( tracy::QueueType::ZoneValidation );
|
||||||
@ -3059,17 +3061,18 @@ TRACY_API void ___tracy_emit_zone_text( TracyCZoneCtx ctx, const char* txt, size
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
TracyLfqPrepareC( tracy::QueueType::ZoneText );
|
TracyLfqPrepareC( tracy::QueueType::ZoneText );
|
||||||
tracy::MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
tracy::MemWrite( &item->zoneTextFat.text, (uint64_t)ptr );
|
||||||
|
tracy::MemWrite( &item->zoneTextFat.size, (uint16_t)size );
|
||||||
TracyLfqCommitC;
|
TracyLfqCommitC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 )
|
||||||
{
|
{
|
||||||
|
assert( size < std::numeric_limits<uint16_t>::max() );
|
||||||
if( !ctx.active ) return;
|
if( !ctx.active ) return;
|
||||||
auto ptr = (char*)tracy::tracy_malloc( size+1 );
|
auto ptr = (char*)tracy::tracy_malloc( size );
|
||||||
memcpy( ptr, txt, size );
|
memcpy( ptr, txt, size );
|
||||||
ptr[size] = '\0';
|
|
||||||
#ifndef TRACY_NO_VERIFY
|
#ifndef TRACY_NO_VERIFY
|
||||||
{
|
{
|
||||||
TracyLfqPrepareC( tracy::QueueType::ZoneValidation );
|
TracyLfqPrepareC( tracy::QueueType::ZoneValidation );
|
||||||
@ -3079,7 +3082,8 @@ TRACY_API void ___tracy_emit_zone_name( TracyCZoneCtx ctx, const char* txt, size
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
TracyLfqPrepareC( tracy::QueueType::ZoneName );
|
TracyLfqPrepareC( tracy::QueueType::ZoneName );
|
||||||
tracy::MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
tracy::MemWrite( &item->zoneTextFat.text, (uint64_t)ptr );
|
||||||
|
tracy::MemWrite( &item->zoneTextFat.size, (uint16_t)size );
|
||||||
TracyLfqCommitC;
|
TracyLfqCommitC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef __TRACYSCOPED_HPP__
|
#ifndef __TRACYSCOPED_HPP__
|
||||||
#define __TRACYSCOPED_HPP__
|
#define __TRACYSCOPED_HPP__
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -64,29 +65,31 @@ public:
|
|||||||
|
|
||||||
tracy_force_inline void Text( const char* txt, size_t size )
|
tracy_force_inline void Text( const char* txt, size_t size )
|
||||||
{
|
{
|
||||||
|
assert( size < std::numeric_limits<uint16_t>::max() );
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
||||||
#endif
|
#endif
|
||||||
auto ptr = (char*)tracy_malloc( size+1 );
|
auto ptr = (char*)tracy_malloc( size );
|
||||||
memcpy( ptr, txt, size );
|
memcpy( ptr, txt, size );
|
||||||
ptr[size] = '\0';
|
|
||||||
TracyLfqPrepare( QueueType::ZoneText );
|
TracyLfqPrepare( QueueType::ZoneText );
|
||||||
MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
MemWrite( &item->zoneTextFat.text, (uint64_t)ptr );
|
||||||
|
MemWrite( &item->zoneTextFat.size, (uint16_t)size );
|
||||||
TracyLfqCommit;
|
TracyLfqCommit;
|
||||||
}
|
}
|
||||||
|
|
||||||
tracy_force_inline void Name( const char* txt, size_t size )
|
tracy_force_inline void Name( const char* txt, size_t size )
|
||||||
{
|
{
|
||||||
|
assert( size < std::numeric_limits<uint16_t>::max() );
|
||||||
if( !m_active ) return;
|
if( !m_active ) return;
|
||||||
#ifdef TRACY_ON_DEMAND
|
#ifdef TRACY_ON_DEMAND
|
||||||
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
if( GetProfiler().ConnectionId() != m_connectionId ) return;
|
||||||
#endif
|
#endif
|
||||||
auto ptr = (char*)tracy_malloc( size+1 );
|
auto ptr = (char*)tracy_malloc( size );
|
||||||
memcpy( ptr, txt, size );
|
memcpy( ptr, txt, size );
|
||||||
ptr[size] = '\0';
|
|
||||||
TracyLfqPrepare( QueueType::ZoneName );
|
TracyLfqPrepare( QueueType::ZoneName );
|
||||||
MemWrite( &item->zoneText.text, (uint64_t)ptr );
|
MemWrite( &item->zoneTextFat.text, (uint64_t)ptr );
|
||||||
|
MemWrite( &item->zoneTextFat.size, (uint16_t)size );
|
||||||
TracyLfqCommit;
|
TracyLfqCommit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,6 +170,11 @@ struct QueueZoneText
|
|||||||
uint64_t text; // ptr
|
uint64_t text; // ptr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct QueueZoneTextFat : public QueueZoneText
|
||||||
|
{
|
||||||
|
uint16_t size;
|
||||||
|
};
|
||||||
|
|
||||||
enum class LockType : uint8_t
|
enum class LockType : uint8_t
|
||||||
{
|
{
|
||||||
Lockable,
|
Lockable,
|
||||||
@ -477,6 +482,7 @@ struct QueueItem
|
|||||||
QueueFrameImage frameImageLean;
|
QueueFrameImage frameImageLean;
|
||||||
QueueSourceLocation srcloc;
|
QueueSourceLocation srcloc;
|
||||||
QueueZoneText zoneText;
|
QueueZoneText zoneText;
|
||||||
|
QueueZoneTextFat zoneTextFat;
|
||||||
QueueLockAnnounce lockAnnounce;
|
QueueLockAnnounce lockAnnounce;
|
||||||
QueueLockTerminate lockTerminate;
|
QueueLockTerminate lockTerminate;
|
||||||
QueueLockWait lockWait;
|
QueueLockWait lockWait;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user