r.ParallelBasePass
r.ParallelBasePass
#Overview
name: r.ParallelBasePass
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Toggles parallel base pass rendering. Parallel rendering must be enabled for this to have an effect.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.ParallelBasePass is to control parallel base pass rendering in Unreal Engine’s rendering system. This setting variable is used to toggle the parallel execution of the base pass, which is a crucial part of the rendering pipeline.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, specifically the base pass rendering component. This can be seen from the file location where the variable is defined: Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp
.
The value of this variable is set through a console variable system. It’s initialized with a default value of 1 (enabled) and can be changed at runtime through console commands or programmatically.
This variable interacts closely with the associated variable CVarParallelBasePass
, which is the actual TAutoConsoleVariable object that stores and manages the value of r.ParallelBasePass.
Developers must be aware that this variable only has an effect when parallel rendering is enabled in the engine. As stated in the description: “Parallel rendering must be enabled for this to have an effect.”
Best practices when using this variable include:
- Ensure that parallel rendering is enabled in the engine for this setting to have any effect.
- Test performance with this setting both enabled and disabled, as parallel rendering may not always provide better performance in all scenarios.
- Be aware that changing this setting at runtime may affect rendering performance and possibly visual output.
Regarding the associated variable CVarParallelBasePass:
The purpose of CVarParallelBasePass is to provide a programmatic interface for the r.ParallelBasePass setting. It’s an instance of TAutoConsoleVariable
This variable is used directly in the rendering code to determine whether parallel base pass should be executed. For example, in the FDeferredShadingSceneRenderer::RenderBasePass
function, it’s used like this:
const bool bEnableParallelBasePasses = GRHICommandList.UseParallelAlgorithms() && CVarParallelBasePass.GetValueOnRenderThread();
This checks if parallel algorithms are supported by the current RHI (Rendering Hardware Interface) and if the CVarParallelBasePass is enabled.
Developers should be aware that this variable is marked as ECVF_RenderThreadSafe, meaning it’s safe to read and modify from the render thread. However, changes to this variable should still be done with care, as they can impact rendering performance and behavior.
Best practices for using CVarParallelBasePass include:
- Use the GetValueOnRenderThread() method when accessing the value from the render thread for thread-safety.
- Consider the implications of changing this value at runtime, especially in performance-critical sections of code.
- Use this variable in conjunction with other parallel rendering settings for optimal performance tuning.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:83
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarParallelBasePass(
TEXT("r.ParallelBasePass"),
1,
TEXT("Toggles parallel base pass rendering. Parallel rendering must be enabled for this to have an effect."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarClearGBufferDBeforeBasePass(
TEXT("r.ClearGBufferDBeforeBasePass"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarParallelBasePass
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:82
Scope: file
Source code excerpt:
ECVF_ReadOnly | ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarParallelBasePass(
TEXT("r.ParallelBasePass"),
1,
TEXT("Toggles parallel base pass rendering. Parallel rendering must be enabled for this to have an effect."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarClearGBufferDBeforeBasePass(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:992
Scope (from outer to inner):
file
function void FDeferredShadingSceneRenderer::RenderBasePass
Source code excerpt:
TRACE_CPUPROFILER_EVENT_SCOPE(FDeferredShadingSceneRenderer::RenderBasePass);
const bool bEnableParallelBasePasses = GRHICommandList.UseParallelAlgorithms() && CVarParallelBasePass.GetValueOnRenderThread();
static const auto ClearMethodCVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.ClearSceneMethod"));
bool bRequiresRHIClear = true;
bool bRequiresFarZQuadClear = false;
if (ClearMethodCVar)