landscape.ForceFlush

landscape.ForceFlush

#Overview

name: landscape.ForceFlush

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.ForceFlush is to control the rendering behavior during landscape editing in Unreal Engine 5. Specifically, it forces a render flush every frame when landscape editing is in progress.

This setting variable is primarily used by the Landscape module within Unreal Engine 5. It’s part of the landscape editing system, which is responsible for modifying and rendering terrain in real-time.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0, which means the forced flush is disabled by default. Developers can change this value at runtime using console commands or through code.

The associated variable CVarLandscapeForceFlush directly interacts with landscape.ForceFlush. They share the same value and purpose.

Developers should be aware that enabling this feature (by setting it to a non-zero value) can have performance implications. Forcing a render flush every frame can potentially slow down the editing process, especially on less powerful hardware or with complex landscapes.

Best practices when using this variable include:

  1. Keep it disabled (0) for normal development to maintain optimal performance.
  2. Enable it temporarily when debugging rendering issues related to landscape editing.
  3. Consider enabling it in situations where immediate visual feedback of landscape edits is crucial, but be mindful of the performance cost.
  4. Use it in conjunction with other landscape debugging tools and variables for comprehensive troubleshooting.

Regarding the associated variable CVarLandscapeForceFlush:

This is the actual C++ variable that controls the behavior defined by landscape.ForceFlush. It’s an instance of TAutoConsoleVariable, which is Unreal Engine’s way of exposing settings to the console variable system.

CVarLandscapeForceFlush is used directly in the code to check whether forced flushing is enabled. For example, in the UpdateLayersContent function of the ALandscape class, it’s checked with GetValueOnGameThread() to determine if immediate texture readback should occur after rendering.

Developers interacting with the landscape system through C++ code should use CVarLandscapeForceFlush.GetValueOnGameThread() to check the current state of this setting, rather than trying to access landscape.ForceFlush directly.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarLandscapeForceFlush(
	TEXT("landscape.ForceFlush"),
	0,
	TEXT("This will force a render flush every frame when landscape editing."));

TAutoConsoleVariable<int32> CVarLandscapeValidateProxyWeightmapUsages(
	TEXT("landscape.ValidateProxyWeightmapUsages"),
	1,

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	TEXT("This will track the accumulation of data changes during the layer blend phase."));

TAutoConsoleVariable<int32> CVarLandscapeForceFlush(
	TEXT("landscape.ForceFlush"),
	0,
	TEXT("This will force a render flush every frame when landscape editing."));

TAutoConsoleVariable<int32> CVarLandscapeValidateProxyWeightmapUsages(
	TEXT("landscape.ValidateProxyWeightmapUsages"),

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

Scope (from outer to inner):

file
function     void ALandscape::UpdateLayersContent

Source code excerpt:


	// If we are flushing then read back resolved textures immediately
	if (bFlushRender || CVarLandscapeForceFlush.GetValueOnGameThread() != 0)
	{
		const bool bDoFlushRender = true;
		ResolveLayersHeightmapTexture(UpdateLayersContentContext.MapHelper, UpdateLayersContentContext.HeightmapsToResolve, bIntermediateRender, bDoFlushRender, UpdateLayersContentContext.AllLandscapeComponentReadbackResults);
		ResolveLayersWeightmapTexture(UpdateLayersContentContext.MapHelper, UpdateLayersContentContext.WeightmapsToResolve, bIntermediateRender, bDoFlushRender, UpdateLayersContentContext.AllLandscapeComponentReadbackResults);
	}