Slate.AlwaysInvalidate

Slate.AlwaysInvalidate

#Overview

name: Slate.AlwaysInvalidate

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 Slate.AlwaysInvalidate is to force invalidation panels to always invalidate their cache, even when caching is enabled. This setting is primarily used for debugging and performance testing in the Slate UI system of Unreal Engine.

The Slate UI subsystem within Unreal Engine relies on this setting variable. It is specifically used in the SInvalidationPanel widget, which is part of the Slate module.

The value of this variable is set through a console variable (CVar) named “Slate.AlwaysInvalidate”. It is defined using FAutoConsoleVariableRef, which allows it to be changed at runtime through console commands or configuration files.

The Slate.AlwaysInvalidate variable interacts directly with a boolean variable named bAlwaysInvalidate. They share the same value, and bAlwaysInvalidate is used in the actual code logic.

Developers must be aware that this variable is only available when WITH_SLATE_DEBUGGING is defined. It’s intended for debugging purposes and should not be relied upon in production code. Enabling this setting can have a significant impact on performance, as it forces all invalidation panels to recache their content every frame.

Best practices when using this variable include:

  1. Only enable it during debugging or performance testing sessions.
  2. Be aware of the performance implications when enabled.
  3. Use it in conjunction with other Slate debugging tools to isolate UI-related issues.

Regarding the associated variable bAlwaysInvalidate:

The purpose of bAlwaysInvalidate is to act as the actual boolean flag that controls the always-invalidate behavior within the code.

It is used in the Slate module, specifically within the SInvalidationPanel class, to determine whether the panel should always invalidate its cache.

The value of bAlwaysInvalidate is set by the Slate.AlwaysInvalidate console variable.

This variable interacts with the caching mechanism of SInvalidationPanel and affects the UpdateCachePrequisites function.

Developers should be aware that bAlwaysInvalidate is a static variable and its state affects all instances of SInvalidationPanel when enabled.

Best practices for using bAlwaysInvalidate include:

  1. Do not modify it directly in code; instead, use the Slate.AlwaysInvalidate console variable.
  2. Be cautious when using it in performance-critical sections, as it can lead to unnecessary recomputation of UI elements.
  3. Consider using it temporarily for debugging and then disabling it for normal operation.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Widgets/SInvalidationPanel.cpp:29

Scope: file

Source code excerpt:

static bool bAlwaysInvalidate = false;
FAutoConsoleVariableRef CVarAlwaysInvalidate(
	TEXT("Slate.AlwaysInvalidate"),
	bAlwaysInvalidate,
	TEXT("Forces invalidation panels to cache, but to always invalidate."));

#endif // WITH_SLATE_DEBUGGING

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/MovieScene/Public/EntitySystem/MovieSceneOverlappingEntityTracker.h:420

Scope (from outer to inner):

file
namespace    UE
namespace    MovieScene
function     uint16 MakeOutput

Source code excerpt:

	}

	uint16 MakeOutput(FMovieSceneEntityID EntityID, ParamType InKey, bool bAlwaysInvalidate)
	{
		const uint16 PreviousOutputIndex = FindOutputByEntity(EntityID);
		const uint16 DesiredOutputIndex  = CreateOutputByKey(InKey);

		if (PreviousOutputIndex == DesiredOutputIndex)
		{
			if (bAlwaysInvalidate)
			{
				// Previous output is now invalidated since we're removing this entity
				InvalidatedOutputs.PadToNum(DesiredOutputIndex + 1, false);
				InvalidatedOutputs[DesiredOutputIndex] = true;
			}

#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Widgets/SInvalidationPanel.cpp:27

Scope: file

Source code excerpt:

#if WITH_SLATE_DEBUGGING

static bool bAlwaysInvalidate = false;
FAutoConsoleVariableRef CVarAlwaysInvalidate(
	TEXT("Slate.AlwaysInvalidate"),
	bAlwaysInvalidate,
	TEXT("Forces invalidation panels to cache, but to always invalidate."));

#endif // WITH_SLATE_DEBUGGING

#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Widgets/SInvalidationPanel.cpp:128

Scope (from outer to inner):

file
function     bool SInvalidationPanel::UpdateCachePrequisites

Source code excerpt:


#if WITH_SLATE_DEBUGGING
	bNeedsRecache = bAlwaysInvalidate;
#endif

	// We only need to re-cache if the incoming layer is higher than the maximum layer Id we cached at,
	// we do this so that widgets that appear and live behind your invalidated UI don't constantly invalidate
	// everything above it.
	if (LayerId > LastIncomingLayerId)