r.RDG.AsyncCompute
r.RDG.AsyncCompute
#Overview
name: r.RDG.AsyncCompute
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Controls the async compute policy.\n 0:disabled, no async compute is used;\n 1:enabled for passes tagged for async compute (default);\n 2:enabled for all compute passes implemented to use the compute command list;\n
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RDG.AsyncCompute is to control the async compute policy in Unreal Engine’s Render Dependency Graph (RDG) system. This setting variable is primarily used in the rendering system, specifically for managing asynchronous compute operations.
This setting variable is mainly used in the RenderCore module of Unreal Engine, as evidenced by its implementation in the RenderGraphPrivate.cpp file. The RenderCore module is a crucial part of the engine’s rendering system, responsible for managing low-level rendering operations and optimizations.
The value of this variable is set through a console variable (CVarRDGAsyncCompute) and can be modified at runtime. It can also be set via command line arguments using the “rdgasynccompute=” parameter.
The associated variable GRDGAsyncCompute interacts closely with r.RDG.AsyncCompute. GRDGAsyncCompute is an integer variable that stores the current value of the async compute policy, and it’s updated whenever the console variable changes.
Developers should be aware of the following when using this variable:
- It has three possible values (0, 1, 2), each with different implications for async compute usage.
- The default value is 1, which enables async compute for passes specifically tagged for it.
- Setting it to 0 disables all async compute operations.
- Setting it to 2 enables async compute for all compute passes that can use the compute command list.
Best practices when using this variable include:
- Use the default value (1) unless there’s a specific reason to change it.
- If performance issues are suspected to be related to async compute, try disabling it (set to 0) for debugging.
- Be cautious when setting it to 2, as this may impact performance if not all compute passes are optimized for async compute.
- When modifying this variable, monitor performance metrics to ensure the change has the desired effect.
Regarding the associated variable CVarRDGAsyncCompute:
The purpose of CVarRDGAsyncCompute is to provide a console-accessible interface for controlling the r.RDG.AsyncCompute setting. It’s an instance of TAutoConsoleVariable
This variable is used in the same RenderCore module and is closely tied to the r.RDG.AsyncCompute setting. Its value is used to update the GRDGAsyncCompute variable, which is then used throughout the rendering code to determine the async compute policy.
The value of CVarRDGAsyncCompute can be set through console commands or programmatically. It’s also initialized based on the RDG_ASYNC_COMPUTE_ENABLED macro.
Developers should be aware that changes to CVarRDGAsyncCompute will trigger an update to GRDGAsyncCompute. There’s also a special case where GRDGAsyncCompute is forced to 0 if GRDGDebugFlushGPU is true, overriding the console variable setting.
Best practices for using CVarRDGAsyncCompute include:
- Use console commands for quick testing and debugging of async compute behavior.
- Be aware that changes to this variable will affect rendering performance, so use with caution in production environments.
- When making programmatic changes, ensure they’re done in a thread-safe manner, preferably on the render thread.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.cpp:262
Scope: file
Source code excerpt:
int32 GRDGAsyncCompute = 1;
TAutoConsoleVariable<int32> CVarRDGAsyncCompute(
TEXT("r.RDG.AsyncCompute"),
RDG_ASYNC_COMPUTE_ENABLED,
TEXT("Controls the async compute policy.\n")
TEXT(" 0:disabled, no async compute is used;\n")
TEXT(" 1:enabled for passes tagged for async compute (default);\n")
TEXT(" 2:enabled for all compute passes implemented to use the compute command list;\n"),
ECVF_RenderThreadSafe);
#Associated Variable and Callsites
This variable is associated with another variable named CVarRDGAsyncCompute
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.cpp:261
Scope: file
Source code excerpt:
int32 GRDGAsyncCompute = 1;
TAutoConsoleVariable<int32> CVarRDGAsyncCompute(
TEXT("r.RDG.AsyncCompute"),
RDG_ASYNC_COMPUTE_ENABLED,
TEXT("Controls the async compute policy.\n")
TEXT(" 0:disabled, no async compute is used;\n")
TEXT(" 1:enabled for passes tagged for async compute (default);\n")
TEXT(" 2:enabled for all compute passes implemented to use the compute command list;\n"),
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.cpp:272
Scope (from outer to inner):
file
lambda-function
Source code excerpt:
FAutoConsoleVariableSink CVarRDGAsyncComputeSink(FConsoleCommandDelegate::CreateLambda([]()
{
GRDGAsyncCompute = CVarRDGAsyncCompute.GetValueOnGameThread();
if (GRDGDebugFlushGPU)
{
GRDGAsyncCompute = 0;
}
#Loc: <Workspace>/Engine/Source/Runtime/RenderCore/Private/RenderGraphPrivate.cpp:614
Scope (from outer to inner):
file
function void InitRenderGraph
Source code excerpt:
if (FParse::Value(FCommandLine::Get(), TEXT("rdgasynccompute="), AsyncComputeValue))
{
CVarRDGAsyncCompute->Set(AsyncComputeValue);
}
#if RDG_GPU_DEBUG_SCOPES
int32 RDGEventValue = 0;
if (FParse::Value(FCommandLine::Get(), TEXT("rdgevents="), RDGEventValue))
{