mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Send zone validation messages.
This is only performed for C API, as C++ scoped zones are always properly ordered, due to RAII. With manual submission of zone begin and end events there's no such guarantee.
This commit is contained in:
parent
970108fbbf
commit
8e52ab318b
@ -1752,9 +1752,21 @@ TracyCZoneCtx ___tracy_emit_zone_begin( const struct ___tracy_source_location_da
|
||||
ctx.active = active;
|
||||
#endif
|
||||
if( !ctx.active ) return ctx;
|
||||
const auto thread = tracy::GetThreadHandle();
|
||||
const auto id = tracy::s_profiler.GetNextZoneId();
|
||||
ctx.id = id;
|
||||
|
||||
tracy::Magic magic;
|
||||
auto& token = tracy::s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
{
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneValidation );
|
||||
tracy::MemWrite( &item->zoneValidation.thread, thread );
|
||||
tracy::MemWrite( &item->zoneValidation.id, id );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
{
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneBegin );
|
||||
#ifdef TRACY_RDTSCP_OPT
|
||||
@ -1764,9 +1776,10 @@ TracyCZoneCtx ___tracy_emit_zone_begin( const struct ___tracy_source_location_da
|
||||
tracy::MemWrite( &item->zoneBegin.time, tracy::Profiler::GetTime( cpu ) );
|
||||
tracy::MemWrite( &item->zoneBegin.cpu, cpu );
|
||||
#endif
|
||||
tracy::MemWrite( &item->zoneBegin.thread, tracy::GetThreadHandle() );
|
||||
tracy::MemWrite( &item->zoneBegin.thread, thread );
|
||||
tracy::MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
@ -1780,9 +1793,20 @@ TracyCZoneCtx ___tracy_emit_zone_begin_callstack( const struct ___tracy_source_l
|
||||
#endif
|
||||
if( !ctx.active ) return ctx;
|
||||
const auto thread = tracy::GetThreadHandle();
|
||||
const auto id = tracy::s_profiler.GetNextZoneId();
|
||||
ctx.id = id;
|
||||
|
||||
tracy::Magic magic;
|
||||
auto& token = tracy::s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
{
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneValidation );
|
||||
tracy::MemWrite( &item->zoneValidation.thread, thread );
|
||||
tracy::MemWrite( &item->zoneValidation.id, id );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
{
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneBeginCallstack );
|
||||
#ifdef TRACY_RDTSCP_OPT
|
||||
@ -1795,6 +1819,7 @@ TracyCZoneCtx ___tracy_emit_zone_begin_callstack( const struct ___tracy_source_l
|
||||
tracy::MemWrite( &item->zoneBegin.thread, thread );
|
||||
tracy::MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
|
||||
tracy::s_profiler.SendCallstack( depth, thread );
|
||||
return ctx;
|
||||
@ -1803,9 +1828,18 @@ TracyCZoneCtx ___tracy_emit_zone_begin_callstack( const struct ___tracy_source_l
|
||||
void ___tracy_emit_zone_end( TracyCZoneCtx ctx )
|
||||
{
|
||||
if( !ctx.active ) return;
|
||||
const auto thread = tracy::GetThreadHandle();
|
||||
tracy::Magic magic;
|
||||
auto& token = tracy::s_token.ptr;
|
||||
auto& tail = token->get_tail_index();
|
||||
{
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneValidation );
|
||||
tracy::MemWrite( &item->zoneValidation.thread, thread );
|
||||
tracy::MemWrite( &item->zoneValidation.id, ctx.id );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
{
|
||||
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneEnd );
|
||||
#ifdef TRACY_RDTSCP_OPT
|
||||
@ -1815,9 +1849,10 @@ void ___tracy_emit_zone_end( TracyCZoneCtx ctx )
|
||||
tracy::MemWrite( &item->zoneEnd.time, tracy::Profiler::GetTime( cpu ) );
|
||||
tracy::MemWrite( &item->zoneEnd.cpu, cpu );
|
||||
#endif
|
||||
tracy::MemWrite( &item->zoneEnd.thread, tracy::GetThreadHandle() );
|
||||
tracy::MemWrite( &item->zoneEnd.thread, thread );
|
||||
tail.store( magic + 1, std::memory_order_release );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user