r.RHICmdFlushRenderThreadTasksBasePass

r.RHICmdFlushRenderThreadTasksBasePass

#Overview

name: r.RHICmdFlushRenderThreadTasksBasePass

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.RHICmdFlushRenderThreadTasksBasePass is to control the synchronization of parallel render thread tasks at the end of the base pass in Unreal Engine’s rendering pipeline.

This setting variable is primarily used by the rendering system, specifically in the base pass rendering module. Based on the callsites, it’s part of the Renderer module in Unreal Engine.

The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 0 and can be changed at runtime.

This variable interacts with another console variable, r.RHICmdFlushRenderThreadTasks. The IsBasePassWaitForTasksEnabled() function checks both variables to determine if flushing should occur.

Developers must be aware that enabling this variable (setting it to a value greater than 0) will cause the engine to wait for the completion of parallel render thread tasks at the end of the base pass. This can impact performance, so it should be used judiciously.

Best practices when using this variable include:

  1. Keep it disabled (set to 0) by default for optimal performance.
  2. Enable it only when debugging rendering issues related to task synchronization in the base pass.
  3. Consider the performance impact when enabling this feature, especially in performance-critical scenarios.

Regarding the associated variable CVarRHICmdFlushRenderThreadTasksBasePass:

The purpose of CVarRHICmdFlushRenderThreadTasksBasePass is to provide an internal representation of the r.RHICmdFlushRenderThreadTasksBasePass console variable within the engine’s C++ code.

This variable is used directly in the rendering system, specifically in the BasePassRendering.cpp file of the Renderer module.

The value of this variable is set through the TAutoConsoleVariable template, which links it to the r.RHICmdFlushRenderThreadTasksBasePass console variable.

It interacts with CVarRHICmdFlushRenderThreadTasks in the IsBasePassWaitForTasksEnabled() function to determine if task flushing should occur.

Developers should be aware that this is an internal representation and should generally interact with the console variable (r.RHICmdFlushRenderThreadTasksBasePass) rather than this C++ variable directly.

Best practices for this variable include:

  1. Use GetValueOnRenderThread() to safely access its value from the render thread.
  2. Avoid directly modifying this variable; instead, use the console variable system to change its value.
  3. Consider the performance implications when checking or using this variable in frequently called functions.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:60

Scope: file

Source code excerpt:


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

static TAutoConsoleVariable<int32> CVarSupportStationarySkylight(
	TEXT("r.SupportStationarySkylight"),
	1,

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:59

Scope: file

Source code excerpt:

	ECVF_ReadOnly | ECVF_RenderThreadSafe);

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

static TAutoConsoleVariable<int32> CVarSupportStationarySkylight(
	TEXT("r.SupportStationarySkylight"),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/BasePassRendering.cpp:196

Scope (from outer to inner):

file
function     static bool IsBasePassWaitForTasksEnabled

Source code excerpt:

static bool IsBasePassWaitForTasksEnabled()
{
	return CVarRHICmdFlushRenderThreadTasksBasePass.GetValueOnRenderThread() > 0 || CVarRHICmdFlushRenderThreadTasks.GetValueOnRenderThread() > 0;
}

static bool IsStandardTranslucenyPassSeparated()
{
	static const auto TranslucencyStandardSeparatedCVar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.Translucency.StandardSeparated"));
	return TranslucencyStandardSeparatedCVar && TranslucencyStandardSeparatedCVar->GetValueOnAnyThread() != 0;