Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,14 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#define AZ_TRAIT_RAD_TELEMETRY_OPEN_FLAGS TMOF_INIT_NETWORKING
@@ -0,0 +1,14 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
RADTelemetry_Traits_Platform.h
)
@@ -0,0 +1,14 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#define AZ_TRAIT_RAD_TELEMETRY_OPEN_FLAGS TMOF_INIT_NETWORKING
@@ -0,0 +1,14 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
RADTelemetry_Traits_Platform.h
)
@@ -0,0 +1,14 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#define AZ_TRAIT_RAD_TELEMETRY_OPEN_FLAGS TMOF_INIT_NETWORKING
@@ -0,0 +1,14 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
RADTelemetry_Traits_Platform.h
)
@@ -0,0 +1,14 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#define AZ_TRAIT_RAD_TELEMETRY_OPEN_FLAGS TMOF_INIT_NETWORKING
@@ -0,0 +1,14 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
RADTelemetry_Traits_Platform.h
)
@@ -0,0 +1,14 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#define AZ_TRAIT_RAD_TELEMETRY_OPEN_FLAGS TMOF_INIT_NETWORKING
@@ -0,0 +1,14 @@
#
# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
# its licensors.
#
# For complete copyright and license terms please see the LICENSE at the root of this
# distribution (the "License"). All use of this software is governed by the License,
# or, if provided, by the license below or the license accompanying this file. Do not
# remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
set(FILES
RADTelemetry_Traits_Platform.h
)
@@ -0,0 +1,348 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#ifdef AZ_PROFILE_TELEMETRY
#include <AzCore/Debug/ProfilerBus.h>
#include <AzCore/PlatformIncl.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <RADTelemetry/ProfileTelemetry.h>
#include <RADTelemetry_Traits_Platform.h>
#include "ProfileTelemetryComponent.h"
namespace RADTelemetry
{
static const char * ProfileChannel = "RADTelemetry";
static const AZ::u32 MaxProfileThreadCount = 128;
static void MessageFrameTickType(AZ::Debug::ProfileFrameAdvanceType type)
{
const char * frameAdvanceTypeMessage = "Profile tick set to %s";
const char* frameAdvanceTypeString = (type == AZ::Debug::ProfileFrameAdvanceType::Game) ? "Game Thread" : "Render Frame";
AZ_Printf(ProfileChannel, frameAdvanceTypeMessage, frameAdvanceTypeString);
tmMessage(0, TMMF_SEVERITY_LOG, frameAdvanceTypeMessage, frameAdvanceTypeString);
}
ProfileTelemetryComponent::ProfileTelemetryComponent()
{
// Connecting in the constructor because we need to catch ALL created threads
AZStd::ThreadEventBus::Handler::BusConnect();
}
ProfileTelemetryComponent::~ProfileTelemetryComponent()
{
AZ_Assert(!m_running, "A telemetry session should not be open.");
AZStd::ThreadEventBus::Handler::BusDisconnect();
if (IsInitialized())
{
tmShutdown();
AZ_OS_FREE(m_buffer);
m_buffer = nullptr;
}
}
void ProfileTelemetryComponent::Activate()
{
AZ::Debug::ProfilerRequestBus::Handler::BusConnect();
ProfileTelemetryRequestBus::Handler::BusConnect();
AZ::SystemTickBus::Handler::BusConnect();
}
void ProfileTelemetryComponent::Deactivate()
{
AZ::SystemTickBus::Handler::BusDisconnect();
ProfileTelemetryRequestBus::Handler::BusDisconnect();
AZ::Debug::ProfilerRequestBus::Handler::BusDisconnect();
Disable();
}
void ProfileTelemetryComponent::OnThreadEnter(const AZStd::thread_id& id, const AZStd::thread_desc* desc)
{
(void)id;
(void)desc;
#if AZ_TRAIT_OS_USE_WINDOWS_THREADS
if (!desc)
{
// Skip unnamed threads
return;
}
if (IsInitialized())
{
// We can send the thread name to Telemetry now
const AZ::u32 newProfiledThreadCount = ++m_profiledThreadCount;
AZ_Assert(newProfiledThreadCount <= MaxProfileThreadCount, "RAD Telemetry profiled threadcount exceeded MaxProfileThreadCount!");
tmThreadName(0, id.m_id, desc->m_name);
return;
}
// Save off to send on the next connection
ScopedLock lock(m_threadNameLock);
auto end = m_threadNames.end();
auto itr = AZStd::find_if(m_threadNames.begin(), end, [id](const ThreadNameEntry& entry)
{
return entry.id == id;
});
if (itr != end)
{
itr->name = desc->m_name;
}
else
{
m_threadNames.push_back({ id, desc->m_name });
}
#else
const AZ::u32 newProfiledThreadCount = ++m_profiledThreadCount;
AZ_Assert(newProfiledThreadCount <= MaxProfileThreadCount, "RAD Telemetry profiled threadcount exceeded MaxProfileThreadCount!");
#endif
}
void ProfileTelemetryComponent::OnThreadExit(const AZStd::thread_id& id)
{
(void)id;
#if AZ_TRAIT_OS_USE_WINDOWS_THREADS
{
ScopedLock lock(m_threadNameLock);
auto end = m_threadNames.end();
auto itr = AZStd::find_if(m_threadNames.begin(), end, [id](const ThreadNameEntry& entry)
{
return entry.id == id;
});
if (itr != end)
{
m_threadNames.erase(itr);
}
else
{
// assume it was already sent on to RAD Telemetry
tmEndThread(0, id.m_id);
--m_profiledThreadCount;
}
}
#else
--m_profiledThreadCount;
#endif
}
void ProfileTelemetryComponent::OnSystemTick()
{
FrameAdvance(AZ::Debug::ProfileFrameAdvanceType::Game);
}
void ProfileTelemetryComponent::FrameAdvance(AZ::Debug::ProfileFrameAdvanceType type)
{
if (type == m_frameAdvanceType)
{
tmTick(0);
}
}
bool ProfileTelemetryComponent::IsActive()
{
return m_running;
}
void ProfileTelemetryComponent::ToggleEnabled()
{
Initialize();
if (!m_running)
{
Enable();
}
else
{
Disable();
}
}
tm_api* ProfileTelemetryComponent::GetApiInstance()
{
Initialize();
return TM_API_PTR;
}
void ProfileTelemetryComponent::Enable()
{
AZ_Printf(ProfileChannel, "Attempting to connect to the Telemetry server at %s:%d", m_address, m_port);
tmSetCaptureMask(m_captureMask);
tm_error result = tmOpen(
0, // unused
"ly", // program name, don't use slashes or weird character that will screw up a filename
__DATE__ " " __TIME__, // identifier, could be date time, or a build number ... whatever you want
m_address, // telemetry server address
TMCT_TCP, // network capture
m_port, // telemetry server port
AZ_TRAIT_RAD_TELEMETRY_OPEN_FLAGS,// flags
3000 // timeout in milliseconds ... pass -1 for infinite
);
switch (result)
{
case TM_OK:
{
m_running = true;
AZ_Printf(ProfileChannel, "Connected to the Telemetry server at %s:%d", m_address, m_port);
MessageFrameTickType(m_frameAdvanceType);
#if AZ_TRAIT_OS_USE_WINDOWS_THREADS
ScopedLock lock(m_threadNameLock);
for (const auto& threadNameEntry : m_threadNames)
{
const AZ::u32 newProfiledThreadCount = ++m_profiledThreadCount;
AZ_Assert(newProfiledThreadCount <= MaxProfileThreadCount, "RAD Telemetry profiled thread count exceeded MaxProfileThreadCount!");
tmThreadName(0, threadNameEntry.id.m_id, threadNameEntry.name.c_str());
}
m_threadNames.clear(); // Telemetry caches names so we can clear what we have sent on
#endif
break;
}
case TMERR_DISABLED:
AZ_Printf(ProfileChannel, "Telemetry is disabled via #define NTELEMETRY");
break;
case TMERR_UNINITIALIZED:
AZ_Printf(ProfileChannel, "tmInitialize failed or was not called");
break;
case TMERR_NETWORK_NOT_INITIALIZED:
AZ_Printf(ProfileChannel, "WSAStartup was not called before tmOpen! Call WSAStartup or pass TMOF_INIT_NETWORKING.");
break;
case TMERR_NULL_API:
AZ_Printf(ProfileChannel, "There is no Telemetry API (the DLL isn't in the EXE's path)!");
break;
case TMERR_COULD_NOT_CONNECT:
AZ_Printf(ProfileChannel, "Unable to connect to the Telemetry server at %s:%d (1. is it running? 2. check firewall settings)", m_address, m_port);
break;
case TMERR_UNKNOWN:
AZ_Printf(ProfileChannel, "Unknown error occurred");
break;
default:
AZ_Assert(false, "Unhandled tmOpen error case %d", result);
break;
}
}
void ProfileTelemetryComponent::Disable()
{
if (m_running)
{
m_running = false;
tmClose(0);
AZ_Printf(ProfileChannel, "Disconnected from the Telemetry server.");
}
}
TM_EXPORT_API tm_api* g_tm_api; // Required for the RAD Telemetry as static lib case
void ProfileTelemetryComponent::Initialize()
{
if (IsInitialized())
{
return;
}
tmLoadLibrary(TM_RELEASE);
if (!TM_API_PTR)
{
// Work around for UnixLike platforms that do not load RAD Telemetry static lib (they are incorrectly compiled with the dynamic library version of tmLoadLibrary. RAD is aware of the issue.)
TM_API_PTR = g_tm_api;
}
AZ_Assert(TM_API_PTR, "Invalid RAD Telemetry API pointer state");
tmSetMaxThreadCount(MaxProfileThreadCount);
const tm_int32 telemetryBufferSize = 16 * 1024 * 1024;
m_buffer = static_cast<char*>(AZ_OS_MALLOC(telemetryBufferSize, sizeof(void*)));
tmInitialize(telemetryBufferSize, m_buffer);
// Notify so individual modules can update their Telemetry pointer
AZ::Debug::ProfilerNotificationBus::Broadcast(&AZ::Debug::ProfilerNotifications::OnProfileSystemInitialized);
}
bool ProfileTelemetryComponent::IsInitialized() const {
return m_buffer != nullptr;
}
void ProfileTelemetryComponent::SetAddress(const char *address, AZ::u16 port)
{
m_address = address;
m_port = port;
}
void ProfileTelemetryComponent::SetCaptureMask(AZ::Debug::ProfileCategoryPrimitiveType mask)
{
m_captureMask = mask;
if (IsInitialized())
{
tmSetCaptureMask(m_captureMask);
}
}
void ProfileTelemetryComponent::SetFrameAdvanceType(AZ::Debug::ProfileFrameAdvanceType type)
{
if (type != m_frameAdvanceType)
{
MessageFrameTickType(type);
m_frameAdvanceType = type;
}
}
AZ::Debug::ProfileCategoryPrimitiveType ProfileTelemetryComponent::GetDefaultCaptureMaskInternal()
{
using MaskType = AZ::Debug::ProfileCategoryPrimitiveType;
// Set all the category bits "below" FirstDetailedCategory and do not enable memory capture by default
return (static_cast<MaskType>(1) << static_cast<MaskType>(AZ::Debug::ProfileCategory::FirstDetailedCategory)) - 1;
}
AZ::Debug::ProfileCategoryPrimitiveType ProfileTelemetryComponent::GetDefaultCaptureMask()
{
return GetDefaultCaptureMaskInternal();
}
AZ::Debug::ProfileCategoryPrimitiveType ProfileTelemetryComponent::GetCaptureMask()
{
return m_captureMask;
}
void ProfileTelemetryComponent::Reflect(AZ::ReflectContext* context)
{
if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<ProfileTelemetryComponent, AZ::Component>()
->Version(1)
;
}
}
void ProfileTelemetryComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided)
{
provided.push_back(AZ_CRC("ProfilerService"));
}
}
#endif
@@ -0,0 +1,107 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#ifdef AZ_PROFILE_TELEMETRY
#include <AzCore/std/parallel/threadbus.h>
#include <AzCore/Component/Component.h>
#include <AzCore/Component/TickBus.h>
#include <AzCore/std/string/string.h>
#include <RADTelemetry/ProfileTelemetryBus.h>
namespace RADTelemetry
{
class ProfileTelemetryComponent
: public AZ::Component
, private AZStd::ThreadEventBus::Handler
, private AZ::SystemTickBus::Handler
, private AZ::Debug::ProfilerRequestBus::Handler
, private ProfileTelemetryRequestBus::Handler
{
public:
AZ_COMPONENT(ProfileTelemetryComponent, "{51118122-7214-4918-BFF3-237E25FF4918}");
ProfileTelemetryComponent();
~ProfileTelemetryComponent() override;
//////////////////////////////////////////////////////////////////////////
// AZ::Component
void Activate() override;
void Deactivate() override;
private:
ProfileTelemetryComponent(const ProfileTelemetryComponent&) = delete;
//////////////////////////////////////////////////////////////////////////
// Thread event bus
void OnThreadEnter(const AZStd::thread_id& id, const AZStd::thread_desc* desc) override;
void OnThreadExit(const AZStd::thread_id& id) override;
//////////////////////////////////////////////////////////////////////////
// SystemTickBus
void OnSystemTick() override;
//////////////////////////////////////////////////////////////////////////
// ProfilerRequstBus
bool IsActive() override;
void FrameAdvance(AZ::Debug::ProfileFrameAdvanceType type) override;
//////////////////////////////////////////////////////////////////////////
// ProfileTelemetryRequestBus
void ToggleEnabled() override;
void SetAddress(const char *address, AZ::u16 port) override;
void SetCaptureMask(AZ::Debug::ProfileCategoryPrimitiveType mask) override;
void SetFrameAdvanceType(AZ::Debug::ProfileFrameAdvanceType type) override;
AZ::Debug::ProfileCategoryPrimitiveType GetCaptureMask() override;
AZ::Debug::ProfileCategoryPrimitiveType GetDefaultCaptureMask() override;
tm_api* GetApiInstance() override;
//////////////////////////////////////////////////////////////////////////
// Component descriptor
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
//////////////////////////////////////////////////////////////////////////
// Private helpers
void Enable();
void Disable();
void Initialize();
bool IsInitialized() const;
static AZ::Debug::ProfileCategoryPrimitiveType GetDefaultCaptureMaskInternal();
//////////////////////////////////////////////////////////////////////////
// Data members
struct ThreadNameEntry
{
AZStd::thread_id id;
AZStd::string name;
};
AZStd::vector<ThreadNameEntry> m_threadNames;
using LockType = AZStd::mutex;
using ScopedLock = AZStd::lock_guard<LockType>;
LockType m_threadNameLock;
AZStd::atomic_uint m_profiledThreadCount = { 0 };
const char* m_address = "127.0.0.1";
char* m_buffer = nullptr;
AZ::Debug::ProfileCategoryPrimitiveType m_captureMask = GetDefaultCaptureMaskInternal();
AZ::Debug::ProfileFrameAdvanceType m_frameAdvanceType = AZ::Debug::ProfileFrameAdvanceType::Game;
AZ::u16 m_port = 4719;
bool m_running = false;
bool m_initialized = false;
};
}
#endif
@@ -0,0 +1,136 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <IGem.h>
#include <IConsole.h>
#include <cstdint>
#include <cstdio> // snprintf
#include <limits>
#include "ProfileTelemetryComponent.h"
namespace RADTelemetry
{
#ifdef AZ_PROFILE_TELEMETRY
using TelemetryRequestBus = RADTelemetry::ProfileTelemetryRequestBus;
using TelemetryRequests = RADTelemetry::ProfileTelemetryRequests;
using MaskType = AZ::Debug::ProfileCategoryPrimitiveType;
static const char* s_telemetryAddress;
static int s_telemetryPort;
static const char* s_telemetryCaptureMask;
static int s_memCaptureEnabled;
static int s_frameAdvanceType;
using FrameAdvanceType = AZ::Debug::ProfileFrameAdvanceType;
static void MaskCvarChangedCallback(ICVar*)
{
if (!s_telemetryCaptureMask || !s_telemetryCaptureMask[0])
{
return;
}
// Parse as a 64-bit hex string
MaskType maskCvarValue = strtoull(s_telemetryCaptureMask, nullptr, 16);
if (maskCvarValue == std::numeric_limits<MaskType>::max())
{
MaskType defaultMask = 0;
TelemetryRequestBus::BroadcastResult(defaultMask, &TelemetryRequests::GetDefaultCaptureMask);
AZ_Error("RADTelemetryGem", false, "Invalid RAD Telemetry capture mask cvar value: %s, using default capture mask 0x%" PRIx64, s_telemetryCaptureMask, defaultMask);
maskCvarValue = defaultMask;
}
// Mask off the memory capture flag and add it back if memory capture is enabled
const MaskType fullCaptureMask = (maskCvarValue & ~AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(AZ::Debug::ProfileCategory::MemoryReserved)) | (s_memCaptureEnabled ? AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(AZ::Debug::ProfileCategory::MemoryReserved) : 0);
TelemetryRequestBus::Broadcast(&TelemetryRequests::SetCaptureMask, fullCaptureMask);
}
static void FrameAdvancedTypeCvarChangedCallback(ICVar*)
{
TelemetryRequestBus::Broadcast(&TelemetryRequests::SetFrameAdvanceType, (s_frameAdvanceType == 0) ? FrameAdvanceType::Game : FrameAdvanceType::Render);
}
static void CmdTelemetryToggleEnabled([[maybe_unused]] IConsoleCmdArgs* args)
{
TelemetryRequestBus::Broadcast(&TelemetryRequests::SetAddress, s_telemetryAddress, s_telemetryPort);
FrameAdvancedTypeCvarChangedCallback(nullptr); // Set frame advance type
MaskCvarChangedCallback(nullptr); // Set the capture mask
TelemetryRequestBus::Broadcast(&TelemetryRequests::ToggleEnabled);
}
#endif
class RADTelemetryModule
: public CryHooksModule
{
public:
AZ_RTTI(RADTelemetryModule, "{50BB63A6-4669-41F2-B93D-6EB8529413CD}", CryHooksModule);
RADTelemetryModule()
: CryHooksModule()
{
#ifdef AZ_PROFILE_TELEMETRY
m_descriptors.insert(m_descriptors.end(), {
ProfileTelemetryComponent::CreateDescriptor(),
});
#endif
}
/**
* Add required SystemComponents to the SystemEntity.
*/
AZ::ComponentTypeList GetRequiredSystemComponents() const override
{
AZ::ComponentTypeList components;
#ifdef AZ_PROFILE_TELEMETRY
components.insert(components.end(),
azrtti_typeid<ProfileTelemetryComponent>()
);
#endif
return components;
}
void OnCrySystemInitialized(ISystem& system, const SSystemInitParams& initParams) override
{
CryHooksModule::OnCrySystemInitialized(system, initParams);
#ifdef AZ_PROFILE_TELEMETRY
REGISTER_COMMAND("radtm_ToggleEnabled", &CmdTelemetryToggleEnabled, 0, "Enabled or Disable RAD Telemetry");
REGISTER_CVAR2("radtm_Address", &s_telemetryAddress, "127.0.0.1", VF_NULL, "The IP address for the telemetry server");
REGISTER_CVAR2("radtm_Port", &s_telemetryPort, 4719, VF_NULL, "The port for the RAD telemetry server");
REGISTER_CVAR2("radtm_MemoryCaptureEnabled", &s_memCaptureEnabled, 0, VF_NULL, "Toggle for telemetry memory capture");
const int defaultFrameAdvanceTypeCvarValue = (FrameAdvanceType::Default == FrameAdvanceType::Game) ? 0 : 1;
REGISTER_CVAR2_CB("radtm_FrameAdvanceType", &s_frameAdvanceType, defaultFrameAdvanceTypeCvarValue, VF_NULL, "Advance profile frames from either: =0 the main thread, or =1 render frame advance", FrameAdvancedTypeCvarChangedCallback);
// Get the default value from ProfileTelemetryComponent
MaskType defaultCaptureMaskValue = 0;
TelemetryRequestBus::BroadcastResult(defaultCaptureMaskValue, &TelemetryRequests::GetCaptureMask);
char defaultCaptureMaskStr[19];
azsnprintf(defaultCaptureMaskStr, AZ_ARRAY_SIZE(defaultCaptureMaskStr), "0x%" PRIx64, defaultCaptureMaskValue);
REGISTER_CVAR2_CB("radtm_CaptureMask", &s_telemetryCaptureMask, defaultCaptureMaskStr, VF_NULL, "A hex bitmask for the categories to be captured, 0x0 for all", MaskCvarChangedCallback);
#endif
}
};
}
// DO NOT MODIFY THIS LINE UNLESS YOU RENAME THE GEM
// The first parameter should be GemName_GemIdLower
// The second should be the fully qualified name of the class above
AZ_DECLARE_MODULE_CLASS(Gem_RADTelemetry, RADTelemetry::RADTelemetryModule)