PackageCompressionMethod

PackageCompressionMethod

#Overview

name: PackageCompressionMethod

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

It is referenced in 3 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 PackageCompressionMethod is to specify the compression algorithm used for packaging game content in Unreal Engine 5. This setting is primarily used in the build and packaging process to determine how game assets and data are compressed when creating distributable game packages.

This setting variable is primarily relied upon by the Unreal Engine’s packaging and compression subsystems. Based on the callsites, it’s used in the following areas:

  1. Project Packaging Settings (DeveloperToolSettings module)
  2. Texture Editor (TextureEditor module)
  3. Core Compression system (Core module, specifically the Oodle Data Compression Format)

The value of this variable is set in the project’s configuration files, typically in DefaultGame.ini. It can be overridden per platform if needed.

PackageCompressionMethod interacts with other variables such as PackageCompressionFormat, PackageAdditionalCompressionOptions, and PackageCompressionLevel variables for different build configurations (Distribution, TestShipping, DebugDevelopment).

Developers must be aware that:

  1. The chosen compression method affects both package size and compression/decompression time.
  2. Some platforms may have hardware-specific compression formats that can override this setting.
  3. The setting is used in conjunction with other compression-related settings to fine-tune the packaging process.

Best practices when using this variable include:

  1. Choose a compression method that balances package size and decompression speed for your target platforms.
  2. Consider using different compression methods for different build configurations (e.g., more aggressive compression for distribution builds, faster compression for development builds).
  3. Be aware of platform-specific limitations or recommendations regarding compression methods.
  4. Test the impact of different compression methods on your project’s build time, package size, and loading times to find the optimal setting for your game.

#Setting Variables

#References In INI files

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

Location: <Workspace>/Engine/Config/Android/BaseAndroidGame.ini:2, section: [/Script/UnrealEd.ProjectPackagingSettings]

Location: <Workspace>/Engine/Config/IOS/BaseIOSGame.ini:2, section: [/Script/UnrealEd.ProjectPackagingSettings]

Location: <Workspace>/Projects/Lyra/Config/DefaultGame.ini:108, 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:363

Scope (from outer to inner):

file
class        class UProjectPackagingSettings : public UObject

Source code excerpt:

	 */
	UPROPERTY(config, EditAnywhere, Category = Packaging, AdvancedDisplay, meta = (DisplayName = "Package Compression Method"))
	FString PackageCompressionMethod;
		
	/*
	 * For compressors with variable levels, select the compressor effort level, which makes packages smaller but takes more time to encode.
	 * This does not affect decode speed.  For faster iteration, use lower effort levels (eg. 1)
	 */
	UPROPERTY(config, EditAnywhere, Category = Packaging, AdvancedDisplay, meta = (DisplayName = "Compressor Effort Level for Debug & Development"))

#Loc: <Workspace>/Engine/Source/Editor/TextureEditor/Private/TextureEditorToolkit.cpp:1262

Scope (from outer to inner):

file
function     void FTextureEditorToolkit::CreateInternalWidgets

Source code excerpt:

	{
		// Validity check the string by trying to convert to enum.
		const FString& LookupCompressor = ProjectSettings->PackageCompressionMethod;
		FOodleDataCompression::ECompressor PackageCompressor = FOodleDataCompression::ECompressor::Kraken;
		if (FOodleDataCompression::ECompressorFromString(LookupCompressor, PackageCompressor))
		{
			OodleCompressor = PackageCompressor;
		}
		else

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/Compression/OodleDataCompressionFormat.cpp:42

Scope: file

Source code excerpt:

PackageCompressionFormat=Oodle
PackageAdditionalCompressionOptions=-compressionblocksize=256KB
PackageCompressionMethod=Kraken
PackageCompressionLevel_Distribution=7
PackageCompressionLevel_TestShipping=5
PackageCompressionLevel_DebugDevelopment=4

* This can be set in DefaultGame.ini then overrides set up per-platform.
* 
* The Engine also has a veto compressionformat set up in the DataDrivenPlatformInfo.ini for each platform in the field
* "HardwareCompressionFormat"
* eg. platforms that don't want any software compressor can set "HardwareCompressionFormat=None" and this will override what you
* set in "PackageCompressionFormat".
* 
* The idea is in typical use, you set "PackageCompressionFormat" for your Game, and you get that compressor on most platforms, but on
* some platforms that don't want compression, it automatically turns off.
* 
* If you want to force use of your Game.ini compressor (ignore the HardwareCompressionFormat) you can set bForceUseProjectCompressionFormat
* in ProjectPackagingSettings.
* 
* 
* ***************************/

#include "CoreMinimal.h"
#include "CoreTypes.h"
#include "Misc/Compression.h"
#include "Misc/ICompressionFormat.h"
#include "Misc/CommandLine.h"
#include "Misc/ConfigCacheIni.h"
#include "Misc/Parse.h"

/*
#if WITH_EDITOR
#include "Settings/ProjectPackagingSettings.h"
#endif
*/

#include "HAL/PlatformProcess.h"

#include "Compression/OodleDataCompression.h"
#include "oodle2.h"


#define OODLE_DERIVEDDATA_VER TEXT("BA7AA26CD1C3498787A3F3AA53895042")

// function pointer for old DLL import :
extern "C"
{
typedef OO_SINTa (OOLINK t_fp_OodleLZ_Compress)(OodleLZ_Compressor compressor,
    const void * rawBuf,OO_SINTa rawLen,void * compBuf,
    OodleLZ_CompressionLevel selection,
    const OodleLZ_CompressOptions * pOptions,
    const void * dictionaryBase,
    const void * lrm);

typedef OO_SINTa (OOLINK t_fp_OodleSetAllocators)(
	t_fp_OodleCore_Plugin_MallocAligned* fp_OodleMallocAligned,
	t_fp_OodleCore_Plugin_Free* fp_OodleFree);
};

#References in C# build files

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

Location: <Workspace>/Engine/Source/Programs/AutomationTool/Scripts/CopyBuildToStagingDirectory.Automation.cs:3064


				string CompressionMethod;
				PlatformGameConfig.GetString("/Script/UnrealEd.ProjectPackagingSettings", "PackageCompressionMethod", out CompressionMethod);
				if (!string.IsNullOrWhiteSpace(CompressionMethod))
				{
					CompressionFormats += " -compressmethod=" + CompressionMethod;
				}