Slate.EnableRetainedRendering

Slate.EnableRetainedRendering

#Overview

name: Slate.EnableRetainedRendering

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.EnableRetainedRendering is to control whether SRetainerWidgets should attempt to render their content to render targets first. This setting is primarily used for optimizing UI rendering in the Unreal Engine’s Slate UI framework.

This setting variable is primarily used in the UMG (Unreal Motion Graphics) module, which is responsible for creating and managing user interfaces in Unreal Engine. Specifically, it affects the behavior of SRetainerWidget, a Slate widget that can cache its content for performance optimization.

The value of this variable is set through an FAutoConsoleVariableRef, which means it can be changed at runtime through console commands or configuration files. By default, it is set to 1 (enabled).

The associated variable GEnableRetainedRendering directly interacts with Slate.EnableRetainedRendering. They share the same value, and GEnableRetainedRendering is used in the C++ code to check if retained rendering is enabled.

Developers should be aware that:

  1. Enabling retained rendering can improve performance for complex UI layouts that don’t change frequently.
  2. However, it may increase memory usage due to the creation of render targets.
  3. Changes to this setting will affect all SRetainerWidgets in the application.

Best practices when using this variable include:

  1. Enable it for UI elements that are complex but relatively static.
  2. Consider disabling it for frequently changing UI elements or on platforms with limited memory.
  3. Profile your application’s performance and memory usage with this setting both enabled and disabled to determine the optimal configuration for your specific use case.

Regarding the associated variable GEnableRetainedRendering: The purpose of GEnableRetainedRendering is to provide a C++ accessible boolean flag that reflects the state of Slate.EnableRetainedRendering. It is used internally by the UMG module to determine whether retained rendering should be applied.

GEnableRetainedRendering is set directly by the FAutoConsoleVariableRef associated with Slate.EnableRetainedRendering. It is primarily used in the IsRetainedRenderingEnabled() function, which serves as a convenient way to check if retained rendering is enabled throughout the codebase.

Developers should be aware that modifying GEnableRetainedRendering directly is not recommended, as it may get overwritten by changes to Slate.EnableRetainedRendering. Instead, they should always use the console variable to modify this setting.

Best practices for GEnableRetainedRendering include using the IsRetainedRenderingEnabled() function to check the state of retained rendering, rather than accessing GEnableRetainedRendering directly. This provides a layer of abstraction and allows for potential future changes to how the enabled state is determined.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/UMG/Private/Slate/SRetainerWidget.cpp:36

Scope: file

Source code excerpt:

int32 GEnableRetainedRendering = 1;
FAutoConsoleVariableRef EnableRetainedRendering(
	TEXT("Slate.EnableRetainedRendering"),
	GEnableRetainedRendering,
	TEXT("Whether to attempt to render things in SRetainerWidgets to render targets first.") 
);

/** True if we allow the transform to be modify to render in local space. */
bool GSlateEnableRenderWithLocalTransform = true;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/UMG/Private/Slate/SRetainerWidget.cpp:34

Scope: file

Source code excerpt:


/** True if we should allow widgets to be cached in the UI at all. */
int32 GEnableRetainedRendering = 1;
FAutoConsoleVariableRef EnableRetainedRendering(
	TEXT("Slate.EnableRetainedRendering"),
	GEnableRetainedRendering,
	TEXT("Whether to attempt to render things in SRetainerWidgets to render targets first.") 
);

/** True if we allow the transform to be modify to render in local space. */
bool GSlateEnableRenderWithLocalTransform = true;
FAutoConsoleVariableRef CVarGlateEnableRenderWithLocalTransform(

#Loc: <Workspace>/Engine/Source/Runtime/UMG/Private/Slate/SRetainerWidget.cpp:51

Scope (from outer to inner):

file
function     static bool IsRetainedRenderingEnabled

Source code excerpt:

static bool IsRetainedRenderingEnabled()
{
	return GEnableRetainedRendering != 0;
}

/** Whether or not the platform should have deferred retainer widget render target updating enabled by default */
#define PLATFORM_REQUIRES_DEFERRED_RETAINER_UPDATE PLATFORM_IOS || PLATFORM_ANDROID;

/**