bGenerateChunks

bGenerateChunks

#Overview

name: bGenerateChunks

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

It is referenced in 18 C++ source files. Also referenced in 1 C# build file meaning it may affect the build system logic.

#Summary

#Usage in the C++ source code

The purpose of bGenerateChunks is to control whether content should be split into chunks during the packaging process for Unreal Engine projects. This setting is primarily used in the context of content distribution and streaming.

bGenerateChunks is primarily used in the Project Packaging Settings and Launcher Services modules of Unreal Engine. These subsystems are responsible for packaging and distributing game content.

The value of this variable is typically set in the Project Packaging Settings, which can be accessed through the project settings in the Unreal Editor. It can also be modified programmatically through the UProjectPackagingSettings class.

This variable interacts closely with other packaging-related variables, such as:

  1. UsePakFile: When bGenerateChunks is true, UsePakFile is automatically set to true.
  2. bBuildHttpChunkInstallData: This is often enabled when bGenerateChunks is true, to generate data for HTTP chunk installation.
  3. bGenerateNoChunks: This setting overrides bGenerateChunks when set to true.

Developers should be aware that:

  1. Enabling chunk generation affects the packaging process and can increase build times.
  2. It’s closely tied to streaming install systems and content delivery networks (CDNs).
  3. Chunk generation is platform-dependent and may not be supported or necessary for all target platforms.

Best practices when using this variable include:

  1. Only enable it when you actually need to split content into chunks, typically for large games that benefit from streaming installation.
  2. Ensure that your content is properly organized to take advantage of chunking.
  3. Test thoroughly with chunk generation enabled to ensure it doesn’t introduce any issues with content loading or game performance.
  4. Consider the implications on your content delivery pipeline when enabling this option.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseGame.ini:104, section: [/Script/UnrealEd.ProjectPackagingSettings]

Location: <Workspace>/Projects/Lyra/Config/DefaultGame.ini:97, section: [/Script/UnrealEd.ProjectPackagingSettings]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Developer/DeveloperToolSettings/Classes/Settings/ProjectPackagingSettings.h:278

Scope (from outer to inner):

file
class        class UProjectPackagingSettings : public UObject

Source code excerpt:

	 */
	UPROPERTY(config, EditAnywhere, Category=Packaging)
	bool bGenerateChunks;

	/** 
	 * If enabled, no platform will generate chunks, regardless of settings in platform-specific ini files.
	 */
	UPROPERTY(config, EditAnywhere, Category=Packaging)
	bool bGenerateNoChunks;

#Loc: <Workspace>/Engine/Source/Developer/DeveloperToolSettings/Private/ProjectPackagingSettings.cpp:113

Scope (from outer to inner):

file
function     void UProjectPackagingSettings::PostEditChangeProperty

