engine
 
载入中...
搜索中...
未找到
类 | Public 成员函数 | Protected 类型 | Protected 成员函数 | Protected 属性 | 所有成员列表
FGPUDefragAllocator类 参考abstract

Simple best fit allocator, splitting and coalescing whenever/ wherever possible. 更多...

#include <GPUDefragAllocator.h>

类

class  FMemoryChunk
 Contains information of a single allocation or free block. 更多...
 
struct  FRelocationStats
 Container for allocator relocation stats. 更多...
 
struct  FSettings
 Container for allocator settings. 更多...
 

Public 成员函数

virtual void * Allocate (int64 AllocationSize, int32 Alignment, TStatId InStat, bool bAllowFailure)
 Allocate physical memory. 更多...
 
void Benchmark (int32 MinChunkSize, int32 MaxChunkSize, float FreeRatio, float LockRatio, bool bFullDefrag, bool bSaveImages, const TCHAR *Filename)
 Performs a benchmark of the allocator and outputs the result to the log. 更多...
 
void BlockOnAsyncReallocation (FAsyncReallocationRequest *Request)
 Blocks the calling thread until the specified request has been completed. 更多...
 
void CancelAsyncReallocation (FAsyncReallocationRequest *Request, const void *CurrentBaseAddress)
 Cancels the specified reallocation request. 更多...
 
void DefragmentMemory (FRelocationStats &Stats)
 Fully defragments the memory and blocks until it's done. 更多...
 
void DumpAllocs (FOutputDevice &Ar= *GLog)
 Dump allocation information.
 
 FGPUDefragAllocator ()
 Constructor, zero initializing all member variables
 
bool FinishAllRelocations ()
 Blocks the calling thread until all relocations and reallocations that were initiated by Tick() have completed. 更多...
 
virtual void Free (void *Pointer)
 Frees allocation associated with the specified Pointer. 更多...
 
int64 GetAllocatedSize (void *Pointer)
 Returns the amount of memory allocated for the specified address. 更多...
 
uint32 GetBlockedCycles () const
 Returns the amount of time blocked by a platform fence since the beginning of the last call to Tick(), in appCycles.
 
int32 GetLargestAvailableAllocation (int32 *OutNumFreeChunks=nullptr)
 Scans the free chunks and returns the largest size you can allocate. 更多...
 
virtual void GetMemoryStats (int64 &OutAllocatedMemorySize, int64 &OutAvailableMemorySize, int64 &OutPendingMemoryAdjustment, int64 &OutPaddingWasteSize)
 Retrieves allocation stats. 更多...
 
void GetSettings (FSettings &OutSettings)
 Returns the current allocator settings. 更多...
 
bool GetTextureMemoryVisualizeData (FColor *TextureData, int32 SizeX, int32 SizeY, int32 Pitch, const int32 PixelSize)
 Fills a texture with to visualize the texture pool memory. 更多...
 
void * GetUserPayload (const void *Pointer)
 Returns the user payload for an FMemoryChunk 更多...
 
bool InBenchmarkMode () const
 Returns whether we're in benchmark mode or not.
 
virtual void Initialize (uint8 *InMemoryBase, int64 InMemorySize, int32 InAllocationAlignment)
 Initialize this allocator with a preallocated block of memory. 更多...
 
bool IsInitialized ()
 Returns whether allocator has been initialized.
 
virtual void Lock (const void *Pointer)
 Locks an FMemoryChunk 更多...
 
void * Reallocate (void *OldBaseAddress, int64 NewSize)
 Tries to reallocate texture memory in-place (without relocating), by adjusting the base address of the allocation but keeping the end address the same. 更多...
 
void SetSettings (const FSettings &InSettings)
 Sets new allocator settings. 更多...
 
void SetUserPayload (const void *Pointer, void *UserPayload)
 Sets the user payload for an FMemoryChunk 更多...
 
