Editor.AsyncTextureCompilation

Editor.AsyncTextureCompilation

#Overview

name: Editor.AsyncTextureCompilation

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of Editor.AsyncTextureCompilation is to enable asynchronous texture compilation in the Unreal Engine editor. This setting is designed to improve performance during Play-in-Editor (PIE) and map load times when texture compilation is required.

This setting variable is primarily used by the Engine’s texture compilation system, specifically within the TextureCompiler module. It’s part of the editor’s performance optimization features and is closely tied to the UnrealEd module.

The value of this variable is set through the UEditorExperimentalSettings class, which is part of the editor’s configuration settings. It’s associated with the bEnableAsyncTextureCompilation boolean property in this class.

The bEnableAsyncTextureCompilation variable interacts directly with Editor.AsyncTextureCompilation. They share the same value, and changes to one will affect the other.

Developers should be aware that this is an experimental feature, as indicated by its inclusion in the EditorExperimentalSettings class. While it can potentially improve performance, it may also introduce instability or unexpected behavior in some scenarios.

Best practices when using this variable include:

  1. Testing thoroughly in your specific project context before enabling in production.
  2. Monitoring performance metrics to ensure it’s actually beneficial for your project.
  3. Being prepared to disable it if any texture-related issues arise.
  4. Keeping the engine and project updated, as experimental features may be subject to changes or improvements in future versions.

Regarding the associated variable bEnableAsyncTextureCompilation:

The purpose of bEnableAsyncTextureCompilation is to provide a user-friendly toggle for the Editor.AsyncTextureCompilation feature within the editor’s settings UI.

This variable is part of the UEditorExperimentalSettings class, which is responsible for managing various experimental features in the Unreal Editor.

The value of this variable is set through the editor’s Project Settings interface, under the Experimental category.

It directly interacts with the Editor.AsyncTextureCompilation console variable, effectively controlling the same feature.

Developers should be aware that this setting is saved per-project, allowing different projects to have different configurations.

Best practices for using this variable include:

  1. Documenting its usage within your team to ensure consistency across different development machines.
  2. Considering version control implications, as changes to this setting might affect different team members differently.
  3. Regularly reviewing its impact on your project’s performance and stability as your project evolves.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/TextureCompiler.cpp:67

Scope (from outer to inner):

file
namespace    TextureCompilingManagerImpl
function     static void EnsureInitializedCVars

Source code excerpt:


			AsyncCompilationHelpers::EnsureInitializedCVars(
				TEXT("texture"),
				CVarAsyncTextureStandard.AsyncCompilation,
				CVarAsyncTextureStandard.AsyncCompilationMaxConcurrency,
				GET_MEMBER_NAME_CHECKED(UEditorExperimentalSettings, bEnableAsyncTextureCompilation));
		}
	}
}

#Associated Variable and Callsites

This variable is associated with another variable named bEnableAsyncTextureCompilation. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Settings/EditorExperimentalSettings.h:10

Scope (from outer to inner):

file
class        class UEditorExperimentalSettings : public UObject

Source code excerpt:

#include "EditorExperimentalSettings.generated.h"

/**
 * Implements Editor settings for experimental features.
 */
