9#include "Containers/Array.h"
13#define RANGE_ALLOCATOR_RECORD_STATS !UE_BUILD_SHIPPING
80 template <
typename FAllocatorModifier>
90 using FAllocatorModifier::Check;
91 using FAllocatorModifier::MakePointer;
95 using FChunkModifier::AdjustAllocation;
117 using FChunkModifier::IsValid;
118 using FChunkModifier::Contains;
124 FreeRanges.
Add(FRange(0,
Allocator.ChunkSize / MinAlignment));
142 FRange& Range = FreeRanges[
Index];
143 const uint16 Start = Range.OffsetMultiplier;
184 const FRange& Range = FreeRanges[
Index];
265#if RANGE_ALLOCATOR_RECORD_STATS
268 const int32 InfoIndex =
Chunks[ChunkIndex].InfoIndex;
273 Chunks[ChunkIndex].~FChunk();
278#if RANGE_ALLOCATOR_RECORD_STATS
290 using FAllocatorModifier::ChunkSize;
291 using FAllocatorModifier::MinAlignment;
311 Alignment =
Align(FMath::Max(Alignment, MinAlignment), MinAlignment);
324 if (
Size + Alignment - 1 <= (
uint32)
Info.MaxFreeRangeSize * MinAlignment)
329#if RANGE_ALLOCATOR_RECORD_STATS
356#if RANGE_ALLOCATOR_RECORD_STATS
371 uint16 MaxFreeRangeSize = ChunkSize / MinAlignment;
384 ::new ((
void*)&Chunk)
FChunk(*
this);
387#if RANGE_ALLOCATOR_RECORD_STATS
408#if RANGE_ALLOCATOR_RECORD_STATS
435 if (Chunk.IsValid() && Chunk.Contains(Addr))
constexpr T Align(T Val, uint64 Alignment)
Definition AlignmentTemplates.h:18
@ INDEX_NONE
Definition CoreMiscDefines.h:150
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
FRWLock Lock
Definition UnversionedPropertySerialization.cpp:921
uint32 Offset
Definition VulkanMemory.cpp:4033
uint32 Size
Definition VulkanMemory.cpp:4034
Definition ScopeLock.h:141
UE_FORCEINLINE_HINT SizeType AddUninitialized()
Definition Array.h:1664
UE_REWRITE SizeType Num() const
Definition Array.h:1144
void RemoveAt(SizeType Index, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:2083
UE_FORCEINLINE_HINT void RemoveAtSwap(SizeType Index, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:2185
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
SizeType Insert(std::initializer_list< ElementType > InitList, const SizeType InIndex)
Definition Array.h:1875
Definition RangeAllocator.h:94
SIZE_T Alloc(uint32 InSize, uint32 InAlignment, uint16 &InOutMaxFreeRangeSize, uint16 &OutOffset, uint16 &OutSize)
Definition RangeAllocator.h:127
void Free(uint16 Offset, uint16 Size, uint16 &InOutMaxFreeRangeSize)
Definition RangeAllocator.h:195
FChunk(const FRangeAllocator &Allocator)
Definition RangeAllocator.h:120
int32 InfoIndex
Definition RangeAllocator.h:113
int32 NextFreeChunkSlot
Definition RangeAllocator.h:114
Definition RangeAllocator.h:82
void Free(const FAllocInfo &AllocInfo)
Definition RangeAllocator.h:400
TRangeAllocator(uint32 InMinAllocSize, ArgTypes &&... Args)
Definition RangeAllocator.h:301
SIZE_T SizeTotal
Definition RangeAllocator.h:279
typename FAllocatorModifier::FPointerType FPointerType
Definition RangeAllocator.h:85
TArray< FChunk > Chunks
Definition RangeAllocator.h:286
FCriticalSection CS
Definition RangeAllocator.h:287
bool Contains(FConstPointerType Addr) const
Definition RangeAllocator.h:429
typename FAllocatorModifier::FAllocInfoModifier FAllocInfoModifier
Definition RangeAllocator.h:88
void FreeChunk(uint32 ChunkIndex)
Definition RangeAllocator.h:263
const uint16 MinAllocSize
Definition RangeAllocator.h:283
typename FAllocatorModifier::FChunkModifier FChunkModifier
Definition RangeAllocator.h:87
SIZE_T SizeUsed
Definition RangeAllocator.h:280
typename FAllocatorModifier::FConstPointerType FConstPointerType
Definition RangeAllocator.h:86
int32 FreeChunkSlotHead
Definition RangeAllocator.h:284
TArray< FFreeChunkInfo > FreeChunkInfos
Definition RangeAllocator.h:285
FPointerType Alloc(uint32 Size, uint32 Alignment, FAllocInfo &OutAllocInfo)
Definition RangeAllocator.h:307
void RemoveFreeChunkInfo(int32 InfoIndex)
Definition RangeAllocator.h:254
UE_REWRITE auto UpperBoundBy(const RangeType &Range, const ValueType &Value, ProjectionType Projection, SortPredicateType SortPredicate) -> decltype(GetNum(Range))
Definition BinarySearch.h:154
U16 Index
Definition radfft.cpp:71
static constexpr UE_FORCEINLINE_HINT bool IsPowerOfTwo(T Value)
Definition UnrealMathUtility.h:519
Definition RangeAllocator.h:294
uint16 RangeOffset
Definition RangeAllocator.h:295
uint32 ChunkIndex
Definition RangeAllocator.h:297
uint16 RangeSize
Definition RangeAllocator.h:296
Definition RangeAllocator.h:244
FFreeChunkInfo(uint16 InMaxFreeRangeSize, uint16 InChunkIndex)
Definition RangeAllocator.h:248
uint16 ChunkIndex
Definition RangeAllocator.h:246
uint16 MaxFreeRangeSize
Definition RangeAllocator.h:245