UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PackageStore.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
7#include "CoreMinimal.h"
8#include "CoreTypes.h"
10#include "HAL/PlatformCrt.h"
11#include "Misc/EnumClassFlags.h"
12#include "Misc/PackagePath.h"
13#include "Misc/SecureHash.h"
14#include "IO/PackageId.h"
16#include "UObject/NameTypes.h"
17
18class FArchive;
19class FCbObjectView;
20class FCbWriter;
22
27{
28 Unknown = 0x0, // Indicates the package was loaded from somewhere outside of the loader
29 LinkerLoad = 0x1,
30 Zen = 0x2,
31};
33
38{
39 None,
40 Missing,
42 Pending,
43 Ok,
44};
45
50{
51#if WITH_EDITORONLY_DATA
52 // the corrected package name, which may be a different case than PackageName that's passed in to GetPackageStoreEntry
53 // only applies to LinkerLoad (loose on the local filesystem) zen packages are never submitted to source control
55#endif
56
57 // for LinkerLoad entries, this will contain the extension of the package. for Zen entries, this will stay Unspecified
59
60 // default to IoDispatcher, since almost all package store entries will use it
62
65#if WITH_EDITOR
66 TArrayView<const FPackageId> OptionalSegmentImportedPackageIds;
67 bool bHasOptionalSegment = false;
68 // This field is used to indicate that the package should load the optional chunk instead of the regular chunk. This is
69 // needed by the StorageServerPackgeStore (ie ZenStore) when loading "AutoOptional" assets, but the FilePackageStore
70 // (ie .ucas files) does _not_ set this. This is because:
71 // * AutoOptional is used to "silently" replace the normal asset with an asset that still has editor-only data in it
72 // * When .ucas files are made, they create a .o.ucas file, which is mounted with a higher priority then the .ucas file
73 // * When FilePackageStore loads, it will automatically read the editor-only version of the asset, _as if it was the normal asset_
74 // * However, ZenStore has no ".o.ucas" file to silently read from instead of the regular file, so it must, at runtime,
75 // request the editor version of the asset (the .o.uasset chunk in the store).
76 // This field is how we communicate out to the AsyncLoadingThread code that it should request the optional chunk instead of the
77 // regular chunk for a given asset. It is basically making a runtime decision that is handled offline by ucas files.
78 // Note that bHasOptionalSegment is always false for AutoOptional because of the "silently read optional as regular".
79 // So to sum up for the two main PackageStores:
80 // ZenStore:
81 // Manual Optional
82 // bHasOptionalSegment = true
83 // bReplaceChunkWithOptional = false
84 // AutoOptional
85 // bHasOptionalSegment = false
86 // bReplaceChunkWithOptional = true
87 // FileStore
88 // Manual Optional(same as Zen)
89 // bHasOptionalSegment = true
90 // bReplaceChunkWithOptional = false
91 // AutoOptional (_not_ same)
92 // bHasOptionalSegment = false
93 // bReplaceChunkWithOptional = false
94 bool bReplaceChunkWithOptional = false;
95#endif
96};
97
103{
104 None = 0,
105 HasPackageData = 0x00000001,
106 AutoOptional = 0x00000002,
107 OptionalSegment = 0x00000004,
108 HasCookError = 0x00000008,
109 LoadUncooked = 0x00000010, // This package must be loaded uncooked, when possibe, when loading from IoStore / ZenStore (i.e. HybridCookedEditor)
110};
112
176
178{
179public:
180 /* Event broadcasted when pending entries are completed and added to the package store */
183};
184
189{
190public:
191 /* Destructor. */
193
196 {
197 return EPackageLoader::Zen;
198 }
199
202
204 virtual void BeginRead() = 0;
205
207 virtual void EndRead() = 0;
208
209 /* Returns the package store entry data with export info and imported packages for the specified package ID. */
212
213 /* Returns the redirected package ID and source package name for the specified package ID if it's being redirected. */
215
216 /* Returns all soft referenced package IDs for the specified package ID. */
221};
222
227{
228public:
230
231 /* Mount a package store backend. */
233
234 /* Returns the package store entry data with export info and imported packages for the specified package ID. */
237
238 /* Returns the redirected package ID and source package name for the specified package ID if it's being redirected. */
240
241 /* Returns all soft referenced package IDs for the specified package ID. */
243
244 COREUOBJECT_API FPackageStoreBackendContext::FPendingEntriesAddedEvent& OnPendingEntriesAdded();
245
247
248private:
250
252
254
257
258 TSharedPtr<IPackageStoreBackend> LinkerLoadBackend;
259#if WITH_EDITOR
261#endif
262
263 static thread_local int32 ThreadReadCount;
264};
265
275
276
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
constexpr bool EnumHasAnyFlags(Enum Flags, Enum Contains)
Definition EnumClassFlags.h:35
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
EPackageStoreEntryFlags
Definition PackageStore.h:103
EPackageStoreEntryStatus
Definition PackageStore.h:38
EPackageLoader
Definition PackageStore.h:27
EPackageExtension
Definition PackagePath.h:39
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 CompactBinary.h:1025
Definition CompactBinaryWriter.h:68
Definition PackageStore.h:278
virtual EPackageStoreEntryStatus GetPackageStoreEntry(FPackageId PackageId, FName PackageName, FPackageStoreEntry &OutPackageStoreEntry) override
Definition PackageStore.cpp:217
virtual void BeginRead() override
Definition PackageStore.cpp:200
static COREUOBJECT_API void ForceLoadPackageAsLoose(FPackageId PackageId)
Definition PackageStore.cpp:290
virtual bool GetPackageRedirectInfo(FPackageId PackageId, FName &OutSourcePackageName, FPackageId &OutRedirectedToPackageId) override
Definition PackageStore.cpp:212
virtual void EndRead() override
Definition PackageStore.cpp:206
virtual void OnMounted(TSharedRef< const FPackageStoreBackendContext >) override
Definition PackageStore.cpp:195
virtual EPackageLoader GetSupportedLoaders() override
Definition PackageStore.cpp:190
Definition NameTypes.h:617
Definition PackageId.h:19
Definition PackageStore.h:178
DECLARE_EVENT(FPackageStoreBackendContext, FPendingEntriesAddedEvent)
FPendingEntriesAddedEvent PendingEntriesAdded
Definition PackageStore.h:182
Definition PackageStore.h:267
COREUOBJECT_API ~FPackageStoreReadScope()
Definition PackageStore.cpp:440
Definition PackageStore.h:227
COREUOBJECT_API bool HasAnyBackendsMounted() const
Definition PackageStore.cpp:592
static COREUOBJECT_API FPackageStore & Get()
Definition PackageStore.cpp:488
COREUOBJECT_API FPackageStoreBackendContext::FPendingEntriesAddedEvent & OnPendingEntriesAdded()
Definition PackageStore.cpp:587
COREUOBJECT_API EPackageStoreEntryStatus GetPackageStoreEntry(FPackageId PackageId, FName PackageName, FPackageStoreEntry &OutPackageStoreEntry)
Definition PackageStore.cpp:540
COREUOBJECT_API TConstArrayView< uint32 > GetSoftReferences(FPackageId PackageId, TConstArrayView< FPackageId > &OutPackageIds)
Definition PackageStore.cpp:574
COREUOBJECT_API bool GetPackageRedirectInfo(FPackageId PackageId, FName &OutSourcePackageName, FPackageId &OutRedirectedToPackageId)
Definition PackageStore.cpp:561
Definition StructuredArchiveSlots.h:52
Definition PackageStore.h:189
virtual void OnMounted(TSharedRef< const FPackageStoreBackendContext > Context)=0
virtual bool GetPackageRedirectInfo(FPackageId PackageId, FName &OutSourcePackageName, FPackageId &OutRedirectedToPackageId)=0
virtual EPackageLoader GetSupportedLoaders()
Definition PackageStore.h:195
virtual void EndRead()=0
virtual ~IPackageStoreBackend()
Definition PackageStore.h:192
virtual TConstArrayView< uint32 > GetSoftReferences(FPackageId PackageId, TConstArrayView< FPackageId > &OutPackageIds)
Definition PackageStore.h:217
virtual void BeginRead()=0
virtual EPackageStoreEntryStatus GetPackageStoreEntry(FPackageId PackageId, FName PackageName, FPackageStoreEntry &OutPackageStoreEntry)=0
Definition ArrayView.h:139
Definition Array.h:670
Definition SharedPointer.h:692
Definition SharedPointer.h:153
Definition PackageStore.h:121
FPackageId GetPackageId() const
Definition PackageStore.h:137
TArray< FPackageId > SoftPackageReferences
Definition PackageStore.h:134
TArray< FPackageId > ImportedPackageIds
Definition PackageStore.h:128
bool HasOptionalSegment() const
Definition PackageStore.h:148
FPackageId PackageId
Definition PackageStore.h:126
COREUOBJECT_API friend FArchive & operator<<(FArchive &Ar, FPackageStoreEntryResource &PackageStoreEntry)
Definition PackageStore.cpp:301
EPackageStoreEntryFlags Flags
Definition PackageStore.h:123
FName PackageName
Definition PackageStore.h:125
TArray< FSHAHash > ShaderMapHashes
Definition PackageStore.h:130
bool IsAutoOptional() const
Definition PackageStore.h:143
bool HasPackageData() const
Definition PackageStore.h:153
TArray< FPackageId > OptionalSegmentImportedPackageIds
Definition PackageStore.h:132
static COREUOBJECT_API FPackageStoreEntryResource CreateEmptyPackage(FName PackageName, bool bHasCookError)
Definition PackageStore.cpp:416
bool HasCookError() const
Definition PackageStore.h:158
static COREUOBJECT_API FPackageStoreEntryResource FromCbObject(FCbObjectView Obj)
Definition PackageStore.cpp:372
Definition PackageStore.h:50
EPackageExtension PackageExtension
Definition PackageStore.h:58
EPackageLoader LoaderType
Definition PackageStore.h:61
TArrayView< const FSHAHash > ShaderMapHashes
Definition PackageStore.h:64
TArrayView< const FPackageId > ImportedPackageIds
Definition PackageStore.h:63
Definition Tuple.h:652