UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FBulkData Class Reference

#include <BulkData.h>

+ Inheritance diagram for FBulkData:

Public Types

using BulkDataRangeArray = TArray< FBulkData *, TInlineAllocator< 8 > >
 
using FSerializeBulkDataElements = TFunction< void(FArchive &, void *, int64, EBulkDataFlags)>
 

Public Member Functions

 FBulkData ()=default
 
COREUOBJECT_API FBulkData (const FBulkData &Other)
 
COREUOBJECT_API ~FBulkData ()
 
COREUOBJECT_API FBulkDataoperator= (const FBulkData &Other)
 
COREUOBJECT_API int64 GetBulkDataSize () const
 
COREUOBJECT_API int64 GetBulkDataSizeOnDisk () const
 
COREUOBJECT_API int64 GetBulkDataOffsetInFile () const
 
COREUOBJECT_API bool IsStoredCompressedOnDisk () const
 
COREUOBJECT_API bool CanLoadFromDisk () const
 
COREUOBJECT_API bool DoesExist () const
 
COREUOBJECT_API FName GetDecompressionFormat () const
 
COREUOBJECT_API bool IsBulkDataLoaded () const
 
COREUOBJECT_API bool IsAsyncLoadingComplete () const
 
COREUOBJECT_API bool IsAvailableForUse () const
 
bool IsOptional () const
 
bool IsInlined () const
 
bool IsInSeparateFile () const
 
bool IsInExternalResource () const
 
bool IsUsingIODispatcher () const
 
bool IsDataMemoryMapped () const
 
bool IsSingleUse () const
 
bool IsDuplicateNonOptional () const
 
COREUOBJECT_API void SetBulkDataFlags (uint32 BulkDataFlagsToSet)
 
COREUOBJECT_API void ResetBulkDataFlags (uint32 BulkDataFlagsToSet)
 
COREUOBJECT_API uint32 GetBulkDataFlags () const
 
COREUOBJECT_API uint32 GetBulkDataAlignment () const
 
COREUOBJECT_API void ClearBulkDataFlags (uint32 BulkDataFlagsToClear)
 
FIoFilenameHash GetIoFilenameHash () const
 
COREUOBJECT_API FIoChunkId CreateChunkId () const
 
COREUOBJECT_API FString GetDebugName () const
 
COREUOBJECT_API void GetCopy (void **Dest, bool bDiscardInternalCopy=true)
 
COREUOBJECT_API voidLock (uint32 LockFlags)
 
COREUOBJECT_API const voidLockReadOnly () const
 
COREUOBJECT_API voidRealloc (int64 ElementCount, int64 ElementSize)
 
COREUOBJECT_API void Unlock () const
 
bool IsLocked () const
 
bool IsUnlocked () const
 
COREUOBJECT_API void RemoveBulkData ()
 
COREUOBJECT_API void ForceBulkDataResident ()
 
COREUOBJECT_API void StoreCompressedOnDisk (FName CompressionFormat)
 
COREUOBJECT_API bool UnloadBulkData ()
 
COREUOBJECT_API void Serialize (FArchive &Ar, UObject *Owner, bool bAttemptFileMapping, int32 ElementSize, EFileRegionType FileRegionType)
 
void SerializeBulkData (FArchive &Ar, void *Data, EBulkDataFlags InBulkDataFlags)
 
FOwnedBulkDataPtrStealFileMapping ()
 
COREUOBJECT_API void GetBulkDataVersions (FArchive &InlineArchive, FPackageFileVersion &OutUEVersion, int32 &OutLicenseeUEVersion, FCustomVersionContainer &OutCustomVersions) const
 
COREUOBJECT_API IAsyncReadFileHandleOpenAsyncReadHandle () const
 
COREUOBJECT_API IBulkDataIORequestCreateStreamingRequest (EAsyncIOPriorityAndFlags Priority, FBulkDataIORequestCallBack *CompleteCallback, uint8 *UserSuppliedMemory) const
 
COREUOBJECT_API IBulkDataIORequestCreateStreamingRequest (int64 OffsetInBulkData, int64 BytesToRead, EAsyncIOPriorityAndFlags Priority, FBulkDataIORequestCallBack *CompleteCallback, uint8 *UserSuppliedMemory) const
 