virtual int32 Tick (FRelocationStats &Stats, bool bPanicDefrag)
 Partially defragments the memory and tries to process all async reallocation requests at the same time. 更多...
 
virtual void Unlock (const void *Pointer)
 Unlocks an FMemoryChunk 更多...
 

Protected 类型

typedef int64 memsize_t
 Allocated memory in uint8s. 更多...
 

Protected 成员函数

FMemoryChunk * AllocateChunk (FMemoryChunk *FreeChunk, int64 AllocationSize, bool bAsync, bool bDoValidation=true)
 Marks the specified chunk as 'allocated' and updates tracking variables. 更多...
 
void BlockOnFence ()
 Blocks the calling thread until the current sync fence has been completed.
 
void BlockOnSyncIndex (uint32 SyncIndex)
 Blocks the calling thread until the specified sync index has been completed. 更多...
 
bool CanRelocate (const FMemoryChunk *Chunk) const
 Returns true if the specified chunk is allowed to relocate at this time. 更多...
 
void CheckForErrors (bool bCheckSortedFreeList)
 Checks the int32ernal state for errors. 更多...
 
void Coalesce (FMemoryChunk *FreedChunk)
 Merges any adjacent free chunks into the specified free chunk. 更多...
 
FMemoryChunk * FindAdjacent (FMemoryChunk *UsedChunk, bool bAnyChunkType)
 Defrag helper function. 更多...
 
FMemoryChunk * FindAdjacentToHole (FMemoryChunk *FreeChunk)
 Searches for an allocated chunk that would fit within the specified free chunk. 更多...
 
FMemoryChunk * FindAny (FMemoryChunk *FreeChunk)
 Searches for an allocated chunk that would fit within the specified free chunk. 更多...
 
void FreeChunk (FMemoryChunk *Chunk)
 Marks the specified chunk as 'free' and updates tracking variables. 更多...
 
void FullDefragmentation (FRelocationStats &Stats)
 Performs a full defrag and ignores all reallocation requests. 更多...
 
uint32 GetCurrentSyncIndex () const
 Returns the sync index to be completed by the next call to FinishAllRelocations().
 
FMemoryChunk * Grow (FMemoryChunk *Chunk, int64 GrowAmount)
 Tries to immediately grow a memory chunk by moving the base address, without relocating any memory. 更多...
 
void InsertFence ()
 Inserts a platform fence and updates the allocator sync index to match.
 
void LinkFreeChunk (FMemoryChunk *Chunk)
 Frees the passed in chunk and coalesces adjacent free chunks into 'Chunk' if possible. 更多...
 
void PartialDefragmentationDownshift (FRelocationStats &Stats, double StartTime)
 Performs a partial defrag by shifting down memory to fill holes, in a brute-force manner. 更多...
 
void PartialDefragmentationFast (FRelocationStats &Stats, double StartTime)
 Performs a partial defrag doing fast checks only. 更多...
 
void PartialDefragmentationSlow (FRelocationStats &Stats, double StartTime)
 Performs a partial defrag doing slow all chunk search to find used chunks to move that are surrounded by other used chunks That a freechunk walk won't find. 更多...
 
virtual void PlatformBlockOnFence (uint64 Fence)=0
 Blocks the calling thread until all relocations initiated before the fence was added has been fully completed. 更多...
 
virtual bool PlatformCanRelocate (const void *Source, void *UserPayload) const =0
 Allows each platform to decide whether an allocation can be relocated at this time. 更多...
 
virtual uint64 PlatformInsertFence ()=0
 Inserts a fence to synchronize relocations. 更多...
 
virtual void PlatformNotifyReallocationFinished (FAsyncReallocationRequest *FinishedRequest, void *UserPayload)=0
 Notifies the platform that an async reallocation request has been completed. 更多...
 
virtual void PlatformRelocate (void *Dest, const void *Source, int64 Size, void *UserPayload)=0
 Copy memory from one location to another. 更多...
 
