diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 42e50812..43dd081e 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -10699,7 +10699,8 @@ void View::DrawFindZone() SmallCheckbox( "Show zone time in frames", &m_findZone.showZoneInFrames ); ImGui::Separator(); - if( ImGui::TreeNodeEx( "Samples", ImGuiTreeNodeFlags_None ) ) + const bool hasSamples = m_worker.AreCallstackSamplesReady() && m_worker.GetCallstackSampleCount() > 0; + if( hasSamples && ImGui::TreeNodeEx( "Samples", ImGuiTreeNodeFlags_None ) ) { { ImGui::Checkbox( ICON_FA_STOPWATCH " Show time", &m_statSampleTime ); @@ -10723,6 +10724,12 @@ void View::DrawFindZone() m_findZone.samplesCache.scheduleUpdate = true; } } + + if( !m_findZone.samplesCache.needZonesPerThread ) + { + m_findZone.samplesCache.needZonesPerThread = true; + m_findZone.scheduleResetMatch = true; + } if( m_findZone.samplesCache.scheduleUpdate && !m_findZone.scheduleResetMatch ) { @@ -10793,6 +10800,16 @@ void View::DrawFindZone() ImGui::TreePop(); } + else + { + if( m_findZone.samplesCache.needZonesPerThread ) + { + m_findZone.samplesCache.needZonesPerThread = false; + m_findZone.samplesCache.scheduleUpdate = false; + m_findZone.samplesCache.counts = Vector(); + m_findZone.samplesCache.threads = unordered_flat_map> >(); + } + } ImGui::Separator(); ImGui::TextUnformatted( "Found zones:" ); @@ -10953,14 +10970,18 @@ void View::DrawFindZone() group->time += timespan; group->zones.push_back_non_empty( ev.Zone() ); - if( lastTid != ev.Thread() ) + + if( m_findZone.samplesCache.needZonesPerThread ) { - lastTid = ev.Thread(); - threadZones = &m_findZone.samplesCache.threads[lastTid]; - threadZones->reserve( 1024 ); + if( lastTid != ev.Thread() ) + { + lastTid = ev.Thread(); + threadZones = &m_findZone.samplesCache.threads[lastTid]; + threadZones->reserve( 1024 ); + } + threadZones->push_back_non_empty( ev.Zone() ); + m_findZone.samplesCache.scheduleUpdate = true; } - threadZones->push_back_non_empty( ev.Zone() ); - m_findZone.samplesCache.scheduleUpdate = true; } m_findZone.processed = zptr - zones.data(); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 97af5fba..c0dff780 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -567,6 +567,7 @@ private: Vector counts; int64_t timeRange = 0; bool scheduleUpdate = false; + bool needZonesPerThread = false; } samplesCache; void Reset()