r.bFlushRenderTargetsOnWorldCleanup
r.bFlushRenderTargetsOnWorldCleanup
#Overview
name: r.bFlushRenderTargetsOnWorldCleanup
This variable is created as a Console Variable (cvar).
- type:
Var
- help: ``
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.bFlushRenderTargetsOnWorldCleanup
is to control whether render targets should be flushed when a world cleanup occurs in Unreal Engine 5. This setting is primarily related to the rendering system and resource management.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, as evidenced by its use in the FRendererModule
class within the Renderer.cpp
file.
The value of this variable is set to 1 by default, as shown in the initialization of bFlushRenderTargetsOnWorldCleanup
. It can be modified at runtime through the console variable system, as it is registered with FAutoConsoleVariableRef
.
This variable interacts with bFlushRenderTargetsOnWorldCleanup
, which is the associated C++ variable that directly controls the behavior. They share the same value, with r.bFlushRenderTargetsOnWorldCleanup
being the console-accessible name.
Developers must be aware that this variable affects performance and memory usage. When enabled (set to a value greater than 0), it causes the engine to free unused render target resources during world cleanup, which can help manage memory but might impact performance if frequent world cleanups occur.
Best practices when using this variable include:
- Leaving it enabled (default value of 1) for most scenarios to ensure proper resource management.
- Consider disabling it (setting to 0) only if you’re experiencing performance issues during world cleanup and have confirmed that render target flushing is the bottleneck.
- Monitor memory usage and rendering performance when modifying this value, as it can have implications on both.
Regarding the associated variable bFlushRenderTargetsOnWorldCleanup
:
The purpose of bFlushRenderTargetsOnWorldCleanup
is to serve as the internal C++ representation of the r.bFlushRenderTargetsOnWorldCleanup
console variable. It directly controls the behavior of render target flushing during world cleanup.
This variable is used within the Renderer module, specifically in the FRendererModule::OnWorldCleanup
function.
The value of this variable is set initially to 1 and can be modified through the console variable system, affecting both this variable and its console counterpart.
It interacts with the GRenderTargetPool
global object, calling the FreeUnusedResources()
method when the variable is set to a value greater than 0.
Developers should be aware that this variable is checked during the world cleanup process and directly influences whether unused render target resources are freed.
Best practices for using this variable are the same as those for r.bFlushRenderTargetsOnWorldCleanup
, as they are essentially two representations of the same setting.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Renderer.cpp:61
Scope: file
Source code excerpt:
static int32 bFlushRenderTargetsOnWorldCleanup = 1;
FAutoConsoleVariableRef CVarFlushRenderTargetsOnWorldCleanup(TEXT("r.bFlushRenderTargetsOnWorldCleanup"), bFlushRenderTargetsOnWorldCleanup, TEXT(""));
void FRendererModule::StartupModule()
{
#if MESH_DRAW_COMMAND_STATS
#Associated Variable and Callsites
This variable is associated with another variable named bFlushRenderTargetsOnWorldCleanup
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Renderer.cpp:60
Scope: file
Source code excerpt:
#endif
static int32 bFlushRenderTargetsOnWorldCleanup = 1;
FAutoConsoleVariableRef CVarFlushRenderTargetsOnWorldCleanup(TEXT("r.bFlushRenderTargetsOnWorldCleanup"), bFlushRenderTargetsOnWorldCleanup, TEXT(""));
void FRendererModule::StartupModule()
{
#if MESH_DRAW_COMMAND_STATS
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/Renderer.cpp:137
Scope (from outer to inner):
file
function void FRendererModule::OnWorldCleanup
lambda-function
Source code excerpt:
[Scene, bWorldChanged](FRHICommandListImmediate& RHICmdList)
{
if(bFlushRenderTargetsOnWorldCleanup > 0)
{
GRenderTargetPool.FreeUnusedResources();
}
if(bWorldChanged && Scene)
{
Scene->OnWorldCleanup();