diff --git a/server/TracyEvent.hpp b/server/TracyEvent.hpp index a376cfd2..bc33045c 100644 --- a/server/TracyEvent.hpp +++ b/server/TracyEvent.hpp @@ -222,13 +222,11 @@ enum { CrashEventSize = sizeof( CrashEvent ) }; struct ContextSwitchData { - static uint8_t Reason( const ContextSwitchData& cs ) { return cs.data & 0xF; } - static uint8_t State( const ContextSwitchData& cs ) { return cs.data >> 4; } - int64_t start; int64_t end; uint8_t cpu; - uint8_t data; + int8_t reason; + int8_t state; }; enum { ContextSwitchDataSize = sizeof( ContextSwitchData ) }; diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 758a959a..558b3a41 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -2349,12 +2349,12 @@ void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxn { TextFocused( "CPU:", RealToString( ev.cpu, true ) ); } - TextFocused( "Wait reason:", DecodeContextSwitchReasonCode( ContextSwitchData::Reason( *pit ) ) ); + TextFocused( "Wait reason:", DecodeContextSwitchReasonCode( pit->reason ) ); ImGui::SameLine(); - TextDisabledUnformatted( DecodeContextSwitchReason( ContextSwitchData::Reason( *pit ) ) ); - TextFocused( "Wait state:", DecodeContextSwitchStateCode( ContextSwitchData::State( *pit ) ) ); + TextDisabledUnformatted( DecodeContextSwitchReason( pit->reason ) ); + TextFocused( "Wait state:", DecodeContextSwitchStateCode( pit->state ) ); ImGui::SameLine(); - TextDisabledUnformatted( DecodeContextSwitchState( ContextSwitchData::State( *pit ) ) ); + TextDisabledUnformatted( DecodeContextSwitchState( pit->state ) ); ImGui::EndTooltip(); if( ImGui::IsMouseClicked( 2 ) ) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 96b12f54..a1be5640 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -1167,7 +1167,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask ) { ptr->start = ReadTimeOffset( f, refTime ); ptr->end = ReadTimeOffset( f, refTime ); - f.Read( &ptr->cpu, sizeof( ptr->cpu ) + sizeof( ptr->data ) ); + f.Read( &ptr->cpu, sizeof( ptr->cpu ) + sizeof( ptr->reason ) + sizeof( ptr->state ) ); ptr++; } m_data.ctxSwitch.emplace( thread, data ); @@ -3726,9 +3726,8 @@ void Worker::ProcessContextSwitch( const QueueContextSwitch& ev ) auto& item = data.back(); assert( item.start <= time ); item.end = time; - assert( ( ev.reason & 0xF ) == ev.reason ); - assert( ( ev.state & 0xF ) == ev.state ); - item.data = ev.reason | ( ev.state << 4 ); + item.reason = ev.reason; + item.state = ev.state; } } if( ev.newThread != 0 ) @@ -3745,7 +3744,8 @@ void Worker::ProcessContextSwitch( const QueueContextSwitch& ev ) item.start = time; item.end = -1; item.cpu = ev.cpu; - item.data = ~0; + item.reason = -1; + item.state = -1; } } @@ -4496,7 +4496,7 @@ void Worker::Write( FileWrite& f ) { WriteTimeOffset( f, refTime, cs.start ); WriteTimeOffset( f, refTime, cs.end ); - f.Write( &cs.cpu, sizeof( cs.cpu ) + sizeof( cs.data ) ); + f.Write( &cs.cpu, sizeof( cs.cpu ) + sizeof( cs.reason ) + sizeof( cs.state ) ); } } }