Skip to content

Commit 58c22dd

Browse files
author
Eric Eaton
committed
Replace GpuEvent with ZoneEvent
This replaces the GpuEvent struct with ZoneEvent and a GpuExtra data type. This allows some common code to be merged, but since this is a minimal implementation of the idea, only a few small things are merged by this patch.
1 parent b6191ce commit 58c22dd

13 files changed

+275
-340
lines changed

csvexport/src/csvexport.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,9 @@ int main(int argc, char** argv)
299299
const auto& zone_data = it->second;
300300
for (const auto& zone_thread_data : zone_data.zones)
301301
{
302-
tracy::GpuEvent* gpu_event = zone_thread_data.Zone();
303-
const auto start = gpu_event->GpuStart();
304-
const auto end = gpu_event->GpuEnd();
302+
auto& gpu_event = worker.GetGpuExtra( *zone_thread_data.Zone() );
303+
const auto start = gpu_event.GpuStart();
304+
const auto end = gpu_event.GpuEnd();
305305

306306
values[2] = std::to_string( start );
307307

profiler/src/profiler/TracyTimelineItemGpu.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ void TimelineItemGpu::HeaderTooltip( const char* label ) const
7070
{
7171
if( it->second.timeline.is_magic() )
7272
{
73-
auto& tl = *(Vector<GpuEvent>*)&it->second.timeline;
74-
tid = m_worker.DecompressThread( tl.begin()->Thread() );
73+
auto& tl = *(Vector<ZoneEvent>*)&it->second.timeline;
74+
tid = m_worker.DecompressThread( m_worker.GetGpuExtra( *tl.begin() ).Thread() );
7575
}
7676
else
7777
{
78-
tid = m_worker.DecompressThread( (*it->second.timeline.begin())->Thread() );
78+
tid = m_worker.DecompressThread( m_worker.GetGpuExtra( **it->second.timeline.begin() ).Thread() );
7979
}
8080
}
8181
}
@@ -147,11 +147,11 @@ int64_t TimelineItemGpu::RangeBegin() const
147147
int64_t t0;
148148
if( td.second.timeline.is_magic() )
149149
{
150-
t0 = ((Vector<GpuEvent>*)&td.second.timeline)->front().GpuStart();
150+
t0 = ((Vector<ZoneEvent>*)&td.second.timeline)->front().Start();
151151
}
152152
else
153153
{
154-
t0 = td.second.timeline.front()->GpuStart();
154+
t0 = td.second.timeline.front()->Start();
155155
}
156156
if( t0 >= 0 )
157157
{
@@ -169,21 +169,21 @@ int64_t TimelineItemGpu::RangeEnd() const
169169
int64_t t0;
170170
if( td.second.timeline.is_magic() )
171171
{
172-
t0 = ((Vector<GpuEvent>*)&td.second.timeline)->front().GpuStart();
172+
t0 = ((Vector<ZoneEvent>*)&td.second.timeline)->front().Start();
173173
}
174174
else
175175
{
176-
t0 = td.second.timeline.front()->GpuStart();
176+
t0 = td.second.timeline.front()->Start();
177177
}
178178
if( t0 >= 0 )
179179
{
180180
if( td.second.timeline.is_magic() )
181181
{
182-
t = std::max( t, std::min( m_worker.GetLastTime(), m_worker.GetZoneEnd( ((Vector<GpuEvent>*)&td.second.timeline)->back() ) ) );
182+
t = std::max( t, std::min( m_worker.GetLastTime(), m_worker.GetZoneEndGPU( ((Vector<ZoneEvent>*)&td.second.timeline)->back() ) ) );
183183
}
184184
else
185185
{
186-
t = std::max( t, std::min( m_worker.GetLastTime(), m_worker.GetZoneEnd( *td.second.timeline.back() ) ) );
186+
t = std::max( t, std::min( m_worker.GetLastTime(), m_worker.GetZoneEndGPU( *td.second.timeline.back() ) ) );
187187
}
188188
}
189189
}

profiler/src/profiler/TracyView.hpp

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class View
255255
void DrawZoneList( const TimelineContext& ctx, const std::vector<TimelineDraw>& drawList, int offset, uint64_t tid, int maxDepth, double margin );
256256
void DrawThreadCropper( const int depth, const uint64_t tid, const float xPos, const float yPos, const float ostep, const float cropperWidth, const bool hasCtxSwitches );
257257
void DrawContextSwitchList( const TimelineContext& ctx, const std::vector<ContextSwitchDraw>& drawList, const Vector<ContextSwitchData>& ctxSwitch, int offset, int endOffset, bool isFiber );
258-
int DispatchGpuZoneLevel( const Vector<short_ptr<GpuEvent>>& 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 );
258+
int DispatchGpuZoneLevel( const Vector<short_ptr<ZoneEvent>>& 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 );
259259
template<typename Adapter, typename V>
260260
int 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 );
261261
template<typename Adapter, typename V>
@@ -333,21 +333,21 @@ class View
333333
uint32_t GetSrcLocColor( const SourceLocation& srcloc, int depth );
334334
uint32_t GetRawSrcLocColor( const SourceLocation& srcloc, int depth );
335335
uint32_t GetZoneColor( const ZoneEvent& ev, uint64_t thread, int depth );
336-
uint32_t GetZoneColor( const GpuEvent& ev );
336+
uint32_t GetZoneColor( const ZoneEvent& ev );
337337
ZoneColorData GetZoneColorData( const ZoneEvent& ev, uint64_t thread, int depth, uint32_t inheritedColor );
338-
ZoneColorData GetZoneColorData( const GpuEvent& ev );
338+
ZoneColorData GetZoneColorData( const ZoneEvent& ev );
339339

