Slate.InvalidationList.EnableReindexLayerId

Slate.InvalidationList.EnableReindexLayerId

#Overview

name: Slate.InvalidationList.EnableReindexLayerId

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 Slate.InvalidationList.EnableReindexLayerId is to control the behavior of the Slate invalidation system when a painted widget returns a larger LayerId than it previously used. This setting is part of the Slate UI framework in Unreal Engine 5.

This setting variable is primarily used in the SlateCore module, specifically within the invalidation system of the Slate UI framework. It’s referenced in the SlateInvalidationRoot.cpp file, which is part of the fast update mechanism for Slate.

The value of this variable is set through the Unreal Engine console variable system. It’s defined as a boolean flag (GSlateInvalidationEnableReindexLayerId) and linked to the console variable “Slate.InvalidationList.EnableReindexLayerId” using FAutoConsoleVariableRef.

The associated variable GSlateInvalidationEnableReindexLayerId directly interacts with this setting. They share the same value, with GSlateInvalidationEnableReindexLayerId being the actual boolean flag used in the code logic.

Developers should be aware that when this setting is enabled, it affects the behavior of the Slate invalidation system. Specifically, it causes the system to re-index other widgets when a painted widget returns a larger LayerId than it previously used. This can impact performance and the order in which UI elements are rendered.

Best practices when using this variable include:

  1. Only enable it when necessary, as it may have performance implications.
  2. Test thoroughly when enabling or disabling this feature to ensure it doesn’t negatively impact your UI’s behavior or performance.
  3. Use it in conjunction with profiling tools to understand its impact on your specific use case.

Regarding the associated variable GSlateInvalidationEnableReindexLayerId:

The purpose of GSlateInvalidationEnableReindexLayerId is to serve as the actual boolean flag that controls the re-indexing behavior in the code logic. It’s directly used in conditional statements within the Slate invalidation system.

This variable is used in the SlateCore module, specifically in the FSlateInvalidationRoot class’s PaintFastPath_UpdateNextWidget function. It determines whether to perform a LayerId fixup operation when a widget paints more elements than it previously had.

The value of GSlateInvalidationEnableReindexLayerId is set through the console variable system, linked to “Slate.InvalidationList.EnableReindexLayerId”.

Developers should be aware that this variable directly affects the behavior of the Slate invalidation system’s fast path painting process. When true, it triggers additional processing to fix up LayerIds, which could impact performance.

Best practices for using GSlateInvalidationEnableReindexLayerId include:

  1. Consider the performance implications when enabling this flag, especially for complex UIs.
  2. Use it in development and testing environments to diagnose LayerId-related issues.
  3. Monitor its impact on frame times and overall UI performance when enabled.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/FastUpdate/SlateInvalidationRoot.cpp:159

Scope: file

Source code excerpt:

bool GSlateInvalidationEnableReindexLayerId = false;
FAutoConsoleVariableRef CVarSlateInvalidationEnableReindexLayerId(
	TEXT("Slate.InvalidationList.EnableReindexLayerId"),
	GSlateInvalidationEnableReindexLayerId,
	TEXT("With invalidation system, when a painted widget returns a bigger LayerId that it used to, re-index the other widgets."));

/**
 *
 */

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/FastUpdate/SlateInvalidationRoot.cpp:157

Scope: file

Source code excerpt:

	TEXT("With the invalidation system, when splitting, only split the array when the number of element left is under X."));

bool GSlateInvalidationEnableReindexLayerId = false;
FAutoConsoleVariableRef CVarSlateInvalidationEnableReindexLayerId(
	TEXT("Slate.InvalidationList.EnableReindexLayerId"),
	GSlateInvalidationEnableReindexLayerId,
	TEXT("With invalidation system, when a painted widget returns a bigger LayerId that it used to, re-index the other widgets."));

/**
 *
 */
 namespace Slate

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/FastUpdate/SlateInvalidationRoot.cpp:682

Scope (from outer to inner):

file
function     bool FSlateInvalidationRoot::PaintFastPath_UpdateNextWidget

Source code excerpt:


			// Did it painted more elements than it previously had
			if (UpdateResult.NewOutgoingLayerId > UpdateResult.PreviousOutgoingLayerId && GSlateInvalidationEnableReindexLayerId)
			{
				if (InvalidationWidget.Visibility.IsVisible() && WidgetPtr)
				{
					PaintFastPath_FixupLayerId(FastPaintContext, InvalidationWidget, UpdateResult.NewOutgoingLayerId);
				}
			}