diff --git a/profiler/src/profiler/TracyView.hpp b/profiler/src/profiler/TracyView.hpp index 29f6cf51..6b37be70 100644 --- a/profiler/src/profiler/TracyView.hpp +++ b/profiler/src/profiler/TracyView.hpp @@ -1038,6 +1038,7 @@ private: Range m_statRange; Range m_flameRange; Range m_waitStackRange; + Range m_framesRange; std::array m_ranges; diff --git a/profiler/src/profiler/TracyViewData.hpp b/profiler/src/profiler/TracyViewData.hpp index fbcd5509..79dcb079 100644 --- a/profiler/src/profiler/TracyViewData.hpp +++ b/profiler/src/profiler/TracyViewData.hpp @@ -46,6 +46,7 @@ enum class RangeId FlameGraph, WaitStacks, Memory, + FrameStatistics, NUM }; diff --git a/profiler/src/profiler/TracyView_FrameStatistics.cpp b/profiler/src/profiler/TracyView_FrameStatistics.cpp index fb4dbdab..1bb3319b 100644 --- a/profiler/src/profiler/TracyView_FrameStatistics.cpp +++ b/profiler/src/profiler/TracyView_FrameStatistics.cpp @@ -46,14 +46,43 @@ void View::DrawFrameStatistics() ImGui::PopStyleVar(); ImGui::SameLine(); SmallCheckbox( "Limit to view", &m_frameSortData.limitToView ); - if( m_frameSortData.limitToView ) + ImGui::SameLine(); + if( SmallCheckbox( "Limit range", &m_framesRange.active ) ) + { + if( m_framesRange.active && m_framesRange.min == 0 && m_framesRange.max == 0 ) + { + m_framesRange.min = m_vd.zvStart; + m_framesRange.max = m_vd.zvEnd; + } + } + const auto limitingRange = m_frameSortData.limitToView || m_framesRange.active; + if( limitingRange ) { ImGui::SameLine(); TextColoredUnformatted( 0xFF00FFFF, ICON_FA_TRIANGLE_EXCLAMATION ); } - const auto frameRange = m_worker.GetFrameRange( *m_frames, m_vd.zvStart, m_vd.zvEnd ); - if( m_frameSortData.frameSet != m_frames || ( m_frameSortData.limitToView && m_frameSortData.limitRange != frameRange ) || ( !m_frameSortData.limitToView && m_frameSortData.limitRange.first != -1 ) ) + std::pair frameRange = { -1, -1 }; + if( limitingRange ) + { + if( m_frameSortData.limitToView ) + { + frameRange = m_worker.GetFrameRange( *m_frames, m_vd.zvStart, m_vd.zvEnd ); + if( m_framesRange.active ) + { + const auto r = m_worker.GetFrameRange( *m_frames, m_framesRange.min, m_framesRange.max ); + if( r.first > frameRange.first ) frameRange.first = r.first; + if( r.second < frameRange.second ) frameRange.second = r.second; + if( frameRange.second < frameRange.first ) frameRange.second = frameRange.first; + } + } + else + { + assert( m_framesRange.active ); + frameRange = m_worker.GetFrameRange( *m_frames, m_framesRange.min, m_framesRange.max ); + } + } + if( m_frameSortData.frameSet != m_frames || ( limitingRange && m_frameSortData.limitRange != frameRange ) || ( !limitingRange && m_frameSortData.limitRange.first != -1 ) ) { m_frameSortData.frameSet = m_frames; m_frameSortData.frameNum = 0; @@ -64,7 +93,7 @@ void View::DrawFrameStatistics() bool recalc = false; int64_t total = 0; double sumSq = 0; - if( !m_frameSortData.limitToView ) + if( !limitingRange ) { if( m_frameSortData.frameNum != fsz || m_frameSortData.limitRange.first != -1 ) { diff --git a/profiler/src/profiler/TracyView_Ranges.cpp b/profiler/src/profiler/TracyView_Ranges.cpp index 315d7592..4616c66a 100644 --- a/profiler/src/profiler/TracyView_Ranges.cpp +++ b/profiler/src/profiler/TracyView_Ranges.cpp @@ -15,6 +15,7 @@ void View::SetupRanges() { &m_flameRange, 0x88B5EE, ICON_FA_FIRE_FLAME_CURVED " Flame graph" }, { &m_waitStackRange, 0xEEB588, ICON_FA_HOURGLASS_HALF " Wait stacks" }, { &m_memInfo.range, 0x88EEE3, ICON_FA_MEMORY " Memory" }, + { &m_framesRange, 0xEE88EE, ICON_FA_IMAGES " Frame statistics" }, }}; } @@ -33,6 +34,8 @@ bool View::ShouldDrawRange( const RangeId& id ) const return m_showWaitStacks; case RangeId::Memory: return m_memInfo.show; + case RangeId::FrameStatistics: + return m_showFrameStatistics; default: return false; }