r.DeferredMeshPassSetupTaskSync

r.DeferredMeshPassSetupTaskSync

#Overview

name: r.DeferredMeshPassSetupTaskSync

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.DeferredMeshPassSetupTaskSync is to control the synchronization point of the mesh pass setup task in the rendering pipeline. It is primarily used in the rendering system of Unreal Engine 5.

This setting variable is relied upon by the Renderer module of Unreal Engine, specifically within the mesh drawing and rendering pipeline.

The value of this variable is set through a console variable (CVarDeferredMeshPassSetupTaskSync) with a default value of 1 (enabled). It can be modified at runtime through console commands or programmatically.

The associated variable CVarDeferredMeshPassSetupTaskSync directly interacts with r.DeferredMeshPassSetupTaskSync. They share the same value and purpose.

Developers must be aware that this variable affects the performance and parallelism of the rendering pipeline. When enabled (set to 1), it defers the sync point of the mesh pass setup task until the Render Dependency Graph (RDG) execute phase, rather than during the RDG setup phase. This can significantly increase the potential for overlap in rendering operations.

Best practices when using this variable include:

  1. Leaving it enabled (default value of 1) for better performance in most scenarios.
  2. Testing the impact on your specific project, as performance gains may vary depending on the complexity of your scenes and rendering requirements.
  3. Considering disabling it temporarily for debugging purposes if you encounter rendering issues, as it may affect the order of rendering operations.

Regarding the associated variable CVarDeferredMeshPassSetupTaskSync:

The purpose of CVarDeferredMeshPassSetupTaskSync is to provide a console-accessible way to control the r.DeferredMeshPassSetupTaskSync setting. It is part of the rendering system’s configuration mechanism.

This console variable is used within the Renderer module, specifically in the mesh drawing and command building process.

The value of CVarDeferredMeshPassSetupTaskSync is set when the variable is initialized, with a default value of 1. It can be changed at runtime through console commands.

CVarDeferredMeshPassSetupTaskSync directly controls the behavior defined by r.DeferredMeshPassSetupTaskSync. It is used in conditional statements to determine whether to defer the mesh pass setup task synchronization.

Developers should be aware that modifying this console variable will have an immediate effect on the rendering pipeline’s behavior. It’s important to understand the potential performance implications when changing this value.

Best practices for using CVarDeferredMeshPassSetupTaskSync include:

  1. Using it for performance testing and optimization.
  2. Documenting any changes made to this variable in project settings or documentation.
  3. Considering exposing it as a user-configurable option if your project benefits from allowing users to adjust this setting.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/MeshDrawCommands.cpp:40

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarDeferredMeshPassSetupTaskSync(
	TEXT("r.DeferredMeshPassSetupTaskSync"),
	1,
	TEXT("If enabled, the sync point of the mesh pass setup task is deferred until RDG execute (from during RDG setup) significantly increasing the overlap possible."),
	ECVF_RenderThreadSafe);

FPrimitiveIdVertexBufferPool::FPrimitiveIdVertexBufferPool()
	: DiscardId(0)

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_RenderThreadSafe);

static TAutoConsoleVariable<int32> CVarDeferredMeshPassSetupTaskSync(
	TEXT("r.DeferredMeshPassSetupTaskSync"),
	1,
	TEXT("If enabled, the sync point of the mesh pass setup task is deferred until RDG execute (from during RDG setup) significantly increasing the overlap possible."),
	ECVF_RenderThreadSafe);

FPrimitiveIdVertexBufferPool::FPrimitiveIdVertexBufferPool()

#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/MeshDrawCommands.cpp:1611

Scope (from outer to inner):

file
function     void FParallelMeshDrawCommandPass::BuildRenderingCommands

Source code excerpt:

		check(!bHasInstanceCullingDrawParameters);

		if (CVarDeferredMeshPassSetupTaskSync.GetValueOnRenderThread() != 0)
		{
			TaskContext.InstanceCullingContext.BuildRenderingCommands(GraphBuilder, GPUScene, &OutInstanceCullingDrawParams);
		}
		else
		{
			TaskContext.InstanceCullingContext.WaitForSetupTask();