r.RDG.ParallelDestruction

r.RDG.ParallelDestruction

#Overview

name: r.RDG.ParallelDestruction

This variable is created as a Console Variable (cvar).

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:

  1. This variable affects the performance and behavior of RDG destruction.
  2. It’s only effective when RDG_ENABLE_PARALLEL_TASKS is defined.
  3. The default value is 1, enabling asynchronous destruction.

Best practices when using this variable:

  1. Use asynchronous destruction (value 1) for better performance in most cases.
  2. 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.
  3. Profile your application with both settings to determine the best option for your specific use case.

Regarding the associated variable GRDGParallelDestruction:

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