diff --git a/manual/tracy.tex b/manual/tracy.tex index bfc9d31b..ef683ef7 100644 --- a/manual/tracy.tex +++ b/manual/tracy.tex @@ -4345,7 +4345,7 @@ In this window, you can set various trace-related options. For example, the time \item \emph{\faSignature{} Draw CPU usage graph} -- You can disable drawing of the CPU usage graph here. \end{itemize} \item \emph{\faEyeDropper{}~Draw stack samples} -- Controls if stack samples for each thread are displayed on the timeline. -\item \emph{\faArrowsLeftRightToLine{}~Draw sections} -- Allows disabling display of sections (see chapter~\ref{sections}). If there are multiple section categories, there's also an expandable list of categories that can be disabled or enabled. +\item \emph{\faArrowsLeftRightToLine{}~Draw sections} -- Allows disabling display of sections (see chapter~\ref{sections}). If there are multiple section categories, there's also an expandable list of categories that can be disabled or enabled. The \emph{\faLayerGroup{}~Group by category} option lays out each category in its own set of rows, ordered by category identifier, instead of packing all sections together by length. \item \emph{\faEye{} Draw GPU zones} -- Allows disabling display of OpenGL / Vulkan / Metal / Direct3D / OpenCL / CUDA / WebGPU zones. The \emph{GPU zones} drop-down allows disabling individual GPU contexts and setting CPU/GPU drift offsets of uncalibrated contexts (see section~\ref{gpuprofiling} for more information). The \emph{\faRobot~Auto} button automatically measures the GPU drift value\footnote{There is an assumption that drift is linear. Automated measurement calculates and removes change over time in delay-to-execution of GPU zones. Resulting value may still be incorrect.}. \item \emph{\faMicrochip{} Draw CPU zones} -- Determines whether CPU zones are displayed. \begin{itemize} diff --git a/profiler/src/profiler/TracyUserData.cpp b/profiler/src/profiler/TracyUserData.cpp index 4c79d826..6af420bc 100644 --- a/profiler/src/profiler/TracyUserData.cpp +++ b/profiler/src/profiler/TracyUserData.cpp @@ -169,6 +169,7 @@ bool UserData::Save() { "drawCpuUsageGraph", m_viewData.drawCpuUsageGraph }, { "drawSamples", m_viewData.drawSamples }, { "drawSections", m_viewData.drawSections }, + { "groupSectionsByCategory", m_viewData.groupSectionsByCategory }, { "dynamicColors", m_viewData.dynamicColors }, { "inheritParentColors", m_viewData.inheritParentColors }, { "forceColors", m_viewData.forceColors }, @@ -269,6 +270,7 @@ bool UserData::Load() LoadValue( options, "drawCpuUsageGraph", m_viewData.drawCpuUsageGraph ); LoadValue( options, "drawSamples", m_viewData.drawSamples ); LoadValue( options, "drawSections", m_viewData.drawSections ); + LoadValue( options, "groupSectionsByCategory", m_viewData.groupSectionsByCategory ); LoadValue( options, "dynamicColors", m_viewData.dynamicColors ); LoadValue( options, "inheritParentColors", m_viewData.inheritParentColors ); LoadValue( options, "forceColors", m_viewData.forceColors ); diff --git a/profiler/src/profiler/TracyViewData.hpp b/profiler/src/profiler/TracyViewData.hpp index 99d32d31..e35efc19 100644 --- a/profiler/src/profiler/TracyViewData.hpp +++ b/profiler/src/profiler/TracyViewData.hpp @@ -49,6 +49,7 @@ struct ViewData uint8_t drawCpuUsageGraph = true; uint8_t drawSamples = true; uint8_t drawSections = true; + uint8_t groupSectionsByCategory = false; uint8_t dynamicColors = 1; uint8_t inheritParentColors = true; uint8_t forceColors = false; diff --git a/profiler/src/profiler/TracyView_FrameTimeline.cpp b/profiler/src/profiler/TracyView_FrameTimeline.cpp index b3de7c23..56a9bf7e 100644 --- a/profiler/src/profiler/TracyView_FrameTimeline.cpp +++ b/profiler/src/profiler/TracyView_FrameTimeline.cpp @@ -372,14 +372,29 @@ void View::DrawTimelineSections() } if( visible.empty() ) return; - pdqsort( visible.begin(), visible.end(), []( const SectionEntry& a, const SectionEntry& b ) { return a.len > b.len; } ); + if( m_vd.groupSectionsByCategory ) + { + pdqsort( visible.begin(), visible.end(), []( const SectionEntry& a, const SectionEntry& b ) { return a.category != b.category ? a.category < b.category : a.len > b.len; } ); + } + else + { + pdqsort( visible.begin(), visible.end(), []( const SectionEntry& a, const SectionEntry& b ) { return a.len > b.len; } ); + } std::vector rows; + size_t rowBase = 0; + uint16_t rowCategory = visible[0].category; for( auto& e : visible ) { - bool found = false; - for( auto& row : rows ) + if( m_vd.groupSectionsByCategory && e.category != rowCategory ) { + rowCategory = e.category; + rowBase = rows.size(); + } + bool found = false; + for( size_t r=rowBase; r 1 ) { + ImGui::Indent(); + val = m_vd.groupSectionsByCategory; + SmallCheckbox( ICON_FA_LAYER_GROUP " Group by category", &val ); + m_vd.groupSectionsByCategory = val; + ImGui::Unindent(); + const auto expand = ImGui::TreeNode( "Sections" ); ImGui::SameLine(); size_t visible = 0;