diff --git a/profiler/build/win32/Tracy.vcxproj b/profiler/build/win32/Tracy.vcxproj
index 85406f8b..6f532edd 100644
--- a/profiler/build/win32/Tracy.vcxproj
+++ b/profiler/build/win32/Tracy.vcxproj
@@ -137,6 +137,7 @@
+
diff --git a/profiler/build/win32/Tracy.vcxproj.filters b/profiler/build/win32/Tracy.vcxproj.filters
index 1895bfaf..1452d027 100644
--- a/profiler/build/win32/Tracy.vcxproj.filters
+++ b/profiler/build/win32/Tracy.vcxproj.filters
@@ -249,6 +249,9 @@
server
+
+ server
+
diff --git a/server/TracyView.cpp b/server/TracyView.cpp
index d3f39e7d..4ff91904 100644
--- a/server/TracyView.cpp
+++ b/server/TracyView.cpp
@@ -4915,13 +4915,6 @@ int View::DispatchGpuZoneLevel( const Vector>& vec, bool hov
}
}
-static int64_t AdjustGpuTime( int64_t time, int64_t begin, int drift )
-{
- if( time < 0 ) return time;
- const auto t = time - begin;
- return time + t / 1000000000 * drift;
-}
-
template
int View::DrawGpuZoneLevel( const V& vec, bool hover, double pxns, int64_t nspx, const ImVec2& wpos, int _offset, int depth, uint64_t thread, float yMin, float yMax, int64_t begin, int drift )
{
@@ -16847,133 +16840,6 @@ const char* View::GetPlotName( const PlotData* plot ) const
}
}
-void View::ZoomToZone( const ZoneEvent& ev )
-{
- const auto end = m_worker.GetZoneEnd( ev );
- if( end - ev.Start() <= 0 ) return;
- ZoomToRange( ev.Start(), end );
-}
-
-void View::ZoomToZone( const GpuEvent& ev )
-{
- const auto end = m_worker.GetZoneEnd( ev );
- if( end - ev.GpuStart() <= 0 ) return;
- auto ctx = GetZoneCtx( ev );
- if( !ctx )
- {
- ZoomToRange( ev.GpuStart(), end );
- }
- else
- {
- const auto td = ctx->threadData.size() == 1 ? ctx->threadData.begin() : ctx->threadData.find( m_worker.DecompressThread( ev.Thread() ) );
- assert( td != ctx->threadData.end() );
- int64_t begin;
- if( td->second.timeline.is_magic() )
- {
- begin = ((Vector*)&td->second.timeline)->front().GpuStart();
- }
- else
- {
- begin = td->second.timeline.front()->GpuStart();
- }
- const auto drift = GpuDrift( ctx );
- ZoomToRange( AdjustGpuTime( ev.GpuStart(), begin, drift ), AdjustGpuTime( end, begin, drift ) );
- }
-}
-
-void View::ZoomToRange( int64_t start, int64_t end, bool pause )
-{
- if( start == end )
- {
- end = start + 1;
- }
-
- if( pause )
- {
- m_viewMode = ViewMode::Paused;
- m_viewModeHeuristicTry = false;
- }
- m_highlightZoom.active = false;
- if( !m_playback.pause && m_playback.sync ) m_playback.pause = true;
-
- m_zoomAnim.active = true;
- if( m_viewMode == ViewMode::LastRange )
- {
- const auto rangeCurr = m_vd.zvEnd - m_vd.zvStart;
- const auto rangeDest = end - start;
- m_zoomAnim.start0 = m_vd.zvStart;
- m_zoomAnim.start1 = m_vd.zvStart - ( rangeDest - rangeCurr );
- m_zoomAnim.end0 = m_vd.zvEnd;
- m_zoomAnim.end1 = m_vd.zvEnd;
- }
- else
- {
- m_zoomAnim.start0 = m_vd.zvStart;
- m_zoomAnim.start1 = start;
- m_zoomAnim.end0 = m_vd.zvEnd;
- m_zoomAnim.end1 = end;
- }
- m_zoomAnim.progress = 0;
-}
-
-void View::ZoomToPrevFrame()
-{
- if( m_vd.zvStart >= m_worker.GetFrameBegin( *m_frames, 0 ) )
- {
- size_t frame;
- if( m_frames->continuous )
- {
- frame = (size_t)m_worker.GetFrameRange( *m_frames, m_vd.zvStart, m_vd.zvStart ).first;
- }
- else
- {
- frame = (size_t)m_worker.GetFrameRange( *m_frames, m_vd.zvStart, m_vd.zvStart ).second;
- }
-
- if( frame > 0 )
- {
- frame--;
- const auto fbegin = m_worker.GetFrameBegin( *m_frames, frame );
- const auto fend = m_worker.GetFrameEnd( *m_frames, frame );
- ZoomToRange( fbegin, fend );
- }
- }
-}
-
-void View::ZoomToNextFrame()
-{
- int64_t start;
- if( m_zoomAnim.active )
- {
- start = m_zoomAnim.start1;
- }
- else
- {
- start = m_vd.zvStart;
- }
-
- size_t frame;
- if( start < m_worker.GetFrameBegin( *m_frames, 0 ) )
- {
- frame = 0;
- }
- else
- {
- frame = (size_t)m_worker.GetFrameRange( *m_frames, start, start ).first + 1;
- }
- if( frame >= m_worker.GetFrameCount( *m_frames ) ) return;
-
- const auto fbegin = m_worker.GetFrameBegin( *m_frames, frame );
- const auto fend = m_worker.GetFrameEnd( *m_frames, frame );
- ZoomToRange( fbegin, fend );
-}
-
-void View::CenterAtTime( int64_t t )
-{
- const auto hr = std::max( 1, ( m_vd.zvEnd - m_vd.zvStart ) / 2 );
- ZoomToRange( t - hr, t + hr );
-}
-
void View::ShowZoneInfo( const ZoneEvent& ev )
{
if( m_zoneInfoWindow && m_zoneInfoWindow != &ev )
diff --git a/server/TracyView.hpp b/server/TracyView.hpp
index f32e8be7..52436d70 100644
--- a/server/TracyView.hpp
+++ b/server/TracyView.hpp
@@ -380,6 +380,7 @@ private:
void AdjustThreadHeight( View::VisData& vis, int oldOffset, int& offset );
void DrawHistogramMinMaxLabel( ImDrawList* draw, int64_t tmin, int64_t tmax, ImVec2 wpos, float w, float ty );
+ static int64_t AdjustGpuTime( int64_t time, int64_t begin, int drift );
Worker m_worker;
std::string m_filename, m_filenameStaging;
diff --git a/server/TracyView_Navigation.cpp b/server/TracyView_Navigation.cpp
new file mode 100644
index 00000000..a0c0a3e9
--- /dev/null
+++ b/server/TracyView_Navigation.cpp
@@ -0,0 +1,133 @@
+#include "TracyView.hpp"
+
+namespace tracy
+{
+
+void View::ZoomToZone( const ZoneEvent& ev )
+{
+ const auto end = m_worker.GetZoneEnd( ev );
+ if( end - ev.Start() <= 0 ) return;
+ ZoomToRange( ev.Start(), end );
+}
+
+void View::ZoomToZone( const GpuEvent& ev )
+{
+ const auto end = m_worker.GetZoneEnd( ev );
+ if( end - ev.GpuStart() <= 0 ) return;
+ auto ctx = GetZoneCtx( ev );
+ if( !ctx )
+ {
+ ZoomToRange( ev.GpuStart(), end );
+ }
+ else
+ {
+ const auto td = ctx->threadData.size() == 1 ? ctx->threadData.begin() : ctx->threadData.find( m_worker.DecompressThread( ev.Thread() ) );
+ assert( td != ctx->threadData.end() );
+ int64_t begin;
+ if( td->second.timeline.is_magic() )
+ {
+ begin = ((Vector*)&td->second.timeline)->front().GpuStart();
+ }
+ else
+ {
+ begin = td->second.timeline.front()->GpuStart();
+ }
+ const auto drift = GpuDrift( ctx );
+ ZoomToRange( AdjustGpuTime( ev.GpuStart(), begin, drift ), AdjustGpuTime( end, begin, drift ) );
+ }
+}
+
+void View::ZoomToRange( int64_t start, int64_t end, bool pause )
+{
+ if( start == end )
+ {
+ end = start + 1;
+ }
+
+ if( pause )
+ {
+ m_viewMode = ViewMode::Paused;
+ m_viewModeHeuristicTry = false;
+ }
+ m_highlightZoom.active = false;
+ if( !m_playback.pause && m_playback.sync ) m_playback.pause = true;
+
+ m_zoomAnim.active = true;
+ if( m_viewMode == ViewMode::LastRange )
+ {
+ const auto rangeCurr = m_vd.zvEnd - m_vd.zvStart;
+ const auto rangeDest = end - start;
+ m_zoomAnim.start0 = m_vd.zvStart;
+ m_zoomAnim.start1 = m_vd.zvStart - ( rangeDest - rangeCurr );
+ m_zoomAnim.end0 = m_vd.zvEnd;
+ m_zoomAnim.end1 = m_vd.zvEnd;
+ }
+ else
+ {
+ m_zoomAnim.start0 = m_vd.zvStart;
+ m_zoomAnim.start1 = start;
+ m_zoomAnim.end0 = m_vd.zvEnd;
+ m_zoomAnim.end1 = end;
+ }
+ m_zoomAnim.progress = 0;
+}
+
+void View::ZoomToPrevFrame()
+{
+ if( m_vd.zvStart >= m_worker.GetFrameBegin( *m_frames, 0 ) )
+ {
+ size_t frame;
+ if( m_frames->continuous )
+ {
+ frame = (size_t)m_worker.GetFrameRange( *m_frames, m_vd.zvStart, m_vd.zvStart ).first;
+ }
+ else
+ {
+ frame = (size_t)m_worker.GetFrameRange( *m_frames, m_vd.zvStart, m_vd.zvStart ).second;
+ }
+
+ if( frame > 0 )
+ {
+ frame--;
+ const auto fbegin = m_worker.GetFrameBegin( *m_frames, frame );
+ const auto fend = m_worker.GetFrameEnd( *m_frames, frame );
+ ZoomToRange( fbegin, fend );
+ }
+ }
+}
+
+void View::ZoomToNextFrame()
+{
+ int64_t start;
+ if( m_zoomAnim.active )
+ {
+ start = m_zoomAnim.start1;
+ }
+ else
+ {
+ start = m_vd.zvStart;
+ }
+
+ size_t frame;
+ if( start < m_worker.GetFrameBegin( *m_frames, 0 ) )
+ {
+ frame = 0;
+ }
+ else
+ {
+ frame = (size_t)m_worker.GetFrameRange( *m_frames, start, start ).first + 1;
+ }
+ if( frame >= m_worker.GetFrameCount( *m_frames ) ) return;
+
+ const auto fbegin = m_worker.GetFrameBegin( *m_frames, frame );
+ const auto fend = m_worker.GetFrameEnd( *m_frames, frame );
+ ZoomToRange( fbegin, fend );
+}
+
+void View::CenterAtTime( int64_t t )
+{
+ const auto hr = std::max( 1, ( m_vd.zvEnd - m_vd.zvStart ) / 2 );
+ ZoomToRange( t - hr, t + hr );
+}
+
+}
diff --git a/server/TracyView_Utility.cpp b/server/TracyView_Utility.cpp
index 6b376f4c..08b4cb49 100644
--- a/server/TracyView_Utility.cpp
+++ b/server/TracyView_Utility.cpp
@@ -718,4 +718,11 @@ const char* View::SourceSubstitution( const char* srcFile ) const
return res.c_str();
}
+int64_t View::AdjustGpuTime( int64_t time, int64_t begin, int drift )
+{
+ if( time < 0 ) return time;
+ const auto t = time - begin;
+ return time + t / 1000000000 * drift;
+}
+
}