Editor.AsyncStaticMeshCompilation
Editor.AsyncStaticMeshCompilation
#Overview
name: Editor.AsyncStaticMeshCompilation
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
1 - Async static meshes compilation is enabled.\n2 - Async static meshes compilation is enabled but on pause (for debugging).\nWhen enabled, static meshes will be replaced by placeholders until they are ready\nto reduce stalls on the game thread and improve overall editor performance.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of Editor.AsyncStaticMeshCompilation is to enable asynchronous compilation of static meshes in the Unreal Engine editor. This setting is designed to improve performance during import and map load times when static mesh compilation is required.
This setting variable is primarily used by the Unreal Engine’s static mesh compilation system, which is part of the engine’s asset processing pipeline. Based on the callsites, it’s evident that this variable is utilized in the Engine module, specifically within the StaticMeshCompiler.cpp file.
The value of this variable is set through the UEditorExperimentalSettings class, which is part of the editor’s configuration system. It’s associated with the boolean property bEnableAsyncStaticMeshCompilation in the UEditorExperimentalSettings class.
The variable interacts closely with other asynchronous compilation settings, such as those for textures, skeletal meshes, and sound waves. It’s part of a broader system for managing asynchronous asset compilation in the editor.
Developers should be aware that enabling this setting can impact the editor’s behavior during asset import and map loading. While it can improve performance, it may also introduce potential race conditions or other asynchronous-related issues if not handled properly in custom code that interacts with static mesh compilation.
Best practices when using this variable include:
- Testing thoroughly after enabling or disabling this setting to ensure it doesn’t negatively impact your specific project’s workflow.
- Being cautious when writing custom code that interacts with static mesh compilation, as the asynchronous nature may require additional synchronization or error handling.
- Considering the impact on memory usage, as asynchronous compilation may temporarily increase memory consumption during asset processing.
Regarding the associated variable bEnableAsyncStaticMeshCompilation:
This is a boolean property in the UEditorExperimentalSettings class. It directly controls whether async static mesh compilation is enabled or disabled. By default, it’s set to false in the constructor of UEditorExperimentalSettings.
Developers can modify this setting through the editor’s Project Settings under the Experimental category. Changing this value will affect the behavior of the static mesh compilation system, potentially improving performance at the cost of increased complexity in asset processing.
When working with this setting, developers should consider the overall impact on their project’s asset pipeline and ensure that any custom systems that interact with static mesh compilation are compatible with asynchronous processing.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMeshCompiler.cpp:69
Scope (from outer to inner):
file
namespace StaticMeshCompilingManagerImpl
function static void EnsureInitializedCVars
Source code excerpt:
AsyncCompilationHelpers::EnsureInitializedCVars(
TEXT("staticmesh"),
CVarAsyncStaticMeshStandard.AsyncCompilation,
CVarAsyncStaticMeshStandard.AsyncCompilationMaxConcurrency,
GET_MEMBER_NAME_CHECKED(UEditorExperimentalSettings, bEnableAsyncStaticMeshCompilation));
}
}
}
#Associated Variable and Callsites
This variable is associated with another variable named bEnableAsyncStaticMeshCompilation
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Settings/EditorExperimentalSettings.h:14
Scope (from outer to inner):
file
class class UEditorExperimentalSettings : public UObject
Source code excerpt:
*/
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;
/** Allows usage of the procedural foliage system */
UPROPERTY(EditAnywhere, config, Category = Foliage, meta = (DisplayName = "Procedural Foliage"))
bool bProceduralFoliage;
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/SettingsClasses.cpp:172
Scope (from outer to inner):
file
function UEditorExperimentalSettings::UEditorExperimentalSettings
Source code excerpt:
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);
CVarEditorHDRNITLevel->Set(HDREditorNITLevel, ECVF_SetByProjectSetting);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMeshCompiler.cpp:60
Scope (from outer to inner):
file
namespace StaticMeshCompilingManagerImpl
function static void EnsureInitializedCVars
Source code excerpt:
namespace StaticMeshCompilingManagerImpl
{
static void EnsureInitializedCVars()
{
static bool bIsInitialized = false;
if (!bIsInitialized)
{
bIsInitialized = true;
AsyncCompilationHelpers::EnsureInitializedCVars(
TEXT("staticmesh"),
CVarAsyncStaticMeshStandard.AsyncCompilation,
CVarAsyncStaticMeshStandard.AsyncCompilationMaxConcurrency,
GET_MEMBER_NAME_CHECKED(UEditorExperimentalSettings, bEnableAsyncStaticMeshCompilation));
}
}
}
FStaticMeshCompilingManager::FStaticMeshCompilingManager()
: Notification(MakeUnique<FAsyncCompilationNotification>(GetAssetNameFormat()))
{
StaticMeshCompilingManagerImpl::EnsureInitializedCVars();
PostReachabilityAnalysisHandle = FCoreUObjectDelegates::PostReachabilityAnalysis.AddRaw(this, &FStaticMeshCompilingManager::OnPostReachabilityAnalysis);
}
void FStaticMeshCompilingManager::OnPostReachabilityAnalysis()
{
if (GetNumRemainingMeshes())
{
TRACE_CPUPROFILER_EVENT_SCOPE(FStaticMeshCompilingManager::CancelUnreachableMeshes);
TArray<UStaticMesh*> PendingStaticMeshes;
PendingStaticMeshes.Reserve(GetNumRemainingMeshes());
for (auto Iterator = RegisteredStaticMesh.CreateIterator(); Iterator; ++Iterator)
{
UStaticMesh* StaticMesh = Iterator->GetEvenIfUnreachable();
if (StaticMesh && StaticMesh->IsUnreachable())
{