r.RDG.ImmediateMode
r.RDG.ImmediateMode
#Overview
name: r.RDG.ImmediateMode
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Executes passes as they get created. Useful to have a callstack of the wiring code when crashing in the pass\' lambda.
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RDG.ImmediateMode is to control the execution mode of the Render Dependency Graph (RDG) system in Unreal Engine 5. It is primarily used for debugging and performance analysis of the rendering system.
This setting variable is primarily used within the RenderCore module of Unreal Engine 5. It affects how the Render Dependency Graph system operates, which is a core part of the engine’s rendering pipeline.
The value of this variable is set through the console variable system. It can be set via command line with -rdgimmediate
or by using the console command r.RDG.ImmediateMode=1
.
The associated variable GRDGImmediateMode directly interacts with r.RDG.ImmediateMode. They share the same value and are used interchangeably in the code.
Developers must be aware that enabling immediate mode changes how render passes are executed. Instead of building a dependency graph and optimizing the execution order, passes are executed immediately as they are created. This can be useful for debugging but may impact performance in normal operation.
Best practices when using this variable include:
- Use it primarily for debugging purposes, especially when investigating crashes in pass execution.
- Be aware that enabling immediate mode may change the behavior and performance characteristics of your rendering code.
- Always test your rendering code with both immediate mode enabled and disabled to ensure it works correctly in both scenarios.
Regarding the associated variable GRDGImmediateMode:
- It is an integer variable that directly corresponds to the r.RDG.ImmediateMode console variable.
- It is used throughout the RenderCore module to check if immediate mode is enabled.
- The IsImmediateMode() function in RenderGraphPrivate.h uses this variable to determine the current mode.
- Developers should generally not modify this variable directly, but instead use the console variable system to change its value.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.cpp:12
Scope: file
Source code excerpt:
int32 GRDGImmediateMode = 0;
FAutoConsoleVariableRef CVarImmediateMode(
TEXT("r.RDG.ImmediateMode"),
GRDGImmediateMode,
TEXT("Executes passes as they get created. Useful to have a callstack of the wiring code when crashing in the pass' lambda."),
ECVF_RenderThreadSafe);
int32 GRDGValidation = 1;
FAutoConsoleVariableRef CVarRDGValidation(
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Public/RenderGraph.h:29
Scope: file
Source code excerpt:
* happen directly in the AddPass() with the immediate mode. When a bug is happening during pass execution, immediate mode
* allows you to have the callstack of the pass setup that may have the source cause of the bug. The immediate mode can be
* enabled from command line with -rdgimmediate, or with the cvar r.RDG.ImmediateMode=1.
*
* Pooled managed resource texture FPooledRenderTarget generated by legacy code can be used in render graph by using
* FRDGBuilder::RegisterExternalTexture().
*
* With the knowledge of pass dependencies, the execution may prioritize different hardware goal, such as prioritizing memory
* pressure or pass GPU execution concurrency. As such, the execution order of passes is not guaranteed. The execution
* order of the pass only guarantees that the execution will perform the work on the intermediary resource exactly as the
* immediate mode does on the GPU.
*
* A render graph pass should not modify the state of a external data structure, as this may lead to edges case according to
* the execution order of the pass. Render graph resources that should survive the render graph execution (For instance, a
* viewport back buffer, temporal AA history for next frame...) should be extracted using
* FRDGBuilder::QueueTextureExtraction(). If a pass is detected not useful to produce any of this resources scheduled for
* extraction, or modifying an external texture, this pass may not even be executed with a warning (TODO).
*
* Unless exception motivated with strong technical reasons (like stereo rendering rendering multiple views at once for VR),
* do not bundle multiple work on different resources in the same pass. This will end up creating more dependencies on a
* bundle of work that individually may only require a subset of those dependencies. The scheduler may be able to overlap a
* part of that with other GPU work. This may also retain allocated transient resources longer, potentially increasing
* highest memory pressure peak of your entire frame.
*
* Although the AddPass() only wants a lambda scope to have deferred execution, it does not mean you nead to write one.
* A pass may already be fully implementable using an even simpler utility such as the ones in FComputeShaderUtils
* or FPixelShaderUtils.
*/
#include "RenderGraphDefinitions.h"
#include "RenderGraphResources.h"
#include "RenderGraphPass.h"
#include "RenderGraphBuilder.h"
#include "RenderGraphUtils.h"
#include "ShaderParameterStruct.h"
#include "ShaderParameterMacros.h"
#Associated Variable and Callsites
This variable is associated with another variable named GRDGImmediateMode
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.cpp:10
Scope: file
Source code excerpt:
int32 GRDGDumpGraphUnknownCount = 0;
int32 GRDGImmediateMode = 0;
FAutoConsoleVariableRef CVarImmediateMode(
TEXT("r.RDG.ImmediateMode"),
GRDGImmediateMode,
TEXT("Executes passes as they get created. Useful to have a callstack of the wiring code when crashing in the pass' lambda."),
ECVF_RenderThreadSafe);
int32 GRDGValidation = 1;
FAutoConsoleVariableRef CVarRDGValidation(
TEXT("r.RDG.Validation"),
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.cpp:518
Scope (from outer to inner):
file
function void InitRenderGraph
Source code excerpt:
if (FParse::Param(FCommandLine::Get(), TEXT("rdgimmediate")))
{
GRDGImmediateMode = 1;
}
int32 ValidationValue = 0;
if (FParse::Value(FCommandLine::Get(), TEXT("rdgvalidation="), ValidationValue))
{
GRDGValidation = ValidationValue;
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.h:38
Scope: file
Source code excerpt:
extern int32 GRDGBreakpoint;
extern int32 GRDGTransitionLog;
extern int32 GRDGImmediateMode;
extern int32 GRDGOverlapUAVs;
extern bool GRDGAllowRHIAccess;
class FRDGAllowRHIAccessScope
{
public:
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.h:101
Scope: file
Source code excerpt:
const int32 GRDGBreakpoint = 0;
const int32 GRDGTransitionLog = 0;
const int32 GRDGImmediateMode = 0;
const int32 GRDGOverlapUAVs = 1;
#define RDG_ALLOW_RHI_ACCESS_SCOPE()
#define EmitRDGWarningf(WarningMessageFormat, ...)
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.h:247
Scope (from outer to inner):
file
function bool IsImmediateMode
Source code excerpt:
FORCEINLINE bool IsImmediateMode()
{
return GRDGImmediateMode != 0;
}
FORCEINLINE bool IsRenderPassMergeEnabled()
{
return GRDGMergeRenderPasses != 0 && !IsImmediateMode();
}