r.RHICmdFlushRenderThreadTasksTranslucentPass

r.RHICmdFlushRenderThreadTasksTranslucentPass

#Overview

name: r.RHICmdFlushRenderThreadTasksTranslucentPass

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

This setting variable is primarily used in the rendering system, specifically in the translucent rendering subsystem of Unreal Engine. It is referenced in the TranslucentRendering.cpp file, which is part of the Renderer module.

The value of this variable is set through a console variable (CVarRHICmdFlushRenderThreadTasksTranslucentPass) with a default value of 0. It can be modified at runtime through console commands or configuration files.

This variable interacts with another console variable, CVarRHICmdFlushRenderThreadTasks. The engine checks both variables to determine if a flush of render thread tasks should occur at the end of the translucent pass.

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 translucent pass. This can impact performance, as it introduces a synchronization point in the rendering pipeline.

Best practices when using this variable include:

  1. Keep it disabled (0) by default for optimal performance.
  2. Enable it only when debugging or profiling specific issues related to translucent rendering.
  3. Consider the performance implications when enabling it, especially in performance-critical scenarios.

Regarding the associated variable CVarRHICmdFlushRenderThreadTasksTranslucentPass:

This is the actual console variable that stores and controls the r.RHICmdFlushRenderThreadTasksTranslucentPass setting. It is defined as a TAutoConsoleVariable, which means it’s an integer value that can be changed at runtime.

The purpose of this variable is the same as r.RHICmdFlushRenderThreadTasksTranslucentPass, as they are essentially the same thing – one is the console command, and the other is the internal variable holding the value.

This variable is used in the IsTranslucencyWaitForTasksEnabled() function, which checks both this variable and CVarRHICmdFlushRenderThreadTasks to determine if the engine should wait for render thread tasks to complete at the end of the translucent pass.

Developers should be aware that this variable is checked on the render thread (using GetValueOnRenderThread()), which means changes to this value will be applied on the next frame.

Best practices for using this variable are the same as those for r.RHICmdFlushRenderThreadTasksTranslucentPass, as they are directly linked.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentRendering.cpp:101

Scope: file

Source code excerpt:


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

static TAutoConsoleVariable<int32> CVarParallelTranslucency(
	TEXT("r.ParallelTranslucency"),
	1,

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentRendering.cpp:100

Scope: file

Source code excerpt:

	ECVF_Scalability | ECVF_Default);

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

static TAutoConsoleVariable<int32> CVarParallelTranslucency(
	TEXT("r.ParallelTranslucency"),

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/TranslucentRendering.cpp:216

Scope (from outer to inner):

file
function     static bool IsTranslucencyWaitForTasksEnabled

Source code excerpt:

static bool IsTranslucencyWaitForTasksEnabled()
{
	return IsParallelTranslucencyEnabled() && (CVarRHICmdFlushRenderThreadTasksTranslucentPass.GetValueOnRenderThread() > 0 || CVarRHICmdFlushRenderThreadTasks.GetValueOnRenderThread() > 0);
}

bool IsSeparateTranslucencyEnabled(ETranslucencyPass::Type TranslucencyPass, float DownsampleScale)
{
	// Currently AfterDOF is rendered earlier in the frame and must be rendered in a separate texture.
	if (   TranslucencyPass == ETranslucencyPass::TPT_TranslucencyAfterDOF