r.StaticMesh.DisableThreadedBuild

r.StaticMesh.DisableThreadedBuild

#Overview

name: r.StaticMesh.DisableThreadedBuild

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.StaticMesh.DisableThreadedBuild is to control whether static mesh building is performed on a single thread or using multiple threads. It is primarily used in the rendering and asset processing systems of Unreal Engine.

This setting variable is relied upon by the Engine module, specifically in the static mesh building subsystem. It’s defined and used within the StaticMeshBuild.cpp file, which is part of the core engine’s runtime functionality.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0, which means threaded building is enabled by default. Users can change this value at runtime using console commands or through configuration files.

The associated variable CVarStaticMeshDisableThreadedBuild directly interacts with r.StaticMesh.DisableThreadedBuild. They share the same value and purpose.

Developers must be aware that setting this variable to 1 will force static mesh building to occur on a single thread, which may impact performance, especially when processing multiple static meshes simultaneously. However, it might be useful for debugging or in scenarios where threaded building causes issues.

Best practices when using this variable include:

  1. Leave it at the default value (0) for optimal performance in most cases.
  2. Use it temporarily for debugging if you suspect issues related to threaded static mesh building.
  3. Consider the performance implications when enabling single-threaded building, especially in production environments.
  4. If you need to change this value, do so early in the application’s lifecycle to ensure consistent behavior.

Regarding the associated variable CVarStaticMeshDisableThreadedBuild: This is the actual console variable object that controls the behavior. It’s used in the code to check the current value and determine whether to use threaded or single-threaded building. The GetValueOnAnyThread() method is used to retrieve its value safely from any thread. Developers should use this variable when they need to programmatically check or modify the threading behavior of static mesh building within C++ code.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMeshBuild.cpp:109

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarStaticMeshDisableThreadedBuild(
	TEXT("r.StaticMesh.DisableThreadedBuild"),
	0,
	TEXT("Activate to force static mesh building from a single thread.\n"),
	ECVF_Default);

#endif // #if WITH_EDITOR

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMeshBuild.cpp:108

Scope: file

Source code excerpt:

}

static TAutoConsoleVariable<int32> CVarStaticMeshDisableThreadedBuild(
	TEXT("r.StaticMesh.DisableThreadedBuild"),
	0,
	TEXT("Activate to force static mesh building from a single thread.\n"),
	ECVF_Default);

#endif // #if WITH_EDITOR

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMeshBuild.cpp:265

Scope (from outer to inner):

file
function     void UStaticMesh::BatchBuild

Source code excerpt:

			};

		if (StaticMeshesToProcess.Num() > 1 && CVarStaticMeshDisableThreadedBuild.GetValueOnAnyThread() == 0)
		{
			FCriticalSection OutErrorsLock;

			struct FStaticMeshTask
			{
				UStaticMesh*  StaticMesh;