diff --git a/profiler/src/profiler/TracyTimelineDraw.hpp b/profiler/src/profiler/TracyTimelineDraw.hpp index 3c814d3b..dc599a9a 100644 --- a/profiler/src/profiler/TracyTimelineDraw.hpp +++ b/profiler/src/profiler/TracyTimelineDraw.hpp @@ -43,10 +43,18 @@ struct ContextSwitchDraw }; +enum class SampleType +{ + Own, + External, + Kernel +}; + struct SamplesDraw { uint32_t num; uint32_t idx; + SampleType type; }; diff --git a/profiler/src/profiler/TracyTimelineItemThread.cpp b/profiler/src/profiler/TracyTimelineItemThread.cpp index 72c1412a..9732c74a 100644 --- a/profiler/src/profiler/TracyTimelineItemThread.cpp +++ b/profiler/src/profiler/TracyTimelineItemThread.cpp @@ -625,7 +625,39 @@ void TimelineItemThread::PreprocessSamples( const TimelineContext& ctx, const Ve nextTime = nt + MinVisNs; } } - m_samplesDraw.emplace_back( SamplesDraw { uint32_t( next - it - 1 ), uint32_t( it - vec.begin() ) } ); + const auto num = uint32_t( next - it - 1 ); + const auto idx = uint32_t( it - vec.begin() ); + if( num == 0 ) + { + auto type = SampleType::Own; + auto& cs = m_worker.GetCallstack( it->callstack.Val() ); + auto frameData = m_worker.GetCallstackFrame( cs[0] ); + if( frameData ) + { + const auto& frame = frameData->data[0]; + if( frame.symAddr >> 63 != 0 ) + { + type = SampleType::Kernel; + } + else if( m_worker.IsFrameExternal( frame.file, frameData->imageName ) ) + { + type = SampleType::External; + } + } + + m_samplesDraw.emplace_back( SamplesDraw { + .num = 0, + .idx = idx, + .type = type + } ); + } + else + { + m_samplesDraw.emplace_back( SamplesDraw { + .num = num, + .idx = idx + } ); + } it = next; } }