From 8ecaaf36c0fa320a81e8cff61a3f031e0273ad02 Mon Sep 17 00:00:00 2001 From: Scott Romero <24445312+AMZN-ScottR@users.noreply.github.com> Date: Thu, 27 Jan 2022 14:43:52 -0800 Subject: [PATCH] [development] updated Profiler interface to allow the forwarding of format string arguments (#7173) Signed-off-by: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com> --- Code/Framework/AzCore/AzCore/Debug/Profiler.h | 10 ++++------ Code/Framework/AzCore/AzCore/Debug/Profiler.inl | 6 +++--- Gems/Profiler/Code/Source/CpuProfilerImpl.cpp | 2 +- Gems/Profiler/Code/Source/CpuProfilerImpl.h | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Code/Framework/AzCore/AzCore/Debug/Profiler.h b/Code/Framework/AzCore/AzCore/Debug/Profiler.h index 6b27b35f53..6557743de8 100644 --- a/Code/Framework/AzCore/AzCore/Debug/Profiler.h +++ b/Code/Framework/AzCore/AzCore/Debug/Profiler.h @@ -67,8 +67,7 @@ namespace AZ::Debug Profiler() = default; virtual ~Profiler() = default; - // support for the extra macro args (e.g. format strings) will come in a later PR - virtual void BeginRegion(const Budget* budget, const char* eventName) = 0; + virtual void BeginRegion(const Budget* budget, const char* eventName, size_t eventNameArgCount, ...) = 0; virtual void EndRegion(const Budget* budget) = 0; }; @@ -76,12 +75,11 @@ namespace AZ::Debug { public: template - static void BeginRegion([[maybe_unused]] Budget* budget, [[maybe_unused]] const char* eventName, [[maybe_unused]] T const&... args); - - static void EndRegion([[maybe_unused]] Budget* budget); + static void BeginRegion(Budget* budget, const char* eventName, T const&... args); + static void EndRegion(Budget* budget); template - ProfileScope(Budget* budget, char const* eventName, T const&... args); + ProfileScope(Budget* budget, const char* eventName, T const&... args); ~ProfileScope(); diff --git a/Code/Framework/AzCore/AzCore/Debug/Profiler.inl b/Code/Framework/AzCore/AzCore/Debug/Profiler.inl index c820639b09..a0917d6130 100644 --- a/Code/Framework/AzCore/AzCore/Debug/Profiler.inl +++ b/Code/Framework/AzCore/AzCore/Debug/Profiler.inl @@ -31,10 +31,10 @@ namespace AZ::Debug if (auto profiler = AZ::Interface::Get(); profiler) { - profiler->BeginRegion(budget, eventName); + profiler->BeginRegion(budget, eventName, sizeof...(T), args...); } } - #endif // #if !defined(_RELEASE) + #endif // !defined(_RELEASE) } inline void ProfileScope::EndRegion([[maybe_unused]] Budget* budget) @@ -55,7 +55,7 @@ namespace AZ::Debug } template - ProfileScope::ProfileScope(Budget* budget, char const* eventName, T const&... args) + ProfileScope::ProfileScope(Budget* budget, const char* eventName, T const&... args) : m_budget{ budget } { BeginRegion(budget, eventName, args...); diff --git a/Gems/Profiler/Code/Source/CpuProfilerImpl.cpp b/Gems/Profiler/Code/Source/CpuProfilerImpl.cpp index c9b32565d9..b0082bd046 100644 --- a/Gems/Profiler/Code/Source/CpuProfilerImpl.cpp +++ b/Gems/Profiler/Code/Source/CpuProfilerImpl.cpp @@ -96,7 +96,7 @@ namespace Profiler AZ::SystemTickBus::Handler::BusDisconnect(); } - void CpuProfilerImpl::BeginRegion(const AZ::Debug::Budget* budget, const char* eventName) + void CpuProfilerImpl::BeginRegion(const AZ::Debug::Budget* budget, const char* eventName, [[maybe_unused]] size_t eventNameArgCount, ...) { // Try to lock here, the shutdownMutex will only be contested when the CpuProfiler is shutting down. if (m_shutdownMutex.try_lock_shared()) diff --git a/Gems/Profiler/Code/Source/CpuProfilerImpl.h b/Gems/Profiler/Code/Source/CpuProfilerImpl.h index c97e45e69c..48b972bc49 100644 --- a/Gems/Profiler/Code/Source/CpuProfilerImpl.h +++ b/Gems/Profiler/Code/Source/CpuProfilerImpl.h @@ -111,7 +111,7 @@ namespace Profiler void OnSystemTick() final override; //! AZ::Debug::Profiler overrides... - void BeginRegion(const AZ::Debug::Budget* budget, const char* eventName) final override; + void BeginRegion(const AZ::Debug::Budget* budget, const char* eventName, size_t eventNameArgCount, ...) final override; void EndRegion(const AZ::Debug::Budget* budget) final override; //! CpuProfiler overrides...