r.ParallelPrePass

r.ParallelPrePass

#Overview

name: r.ParallelPrePass

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.ParallelPrePass is to toggle parallel z-prepass rendering in Unreal Engine’s rendering system. This setting is specifically designed for the depth rendering subsystem, which is crucial for determining visibility and occlusion in 3D scenes.

The Unreal Engine subsystem that relies on this setting variable is the Renderer module, particularly the depth rendering component. This can be seen from the file location where the variable is defined: Engine/Source/Runtime/Renderer/Private/DepthRendering.cpp.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1 (enabled) but can be changed at runtime through console commands or configuration files.

The associated variable CVarParallelPrePass interacts directly with r.ParallelPrePass. They share the same value and purpose, with CVarParallelPrePass being the actual TAutoConsoleVariable object used in the code.

Developers must be aware that this variable only has an effect when parallel rendering is enabled in the engine. This is evident from the description: “Parallel rendering must be enabled for this to have an effect.”

Best practices when using this variable include:

  1. Ensure that parallel rendering is enabled for this setting to take effect.
  2. Monitor performance impacts when toggling this setting, as parallel rendering can affect performance differently depending on the hardware and scene complexity.
  3. Consider disabling this feature for debugging purposes if issues arise in the depth pass stage of rendering.

Regarding the associated variable CVarParallelPrePass:

The purpose of CVarParallelPrePass is the same as r.ParallelPrePass - it’s the actual console variable object used to control parallel z-prepass rendering.

It’s used within the Renderer module, specifically in the depth rendering system.

The value is set when the variable is initialized (default to 1) and can be modified at runtime through the console or configuration files.

This variable directly controls the behavior of the parallel prepass feature. It’s checked in the RenderPrePass function to determine whether to use parallel algorithms for the depth pass.

Developers should be aware that this variable is marked as ECVF_RenderThreadSafe, meaning it’s safe to modify from the render thread.

Best practices include using this variable for fine-tuning rendering performance, especially on multi-core systems where parallel rendering can provide significant speed improvements.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DepthRendering.cpp:39

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarParallelPrePass(
	TEXT("r.ParallelPrePass"),
	1,
	TEXT("Toggles parallel zprepass rendering. Parallel rendering must be enabled for this to have an effect."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarRHICmdFlushRenderThreadTasksPrePass(
	TEXT("r.RHICmdFlushRenderThreadTasksPrePass"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DepthRendering.cpp:38

Scope: file

Source code excerpt:

#include "DepthCopy.h"

static TAutoConsoleVariable<int32> CVarParallelPrePass(
	TEXT("r.ParallelPrePass"),
	1,
	TEXT("Toggles parallel zprepass rendering. Parallel rendering must be enabled for this to have an effect."),
	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarRHICmdFlushRenderThreadTasksPrePass(

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DepthRendering.cpp:501

Scope (from outer to inner):

file
function     void FDeferredShadingSceneRenderer::RenderPrePass

Source code excerpt:

	SCOPE_CYCLE_COUNTER(STAT_DepthDrawTime);

	const bool bParallelDepthPass = GRHICommandList.UseParallelAlgorithms() && CVarParallelPrePass.GetValueOnRenderThread();

	RenderPrePassHMD(GraphBuilder, InViews, SceneDepthTexture);

	if (DepthPass.IsRasterStencilDitherEnabled())
	{
		AddDitheredStencilFillPass(GraphBuilder, InViews, SceneDepthTexture, DepthPass);