[development] Android trace support (#7021)
- Abstracted the platform specific low level profiler API - Added support for ATrace markers on Android - Stubbed iOS, Linux, and macOS with unimplemented versions of the low level platform profiler API Signed-off-by: AMZN-ScottR 24445312+AMZN-ScottR@users.noreply.github.com
This commit is contained in:
@@ -10,11 +10,6 @@
|
||||
#include <AzCore/Debug/Budget.h>
|
||||
#include <AzCore/Statistics/StatisticalProfilerProxy.h>
|
||||
|
||||
#ifdef USE_PIX
|
||||
#include <AzCore/PlatformIncl.h>
|
||||
#include <WinPixEventRuntime/pix3.h>
|
||||
#endif
|
||||
|
||||
#if defined(AZ_PROFILER_MACRO_DISABLE) // by default we never disable the profiler registers as their overhead should be minimal, you can
|
||||
// still do that for your code though.
|
||||
#define AZ_PROFILE_SCOPE(...)
|
||||
|
||||
@@ -10,44 +10,48 @@
|
||||
|
||||
namespace AZ::Debug
|
||||
{
|
||||
namespace Platform
|
||||
{
|
||||
template<typename... T>
|
||||
void BeginProfileRegion(Budget* budget, const char* eventName, T const&... args);
|
||||
void BeginProfileRegion(Budget* budget, const char* eventName);
|
||||
void EndProfileRegion(Budget* budget);
|
||||
} // namespace Platform
|
||||
|
||||
template<typename... T>
|
||||
void ProfileScope::BeginRegion(
|
||||
[[maybe_unused]] Budget* budget, [[maybe_unused]] const char* eventName, [[maybe_unused]] T const&... args)
|
||||
{
|
||||
if (!budget)
|
||||
#if !defined(_RELEASE)
|
||||
if (budget)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#if !defined(_RELEASE)
|
||||
// TODO: Verification that the supplied system name corresponds to a known budget
|
||||
#if defined(USE_PIX)
|
||||
PIXBeginEvent(PIX_COLOR_INDEX(budget->Crc() & 0xff), eventName, args...);
|
||||
#endif
|
||||
budget->BeginProfileRegion();
|
||||
Platform::BeginProfileRegion(budget, eventName, args...);
|
||||
|
||||
if (auto profiler = AZ::Interface<Profiler>::Get(); profiler)
|
||||
{
|
||||
profiler->BeginRegion(budget, eventName);
|
||||
budget->BeginProfileRegion();
|
||||
|
||||
if (auto profiler = AZ::Interface<Profiler>::Get(); profiler)
|
||||
{
|
||||
profiler->BeginRegion(budget, eventName);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // #if !defined(_RELEASE)
|
||||
}
|
||||
|
||||
inline void ProfileScope::EndRegion([[maybe_unused]] Budget* budget)
|
||||
{
|
||||
if (!budget)
|
||||
#if !defined(_RELEASE)
|
||||
if (budget)
|
||||
{
|
||||
return;
|
||||
budget->EndProfileRegion();
|
||||
|
||||
if (auto profiler = AZ::Interface<Profiler>::Get(); profiler)
|
||||
{
|
||||
profiler->EndRegion(budget);
|
||||
}
|
||||
|
||||
Platform::EndProfileRegion(budget);
|
||||
}
|
||||
#if !defined(_RELEASE)
|
||||
budget->EndProfileRegion();
|
||||
#if defined(USE_PIX)
|
||||
PIXEndEvent();
|
||||
#endif
|
||||
if (auto profiler = AZ::Interface<Profiler>::Get(); profiler)
|
||||
{
|
||||
profiler->EndRegion(budget);
|
||||
}
|
||||
#endif
|
||||
#endif // !defined(_RELEASE)
|
||||
}
|
||||
|
||||
template<typename... T>
|
||||
@@ -63,3 +67,5 @@ namespace AZ::Debug
|
||||
}
|
||||
|
||||
} // namespace AZ::Debug
|
||||
|
||||
#include <AzCore/Debug/Profiler_Platform.inl>
|
||||
|
||||
Reference in New Issue
Block a user