Static Public Member Functions

static COREUOBJECT_API void DumpBulkDataUsage (FOutputDevice &Log)
 
static COREUOBJECT_API void SetBulkDataFlagsOn (EBulkDataFlags &InOutAccumulator, EBulkDataFlags FlagsToSet)
 
static COREUOBJECT_API void ClearBulkDataFlagsOn (EBulkDataFlags &InOutAccumulator, EBulkDataFlags FlagsToClear)
 
static COREUOBJECT_API bool HasFlags (EBulkDataFlags Flags, EBulkDataFlags Contains)
 
static COREUOBJECT_API FName GetDecompressionFormat (EBulkDataFlags InFlags)
 

Static Public Attributes

static constexpr SIZE_T MaxBulkDataSize = (1ull << 40) - 1
 

Protected Member Functions

COREUOBJECT_API void SerializeBulkData (FArchive &Ar, void *Data, int64 DataSize, EBulkDataFlags InBulkDataFlags)
 

Friends

class FLinkerLoad
 
class FLinkerSave
 
class FExportArchive
 
class UE::Serialization::FEditorBulkData
 
class FBulkDataBatchRequest
 

Detailed Description

@documentation

Member Typedef Documentation

◆ BulkDataRangeArray

◆ FSerializeBulkDataElements

Constructor & Destructor Documentation

◆ FBulkData() [1/2]

FBulkData::FBulkData ( )
default

Constructor, initializing all member variables.

◆ FBulkData() [2/2]

FBulkData::FBulkData ( const FBulkData Other)

Copy constructor. Use the common routine to perform the copy.

Parameters
Otherthe source array to copy

◆ ~FBulkData()

FBulkData::~FBulkData ( )

Virtual destructor, free'ing allocated memory.

Member Function Documentation

◆ CanLoadFromDisk()

bool FBulkData::CanLoadFromDisk ( ) const

Returns true if the data can be loaded from disk.

◆ ClearBulkDataFlags()

void FBulkData::ClearBulkDataFlags ( uint32  BulkDataFlagsToClear)

Clears the passed in bulk data flags.

Parameters
BulkDataFlagsToClearBulk data flags to clear

◆ ClearBulkDataFlagsOn()

void FBulkData::ClearBulkDataFlagsOn ( EBulkDataFlags InOutAccumulator,
EBulkDataFlags  FlagsToClear 
)
static

Disable the given flags in the given accumulator variable.

◆ CreateChunkId()

FIoChunkId FBulkData::CreateChunkId ( ) const

Returns a FIoChunkId for the bulkdata payload, this will be invalid if the bulkdata is not stored in the IoStore

◆ CreateStreamingRequest() [1/2]

IBulkDataIORequest * FBulkData::CreateStreamingRequest ( EAsyncIOPriorityAndFlags  Priority,
FBulkDataIORequestCallBack CompleteCallback,
uint8 UserSuppliedMemory 
) const

Create an async read request for the bulk data. This version will load the entire data range that the FBulkData represents.

Parameters
PriorityPriority and flags of the request. If this includes AIOP_FLAG_PRECACHE, then memory will never be returned. The request should always be canceled and waited for, even for a precache request.
CompleteCallbackCalled from an arbitrary thread when the request is complete. Can be nullptr, if non-null, must remain valid until it is called. It will always be called.
UserSuppliedMemoryA pointer to memory for the IO request to be written to, it is up to the caller to make sure that it is large enough. If the pointer is null then the system will allocate memory instead.
Returns
A request for the read. This is owned by the caller and must be deleted by the caller.

◆ CreateStreamingRequest() [2/2]

IBulkDataIORequest * FBulkData::CreateStreamingRequest ( int64  OffsetInBulkData,
int64  BytesToRead,
EAsyncIOPriorityAndFlags  Priority,
FBulkDataIORequestCallBack CompleteCallback,
uint8 UserSuppliedMemory 
) const

Create an async read request for the bulk data. This version allows the user to request a subset of the data that the FBulkData represents.

