1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-29 04:23:51 +00:00

Simplify ZoneBegin functions

This commit is contained in:
Igor S. Gerasimov 2025-01-02 11:09:45 +01:00
parent 3f700c93a6
commit d30a2d6854
2 changed files with 31 additions and 48 deletions

View File

@ -4291,20 +4291,16 @@ TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin_callstack( const struct ___trac
TracyQueueCommitC( zoneValidationThread );
}
#endif
if (depth > 0 && tracy::has_callstack()) {
auto zoneQueue = tracy::QueueType::ZoneBegin;
if( depth > 0 && tracy::has_callstack() ) {
tracy::GetProfiler().SendCallstack( depth );
{
TracyQueuePrepareC( tracy::QueueType::ZoneBeginCallstack );
tracy::MemWrite( &item->zoneBegin.time, tracy::Profiler::GetTime() );
tracy::MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
TracyQueueCommitC( zoneBeginThread );
}
} else {
TracyQueuePrepareC( tracy::QueueType::ZoneBegin );
tracy::MemWrite( &item->zoneBegin.time, tracy::Profiler::GetTime() );
tracy::MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
TracyQueueCommitC( zoneBeginThread );
zoneQueue = tracy::QueueType::ZoneBeginCallstack;
}
TracyQueuePrepareC( zoneQueue );
tracy::MemWrite( &item->zoneBegin.time, tracy::Profiler::GetTime() );
tracy::MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
TracyQueueCommitC( zoneBeginThread );
return ctx;
}
@ -4363,20 +4359,16 @@ TRACY_API TracyCZoneCtx ___tracy_emit_zone_begin_alloc_callstack( uint64_t srclo
TracyQueueCommitC( zoneValidationThread );
}
#endif
if (depth > 0 && tracy::has_callstack()) {
auto zoneQueue = tracy::QueueType::ZoneBeginAllocSrcLoc;
if( depth > 0 && tracy::has_callstack() ) {
tracy::GetProfiler().SendCallstack( depth );
{
TracyQueuePrepareC( tracy::QueueType::ZoneBeginAllocSrcLocCallstack );
tracy::MemWrite( &item->zoneBegin.time, tracy::Profiler::GetTime() );
tracy::MemWrite( &item->zoneBegin.srcloc, srcloc );
TracyQueueCommitC( zoneBeginThread );
}
} else {
TracyQueuePrepareC( tracy::QueueType::ZoneBeginAllocSrcLoc );
tracy::MemWrite( &item->zoneBegin.time, tracy::Profiler::GetTime() );
tracy::MemWrite( &item->zoneBegin.srcloc, srcloc );
TracyQueueCommitC( zoneBeginThread );
zoneQueue = tracy::QueueType::ZoneBeginAllocSrcLocCallstack;
}
TracyQueuePrepareC( zoneQueue );
tracy::MemWrite( &item->zoneBegin.time, tracy::Profiler::GetTime() );
tracy::MemWrite( &item->zoneBegin.srcloc, srcloc );
TracyQueueCommitC( zoneBeginThread );
return ctx;
}

View File

@ -34,19 +34,15 @@ public:
#ifdef TRACY_ON_DEMAND
m_connectionId = GetProfiler().ConnectionId();
#endif
if (depth > 0 && has_callstack()) {
auto zoneQueue = QueueType::ZoneBegin;
if( depth > 0 && has_callstack() ) {
GetProfiler().SendCallstack( depth );
TracyQueuePrepare( QueueType::ZoneBeginCallstack );
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
TracyQueueCommit( zoneBeginThread );
} else {
TracyQueuePrepare( QueueType::ZoneBegin );
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
TracyQueueCommit( zoneBeginThread );
zoneQueue = QueueType::ZoneBeginCallstack;
}
TracyQueuePrepare( zoneQueue );
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
TracyQueueCommit( zoneBeginThread );
}
tracy_force_inline ScopedZone( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, uint32_t color, int depth = -1, bool is_active = true )
@ -60,21 +56,16 @@ public:
#ifdef TRACY_ON_DEMAND
m_connectionId = GetProfiler().ConnectionId();
#endif
if (depth > 0 && has_callstack()) {
auto zoneQueue = QueueType::ZoneBeginAllocSrcLoc;
if( depth > 0 && has_callstack() ) {
GetProfiler().SendCallstack( depth );
TracyQueuePrepare( QueueType::ZoneBeginAllocSrcLocCallstack );
const auto srcloc = Profiler::AllocSourceLocation( line, source, sourceSz, function, functionSz, name, nameSz, color );
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
MemWrite( &item->zoneBegin.srcloc, srcloc );
TracyQueueCommit( zoneBeginThread );
} else {
TracyQueuePrepare( QueueType::ZoneBeginAllocSrcLoc );
const auto srcloc = Profiler::AllocSourceLocation( line, source, sourceSz, function, functionSz, name, nameSz, color );
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
MemWrite( &item->zoneBegin.srcloc, srcloc );
TracyQueueCommit( zoneBeginThread );
zoneQueue = QueueType::ZoneBeginAllocSrcLocCallstack;
}
TracyQueuePrepare( zoneQueue );
const auto srcloc = Profiler::AllocSourceLocation( line, source, sourceSz, function, functionSz, name, nameSz, color );
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
MemWrite( &item->zoneBegin.srcloc, srcloc );
TracyQueueCommit( zoneBeginThread );
}
tracy_force_inline ScopedZone( uint32_t line, const char* source, size_t sourceSz, const char* function, size_t functionSz, const char* name, size_t nameSz, int depth, bool is_active = true ) : ScopedZone( line, source, sourceSz, function, functionSz, name, nameSz, 0, depth, is_active ) {}