Merge pull request #1467 from psmyles/sections-group-by-category

Add option to group section rows by category
This commit is contained in:
Bartosz Taudul
2026-09-08 18:15:36 +02:00
committed by GitHub
5 changed files with 28 additions and 4 deletions

View File

@@ -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}

View File

@@ -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 );

View File

@@ -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;

View File

@@ -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<SectionRow> 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<rows.size(); r++ )
{
auto& row = rows[r];
for( size_t i=0; i<row.available.size(); i++ )
{
const auto gap = row.available[i];

View File

@@ -113,6 +113,12 @@ void View::DrawOptions()
const auto& categories = m_worker.GetSectionDescriptions();
if( categories.size() > 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;