Add memory profiling events to the main areas of the engine

This commit is contained in:
Wojtek Figat
2025-05-22 04:47:01 +02:00
parent 32bc73610f
commit c639a3103c
101 changed files with 502 additions and 17 deletions

View File

@@ -13,6 +13,8 @@
#include "Engine/Render2D/FontManager.h"
#include "Engine/Render2D/FontTextureAtlas.h"
#include "Engine/Renderer/RenderList.h"
#include "Engine/Profiler/ProfilerCPU.h"
#include "Engine/Profiler/ProfilerMemory.h"
#include "Engine/Serialization/Serialization.h"
#include "Engine/Content/Assets/MaterialInstance.h"
#include "Engine/Content/Content.h"
@@ -120,6 +122,9 @@ void TextRender::SetLayoutOptions(TextLayoutOptions& value)
void TextRender::UpdateLayout()
{
PROFILE_CPU();
PROFILE_MEM(UI);
// Clear
_ib.Clear();
_vb.Clear();

View File

@@ -6,6 +6,7 @@
#include "Engine/Scripting/ManagedCLR/MClass.h"
#include "Engine/Scripting/ManagedCLR/MUtils.h"
#include "Engine/Serialization/Serialization.h"
#include "Engine/Profiler/ProfilerMemory.h"
#if COMPILE_WITHOUT_CSHARP
#define UICANVAS_INVOKE(event)
@@ -26,6 +27,7 @@ MMethod* UICanvas_ParentChanged = nullptr;
auto* managed = GetManagedInstance(); \
if (managed) \
{ \
PROFILE_MEM(UI); \
MObject* exception = nullptr; \
UICanvas_##event->Invoke(managed, nullptr, &exception); \
if (exception) \
@@ -77,6 +79,7 @@ void UICanvas::Serialize(SerializeStream& stream, const void* otherObj)
SERIALIZE_GET_OTHER_OBJ(UICanvas);
#if !COMPILE_WITHOUT_CSHARP
PROFILE_MEM(UI);
stream.JKEY("V");
void* params[1];
params[0] = other ? other->GetOrCreateManagedInstance() : nullptr;
@@ -109,6 +112,7 @@ void UICanvas::Deserialize(DeserializeStream& stream, ISerializeModifier* modifi
const auto dataMember = stream.FindMember("V");
if (dataMember != stream.MemberEnd())
{
PROFILE_MEM(UI);
rapidjson_flax::StringBuffer buffer;
rapidjson_flax::Writer<rapidjson_flax::StringBuffer> writer(buffer);
dataMember->value.Accept(writer);

View File

@@ -7,6 +7,7 @@
#include "Engine/Scripting/ManagedCLR/MClass.h"
#include "Engine/Scripting/ManagedCLR/MCore.h"
#include "Engine/Serialization/Serialization.h"
#include "Engine/Profiler/ProfilerMemory.h"
#if COMPILE_WITHOUT_CSHARP
#define UICONTROL_INVOKE(event)
@@ -25,6 +26,7 @@ MMethod* UIControl_EndPlay = nullptr;
auto* managed = GetManagedInstance(); \
if (managed) \
{ \
PROFILE_MEM(UI); \
MObject* exception = nullptr; \
UIControl_##event->Invoke(managed, nullptr, &exception); \
if (exception) \
@@ -78,6 +80,7 @@ void UIControl::Serialize(SerializeStream& stream, const void* otherObj)
SERIALIZE_MEMBER(NavTargetRight, _navTargetRight);
#if !COMPILE_WITHOUT_CSHARP
PROFILE_MEM(UI);
void* params[2];
MString* controlType = nullptr;
params[0] = &controlType;
@@ -129,6 +132,7 @@ void UIControl::Deserialize(DeserializeStream& stream, ISerializeModifier* modif
DESERIALIZE_MEMBER(NavTargetRight, _navTargetRight);
#if !COMPILE_WITHOUT_CSHARP
PROFILE_MEM(UI);
MTypeObject* typeObj = nullptr;
const auto controlMember = stream.FindMember("Control");
if (controlMember != stream.MemberEnd())