bSerializeDependencies

bSerializeDependencies

#Overview

name: bSerializeDependencies

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 13 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of bSerializeDependencies is to control whether dependency information should be serialized (saved or loaded) in the Unreal Engine asset registry system. This setting variable is primarily used for managing the serialization of asset dependencies, which include hard and soft package references.

bSerializeDependencies is primarily used in the Asset Registry subsystem of Unreal Engine. This subsystem is responsible for tracking and managing asset metadata and dependencies throughout the engine.

The value of this variable is typically set in the engine configuration files (INI files). It’s read from the “[AssetRegistry]” section of the engine INI file, as seen in the InitializeSerializationOptionsFromIni function.

This variable interacts with several other related variables, such as:

Developers should be aware that:

  1. This variable significantly affects the size and content of serialized asset registry data.
  2. Enabling this option will increase the amount of data saved and loaded, which may impact performance and storage requirements.
  3. It’s crucial for maintaining accurate dependency information between assets, which is vital for various engine systems and tools.

Best practices when using this variable include:

  1. Enable it in development environments to ensure complete dependency information is available for debugging and asset management.
  2. Consider disabling it in shipping builds if dependency information is not required at runtime, to reduce file sizes and load times.
  3. Always test the impact of changing this setting on your project’s performance and functionality.
  4. Use it in conjunction with other serialization options to fine-tune the level of detail in your asset registry data.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:2736, section: [AssetRegistry]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/AssetRegistry/Private/AssetRegistry.cpp:1309

Scope (from outer to inner):

file
namespace    UE::AssetRegistry
namespace    Utils
function     void InitializeSerializationOptionsFromIni

Source code excerpt:

	{
		EngineIni->GetBool(TEXT("AssetRegistry"), TEXT("bSerializeAssetRegistry"), Options.bSerializeAssetRegistry);
		EngineIni->GetBool(TEXT("AssetRegistry"), TEXT("bSerializeDependencies"), Options.bSerializeDependencies);
		EngineIni->GetBool(TEXT("AssetRegistry"), TEXT("bSerializeNameDependencies"), Options.bSerializeSearchableNameDependencies);
		EngineIni->GetBool(TEXT("AssetRegistry"), TEXT("bSerializeManageDependencies"), Options.bSerializeManageDependencies);
		EngineIni->GetBool(TEXT("AssetRegistry"), TEXT("bSerializePackageData"), Options.bSerializePackageData);
		EngineIni->GetBool(TEXT("AssetRegistry"), TEXT("bFilterAssetDataWithNoTags"), Options.bFilterAssetDataWithNoTags);
		EngineIni->GetBool(TEXT("AssetRegistry"), TEXT("bFilterDependenciesWithNoTags"), Options.bFilterDependenciesWithNoTags);
		EngineIni->GetBool(TEXT("AssetRegistry"), TEXT("bFilterSearchableNames"), Options.bFilterSearchableNames);

#Loc: <Workspace>/Engine/Source/Runtime/AssetRegistry/Private/AssetRegistryState.cpp:30

Scope: file

Source code excerpt:

#include "UObject/UObjectIterator.h"

// Even if bSerializeDependencies is enabled, this can bypass serializing at runtime.
// Update your <project>.Target.cs build scripts to define as needed.
#ifndef ASSET_REGISTRY_ALLOW_DEPENDENCY_SERIALIZATION
#define ASSET_REGISTRY_ALLOW_DEPENDENCY_SERIALIZATION 1
#endif

FAssetRegistryState& FAssetRegistryState::operator=(FAssetRegistryState&& Rhs)

#Loc: <Workspace>/Engine/Source/Runtime/AssetRegistry/Private/AssetRegistryState.cpp:1389

Scope (from outer to inner):

file
function     bool FAssetRegistryState::Save

Source code excerpt:

	Ar << DependencySectionSize;
	int64 DependencySectionStart = Ar.Tell();
	if (!Options.bSerializeDependencies)
	{
		int32 NumDependencies = 0;
		Ar << NumDependencies;
	}
	else
	{

#Loc: <Workspace>/Engine/Source/Runtime/AssetRegistry/Private/AssetRegistryState.cpp:1669

Scope (from outer to inner):

file
function     void FAssetRegistryState::LoadDependencies_BeforeFlags

Source code excerpt:

}

void FAssetRegistryState::LoadDependencies_BeforeFlags(FArchive& Ar, bool bSerializeDependencies, FAssetRegistryVersion::Type Version)
{
	int32 LocalNumDependsNodes = 0;
	Ar << LocalNumDependsNodes;

	FDependsNode Placeholder;
	FDependsNode* PreallocatedDependsNodeDataBuffer = nullptr;
	if (bSerializeDependencies && LocalNumDependsNodes > 0)
	{
		PreallocatedDependsNodeDataBuffer = new FDependsNode[LocalNumDependsNodes];
		PreallocatedDependsNodeDataBuffers.Add(PreallocatedDependsNodeDataBuffer);
		CachedDependsNodes.Reserve(LocalNumDependsNodes);
	}
	TUniqueFunction<FDependsNode* (int32)> GetNodeFromSerializeIndex = [&PreallocatedDependsNodeDataBuffer, LocalNumDependsNodes](int32 Index)->FDependsNode *

#Loc: <Workspace>/Engine/Source/Runtime/AssetRegistry/Private/AssetRegistryState.cpp:1699

Scope (from outer to inner):

file
function     void FAssetRegistryState::LoadDependencies_BeforeFlags

Source code excerpt:

		// Create the node if we're actually saving dependencies, otherwise just fake serialize
		FDependsNode* DependsNode = nullptr;
		if (bSerializeDependencies)
		{
			DependsNode = &PreallocatedDependsNodeDataBuffer[DependsNodeIndex];
		}
		else
		{
			DependsNode = &Placeholder;

#Loc: <Workspace>/Engine/Source/Runtime/AssetRegistry/Private/AssetRegistryState.cpp:1709

Scope (from outer to inner):

file
function     void FAssetRegistryState::LoadDependencies_BeforeFlags

Source code excerpt:


		// Call the DependsNode legacy serialization function
		DependsNode->SerializeLoad_BeforeFlags(Ar, Version, PreallocatedDependsNodeDataBuffer, LocalNumDependsNodes, bSerializeDependencies, HardBits, SoftBits, HardManageBits, SoftManageBits);

		// Register the DependsNode with its AssetIdentifier
		if (bSerializeDependencies)
		{
			CachedDependsNodes.Add(DependsNode->GetIdentifier(), DependsNode);
		}
	}
}

#Loc: <Workspace>/Engine/Source/Runtime/AssetRegistry/Private/DependsNode.cpp:716

Scope (from outer to inner):

file
function     void FDependsNode::SerializeLoad_BeforeFlags

Source code excerpt:

}

