mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 14:44:34 +00:00
Move context switch minpx calculation to rendering code.
This commit is contained in:
parent
f2700b2786
commit
b3e9ede557
@ -51,7 +51,6 @@ struct ContextSwitchDraw
|
||||
{
|
||||
ContextSwitchDrawType type;
|
||||
short_ptr<ContextSwitchData> ev;
|
||||
float minpx;
|
||||
union
|
||||
{
|
||||
ContextSwitchDrawFolded folded;
|
||||
|
@ -456,8 +456,6 @@ int TimelineItemThread::PreprocessZoneLevel( const TimelineContext& ctx, const V
|
||||
|
||||
void TimelineItemThread::PreprocessContextSwitches( const TimelineContext& ctx, const ContextSwitch& ctxSwitch )
|
||||
{
|
||||
const auto w = ctx.w;
|
||||
const auto pxns = ctx.pxns;
|
||||
const auto nspx = ctx.nspx;
|
||||
const auto vStart = ctx.vStart;
|
||||
const auto vEnd = ctx.vEnd;
|
||||
@ -475,7 +473,6 @@ void TimelineItemThread::PreprocessContextSwitches( const TimelineContext& ctx,
|
||||
const auto& sampleData = m_thread->samples;
|
||||
|
||||
auto pit = citend;
|
||||
double minpx = -10.0;
|
||||
while( it < citend )
|
||||
{
|
||||
auto& ev = *it;
|
||||
@ -496,17 +493,16 @@ void TimelineItemThread::PreprocessContextSwitches( const TimelineContext& ctx,
|
||||
if( found ) waitStack = sdit->callstack.Val();
|
||||
}
|
||||
|
||||
auto& ref = m_ctxDraw.emplace_back( ContextSwitchDraw { ContextSwitchDrawType::Waiting, &ev, float( minpx ) } );
|
||||
auto& ref = m_ctxDraw.emplace_back( ContextSwitchDraw { ContextSwitchDrawType::Waiting, &ev } );
|
||||
ref.waiting.prev = pit;
|
||||
ref.waiting.waitStack = waitStack;
|
||||
}
|
||||
|
||||
const auto end = ev.IsEndValid() ? ev.End() : m_worker.GetLastTime();
|
||||
const auto zsz = std::max( ( end - ev.Start() ) * pxns, pxns * 0.5 );
|
||||
if( zsz < MinCtxSize )
|
||||
const auto zsz = end - ev.Start();
|
||||
if( zsz < MinCtxNs )
|
||||
{
|
||||
int num = 0;
|
||||
const auto px0 = std::max( ( ev.Start() - vStart ) * pxns, -10.0 );
|
||||
auto px1ns = end - vStart;
|
||||
auto rend = end;
|
||||
auto nextTime = end + MinCtxNs;
|
||||
@ -524,15 +520,14 @@ void TimelineItemThread::PreprocessContextSwitches( const TimelineContext& ctx,
|
||||
rend = nend;
|
||||
nextTime = nend + nspx;
|
||||
}
|
||||
minpx = std::min( std::max( px1ns * pxns, px0+MinCtxSize ), double( w + 10 ) );
|
||||
if( num == 1 )
|
||||
{
|
||||
auto& ref = m_ctxDraw.emplace_back( ContextSwitchDraw { ContextSwitchDrawType::FoldedOne, &ev, float( minpx ) } );
|
||||
auto& ref = m_ctxDraw.emplace_back( ContextSwitchDraw { ContextSwitchDrawType::FoldedOne, &ev } );
|
||||
ref.folded.rend = rend;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& ref = m_ctxDraw.emplace_back( ContextSwitchDraw { ContextSwitchDrawType::FoldedMulti, &ev, float( minpx ) } );
|
||||
auto& ref = m_ctxDraw.emplace_back( ContextSwitchDraw { ContextSwitchDrawType::FoldedMulti, &ev } );
|
||||
ref.folded.rend = rend;
|
||||
ref.folded.num = num;
|
||||
}
|
||||
@ -540,7 +535,7 @@ void TimelineItemThread::PreprocessContextSwitches( const TimelineContext& ctx,
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ctxDraw.emplace_back( ContextSwitchDraw { ContextSwitchDrawType::Running, &ev, float( minpx ) } );
|
||||
m_ctxDraw.emplace_back( ContextSwitchDraw { ContextSwitchDrawType::Running, &ev } );
|
||||
pit = it;
|
||||
++it;
|
||||
}
|
||||
|
@ -136,6 +136,8 @@ const char* View::DecodeContextSwitchState( uint8_t state )
|
||||
|
||||
void View::DrawContextSwitchList( const TimelineContext& ctx, const std::vector<ContextSwitchDraw>& drawList, int offset, int endOffset, bool isFiber )
|
||||
{
|
||||
constexpr float MinCtxSize = 4;
|
||||
|
||||
const auto vStart = ctx.vStart;
|
||||
const auto& wpos = ctx.wpos;
|
||||
const auto pxns = ctx.pxns;
|
||||
@ -148,6 +150,8 @@ void View::DrawContextSwitchList( const TimelineContext& ctx, const std::vector<
|
||||
const auto dpos = wpos + ImVec2( 0.5f, 0.5f );
|
||||
const auto ty05 = round( ty * 0.5f );
|
||||
|
||||
double minpx = -10;
|
||||
|
||||
for( auto& v : drawList )
|
||||
{
|
||||
const auto& ev = *v.ev;
|
||||
@ -157,7 +161,7 @@ void View::DrawContextSwitchList( const TimelineContext& ctx, const std::vector<
|
||||
{
|
||||
const auto& prev = *v.waiting.prev;
|
||||
const bool migration = prev.Cpu() != ev.Cpu();
|
||||
const auto px0 = std::max( { ( prev.End() - vStart ) * pxns, -10.0, double( v.minpx ) } );
|
||||
const auto px0 = std::max( { ( prev.End() - vStart ) * pxns, -10.0, double( minpx ) } );
|
||||
const auto pxw = ( ev.WakeupVal() - vStart ) * pxns;
|
||||
const auto px1 = std::min( ( ev.Start() - vStart ) * pxns, w + 10.0 );
|
||||
const auto color = migration ? 0xFFEE7711 : 0xFF2222AA;
|
||||
@ -253,10 +257,12 @@ void View::DrawContextSwitchList( const TimelineContext& ctx, const std::vector<
|
||||
case ContextSwitchDrawType::FoldedOne:
|
||||
{
|
||||
const auto px0 = std::max( ( ev.Start() - vStart ) * pxns, -10.0 );
|
||||
DrawLine( draw, dpos + ImVec2( px0, offset + ty05 - 0.5f ), dpos + ImVec2( v.minpx, offset + ty05 - 0.5f ), 0xFF22DD22, lineSize );
|
||||
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( px0, offset ), wpos + ImVec2( v.minpx, offset + ty + 1 ) ) )
|
||||
{
|
||||
const auto end = v.folded.rend.Val();
|
||||
const auto px1ns = end - vStart;
|
||||
minpx = std::min( std::max( px1ns * pxns, px0+MinCtxSize ), double( w + 10 ) );
|
||||
DrawLine( draw, dpos + ImVec2( px0, offset + ty05 - 0.5f ), dpos + ImVec2( minpx, offset + ty05 - 0.5f ), 0xFF22DD22, lineSize );
|
||||
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( px0, offset ), wpos + ImVec2( minpx, offset + ty + 1 ) ) )
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
if( isFiber )
|
||||
{
|
||||
@ -285,10 +291,12 @@ void View::DrawContextSwitchList( const TimelineContext& ctx, const std::vector<
|
||||
case ContextSwitchDrawType::FoldedMulti:
|
||||
{
|
||||
const auto px0 = std::max( ( ev.Start() - vStart ) * pxns, -10.0 );
|
||||
DrawZigZag( draw, wpos + ImVec2( 0, offset + ty05 ), px0, v.minpx, ty/4, 0xFF888888, 1.5 );
|
||||
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( px0, offset ), wpos + ImVec2( v.minpx, offset + ty + 1 ) ) )
|
||||
{
|
||||
const auto end = v.folded.rend.Val();
|
||||
const auto px1ns = end - vStart;
|
||||
minpx = std::min( std::max( px1ns * pxns, px0+MinCtxSize ), double( w + 10 ) );
|
||||
DrawZigZag( draw, wpos + ImVec2( 0, offset + ty05 ), px0, minpx, ty/4, 0xFF888888, 1.5 );
|
||||
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( px0, offset ), wpos + ImVec2( minpx, offset + ty + 1 ) ) )
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
TextFocused( isFiber ? "Fiber is" : "Thread is", "changing activity multiple times" );
|
||||
TextFocused( "Number of running regions:", RealToString( v.folded.num ) );
|
||||
@ -305,7 +313,7 @@ void View::DrawContextSwitchList( const TimelineContext& ctx, const std::vector<
|
||||
case ContextSwitchDrawType::Running:
|
||||
{
|
||||
const auto end = ev.IsEndValid() ? ev.End() : m_worker.GetLastTime();
|
||||
const auto px0 = std::max( { ( ev.Start() - vStart ) * pxns, -10.0, double( v.minpx ) } );
|
||||
const auto px0 = std::max( { ( ev.Start() - vStart ) * pxns, -10.0, double( minpx ) } );
|
||||
const auto px1 = std::min( ( end - vStart ) * pxns, w + 10.0 );
|
||||
DrawLine( draw, dpos + ImVec2( px0, offset + ty05 - 0.5f ), dpos + ImVec2( px1, offset + ty05 - 0.5f ), 0xFF22DD22, lineSize );
|
||||
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( px0, offset ), wpos + ImVec2( px1, offset + ty + 1 ) ) )
|
||||
|
Loading…
Reference in New Issue
Block a user