geometry.MeshSceneAdapter.SingleThreaded

geometry.MeshSceneAdapter.SingleThreaded

#Overview

name: geometry.MeshSceneAdapter.SingleThreaded

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 geometry.MeshSceneAdapter.SingleThreaded is to control whether multi-threading is used in the MeshSceneAdapter component of Unreal Engine’s geometry system. This setting variable is primarily used for debugging and performance testing purposes.

This setting variable is used within the MeshModelingToolset plugin, specifically in the ModelingComponents module. It affects the behavior of the MeshSceneAdapter class, which is responsible for managing and processing mesh data in the scene.

The value of this variable is set through a console variable (CVar) named CVarMeshSceneAdapterDisableMultiThreading. It is initialized with a default value of 0, meaning multi-threading is enabled by default.

The associated variable CVarMeshSceneAdapterDisableMultiThreading directly interacts with this setting. It is used to retrieve the current value of the setting and determine whether to use single-threaded or multi-threaded processing in the MeshSceneAdapter.

Developers must be aware that changing this variable will impact the performance of mesh processing operations. Setting it to a non-zero value will force single-threaded execution, which may be slower but can be useful for debugging or isolating issues related to multi-threading.

Best practices when using this variable include:

  1. Leave it at the default value (0) for normal operation to benefit from multi-threading performance.
  2. Use it temporarily for debugging purposes when investigating potential multi-threading issues.
  3. Be cautious about setting it to a non-zero value in production environments, as it may negatively impact performance.

Regarding the associated variable CVarMeshSceneAdapterDisableMultiThreading:

This is an internal variable of type TAutoConsoleVariable that directly controls the behavior defined by the geometry.MeshSceneAdapter.SingleThreaded setting. It is used in the C++ code to determine whether to use single-threaded or multi-threaded processing in various parts of the MeshSceneAdapter implementation.

The variable is checked in multiple places within the MeshSceneAdapter code, such as in the Build_FullDecompose and ParallelMeshVertexEnumeration functions. When its value is non-zero, it forces single-threaded execution of certain operations.

Developers should not interact with this variable directly but instead use the console command or project settings to modify the geometry.MeshSceneAdapter.SingleThreaded value. The CVarMeshSceneAdapterDisableMultiThreading variable automatically reflects the changes made to the setting.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Private/Scene/MeshSceneAdapter.cpp:35

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarMeshSceneAdapterDisableMultiThreading(
	TEXT("geometry.MeshSceneAdapter.SingleThreaded"),
	0,
	TEXT("Determines whether or not to use multi-threading in MeshSceneAdapter.\n"));


namespace UE
{

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Private/Scene/MeshSceneAdapter.cpp:34

Scope: file

Source code excerpt:



static TAutoConsoleVariable<int32> CVarMeshSceneAdapterDisableMultiThreading(
	TEXT("geometry.MeshSceneAdapter.SingleThreaded"),
	0,
	TEXT("Determines whether or not to use multi-threading in MeshSceneAdapter.\n"));


namespace UE

#Loc: <Workspace>/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Private/Scene/MeshSceneAdapter.cpp:1658

Scope (from outer to inner):

file
function     void FMeshSceneAdapter::Build_FullDecompose

Source code excerpt:

void FMeshSceneAdapter::Build_FullDecompose(const FMeshSceneAdapterBuildOptions& BuildOptions)
{
	EParallelForFlags ParallelFlags = (CVarMeshSceneAdapterDisableMultiThreading.GetValueOnAnyThread() != 0) ?
		EParallelForFlags::ForceSingleThread : EParallelForFlags::Unbalanced;

	bool bCanUseCompressedMeshes = (BuildOptions.bEnableUVQueries == false && BuildOptions.bEnableNormalsQueries == false);

	// initial list of spatial wrappers that need to be built
	TArray<FSpatialWrapperInfo*> ToBuild;

#Loc: <Workspace>/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Private/Scene/MeshSceneAdapter.cpp:2611

Scope (from outer to inner):

file
function     void FMeshSceneAdapter::ParallelMeshVertexEnumeration

Source code excerpt:

	}

	bool bSingleThread = bForceSingleThreaded || (CVarMeshSceneAdapterDisableMultiThreading.GetValueOnAnyThread() != 0);

	ParallelFor(N, [&](int32 Index)
	{
		const FSpatialCacheInfo& CacheInfo = SortedSpatials[Index];

		bool bContinue = MeshFilterFunc(Index, CacheInfo.Actor->SourceActor, CacheInfo.ChildMesh, CacheInfo.Bounds);