r.ParallelShadowsNonWholeScene
r.ParallelShadowsNonWholeScene
#Overview
name: r.ParallelShadowsNonWholeScene
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Toggles parallel shadow rendering for non whole-scene shadows. r.ParallelShadows 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.ParallelShadowsNonWholeScene is to control parallel shadow rendering for non-whole-scene shadows in Unreal Engine’s rendering system. This setting variable is part of the engine’s shadow rendering optimization features.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, specifically the shadow depth rendering component. This can be seen from the file location “Engine/Source/Runtime/Renderer/Private/ShadowDepthRendering.cpp”.
The value of this variable is set through the console variable system in Unreal Engine. It is initialized with a default value of 0, which means it’s disabled by default.
This variable interacts with another console variable, CVarParallelShadows. As mentioned in the description, “r.ParallelShadows must be enabled for this to have an effect.” This means that both r.ParallelShadows and r.ParallelShadowsNonWholeScene need to be enabled for parallel rendering of non-whole-scene shadows to occur.
Developers must be aware that this variable only affects non-whole-scene shadows. Whole-scene directional shadows are handled separately. Also, it’s important to note that this feature is not supported on mobile platforms, as indicated by the condition !IsMobilePlatform(ShaderPlatform)
in the IsParallelDispatchEnabled function.
Best practices when using this variable include:
- Ensure that r.ParallelShadows is also enabled for this to have any effect.
- Be aware of potential performance implications on different hardware configurations.
- Test thoroughly, especially on non-mobile platforms where this feature is supported.
- Consider the impact on rendering quality and performance when enabling this feature.
Regarding the associated variable CVarParallelShadowsNonWholeScene:
The purpose of CVarParallelShadowsNonWholeScene is to serve as the internal representation of the r.ParallelShadowsNonWholeScene console variable within the engine’s code.
This variable is used directly in the Renderer module to determine whether parallel shadow rendering for non-whole-scene shadows should be enabled. It’s accessed using the GetValueOnRenderThread() method, which ensures thread-safe access to the variable’s value.
The value of CVarParallelShadowsNonWholeScene is set when the r.ParallelShadowsNonWholeScene console variable is modified.
Developers should be aware that this is an internal variable and should not be modified directly. Instead, they should use the r.ParallelShadowsNonWholeScene console variable to control this setting.
Best practices for using CVarParallelShadowsNonWholeScene include:
- Always access its value using GetValueOnRenderThread() to ensure thread safety.
- Do not modify this variable directly; use the console variable system instead.
- Be aware of its interaction with other variables like CVarParallelShadows when implementing rendering logic.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowDepthRendering.cpp:729
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<int32> CVarParallelShadowsNonWholeScene(
TEXT("r.ParallelShadowsNonWholeScene"),
0,
TEXT("Toggles parallel shadow rendering for non whole-scene shadows. r.ParallelShadows must be enabled for this to have an effect."),
ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarRHICmdFlushRenderThreadTasksShadowPass(
#Associated Variable and Callsites
This variable is associated with another variable named CVarParallelShadowsNonWholeScene
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowDepthRendering.cpp:728
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe
);
static TAutoConsoleVariable<int32> CVarParallelShadowsNonWholeScene(
TEXT("r.ParallelShadowsNonWholeScene"),
0,
TEXT("Toggles parallel shadow rendering for non whole-scene shadows. r.ParallelShadows must be enabled for this to have an effect."),
ECVF_RenderThreadSafe
);
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/ShadowDepthRendering.cpp:1570
Scope (from outer to inner):
file
function bool IsParallelDispatchEnabled
Source code excerpt:
{
return GRHICommandList.UseParallelAlgorithms() && CVarParallelShadows.GetValueOnRenderThread()
&& (ProjectedShadowInfo->IsWholeSceneDirectionalShadow() || CVarParallelShadowsNonWholeScene.GetValueOnRenderThread())
// Parallel dispatch is not supported on mobile platform
&& !IsMobilePlatform(ShaderPlatform);
}
void FSceneRenderer::RenderShadowDepthMapAtlases(FRDGBuilder& GraphBuilder)
{