From f43755625c137f092d6a78f2eaba2e4782ad6331 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 26 Apr 2020 14:52:18 +0200 Subject: [PATCH] Add uarch selection UI. --- server/TracySourceView.cpp | 58 ++++++++++++++++++++++++++++++++++++++ server/TracySourceView.hpp | 1 + 2 files changed, 59 insertions(+) diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp index 547105f2..167c3bb1 100644 --- a/server/TracySourceView.cpp +++ b/server/TracySourceView.cpp @@ -20,6 +20,33 @@ namespace tracy { +struct MicroArchUx +{ + const char* uArch; + const char* cpuName; + const char* moniker; +}; + +static constexpr MicroArchUx s_uArchUx[] = { + { "Conroe", "Core 2 Duo E6750", "CON" }, + { "Wolfdale", "Core 2 Duo E8400", "WOL" }, + { "Nehalem", "Core i5-750", "NHM" }, + { "Westmere", "Core i5-650", "WSM" }, + { "Sandy Bridge", "Core i7-2600", "SNB" }, + { "Ivy Bridge", "Core i5-3470", "IVB" }, + { "Haswell", "Xeon E3-1225 v3", "HSW" }, + { "Broadwell", "Core i5-5200U", "BDW" }, + { "Skylake", "Core i7-6500U", "SKL" }, + { "Skylake-X", "Core i9-7900X", "SKX" }, + { "Kaby Lake", "Core i7-7700", "KBL" }, + { "Coffee Lake", "Core i7-8700K", "CFL" }, + { "Cannon Lake", "Core i3-8121U", "CNL" }, + { "Ice Lake", "Core i5-1035G1", "ICL" }, + { "AMD Zen+", "Ryzen 5 2600", "ZEN+" }, + { "AMD Zen 2", "Ryzen 7 3700X", "ZEN2" }, +}; + + enum { JumpSeparation = 6 }; enum { JumpArrowBase = 9 }; @@ -43,6 +70,7 @@ SourceView::SourceView( ImFont* font ) , m_calcInlineStats( true ) , m_showJumps( true ) , m_cpuArch( CpuArchUnknown ) + , m_selMicroArch( sizeof( s_uArchUx ) / sizeof( *s_uArchUx ) - 1 ) { } @@ -1013,6 +1041,36 @@ uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map mw ) mw = w; + } + ImGui::TextUnformatted( ICON_FA_MICROCHIP " \xce\xbc""arch:" ); + ImGui::SameLine(); + ImGui::SetNextItemWidth( mw + ImGui::GetFontSize() ); + ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) ); + if( ImGui::BeginCombo( "##uarch", s_uArchUx[m_selMicroArch].uArch, ImGuiComboFlags_HeightLarge ) ) + { + int idx = 0; + for( auto& v : s_uArchUx ) + { + if( ImGui::Selectable( v.uArch, idx == m_selMicroArch ) ) m_selMicroArch = idx; + ImGui::SameLine(); + TextDisabledUnformatted( v.cpuName ); + idx++; + } + ImGui::EndCombo(); + } + ImGui::PopStyleVar(); + } + ImGui::BeginChild( "##asmView", ImVec2( 0, 0 ), true, ImGuiWindowFlags_NoMove ); if( m_font ) ImGui::PushFont( m_font ); diff --git a/server/TracySourceView.hpp b/server/TracySourceView.hpp index dd2ccbb4..1061922f 100644 --- a/server/TracySourceView.hpp +++ b/server/TracySourceView.hpp @@ -154,6 +154,7 @@ private: TokenizerState m_tokenizer; CpuArchitecture m_cpuArch; + int m_selMicroArch; }; }