Rename RenderListAllocation into RendererAllocation

This commit is contained in:
Wojtek Figat
2022-10-28 09:14:09 +02:00
parent eb52d333ae
commit 27ad3c38b7
7 changed files with 97 additions and 89 deletions

View File

@@ -8,6 +8,7 @@
#include "Engine/Graphics/DynamicBuffer.h"
#include "Engine/Scripting/ScriptingObject.h"
#include "DrawCall.h"
#include "RendererAllocation.h"
enum class StaticFlags;
class RenderBuffers;
@@ -220,89 +221,10 @@ struct DrawBatch
}
};
class RenderListAllocation
{
public:
static FLAXENGINE_API void* Allocate(uintptr size);
static FLAXENGINE_API void Free(void* ptr, uintptr size);
template<typename T>
class Data
{
T* _data = nullptr;
uintptr _size;
public:
FORCE_INLINE Data()
{
}
FORCE_INLINE ~Data()
{
if (_data)
RenderListAllocation::Free(_data, _size);
}
FORCE_INLINE T* Get()
{
return _data;
}
FORCE_INLINE const T* Get() const
{
return _data;
}
FORCE_INLINE int32 CalculateCapacityGrow(int32 capacity, int32 minCapacity) const
{
capacity = capacity ? capacity * 2 : 64;
if (capacity < minCapacity)
capacity = minCapacity;
return capacity;
}
FORCE_INLINE void Allocate(uint64 capacity)
{
_size = capacity * sizeof(T);
_data = (T*)RenderListAllocation::Allocate(_size);
}
FORCE_INLINE void Relocate(uint64 capacity, int32 oldCount, int32 newCount)
{
T* newData = capacity != 0 ? (T*)RenderListAllocation::Allocate(capacity * sizeof(T)) : nullptr;
if (oldCount)
{
if (newCount > 0)
Memory::MoveItems(newData, _data, newCount);
Memory::DestructItems(_data, oldCount);
}
if (_data)
RenderListAllocation::Free(_data, _size);
_data = newData;
_size = capacity * sizeof(T);
}
FORCE_INLINE void Free()
{
if (_data)
{
RenderListAllocation::Free(_data, _size);
_data = nullptr;
}
}
FORCE_INLINE void Swap(Data& other)
{
::Swap(_data, other._data);
::Swap(_size, other._size);
}
};
};
struct BatchedDrawCall
{
DrawCall DrawCall;
Array<struct InstanceData, RenderListAllocation> Instances;
Array<struct InstanceData, RendererAllocation> Instances;
};
/// <summary>