[atom_cpu_profiler_gem_promotion] created profiler ImGui variant module and hooked up data/viz to their respective modules
Signed-off-by: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ProfilerImGuiSystemComponent.h>
|
||||
|
||||
#include <AzCore/Serialization/SerializeContext.h>
|
||||
#include <AzCore/Serialization/EditContext.h>
|
||||
#include <AzCore/Serialization/EditContextConstants.inl>
|
||||
|
||||
#include <AzFramework/Components/ConsoleBus.h>
|
||||
|
||||
namespace Profiler
|
||||
{
|
||||
static constexpr AZ::Crc32 profilerImGuiServiceCrc = AZ_CRC_CE("ProfilerImGuiService");
|
||||
|
||||
void ProfilerImGuiSystemComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serialize->Class<ProfilerImGuiSystemComponent, AZ::Component>()
|
||||
->Version(0);
|
||||
|
||||
if (AZ::EditContext* ec = serialize->GetEditContext())
|
||||
{
|
||||
ec->Class<ProfilerImGuiSystemComponent>("ProfilerImGui", "Provides in-game visualization of the performance data gathered by the ProfilerSystemComponent")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System"))
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ProfilerImGuiSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
|
||||
{
|
||||
provided.push_back(profilerImGuiServiceCrc);
|
||||
}
|
||||
|
||||
void ProfilerImGuiSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
|
||||
{
|
||||
incompatible.push_back(profilerImGuiServiceCrc);
|
||||
}
|
||||
|
||||
void ProfilerImGuiSystemComponent::GetRequiredServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& required)
|
||||
{
|
||||
}
|
||||
|
||||
void ProfilerImGuiSystemComponent::GetDependentServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& dependent)
|
||||
{
|
||||
}
|
||||
|
||||
ProfilerImGuiSystemComponent::ProfilerImGuiSystemComponent()
|
||||
{
|
||||
}
|
||||
|
||||
ProfilerImGuiSystemComponent::~ProfilerImGuiSystemComponent()
|
||||
{
|
||||
}
|
||||
|
||||
void ProfilerImGuiSystemComponent::Init()
|
||||
{
|
||||
}
|
||||
|
||||
void ProfilerImGuiSystemComponent::Activate()
|
||||
{
|
||||
#if defined(IMGUI_ENABLED)
|
||||
ImGui::ImGuiUpdateListenerBus::Handler::BusConnect();
|
||||
#endif // defined(IMGUI_ENABLED)
|
||||
}
|
||||
|
||||
void ProfilerImGuiSystemComponent::Deactivate()
|
||||
{
|
||||
#if defined(IMGUI_ENABLED)
|
||||
ImGui::ImGuiUpdateListenerBus::Handler::BusDisconnect();
|
||||
#endif // defined(IMGUI_ENABLED)
|
||||
}
|
||||
|
||||
#if defined(IMGUI_ENABLED)
|
||||
void ProfilerImGuiSystemComponent::OnImGuiUpdate()
|
||||
{
|
||||
if (m_showCpuProfiler)
|
||||
{
|
||||
m_imguiCpuProfiler.Draw(m_showCpuProfiler);
|
||||
}
|
||||
}
|
||||
|
||||
void ProfilerImGuiSystemComponent::OnImGuiMainMenuUpdate()
|
||||
{
|
||||
if (ImGui::BeginMenu("Profiler"))
|
||||
{
|
||||
if (ImGui::MenuItem("CPU", "", &m_showCpuProfiler))
|
||||
{
|
||||
CpuProfiler::Get()->SetProfilerEnabled(m_showCpuProfiler);
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
#endif // defined(IMGUI_ENABLED)
|
||||
} // namespace Profiler
|
||||
Reference in New Issue
Block a user