String literal message transfer.

This commit is contained in:
Bartosz Taudul 2017-10-15 13:06:49 +02:00
parent 95439a726a
commit 5b9fcddfb3
7 changed files with 29 additions and 4 deletions

View File

@ -19,6 +19,7 @@
#define TracyPlot(x,y) #define TracyPlot(x,y)
#define TracyMessage(x,y) #define TracyMessage(x,y)
#define TracyMessageL(x)
#else #else
@ -42,6 +43,7 @@
#define TracyPlot( name, val ) tracy::Profiler::PlotData( name, val ); #define TracyPlot( name, val ) tracy::Profiler::PlotData( name, val );
#define TracyMessage( txt, size ) tracy::Profiler::Message( txt, size ); #define TracyMessage( txt, size ) tracy::Profiler::Message( txt, size );
#define TracyMessageL( txt ) tracy::Profiler::Message( txt );
#endif #endif

View File

@ -285,6 +285,9 @@ bool Profiler::HandleServerQuery()
SendString( ptr, (const char*)ptr, QueueType::MessageData ); SendString( ptr, (const char*)ptr, QueueType::MessageData );
tracy_free( (void*)ptr ); tracy_free( (void*)ptr );
break; break;
case ServerQueryMessageLiteral:
SendString( ptr, (const char*)ptr, QueueType::MessageData );
break;
default: default:
assert( false ); assert( false );
break; break;

View File

@ -146,6 +146,20 @@ public:
tail.store( magic + 1, std::memory_order_release ); tail.store( magic + 1, std::memory_order_release );
} }
static tracy_force_inline void Message( const char* txt )
{
uint32_t cpu;
Magic magic;
auto& token = s_token.ptr;
auto& tail = token->get_tail_index();
auto item = token->enqueue_begin<moodycamel::CanAlloc>( magic );
item->hdr.type = QueueType::MessageLiteral;
item->message.time = GetTime( cpu );
item->message.thread = GetThreadHandle();
item->message.text = (uint64_t)txt;
tail.store( magic + 1, std::memory_order_release );
}
static bool ShouldExit(); static bool ShouldExit();
private: private:

View File

@ -24,6 +24,7 @@ enum ServerQuery : uint8_t
ServerQuerySourceLocation, ServerQuerySourceLocation,
ServerQueryPlotName, ServerQueryPlotName,
ServerQueryMessage, ServerQueryMessage,
ServerQueryMessageLiteral,
}; };
enum { WelcomeMessageProgramNameSize = 64 }; enum { WelcomeMessageProgramNameSize = 64 };

View File

@ -24,6 +24,7 @@ enum class QueueType : uint8_t
PlotData, PlotData,
PlotName, PlotName,
Message, Message,
MessageLiteral,
MessageData, MessageData,
NUM_TYPES NUM_TYPES
}; };
@ -185,6 +186,7 @@ static const size_t QueueDataSize[] = {
sizeof( QueueHeader ) + sizeof( QueuePlotData ), sizeof( QueueHeader ) + sizeof( QueuePlotData ),
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // plot name sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // plot name
sizeof( QueueHeader ) + sizeof( QueueMessage ), sizeof( QueueHeader ) + sizeof( QueueMessage ),
sizeof( QueueHeader ) + sizeof( QueueMessage ), // literal
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // message data sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // message data
}; };

View File

@ -511,7 +511,10 @@ void View::Process( const QueueItem& ev )
ProcessPlotData( ev.plotData ); ProcessPlotData( ev.plotData );
break; break;
case QueueType::Message: case QueueType::Message:
ProcessMessage( ev.message ); ProcessMessage( ev.message, false );
break;
case QueueType::MessageLiteral:
ProcessMessage( ev.message, true );
break; break;
default: default:
assert( false ); assert( false );
@ -701,10 +704,10 @@ void View::ProcessPlotData( const QueuePlotData& ev )
} }
} }
void View::ProcessMessage( const QueueMessage& ev ) void View::ProcessMessage( const QueueMessage& ev, bool literal )
{ {
m_pendingMessages.emplace( ev.text, MessagePending { int64_t( ev.time * m_timerMul ), ev.thread } ); m_pendingMessages.emplace( ev.text, MessagePending { int64_t( ev.time * m_timerMul ), ev.thread } );
ServerQuery( ServerQueryMessage, ev.text ); ServerQuery( literal ? ServerQueryMessageLiteral : ServerQueryMessage, ev.text );
} }
void View::CheckString( uint64_t ptr ) void View::CheckString( uint64_t ptr )

View File

@ -108,7 +108,7 @@ private:
void ProcessLockRelease( const QueueLockRelease& ev ); void ProcessLockRelease( const QueueLockRelease& ev );
void ProcessLockMark( const QueueLockMark& ev ); void ProcessLockMark( const QueueLockMark& ev );
void ProcessPlotData( const QueuePlotData& ev ); void ProcessPlotData( const QueuePlotData& ev );
void ProcessMessage( const QueueMessage& ev ); void ProcessMessage( const QueueMessage& ev, bool literal );
void CheckString( uint64_t ptr ); void CheckString( uint64_t ptr );
void CheckThreadString( uint64_t id ); void CheckThreadString( uint64_t id );