UCLASS(config=EditorPerProjectUserSettings, MinimalAPI)
class UEditorExperimentalSettings
	: public UObject
{
	GENERATED_UCLASS_BODY()

public:
	/** Enable async texture compilation to improve PIE and map load time performance when compilation is required */
	UPROPERTY(EditAnywhere, config, Category = Performance, meta = (DisplayName = "Enable async texture compilation and loading"))
	bool bEnableAsyncTextureCompilation;

	/** Enable async static mesh compilation to improve import and map load time performance when compilation is required */
	UPROPERTY(EditAnywhere, config, Category = Performance, meta = (DisplayName = "Enable async static mesh compilation and loading"))
	bool bEnableAsyncStaticMeshCompilation;

	/** Enable async skeletal mesh compilation to improve import and map load time performance when compilation is required */
	UE_DEPRECATED(5.1, "Deprecated & replaced by bEnableAsyncSkinnedAssetCompilation.")
	UPROPERTY(/*EditAnywhere - deprecated & replaced by bEnableAsyncSkinnedAssetCompilation, */config/*, Category = Performance, meta = (DisplayName = "Enable async skeletal mesh compilation and loading")*/)
	bool bEnableAsyncSkeletalMeshCompilation;

	/** Enable async skinned asset compilation to improve import and map load time performance when compilation is required */
	UPROPERTY(EditAnywhere, config, Category = Performance, meta = (DisplayName = "Enable async skinned asset compilation and loading"))
	bool bEnableAsyncSkinnedAssetCompilation;

	/** Enable async sound compilation to improve import and map load time performance when compilation is required */
	UPROPERTY(EditAnywhere, config, Category = Performance, meta = (DisplayName = "Enable async sound compilation and loading"))
	bool bEnableAsyncSoundWaveCompilation;

	/** Allows the editor to run on HDR monitors on Windows 10 */
	UPROPERTY(EditAnywhere, config, Category = HDR, meta = (ConfigRestartRequired = true, DisplayName = "Enable Editor Support for HDR Monitors"))
	bool bHDREditor;

	/** The brightness of the slate UI on HDR monitors */
	UPROPERTY(EditAnywhere, config, Category = HDR, meta = (ClampMin = "100.0", ClampMax = "300.0", UIMin = "100.0", UIMax = "300.0"))
	float HDREditorNITLevel;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/SettingsClasses.cpp:171

Scope (from outer to inner):

file
function     UEditorExperimentalSettings::UEditorExperimentalSettings

Source code excerpt:

static TAutoConsoleVariable<int32> CVarEditorHDRSupport(
	TEXT("Editor.HDRSupport"),
	0,
	TEXT("Sets whether or not we should allow the editor to run on HDR monitors"),
	ECVF_Default);

static TAutoConsoleVariable<float> CVarEditorHDRNITLevel(
	TEXT("Editor.HDRNITLevel"),
	160.0f,
	TEXT("Sets The desired NIT level of the editor when running on HDR"),
	ECVF_Default);

UEditorExperimentalSettings::UEditorExperimentalSettings( const FObjectInitializer& ObjectInitializer )
	: Super(ObjectInitializer)
	, bEnableAsyncTextureCompilation(false)
	, bEnableAsyncStaticMeshCompilation(false)
	, bEnableAsyncSkeletalMeshCompilation(true)	// This was false and set to True in /Engine/Config/BaseEditorPerProjectUserSettings.ini. The setting is removed from .ini so change it to default True.
	, bEnableAsyncSkinnedAssetCompilation(false)
	, bEnableAsyncSoundWaveCompilation(false)
	, bHDREditor(false)
	, HDREditorNITLevel(160.0f)
	, bUseOpenCLForConvexHullDecomp(false)
	, bAllowPotentiallyUnsafePropertyEditing(false)
	, bPackedLevelActor(true)
	, bLevelInstance(true)
{
}

void UEditorExperimentalSettings::PostInitProperties()
{
	PRAGMA_DISABLE_DEPRECATION_WARNINGS
	// bEnableAsyncSkeletalMeshCompilation's default to True (see comment in constructor above).
	// To be backwards compatible, if a user project overrides it to False, pass on the value to bEnableAsyncSkinnedAssetCompilation.
	if (!bEnableAsyncSkeletalMeshCompilation)
	{
		UE_LOG(LogSettingsClasses, Warning, TEXT("bEnableAsyncSkeletalMeshCompilation is deprecated and replaced with bEnableAsyncSkinnedAssetCompilation. Please update the config. Setting bEnableAsyncSkinnedAssetCompilation to False."));
		bEnableAsyncSkinnedAssetCompilation = false;
	}
	PRAGMA_ENABLE_DEPRECATION_WARNINGS

	CVarEditorHDRSupport->Set(bHDREditor ? 1 : 0, ECVF_SetByProjectSetting);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/TextureCompiler.cpp:58

Scope (from outer to inner):

file
namespace    TextureCompilingManagerImpl
function     static void EnsureInitializedCVars

Source code excerpt:

	}

	static void EnsureInitializedCVars()
	{
		static bool bIsInitialized = false;

		if (!bIsInitialized)
		{
			bIsInitialized = true;

			AsyncCompilationHelpers::EnsureInitializedCVars(
				TEXT("texture"),
				CVarAsyncTextureStandard.AsyncCompilation,
				CVarAsyncTextureStandard.AsyncCompilationMaxConcurrency,
				GET_MEMBER_NAME_CHECKED(UEditorExperimentalSettings, bEnableAsyncTextureCompilation));
		}
	}
}

FTextureCompilingManager::FTextureCompilingManager()
	: Notification(MakeUnique<FAsyncCompilationNotification>(GetAssetNameFormat()))
{
	TextureCompilingManagerImpl::EnsureInitializedCVars();
}

FName FTextureCompilingManager::GetStaticAssetTypeName()
{
	return TEXT("UE-Texture");
}

bool FTextureCompilingManager::IsCompilingTexture(UTexture* InTexture) const 
{
	check(IsInGameThread());

	if (!InTexture)
	{
		return false;
	}

	const TWeakObjectPtr<UTexture> InWeakTexturePtr = InTexture;
	uint32 Hash = GetTypeHash(InWeakTexturePtr);