From f25b096adf13530fcd0bb69d78dbcea765c6cc5c Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 11 Oct 2026 12:46:05 +0200 Subject: [PATCH] Add a section marking achievement. --- profiler/CMakeLists.txt | 1 + profiler/src/achievements/Sections.md | 9 +++++++++ profiler/src/profiler/TracyAchievementData.cpp | 8 ++++++++ profiler/src/profiler/TracyView_FrameTimeline.cpp | 1 + 4 files changed, 19 insertions(+) create mode 100644 profiler/src/achievements/Sections.md diff --git a/profiler/CMakeLists.txt b/profiler/CMakeLists.txt index ec44c841..be5ff535 100644 --- a/profiler/CMakeLists.txt +++ b/profiler/CMakeLists.txt @@ -221,6 +221,7 @@ Embed(PROFILER_FILES TextLoadTrace src/achievements/LoadTrace.md TEXT) Embed(PROFILER_FILES TextManual src/achievements/Manual.md TEXT) Embed(PROFILER_FILES TextSamplingIntro src/achievements/SamplingIntro.md TEXT) Embed(PROFILER_FILES TextSaveTrace src/achievements/SaveTrace.md TEXT) +Embed(PROFILER_FILES TextSections src/achievements/Sections.md TEXT) set(INCLUDES "${CMAKE_CURRENT_BINARY_DIR}") set(LIBS "") diff --git a/profiler/src/achievements/Sections.md b/profiler/src/achievements/Sections.md new file mode 100644 index 00000000..f3554b71 --- /dev/null +++ b/profiler/src/achievements/Sections.md @@ -0,0 +1,9 @@ +# Mark sections + +Zones are bound to the scope of a function or a block, but your program's big-picture phases are not. For those, use sections: `TracySectionEnter( "Loading level %d", level )` marks the start and returns an identifier you store, and `TracySectionLeave( id )` marks the end, even when the two calls sit in completely different places. Every section is tracked independently, so sections may overlap, nest, or leave gaps: a main menu section, one section per level, and so on. + +Sections can be organized into categories. `TracySectionSetup( category, "Game levels" )` gives a category a name, and `TracySectionEnterCategory( category, ... )` starts a section inside it. Sections started with plain `TracySectionEnter` end up in category 0. Categories let you filter out the noise later. For example, when you care about level progression, you can hide the inventory-screen sections instead of sifting through them. + +Sections appear in their own lane at the top of the timeline, above all the threads, as a high-level view of what your program is doing at any moment. Middle-click a section bar to zoom the view straight to its span. + +Mark the main phases of your application, start them with `TracySectionEnter` and end them with `TracySectionLeave`, then middle-click your way through the section lane to examine each phase up close. Try it out! diff --git a/profiler/src/profiler/TracyAchievementData.cpp b/profiler/src/profiler/TracyAchievementData.cpp index 7d91e3c9..9b4d208c 100644 --- a/profiler/src/profiler/TracyAchievementData.cpp +++ b/profiler/src/profiler/TracyAchievementData.cpp @@ -16,6 +16,7 @@ #include "data/TextLoadTrace.hpp" #include "data/TextManual.hpp" #include "data/TextSamplingIntro.hpp" +#include "data/TextSections.hpp" #include "data/TextSaveTrace.hpp" namespace tracy::data @@ -75,11 +76,18 @@ AchievementItem ai_annotateZones = { .text = Unpack( TextAnnotateZones ) }; +AchievementItem ai_markSections = { + .id = "markSections", + .name = "Mark sections", + .text = Unpack( TextSections ) +}; + AchievementItem* ac_instrumentationIntroItems[] = { &ai_100million, &ai_instrumentationStatistics, &ai_findZone, &ai_annotateZones, + &ai_markSections, nullptr }; diff --git a/profiler/src/profiler/TracyView_FrameTimeline.cpp b/profiler/src/profiler/TracyView_FrameTimeline.cpp index 2fa7fce8..e65cec00 100644 --- a/profiler/src/profiler/TracyView_FrameTimeline.cpp +++ b/profiler/src/profiler/TracyView_FrameTimeline.cpp @@ -446,6 +446,7 @@ void View::DrawTimelineSections() if( IsMouseClickReleased( ImGuiMouseButton_Right ) ) m_setRangePopup = RangeSlim { s, e, true }; if( IsMouseClicked( ImGuiMouseButton_Middle ) ) { + if( s_config.achievements ) Achieve( "markSections" ); ZoomToRange( s, e ); } };