r.RDG.MergeRenderPasses

r.RDG.MergeRenderPasses

#Overview

name: r.RDG.MergeRenderPasses

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.RDG.MergeRenderPasses is to control the merging of identical, contiguous render passes in the Render Dependency Graph (RDG) system of Unreal Engine 5. This setting is part of the rendering optimization system.

This setting variable is primarily used in the RenderCore module of Unreal Engine 5, specifically within the Render Dependency Graph (RDG) subsystem. The RDG is a crucial part of UE5’s rendering pipeline, responsible for managing render passes and optimizing rendering performance.

The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 1 (enabled) but can be changed at runtime through console commands or through the command line arguments when launching the engine.

The associated variable GRDGMergeRenderPasses directly interacts with r.RDG.MergeRenderPasses. They share the same value, with GRDGMergeRenderPasses being the internal representation used in the C++ code.

Developers must be aware that this setting can significantly impact rendering performance and visual output. When enabled (default), it allows the engine to optimize render passes by merging identical, contiguous ones. This can potentially improve performance but might affect certain rendering techniques that rely on specific pass ordering.

Best practices when using this variable include:

  1. Leave it enabled (default) for most scenarios to benefit from rendering optimizations.
  2. If experiencing unexpected visual artifacts or performance issues in specific rendering scenarios, try disabling it for debugging purposes.
  3. When developing custom rendering features, be aware of this optimization and design your render passes with potential merging in mind.
  4. Use the command line option “rdgmergerenderpasses” to override the default setting when necessary for testing or specific use cases.

Regarding the associated variable GRDGMergeRenderPasses: The purpose of GRDGMergeRenderPasses is to serve as the internal C++ representation of the r.RDG.MergeRenderPasses setting. It’s used directly in the engine’s C++ code to control the render pass merging behavior.

This variable is used in the RenderCore module, specifically within the RDG system. It’s checked in various parts of the RDG implementation to determine whether render pass merging should be performed.

The value of GRDGMergeRenderPasses is set in multiple ways:

  1. It’s initialized to 1 by default.
  2. It can be modified through the console variable system via r.RDG.MergeRenderPasses.
  3. It can be set through command line arguments using “rdgmergerenderpasses=”.

GRDGMergeRenderPasses interacts directly with r.RDG.MergeRenderPasses, as they share the same value. It’s also used in conjunction with other RDG-related variables like GRDGAsyncCompute and GRDGCullPasses.

Developers should be aware that modifying GRDGMergeRenderPasses directly in C++ code is not recommended. Instead, they should use the console variable system or command line arguments to change this setting.

Best practices for using GRDGMergeRenderPasses include:

  1. Avoid modifying it directly in C++ code; use the console variable system instead.
  2. When implementing custom rendering features that interact with the RDG system, check this variable to ensure compatibility with the current render pass merging state.
  3. Use the IsRenderPassMergeEnabled() function provided in the RDG system to check if merging is currently enabled, as it also considers other factors like the immediate mode state.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.cpp:296

Scope: file

Source code excerpt:

int32 GRDGMergeRenderPasses = 1;
FAutoConsoleVariableRef CVarRDGMergeRenderPasses(
	TEXT("r.RDG.MergeRenderPasses"),
	GRDGMergeRenderPasses,
	TEXT("The graph will merge identical, contiguous render passes into a single render pass.\n")
	TEXT(" 0:off;\n")
	TEXT(" 1:on(default);\n"),
	ECVF_RenderThreadSafe);

#Associated Variable and Callsites

This variable is associated with another variable named GRDGMergeRenderPasses. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.cpp:294

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

int32 GRDGMergeRenderPasses = 1;
FAutoConsoleVariableRef CVarRDGMergeRenderPasses(
	TEXT("r.RDG.MergeRenderPasses"),
	GRDGMergeRenderPasses,
	TEXT("The graph will merge identical, contiguous render passes into a single render pass.\n")
	TEXT(" 0:off;\n")
	TEXT(" 1:on(default);\n"),
	ECVF_RenderThreadSafe);

int32 GRDGTransientAllocator = 1;

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.cpp:608

Scope (from outer to inner):

file
function     void InitRenderGraph

Source code excerpt:

	if (FParse::Value(FCommandLine::Get(), TEXT("rdgmergerenderpasses="), MergeRenderPassesValue))
	{
		GRDGMergeRenderPasses = MergeRenderPassesValue;
	}

	int32 AsyncComputeValue = 0;
	if (FParse::Value(FCommandLine::Get(), TEXT("rdgasynccompute="), AsyncComputeValue))
	{
		CVarRDGAsyncCompute->Set(AsyncComputeValue);

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.h:112

Scope: file

Source code excerpt:

extern int32 GRDGAsyncCompute;
extern int32 GRDGCullPasses;
extern int32 GRDGMergeRenderPasses;
extern int32 GRDGTransientAllocator;
extern int32 GRDGTransientExtractedResources;
extern int32 GRDGTransientIndirectArgBuffers;

#if RDG_ENABLE_PARALLEL_TASKS

#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.h:252

Scope (from outer to inner):

file
function     bool IsRenderPassMergeEnabled

Source code excerpt:

FORCEINLINE bool IsRenderPassMergeEnabled()
{
	return GRDGMergeRenderPasses != 0 && !IsImmediateMode();
}

FORCEINLINE bool IsAsyncComputeSupported()
{
	return GRDGAsyncCompute > 0 && !IsImmediateMode() && GSupportsEfficientAsyncCompute && GRHISupportsSeparateDepthStencilCopyAccess && !GTriggerGPUProfile;
}