Parameters
OffsetInBulkDataOffset into the bulk data to start reading from.
BytesToReadThe number of bytes to read. If this request is AIOP_Preache, the size can be anything, even MAX_int64, otherwise the size and offset must be fully contained in the file.
PriorityPriority and flags of the request. If this includes AIOP_FLAG_PRECACHE, then memory will never be returned. The request should always be canceled and waited for, even for a precache request.
CompleteCallbackCalled from an arbitrary thread when the request is complete. Can be nullptr, if non-null, must remain valid until it is called. It will always be called.
UserSuppliedMemoryA pointer to memory for the IO request to be written to, it is up to the caller to make sure that it is large enough. If the pointer is null then the system will allocate memory instead.
Returns
A request for the read. This is owned by the caller and must be deleted by the caller.

◆ DoesExist()

bool FBulkData::DoesExist ( ) const

Returns true if the data references a file that currently exists and can be referenced by the file system.

◆ DumpBulkDataUsage()

void FBulkData::DumpBulkDataUsage ( FOutputDevice Log)
static

Dumps detailed information of bulk data usage.

Parameters
LogFOutputDevice to use for logging

◆ ForceBulkDataResident()

void FBulkData::ForceBulkDataResident ( )

Forces the bulk data to be resident in memory and detaches the archive.

◆ GetBulkDataAlignment()

uint32 FBulkData::GetBulkDataAlignment ( ) const

Gets the current bulk data alignment.

Returns
Bulk data alignment currently set

◆ GetBulkDataFlags()

uint32 FBulkData::GetBulkDataFlags ( ) const

Gets the current bulk data flags.

Returns
Bulk data flags currently set

◆ GetBulkDataOffsetInFile()

int64 FBulkData::GetBulkDataOffsetInFile ( ) const

Returns the offset into the file the bulk data is located at.

Returns
Offset into the file or INDEX_NONE in case there is no association

◆ GetBulkDataSize()

int64 FBulkData::GetBulkDataSize ( ) const

Returns the size of the bulk data in bytes.

Returns
Size of the bulk data in bytes

◆ GetBulkDataSizeOnDisk()

int64 FBulkData::GetBulkDataSizeOnDisk ( ) const

Returns the size of the bulk data on disk. This can differ from GetBulkDataSize if BULKDATA_SerializeCompressed is set.

Returns
Size of the bulk data on disk or INDEX_NONE in case there's no association

◆ GetBulkDataVersions()

void FBulkData::GetBulkDataVersions ( FArchive InlineArchive,
FPackageFileVersion OutUEVersion,
int32 OutLicenseeUEVersion,
FCustomVersionContainer OutCustomVersions 
) const

Get the CustomVersions used in the file containing the BulkData payload. If !IsInSeparateFile, this will be the custom versions from the archive used to serialize the FBulkData, which the caller must provide. Otherwise, the CustomVersions come from the separate file and this function will look them up.

Parameters
InlineArchiveThe archive that was used to load this object

◆ GetCopy()

void FBulkData::GetCopy ( void **  Dest,
bool  bDiscardInternalCopy = true 
)

Retrieves a copy of the bulk data.

Parameters
Dest[in/out] Pointer to pointer going to hold copy, can point to NULL pointer in which case memory is allocated
bDiscardInternalCopyWhether to discard/ free the potentially internally allocated copy of the data

◆ GetDebugName()

FString FBulkData::GetDebugName ( ) const

Returns a string representing the bulk data for debugging purposes.

◆ GetDecompressionFormat() [1/2]

FName FBulkData::GetDecompressionFormat ( ) const

Returns flags usable to decompress the bulk data

Returns
NAME_None if the data was not compressed on disk, or valid format to pass to FCompression::UncompressMemory for this data

Returns flags usable to decompress the bulk data

Returns
COMPRESS_NONE if the data was not compressed on disk, or valid flags to pass to FCompression::UncompressMemory for this data

◆ GetDecompressionFormat() [2/2]

FName FBulkData::GetDecompressionFormat ( EBulkDataFlags  InFlags)
static

Returns decompress method flags specified by the given bulk data flags.

