From 801a34ea660fc02b891edc8fcced5e6b7ed3c878 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 17 Jun 2026 18:36:55 +0200 Subject: [PATCH] Add trigger parameter. --- .../src/profiler/TracyView_ConnectionState.cpp | 15 +++++++++++++-- public/client/TracyProfiler.hpp | 5 +++-- public/common/TracyQueue.hpp | 2 +- public/tracy/Tracy.hpp | 8 +++++++- server/TracyEvent.hpp | 9 ++++++++- server/TracyWorker.cpp | 2 +- 6 files changed, 33 insertions(+), 8 deletions(-) diff --git a/profiler/src/profiler/TracyView_ConnectionState.cpp b/profiler/src/profiler/TracyView_ConnectionState.cpp index fb7925b3..a77938ac 100644 --- a/profiler/src/profiler/TracyView_ConnectionState.cpp +++ b/profiler/src/profiler/TracyView_ConnectionState.cpp @@ -203,15 +203,18 @@ bool View::DrawConnection() ImGui::TextUnformatted( m_worker.GetString( p.name ) ); ImGui::TableNextColumn(); ImGui::PushID( idx ); - if( p.isBool ) + switch( p.type ) + { + case ParameterType::Boolean: { bool val = p.val; if( ImGui::Checkbox( "", &val ) ) { m_worker.SetParameter( idx, int32_t( val ) ); } + break; } - else + case ParameterType::Integer: { auto val = int( p.val ); ImGui::SetNextItemWidth( 100 * GetScale() ); @@ -219,6 +222,14 @@ bool View::DrawConnection() { m_worker.SetParameter( idx, int32_t( val ) ); } + break; + } + case ParameterType::Trigger: + if( ImGui::Button( ICON_FA_CIRCLE_DOT ) ) + { + m_worker.SetParameter( idx, p.val ); + } + break; } ImGui::PopID(); idx++; diff --git a/public/client/TracyProfiler.hpp b/public/client/TracyProfiler.hpp index a9183289..e347f1fb 100644 --- a/public/client/TracyProfiler.hpp +++ b/public/client/TracyProfiler.hpp @@ -748,12 +748,13 @@ public: profiler.m_paramCallbackData = data; } - static tracy_force_inline void ParameterSetup( uint32_t idx, const char* name, bool isBool, int32_t val ) + static tracy_force_inline void ParameterSetup( uint32_t idx, const char* name, uint8_t type, int32_t val ) { + assert( type >= 0 && type <= 2 ); TracyLfqPrepare( QueueType::ParamSetup ); tracy::MemWrite( &item->paramSetup.idx, idx ); tracy::MemWrite( &item->paramSetup.name, (uint64_t)name ); - tracy::MemWrite( &item->paramSetup.isBool, (uint8_t)isBool ); + tracy::MemWrite( &item->paramSetup.type, type ); tracy::MemWrite( &item->paramSetup.val, val ); #ifdef TRACY_ON_DEMAND diff --git a/public/common/TracyQueue.hpp b/public/common/TracyQueue.hpp index ec5d44d7..bb88ad5f 100644 --- a/public/common/TracyQueue.hpp +++ b/public/common/TracyQueue.hpp @@ -795,7 +795,7 @@ struct QueueParamSetup { uint32_t idx; uint64_t name; // ptr - uint8_t isBool; + uint8_t type; int32_t val; }; diff --git a/public/tracy/Tracy.hpp b/public/tracy/Tracy.hpp index 855b9e44..39960b86 100644 --- a/public/tracy/Tracy.hpp +++ b/public/tracy/Tracy.hpp @@ -16,6 +16,12 @@ # define TracyLine TracyConcat(__LINE__,U) // MSVC Edit and continue __LINE__ is non-constant. See https://developercommunity.visualstudio.com/t/-line-cannot-be-used-as-an-argument-for-constexpr/195665 #endif + +#define TracyParamTypeInt 0 +#define TracyParamTypeBool 1 +#define TracyParamTypeTrigger 2 + + #ifndef TRACY_ENABLE #define TracyNoop @@ -248,7 +254,7 @@ #define TracySourceCallbackRegister( cb, data ) tracy::Profiler::SourceCallbackRegister( cb, data ) #define TracyParameterRegister( cb, data ) tracy::Profiler::ParameterRegister( cb, data ) -#define TracyParameterSetup( idx, name, isBool, val ) tracy::Profiler::ParameterSetup( idx, name, isBool, val ) +#define TracyParameterSetup( idx, name, type, val ) tracy::Profiler::ParameterSetup( idx, name, type, val ) #define TracyIsConnected tracy::GetProfiler().IsConnected() #define TracySetProgramName( name ) tracy::GetProfiler().SetProgramName( name ); diff --git a/server/TracyEvent.hpp b/server/TracyEvent.hpp index 485d5274..fc329698 100644 --- a/server/TracyEvent.hpp +++ b/server/TracyEvent.hpp @@ -849,11 +849,18 @@ struct CpuThreadData }; +enum class ParameterType +{ + Integer, + Boolean, + Trigger +}; + struct Parameter { uint32_t idx; StringRef name; - bool isBool; + ParameterType type; int32_t val; }; diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index ccf16eeb..a560d7ac 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -7261,7 +7261,7 @@ void Worker::ProcessHwSampleBranchMiss( const QueueHwSample& ev ) 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 } ); + m_params.push_back( Parameter { ev.idx, StringRef( StringRef::Ptr, ev.name ), ParameterType( ev.type ), ev.val } ); } void Worker::ProcessSourceCodeNotAvailable( const QueueSourceCodeNotAvailable& ev )