r.RHICmdFlushRenderThreadTasksVelocityPass

r.RHICmdFlushRenderThreadTasksVelocityPass

#Overview

name: r.RHICmdFlushRenderThreadTasksVelocityPass

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.RHICmdFlushRenderThreadTasksVelocityPass is to control the synchronization of parallel render thread tasks at the end of the velocity pass in Unreal Engine’s rendering system. It serves as a more granular version of the r.RHICmdFlushRenderThreadTasks setting.

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

The value of this variable is set through a console variable (CVar) system, allowing it to be modified at runtime. It is initialized with a default value of 0, meaning that by default, the engine does not wait for the completion of parallel render thread tasks at the end of the velocity pass.

This variable interacts with another console variable, r.RHICmdFlushRenderThreadTasks. The engine will flush render thread tasks if either of these variables is set to a value greater than 0.

Developers must be aware that enabling this setting (by setting it to a value greater than 0) may impact performance, as it introduces a synchronization point in the rendering pipeline. However, it can be useful for debugging or ensuring consistency in certain rendering scenarios.

Best practices when using this variable include:

  1. Leaving it at its default value (0) for optimal performance in most cases.
  2. Enabling it temporarily for debugging purposes when investigating issues related to velocity rendering or parallel task execution.
  3. Considering the performance implications before enabling it in a production environment.

Regarding the associated variable CVarRHICmdFlushRenderThreadTasksVelocityPass:

This is the actual console variable object that represents r.RHICmdFlushRenderThreadTasksVelocityPass in the code. It is used to access and modify the value of the setting.

The purpose of CVarRHICmdFlushRenderThreadTasksVelocityPass is to provide a programmatic interface for the r.RHICmdFlushRenderThreadTasksVelocityPass setting within the engine’s code.

This variable is used in the Renderer module, specifically in the FVelocityRendering::IsVelocityWaitForTasksEnabled function, which determines whether the engine should wait for velocity-related tasks to complete.

The value of this variable is typically set through the console or configuration files, but it can also be accessed and potentially modified at runtime using the GetValueOnRenderThread() method.

CVarRHICmdFlushRenderThreadTasksVelocityPass interacts with CVarRHICmdFlushRenderThreadTasks in the IsVelocityWaitForTasksEnabled function to determine if task flushing should occur.

Developers should be aware that this variable represents the actual storage and access mechanism for the r.RHICmdFlushRenderThreadTasksVelocityPass setting. Any changes to its value will directly affect the behavior of the velocity rendering system.

Best practices for using this variable include:

  1. Using GetValueOnRenderThread() to safely access its value from render thread code.
  2. Avoiding direct modification of the variable unless absolutely necessary, preferring to change the value through the console variable system instead.
  3. Considering the performance implications of frequently querying this variable’s value in performance-critical code paths.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarRHICmdFlushRenderThreadTasksVelocityPass(
	TEXT("r.RHICmdFlushRenderThreadTasksVelocityPass"),
	0,
	TEXT("Wait for completion of parallel render thread tasks at the end of the velocity pass.  A more granular version of r.RHICmdFlushRenderThreadTasks. If either r.RHICmdFlushRenderThreadTasks or r.RHICmdFlushRenderThreadTasksVelocityPass is > 0 we will flush."));

DECLARE_GPU_DRAWCALL_STAT_NAMED(RenderVelocities, TEXT("Render Velocities"));

/** Validate that deprecated CVars are no longer set. */

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	);

static TAutoConsoleVariable<int32> CVarRHICmdFlushRenderThreadTasksVelocityPass(
	TEXT("r.RHICmdFlushRenderThreadTasksVelocityPass"),
	0,
	TEXT("Wait for completion of parallel render thread tasks at the end of the velocity pass.  A more granular version of r.RHICmdFlushRenderThreadTasks. If either r.RHICmdFlushRenderThreadTasks or r.RHICmdFlushRenderThreadTasksVelocityPass is > 0 we will flush."));

DECLARE_GPU_DRAWCALL_STAT_NAMED(RenderVelocities, TEXT("Render Velocities"));

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

Scope (from outer to inner):

file
function     bool FVelocityRendering::IsVelocityWaitForTasksEnabled

Source code excerpt:

bool FVelocityRendering::IsVelocityWaitForTasksEnabled(EShaderPlatform ShaderPlatform)
{
	return FVelocityRendering::IsParallelVelocity(ShaderPlatform) && (CVarRHICmdFlushRenderThreadTasksVelocityPass.GetValueOnRenderThread() > 0 || CVarRHICmdFlushRenderThreadTasks.GetValueOnRenderThread() > 0);
}

bool FVelocityMeshProcessor::PrimitiveHasVelocityForView(const FViewInfo& View, const FPrimitiveSceneProxy* PrimitiveSceneProxy)
{
	// Skip camera cuts which effectively reset velocity for the new frame.
	if (View.bCameraCut && !View.PreviousViewTransform.IsSet())