◆ GetIoFilenameHash()

FIoFilenameHash FBulkData::GetIoFilenameHash ( ) const
inline

Returns the io filename hash associated with this bulk data.

Returns
Hash or INVALID_IO_FILENAME_HASH if invalid.

◆ HasFlags()

bool FBulkData::HasFlags ( EBulkDataFlags  Flags,
EBulkDataFlags  Contains 
)
static

Returns whether all of the specified flags are set.

◆ IsAsyncLoadingComplete()

bool FBulkData::IsAsyncLoadingComplete ( ) const

Deprecated

Returns
As of 5.5 this will always return true as StartAsyncLoading was removed

◆ IsAvailableForUse()

bool FBulkData::IsAvailableForUse ( ) const

Returns whether this bulk data is used

Returns
true if BULKDATA_Unused is not set

◆ IsBulkDataLoaded()

bool FBulkData::IsBulkDataLoaded ( ) const

Returns whether the bulk data is currently loaded and resident in memory.

Returns
true if bulk data is loaded, false otherwise

◆ IsDataMemoryMapped()

bool FBulkData::IsDataMemoryMapped ( ) const
inline

Returns whether this bulk data is memory mapped or not.

◆ IsDuplicateNonOptional()

bool FBulkData::IsDuplicateNonOptional ( ) const
inline

Returns whether this bulk data represents duplicate non-optional data or not

Returns
true if BULKDATA_DuplicateNonOptionalPayload is set

◆ IsInExternalResource()

bool FBulkData::IsInExternalResource ( ) const
inline

Returns whether this bulk data is stored in a PackageExternalResource rather than in a neighboring segment of its owner's PackagePath.

◆ IsInlined()

bool FBulkData::IsInlined ( ) const
inline

Returns whether this bulk data is currently stored inline or not

Returns
true if BULKDATA_PayloadAtEndOfFile is not set

◆ IsInSeparateFile()

bool FBulkData::IsInSeparateFile ( ) const
inline

Returns whether this bulk data is currently stored in it's own file or not

Returns
true if BULKDATA_PayloadInSeparateFile is set

◆ IsLocked()

bool FBulkData::IsLocked ( ) const
inline

Checks if this bulk is locked

◆ IsOptional()

bool FBulkData::IsOptional ( ) const
inline

Returns whether this bulk data represents optional data or not

Returns
true if BULKDATA_OptionalPayload is set

◆ IsSingleUse()

bool FBulkData::IsSingleUse ( ) const
inline

Returns whether to deallocate the bulk data after lock

◆ IsStoredCompressedOnDisk()

bool FBulkData::IsStoredCompressedOnDisk ( ) const

Returns whether the bulk data is stored compressed on disk.

Returns
true if data is compressed on disk, false otherwise

◆ IsUnlocked()

bool FBulkData::IsUnlocked ( ) const
inline

Checks if this bulk is unlocked

◆ IsUsingIODispatcher()

bool FBulkData::IsUsingIODispatcher ( ) const
inline

Returns whether this bulk data is accessed via the IoDispatcher or not.

Returns
false as the old BulkData API does not support it

◆ Lock()

void * FBulkData::Lock ( uint32  LockFlags)

Locks the bulk data and returns a pointer to it.

Parameters
LockFlagsFlags determining lock behavior

◆ LockReadOnly()

const void * FBulkData::LockReadOnly ( ) const

Locks the bulk data and returns a read-only pointer to it. This variant can be called on a const bulkdata

◆ OpenAsyncReadHandle()

IAsyncReadFileHandle * FBulkData::OpenAsyncReadHandle ( ) const

Opens a new IAsyncReadFileHandle that references the file that the BulkData object represents.

Returns
A valid handle if the file can be accessed, if it cannot then nullptr.

◆ operator=()

FBulkData & FBulkData::operator= ( const FBulkData Other)

Copies the source array into this one after detaching from archive.

Parameters
Otherthe source array to copy

◆ Realloc()

void * FBulkData::Realloc ( int64  ElementCount,
int64  ElementSize 
)

Change size of locked bulk data. Only valid if locked via read-write lock.