void Relocate (FRelocationStats &Stats, FMemoryChunk *Dest, int64 DestOffset, const void *Source, int64 Size, void *UserPayload)
 Copy memory from one location to another. 更多...
 
FMemoryChunk * RelocateIntoFreeChunk (FRelocationStats &Stats, FMemoryChunk *FreeChunk, FMemoryChunk *UsedChunk)
 Initiates an async relocation of an allocated chunk into a free chunk. 更多...
 
FMemoryChunk * Shrink (FMemoryChunk *Chunk, int64 ShrinkAmount)
 Immediately shrinks a memory chunk by moving the base address, without relocating any memory. 更多...
 
void SortFreeList (int32 &NumFreeChunks, int64 &LargestFreeChunk)
 Sorts the freelist based on increasing base address. 更多...
 
void Split (FMemoryChunk *BaseChunk, int64 FirstSize)
 Split allocation into two, first chunk being used and second being available. 更多...
 

Protected 属性

int32 AllocationAlignment
 Allocation alignment requirements. 更多...
 
volatile memsize_t AvailableMemorySize
 Available memory in uint8s. 更多...
 
bool bBenchmarkMode
 When in benchmark mode, don't call any Platform functions. 更多...
 
uint32 BlockedCycles
 Amount of time blocked by a platform fence since the beginning of the last call to Tick(), in appCycles. 更多...
 
uint64 CompletedSyncIndex
 Sync index that has been completed, so far. 更多...
 
uint64 CurrentSyncIndex
 Ever-increasing index to synchronize all relocations initiated by Tick().
 
FMemoryChunk * FirstChunk
 Head of linked list of chunks. 更多...
 
FMemoryChunk * FirstFreeChunk
 Head of linked list of free chunks. 更多...
 
FMemoryChunk * LastChunk
 Last chunk in the linked list of chunks (see FirstChunk). 更多...
 
int32 MaxNumHoles
 Maximum number of disjoint32 free memory regions we've had.
 
uint8 * MemoryBase
 Base of memory pool. 更多...
 
uint64 MemorySize
 Total size of memory pool, in uint8s. 更多...
 
int64 MinLargestHole
 Smallest consecutive free memory region we've had. 更多...
 
int32 NumCanceledAsyncRequests
 Total number of async requests that has been canceled so far. 更多...
 
int32 NumFinishedAsyncAllocations
 Total number of async allocations successfully completed so far. 更多...
 
int32 NumFinishedAsyncReallocations
 Total number of async reallocations successfully completed so far. 更多...
 
int32 NumRelocationsInProgress
 Number of async relocations that are currently in progress.
 
TDoubleLinkedList< FMemoryChunk * > PendingFreeChunks
 Chunks that couldn't be freed immediately because they were being relocated.
 
volatile memsize_t PendingMemoryAdjustment
 Adjustment to allocated memory, pending all reallocations. 更多...
 
uint64 PlatformSyncFence
 Platform-specific (GPU) fence, used for synchronizing the Sync Index.
 
TMap< void *, FMemoryChunk * > PointerToChunkMap
 Mapping from Pointer to chunk for fast removal. 更多...
 
FSettings Settings
 Allocator settings that affect its behavior. 更多...
 
double TimeSpentInAllocator
 Cumulative time spent in allocator. 更多...
 
uint64 TotalNumBytesRelocated
 Total number of uint8s relocated so far. 更多...
 
uint64 TotalNumRelocations
 Total number of relocations performed so far. 更多...
 

详细描述

Simple best fit allocator, splitting and coalescing whenever/ wherever possible.

NOT THREAD-SAFE.

成员类型定义说明

◆ memsize_t

typedef int64 FGPUDefragAllocator::memsize_t
protected

Allocated memory in uint8s.


成员函数说明

◆ Allocate()

virtual void * FGPUDefragAllocator::Allocate ( int64  AllocationSize,
int32  Alignment,
TStatId  InStat,
bool  bAllowFailure 
)
virtual

