From f068a1d31fec4426289fe66fb6722a44f8a12061 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 31 Jan 2021 19:03:16 +0100 Subject: [PATCH] Display GPU context name in thread track labels. --- server/TracyView.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 9f855f6d..70a48f40 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -2921,11 +2921,23 @@ void View::DrawZones() const bool isMultithreaded = (v->type == GpuContextType::Vulkan) || (v->type == GpuContextType::OpenCL) || (v->type == GpuContextType::Direct3D12); + float boxwidth; char buf[64]; sprintf( buf, "%s context %zu", GpuContextNames[(int)v->type], i ); - DrawTextContrast( draw, wpos + ImVec2( ty, oldOffset ), showFull ? 0xFFFFAAAA : 0xFF886666, buf ); + if( v->name.Active() ) + { + char tmp[4096]; + sprintf( tmp, "%s: %s", buf, m_worker.GetString( v->name ) ); + DrawTextContrast( draw, wpos + ImVec2( ty, oldOffset ), showFull ? 0xFFFFAAAA : 0xFF886666, tmp ); + boxwidth = ImGui::CalcTextSize( tmp ).x; + } + else + { + DrawTextContrast( draw, wpos + ImVec2( ty, oldOffset ), showFull ? 0xFFFFAAAA : 0xFF886666, buf ); + boxwidth = ImGui::CalcTextSize( buf ).x; + } - if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( 0, oldOffset ), wpos + ImVec2( ty + ImGui::CalcTextSize( buf ).x, oldOffset + ty ) ) ) + if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( 0, oldOffset ), wpos + ImVec2( ty + boxwidth, oldOffset + ty ) ) ) { if( IsMouseClicked( 0 ) ) { @@ -2961,6 +2973,7 @@ void View::DrawZones() ImGui::BeginTooltip(); ImGui::TextUnformatted( buf ); + if( v->name.Active() ) TextFocused( "Name:", m_worker.GetString( v->name ) ); ImGui::Separator(); if( !isMultithreaded ) {