Slate.CopyBackbufferToSlatePostRenderTargets
Slate.CopyBackbufferToSlatePostRenderTargets
#Overview
name: Slate.CopyBackbufferToSlatePostRenderTargets
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Experimental. Set true to copy final backbuffer into slate RTs for slate post processing / material usage
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of Slate.CopyBackbufferToSlatePostRenderTargets is to enable copying the final backbuffer into Slate render targets for post-processing and material usage in the Slate UI system. This is an experimental feature that affects the rendering pipeline of Unreal Engine’s user interface system.
This setting variable is primarily used in the SlateRHIRenderer module, which is responsible for rendering Slate UI elements using the RHI (Rendering Hardware Interface). Based on the callsites, it’s clear that this variable is utilized in the FSlateRHIRenderer class, which is a core component of the Slate rendering system.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0 (disabled) and can be changed at runtime using console commands or through engine configuration files.
The associated variable CVarCopyBackbufferToSlatePostRenderTargets interacts directly with this setting. It’s the actual TAutoConsoleVariable object that stores and manages the value of the setting.
Developers must be aware of several important aspects when using this variable:
- It’s marked as experimental, indicating that it may not be fully stable or optimized.
- It affects performance, as it involves an additional copy operation of the backbuffer.
- It’s render thread safe, meaning it can be accessed from both game and render threads.
- It’s primarily intended for advanced UI effects and may not be necessary for most projects.
Best practices when using this variable include:
- Only enable it when necessary for specific UI post-processing or material effects.
- Monitor performance impact when enabled, especially on lower-end hardware.
- Use it in conjunction with USlateRHIRendererSettings for managing the post-processing render targets.
- Be cautious when modifying its value at runtime, as it can affect ongoing rendering operations.
Regarding the associated variable CVarCopyBackbufferToSlatePostRenderTargets:
This is the actual console variable object that controls the behavior described by Slate.CopyBackbufferToSlatePostRenderTargets. It’s used internally by the engine to query the current state of the setting and determine whether to perform the backbuffer copy operation.
The FSlateRHIRenderer class uses this variable in several key areas:
- In the GetProcessSlatePostBuffers() method to determine if post-processing buffers should be used.
- In the DrawWindows_Private() method to decide whether to update Slate post buffers and handle resource updates for these buffers.
Developers should interact with this setting primarily through the console variable system rather than accessing CVarCopyBackbufferToSlatePostRenderTargets directly in most cases. This ensures proper synchronization and thread-safety when modifying or querying the value.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:104
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarCopyBackbufferToSlatePostRenderTargets(
TEXT("Slate.CopyBackbufferToSlatePostRenderTargets"),
0,
TEXT("Experimental. Set true to copy final backbuffer into slate RTs for slate post processing / material usage"),
ECVF_RenderThreadSafe);
#if WITH_SLATE_VISUALIZERS
#Associated Variable and Callsites
This variable is associated with another variable named CVarCopyBackbufferToSlatePostRenderTargets
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:103
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarCopyBackbufferToSlatePostRenderTargets(
TEXT("Slate.CopyBackbufferToSlatePostRenderTargets"),
0,
TEXT("Experimental. Set true to copy final backbuffer into slate RTs for slate post processing / material usage"),
ECVF_RenderThreadSafe);
#if WITH_SLATE_VISUALIZERS
#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:287
Scope (from outer to inner):
file
function int32 FSlateRHIRenderer::GetProcessSlatePostBuffers
Source code excerpt:
int32 FSlateRHIRenderer::GetProcessSlatePostBuffers()
{
return CVarCopyBackbufferToSlatePostRenderTargets->GetInt();
}
bool FSlateRHIRenderer::Initialize()
{
LoadUsedTextures();
#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:1773
Scope (from outer to inner):
file
function void FSlateRHIRenderer::DrawWindows_Private
Source code excerpt:
// Update slate post buffers before slate draw if needed
if (CVarCopyBackbufferToSlatePostRenderTargets.GetValueOnAnyThread() && IsInGameThread() && GIsClient && !IsRunningCommandlet() && !GUsingNullRHI && UAssetManager::IsInitialized())
{
uint8 SlatePostBufferBitIndex = 0;
for (ESlatePostRT SlatePostBufferBit : TEnumRange<ESlatePostRT>())
{
// We only attempt to load if the buffer is enabled, so just try to load / get the buffer
UTextureRenderTarget2D* SlatePostBuffer = USlateRHIRendererSettings::GetMutable()->LoadGetPostBufferRT(SlatePostBufferBit);
#Loc: <Workspace>/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateRHIRenderer.cpp:1943
Scope (from outer to inner):
file
function void FSlateRHIRenderer::DrawWindows_Private
Source code excerpt:
// After we draw, if a resource is going to update a post buffer we need to add another render fence for that buffer
if (CVarCopyBackbufferToSlatePostRenderTargets.GetValueOnAnyThread())
{
uint8 SlatePostBufferBitIndex = 0;
for (ESlatePostRT SlatePostBufferBit : TEnumRange<ESlatePostRT>())
{
bool bResourceUpdatedPostBuffer = (ResourceUpdatingPostBufferBits & SlatePostBufferBit) != ESlatePostRT::None;
if (bResourceUpdatedPostBuffer)