@@ -34,9 +34,10 @@ bool TimelineItemThread::IsEmpty() const
3434{
3535 auto & crash = m_worker.GetCrashEvent ();
3636 return crash.thread != m_thread->id &&
37- m_thread->timeline .empty () &&
38- m_thread->messages .empty () &&
39- m_thread->ghostZones .empty ();
37+ m_thread->timeline .empty () &&
38+ m_thread->messages .empty () &&
39+ ( m_thread->ctx ->type != ZoneContextType::CPU ||
40+ static_cast <const CPUThreadData*>( m_thread )->ghostZones .empty () );
4041}
4142
4243uint32_t TimelineItemThread::HeaderColor () const
@@ -220,14 +221,18 @@ void TimelineItemThread::HeaderTooltip( const char* label ) const
220221 {
221222 TextFocused ( " Running state regions:" , RealToString ( ctx->v .size () ) );
222223 }
223- if ( ! m_thread->samples . empty () )
224+ if ( m_thread->ctx -> type != ZoneContextType::CPU )
224225 {
225- TextFocused ( " Call stack samples: " , RealToString ( m_thread-> samples . size () ) );
226- if ( m_thread-> kernelSampleCnt != 0 )
226+ auto cpu_thread = static_cast < const CPUThreadData*>( m_thread );
227+ if ( !cpu_thread-> samples . empty () )
227228 {
228- TextFocused ( " Kernel samples:" , RealToString ( m_thread->kernelSampleCnt ) );
229- ImGui::SameLine ();
230- ImGui::TextDisabled ( " (%.2f%%)" , 100 .f * m_thread->kernelSampleCnt / m_thread->samples .size () );
229+ TextFocused ( " Call stack samples:" , RealToString ( cpu_thread->samples .size () ) );
230+ if ( cpu_thread->kernelSampleCnt != 0 )
231+ {
232+ TextFocused ( " Kernel samples:" , RealToString ( cpu_thread->kernelSampleCnt ) );
233+ ImGui::SameLine ();
234+ ImGui::TextDisabled ( " (%.2f%%)" , 100 .f * cpu_thread->kernelSampleCnt / cpu_thread->samples .size () );
235+ }
231236 }
232237 }
233238 ImGui::EndTooltip ();
@@ -238,21 +243,25 @@ void TimelineItemThread::HeaderExtraContents( const TimelineContext& ctx, int of
238243 m_view.DrawThreadMessagesList ( ctx, m_msgDraw, offset, m_thread->id );
239244
240245#ifndef TRACY_NO_STATISTICS
241- const bool hasGhostZones = m_worker.AreGhostZonesReady () && !m_thread->ghostZones .empty ();
242- if ( hasGhostZones && !m_thread->timeline .empty () )
246+ if ( m_thread->ctx ->type == ZoneContextType::CPU )
243247 {
244- auto draw = ImGui::GetWindowDrawList ();
245- const auto ty = ImGui::GetTextLineHeight ();
248+ auto cpu_thread = static_cast <const CPUThreadData*>( m_thread );
249+ const bool hasGhostZones = m_worker.AreGhostZonesReady () && !cpu_thread->ghostZones .empty ();
250+ if ( hasGhostZones && !m_thread->timeline .empty () )
251+ {
252+ auto draw = ImGui::GetWindowDrawList ();
253+ const auto ty = ImGui::GetTextLineHeight ();
246254
247- const auto color = m_ghost ? 0xFFAA9999 : 0x88AA7777 ;
248- draw->AddText ( ctx.wpos + ImVec2 ( 1 .5f * ty + labelWidth, offset ), color, ICON_FA_GHOST );
249- float ghostSz = ImGui::CalcTextSize ( ICON_FA_GHOST ).x ;
255+ const auto color = m_ghost ? 0xFFAA9999 : 0x88AA7777 ;
256+ draw->AddText ( ctx.wpos + ImVec2 ( 1 .5f * ty + labelWidth, offset ), color, ICON_FA_GHOST );
257+ float ghostSz = ImGui::CalcTextSize ( ICON_FA_GHOST ).x ;
250258
251- if ( ctx.hover && ImGui::IsMouseHoveringRect ( ctx.wpos + ImVec2 ( 1 .5f * ty + labelWidth, offset ), ctx.wpos + ImVec2 ( 1 .5f * ty + labelWidth + ghostSz, offset + ty ) ) )
252- {
253- if ( IsMouseClicked ( 0 ) )
259+ if ( ctx.hover && ImGui::IsMouseHoveringRect ( ctx.wpos + ImVec2 ( 1 .5f * ty + labelWidth, offset ), ctx.wpos + ImVec2 ( 1 .5f * ty + labelWidth + ghostSz, offset + ty ) ) )
254260 {
255- m_ghost = !m_ghost;
261+ if ( IsMouseClicked ( 0 ) )
262+ {
263+ m_ghost = !m_ghost;
264+ }
256265 }
257266 }
258267 }
@@ -309,9 +318,10 @@ void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& t
309318
310319 td.Queue ( [this , &ctx, visible] {
311320#ifndef TRACY_NO_STATISTICS
312- if ( m_worker.AreGhostZonesReady () && ( m_ghost || ( m_view.GetViewData ().ghostZones && m_thread->timeline .empty () ) ) )
321+ if ( m_thread-> ctx -> type == ZoneContextType::CPU && m_worker.AreGhostZonesReady () && ( m_ghost || ( m_view.GetViewData ().ghostZones && m_thread->timeline .empty () ) ) )
313322 {
314- m_depth = PreprocessGhostLevel ( ctx, m_thread->ghostZones , 0 , visible );
323+ auto cpu_thread = static_cast <const CPUThreadData*>( m_thread );
324+ m_depth = PreprocessGhostLevel ( ctx, cpu_thread->ghostZones , 0 , visible );
315325 }
316326 else
317327#endif
@@ -336,12 +346,16 @@ void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& t
336346 }
337347 }
338348
339- m_hasSamples = false ;
340- if ( vd.drawSamples && !m_thread->samples .empty () )
349+ if ( m_thread->ctx ->type == ZoneContextType::CPU )
341350 {
342- td.Queue ( [this , &ctx, visible, yPos] {
343- PreprocessSamples ( ctx, m_thread->samples , visible, yPos );
344- } );
351+ auto cpu_thread = static_cast <const CPUThreadData*>( m_thread );
352+ m_hasSamples = false ;
353+ if ( vd.drawSamples && !cpu_thread->samples .empty () )
354+ {
355+ td.Queue ( [this , &ctx, visible, yPos, cpu_thread] {
356+ PreprocessSamples ( ctx, cpu_thread->samples , visible, yPos );
357+ } );
358+ }
345359 }
346360
347361 m_hasMessages = false ;
@@ -525,7 +539,6 @@ void TimelineItemThread::PreprocessContextSwitches( const TimelineContext& ctx,
525539 if ( !visible ) return ;
526540
527541 const auto MinCtxNs = int64_t ( round ( GetScale () * MinCtxSize * nspx ) );
528- const auto & sampleData = m_thread->samples ;
529542
530543 bool first = true ;
531544 while ( it < citend )
@@ -535,8 +548,9 @@ void TimelineItemThread::PreprocessContextSwitches( const TimelineContext& ctx,
535548 {
536549 first = false ;
537550 }
538- else
551+ else if ( m_thread-> ctx -> type == ZoneContextType::CPU )
539552 {
553+ const Vector<SampleData>& sampleData = static_cast <const CPUThreadData*>( m_thread )->samples ;
540554 uint32_t waitStack = 0 ;
541555 if ( !sampleData.empty () )
542556 {
0 commit comments