void FDependsNode::SerializeLoad_BeforeFlags(FArchive& Ar, FAssetRegistryVersion::Type Version, FDependsNode* PreallocatedDependsNodeDataBuffer, int32 NumDependsNodes, bool bSerializeDependencies,
	uint32 HardBits, uint32 SoftBits, uint32 HardManageBits, uint32 SoftManageBits)
{
	Ar << Identifier;

	int32 NumHard, NumSoft, NumName, NumSoftManage, NumHardManage, NumReferencers;
	Ar << NumHard;

#Loc: <Workspace>/Engine/Source/Runtime/AssetRegistry/Private/DependsNode.cpp:738

Scope (from outer to inner):

file
function     void FDependsNode::SerializeLoad_BeforeFlags

Source code excerpt:

	// Empty dependency arrays and reserve space
	PackageDependencies.Empty(NumHard + NumSoft);
	NameDependencies.Empty(bSerializeDependencies ? NumName : 0);
	ManageDependencies.Empty(bSerializeDependencies ? NumSoftManage + NumHardManage : 0);
	Referencers.Empty(NumReferencers);

	auto SerializeNodeArray = [&Ar, PreallocatedDependsNodeDataBuffer, NumDependsNodes](int32 Num, TArray<FDependsNode*>& OutNodes, TBitArray<>* OutFlagBits, uint32 FlagSetWidth, uint32 FlagSetBits, bool bShouldOverwriteFlag, bool bAllowWrite)
	{
		for (int32 DependencyIndex = 0; DependencyIndex < Num; ++DependencyIndex)
		{

#Loc: <Workspace>/Engine/Source/Runtime/AssetRegistry/Private/DependsNode.cpp:779

Scope (from outer to inner):

file
function     void FDependsNode::SerializeLoad_BeforeFlags

Source code excerpt:

	SerializeNodeArray(NumHard, PackageDependencies, &PackageFlags, PackageFlagSetWidth, HardBits, true, true);
	SerializeNodeArray(NumSoft, PackageDependencies, &PackageFlags, PackageFlagSetWidth, SoftBits, false, true);
	SerializeNodeArray(NumName, NameDependencies, nullptr, 0, 0, true, bSerializeDependencies);
	SerializeNodeArray(NumSoftManage, ManageDependencies, &ManageFlags, ManageFlagSetWidth, SoftManageBits, true, bSerializeDependencies);
	SerializeNodeArray(NumHardManage, ManageDependencies, &ManageFlags, ManageFlagSetWidth, HardManageBits, true, bSerializeDependencies);
	SerializeNodeArray(NumReferencers, Referencers, nullptr, 0, 0, true, true);

	SetIsDependenciesInitialized(true);
}

void FDependsNode::GetPropertySetBits_BeforeFlags(uint32& HardBits, uint32& SoftBits, uint32& HardManageBits, uint32& SoftManageBits)

#Loc: <Workspace>/Engine/Source/Runtime/AssetRegistry/Private/DependsNode.h:154

Scope (from outer to inner):

file
class        class FDependsNode

Source code excerpt:

	void SerializeLoad(FArchive& Ar, const TUniqueFunction<FDependsNode*(int32)>& GetNodeFromSerializeIndex, FLoadScratch& Scratch);

	void SerializeLoad_BeforeFlags(FArchive& Ar, FAssetRegistryVersion::Type Version, FDependsNode* PreallocatedDependsNodeDataBuffer, int32 NumDependsNodes, bool bSerializeDependencies,
		uint32 HardBits, uint32 SoftBits, uint32 HardManageBits, uint32 SoftManageBits);
	static void GetPropertySetBits_BeforeFlags(uint32& HardBits, uint32& SoftBits, uint32& HardManageBits, uint32& SoftManageBits);

	bool IsDependencyListSorted(UE::AssetRegistry::EDependencyCategory Category) const;
	void SetIsDependencyListSorted(UE::AssetRegistry::EDependencyCategory Category, bool bValue);
	bool IsReferencersSorted() const;

#Loc: <Workspace>/Engine/Source/Runtime/AssetRegistry/Public/AssetRegistry/AssetRegistryState.h:53

Scope: file

Source code excerpt:


	/** True rather to load/save dependency info. If true this will handle hard and soft package references */
	bool bSerializeDependencies = false;

	/** True rather to load/save dependency info for Name references,  */
	bool bSerializeSearchableNameDependencies = false;

	/** True rather to load/save dependency info for Manage references,  */
	bool bSerializeManageDependencies = false;

#Loc: <Workspace>/Engine/Source/Runtime/AssetRegistry/Public/AssetRegistry/AssetRegistryState.h:102

Scope (from outer to inner):

file
function     void InitForDevelopment

Source code excerpt:

	void InitForDevelopment()
	{
		bSerializeAssetRegistry = bSerializeDependencies = bSerializeSearchableNameDependencies = bSerializeManageDependencies = bSerializePackageData = true;
		DisableFilters();
	}
};

struct FAssetRegistryLoadOptions
{
	FAssetRegistryLoadOptions() = default;
	explicit FAssetRegistryLoadOptions(const FAssetRegistrySerializationOptions& Options)
		: bLoadDependencies(Options.bSerializeDependencies)
		, bLoadPackageData(Options.bSerializePackageData)
	{}

	bool bLoadDependencies = true;
	bool bLoadPackageData = true;
	int32 ParallelWorkers = 0;

#Loc: <Workspace>/Engine/Source/Runtime/AssetRegistry/Public/AssetRegistry/AssetRegistryState.h:609

Scope (from outer to inner):

file
class        class FAssetRegistryState

Source code excerpt:


	void LoadDependencies(FArchive& Ar);
	void LoadDependencies_BeforeFlags(FArchive& Ar, bool bSerializeDependencies, FAssetRegistryVersion::Type Version);

	void SetTagsOnExistingAsset(FAssetData* AssetData, FAssetDataTagMap&& NewTags);

	void SetDependencyNodeSorting(bool bSortDependencies, bool bSortReferencers);

	void RemoveAssetData(FAssetData* AssetData, const FCachedAssetKey& Key, bool bRemoveDependencyData,