mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Add allocated srcloc zone begin emit functions to C API.
This commit is contained in:
parent
68ff33d0ba
commit
399b87fecc
2
TracyC.h
2
TracyC.h
@ -81,6 +81,8 @@ typedef /*const*/ struct ___tracy_c_zone_context TracyCZoneCtx;
|
||||
|
||||
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_alloc( uint64_t srcloc, int active );
|
||||
TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin_alloc_callstack( uint64_t srcloc, int depth, int active );
|
||||
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_name( TracyCZoneCtx ctx, const char* txt, size_t size );
|
||||
|
@ -2767,6 +2767,80 @@ TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin_callstack( const struct ___trac
|
||||
return ctx;
|
||||
}
|
||||
|
||||
TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin_alloc( uint64_t srcloc, int active )
|
||||
{
|
||||
___tracy_c_zone_context ctx;
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
ctx.active = active && tracy::GetProfiler().IsConnected();
|
||||
#else
|
||||
ctx.active = active;
|
||||
#endif
|
||||
if( !ctx.active ) return ctx;
|
||||
const auto id = tracy::GetProfiler().GetNextZoneId();
|
||||
ctx.id = id;
|
||||
|
||||
#ifndef TRACY_NO_VERIFY
|
||||
{
|
||||
tracy::Magic magic;
|
||||
auto token = tracy::GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneValidation );
|
||||
tracy::MemWrite( &item->zoneValidation.id, id );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
#endif
|
||||
{
|
||||
tracy::Magic magic;
|
||||
auto token = tracy::GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneBeginAllocSrcLoc );
|
||||
tracy::MemWrite( &item->zoneBegin.time, tracy::Profiler::GetTime() );
|
||||
tracy::MemWrite( &item->zoneBegin.srcloc, srcloc );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin_alloc_callstack( uint64_t srcloc, int depth, int active )
|
||||
{
|
||||
___tracy_c_zone_context ctx;
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
ctx.active = active && tracy::GetProfiler().IsConnected();
|
||||
#else
|
||||
ctx.active = active;
|
||||
#endif
|
||||
if( !ctx.active ) return ctx;
|
||||
const auto id = tracy::GetProfiler().GetNextZoneId();
|
||||
ctx.id = id;
|
||||
|
||||
#ifndef TRACY_NO_VERIFY
|
||||
{
|
||||
tracy::Magic magic;
|
||||
auto token = tracy::GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneValidation );
|
||||
tracy::MemWrite( &item->zoneValidation.id, id );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
#endif
|
||||
{
|
||||
tracy::Magic magic;
|
||||
auto token = tracy::GetToken();
|
||||
auto& tail = token->get_tail_index();
|
||||
auto item = token->enqueue_begin( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneBeginAllocSrcLocCallstack );
|
||||
tracy::MemWrite( &item->zoneBegin.time, tracy::Profiler::GetTime() );
|
||||
tracy::MemWrite( &item->zoneBegin.srcloc, srcloc );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
|
||||
tracy::GetProfiler().SendCallstack( depth );
|
||||
return ctx;
|
||||
}
|
||||
|
||||
TRACY_API void ___tracy_emit_zone_end( TracyCZoneCtx ctx )
|
||||
{
|
||||
if( !ctx.active ) return;
|
||||
|
Loading…
Reference in New Issue
Block a user