mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-23 06:44:35 +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;
|
ctx.active = active;
|
||||||
#endif
|
#endif
|
||||||
if( !ctx.active ) return ctx;
|
if( !ctx.active ) return ctx;
|
||||||
|
const auto thread = tracy::GetThreadHandle();
|
||||||
|
const auto id = tracy::s_profiler.GetNextZoneId();
|
||||||
|
ctx.id = id;
|
||||||
|
|
||||||
tracy::Magic magic;
|
tracy::Magic magic;
|
||||||
auto& token = tracy::s_token.ptr;
|
auto& token = tracy::s_token.ptr;
|
||||||
auto& tail = token->get_tail_index();
|
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 );
|
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneBegin );
|
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneBegin );
|
||||||
#ifdef TRACY_RDTSCP_OPT
|
#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.time, tracy::Profiler::GetTime( cpu ) );
|
||||||
tracy::MemWrite( &item->zoneBegin.cpu, cpu );
|
tracy::MemWrite( &item->zoneBegin.cpu, cpu );
|
||||||
#endif
|
#endif
|
||||||
tracy::MemWrite( &item->zoneBegin.thread, tracy::GetThreadHandle() );
|
tracy::MemWrite( &item->zoneBegin.thread, thread );
|
||||||
tracy::MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
|
tracy::MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
|
||||||
tail.store( magic + 1, std::memory_order_release );
|
tail.store( magic + 1, std::memory_order_release );
|
||||||
|
}
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1780,9 +1793,20 @@ TracyCZoneCtx ___tracy_emit_zone_begin_callstack( const struct ___tracy_source_l
|
|||||||
#endif
|
#endif
|
||||||
if( !ctx.active ) return ctx;
|
if( !ctx.active ) return ctx;
|
||||||
const auto thread = tracy::GetThreadHandle();
|
const auto thread = tracy::GetThreadHandle();
|
||||||
|
const auto id = tracy::s_profiler.GetNextZoneId();
|
||||||
|
ctx.id = id;
|
||||||
|
|
||||||
tracy::Magic magic;
|
tracy::Magic magic;
|
||||||
auto& token = tracy::s_token.ptr;
|
auto& token = tracy::s_token.ptr;
|
||||||
auto& tail = token->get_tail_index();
|
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 );
|
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneBeginCallstack );
|
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneBeginCallstack );
|
||||||
#ifdef TRACY_RDTSCP_OPT
|
#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.thread, thread );
|
||||||
tracy::MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
|
tracy::MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
|
||||||
tail.store( magic + 1, std::memory_order_release );
|
tail.store( magic + 1, std::memory_order_release );
|
||||||
|
}
|
||||||
|
|
||||||
tracy::s_profiler.SendCallstack( depth, thread );
|
tracy::s_profiler.SendCallstack( depth, thread );
|
||||||
return ctx;
|
return ctx;
|
||||||
@ -1803,9 +1828,18 @@ TracyCZoneCtx ___tracy_emit_zone_begin_callstack( const struct ___tracy_source_l
|
|||||||
void ___tracy_emit_zone_end( TracyCZoneCtx ctx )
|
void ___tracy_emit_zone_end( TracyCZoneCtx ctx )
|
||||||
{
|
{
|
||||||
if( !ctx.active ) return;
|
if( !ctx.active ) return;
|
||||||
|
const auto thread = tracy::GetThreadHandle();
|
||||||
tracy::Magic magic;
|
tracy::Magic magic;
|
||||||
auto& token = tracy::s_token.ptr;
|
auto& token = tracy::s_token.ptr;
|
||||||
auto& tail = token->get_tail_index();
|
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 );
|
auto item = token->enqueue_begin<tracy::moodycamel::CanAlloc>( magic );
|
||||||
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneEnd );
|
tracy::MemWrite( &item->hdr.type, tracy::QueueType::ZoneEnd );
|
||||||
#ifdef TRACY_RDTSCP_OPT
|
#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.time, tracy::Profiler::GetTime( cpu ) );
|
||||||
tracy::MemWrite( &item->zoneEnd.cpu, cpu );
|
tracy::MemWrite( &item->zoneEnd.cpu, cpu );
|
||||||
#endif
|
#endif
|
||||||
tracy::MemWrite( &item->zoneEnd.thread, tracy::GetThreadHandle() );
|
tracy::MemWrite( &item->zoneEnd.thread, thread );
|
||||||
tail.store( magic + 1, std::memory_order_release );
|
tail.store( magic + 1, std::memory_order_release );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user