Parameters
ElementCountNumber of elements to allocate.
ElementSizeSize in bytes of the individual element.

WITH_EDITOR

◆ RemoveBulkData()

void FBulkData::RemoveBulkData ( )

Clears/removes any currently allocated data payload and resets element count to 0.

Note that once this has been called, the bulkdata object will no longer be able to reload it's payload from disk!

Clears/ removes the bulk data and resets element count to 0.

◆ ResetBulkDataFlags()

void FBulkData::ResetBulkDataFlags ( uint32  BulkDataFlagsToSet)

Enable the given flags and disable all other flags. This can be used with GetBulkDataFlags() to effectively reset the flags to a previous state.

Parameters
BulkDataFlagsToSetBulk data flags to set

◆ Serialize()

void FBulkData::Serialize ( FArchive Ar,
UObject Owner,
bool  bAttemptFileMapping,
int32  ElementSize,
EFileRegionType  FileRegionType 
)

Serialize function used to serialize this bulk data structure.

Parameters
ArArchive to serialize with
OwnerObject owning the bulk data
IdxIndex of bulk data item being serialized
bAttemptFileMappingIf true, attempt to map this instead of loading it into malloc'ed memory
FileRegionTypeWhen cooking, a hint describing the type of data, used by some platforms to improve compression ratios

WITH_EDITOR

◆ SerializeBulkData() [1/2]

void FBulkData::SerializeBulkData ( FArchive Ar,
void Data,
EBulkDataFlags  InBulkDataFlags 
)
inline

Serialize just the bulk data portion to/ from the passed in memory.

Parameters
ArArchive to serialize with
DataMemory to serialize either to or from
InBulkDataFlagsFlags describing how the data was/shouldbe serialized

◆ SerializeBulkData() [2/2]

void FBulkData::SerializeBulkData ( FArchive Ar,
void Data,
int64  DataSize,
EBulkDataFlags  InBulkDataFlags 
)
protected

◆ SetBulkDataFlags()

void FBulkData::SetBulkDataFlags ( uint32  BulkDataFlagsToSet)

Enables the given flags without affecting any previously set flags.

Parameters
BulkDataFlagsToSetBulk data flags to set

Sets the passed in bulk data flags.

Parameters
BulkDataFlagsToSetBulk data flags to set

◆ SetBulkDataFlagsOn()

void FBulkData::SetBulkDataFlagsOn ( EBulkDataFlags InOutAccumulator,
EBulkDataFlags  FlagsToSet 
)
static

Enable the given flags in the given accumulator variable.

◆ StealFileMapping()

FOwnedBulkDataPtr * FBulkData::StealFileMapping ( )
inline

◆ StoreCompressedOnDisk()

void FBulkData::StoreCompressedOnDisk ( FName  CompressionFormat)

Sets whether we should store the data compressed on disk.

Parameters
CompressionFormatThe format to use for compression e.g. NAME_None or NAME_Oodle.

This should likely not be used - bulk data that gets deployed should be compressed via UnrealPak so that it can leverage hardware compression as available, and editor bulk data is compressed by default and should use FEditorBulkData::SetCompressionOptions to control that if necessary.

◆ UnloadBulkData()

bool FBulkData::UnloadBulkData ( )

Deallocates bulk data without detaching the archive, so that further bulk data accesses require a reload. Only supported in editor builds.

Returns
Whether the operation succeeded.

Deallocates bulk data without detaching the archive.

◆ Unlock()

void FBulkData::Unlock ( ) const

Unlocks bulk data after which point the pointer returned by Lock no longer is valid.

Friends And Related Symbol Documentation

◆ FBulkDataBatchRequest

◆ FExportArchive

friend class FExportArchive
friend

◆ FLinkerLoad

friend class FLinkerLoad
friend

◆ FLinkerSave

friend class FLinkerSave
friend

◆ UE::Serialization::FEditorBulkData

Member Data Documentation

◆ MaxBulkDataSize

constexpr SIZE_T FBulkData::MaxBulkDataSize = (1ull << 40) - 1
staticconstexpr

The documentation for this class was generated from the following files: