From 3b3cd5ade4a7d5ef502b8256323e76bd2263dd3f Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 21 Jun 2024 23:01:32 +0200 Subject: [PATCH] Optimize Global Surface Atlas defragmenting to just reset tiles, not whole objects list --- Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp b/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp index f92e0ca52..3fd2060d9 100644 --- a/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp +++ b/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp @@ -268,7 +268,14 @@ public: (float)AtlasPixelsUsed / AtlasPixelsTotal < maxUsageToDefrag) { PROFILE_CPU_NAMED("Defragment Atlas"); - ClearObjects(); + LastFrameAtlasDefragmentation = Engine::FrameCount; + for (auto& e : Objects) + { + auto& object = e.Value; + Platform::MemoryClear(object.Tiles, sizeof(object.Tiles)); + } + Atlas.Clear(); + AtlasPixelsUsed = 0; } }