From 66434446b1d0484f97a1012b2967c45fe9c48b39 Mon Sep 17 00:00:00 2001 From: Chandan Singh <2673035+psmyles@users.noreply.github.com> Date: Tue, 8 Sep 2026 15:03:02 +0530 Subject: [PATCH 1/2] Add option to group section rows by category. Sections are packed into timeline rows purely by length, so sections from different categories share rows and the same category can move between rows along the timeline. When categories mark different kinds of activity (game levels, loading screens, cutscenes) this makes the row layout hard to read. The new "Group by category" option in the section options lays out each category in its own set of rows, in category identifier order, with the existing length-first packing applied within a category. Off by default, so the current layout is unchanged unless the option is enabled. Only shown when the trace has more than one section category. --- manual/tracy.tex | 2 +- profiler/src/profiler/TracyUserData.cpp | 2 ++ profiler/src/profiler/TracyViewData.hpp | 1 + .../src/profiler/TracyView_FrameTimeline.cpp | 21 ++++++++++++++++--- profiler/src/profiler/TracyView_Options.cpp | 6 ++++++ 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/manual/tracy.tex b/manual/tracy.tex index bfc9d31b..27eac578 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; From ecf722b64f5b2698bdf1d138a7065c63da1ab262 Mon Sep 17 00:00:00 2001 From: Chandan Singh <2673035+psmyles@users.noreply.github.com> Date: Tue, 8 Sep 2026 21:44:34 +0530 Subject: [PATCH 2/2] Remove stray carriage return in the manual --- manual/tracy.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manual/tracy.tex b/manual/tracy.tex index 27eac578..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. 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{\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}