Another fix for determining if there's CPU usage data to draw.

This commit is contained in:
Bartosz Taudul 2023-04-15 12:36:42 +02:00
parent f0acb73d09
commit 9b270c8e11
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -65,8 +65,7 @@ void TimelineItemCpuData::Preprocess( const TimelineContext& ctx, TaskDispatch&
const auto ostep = ty + 1; const auto ostep = ty + 1;
const auto sstep = sty + 1; const auto sstep = sty + 1;
m_hasCpuData = false; bool hasCpuData = false;
auto pos = yPos + ostep; auto pos = yPos + ostep;
#ifdef TRACY_NO_STATISTICS #ifdef TRACY_NO_STATISTICS
@ -74,6 +73,28 @@ void TimelineItemCpuData::Preprocess( const TimelineContext& ctx, TaskDispatch&
#else #else
if( m_view.GetViewData().drawCpuUsageGraph && m_worker.IsCpuUsageReady() ) if( m_view.GetViewData().drawCpuUsageGraph && m_worker.IsCpuUsageReady() )
#endif #endif
{
#ifndef TRACY_NO_STATISTICS
auto& ctxUsage = m_worker.GetCpuUsage();
if( !ctxUsage.empty() )
{
hasCpuData = true;
}
else
#endif
{
const auto cpuDataCount = m_worker.GetCpuDataCpuCount();
const auto cpuData = m_worker.GetCpuData();
for( int i=0; i<cpuDataCount; i++ )
{
if( !cpuData[i].cs.empty() )
{
hasCpuData = true;
break;
}
}
}
if( hasCpuData )
{ {
const auto cpuUsageHeight = floor( 30.f * GetScale() ); const auto cpuUsageHeight = floor( 30.f * GetScale() );
if( pos <= yMax && pos + cpuUsageHeight + 3 >= yMin ) if( pos <= yMax && pos + cpuUsageHeight + 3 >= yMin )
@ -84,6 +105,8 @@ void TimelineItemCpuData::Preprocess( const TimelineContext& ctx, TaskDispatch&
} }
pos += cpuUsageHeight + 3; pos += cpuUsageHeight + 3;
} }
}
m_hasCpuData = hasCpuData;
auto cpuData = m_worker.GetCpuData(); auto cpuData = m_worker.GetCpuData();
const auto cpuCnt = m_worker.GetCpuDataCpuCount(); const auto cpuCnt = m_worker.GetCpuDataCpuCount();
@ -161,7 +184,6 @@ void TimelineItemCpuData::PreprocessCpuUsage( const TimelineContext& ctx )
auto& ctxUsage = m_worker.GetCpuUsage(); auto& ctxUsage = m_worker.GetCpuUsage();
if( !ctxUsage.empty() ) if( !ctxUsage.empty() )
{ {
m_hasCpuData = true;
auto itBegin = ctxUsage.begin(); auto itBegin = ctxUsage.begin();
for( size_t i=0; i<num; i++ ) for( size_t i=0; i<num; i++ )
{ {
@ -204,7 +226,6 @@ void TimelineItemCpuData::PreprocessCpuUsage( const TimelineContext& ctx )
auto& cs = cpuData[i].cs; auto& cs = cpuData[i].cs;
if( !cs.empty() ) if( !cs.empty() )
{ {
m_hasCpuData = true;
auto itBegin = cs.begin(); auto itBegin = cs.begin();
auto ptr = m_cpuDraw.data(); auto ptr = m_cpuDraw.data();
for( size_t i=0; i<num; i++ ) for( size_t i=0; i<num; i++ )