Compile out tracker in release mode

Signed-off-by: Jeremy Ong <jcong@amazon.com>
This commit is contained in:
Jeremy Ong
2021-08-24 15:06:56 -06:00
parent c37c0cab08
commit a9b4ad3486
5 changed files with 25 additions and 14 deletions
@@ -545,7 +545,9 @@ namespace AZ
m_entityActivatedEvent.DisconnectAllHandlers();
m_entityDeactivatedEvent.DisconnectAllHandlers();
#if !defined(_RELEASE)
m_budgetTracker.Reset();
#endif
DestroyAllocator();
}
@@ -595,7 +597,9 @@ namespace AZ
CreateOSAllocator();
CreateSystemAllocator();
#if !defined(_RELEASE)
m_budgetTracker.Init();
#endif
// This can be moved to the ComponentApplication constructor if need be
// This is reading the *.setreg files using SystemFile and merging the settings
@@ -395,7 +395,9 @@ namespace AZ
// from the m_console member when it goes out of scope
AZ::SettingsRegistryConsoleUtils::ConsoleFunctorHandle m_settingsRegistryConsoleFunctors;
#if !defined(_RELEASE)
Debug::BudgetTracker m_budgetTracker;
#endif
// this is used when no argV/ArgC is supplied.
// in order to have the same memory semantics (writable, non-const)
@@ -29,6 +29,12 @@ namespace AZ::Debug
// TODO: Budget implementation for tracking budget wall time per-core, memory, etc.
};
Budget::Budget(const char* name)
: m_name{ name }
, m_crc{ Crc32(name) }
{
}
Budget::Budget(const char* name, uint32_t crc)
: m_name{ name }
, m_crc{ crc }
+12 -13
View File
@@ -9,7 +9,6 @@
#include <AzCore/Debug/BudgetTracker.h>
#include <AzCore/Math/Crc.h>
#include <AzCore/std/parallel/atomic.h>
namespace AZ::Debug
{
@@ -17,6 +16,7 @@ namespace AZ::Debug
class Budget final
{
public:
explicit Budget(const char* name);
Budget(const char* name, uint32_t crc);
~Budget();
@@ -38,7 +38,7 @@ namespace AZ::Debug
private:
const char* m_name;
uint32_t m_crc;
const uint32_t m_crc;
struct BudgetImpl* m_impl = nullptr;
};
} // namespace AZ::Debug
@@ -49,6 +49,13 @@ namespace AZ::Debug
// for usage.
#define AZ_BUDGET_GETTER(name) GetAzBudget##name
#if defined(_RELEASE)
#define AZ_DEFINE_BUDGET(name) \
::AZ::Debug::Budget* AZ_BUDGET_GETTER(name)() \
{ \
return nullptr; \
}
#else
// Usage example:
// In a single C++ source file:
// AZ_DEFINE_BUDGET(AzCore);
@@ -59,18 +66,10 @@ namespace AZ::Debug
::AZ::Debug::Budget* AZ_BUDGET_GETTER(name)() \
{ \
constexpr static uint32_t crc = AZ_CRC_CE(#name); \
static ::AZStd::atomic<::AZ::Debug::Budget*> budget; \
::AZ::Debug::Budget* out = budget.load(AZStd::memory_order_acquire); \
if (out) \
{ \
return out; \
} \
else \
{ \
budget.store(::AZ::Debug::BudgetTracker::GetBudgetFromEnvironment(#name, crc), AZStd::memory_order_release); \
return budget; \
} \
static ::AZ::Debug::Budget* budget = ::AZ::Debug::BudgetTracker::GetBudgetFromEnvironment(#name, crc); \
return budget; \
}
#endif
// If using a budget defined in a different C++ source file, add AZ_DECLARE_BUDGET(yourBudget); somewhere in your source file at namespace
// scope Alternatively, AZ_DECLARE_BUDGET can be used in a header to declare the budget for use across any users of the header
@@ -269,7 +269,7 @@ namespace Terrain
void TerrainFeatureProcessor::ProcessSurfaces(const FeatureProcessor::RenderPacket& process)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzRender);
AZ_PROFILE_FUNCTION(AzRender);
if (m_drawListTag.IsNull())
{