Remove RAD (pending future interface for external profiler registration)
Signed-off-by: Jeremy Ong <jcong@amazon.com>monroegm-disable-blank-issue-2
parent
11d4543442
commit
ec6e9407f6
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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/Debug/ProfileModuleInit.h>
|
|
||||||
|
|
||||||
#ifdef AZ_PROFILE_TELEMETRY
|
|
||||||
# include <RADTelemetry/ProfileTelemetryBus.h>
|
|
||||||
// Define the per-module RAD Telemetry instance pointer
|
|
||||||
struct tm_api;
|
|
||||||
tm_api* g_radTmApi;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
namespace AZ
|
|
||||||
{
|
|
||||||
namespace Debug
|
|
||||||
{
|
|
||||||
void ProfileModuleInit()
|
|
||||||
{
|
|
||||||
#if defined(AZ_PROFILE_TELEMETRY)
|
|
||||||
{
|
|
||||||
if (!g_radTmApi)
|
|
||||||
{
|
|
||||||
using namespace RADTelemetry;
|
|
||||||
ProfileTelemetryRequestBus::BroadcastResult(g_radTmApi, &ProfileTelemetryRequests::GetApiInstance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// Add additional per-DLL required profiler initialization here
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ProfileModuleInitializer::ProfileModuleInitializer()
|
|
||||||
{
|
|
||||||
ProfilerNotificationBus::Handler::BusConnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
ProfileModuleInitializer::~ProfileModuleInitializer()
|
|
||||||
{
|
|
||||||
ProfilerNotificationBus::Handler::BusDisconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProfileModuleInitializer::OnProfileSystemInitialized()
|
|
||||||
{
|
|
||||||
ProfileModuleInit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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/Debug/ProfilerBus.h>
|
|
||||||
|
|
||||||
namespace AZ
|
|
||||||
{
|
|
||||||
namespace Debug
|
|
||||||
{
|
|
||||||
//! Perform any required per-module initialization of the current profiler
|
|
||||||
void ProfileModuleInit();
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* ProfileModuleInitializer
|
|
||||||
* Helper class that calls ProfileModuleInit when OnProfileSystemInitialized is fired.
|
|
||||||
*/
|
|
||||||
class ProfileModuleInitializer
|
|
||||||
: private AZ::Debug::ProfilerNotificationBus::Handler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ProfileModuleInitializer();
|
|
||||||
~ProfileModuleInitializer() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void OnProfileSystemInitialized() override;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,143 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
|
|
||||||
#ifdef AZ_PROFILE_TELEMETRY
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* ProfileTelemetry.h provides a RAD Telemetry specific implementation of the AZ_PROFILE_FUNCTION, AZ_PROFILE_SCOPE, and AZ_PROFILE_SCOPE_DYNAMIC performance instrumentation markers
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define TM_API_PTR g_radTmApi
|
|
||||||
#include <rad_tm.h>
|
|
||||||
#include <AzCore/Math/Color.h>
|
|
||||||
|
|
||||||
namespace ProfileTelemetryInternal
|
|
||||||
{
|
|
||||||
inline constexpr tm_uint32 ConvertColor(uint32_t rgba)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
((rgba >> 24) & 0x000000ff) | // move byte 3 to byte 0
|
|
||||||
((rgba << 8) & 0x00ff0000) | // move byte 1 to byte 2
|
|
||||||
((rgba >> 8) & 0x0000ff00) | // move byte 2 to byte 1
|
|
||||||
((rgba << 24) & 0xff000000); // byte 0 to byte 3
|
|
||||||
}
|
|
||||||
|
|
||||||
inline constexpr tm_uint32 ConvertColor(const AZ::Color& color)
|
|
||||||
{
|
|
||||||
return ConvertColor(color.ToU32());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category) (static_cast<uint32_t>(1) << static_cast<uint32_t>(category))
|
|
||||||
// Helpers
|
|
||||||
#define AZ_INTERNAL_PROF_MEMORY_CAT_TO_FLAGS(category) (AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category) | \
|
|
||||||
AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(AZ::Debug::ProfileCategory::MemoryReserved))
|
|
||||||
|
|
||||||
#define AZ_INTERNAL_PROF_VERIFY_INTERVAL_ID(id) static_assert(sizeof(id) <= sizeof(tm_uint64), "Interval id must be a unique value no larger than 64-bits")
|
|
||||||
|
|
||||||
#define AZ_INTERNAL_PROF_TM_FUNC_VERIFY_CAT(category, flags) \
|
|
||||||
tmFunction(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category), flags)
|
|
||||||
|
|
||||||
#define AZ_INTERNAL_PROF_TM_ZONE_VERIFY_CAT(category, flags, ...) \
|
|
||||||
tmZone(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category), flags, __VA_ARGS__)
|
|
||||||
|
|
||||||
// AZ_PROFILE_FUNCTION
|
|
||||||
#define AZ_PROFILE_FUNCTION(category) \
|
|
||||||
AZ_INTERNAL_PROF_TM_FUNC_VERIFY_CAT(category, TMZF_NONE)
|
|
||||||
|
|
||||||
#define AZ_PROFILE_FUNCTION_STALL(category) \
|
|
||||||
AZ_INTERNAL_PROF_TM_FUNC_VERIFY_CAT(category, TMZF_STALL)
|
|
||||||
|
|
||||||
#define AZ_PROFILE_FUNCTION_IDLE(category) \
|
|
||||||
AZ_INTERNAL_PROF_TM_FUNC_VERIFY_CAT(category, TMZF_IDLE)
|
|
||||||
|
|
||||||
|
|
||||||
// AZ_PROFILE_SCOPE
|
|
||||||
#define AZ_PROFILE_SCOPE(category, name) \
|
|
||||||
AZ_INTERNAL_PROF_TM_ZONE_VERIFY_CAT(category, TMZF_NONE, name)
|
|
||||||
|
|
||||||
#define AZ_PROFILE_SCOPE_STALL(category, name) \
|
|
||||||
AZ_INTERNAL_PROF_TM_ZONE_VERIFY_CAT(category, TMZF_STALL, name)
|
|
||||||
|
|
||||||
#define AZ_PROFILE_SCOPE_IDLE(category, name) \
|
|
||||||
AZ_INTERNAL_PROF_TM_ZONE_VERIFY_CAT(category, TMZF_IDLE, name)
|
|
||||||
|
|
||||||
// AZ_PROFILE_SCOPE_DYNAMIC
|
|
||||||
// For profiling events with dynamic scope names
|
|
||||||
// Note: the first variable argument must be a const format string
|
|
||||||
// Usage: AZ_PROFILE_SCOPE_DYNAMIC(AZ::Debug::ProfileCategory, <printf style const format string>, format args...)
|
|
||||||
#define AZ_PROFILE_SCOPE_DYNAMIC(category, ...) \
|
|
||||||
AZ_INTERNAL_PROF_TM_ZONE_VERIFY_CAT(category, TMZF_NONE, __VA_ARGS__)
|
|
||||||
|
|
||||||
#define AZ_PROFILE_SCOPE_STALL_DYNAMIC(category, ...) \
|
|
||||||
AZ_INTERNAL_PROF_TM_ZONE_VERIFY_CAT(category, TMZF_STALL, __VA_ARGS__)
|
|
||||||
|
|
||||||
#define AZ_PROFILE_SCOPE_IDLE_DYNAMIC(category, ...) \
|
|
||||||
AZ_INTERNAL_PROF_TM_ZONE_VERIFY_CAT(category, TMZF_IDLE, __VA_ARGS__)
|
|
||||||
|
|
||||||
|
|
||||||
// AZ_PROFILE_EVENT_BEGIN/END
|
|
||||||
// For profiling events that do not start and stop in the same scope (they MUST start/stop on the same thread)
|
|
||||||
// ALWAYS favor using scoped events (AZ_PROFILE_FUNCTION, AZ_PROFILE_SCOPE) as debugging an unmatched begin/end can be challenging
|
|
||||||
#define AZ_PROFILE_EVENT_BEGIN(category, name) \
|
|
||||||
tmEnter(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category), TMZF_NONE, name)
|
|
||||||
|
|
||||||
#define AZ_PROFILE_EVENT_END(category) \
|
|
||||||
tmLeave(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category))
|
|
||||||
|
|
||||||
|
|
||||||
// AZ_PROFILE_INTERVAL (mapped to Telemetry Timespan APIs)
|
|
||||||
// Note: using C-style casting as we allow either pointers or integral types as IDs
|
|
||||||
#define AZ_PROFILE_INTERVAL_START(category, id, ...) \
|
|
||||||
AZ_INTERNAL_PROF_VERIFY_INTERVAL_ID(id); \
|
|
||||||
tmBeginTimeSpan(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category), (tm_uint64)(id), TMZF_NONE, __VA_ARGS__)
|
|
||||||
|
|
||||||
#define AZ_PROFILE_INTERVAL_START_COLORED(category, id, color, ...) \
|
|
||||||
AZ_INTERNAL_PROF_VERIFY_INTERVAL_ID(id); \
|
|
||||||
tmBeginColoredTimeSpan(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category), (tm_uint64)(id), 0, ProfileTelemetryInternal::ConvertColor(color), TMZF_NONE, __VA_ARGS__)
|
|
||||||
|
|
||||||
#define AZ_PROFILE_INTERVAL_END(category, id) \
|
|
||||||
AZ_INTERNAL_PROF_VERIFY_INTERVAL_ID(id); \
|
|
||||||
tmEndTimeSpan(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category), (tm_uint64)(id))
|
|
||||||
|
|
||||||
// AZ_PROFILE_INTERVAL_SCOPED
|
|
||||||
// Scoped interval event that implicitly starts and ends in the same scope
|
|
||||||
// Note: using C-style casting as we allow either pointers or integral types as IDs
|
|
||||||
// Note: the first variable argument must be a const format string
|
|
||||||
// Usage: AZ_PROFILE_INTERVAL_SCOPED(AZ::Debug::ProfileCategory, <unique interval id>, <printf style const format string>, format args...)
|
|
||||||
#define AZ_PROFILE_INTERVAL_SCOPED(category, id, ...) \
|
|
||||||
AZ_INTERNAL_PROF_VERIFY_INTERVAL_ID(id); \
|
|
||||||
tmTimeSpan(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category), (tm_uint64)(id), TM_MIN_TIME_SPAN_TRACK_ID + static_cast<AZ::Debug::ProfileCategoryPrimitiveType>(category), 0, TMZF_NONE, __VA_ARGS__)
|
|
||||||
|
|
||||||
|
|
||||||
// AZ_PROFILE_DATAPOINT (mapped to tmPlot APIs)
|
|
||||||
// Note: data points can have static or dynamic names, if using a dynamic name the first variable argument must be a const format string
|
|
||||||
// Usage: AZ_PROFILE_DATAPOINT(AZ::Debug::ProfileCategory, <printf style const format string>, format args...)
|
|
||||||
#define AZ_PROFILE_DATAPOINT(category, value, ...) \
|
|
||||||
tmPlot(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category), TM_PLOT_UNITS_REAL, TM_PLOT_DRAW_LINE, static_cast<double>(value), __VA_ARGS__)
|
|
||||||
|
|
||||||
#define AZ_PROFILE_DATAPOINT_PERCENT(category, value, ...) \
|
|
||||||
tmPlot(AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(category), TM_PLOT_UNITS_PERCENTAGE_DIRECT, TM_PLOT_DRAW_LINE, static_cast<double>(value), __VA_ARGS__)
|
|
||||||
|
|
||||||
|
|
||||||
// AZ_PROFILE_MEMORY_ALLOC
|
|
||||||
#define AZ_PROFILE_MEMORY_ALLOC(category, address, size, context) \
|
|
||||||
tmAlloc(AZ_INTERNAL_PROF_MEMORY_CAT_TO_FLAGS(category), address, size, context)
|
|
||||||
|
|
||||||
#define AZ_PROFILE_MEMORY_ALLOC_EX(category, filename, lineNumber, address, size, context) \
|
|
||||||
tmAllocEx(AZ_INTERNAL_PROF_MEMORY_CAT_TO_FLAGS(category), filename, lineNumber, address, size, context)
|
|
||||||
|
|
||||||
#define AZ_PROFILE_MEMORY_FREE(category, address) \
|
|
||||||
tmFree(AZ_INTERNAL_PROF_MEMORY_CAT_TO_FLAGS(category), address)
|
|
||||||
|
|
||||||
#define AZ_PROFILE_MEMORY_FREE_EX(category, filename, lineNumber, address) \
|
|
||||||
tmFreeEx(AZ_INTERNAL_PROF_MEMORY_CAT_TO_FLAGS(category), filename, lineNumber, address)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
|
|
||||||
#ifdef AZ_PROFILE_TELEMETRY
|
|
||||||
|
|
||||||
#include <AzCore/base.h>
|
|
||||||
#include <AzCore/Debug/Profiler.h>
|
|
||||||
#include <AzCore/Debug/ProfilerBus.h>
|
|
||||||
#include <AzCore/EBus/EBus.h>
|
|
||||||
|
|
||||||
struct tm_api;
|
|
||||||
|
|
||||||
namespace RADTelemetry
|
|
||||||
{
|
|
||||||
class ProfileTelemetryRequests
|
|
||||||
: public AZ::EBusTraits
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
|
|
||||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
|
|
||||||
|
|
||||||
virtual ~ProfileTelemetryRequests() = default;
|
|
||||||
|
|
||||||
virtual void ToggleEnabled() = 0;
|
|
||||||
|
|
||||||
virtual void SetAddress(const char* address, AZ::u16 port) = 0;
|
|
||||||
|
|
||||||
virtual void SetCaptureMask(AZ::Debug::ProfileCategoryPrimitiveType mask) = 0;
|
|
||||||
|
|
||||||
virtual void SetFrameAdvanceType(AZ::Debug::ProfileFrameAdvanceType type) = 0;
|
|
||||||
|
|
||||||
virtual AZ::Debug::ProfileCategoryPrimitiveType GetCaptureMask() = 0;
|
|
||||||
|
|
||||||
virtual AZ::Debug::ProfileCategoryPrimitiveType GetDefaultCaptureMask() = 0;
|
|
||||||
|
|
||||||
virtual tm_api* GetApiInstance() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
using ProfileTelemetryRequestBus = AZ::EBus<ProfileTelemetryRequests>;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
#
|
|
||||||
# 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)
|
|
||||||
@ -1,47 +0,0 @@
|
|||||||
#
|
|
||||||
# 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(LY_RAD_TELEMETRY_ENABLED OFF CACHE BOOL "Enables RAD Telemetry in Debug/Profile mode.")
|
|
||||||
set(LY_RAD_TELEMETRY_INSTALL_ROOT "@LY_3RDPARTY_PATH@/RadTelemetry" CACHE PATH "Install path to RAD Telemetry.")
|
|
||||||
string(CONFIGURE ${LY_RAD_TELEMETRY_INSTALL_ROOT} LY_RAD_TELEMETRY_INSTALL_ROOT @ONLY)
|
|
||||||
|
|
||||||
ly_get_list_relative_pal_filename(pal_source_dir ${CMAKE_CURRENT_LIST_DIR}/Source/Platform/${PAL_PLATFORM_NAME})
|
|
||||||
|
|
||||||
ly_add_target(
|
|
||||||
NAME RADTelemetry.Static STATIC
|
|
||||||
NAMESPACE Gem
|
|
||||||
FILES_CMAKE
|
|
||||||
radtelemetry_files.cmake
|
|
||||||
${pal_source_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake
|
|
||||||
INCLUDE_DIRECTORIES
|
|
||||||
PRIVATE
|
|
||||||
Source
|
|
||||||
${pal_source_dir}
|
|
||||||
BUILD_DEPENDENCIES
|
|
||||||
PUBLIC
|
|
||||||
AZ::AzCore
|
|
||||||
Legacy::CryCommon
|
|
||||||
)
|
|
||||||
|
|
||||||
ly_add_target(
|
|
||||||
NAME RADTelemetry ${PAL_TRAIT_MONOLITHIC_DRIVEN_MODULE_TYPE}
|
|
||||||
NAMESPACE Gem
|
|
||||||
FILES_CMAKE
|
|
||||||
radtelemetry_shared_files.cmake
|
|
||||||
INCLUDE_DIRECTORIES
|
|
||||||
PRIVATE
|
|
||||||
Source
|
|
||||||
BUILD_DEPENDENCIES
|
|
||||||
PRIVATE
|
|
||||||
Gem::RADTelemetry.Static
|
|
||||||
)
|
|
||||||
|
|
||||||
# the RADTelemetry module above can be used in all kinds of applications, but we don't enable it in asset builders
|
|
||||||
ly_create_alias(NAME RADTelemetry.Clients NAMESPACE Gem TARGETS Gem::RADTelemetry)
|
|
||||||
ly_create_alias(NAME RADTelemetry.Tools NAMESPACE Gem TARGETS Gem::RADTelemetry)
|
|
||||||
ly_create_alias(NAME RADTelemetry.Servers NAMESPACE Gem TARGETS Gem::RADTelemetry)
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
|
|
||||||
#define AZ_TRAIT_RAD_TELEMETRY_OPEN_FLAGS TMOF_INIT_NETWORKING
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
#
|
|
||||||
# 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
|
|
||||||
RADTelemetry_Traits_Platform.h
|
|
||||||
)
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
|
|
||||||
#define AZ_TRAIT_RAD_TELEMETRY_OPEN_FLAGS TMOF_INIT_NETWORKING
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
#
|
|
||||||
# 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
|
|
||||||
RADTelemetry_Traits_Platform.h
|
|
||||||
)
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
|
|
||||||
#define AZ_TRAIT_RAD_TELEMETRY_OPEN_FLAGS TMOF_INIT_NETWORKING
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
#
|
|
||||||
# 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
|
|
||||||
RADTelemetry_Traits_Platform.h
|
|
||||||
)
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
|
|
||||||
#define AZ_TRAIT_RAD_TELEMETRY_OPEN_FLAGS TMOF_INIT_NETWORKING
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
#
|
|
||||||
# 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
|
|
||||||
RADTelemetry_Traits_Platform.h
|
|
||||||
)
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
|
|
||||||
#define AZ_TRAIT_RAD_TELEMETRY_OPEN_FLAGS TMOF_INIT_NETWORKING
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
#
|
|
||||||
# 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
|
|
||||||
RADTelemetry_Traits_Platform.h
|
|
||||||
)
|
|
||||||
@ -1,344 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#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>(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
|
|
||||||
@ -1,103 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
||||||
|
|
||||||
#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
|
|
||||||
@ -1,132 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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 <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(MemoryReserved)) | (s_memCaptureEnabled ? AZ_PROFILE_CAT_TO_RAD_CAPFLAGS(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)
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
#
|
|
||||||
# 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/ProfileTelemetryComponent.cpp
|
|
||||||
Source/ProfileTelemetryComponent.h
|
|
||||||
)
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
#
|
|
||||||
# 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/RADTelemetryModule.cpp
|
|
||||||
)
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"gem_name": "RADTelemetry",
|
|
||||||
"display_name": "RAD Telemetry",
|
|
||||||
"license": "Apache-2.0 Or MIT",
|
|
||||||
"origin": "Open 3D Engine - o3de.org",
|
|
||||||
"type": "Tool",
|
|
||||||
"summary": "The RAD Telemetry Gem provides support for RAD Telemetry, a performance profiling and visualization middleware, in Open 3D Engine.",
|
|
||||||
"canonical_tags": ["Gem"],
|
|
||||||
"user_tags": ["Debug", "SDK"],
|
|
||||||
"icon_path": "preview.png",
|
|
||||||
"requirements": "",
|
|
||||||
"documentation_url": "https://o3de.org/docs/user-guide/gems/reference/debug/rad/rad-telemetry/"
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:6d6204c6730e5675791765ca194e9b1cbec282208e280507de830afc2805e5fa
|
|
||||||
size 41127
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
#
|
|
||||||
# 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(RADTELEMETRY_LIBS ${BASE_PATH}/Lib/librad_tm_android_arm64.a)
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
#
|
|
||||||
# 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(RADTELEMETRY_LIBS ${BASE_PATH}/Lib/librad_tm_mac_x64_link.a)
|
|
||||||
|
|
||||||
set(RADTELEMETRY_RUNTIME_DEPENDENCIES ${BASE_PATH}/Lib/librad_tm_mac_x64.dylib)
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
#
|
|
||||||
# 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(RADTELEMETRY_LIBS ${BASE_PATH}/Lib/rad_tm_win64.lib)
|
|
||||||
|
|
||||||
set(RADTELEMETRY_RUNTIME_DEPENDENCIES ${BASE_PATH}/Dll/rad_tm_win64.dll)
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
#
|
|
||||||
# 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(RADTELEMETRY_LIBS ${BASE_PATH}/Lib/librad_tm_ios.a)
|
|
||||||
Loading…
Reference in New Issue