[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:
@@ -21,7 +21,6 @@ ly_add_target(
|
||||
PUBLIC
|
||||
AZ::AzCore
|
||||
AZ::AzFramework
|
||||
Gem::ImGui.Static
|
||||
)
|
||||
|
||||
# Here add Profiler target, it depends on the Profiler.Static
|
||||
@@ -38,6 +37,22 @@ ly_add_target(
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
Gem::Profiler.Static
|
||||
)
|
||||
|
||||
ly_add_target(
|
||||
NAME ProfilerImGui ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
|
||||
NAMESPACE Gem
|
||||
FILES_CMAKE
|
||||
profiler_imgui_shared_files.cmake
|
||||
INCLUDE_DIRECTORIES
|
||||
PUBLIC
|
||||
Include
|
||||
PRIVATE
|
||||
Source
|
||||
BUILD_DEPENDENCIES
|
||||
PRIVATE
|
||||
Gem::Profiler.Static
|
||||
Gem::ImGui.Static
|
||||
RUNTIME_DEPENDENCIES
|
||||
Gem::ImGui
|
||||
)
|
||||
@@ -45,5 +60,5 @@ ly_add_target(
|
||||
# By default, we will specify that the above target Profiler would be used by
|
||||
# Client and Server type targets when this gem is enabled. If you don't want it
|
||||
# active in Clients or Servers by default, delete one of both of the following lines:
|
||||
ly_create_alias(NAME Profiler.Clients NAMESPACE Gem TARGETS Gem::Profiler)
|
||||
ly_create_alias(NAME Profiler.Clients NAMESPACE Gem TARGETS Gem::ProfilerImGui)
|
||||
ly_create_alias(NAME Profiler.Servers NAMESPACE Gem TARGETS Gem::Profiler)
|
||||
|
||||
+12
-6
@@ -6,20 +6,22 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ProfilerImGuiSystemComponent.h>
|
||||
#include <ProfilerSystemComponent.h>
|
||||
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Module/Module.h>
|
||||
#include <ProfilerSystemComponent.h>
|
||||
|
||||
namespace Profiler
|
||||
{
|
||||
class ProfilerModuleInterface
|
||||
class ProfilerImGuiModule
|
||||
: public AZ::Module
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ProfilerModuleInterface, "{c966e43a-420d-41c9-bd0d-4cb0bca0d3e1}", AZ::Module);
|
||||
AZ_CLASS_ALLOCATOR(ProfilerModuleInterface, AZ::SystemAllocator, 0);
|
||||
AZ_RTTI(ProfilerImGuiModule, "{5946991E-A96C-4E7A-A9B3-605E3C8EC3CB}", AZ::Module);
|
||||
AZ_CLASS_ALLOCATOR(ProfilerImGuiModule, AZ::SystemAllocator, 0);
|
||||
|
||||
ProfilerModuleInterface()
|
||||
ProfilerImGuiModule()
|
||||
{
|
||||
// Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
|
||||
// Add ALL components descriptors associated with this gem to m_descriptors.
|
||||
@@ -27,7 +29,8 @@ namespace Profiler
|
||||
// This happens through the [MyComponent]::Reflect() function.
|
||||
m_descriptors.insert(m_descriptors.end(), {
|
||||
ProfilerSystemComponent::CreateDescriptor(),
|
||||
});
|
||||
ProfilerImGuiSystemComponent::CreateDescriptor(),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,7 +40,10 @@ namespace Profiler
|
||||
{
|
||||
return AZ::ComponentTypeList{
|
||||
azrtti_typeid<ProfilerSystemComponent>(),
|
||||
azrtti_typeid<ProfilerImGuiSystemComponent>(),
|
||||
};
|
||||
}
|
||||
};
|
||||
}// namespace Profiler
|
||||
|
||||
AZ_DECLARE_MODULE_CLASS(Gem_Profiler, Profiler::ProfilerImGuiModule)
|
||||
@@ -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
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Profiler/ProfilerBus.h>
|
||||
|
||||
#include <ImGuiCpuProfiler.h>
|
||||
|
||||
#include <AzCore/Component/Component.h>
|
||||
|
||||
#if defined(IMGUI_ENABLED)
|
||||
#include <ImGuiBus.h>
|
||||
#include <imgui/imgui.h>
|
||||
#endif // defined(IMGUI_ENABLED)
|
||||
|
||||
namespace Profiler
|
||||
{
|
||||
class ProfilerImGuiSystemComponent
|
||||
: public AZ::Component
|
||||
#if defined(IMGUI_ENABLED)
|
||||
, public ImGui::ImGuiUpdateListenerBus::Handler
|
||||
#endif // defined(IMGUI_ENABLED)
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(ProfilerImGuiSystemComponent, "{E59A8A53-6784-4CCB-A8B5-9F91DA9BF1C5}");
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
|
||||
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
|
||||
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
|
||||
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
|
||||
|
||||
ProfilerImGuiSystemComponent();
|
||||
~ProfilerImGuiSystemComponent();
|
||||
|
||||
protected:
|
||||
// AZ::Component interface implementation
|
||||
void Init() override;
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
|
||||
#if defined(IMGUI_ENABLED)
|
||||
// ImGuiUpdateListenerBus overrides
|
||||
void OnImGuiUpdate() override;
|
||||
void OnImGuiMainMenuUpdate() override;
|
||||
#endif // defined(IMGUI_ENABLED)
|
||||
|
||||
private:
|
||||
#if defined(IMGUI_ENABLED)
|
||||
ImGuiCpuProfiler m_imguiCpuProfiler;
|
||||
bool m_showCpuProfiler{ false };
|
||||
#endif // defined(IMGUI_ENABLED)
|
||||
};
|
||||
|
||||
} // namespace Profiler
|
||||
@@ -6,17 +6,40 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ProfilerModuleInterface.h>
|
||||
#include <ProfilerSystemComponent.h>
|
||||
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Module/Module.h>
|
||||
|
||||
namespace Profiler
|
||||
{
|
||||
class ProfilerModule
|
||||
: public ProfilerModuleInterface
|
||||
: public AZ::Module
|
||||
{
|
||||
public:
|
||||
AZ_RTTI(ProfilerModule, "{1908f95f-30b9-4e27-8ae7-1e9fe487ef87}", ProfilerModuleInterface);
|
||||
AZ_RTTI(ProfilerModule, "{4A286414-B387-4D20-9A7E-2F792755B769}", AZ::Module);
|
||||
AZ_CLASS_ALLOCATOR(ProfilerModule, AZ::SystemAllocator, 0);
|
||||
|
||||
ProfilerModule()
|
||||
{
|
||||
// Push results of [MyComponent]::CreateDescriptor() into m_descriptors here.
|
||||
// Add ALL components descriptors associated with this gem to m_descriptors.
|
||||
// This will associate the AzTypeInfo information for the components with the the SerializeContext, BehaviorContext and EditContext.
|
||||
// This happens through the [MyComponent]::Reflect() function.
|
||||
m_descriptors.insert(m_descriptors.end(), {
|
||||
ProfilerSystemComponent::CreateDescriptor(),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Add required SystemComponents to the SystemEntity.
|
||||
*/
|
||||
AZ::ComponentTypeList GetRequiredSystemComponents() const override
|
||||
{
|
||||
return AZ::ComponentTypeList{
|
||||
azrtti_typeid<ProfilerSystemComponent>(),
|
||||
};
|
||||
}
|
||||
};
|
||||
}// namespace Profiler
|
||||
|
||||
|
||||
@@ -14,33 +14,35 @@
|
||||
|
||||
namespace Profiler
|
||||
{
|
||||
static constexpr AZ::Crc32 profilerServiceCrc = AZ_CRC_CE("ProfilerService");
|
||||
|
||||
void ProfilerSystemComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
|
||||
{
|
||||
serialize->Class<ProfilerSystemComponent, AZ::Component>()
|
||||
->Version(0)
|
||||
;
|
||||
->Version(0);
|
||||
|
||||
if (AZ::EditContext* ec = serialize->GetEditContext())
|
||||
{
|
||||
ec->Class<ProfilerSystemComponent>("Profiler", "[Description of functionality provided by this System Component]")
|
||||
ec->Class<ProfilerSystemComponent>("Profiler", "Provides a custom implementation of the AZ::Debug::Profiler interface for capturing performance data")
|
||||
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
|
||||
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System"))
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
|
||||
;
|
||||
->Attribute(AZ::Edit::Attributes::AutoExpand, true);
|
||||
}
|
||||
}
|
||||
|
||||
CpuProfilingStatisticsSerializer::Reflect(context);
|
||||
}
|
||||
|
||||
void ProfilerSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
|
||||
{
|
||||
provided.push_back(AZ_CRC_CE("ProfilerService"));
|
||||
provided.push_back(profilerServiceCrc);
|
||||
}
|
||||
|
||||
void ProfilerSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
|
||||
{
|
||||
incompatible.push_back(AZ_CRC_CE("ProfilerService"));
|
||||
incompatible.push_back(profilerServiceCrc);
|
||||
}
|
||||
|
||||
void ProfilerSystemComponent::GetRequiredServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& required)
|
||||
@@ -74,17 +76,14 @@ namespace Profiler
|
||||
void ProfilerSystemComponent::Activate()
|
||||
{
|
||||
ProfilerRequestBus::Handler::BusConnect();
|
||||
AZ::TickBus::Handler::BusConnect();
|
||||
|
||||
m_cpuProfiler.Init();
|
||||
}
|
||||
|
||||
void ProfilerSystemComponent::Deactivate()
|
||||
{
|
||||
AZ::TickBus::Handler::BusDisconnect();
|
||||
m_cpuProfiler.Shutdown();
|
||||
|
||||
ProfilerRequestBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
void ProfilerSystemComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace Profiler
|
||||
|
||||
@@ -8,16 +8,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Component/Component.h>
|
||||
#include <AzCore/Component/TickBus.h>
|
||||
#include <Profiler/ProfilerBus.h>
|
||||
#include <CpuProfilerImpl.h>
|
||||
|
||||
#include <AzCore/Component/Component.h>
|
||||
|
||||
|
||||
namespace Profiler
|
||||
{
|
||||
class ProfilerSystemComponent
|
||||
: public AZ::Component
|
||||
, protected ProfilerRequestBus::Handler
|
||||
, public AZ::TickBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(ProfilerSystemComponent, "{3f52c1d7-d920-4781-8ed7-88077ec4f305}");
|
||||
@@ -45,10 +46,8 @@ namespace Profiler
|
||||
void Deactivate() override;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// AZTickBus interface implementation
|
||||
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CpuProfilerImpl m_cpuProfiler;
|
||||
};
|
||||
|
||||
} // namespace Profiler
|
||||
|
||||
@@ -11,9 +11,6 @@ set(FILES
|
||||
Source/CpuProfiler.h
|
||||
Source/CpuProfilerImpl.cpp
|
||||
Source/CpuProfilerImpl.h
|
||||
Source/ImGuiCpuProfiler.cpp
|
||||
Source/ImGuiCpuProfiler.h
|
||||
Source/ProfilerModuleInterface.h
|
||||
Source/ProfilerSystemComponent.cpp
|
||||
Source/ProfilerSystemComponent.h
|
||||
)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# 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
|
||||
#
|
||||
#
|
||||
|
||||
set(FILES
|
||||
Source/ImGuiCpuProfiler.cpp
|
||||
Source/ImGuiCpuProfiler.h
|
||||
Source/ProfilerImGuiModule.cpp
|
||||
Source/ProfilerImGuiSystemComponent.cpp
|
||||
Source/ProfilerImGuiSystemComponent.h
|
||||
)
|
||||
Reference in New Issue
Block a user