340340
void ZoomToZone( const ZoneEvent& ev );
341-
void ZoomToZone( const GpuEvent& ev );
341+
void ZoomToZoneGPU( const ZoneEvent& ev );
342342
void ZoomToPrevFrame();
343343
void ZoomToNextFrame();
344344
void CenterAtTime( int64_t t );
345345

346346
void ShowZoneInfo( const ZoneEvent& ev );
347-
void ShowZoneInfo( const GpuEvent& ev, uint64_t thread );
347+
void ShowZoneInfo( const ZoneEvent& ev, uint64_t thread );
348348

349349
void ZoneTooltip( const ZoneEvent& ev );
350-
void ZoneTooltip( const GpuEvent& ev );
350+
void ZoneTooltipGPU( const ZoneEvent& ev );
351351
void CallstackTooltip( uint32_t idx );
352352
void CallstackTooltipContents( uint32_t idx );
353353
void CrashTooltip();
@@ -357,11 +357,11 @@ class View
357357
const ZoneEvent* GetZoneChild( const ZoneEvent& zone, int64_t time ) const;
358358
bool IsZoneReentry( const ZoneEvent& zone ) const;
359359
bool IsZoneReentry( const ZoneEvent& zone, uint64_t tid ) const;
360-
const GpuEvent* GetZoneParent( const GpuEvent& zone ) const;
360+
const ZoneEvent* GetZoneParentGPU( const ZoneEvent& zone ) const;
361361
const ThreadData* GetZoneThreadData( const ZoneEvent& zone ) const;
362362
uint64_t GetZoneThread( const ZoneEvent& zone ) const;
363-
uint64_t GetZoneThread( const GpuEvent& zone ) const;
364-
const GpuCtxData* GetZoneCtx( const GpuEvent& zone ) const;
363+
uint64_t GetZoneThreadGPU( const EventAdapter<true>& zone ) const;
364+
const GpuCtxData* GetZoneCtx( const ZoneEvent& zone ) const;
365365
bool FindMatchingZone( int prev0, int prev1, int flags );
366366
const ZoneEvent* FindZoneAtTime( uint64_t thread, int64_t time ) const;
367367
uint64_t GetFrameNumber( const FrameData& fd, int i ) const;
@@ -379,12 +379,10 @@ class View
379379
void SmallCallstackButton( const char* name, uint32_t callstack, int& idx, bool tooltip = true );
380380
void DrawCallstackCalls( uint32_t callstack, uint16_t limit ) const;
381381
void SetViewToLastFrames();
382-
int64_t GetZoneChildTime( const ZoneEvent& zone );
383-
int64_t GetZoneChildTime( const GpuEvent& zone );
382+
int64_t GetZoneChildTime( const ZoneEvent& zone, bool gpu );
384383
int64_t GetZoneChildTimeFast( const ZoneEvent& zone );
385384
int64_t GetZoneChildTimeFastClamped( const ZoneEvent& zone, int64_t t0, int64_t t1 );
386-
int64_t GetZoneSelfTime( const ZoneEvent& zone );
387-
int64_t GetZoneSelfTime( const GpuEvent& zone );
385+
int64_t GetZoneSelfTime( const ZoneEvent& zone, bool gpu = false );
388386
bool GetZoneRunningTime( const ContextSwitch* ctx, const ZoneEvent& ev, int64_t& time, uint64_t& cnt );
389387
bool GetZoneRunningTime( const ContextSwitch* ctx, const ZoneEvent& ev, const RangeSlim& range, int64_t& time, uint64_t& cnt );
390388
const char* GetThreadContextData( uint64_t thread, bool& local, bool& untracked, const char*& program );
@@ -479,8 +477,8 @@ class View
479477
DecayValue<const MessageData*> m_msgHighlight = nullptr;
480478
DecayValue<uint32_t> m_lockHoverHighlight = InvalidId;
481479
DecayValue<const MessageData*> m_msgToFocus = nullptr;
482-
const GpuEvent* m_gpuInfoWindow = nullptr;
483-
const GpuEvent* m_gpuHighlight;
480+
const ZoneEvent* m_gpuInfoWindow = nullptr;
481+
const ZoneEvent* m_gpuHighlight;
484482
uint64_t m_gpuInfoWindowThread;
485483
uint32_t m_callstackInfoWindow = 0;
486484
int64_t m_memoryAllocInfoWindow = -1;
@@ -575,7 +573,7 @@ class View
575573
BuzzAnim<uint32_t> m_statBuzzAnim;
576574

577575
Vector<const ZoneEvent*> m_zoneInfoStack;
578-
Vector<const GpuEvent*> m_gpuInfoStack;
576+
Vector<const ZoneEvent*> m_gpuInfoStack;
579577

580578
SourceContents m_srcHintCache;
581579
std::unique_ptr<SourceView> m_sourceView;
@@ -877,8 +875,6 @@ class View
877875
struct {
878876
std::pair<const ZoneEvent*, int64_t> zoneSelfTime = { nullptr, 0 };
879877
std::pair<const ZoneEvent*, int64_t> zoneSelfTime2 = { nullptr, 0 };
880-
std::pair<const GpuEvent*, int64_t> gpuSelfTime = { nullptr, 0 };
881-
std::pair<const GpuEvent*, int64_t> gpuSelfTime2 = { nullptr, 0 };
882878
} m_cache;
883879

884880
struct {

0 commit comments

Comments
 (0)