[profiler_capture_api] started migration of ProfilerRequests EBus to AZ::Interface
Signed-off-by: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com>
This commit is contained in:
@@ -26,23 +26,32 @@ namespace AZ::Debug
|
||||
|
||||
void ProfilerCaptureFrame([[maybe_unused]] const AZ::ConsoleCommandContainer& arguments)
|
||||
{
|
||||
AZStd::string captureFile = GenerateOutputFile("single");
|
||||
AZLOG_INFO("Setting capture file to %s", captureFile.c_str());
|
||||
AZ::Debug::ProfilerRequestBus::Broadcast(&AZ::Debug::ProfilerRequestBus::Events::CaptureFrame, captureFile);
|
||||
if (auto profilerSystem = ProfilerSystemInterface::Get(); profilerSystem)
|
||||
{
|
||||
AZStd::string captureFile = GenerateOutputFile("single");
|
||||
AZLOG_INFO("Setting capture file to %s", captureFile.c_str());
|
||||
profilerSystem->CaptureFrame(captureFile);
|
||||
}
|
||||
}
|
||||
AZ_CONSOLEFREEFUNC(ProfilerCaptureFrame, AZ::ConsoleFunctorFlags::DontReplicate, "Capture a single frame of profiling data");
|
||||
|
||||
void ProfilerStartCapture([[maybe_unused]] const AZ::ConsoleCommandContainer& arguments)
|
||||
{
|
||||
AZStd::string captureFile = GenerateOutputFile("multi");
|
||||
AZLOG_INFO("Setting capture file to %s", captureFile.c_str());
|
||||
ProfilerRequestBus::Broadcast(&ProfilerRequestBus::Events::StartCapture, captureFile);
|
||||
if (auto profilerSystem = ProfilerSystemInterface::Get(); profilerSystem)
|
||||
{
|
||||
AZStd::string captureFile = GenerateOutputFile("multi");
|
||||
AZLOG_INFO("Setting capture file to %s", captureFile.c_str());
|
||||
profilerSystem->StartCapture(captureFile);
|
||||
}
|
||||
}
|
||||
AZ_CONSOLEFREEFUNC(ProfilerStartCapture, AZ::ConsoleFunctorFlags::DontReplicate, "Start a multi-frame capture of profiling data");
|
||||
|
||||
void ProfilerEndCapture([[maybe_unused]] const AZ::ConsoleCommandContainer& arguments)
|
||||
{
|
||||
AZ::Debug::ProfilerRequestBus::Broadcast(&AZ::Debug::ProfilerRequestBus::Events::EndCapture);
|
||||
if (auto profilerSystem = ProfilerSystemInterface::Get(); profilerSystem)
|
||||
{
|
||||
profilerSystem->EndCapture();
|
||||
}
|
||||
}
|
||||
AZ_CONSOLEFREEFUNC(ProfilerEndCapture, AZ::ConsoleFunctorFlags::DontReplicate, "End and dump an in-progress continuous capture");
|
||||
|
||||
|
||||
@@ -43,16 +43,9 @@ namespace AZ
|
||||
* ProfilerRequests provides an interface for making profiling system requests
|
||||
*/
|
||||
class ProfilerRequests
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
// EBusTraits overrides
|
||||
static constexpr AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
|
||||
static constexpr AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
|
||||
|
||||
// Allow multiple threads to concurrently make requests
|
||||
using MutexType = AZStd::mutex;
|
||||
|
||||
AZ_RTTI(ProfilerRequests, "{90AEC117-14C1-4BAE-9704-F916E49EF13F}");
|
||||
virtual ~ProfilerRequests() = default;
|
||||
|
||||
//! Getter/setter for the profiler active state
|
||||
@@ -66,7 +59,21 @@ namespace AZ
|
||||
virtual bool StartCapture(AZStd::string outputFilePath) = 0;
|
||||
virtual bool EndCapture() = 0;
|
||||
};
|
||||
using ProfilerRequestBus = AZ::EBus<ProfilerRequests>;
|
||||
|
||||
class ProfilerRequestsTraits
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
// EBusTraits overrides
|
||||
static constexpr AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
|
||||
static constexpr AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
|
||||
|
||||
// Allow multiple threads to concurrently make requests
|
||||
using MutexType = AZStd::mutex;
|
||||
};
|
||||
|
||||
using ProfilerSystemInterface = AZ::Interface<ProfilerRequests>;
|
||||
using ProfilerRequestBus = AZ::EBus<ProfilerRequests, ProfilerRequestsTraits>;
|
||||
|
||||
//! helper function for getting the profiler capture location from the settings registry that
|
||||
//! includes fallback handing in the event the registry value can't be determined
|
||||
|
||||
@@ -156,7 +156,10 @@ namespace AZ
|
||||
void StreamerComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time)
|
||||
{
|
||||
bool isEnabled = false;
|
||||
AZ::Debug::ProfilerRequestBus::BroadcastResult(isEnabled, &AZ::Debug::ProfilerRequests::IsActive);
|
||||
if (auto profilerSystem = AZ::Debug::ProfilerSystemInterface::Get(); profilerSystem)
|
||||
{
|
||||
isEnabled = profilerSystem->IsActive();
|
||||
}
|
||||
|
||||
if (isEnabled)
|
||||
{
|
||||
|
||||
@@ -1175,7 +1175,10 @@ namespace PhysX
|
||||
using physx::PxGeometryType;
|
||||
|
||||
bool isProfilingActive = false;
|
||||
AZ::Debug::ProfilerRequestBus::BroadcastResult(isProfilingActive, &AZ::Debug::ProfilerRequests::IsActive);
|
||||
if (auto profilerSystem = AZ::Debug::ProfilerSystemInterface::Get(); profilerSystem)
|
||||
{
|
||||
isProfilingActive = profilerSystem->IsActive();
|
||||
}
|
||||
|
||||
if (!isProfilingActive)
|
||||
{
|
||||
|
||||
@@ -154,10 +154,7 @@ namespace Profiler
|
||||
|
||||
if (m_captureToFile)
|
||||
{
|
||||
AZ::Debug::ProfilerRequestBus::Broadcast(
|
||||
&AZ::Debug::ProfilerRequestBus::Events::CaptureFrame,
|
||||
GenerateOutputFile("single")
|
||||
);
|
||||
AZ::Debug::ProfilerSystemInterface::Get()->CaptureFrame(GenerateOutputFile("single"));
|
||||
}
|
||||
m_captureToFile = false;
|
||||
|
||||
@@ -198,17 +195,15 @@ namespace Profiler
|
||||
bool isInProgress = CpuProfiler::Get()->IsContinuousCaptureInProgress();
|
||||
if (ImGui::Button(isInProgress ? "End" : "Begin"))
|
||||
{
|
||||
auto profilerSystem = AZ::Debug::ProfilerSystemInterface::Get();
|
||||
if (isInProgress)
|
||||
{
|
||||
AZ::Debug::ProfilerRequestBus::Broadcast(&AZ::Debug::ProfilerRequestBus::Events::EndCapture);
|
||||
profilerSystem->EndCapture();
|
||||
m_paused = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ::Debug::ProfilerRequestBus::Broadcast(
|
||||
&AZ::Debug::ProfilerRequestBus::Events::StartCapture,
|
||||
GenerateOutputFile("multi")
|
||||
);
|
||||
profilerSystem->StartCapture(GenerateOutputFile("multi"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -128,10 +128,18 @@ namespace Profiler
|
||||
|
||||
ProfilerSystemComponent::ProfilerSystemComponent()
|
||||
{
|
||||
if (AZ::Debug::ProfilerSystemInterface::Get() == nullptr)
|
||||
{
|
||||
AZ::Debug::ProfilerSystemInterface::Register(this);
|
||||
}
|
||||
}
|
||||
|
||||
ProfilerSystemComponent::~ProfilerSystemComponent()
|
||||
{
|
||||
if (AZ::Debug::ProfilerSystemInterface::Get() == this)
|
||||
{
|
||||
AZ::Debug::ProfilerSystemInterface::Unregister(this);
|
||||
}
|
||||
}
|
||||
|
||||
void ProfilerSystemComponent::Activate()
|
||||
|
||||
Reference in New Issue
Block a user