Fix invalid tracy events from C# profiling api when profiler gets connected mid-event
This commit is contained in:
@@ -108,6 +108,7 @@ namespace
|
||||
};
|
||||
|
||||
ChunkedArray<Location, 256> ManagedSourceLocations;
|
||||
uint32 ManagedEventsCount[PLATFORM_THREADS_LIMIT] = { 0 };
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@@ -145,7 +146,9 @@ DEFINE_INTERNAL_CALL(void) ProfilerInternal_BeginEvent(MString* nameObj)
|
||||
srcLoc->color = 0;
|
||||
}
|
||||
//static constexpr tracy::SourceLocationData tracySrcLoc{ nullptr, __FUNCTION__, __FILE__, (uint32_t)__LINE__, 0 };
|
||||
tracy::ScopedZone::Begin(srcLoc);
|
||||
const bool tracyActive = tracy::ScopedZone::Begin(srcLoc);
|
||||
if (tracyActive)
|
||||
ManagedEventsCount[Platform::GetCurrentThreadID()]++;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
@@ -155,7 +158,12 @@ DEFINE_INTERNAL_CALL(void) ProfilerInternal_EndEvent()
|
||||
{
|
||||
#if COMPILE_WITH_PROFILER
|
||||
#if TRACY_ENABLE
|
||||
tracy::ScopedZone::End();
|
||||
auto& tracyActive = ManagedEventsCount[Platform::GetCurrentThreadID()];
|
||||
if (tracyActive > 0)
|
||||
{
|
||||
tracyActive--;
|
||||
tracy::ScopedZone::End();
|
||||
}
|
||||
#endif
|
||||
ProfilerCPU::EndEvent();
|
||||
#endif
|
||||
|
||||
@@ -12,15 +12,16 @@
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
void ScopedZone::Begin(const SourceLocationData* srcloc)
|
||||
bool ScopedZone::Begin(const SourceLocationData* srcloc)
|
||||
{
|
||||
#ifdef TRACY_ON_DEMAND
|
||||
if (!GetProfiler().IsConnected()) return;
|
||||
if (!GetProfiler().IsConnected()) return false;
|
||||
#endif
|
||||
TracyLfqPrepare( QueueType::ZoneBegin );
|
||||
MemWrite( &item->zoneBegin.time, Profiler::GetTime() );
|
||||
MemWrite( &item->zoneBegin.srcloc, (uint64_t)srcloc );
|
||||
TracyQueueCommit( zoneBeginThread );
|
||||
return true;
|
||||
}
|
||||
|
||||
void ScopedZone::End()
|
||||
|
||||
@@ -39,7 +39,7 @@ struct TRACY_API SourceLocationData
|
||||
class TRACY_API ScopedZone
|
||||
{
|
||||
public:
|
||||
static void Begin( const SourceLocationData* srcloc );
|
||||
static bool Begin( const SourceLocationData* srcloc );
|
||||
static void End();
|
||||
|
||||
ScopedZone( const ScopedZone& ) = delete;
|
||||
|
||||
Reference in New Issue
Block a user