UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AsyncLoading2.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 AsyncLoading2.h: Unreal async loading #2 definitions.
5=============================================================================*/
6
7#pragma once
8
9#include "Containers/Array.h"
12#include "CoreMinimal.h"
13#include "CoreTypes.h"
14#include "IO/PackageId.h"
20#include "Templates/TypeHash.h"
21#include "UObject/NameTypes.h"
25#if WITH_VERSE_VM || defined(__INTELLISENSE__)
27#endif
28
29class FArchive;
30class FIoDispatcher;
33class UPackage;
34
36{
37public:
43
45 {
46 return ImportedPackageIndex;
47 }
48
50 {
51 return ImportedPublicExportHashIndex;
52 }
53
54private:
55 uint32 ImportedPackageIndex;
56 uint32 ImportedPublicExportHashIndex;
57};
58
60{
61 static constexpr uint64 IndexBits = 62ull;
62 static constexpr uint64 IndexMask = (1ull << IndexBits) - 1ull;
63 static constexpr uint64 TypeMask = ~IndexMask;
64 static constexpr uint64 TypeShift = IndexBits;
65 static constexpr uint64 Invalid = ~0ull;
66
67 uint64 TypeAndId = Invalid;
68
69 enum EType
70 {
71 Export,
72 ScriptImport,
73 PackageImport,
74 Null,
75 TypeCount = Null,
76 };
77 static_assert((TypeCount - 1) <= (TypeMask >> TypeShift), "FPackageObjectIndex: Too many types for TypeMask");
78
79 inline explicit FPackageObjectIndex(EType InType, uint64 InId) : TypeAndId((uint64(InType) << TypeShift) | InId) {}
80
81 COREUOBJECT_API static uint64 GenerateImportHashFromObjectPath(const FStringView& ObjectPath);
82 COREUOBJECT_API static uint64 GenerateImportHashFromVersePath(FUtf8StringView VersePath);
83
84public:
86
88 {
89 return FPackageObjectIndex(Export, Index);
90 }
91
93 {
94 return FPackageObjectIndex(ScriptImport, GenerateImportHashFromObjectPath(ScriptObjectPath));
95 }
96
97#if WITH_VERSE_VM || defined(__INTELLISENSE__)
98 inline static FPackageObjectIndex FromVersePath(Verse::VUniqueString* VersePath)
99 {
100 return FromVersePath(VersePath->AsStringView());
101 }
102#endif
104 {
105 return FPackageObjectIndex(ScriptImport, GenerateImportHashFromVersePath(VersePath));
106 }
107
109 {
110 uint64 Id = static_cast<uint64>(PackageImportRef.GetImportedPackageIndex()) << 32 | PackageImportRef.GetImportedPublicExportHashIndex();
111 check(!(Id & TypeMask));
112 return FPackageObjectIndex(PackageImport, Id);
113 }
114
115 inline bool IsNull() const
116 {
117 return TypeAndId == Invalid;
118 }
119
120 inline bool IsExport() const
121 {
122 return (TypeAndId >> TypeShift) == Export;
123 }
124
125 inline bool IsImport() const
126 {
127 return IsScriptImport() || IsPackageImport();
128 }
129
130 inline bool IsScriptImport() const
131 {
132 return (TypeAndId >> TypeShift) == ScriptImport;
133 }
134
135 inline bool IsPackageImport() const
136 {
137 return (TypeAndId >> TypeShift) == PackageImport;
138 }
139
140 inline uint32 ToExport() const
141 {
142 check(IsExport());
143 return uint32(TypeAndId);
144 }
145
147 {
148 uint32 ImportedPackageIndex = static_cast<uint32>((TypeAndId & IndexMask) >> 32);
149 uint32 ExportHash = static_cast<uint32>(TypeAndId);
150 return FPackageImportReference(ImportedPackageIndex, ExportHash);
151 }
152
153 inline uint64 Value() const
154 {
155 return TypeAndId & IndexMask;
156 }
157
159 {
160 return TypeAndId == Other.TypeAndId;
161 }
162
164 {
165 return TypeAndId != Other.TypeAndId;
166 }
167
169 {
170 Ar << Value.TypeAndId;
171 return Ar;
172 }
173
175 {
176 return uint32(Value.TypeAndId);
177 }
178};
179
181{
182public:
184 {
185 }
186
187 bool IsNull() const
188 {
189 return GetExportHash() == 0;
190 }
191
193 {
194 return FPackageId::FromValue(uint64(PackageIdHigh) << 32 | PackageIdLow);
195 }
196
198 {
199 return uint64(ExportHashHigh) << 32 | ExportHashLow;
200 }
201
202 inline bool operator==(const FPublicExportKey& Other) const
203 {
204 return GetExportHash() == Other.GetExportHash() &&
205 GetPackageId() == Other.GetPackageId();
206 }
207
208 inline bool operator!=(const FPublicExportKey& Other) const
209 {
210 return GetExportHash() != Other.GetExportHash() ||
211 GetPackageId() != Other.GetPackageId();
212 }
213
214 inline friend uint32 GetTypeHash(const FPublicExportKey& In)
215 {
217 }
218
219 static FPublicExportKey MakeKey(FPackageId PackageId, uint64 ExportHash)
220 {
221 check(PackageId.IsValid());
222 check(ExportHash);
223 uint64 PackageIdValue = PackageId.Value();
224 return FPublicExportKey(uint32(PackageIdValue >> 32), uint32(PackageIdValue), uint32(ExportHash >> 32), uint32(ExportHash));
225 }
226
227 static FPublicExportKey FromPackageImport(FPackageObjectIndex ObjectIndex, const TArrayView<const FPackageId>& ImportedPackageIds, const TArrayView<const uint64>& ImportedPublicExportHashes)
228 {
229 check(ObjectIndex.IsPackageImport());
231 FPackageId PackageId = ImportedPackageIds[PackageImportRef.GetImportedPackageIndex()];
232 uint64 ExportHash = ImportedPublicExportHashes[PackageImportRef.GetImportedPublicExportHashIndex()];
233 return MakeKey(PackageId, ExportHash);
234 }
235
236private:
238 : PackageIdHigh(InPackageIdHigh)
239 , PackageIdLow(InPackageIdLow)
240 , ExportHashHigh(InExportHashHigh)
241 , ExportHashLow(InExportHashLow)
242 {
243 }
244
245 uint32 PackageIdHigh = 0;
246 uint32 PackageIdLow = 0;
247 uint32 ExportHashHigh = 0;
248 uint32 ExportHashLow = 0;
249};
250
255{
256 None,
259};
261{
262 switch (Flags)
263 {
264 case EExportFilterFlags::NotForServer: return TEXT("NotForServer");
265 case EExportFilterFlags::NotForClient: return TEXT("NotForClient");
266 case EExportFilterFlags::None: return TEXT("None");
267 default: checkNoEntry();
268 }
269 return TEXT("");
270}
271
282
292
299
318
324
341
348
356
372// The sizeof FMinimalName may be variable but FMappedName should always be larger, so FScriptObjectEntry has a fixed size.
373static_assert(sizeof(FMappedName) >= sizeof(FMinimalName));
374
404
416
417// If we change the size of FBulkDataCookedIndex we will need to update FBulkDataMapEntry
418static_assert(sizeof(FBulkDataCookedIndex) == sizeof(uint8));
419
420// We don't want to grow the size of FBulkDataMapEntry accidently
421static_assert(sizeof(FBulkDataMapEntry) <= 32, "The memory layout of FBulkDataMapEntry now exceeds 32 bytes, was this intended?");
422
429
#define check(expr)
Definition AssertionMacros.h:314
#define checkNoEntry()
Definition AssertionMacros.h:316
EZenPackageVersion
Definition AsyncLoading2.h:273
EExportFilterFlags
Definition AsyncLoading2.h:255
COREUOBJECT_API void FindAllRuntimeScriptPackages(FRuntimeScriptPackages &OutPackages)
Definition AsyncLoading2.cpp:288
IAsyncPackageLoader * MakeAsyncPackageLoader2(FIoDispatcher &InIoDispatcher)
Definition AsyncLoading2.cpp:12316
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const TCHAR * LexToString(EAnalyticsRecordEventMode Mode)
Definition IAnalyticsProvider.cpp:5
EObjectFlags
Definition ObjectMacros.h:552
@ RF_NoFlags
No flags, used to avoid a cast.
Definition ObjectMacros.h:555
constexpr uint32 HashCombine(uint32 A, uint32 C)
Definition TypeHash.h:36
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
Definition BulkDataCookedIndex.h:34
Definition CustomVersion.h:111
Definition IoDispatcher.h:350
Definition MappedName.h:22
Definition PackageId.h:19
static FPackageId FromValue(const uint64 Value)
Definition PackageId.h:30
uint64 Value() const
Definition PackageId.h:40
bool IsValid() const
Definition PackageId.h:35
Definition AsyncLoading2.h:36
FPackageImportReference(uint32 InImportedPackageIndex, uint32 InImportedPublicExportHashIndex)
Definition AsyncLoading2.h:38
uint32 GetImportedPublicExportHashIndex() const
Definition AsyncLoading2.h:49
uint32 GetImportedPackageIndex() const
Definition AsyncLoading2.h:44
Definition ObjectResource.h:44
Definition AsyncLoading2.h:60
bool operator!=(FPackageObjectIndex Other) const
Definition AsyncLoading2.h:163
FPackageObjectIndex()=default
static FPackageObjectIndex FromExportIndex(const int32 Index)
Definition AsyncLoading2.h:87
friend uint32 GetTypeHash(const FPackageObjectIndex &Value)
Definition AsyncLoading2.h:174
bool IsPackageImport() const
Definition AsyncLoading2.h:135
bool IsNull() const
Definition AsyncLoading2.h:115
bool IsImport() const
Definition AsyncLoading2.h:125
static FPackageObjectIndex FromVersePath(FUtf8StringView VersePath)
Definition AsyncLoading2.h:103
static FPackageObjectIndex FromScriptPath(const FStringView &ScriptObjectPath)
Definition AsyncLoading2.h:92
bool operator==(FPackageObjectIndex Other) const
Definition AsyncLoading2.h:158
static FPackageObjectIndex FromPackageImportRef(const FPackageImportReference &PackageImportRef)
Definition AsyncLoading2.h:108
bool IsExport() const
Definition AsyncLoading2.h:120
bool IsScriptImport() const
Definition AsyncLoading2.h:130
friend FArchive & operator<<(FArchive &Ar, FPackageObjectIndex &Value)
Definition AsyncLoading2.h:168
FPackageImportReference ToPackageImportRef() const
Definition AsyncLoading2.h:146
uint64 Value() const
Definition AsyncLoading2.h:153
uint32 ToExport() const
Definition AsyncLoading2.h:140
Definition AsyncLoading2.h:181
bool operator!=(const FPublicExportKey &Other) const
Definition AsyncLoading2.h:208
bool IsNull() const
Definition AsyncLoading2.h:187
static FPublicExportKey FromPackageImport(FPackageObjectIndex ObjectIndex, const TArrayView< const FPackageId > &ImportedPackageIds, const TArrayView< const uint64 > &ImportedPublicExportHashes)
Definition AsyncLoading2.h:227
friend uint32 GetTypeHash(const FPublicExportKey &In)
Definition AsyncLoading2.h:214
FPublicExportKey()
Definition AsyncLoading2.h:183
uint64 GetExportHash() const
Definition AsyncLoading2.h:197
FPackageId GetPackageId() const
Definition AsyncLoading2.h:192
bool operator==(const FPublicExportKey &Other) const
Definition AsyncLoading2.h:202
static FPublicExportKey MakeKey(FPackageId PackageId, uint64 ExportHash)
Definition AsyncLoading2.h:219
Definition AsyncPackageLoader.h:88
Definition ArrayView.h:139
Definition Array.h:670
Definition Package.h:216
U16 Index
Definition radfft.cpp:71
Definition AsyncLoading2.h:406
int64 SerialOffset
Definition AsyncLoading2.h:407
int64 SerialSize
Definition AsyncLoading2.h:409
COREUOBJECT_API friend FArchive & operator<<(FArchive &Ar, FBulkDataMapEntry &BulkDataEntry)
Definition AsyncLoading2.cpp:248
uint32 Flags
Definition AsyncLoading2.h:410
FBulkDataCookedIndex CookedIndex
Definition AsyncLoading2.h:411
int64 DuplicateSerialOffset
Definition AsyncLoading2.h:408
uint8 Pad[3]
Definition AsyncLoading2.h:412
Definition AsyncLoading2.h:395
uint64 CookedSerialOffset
Definition AsyncLoading2.h:396
FMappedName CppClassInfo
Definition AsyncLoading2.h:399
uint64 CookedSerialLayoutSize
Definition AsyncLoading2.h:397
COREUOBJECT_API friend FArchive & operator<<(FArchive &Ar, FCellExportMapEntry &CellExportMapEntry)
Definition AsyncLoading2.cpp:237
uint64 PublicExportHash
Definition AsyncLoading2.h:400
uint64 CookedSerialSize
Definition AsyncLoading2.h:398
Definition AsyncLoading2.h:343
FPackageIndex LocalImportOrExportIndex
Definition AsyncLoading2.h:344
COREUOBJECT_API friend FArchive & operator<<(FArchive &Ar, FDependencyBundleEntry &DependencyBundleEntry)
Definition AsyncLoading2.cpp:175
Definition AsyncLoading2.h:350
int32 FirstEntryIndex
Definition AsyncLoading2.h:351
COREUOBJECT_API friend FArchive & operator<<(FArchive &Ar, FDependencyBundleHeader &DependencyBundleHeader)
Definition AsyncLoading2.cpp:182
uint32 EntryCount[FExportBundleEntry::ExportCommandType_Count][FExportBundleEntry::ExportCommandType_Count]
Definition AsyncLoading2.h:352
Definition AsyncLoading2.h:329
EExportCommandType
Definition AsyncLoading2.h:331
@ ExportCommandType_Serialize
Definition AsyncLoading2.h:333
@ ExportCommandType_Count
Definition AsyncLoading2.h:334
@ ExportCommandType_Create
Definition AsyncLoading2.h:332
uint32 LocalExportIndex
Definition AsyncLoading2.h:336
COREUOBJECT_API friend FArchive & operator<<(FArchive &Ar, FExportBundleEntry &ExportBundleEntry)
Definition AsyncLoading2.cpp:167
uint32 CommandType
Definition AsyncLoading2.h:337
Definition AsyncLoading2.h:379
FPackageObjectIndex OuterIndex
Definition AsyncLoading2.h:383
FPackageObjectIndex ClassIndex
Definition AsyncLoading2.h:384
uint64 CookedSerialOffset
Definition AsyncLoading2.h:380
EExportFilterFlags FilterFlags
Definition AsyncLoading2.h:389
COREUOBJECT_API friend FArchive & operator<<(FArchive &Ar, FExportMapEntry &ExportMapEntry)
Definition AsyncLoading2.cpp:205
uint8 Pad[3]
Definition AsyncLoading2.h:390
uint64 PublicExportHash
Definition AsyncLoading2.h:387
FMappedName ObjectName
Definition AsyncLoading2.h:382
uint64 CookedSerialSize
Definition AsyncLoading2.h:381
FPackageObjectIndex TemplateIndex
Definition AsyncLoading2.h:386
EObjectFlags ObjectFlags
Definition AsyncLoading2.h:388
FPackageObjectIndex SuperIndex
Definition AsyncLoading2.h:385
Definition NameTypes.h:439
Definition ObjectVersion.h:762
Definition AsyncLoading2.h:424
TArray< UPackage * > Script
Definition AsyncLoading2.h:425
TArray< UPackage * > VerseVNI
Definition AsyncLoading2.h:426
Definition AsyncLoading2.h:358
FMappedName Mapped
Definition AsyncLoading2.h:361
FPackageObjectIndex GlobalIndex
Definition AsyncLoading2.h:364
FPackageObjectIndex OuterIndex
Definition AsyncLoading2.h:365
COREUOBJECT_API friend FArchive & operator<<(FArchive &Ar, FScriptObjectEntry &ScriptObjectEntry)
Definition AsyncLoading2.cpp:196
FPackageObjectIndex CDOClassIndex
Definition AsyncLoading2.h:366
FScriptObjectEntry()
Definition AsyncLoading2.h:368
FMinimalName ObjectName
Definition AsyncLoading2.h:362
Definition AsyncLoading2.h:320
int32 CellExportMapOffset
Definition AsyncLoading2.h:322
int32 CellImportMapOffset
Definition AsyncLoading2.h:321
Definition AsyncLoading2.h:294
COREUOBJECT_API friend FArchive & operator<<(FArchive &Ar, FZenPackageImportedPackageNamesContainer &Container)
Definition AsyncLoading2.cpp:131
TArray< FName > Names
Definition AsyncLoading2.h:295
Definition AsyncLoading2.h:304
uint32 HeaderSize
Definition AsyncLoading2.h:306
int32 ImportedPackageNamesOffset
Definition AsyncLoading2.h:316
int32 ImportMapOffset
Definition AsyncLoading2.h:311
uint32 bHasVersioningInfo
Definition AsyncLoading2.h:305
int32 ExportMapOffset
Definition AsyncLoading2.h:312
int32 ExportBundleEntriesOffset
Definition AsyncLoading2.h:313
uint32 PackageFlags
Definition AsyncLoading2.h:308
FMappedName Name
Definition AsyncLoading2.h:307
int32 ImportedPublicExportHashesOffset
Definition AsyncLoading2.h:310
int32 DependencyBundleEntriesOffset
Definition AsyncLoading2.h:315
uint32 _Unused
Definition AsyncLoading2.h:309
int32 DependencyBundleHeadersOffset
Definition AsyncLoading2.h:314
Definition AsyncLoading2.h:284
FCustomVersionContainer CustomVersions
Definition AsyncLoading2.h:288
COREUOBJECT_API friend FArchive & operator<<(FArchive &Ar, FZenPackageVersioningInfo &ExportBundleEntry)
Definition AsyncLoading2.cpp:122
EZenPackageVersion ZenVersion
Definition AsyncLoading2.h:285
int32 LicenseeVersion
Definition AsyncLoading2.h:287
FPackageFileVersion PackageVersion
Definition AsyncLoading2.h:286