Slate.MemorylessDepthStencil
Slate.MemorylessDepthStencil
#Overview
name: Slate.MemorylessDepthStencil
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether to use memoryless DepthStencil target for Slate. Reduces memory usage and implies that DepthStencil state can\'t be preserved between Slate renderpasses
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of Slate.MemorylessDepthStencil is to control whether Slate, Unreal Engine’s UI framework, uses a memoryless depth-stencil target. This setting is primarily related to the rendering system, specifically for UI rendering optimization.
This setting variable is used within the SlateRHIRenderer module, which is responsible for rendering Slate UI elements using the RHI (Rendering Hardware Interface).
The value of this variable is set through a console variable (CVarMemorylessDepthStencil), which allows runtime configuration. It’s initialized with a default value of 0, meaning memoryless depth-stencil is disabled by default.
The associated variable CVarMemorylessDepthStencil directly interacts with Slate.MemorylessDepthStencil. They share the same value and purpose.
Developers must be aware that enabling this setting (setting it to a non-zero value) reduces memory usage but implies that the depth-stencil state cannot be preserved between Slate render passes. This trade-off between memory usage and state preservation is crucial to understand when optimizing UI rendering.
Best practices when using this variable include:
- Only enable it when memory optimization is critical and the loss of depth-stencil state between render passes is acceptable.
- Test thoroughly after enabling to ensure no unexpected visual artifacts occur in the UI.
- Consider the target hardware capabilities, as memoryless textures may not be supported on all platforms.
Regarding the associated variable CVarMemorylessDepthStencil:
Its purpose is identical to Slate.MemorylessDepthStencil - it controls the use of memoryless depth-stencil targets in Slate rendering.
This variable is used in the SlateRHIRenderer module, specifically in the FViewportInfo class methods.
The value is set through the console variable system, allowing for runtime configuration.
It directly interacts with the Slate.MemorylessDepthStencil setting, as they share the same value.
Developers should be aware that this variable is checked in the rendering thread, so changes may not take effect immediately.
Best practices include:
- Use this variable for fine-tuning rendering performance in development and testing.
- Document any performance impacts observed when enabling or disabling this feature.
- Consider exposing this setting in a user-friendly manner for advanced users or developers to adjust based on their specific needs.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:98
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarMemorylessDepthStencil(
TEXT("Slate.MemorylessDepthStencil"),
0,
TEXT("Whether to use memoryless DepthStencil target for Slate. Reduces memory usage and implies that DepthStencil state can't be preserved between Slate renderpasses"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarCopyBackbufferToSlatePostRenderTargets(
TEXT("Slate.CopyBackbufferToSlatePostRenderTargets"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarMemorylessDepthStencil
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:97
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarMemorylessDepthStencil(
TEXT("Slate.MemorylessDepthStencil"),
0,
TEXT("Whether to use memoryless DepthStencil target for Slate. Reduces memory usage and implies that DepthStencil state can't be preserved between Slate renderpasses"),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarCopyBackbufferToSlatePostRenderTargets(
#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:176
Scope (from outer to inner):
file
function void FViewportInfo::ConditionallyUpdateDepthBuffer
Source code excerpt:
check(IsInRenderingThread());
bool bWantsMemorylessDepthStencil = (CVarMemorylessDepthStencil.GetValueOnAnyThread() != 0);
bool bDepthStencilStale =
bInRequiresStencilTest &&
(!bRequiresStencilTest ||
(DepthStencil.IsValid() && (DepthStencil->GetSizeX() != InWidth || DepthStencil->GetSizeY() != InHeight || IsMemorylessTexture(DepthStencil) != bWantsMemorylessDepthStencil)));
#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:199
Scope (from outer to inner):
file
function void FViewportInfo::RecreateDepthBuffer_RenderThread
Source code excerpt:
{
ETextureCreateFlags TargetableTextureFlags = TexCreate_DepthStencilTargetable;
if (CVarMemorylessDepthStencil.GetValueOnAnyThread() != 0)
{
// Use Memoryless target, expecting that DepthStencil content is intermediate and can't be preserved between renderpasses
TargetableTextureFlags|= TexCreate_Memoryless;
}
const FRHITextureCreateDesc Desc =