Add a section marking achievement.

This commit is contained in:
Bartosz Taudul
2026-10-11 12:46:05 +02:00
parent 1af7bef86f
commit f25b096adf
4 changed files with 19 additions and 0 deletions

View File

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

View File

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

View File

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

View File

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