mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Implement setting client parameters from server.
This commit is contained in:
@@ -593,6 +593,15 @@ struct CpuThreadData
|
||||
|
||||
enum { CpuThreadDataSize = sizeof( CpuThreadData ) };
|
||||
|
||||
|
||||
struct Parameter
|
||||
{
|
||||
uint32_t idx;
|
||||
StringRef name;
|
||||
bool isBool;
|
||||
int32_t val;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1070,6 +1070,49 @@ bool View::DrawConnection()
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
const auto& params = m_worker.GetParameters();
|
||||
if( !params.empty() )
|
||||
{
|
||||
ImGui::Separator();
|
||||
if( ImGui::TreeNode( "Trace parameters" ) )
|
||||
{
|
||||
ImGui::Columns( 2 );
|
||||
ImGui::TextUnformatted( "Name" );
|
||||
ImGui::NextColumn();
|
||||
ImGui::TextUnformatted( "Value" );
|
||||
ImGui::NextColumn();
|
||||
ImGui::Separator();
|
||||
size_t idx = 0;
|
||||
for( auto& p : params )
|
||||
{
|
||||
ImGui::TextUnformatted( m_worker.GetString( p.name ) );
|
||||
ImGui::NextColumn();
|
||||
ImGui::PushID( idx );
|
||||
if( p.isBool )
|
||||
{
|
||||
bool val = p.val;
|
||||
if( ImGui::Checkbox( "", &val ) )
|
||||
{
|
||||
m_worker.SetParameter( idx, int32_t( val ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto val = int( p.val );
|
||||
if( ImGui::InputInt( "", &val, 1, 100, ImGuiInputTextFlags_EnterReturnsTrue ) )
|
||||
{
|
||||
m_worker.SetParameter( idx, int32_t( val ) );
|
||||
}
|
||||
}
|
||||
ImGui::PopID();
|
||||
ImGui::NextColumn();
|
||||
idx++;
|
||||
}
|
||||
ImGui::EndColumns();
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -3235,6 +3235,9 @@ bool Worker::Process( const QueueItem& ev )
|
||||
case QueueType::TidToPid:
|
||||
ProcessTidToPid( ev.tidToPid );
|
||||
break;
|
||||
case QueueType::ParamSetup:
|
||||
ProcessParamSetup( ev.paramSetup );
|
||||
break;
|
||||
default:
|
||||
assert( false );
|
||||
break;
|
||||
@@ -4575,6 +4578,12 @@ void Worker::ProcessTidToPid( const QueueTidToPid& ev )
|
||||
m_data.tidToPid.emplace( ev.tid, ev.pid );
|
||||
}
|
||||
|
||||
void Worker::ProcessParamSetup( const QueueParamSetup& ev )
|
||||
{
|
||||
CheckString( ev.name );
|
||||
m_params.push_back( Parameter { ev.idx, StringRef( StringRef::Ptr, ev.name ), bool( ev.isBool ), ev.val } );
|
||||
}
|
||||
|
||||
void Worker::MemAllocChanged( int64_t time )
|
||||
{
|
||||
const auto val = (double)m_data.memory.usage;
|
||||
@@ -5670,4 +5679,13 @@ const char* Worker::UnpackFrameImage( const FrameImage& image )
|
||||
return m_frameImageCompressedBuffer;
|
||||
}
|
||||
|
||||
void Worker::SetParameter( size_t paramIdx, int32_t val )
|
||||
{
|
||||
assert( paramIdx < m_params.size() );
|
||||
m_params[paramIdx].val = val;
|
||||
const auto idx = uint64_t( m_params[paramIdx].idx );
|
||||
const auto v = uint64_t( uint32_t( val ) );
|
||||
Query( ServerQueryParameter, ( idx << 32 ) | val );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -419,6 +419,9 @@ public:
|
||||
const char* PackFrameImage( const char* image, uint32_t inBytes, uint32_t& csz );
|
||||
const char* UnpackFrameImage( const FrameImage& image );
|
||||
|
||||
const Vector<Parameter>& GetParameters() const { return m_params; }
|
||||
void SetParameter( size_t paramIdx, int32_t val );
|
||||
|
||||
private:
|
||||
void Network();
|
||||
void Exec();
|
||||
@@ -479,6 +482,7 @@ private:
|
||||
tracy_force_inline void ProcessContextSwitch( const QueueContextSwitch& ev );
|
||||
tracy_force_inline void ProcessThreadWakeup( const QueueThreadWakeup& ev );
|
||||
tracy_force_inline void ProcessTidToPid( const QueueTidToPid& ev );
|
||||
tracy_force_inline void ProcessParamSetup( const QueueParamSetup& ev );
|
||||
|
||||
tracy_force_inline ZoneEvent* AllocZoneEvent();
|
||||
tracy_force_inline void ProcessZoneBeginImpl( ZoneEvent* zone, const QueueZoneBegin& ev );
|
||||
@@ -708,6 +712,8 @@ private:
|
||||
#ifdef TRACY_NO_STATISTICS
|
||||
Vector<ZoneEvent*> m_zoneEventPool;
|
||||
#endif
|
||||
|
||||
Vector<Parameter> m_params;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user