Allocate physical memory.

参数
AllocationSizeSize of allocation
bAllowFailureWhether to allow allocation failure or not
返回
Pointer to allocated memory

◆ AllocateChunk()

FMemoryChunk * FGPUDefragAllocator::AllocateChunk ( FMemoryChunk *  FreeChunk,
int64  AllocationSize,
bool  bAsync,
bool  bDoValidation = true 
)
protected

Marks the specified chunk as 'allocated' and updates tracking variables.

Splits the chunk if only a portion of it is allocated.

参数
FreeChunkChunk to allocate
AllocationSizeNumber of uint8s to allocate
bAsyncIf true, allows allocating from relocating chunks and maint32ains the free-list sort order.
返回
The memory chunk that was allocated (the original chunk could've been split).

◆ Benchmark()

void FGPUDefragAllocator::Benchmark ( int32  MinChunkSize,
int32  MaxChunkSize,
float  FreeRatio,
float  LockRatio,
bool  bFullDefrag,
bool  bSaveImages,
const TCHAR *  Filename 
)

Performs a benchmark of the allocator and outputs the result to the log.

参数
MinChunkSizeMinimum number of uint8s per random chunk
MaxChunkSizeMaximum number of uint8s per random chunk
FreeRatioFree 0.0-1.0 of the memory before benchmarking
LockRatioLock 0.0-1.0 % of the memory before benchmarking
bFullDefragWhether to test full defrag (true) or continuous defrag (false)
bSaveImagesWhether to save before/after images to hard disk (TexturePoolBenchmark-*.bmp)
Filename[opt] Filename to a previously saved memory layout to use for benchmarking, or nullptr

◆ BlockOnAsyncReallocation()

FORCEINLINE void FGPUDefragAllocator::BlockOnAsyncReallocation ( FAsyncReallocationRequest *  Request)

Blocks the calling thread until the specified request has been completed.

参数
RequestRequest to wait for. Must be a valid request.

◆ BlockOnSyncIndex()

void FGPUDefragAllocator::BlockOnSyncIndex ( uint32  SyncIndex)
protected

Blocks the calling thread until the specified sync index has been completed.

参数
SyncIndexSync index to wait for

◆ CancelAsyncReallocation()

void FGPUDefragAllocator::CancelAsyncReallocation ( FAsyncReallocationRequest *  Request,
const void *  CurrentBaseAddress 
)

Cancels the specified reallocation request.

Note that the allocator doesn't keep track of requests after it's been completed, so the user must provide the current base address. This may not match any of the addresses in the (old) request since the memory may have been relocated since then.

参数
RequestRequest to cancel. Must be a valid request.
CurrentBaseAddressCurrent baseaddress used by the allocation.

◆ CanRelocate()

FORCEINLINE bool FGPUDefragAllocator::CanRelocate ( const FMemoryChunk *  Chunk) const
protected

Returns true if the specified chunk is allowed to relocate at this time.

Will also call PlatformCanRelocate().

参数
ChunkChunk to check
返回
true if the allocation can be relocated at this time

◆ CheckForErrors()

void FGPUDefragAllocator::CheckForErrors ( bool  bCheckSortedFreeList)
protected

Checks the int32ernal state for errors.

(Slow)

参数
bCheckSortedFreeListIf true, also checks that the freelist is sorted

◆ Coalesce()

void FGPUDefragAllocator::Coalesce ( FMemoryChunk *  FreedChunk)
protected

Merges any adjacent free chunks into the specified free chunk.

Doesn't affect the free-list sort order.

参数
FreedChunkChunk that just became available.

◆ DefragmentMemory()

void FGPUDefragAllocator::DefragmentMemory ( FRelocationStats &  Stats)

Fully defragments the memory and blocks until it's done.

参数
Stats[out] Stats

◆ FindAdjacent()

FMemoryChunk * FGPUDefragAllocator::FindAdjacent ( FMemoryChunk *  UsedChunk,
bool  bAnyChunkType 
)
protected

Defrag helper function.

Checks if the specified allocation fits within the adjacent free chunk(s).

参数
UsedChunkAllocated chunk to check for a fit
bAnyChunkTypeIf false, only succeeds if 'UsedChunk' has a reallocation request and fits
返回
Returns 'UsedChunk' if it fits the criteria, otherwise nullptr

◆ FindAdjacentToHole()

FMemoryChunk * FGPUDefragAllocator::FindAdjacentToHole ( FMemoryChunk *  FreeChunk)
protected

Searches for an allocated chunk that would fit within the specified free chunk.

The allocated chunk must be adjacent to a free chunk and have a larger base address than 'FreeChunk'. Starts searching from the end of the texture pool.

参数
FreeChunkFree chunk we're trying to fill up
返回
Pointer to a suitable chunk, or nullptr

◆ FindAny()

FMemoryChunk * FGPUDefragAllocator::FindAny ( FMemoryChunk *  FreeChunk)
protected

Searches for an allocated chunk that would fit within the specified free chunk.

Any chunk that fits and has a larger base address than 'FreeChunk' is accepted. Starts searching from the end of the texture pool.

参数
FreeChunkFree chunk we're trying to fill up
返回
Pointer to a suitable chunk, or nullptr

◆ FinishAllRelocations()

bool FGPUDefragAllocator::FinishAllRelocations ( )

Blocks the calling thread until all relocations and reallocations that were initiated by Tick() have completed.

返回
true if there were any relocations in progress before this call

◆ Free()

virtual void FGPUDefragAllocator::Free ( void *  Pointer)
virtual

Frees allocation associated with the specified Pointer.

参数
PointerPointer to free.

◆ FreeChunk()

void FGPUDefragAllocator::FreeChunk ( FMemoryChunk *  Chunk)
protected

Marks the specified chunk as 'free' and updates tracking variables.

Calls LinkFreeChunk() to coalesce adjacent free memory.

参数
ChunkChunk to free

◆ FullDefragmentation()

void FGPUDefragAllocator::FullDefragmentation ( FRelocationStats &  Stats)
protected

Performs a full defrag and ignores all reallocation requests.

参数
Stats[out] Stats

◆ GetAllocatedSize()

int64 FGPUDefragAllocator::GetAllocatedSize ( void *  Pointer)

Returns the amount of memory allocated for the specified address.

参数
PointerPointer to check.
返回
Number of uint8s allocated

◆ GetLargestAvailableAllocation()

int32 FGPUDefragAllocator::GetLargestAvailableAllocation ( int32 *  OutNumFreeChunks = nullptr)

Scans the free chunks and returns the largest size you can allocate.

参数
OutNumFreeChunksUpon return, contains the total number of free chunks. May be nullptr.
返回
The largest size of all free chunks.

◆ GetMemoryStats()

virtual void FGPUDefragAllocator::GetMemoryStats ( int64 &  OutAllocatedMemorySize,
int64 &  OutAvailableMemorySize,
int64 &  OutPendingMemoryAdjustment,
int64 &  OutPaddingWasteSize 
)
inlinevirtual

Retrieves allocation stats.

参数
OutAllocatedMemorySize[out] Size of allocated memory
OutAvailableMemorySize[out] Size of available memory
OutPendingMemoryAdjustment[out] Size of pending allocation change (due to async reallocation)

◆ GetSettings()

void FGPUDefragAllocator::GetSettings ( FSettings &  OutSettings)
inline

Returns the current allocator settings.

参数
OutSettings[out] Current allocator settings

◆ GetTextureMemoryVisualizeData()

bool FGPUDefragAllocator::GetTextureMemoryVisualizeData ( FColor *  TextureData,
int32  SizeX,
int32  SizeY,
int32  Pitch,
const int32  PixelSize 
)

Fills a texture with to visualize the texture pool memory.

参数
TextureDataStart address
SizeXNumber of pixels along X
SizeYNumber of pixels along Y
PitchNumber of uint8s between each row
PixelSizeNumber of uint8s each pixel represents
返回
true if successful, false otherwise

◆ GetUserPayload()

void * FGPUDefragAllocator::GetUserPayload ( const void *  Pointer)

Returns the user payload for an FMemoryChunk

参数
PointerPointer indicating a chunk return The chunk's user payload

◆ Grow()

FMemoryChunk * FGPUDefragAllocator::Grow ( FMemoryChunk *  Chunk,
int64  GrowAmount 
)
protected

Tries to immediately grow a memory chunk by moving the base address, without relocating any memory.

参数
ChunkChunk to grow
GrowAmountNumber of uint8s to grow by
返回
nullptr if it failed, otherwise the new grown chunk

◆ Initialize()

virtual void FGPUDefragAllocator::Initialize ( uint8 *  InMemoryBase,
int64  InMemorySize,
int32  InAllocationAlignment 
)
inlinevirtual

Initialize this allocator with a preallocated block of memory.

参数
InMemoryBaseBase address for the block of memory
InMemorySizeSize of the block of memory, in uint8s
InAllocationAlignmentAlignment for all allocations, in uint8s

◆ LinkFreeChunk()

void FGPUDefragAllocator::LinkFreeChunk ( FMemoryChunk *  Chunk)
inlineprotected

Frees the passed in chunk and coalesces adjacent free chunks into 'Chunk' if possible.

Maint32ains the free-list order if bSortedFreeList is true.

参数
ChunkChunk to mark as available.
bSortedFreeListIf true, maintains the free-list sort order

◆ Lock()

virtual void FGPUDefragAllocator::Lock ( const void *  Pointer)
virtual

Locks an FMemoryChunk

参数
PointerPointer indicating which chunk to lock

◆ PartialDefragmentationDownshift()

void FGPUDefragAllocator::PartialDefragmentationDownshift ( FRelocationStats &  Stats,
double  StartTime 
)
protected

Performs a partial defrag by shifting down memory to fill holes, in a brute-force manner.

Takes consideration to async reallocations, but processes the all memory in order.

参数
Stats[out] Stats
StartTimeStart time, used for limiting the Tick() time

◆ PartialDefragmentationFast()

void FGPUDefragAllocator::PartialDefragmentationFast ( FRelocationStats &  Stats,
double  StartTime 
)
protected

Performs a partial defrag doing fast checks only.

Adjacency and freelist walk.

参数
Stats[out] Stats
StartTimeStart time, used for limiting the Tick() time

◆ PartialDefragmentationSlow()

void FGPUDefragAllocator::PartialDefragmentationSlow ( FRelocationStats &  Stats,
double  StartTime 
)
protected

Performs a partial defrag doing slow all chunk search to find used chunks to move that are surrounded by other used chunks That a freechunk walk won't find.

参数
Stats[out] Stats
StartTimeStart time, used for limiting the Tick() time

◆ PlatformBlockOnFence()

virtual void FGPUDefragAllocator::PlatformBlockOnFence ( uint64  Fence)
protectedpure virtual

Blocks the calling thread until all relocations initiated before the fence was added has been fully completed.

参数
FenceFence to block on

◆ PlatformCanRelocate()

virtual bool FGPUDefragAllocator::PlatformCanRelocate ( const void *  Source,
void *  UserPayload 
) const
protectedpure virtual

Allows each platform to decide whether an allocation can be relocated at this time.

参数
SourceBase address of the allocation
UserPayloadUser payload for the allocation
返回
true if the allocation can be relocated at this time

◆ PlatformInsertFence()

virtual uint64 FGPUDefragAllocator::PlatformInsertFence ( )
protectedpure virtual

Inserts a fence to synchronize relocations.

The fence can be blocked on at a later time to ensure that all relocations initiated so far has been fully completed.

返回
New fence value

◆ PlatformNotifyReallocationFinished()

virtual void FGPUDefragAllocator::PlatformNotifyReallocationFinished ( FAsyncReallocationRequest *  FinishedRequest,
void *  UserPayload 
)
protectedpure virtual

Notifies the platform that an async reallocation request has been completed.

参数
FinishedRequestThe request that got completed
UserPayloadUser payload for the allocation

◆ PlatformRelocate()

virtual void FGPUDefragAllocator::PlatformRelocate ( void *  Dest,
const void *  Source,
int64  Size,
void *  UserPayload 
)
protectedpure virtual

Copy memory from one location to another.

If it returns false, the defragmentation process will assume the memory is not relocatable and keep it in place. Note: Source and destination may overlap.

参数
DestDestination memory start address
SourceSource memory start address
SizeNumber of uint8s to copy
UserPayloadUser payload for this allocation

◆ Reallocate()

void * FGPUDefragAllocator::Reallocate ( void *  OldBaseAddress,
int64  NewSize 
)

Tries to reallocate texture memory in-place (without relocating), by adjusting the base address of the allocation but keeping the end address the same.

Note: Newly freed memory due to shrinking won't be available for allocation right away (need GPU sync).

参数
OldBaseAddressPointer to the original allocation
返回
New base address if it succeeded, otherwise nullptr

◆ Relocate()

void FGPUDefragAllocator::Relocate ( FRelocationStats &  Stats,
FMemoryChunk *  Dest,
int64  DestOffset,
const void *  Source,
int64  Size,
void *  UserPayload 
)
inlineprotected

Copy memory from one location to another.

If it returns false, the defragmentation process will assume the memory is not relocatable and keep it in place. Note: Source and destination may overlap.

参数
Stats[out] Stats
DestDestination memory chunk
DestOffsetDestination offset, counted from the base address of the destination memory chunk, in uint8s
SourceBase address of the source memory
SizeNumber of uint8s to copy
UserPayloadUser payload for the allocation

◆ RelocateIntoFreeChunk()

FMemoryChunk * FGPUDefragAllocator::RelocateIntoFreeChunk ( FRelocationStats &  Stats,
FMemoryChunk *  FreeChunk,
FMemoryChunk *  UsedChunk 
)
protected

Initiates an async relocation of an allocated chunk into a free chunk.

Takes potential reallocation request into account.

参数
Stats[out] Stats
FreeChunkDestination chunk (free memory)
UsedChunkSource chunk (allocated memory)
返回
Next Free chunk to try to fill up

◆ SetSettings()

void FGPUDefragAllocator::SetSettings ( const FSettings &  InSettings)
inline

Sets new allocator settings.

参数
InSettingsNew allocator settings to replace the old ones.

◆ SetUserPayload()

void FGPUDefragAllocator::SetUserPayload ( const void *  Pointer,
void *  UserPayload 
)

Sets the user payload for an FMemoryChunk

参数
PointerPointer indicating a chunk
UserPayloadUser payload to set

◆ Shrink()

FMemoryChunk * FGPUDefragAllocator::Shrink ( FMemoryChunk *  Chunk,
int64  ShrinkAmount 
)
protected

Immediately shrinks a memory chunk by moving the base address, without relocating any memory.

Always succeeds.

参数
ChunkChunk to shrink
ShrinkAmountNumber of uint8s to shrink by
返回
The new shrunken chunk

◆ SortFreeList()

void FGPUDefragAllocator::SortFreeList ( int32 &  NumFreeChunks,
int64 &  LargestFreeChunk 
)
protected

Sorts the freelist based on increasing base address.

参数
NumFreeChunks[out] Number of free chunks
LargestFreeChunk[out] Size of the largest free chunk, in uint8s

◆ Split()

void FGPUDefragAllocator::Split ( FMemoryChunk *  BaseChunk,
int64  FirstSize 
)
inlineprotected

Split allocation into two, first chunk being used and second being available.

Maint32ains the free-list order if bSortedFreeList is true.

参数
BaseChunkChunk to split
FirstSizeNew size of first chunk
bSortedFreeListIf true, maint32ains the free-list order

◆ Tick()

virtual int32 FGPUDefragAllocator::Tick ( FRelocationStats &  Stats,
bool  bPanicDefrag 
)
virtual

Partially defragments the memory and tries to process all async reallocation requests at the same time.

Call this once per frame.

参数
Stats[out] Stats
bPanicDefragIf true, performs a full defrag and ignores all reallocation requests
返回
Num bytes relocated.

◆ Unlock()

virtual void FGPUDefragAllocator::Unlock ( const void *  Pointer)
virtual

Unlocks an FMemoryChunk

参数
PointerPointer indicating which chunk to unlock

类成员变量说明

◆ AllocationAlignment

int32 FGPUDefragAllocator::AllocationAlignment
protected

Allocation alignment requirements.


◆ AvailableMemorySize

volatile memsize_t FGPUDefragAllocator::AvailableMemorySize
protected

Available memory in uint8s.


◆ bBenchmarkMode

bool FGPUDefragAllocator::bBenchmarkMode
protected

When in benchmark mode, don't call any Platform functions.


◆ BlockedCycles

uint32 FGPUDefragAllocator::BlockedCycles
protected

Amount of time blocked by a platform fence since the beginning of the last call to Tick(), in appCycles.


◆ CompletedSyncIndex

uint64 FGPUDefragAllocator::CompletedSyncIndex
protected

Sync index that has been completed, so far.


◆ FirstChunk

FMemoryChunk* FGPUDefragAllocator::FirstChunk
protected

Head of linked list of chunks.

Sorted by memory address.

◆ FirstFreeChunk

FMemoryChunk* FGPUDefragAllocator::FirstFreeChunk
protected

Head of linked list of free chunks.

Unsorted.

◆ LastChunk

FMemoryChunk* FGPUDefragAllocator::LastChunk
protected

Last chunk in the linked list of chunks (see FirstChunk).


◆ MemoryBase

uint8* FGPUDefragAllocator::MemoryBase
protected

Base of memory pool.


◆ MemorySize

uint64 FGPUDefragAllocator::MemorySize
protected

Total size of memory pool, in uint8s.


◆ MinLargestHole

int64 FGPUDefragAllocator::MinLargestHole
protected

Smallest consecutive free memory region we've had.


◆ NumCanceledAsyncRequests

int32 FGPUDefragAllocator::NumCanceledAsyncRequests
protected

Total number of async requests that has been canceled so far.


◆ NumFinishedAsyncAllocations

int32 FGPUDefragAllocator::NumFinishedAsyncAllocations
protected

Total number of async allocations successfully completed so far.


◆ NumFinishedAsyncReallocations

int32 FGPUDefragAllocator::NumFinishedAsyncReallocations
protected

Total number of async reallocations successfully completed so far.


◆ PendingMemoryAdjustment

volatile memsize_t FGPUDefragAllocator::PendingMemoryAdjustment
protected

Adjustment to allocated memory, pending all reallocations.


◆ PointerToChunkMap

TMap<void*, FMemoryChunk*> FGPUDefragAllocator::PointerToChunkMap
protected

Mapping from Pointer to chunk for fast removal.


◆ Settings

FSettings FGPUDefragAllocator::Settings
protected

Allocator settings that affect its behavior.


◆ TimeSpentInAllocator

double FGPUDefragAllocator::TimeSpentInAllocator
protected

Cumulative time spent in allocator.


◆ TotalNumBytesRelocated

uint64 FGPUDefragAllocator::TotalNumBytesRelocated
protected

Total number of uint8s relocated so far.


◆ TotalNumRelocations

uint64 FGPUDefragAllocator::TotalNumRelocations
protected

Total number of relocations performed so far.



该类的文档由以下文件生成: