r.RDG.ParallelDestruction
r.RDG.ParallelDestruction
#Overview
name: r.RDG.ParallelDestruction
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
RDG will destruct the graph using an async task. 0: graph destruction is done synchronously; 1: graph destruction may be done asynchronously (default);
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RDG.ParallelDestruction is to control whether the Render Dependency Graph (RDG) destruction is performed asynchronously or synchronously. This setting is part of the rendering system in Unreal Engine 5, specifically related to the RDG subsystem.
The Render Dependency Graph module relies on this setting variable. It is used in the RenderCore runtime module, as evident from the file paths in the callsites.
The value of this variable is set through a console variable (CVar) named “r.RDG.ParallelDestruction”. It can be changed at runtime using console commands or through configuration files.
The associated variable GRDGParallelDestruction interacts directly with r.RDG.ParallelDestruction. They share the same value, with GRDGParallelDestruction being the actual integer variable used in the code.
Developers must be aware that:
- This variable affects the performance and behavior of RDG destruction.
- It’s only effective when RDG_ENABLE_PARALLEL_TASKS is defined.
- The default value is 1, enabling asynchronous destruction.
Best practices when using this variable:
- Use asynchronous destruction (value 1) for better performance in most cases.
- Consider switching to synchronous destruction (value 0) if you encounter any issues related to resource cleanup or if you need deterministic behavior in certain scenarios.
- Profile your application with both settings to determine the best option for your specific use case.
Regarding the associated variable GRDGParallelDestruction:
- It’s the actual integer variable used in the code to control the behavior.
- It’s used in the FRDGBuilder destructor to determine whether to use asynchronous deletion.
- It’s defined as an external variable in the header file, allowing it to be accessed across different source files within the RenderCore module.
- When RDG_ENABLE_PARALLEL_TASKS is not defined, it’s set as a constant 0, disabling parallel destruction.
Developers should be aware that changing r.RDG.ParallelDestruction will directly affect the value of GRDGParallelDestruction and, consequently, the behavior of the RDG destruction process.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.cpp:337
Scope: file
Source code excerpt:
int32 GRDGParallelDestruction = 1;
FAutoConsoleVariableRef CVarRDGParallelDestruction(
TEXT("r.RDG.ParallelDestruction"), GRDGParallelDestruction,
TEXT("RDG will destruct the graph using an async task.")
TEXT(" 0: graph destruction is done synchronously;")
TEXT(" 1: graph destruction may be done asynchronously (default);"),
ECVF_RenderThreadSafe);
int32 GRDGParallelSetup = 1;
#Associated Variable and Callsites
This variable is associated with another variable named GRDGParallelDestruction
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphBuilder.cpp:593
Scope (from outer to inner):
file
function FRDGBuilder::~FRDGBuilder
Source code excerpt:
FRDGBuilder::~FRDGBuilder()
{
if (ParallelExecute.bEnabled && GRDGParallelDestruction > 0)
{
AsyncDeleter.Function = [
Allocators = MoveTemp(Allocators),
Passes = MoveTemp(Passes),
Textures = MoveTemp(Textures),
Buffers = MoveTemp(Buffers),
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.cpp:335
Scope: file
Source code excerpt:
#if RDG_ENABLE_PARALLEL_TASKS
int32 GRDGParallelDestruction = 1;
FAutoConsoleVariableRef CVarRDGParallelDestruction(
TEXT("r.RDG.ParallelDestruction"), GRDGParallelDestruction,
TEXT("RDG will destruct the graph using an async task.")
TEXT(" 0: graph destruction is done synchronously;")
TEXT(" 1: graph destruction may be done asynchronously (default);"),
ECVF_RenderThreadSafe);
int32 GRDGParallelSetup = 1;
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.h:119
Scope: file
Source code excerpt:
#if RDG_ENABLE_PARALLEL_TASKS
extern int32 GRDGParallelDestruction;
extern int32 GRDGParallelSetup;
extern int32 GRDGParallelExecute;
extern int32 GRDGParallelExecutePassMin;
extern int32 GRDGParallelExecutePassMax;
#else
const int32 GRDGParallelDestruction = 0;
const int32 GRDGParallelSetup = 0;
const int32 GRDGParallelExecute = 0;
const int32 GRDGParallelExecutePassMin = 0;
const int32 GRDGParallelExecutePassMax = 0;
#endif