Source code excerpt:

	else if (Name == FName(TEXT("bGenerateChunks")))
	{
		if (bGenerateChunks)
		{
			UsePakFile = true;
		}
	}
	else if (Name == FName(TEXT("UsePakFile")))
	{
		if (!UsePakFile)
		{
			bGenerateChunks = false;
			bBuildHttpChunkInstallData = false;
		}
	}
	else if (Name == FName(TEXT("bBuildHTTPChunkInstallData")))
	{
		if (bBuildHttpChunkInstallData)
		{
			UsePakFile = true;
			bGenerateChunks = true;
			//Ensure data is something valid
			if (HttpChunkInstallDataDirectory.Path.IsEmpty())
			{
				auto CloudInstallDir = FPaths::ConvertRelativePathToFull(FPaths::GetPath(FPaths::GetProjectFilePath())) / TEXT("ChunkInstall");
				HttpChunkInstallDataDirectory.Path = CloudInstallDir;
			}

#Loc: <Workspace>/Engine/Source/Developer/LauncherServices/Private/Profiles/LauncherProfile.h:874

Scope (from outer to inner):

file
class        class FLauncherProfile final : public ILauncherProfile
function     virtual bool IsGeneratingChunks

Source code excerpt:

	virtual bool IsGeneratingChunks() const override
	{
		return bGenerateChunks;
	}

	virtual bool IsGenerateHttpChunkData() const override
	{
		return bGenerateHttpChunkData;
	}

#Loc: <Workspace>/Engine/Source/Developer/LauncherServices/Private/Profiles/LauncherProfile.h:1045

Scope (from outer to inner):

file
class        class FLauncherProfile final : public ILauncherProfile
function     virtual bool Serialize

Source code excerpt:

		if (Version >= LAUNCHERSERVICES_ADDEDGENERATECHUNKS)
		{
			Archive << bGenerateChunks;
			Archive << bGenerateHttpChunkData;
			Archive << HttpChunkDataDirectory;
			Archive << HttpChunkDataReleaseName;
		}
		if (Version >= LAUNCHERSERVICES_ADDARCHIVE)
		{

#Loc: <Workspace>/Engine/Source/Developer/LauncherServices/Private/Profiles/LauncherProfile.h:1238

Scope (from outer to inner):

file
class        class FLauncherProfile final : public ILauncherProfile
function     virtual void Save

Source code excerpt:

		Writer.WriteValue("CreateDLC", CreateDLC);
		Writer.WriteValue("DLCName", DLCName);
		Writer.WriteValue("GenerateChunks", bGenerateChunks);
		Writer.WriteValue("GenerateHttpChunkData", bGenerateHttpChunkData);
		Writer.WriteValue("HttpChunkDataDirectory", HttpChunkDataDirectory);
		Writer.WriteValue("HttpChunkDataReleaseName", HttpChunkDataReleaseName);
		Writer.WriteValue("Archive", bArchive);
		Writer.WriteValue("ArchiveDirectory", ArchiveDir);
		Writer.WriteValue("AdditionalCommandLineParameters", AdditionalCommandLineParameters);

#Loc: <Workspace>/Engine/Source/Developer/LauncherServices/Private/Profiles/LauncherProfile.h:1907

Scope (from outer to inner):

file
class        class FLauncherProfile final : public ILauncherProfile
function     virtual bool Load

Source code excerpt:

		CreateDLC = Object.GetBoolField(TEXT("CreateDLC"));
		DLCName = Object.GetStringField(TEXT("DLCName"));
		bGenerateChunks = Object.GetBoolField(TEXT("GenerateChunks"));
		bGenerateHttpChunkData = Object.GetBoolField(TEXT("GenerateHttpChunkData"));
		HttpChunkDataDirectory = Object.GetStringField(TEXT("HttpChunkDataDirectory"));
		HttpChunkDataReleaseName = Object.GetStringField(TEXT("HttpChunkDataReleaseName"));

		if (Version >= LAUNCHERSERVICES_ADDARCHIVE)
		{

#Loc: <Workspace>/Engine/Source/Developer/LauncherServices/Private/Profiles/LauncherProfile.h:2074

Scope (from outer to inner):

file
class        class FLauncherProfile final : public ILauncherProfile
function     virtual void SetDefaults

Source code excerpt:

		DLCIncludeEngineContent = false;

		bGenerateChunks = false;
		bGenerateHttpChunkData = false;
		HttpChunkDataDirectory = TEXT("");
		HttpChunkDataReleaseName = TEXT("");

		// default launch settings
		DefaultDeployPlatform = NAME_None;

#Loc: <Workspace>/Engine/Source/Developer/LauncherServices/Private/Profiles/LauncherProfile.h:2227

Scope (from outer to inner):

file
class        class FLauncherProfile final : public ILauncherProfile
function     virtual void SetGenerateChunks

Source code excerpt:

	virtual void SetGenerateChunks(bool bInGenerateChunks) override
	{
		if (bGenerateChunks != bInGenerateChunks)
		{
			bGenerateChunks = bInGenerateChunks;
			Validate();
		}
	}

	virtual void SetGenerateHttpChunkData(bool bInGenerateHttpChunkData) override
	{

#Loc: <Workspace>/Engine/Source/Developer/LauncherServices/Private/Profiles/LauncherProfile.h:3128

Scope (from outer to inner):

file
class        class FLauncherProfile final : public ILauncherProfile

Source code excerpt:


	// Flag indicating if content should be split into chunks
	bool bGenerateChunks;
	
	// Flag indicating if chunked content should be used to generate HTTPChunkInstall data
	bool bGenerateHttpChunkData;
	
	// Where to store HTTPChunkInstall data
	FString HttpChunkDataDirectory;

#Loc: <Workspace>/Engine/Source/Developer/LauncherServices/Public/ILauncherProfile.h:1086

Scope (from outer to inner):

file
class        class ILauncherProfile

Source code excerpt:

	 * @param true if Chunks should be generated, false otherwise.
	 */
	virtual void SetGenerateChunks(bool bGenerateChunks) = 0;
	/**
	 * Set whether packaging will use chunk data to generate http chunk install data.
	 *
	 * @param true if data should be generated, false otherwise.
	 */
	virtual void SetGenerateHttpChunkData(bool bGenerateHttpChunkData) = 0;

#Loc: <Workspace>/Engine/Source/Editor/TurnkeySupport/Private/TurnkeySupportModule.cpp:466

Scope (from outer to inner):

file
class        class FTurnkeySupportCallbacks
function     static void CookOrPackage

Source code excerpt:

			}

			if (PackagingSettings->bGenerateChunks)
			{
				BuildCookRunParams += TEXT(" -manifests");
			}

			// Whether to include the crash reporter.
			if (PackagingSettings->IncludeCrashReporter && PlatformInfo->DataDrivenPlatformInfo->bCanUseCrashReporter)

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/AssetRegistryGenerator.cpp:179

Scope (from outer to inner):

file
function     FAssetRegistryGenerator::FAssetRegistryGenerator

Source code excerpt:

	: AssetRegistry(FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry")).Get())
	, TargetPlatform(InPlatform)
	, bGenerateChunks(false)
	, bClonedGlobalAssetRegistry(false)
	, HighestChunkId(0)
	, DependencyInfo(*GetMutableDefault<UChunkDependencyInfo>())
{
	LLM_SCOPE_BYTAG(Cooker_GeneratedAssetRegistry);
	bool bOnlyHardReferences = false;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/AssetRegistryGenerator.cpp:840

Scope (from outer to inner):

file
function     void FAssetRegistryGenerator::CalculateChunkIdsAndAssignToManifest

Source code excerpt:

	TArray<int32> ExistingChunkIDs;

	if (!bGenerateChunks)
	{
		TargetChunks.AddUnique(0);
		ExistingChunkIDs.AddUnique(0);
	}
	else
	{

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/AssetRegistryGenerator.cpp:984

Scope (from outer to inner):

file
function     bool FAssetRegistryGenerator::SaveManifests

Source code excerpt:

{
	LLM_SCOPE_BYTAG(Cooker_GeneratedAssetRegistry);
	if (!bGenerateChunks)
	{
		return true;
	}

	if (!GenerateStreamingInstallManifest(InOverrideChunkSize, InManifestSubDir, InSandboxFile))
	{

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/AssetRegistryGenerator.cpp:1528

Scope (from outer to inner):

file
function     void FAssetRegistryGenerator::FinalizeChunkIDs

Source code excerpt:

	LLM_SCOPE_BYTAG(Cooker_GeneratedAssetRegistry);
	// bGenerateNoChunks overrides bGenerateStreamingInstallManifest overrides ShouldPlatformGenerateStreamingInstallManifest
	// bGenerateChunks means we allow chunks other than 0 based on package ChunkIds, AND we generate a manifest for each chunk
	const UProjectPackagingSettings* PackagingSettings = Cast<UProjectPackagingSettings>(UProjectPackagingSettings::StaticClass()->GetDefaultObject());
	if (PackagingSettings->bGenerateNoChunks)
	{
		bGenerateChunks = false;
	}
	else if (bGenerateStreamingInstallManifest)
	{
		bGenerateChunks = true;
	}
	else
	{
		bGenerateChunks = ShouldPlatformGenerateStreamingInstallManifest(TargetPlatform);
	}

	CookedPackages = InCookedPackages;
	DevelopmentOnlyPackages = InDevelopmentOnlyPackages;

	// Possibly apply previous AssetData and AssetPackageData for packages kept from a previous cook

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Commandlets/AssetRegistryGenerator.cpp:1729

Scope (from outer to inner):

file
function     bool FAssetRegistryGenerator::SaveAssetRegistry

Source code excerpt:

		}

		if (bGenerateChunks)
		{
			FString ChunkListsPath = PlatformSandboxPath.Replace(*FString::Printf(TEXT("/%s"), DevelopmentAssetRegistryFilename), TEXT(""));

			// Write out CSV file with chunking information
			GenerateAssetChunkInformationCSV(ChunkListsPath, false);
		}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Public/Commandlets/AssetRegistryGenerator.h:320

Scope (from outer to inner):

file
class        class FAssetRegistryGenerator

Source code excerpt:

	TSet<FName> PackagesContainingMaps;
	/** Should the chunks be generated or only asset registry */
	bool bGenerateChunks;
	bool bClonedGlobalAssetRegistry;
	/** Highest chunk id, being used for geneating dependency tree */
	int32 HighestChunkId;
	/** Array of Maps with chunks<->packages assignments */
	TArray<TUniquePtr<FChunkPackageSet>> ChunkManifests;
	/** Map of packages that has not been assigned to chunks */

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AssetManager.cpp:4110

Scope (from outer to inner):

file
function     void UAssetManager::UpdateManagementDatabase

Source code excerpt:


	UProjectPackagingSettings* ProjectPackagingSettings = GetMutableDefault<UProjectPackagingSettings>();
	if (ProjectPackagingSettings && ProjectPackagingSettings->bGenerateChunks)
	{
		// Update the editor preview chunk package list for all chunks, but only if we actually care about chunks
		// bGenerateChunks is settable per platform, but should be enabled on the default platform for preview to work
		TArray<int32> OverrideChunkList;
		for (FName PackageName : PackagesToUpdateChunksFor)
		{
			ChunkList.Reset();
			OverrideChunkList.Reset();
			GetPackageChunkIds(PackageName, nullptr, ExistingChunkList, ChunkList, &OverrideChunkList);

#References in C# build files

This variable is referenced in the following C# build files:

Location: <Workspace>/Engine/Source/Programs/AutomationTool/AutomationUtils/DeploymentContext.cs:665

		{
			bool bSetting = false;
			if (GameConfig.GetBool(PackagingIniPath, "bGenerateChunks", out bSetting))
			{
				PlatformUsesChunkManifests = bSetting;
			}
		}
	}