landscape.EditLayersLocalMerge.MaxComponentsPerWeightmapResolveBatch

landscape.EditLayersLocalMerge.MaxComponentsPerWeightmapResolveBatch

#Overview

name: landscape.EditLayersLocalMerge.MaxComponentsPerWeightmapResolveBatch

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 landscape.EditLayersLocalMerge.MaxComponentsPerWeightmapResolveBatch is to control the number of landscape components that can be rendered in a single batch when resolving weightmaps in the Unreal Engine 5 landscape system.

This setting variable is primarily used by the Landscape module, specifically in the context of editing landscape layers and merging weightmaps.

The value of this variable is set through a console variable (CVar) named CVarLandscapeEditLayersMaxComponentsPerWeightmapResolveBatch. It is initialized with a default value of 16, but can be changed at runtime through the console or configuration files.

The associated variable CVarLandscapeEditLayersMaxComponentsPerWeightmapResolveBatch directly interacts with this setting. It’s a TAutoConsoleVariable that stores and provides access to the actual value.

Developers must be aware that increasing this value will allow more weightmaps to be resolved in a single batch, which can potentially improve performance. However, it also increases GPU memory consumption as more transient textures will be needed in memory at a time.

Best practices when using this variable include:

  1. Carefully balancing performance gains against increased memory usage.
  2. Testing different values to find the optimal setting for specific hardware configurations.
  3. Considering the complexity and size of the landscape when adjusting this value.
  4. Monitoring GPU memory usage when increasing this value to ensure it doesn’t lead to memory issues.

Regarding the associated variable CVarLandscapeEditLayersMaxComponentsPerWeightmapResolveBatch:

The purpose of this variable is to provide a programmatic way to access and modify the landscape.EditLayersLocalMerge.MaxComponentsPerWeightmapResolveBatch setting within the engine’s C++ code.

This variable is used in the Landscape module, specifically in the landscape layer editing and weightmap merging processes.

The value of this variable is set when the engine initializes the console variables, but can be changed at runtime using console commands.

It directly interacts with the landscape.EditLayersLocalMerge.MaxComponentsPerWeightmapResolveBatch setting, essentially serving as its in-code representation.

Developers should be aware that changes to this variable will immediately affect the landscape weightmap resolution process. It’s accessed in performance-critical code, so frequent changes during runtime should be avoided.

Best practices for using this variable include:

  1. Using GetValueOnGameThread() when accessing the value, as shown in the provided code snippet.
  2. Considering caching the value if it’s accessed frequently in performance-critical sections.
  3. Being cautious about changing the value during runtime, as it could impact performance and memory usage.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp:223

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarLandscapeEditLayersMaxComponentsPerWeightmapResolveBatch(
	TEXT("landscape.EditLayersLocalMerge.MaxComponentsPerWeightmapResolveBatch"),
	16,
	TEXT("Number of components being rendered in a single batch when resolving weightmaps. The higher the number, the more weightmaps can be resolved in a single batch (and the higher the GPU memory consumption since more transient textures will be needed in memory at a time)"),
	ECVF_RenderThreadSafe);

struct FLandscapeDirty
{

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp:222

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

TAutoConsoleVariable<int32> CVarLandscapeEditLayersMaxComponentsPerWeightmapResolveBatch(
	TEXT("landscape.EditLayersLocalMerge.MaxComponentsPerWeightmapResolveBatch"),
	16,
	TEXT("Number of components being rendered in a single batch when resolving weightmaps. The higher the number, the more weightmaps can be resolved in a single batch (and the higher the GPU memory consumption since more transient textures will be needed in memory at a time)"),
	ECVF_RenderThreadSafe);

struct FLandscapeDirty

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp:6955

Scope (from outer to inner):

file
function     void ALandscape::PrepareLayersWeightmapsLocalMergeRenderThreadData

Source code excerpt:

		TRACE_CPUPROFILER_EVENT_SCOPE(LandscapeLayers_PrepareWeightmapTextureResolveInfoBatches);

		int32 MaxComponentsPerResolveBatch = CVarLandscapeEditLayersMaxComponentsPerWeightmapResolveBatch.GetValueOnGameThread();

		// Copy the texture infos because TextureToResolveInfos indices need to remain stable at this point :
		TArray<FTextureResolveInfo> RemainingTextureToResolveInfos = OutRenderThreadData.TextureToResolveInfos;
		if (!RemainingTextureToResolveInfos.IsEmpty())
		{
			TBitArray<TInlineAllocator<1>> TempBitArray;