r.ParallelVelocity

r.ParallelVelocity

#Overview

name: r.ParallelVelocity

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.ParallelVelocity is to toggle parallel velocity rendering in the Unreal Engine 5 rendering system. This setting is specifically designed to control whether velocity calculations are performed in parallel, which can potentially improve performance on supported platforms.

This setting variable is primarily used by the Renderer module of Unreal Engine, specifically within the velocity rendering subsystem. It’s defined and utilized in the VelocityRendering.cpp file, which is part of the core rendering pipeline.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, meaning parallel velocity rendering is enabled by default. However, developers can modify this value at runtime using console commands or through project settings.

The associated variable CVarParallelVelocity directly interacts with r.ParallelVelocity. They share the same value and purpose, with CVarParallelVelocity being the actual C++ variable used in the code to check the setting’s value.

Developers must be aware of several important factors when using this variable:

  1. Parallel rendering must be enabled for this setting to have any effect.
  2. This setting is not supported on mobile platforms, as indicated by the check in the IsParallelVelocity function.
  3. Changing this value is render thread safe, meaning it can be modified without causing threading issues in the rendering pipeline.

Best practices when using this variable include:

  1. Ensure parallel rendering is enabled if you want to utilize parallel velocity rendering.
  2. Test performance with this setting both enabled and disabled to determine the optimal configuration for your specific project and target platforms.
  3. Be cautious when changing this value during runtime, as it may impact performance or visual quality.

Regarding the associated variable CVarParallelVelocity:

The purpose of CVarParallelVelocity is to provide a programmatic interface to the r.ParallelVelocity setting within the C++ code. It allows the engine to query the current state of parallel velocity rendering and make decisions based on its value.

CVarParallelVelocity is used directly in the Renderer module, specifically in the VelocityRendering.cpp file. It’s accessed in the IsParallelVelocity function to determine whether parallel velocity calculations should be performed.

The value of CVarParallelVelocity is set automatically based on the r.ParallelVelocity console variable. Developers don’t need to set it manually in code.

This variable interacts directly with the r.ParallelVelocity setting, effectively serving as its in-code representation.

When working with CVarParallelVelocity, developers should be aware that its value is queried on the render thread (using GetValueOnRenderThread()), ensuring thread-safe access to the setting.

Best practices for using CVarParallelVelocity include:

  1. Use the IsParallelVelocity function provided by FVelocityRendering instead of accessing CVarParallelVelocity directly, as it includes additional checks (like platform support).
  2. Remember that changes to r.ParallelVelocity will be reflected in CVarParallelVelocity, so there’s no need to update both separately.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VelocityRendering.cpp:49

Scope: file

Source code excerpt:


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

static TAutoConsoleVariable<int32> CVarRHICmdFlushRenderThreadTasksVelocityPass(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VelocityRendering.cpp:48

Scope: file

Source code excerpt:

	ECVF_ReadOnly | ECVF_RenderThreadSafe);

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/VelocityRendering.cpp:421

Scope (from outer to inner):

file
function     bool FVelocityRendering::IsParallelVelocity

Source code excerpt:

bool FVelocityRendering::IsParallelVelocity(EShaderPlatform ShaderPlatform)
{
	return GRHICommandList.UseParallelAlgorithms() && CVarParallelVelocity.GetValueOnRenderThread()
		// Parallel dispatch is not supported on mobile platform
		&& !IsMobilePlatform(ShaderPlatform);
}

bool FVelocityRendering::IsVelocityWaitForTasksEnabled(EShaderPlatform ShaderPlatform)
{