[atom_cpu_profiler_gem_promotion] initial Profiler gem add

Signed-off-by: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com>
monroegm-disable-blank-issue-2
AMZN-ScottR 4 years ago
parent da75b7ef2b
commit fbc7f5d943

@ -0,0 +1,9 @@
#
# 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
#
#
add_subdirectory(Code)

@ -0,0 +1,46 @@
#
# 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
#
#
# Add the Profiler.Static target
ly_add_target(
NAME Profiler.Static STATIC
NAMESPACE Gem
FILES_CMAKE
profiler_files.cmake
INCLUDE_DIRECTORIES
PUBLIC
Include
PRIVATE
Source
BUILD_DEPENDENCIES
PUBLIC
AZ::AzCore
AZ::AzFramework
)
# Here add Profiler target, it depends on the Profiler.Static
ly_add_target(
NAME Profiler ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
NAMESPACE Gem
FILES_CMAKE
profiler_shared_files.cmake
INCLUDE_DIRECTORIES
PUBLIC
Include
PRIVATE
Source
BUILD_DEPENDENCIES
PRIVATE
Gem::Profiler.Static
)
# 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.Servers NAMESPACE Gem TARGETS Gem::Profiler)

@ -0,0 +1,37 @@
/*
* 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 <AzCore/EBus/EBus.h>
#include <AzCore/Interface/Interface.h>
namespace Profiler
{
class ProfilerRequests
{
public:
AZ_RTTI(ProfilerRequests, "{3757c4e5-1941-457c-85ae-16305e17a4c6}");
virtual ~ProfilerRequests() = default;
// Put your public methods here
};
class ProfilerBusTraits
: public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static constexpr AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static constexpr AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
//////////////////////////////////////////////////////////////////////////
};
using ProfilerRequestBus = AZ::EBus<ProfilerRequests, ProfilerBusTraits>;
using ProfilerInterface = AZ::Interface<ProfilerRequests>;
} // namespace Profiler

@ -0,0 +1,23 @@
/*
* 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 <ProfilerModuleInterface.h>
#include <ProfilerSystemComponent.h>
namespace Profiler
{
class ProfilerModule
: public ProfilerModuleInterface
{
public:
AZ_RTTI(ProfilerModule, "{1908f95f-30b9-4e27-8ae7-1e9fe487ef87}", ProfilerModuleInterface);
AZ_CLASS_ALLOCATOR(ProfilerModule, AZ::SystemAllocator, 0);
};
}// namespace Profiler
AZ_DECLARE_MODULE_CLASS(Gem_Profiler, Profiler::ProfilerModule)

@ -0,0 +1,43 @@
/*
* 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 <AzCore/Memory/SystemAllocator.h>
#include <AzCore/Module/Module.h>
#include <ProfilerSystemComponent.h>
namespace Profiler
{
class ProfilerModuleInterface
: public AZ::Module
{
public:
AZ_RTTI(ProfilerModuleInterface, "{c966e43a-420d-41c9-bd0d-4cb0bca0d3e1}", AZ::Module);
AZ_CLASS_ALLOCATOR(ProfilerModuleInterface, AZ::SystemAllocator, 0);
ProfilerModuleInterface()
{
// 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

@ -0,0 +1,90 @@
/*
* 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 <ProfilerSystemComponent.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
#include <AzCore/Serialization/EditContextConstants.inl>
namespace Profiler
{
void ProfilerSystemComponent::Reflect(AZ::ReflectContext* context)
{
if (AZ::SerializeContext* serialize = azrtti_cast<AZ::SerializeContext*>(context))
{
serialize->Class<ProfilerSystemComponent, AZ::Component>()
->Version(0)
;
if (AZ::EditContext* ec = serialize->GetEditContext())
{
ec->Class<ProfilerSystemComponent>("Profiler", "[Description of functionality provided by this System Component]")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System"))
->Attribute(AZ::Edit::Attributes::AutoExpand, true)
;
}
}
}
void ProfilerSystemComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC_CE("ProfilerService"));
}
void ProfilerSystemComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
{
incompatible.push_back(AZ_CRC_CE("ProfilerService"));
}
void ProfilerSystemComponent::GetRequiredServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& required)
{
}
void ProfilerSystemComponent::GetDependentServices([[maybe_unused]] AZ::ComponentDescriptor::DependencyArrayType& dependent)
{
}
ProfilerSystemComponent::ProfilerSystemComponent()
{
if (ProfilerInterface::Get() == nullptr)
{
ProfilerInterface::Register(this);
}
}
ProfilerSystemComponent::~ProfilerSystemComponent()
{
if (ProfilerInterface::Get() == this)
{
ProfilerInterface::Unregister(this);
}
}
void ProfilerSystemComponent::Init()
{
}
void ProfilerSystemComponent::Activate()
{
ProfilerRequestBus::Handler::BusConnect();
AZ::TickBus::Handler::BusConnect();
}
void ProfilerSystemComponent::Deactivate()
{
AZ::TickBus::Handler::BusDisconnect();
ProfilerRequestBus::Handler::BusDisconnect();
}
void ProfilerSystemComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time)
{
}
} // namespace Profiler

@ -0,0 +1,54 @@
/*
* 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 <AzCore/Component/Component.h>
#include <AzCore/Component/TickBus.h>
#include <Profiler/ProfilerBus.h>
namespace Profiler
{
class ProfilerSystemComponent
: public AZ::Component
, protected ProfilerRequestBus::Handler
, public AZ::TickBus::Handler
{
public:
AZ_COMPONENT(ProfilerSystemComponent, "{3f52c1d7-d920-4781-8ed7-88077ec4f305}");
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);
ProfilerSystemComponent();
~ProfilerSystemComponent();
protected:
////////////////////////////////////////////////////////////////////////
// ProfilerRequestBus interface implementation
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// AZTickBus interface implementation
void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
////////////////////////////////////////////////////////////////////////
};
} // namespace Profiler

@ -0,0 +1,14 @@
#
# 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
Include/Profiler/ProfilerBus.h
Source/ProfilerModuleInterface.h
Source/ProfilerSystemComponent.cpp
Source/ProfilerSystemComponent.h
)

@ -0,0 +1,11 @@
#
# 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/ProfilerModule.cpp
)

@ -0,0 +1,16 @@
{
"gem_name": "Profiler",
"display_name": "Profiler",
"license": "Apache-2.0 Or MIT",
"origin": "Open 3D Engine - o3de.org",
"type": "Code",
"summary": "A collection of utilities for capturing performance data",
"canonical_tags": [
"Gem"
],
"user_tags": [
"Profiler"
],
"icon_path": "preview.png",
"requirements": ""
}

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7ac9dd09bde78f389e3725ac49d61eff109857e004840bc0bc3881739df9618d
size 2217
Loading…
Cancel
Save