Cleanup code to share it for engine service profile event formatting
This commit is contained in:
@@ -37,6 +37,21 @@ DEFINE_ENGINE_SERVICE_EVENT(LateFixedUpdate);
|
|||||||
DEFINE_ENGINE_SERVICE_EVENT(Draw);
|
DEFINE_ENGINE_SERVICE_EVENT(Draw);
|
||||||
DEFINE_ENGINE_SERVICE_EVENT_INVERTED(BeforeExit);
|
DEFINE_ENGINE_SERVICE_EVENT_INVERTED(BeforeExit);
|
||||||
|
|
||||||
|
#if TRACY_ENABLE
|
||||||
|
|
||||||
|
StringView FillEventNameBuffer(Char* buffer, StringView name, StringView postfix)
|
||||||
|
{
|
||||||
|
int32 size = 0;
|
||||||
|
for (int32 j = 0; j < name.Length(); j++)
|
||||||
|
if (name[j] != ' ')
|
||||||
|
buffer[size++] = name[j];
|
||||||
|
Platform::MemoryCopy(buffer + size, postfix.Get(), (postfix.Length() + 1) * sizeof(Char));
|
||||||
|
size += postfix.Length();
|
||||||
|
return StringView(buffer, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
EngineService::EngineServicesArray& EngineService::GetServices()
|
EngineService::EngineServicesArray& EngineService::GetServices()
|
||||||
{
|
{
|
||||||
static EngineServicesArray Services;
|
static EngineServicesArray Services;
|
||||||
@@ -78,14 +93,9 @@ void EngineService::OnInit()
|
|||||||
const StringView name(service->Name);
|
const StringView name(service->Name);
|
||||||
#if TRACY_ENABLE
|
#if TRACY_ENABLE
|
||||||
ZoneScoped;
|
ZoneScoped;
|
||||||
int32 nameBufferLength = 0;
|
|
||||||
Char nameBuffer[100];
|
Char nameBuffer[100];
|
||||||
for (int32 j = 0; j < name.Length(); j++)
|
StringView zoneName = FillEventNameBuffer(nameBuffer, name, StringView(TEXT("::Init"), 6));
|
||||||
if (name[j] != ' ')
|
ZoneName(zoneName.Get(), zoneName.Length());
|
||||||
nameBuffer[nameBufferLength++] = name[j];
|
|
||||||
Platform::MemoryCopy(nameBuffer + nameBufferLength, TEXT("::Init"), 7 * sizeof(Char));
|
|
||||||
nameBufferLength += 7;
|
|
||||||
ZoneName(nameBuffer, nameBufferLength);
|
|
||||||
#endif
|
#endif
|
||||||
LOG(Info, "Initialize {0}...", name);
|
LOG(Info, "Initialize {0}...", name);
|
||||||
service->IsInitialized = true;
|
service->IsInitialized = true;
|
||||||
@@ -114,15 +124,10 @@ void EngineService::OnDispose()
|
|||||||
{
|
{
|
||||||
#if TRACY_ENABLE
|
#if TRACY_ENABLE
|
||||||
ZoneScoped;
|
ZoneScoped;
|
||||||
const StringView name(service->Name);
|
|
||||||
int32 nameBufferLength = 0;
|
|
||||||
Char nameBuffer[100];
|
Char nameBuffer[100];
|
||||||
for (int32 j = 0; j < name.Length(); j++)
|
const StringView name(service->Name);
|
||||||
if (name[j] != ' ')
|
StringView zoneName = FillEventNameBuffer(nameBuffer, name, StringView(TEXT("::Dispose"), 9));
|
||||||
nameBuffer[nameBufferLength++] = name[j];
|
ZoneName(zoneName.Get(), zoneName.Length());
|
||||||
Platform::MemoryCopy(nameBuffer + nameBufferLength, TEXT("::Dispose"), 10 * sizeof(Char));
|
|
||||||
nameBufferLength += 10;
|
|
||||||
ZoneName(nameBuffer, nameBufferLength);
|
|
||||||
#endif
|
#endif
|
||||||
service->IsInitialized = false;
|
service->IsInitialized = false;
|
||||||
service->Dispose();
|
service->Dispose();
|
||||||
|
|||||||
Reference in New Issue
Block a user