From e8286600d1957d3aa3d6cd5561a8be85e5899550 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 30 Oct 2019 23:12:43 +0100 Subject: [PATCH] Use -1 as invalid GPU start time. --- server/TracyView.cpp | 22 +++++++++++----------- server/TracyWorker.cpp | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 32609e13..c0135d68 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -2106,7 +2106,7 @@ void View::DrawZones() for( auto& td : v->threadData ) { assert( !td.second.timeline.empty() ); - if( td.second.timeline.front()->gpuStart != std::numeric_limits::max() ) + if( td.second.timeline.front()->gpuStart >= 0 ) { const auto begin = td.second.timeline.front()->gpuStart; const auto drift = GpuDrift( v ); @@ -2177,7 +2177,7 @@ void View::DrawZones() for( auto& td : v->threadData ) { const auto _t0 = td.second.timeline.front()->gpuStart; - if( _t0 != std::numeric_limits::max() ) + if( _t0 >= 0 ) { // FIXME t0 = std::min( t0, _t0 ); @@ -2242,7 +2242,7 @@ void View::DrawZones() for( auto& td : v->threadData ) { const auto _t0 = td.second.timeline.front()->gpuStart; - if( _t0 != std::numeric_limits::max() ) + if( _t0 >= 0 ) { t0 = std::min( t0, _t0 ); } @@ -3308,7 +3308,7 @@ int View::DispatchGpuZoneLevel( const Vector& vec, bool hover, double static int64_t AdjustGpuTime( int64_t time, int64_t begin, int drift ) { - if( time < 0 || time == std::numeric_limits::max() ) return time; + if( time < 0 ) return time; const auto t = time - begin; return time + t / 1000000000 * drift; } @@ -3321,7 +3321,7 @@ int View::DrawGpuZoneLevel( const Vector& vec, bool hover, double pxn auto it = std::lower_bound( vec.begin(), vec.end(), std::max( 0, m_vd.zvStart - delay ), [begin, drift] ( const auto& l, const auto& r ) { return (uint64_t)AdjustGpuTime( l->gpuEnd, begin, drift ) < (uint64_t)r; } ); if( it == vec.end() ) return depth; - const auto zitend = std::lower_bound( it, vec.end(), m_vd.zvEnd + resolution, [begin, drift] ( const auto& l, const auto& r ) { return AdjustGpuTime( l->gpuStart, begin, drift ) < r; } ); + const auto zitend = std::lower_bound( it, vec.end(), std::max( 0, m_vd.zvEnd + resolution ), [begin, drift] ( const auto& l, const auto& r ) { return (uint64_t)AdjustGpuTime( l->gpuStart, begin, drift ) < (uint64_t)r; } ); if( it == zitend ) return depth; const auto w = ImGui::GetWindowContentRegionWidth() - 1; @@ -3352,13 +3352,13 @@ int View::DrawGpuZoneLevel( const Vector& vec, bool hover, double pxn for(;;) { const auto prevIt = it; - it = std::lower_bound( it, zitend, nextTime, [begin, drift] ( const auto& l, const auto& r ) { return (uint64_t)AdjustGpuTime( l->gpuEnd, begin, drift ) < (uint64_t)r; } ); + it = std::lower_bound( it, zitend, std::max( 0, nextTime ), [begin, drift] ( const auto& l, const auto& r ) { return (uint64_t)AdjustGpuTime( l->gpuEnd, begin, drift ) < (uint64_t)r; } ); if( it == prevIt ) ++it; num += std::distance( prevIt, it ); if( it == zitend ) break; const auto nend = AdjustGpuTime( m_worker.GetZoneEnd( **it ), begin, drift ); const auto pxnext = ( nend - m_vd.zvStart ) * pxns; - if( pxnext - px1 >= MinVisSize * 2 ) break; + if( pxnext < 0 || pxnext - px1 >= MinVisSize * 2 ) break; px1 = pxnext; rend = nend; nextTime = nend + nspx; @@ -3481,7 +3481,7 @@ int View::SkipGpuZoneLevel( const Vector& vec, bool hover, double pxn auto it = std::lower_bound( vec.begin(), vec.end(), std::max( 0, m_vd.zvStart - delay ), [begin, drift] ( const auto& l, const auto& r ) { return (uint64_t)AdjustGpuTime( l->gpuEnd, begin, drift ) < (uint64_t)r; } ); if( it == vec.end() ) return depth; - const auto zitend = std::lower_bound( it, vec.end(), m_vd.zvEnd + resolution, [begin, drift] ( const auto& l, const auto& r ) { return AdjustGpuTime( l->gpuStart, begin, drift ) < r; } ); + const auto zitend = std::lower_bound( it, vec.end(), std::max( 0, m_vd.zvEnd + resolution ), [begin, drift] ( const auto& l, const auto& r ) { return (uint64_t)AdjustGpuTime( l->gpuStart, begin, drift ) < (uint64_t)r; } ); if( it == zitend ) return depth; depth++; @@ -13248,7 +13248,7 @@ const GpuEvent* View::GetZoneParent( const GpuEvent& zone ) const if( timeline->empty() ) continue; for(;;) { - auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.gpuStart, [] ( const auto& l, const auto& r ) { return l < r->gpuStart; } ); + auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.gpuStart, [] ( const auto& l, const auto& r ) { return (uint64_t)l < (uint64_t)r->gpuStart; } ); if( it != timeline->begin() ) --it; if( zone.gpuEnd >= 0 && (*it)->gpuStart > zone.gpuEnd ) break; if( *it == &zone ) return parent; @@ -13297,7 +13297,7 @@ uint64_t View::GetZoneThread( const GpuEvent& zone ) const if( timeline->empty() ) continue; for(;;) { - auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.gpuStart, [] ( const auto& l, const auto& r ) { return l < r->gpuStart; } ); + auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.gpuStart, [] ( const auto& l, const auto& r ) { return (uint64_t)l < (uint64_t)r->gpuStart; } ); if( it != timeline->begin() ) --it; if( zone.gpuEnd >= 0 && (*it)->gpuStart > zone.gpuEnd ) break; if( *it == &zone ) return ctx->thread; @@ -13323,7 +13323,7 @@ const GpuCtxData* View::GetZoneCtx( const GpuEvent& zone ) const if( timeline->empty() ) continue; for(;;) { - auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.gpuStart, [] ( const auto& l, const auto& r ) { return l < r->gpuStart; } ); + auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.gpuStart, [] ( const auto& l, const auto& r ) { return (uint64_t)l < (uint64_t)r->gpuStart; } ); if( it != timeline->begin() ) --it; if( zone.gpuEnd >= 0 && (*it)->gpuStart > zone.gpuEnd ) break; if( *it == &zone ) return ctx; diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 5e88e24a..c1c01223 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -2060,7 +2060,7 @@ int64_t Worker::GetZoneEnd( const GpuEvent& ev ) for(;;) { if( ptr->gpuEnd >= 0 ) return ptr->gpuEnd; - if( ptr->child < 0 ) return ptr->gpuStart; + if( ptr->child < 0 ) return ptr->gpuStart >= 0 ? ptr->gpuStart : m_data.lastTime; ptr = GetGpuChildren( ptr->child ).back(); } } @@ -4198,7 +4198,7 @@ void Worker::ProcessGpuZoneBeginImpl( GpuEvent* zone, const QueueGpuZoneBegin& e const auto time = TscTime( cpuTime - m_data.baseTime ); zone->SetCpuStart( time ); zone->SetCpuEnd( -1 ); - zone->gpuStart = std::numeric_limits::max(); + zone->gpuStart = -1; zone->gpuEnd = -1; zone->SetSrcLoc( ShrinkSourceLocation( ev.srcloc ) ); zone->callstack.SetVal( 0 ); @@ -4315,7 +4315,7 @@ void Worker::ProcessGpuTime( const QueueGpuTime& ev ) assert( zone ); ctx->query[ev.queryId] = nullptr; - if( zone->gpuStart == std::numeric_limits::max() ) + if( zone->gpuStart < 0 ) { const auto time = ctx->timeDiff + gpuTime; zone->gpuStart = time;