diff --git a/profiler/src/profiler/TracyTimelineItemPlot.cpp b/profiler/src/profiler/TracyTimelineItemPlot.cpp index bb328726..272e9a47 100644 --- a/profiler/src/profiler/TracyTimelineItemPlot.cpp +++ b/profiler/src/profiler/TracyTimelineItemPlot.cpp @@ -112,7 +112,7 @@ int64_t TimelineItemPlot::RangeEnd() const bool TimelineItemPlot::DrawContents( const TimelineContext& ctx, int& offset ) { - return m_view.DrawPlot( ctx, *m_plot, m_draw, offset ); + return m_view.DrawPlot( ctx, *m_plot, m_draw, offset, m_rightEnd ); } void TimelineItemPlot::DrawFinished() @@ -138,17 +138,30 @@ void TimelineItemPlot::Preprocess( const TimelineContext& ctx, TaskDispatch& td, auto& vec = m_plot->data; vec.ensure_sorted(); - if( vec.front().time.Val() > vEnd || vec.back().time.Val() < vStart ) + if( vec.front().time.Val() > vEnd ) { m_plot->rMin = 0; m_plot->rMax = 0; m_plot->num = 0; + m_rightEnd = false; + return; + } + else if( vec.back().time.Val() < vStart ) + { + const auto lastTime = m_worker.GetLastTime(); + const auto val = vec.back().val; + m_plot->rMin = val - 1; + m_plot->rMax = val + 1; + m_plot->num = lastTime < vStart ? 0 : 1; + m_rightEnd = vec.back().time.Val() < lastTime; return; } auto it = std::lower_bound( vec.begin(), vec.end(), vStart, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } ); auto end = std::lower_bound( it, vec.end(), vEnd, [] ( const auto& l, const auto& r ) { return l.time.Val() < r; } ); + m_rightEnd = end == vec.end() && vec.back().time.Val() < m_worker.GetLastTime(); + if( end != vec.end() ) end++; if( it != vec.begin() ) it--; diff --git a/profiler/src/profiler/TracyTimelineItemPlot.hpp b/profiler/src/profiler/TracyTimelineItemPlot.hpp index ec2fdf0e..a57e98eb 100644 --- a/profiler/src/profiler/TracyTimelineItemPlot.hpp +++ b/profiler/src/profiler/TracyTimelineItemPlot.hpp @@ -36,6 +36,7 @@ private: PlotData* m_plot; std::vector m_draw; + bool m_rightEnd; }; } diff --git a/profiler/src/profiler/TracyView.hpp b/profiler/src/profiler/TracyView.hpp index 1c1ee4b1..cf33765d 100644 --- a/profiler/src/profiler/TracyView.hpp +++ b/profiler/src/profiler/TracyView.hpp @@ -151,7 +151,7 @@ public: void HighlightThread( uint64_t thread ); void ZoomToRange( int64_t start, int64_t end, bool pause = true ); - bool DrawPlot( const TimelineContext& ctx, PlotData& plot, const std::vector& plotDraw, int& offset ); + bool DrawPlot( const TimelineContext& ctx, PlotData& plot, const std::vector& plotDraw, int& offset, bool rightEnd ); void DrawThread( const TimelineContext& ctx, const ThreadData& thread, const std::vector& draw, const std::vector& ctxDraw, const std::vector& samplesDraw, const std::vector>& lockDraw, int& offset, int depth, bool hasCtxSwitches, bool hasSamples ); void DrawThreadMessagesList( const TimelineContext& ctx, const std::vector& drawList, int offset, uint64_t tid ); void DrawThreadOverlays( const ThreadData& thread, const ImVec2& ul, const ImVec2& dr ); diff --git a/profiler/src/profiler/TracyView_Plots.cpp b/profiler/src/profiler/TracyView_Plots.cpp index 9eb02a6c..a4e3cb97 100644 --- a/profiler/src/profiler/TracyView_Plots.cpp +++ b/profiler/src/profiler/TracyView_Plots.cpp @@ -11,7 +11,7 @@ namespace tracy { -bool View::DrawPlot( const TimelineContext& ctx, PlotData& plot, const std::vector& plotDraw, int& offset ) +bool View::DrawPlot( const TimelineContext& ctx, PlotData& plot, const std::vector& plotDraw, int& offset, bool rightEnd ) { auto draw = ImGui::GetWindowDrawList(); const auto& wpos = ctx.wpos; @@ -173,6 +173,34 @@ bool View::DrawPlot( const TimelineContext& ctx, PlotData& plot, const std::vect } } + if( rightEnd ) + { + const auto lastTime = m_worker.GetLastTime(); + if( lastTime > m_vd.zvStart ) + { + double y; + double x0 = 0; + const auto x1 = std::min( ( lastTime - m_vd.zvStart ) * pxns, w ); + + if( plotDraw.empty() ) + { + y = PlotHeight * 0.5; + DrawLine( draw, dpos + ImVec2( 0, offset + y ), dpos + ImVec2( x1, offset + y ), color ); + } + else + { + x0 = ( plot.data.back().time.Val() - m_vd.zvStart ) * pxns; + y = PlotHeight - ( plot.data.back().val - min ) * revrange * PlotHeight; + DrawLine( draw, dpos + ImVec2( x0, offset + y ), dpos + ImVec2( x1, offset + y ), color ); + } + + if( plot.fill ) + { + draw->AddRectFilled( dpos + ImVec2( x0, offset + PlotHeight ), dpos + ImVec2( x1, offset + y ), fill ); + } + } + } + auto tmp = FormatPlotValue( plot.rMax, plot.format ); DrawTextSuperContrast( draw, wpos + ImVec2( 0, offset ), color, tmp ); offset += PlotHeight - ty;