Optimize RendererAllocation by reducing fragmentation with operating on power-of-2 blocks
This commit is contained in:
@@ -220,6 +220,7 @@ void RenderFogData::Init(const RenderView& view, IFogRenderer* renderer)
|
||||
void* RendererAllocation::Allocate(uintptr size)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
size = AllocationUtils::AlignToPowerOf2((int32)size); // Reduce fragmentation by operating on power-of-2 blocks
|
||||
void* result = nullptr;
|
||||
MemPoolLocker.Lock();
|
||||
for (int32 i = 0; i < MemPool.Count(); i++)
|
||||
@@ -240,6 +241,7 @@ void* RendererAllocation::Allocate(uintptr size)
|
||||
void RendererAllocation::Free(void* ptr, uintptr size)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
size = AllocationUtils::AlignToPowerOf2((int32)size); // Reduce fragmentation by operating on power-of-2 blocks
|
||||
MemPoolLocker.Lock();
|
||||
MemPool.Add({ ptr, size });
|
||||
MemPoolLocker.Unlock();
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
#include "Engine/Core/Memory/SimpleHeapAllocation.h"
|
||||
|
||||
/// <summary>
|
||||
/// Shared pool allocator for the renderer used for large chunks of memory.
|
||||
/// </summary>
|
||||
class RendererAllocation : public SimpleHeapAllocation<RendererAllocation, 64>
|
||||
{
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user