From cc0ca341bb538a0fe428005d20bc571e24a3283d Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 19 Jun 2021 18:16:11 +0200 Subject: [PATCH] Add cost criteria selection UI. --- server/TracySourceView.cpp | 33 +++++++++++++++++++++++++-------- server/TracySourceView.hpp | 1 + 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp index 9095c77e..fa72da77 100644 --- a/server/TracySourceView.cpp +++ b/server/TracySourceView.cpp @@ -165,6 +165,7 @@ SourceView::SourceView( ImFont* font, GetWindowCallback gwcb ) , m_atnt( false ) , m_childCalls( false ) , m_hwSamples( true ) + , m_cost( 0 ) , m_showJumps( true ) , m_cpuArch( CpuArchUnknown ) , m_showLatency( false ) @@ -1179,7 +1180,7 @@ void SourceView::RenderSymbolView( Worker& worker, View& view ) ImGui::SameLine(); ImGui::Spacing(); ImGui::SameLine(); - TextFocused( ICON_FA_WEIGHT_HANGING " Code size:", MemSizeToString( m_codeLen ) ); + TextFocused( ICON_FA_WEIGHT_HANGING " Code:", MemSizeToString( m_codeLen ) ); } AddrStat iptotalSrc = {}, iptotalAsm = {}; @@ -1212,6 +1213,29 @@ void SourceView::RenderSymbolView( Worker& worker, View& view ) ImGui::SameLine(); ImGui::Spacing(); ImGui::SameLine(); + if( worker.GetHwSampleCountAddress() != 0 ) + { + SmallCheckbox( ICON_FA_HAMMER " Hw samples", &m_hwSamples ); + ImGui::SameLine(); + ImGui::Spacing(); + ImGui::SameLine(); + ImGui::TextUnformatted( ICON_FA_HIGHLIGHTER " Cost" ); + ImGui::SameLine(); + const char* items[] = { "Sample count", "Cycles", "Retirements" }; + float mw = 0; + for( auto& v : items ) + { + const auto w = ImGui::CalcTextSize( v ).x; + if( w > mw ) mw = w; + } + ImGui::SetNextItemWidth( mw + ImGui::GetFontSize() ); + ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) ); + ImGui::Combo( "##cost", &m_cost, items, sizeof( items ) / sizeof( *items ) ); + ImGui::PopStyleVar(); + ImGui::SameLine(); + ImGui::Spacing(); + ImGui::SameLine(); + } if( !slzReady ) { ImGui::PushItemFlag( ImGuiItemFlags_Disabled, true ); @@ -1222,13 +1246,6 @@ void SourceView::RenderSymbolView( Worker& worker, View& view ) { m_childCalls = !m_childCalls; } - if( worker.GetHwSampleCountAddress() != 0 ) - { - SmallCheckbox( ICON_FA_HAND_POINT_DOWN " Hardware samples", &m_hwSamples ); - ImGui::SameLine(); - ImGui::Spacing(); - ImGui::SameLine(); - } SmallCheckbox( ICON_FA_SIGN_OUT_ALT " Child calls", &m_childCalls ); if( !slzReady ) { diff --git a/server/TracySourceView.hpp b/server/TracySourceView.hpp index 31b622ff..3b2fc17d 100644 --- a/server/TracySourceView.hpp +++ b/server/TracySourceView.hpp @@ -186,6 +186,7 @@ private: uint64_t m_jumpPopupAddr; bool m_hwSamples; bool m_childCalls; + int m_cost; SourceContents m_source; SourceContents m_sourceTooltip;