r.RHICmdFlushRenderThreadTasksPrePass
r.RHICmdFlushRenderThreadTasksPrePass
#Overview
name: r.RHICmdFlushRenderThreadTasksPrePass
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Wait for completion of parallel render thread tasks at the end of the pre pass. A more granular version of r.RHICmdFlushRenderThreadTasks. If either r.RHICmdFlushRenderThreadTasks or r.RHICmdFlushRenderThreadTasksPrePass is > 0 we will flush.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RHICmdFlushRenderThreadTasksPrePass is to control the synchronization of render thread tasks at the end of the pre-pass stage in the rendering pipeline. It acts as a more granular version of the r.RHICmdFlushRenderThreadTasks variable.
This setting variable is primarily used by the rendering system in Unreal Engine 5, specifically within the depth rendering subsystem. It’s part of the Renderer module, as evidenced by its location in the DepthRendering.cpp file.
The value of this variable is set through the console variable system in Unreal Engine. It’s initialized with a default value of 0, which means it’s disabled by default.
This variable interacts closely with another console variable, r.RHICmdFlushRenderThreadTasks. As seen in the IsDepthPassWaitForTasksEnabled() function, if either of these variables is set to a value greater than 0, the depth pass will wait for the completion of render thread tasks.
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 pre-pass. This can impact performance, so it should be used judiciously.
Best practices when using this variable include:
- Only enable it when debugging or profiling render thread tasks related to the depth pre-pass.
- Be aware of its performance implications and use it in conjunction with profiling tools.
- Consider using this more granular option instead of the broader r.RHICmdFlushRenderThreadTasks when focusing specifically on pre-pass issues.
Regarding the associated variable CVarRHICmdFlushRenderThreadTasksPrePass:
The purpose of CVarRHICmdFlushRenderThreadTasksPrePass is to serve as the internal representation of the r.RHICmdFlushRenderThreadTasksPrePass console variable within the engine’s C++ code.
This variable is used directly in the rendering system’s depth rendering logic, specifically in the IsDepthPassWaitForTasksEnabled() function.
The value of this variable is set by the console variable system when r.RHICmdFlushRenderThreadTasksPrePass is modified.
It interacts with CVarRHICmdFlushRenderThreadTasks in the IsDepthPassWaitForTasksEnabled() function to determine whether to wait for render thread tasks.
Developers should be aware that this is the actual variable used in the C++ code, and any changes to r.RHICmdFlushRenderThreadTasksPrePass will be reflected in this variable.
Best practices for using this variable include:
- Use the console variable r.RHICmdFlushRenderThreadTasksPrePass to modify its value, rather than attempting to change it directly in code.
- When reading its value in code, use the GetValueOnRenderThread() method to ensure thread-safe access.
- Consider the performance implications of frequently checking 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/DepthRendering.cpp:45
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarRHICmdFlushRenderThreadTasksPrePass(
TEXT("r.RHICmdFlushRenderThreadTasksPrePass"),
0,
TEXT("Wait for completion of parallel render thread tasks at the end of the pre pass. A more granular version of r.RHICmdFlushRenderThreadTasks. If either r.RHICmdFlushRenderThreadTasks or r.RHICmdFlushRenderThreadTasksPrePass is > 0 we will flush."));
static int32 GEarlyZSortMasked = 1;
static FAutoConsoleVariableRef CVarSortPrepassMasked(
TEXT("r.EarlyZSortMasked"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarRHICmdFlushRenderThreadTasksPrePass
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DepthRendering.cpp:44
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarRHICmdFlushRenderThreadTasksPrePass(
TEXT("r.RHICmdFlushRenderThreadTasksPrePass"),
0,
TEXT("Wait for completion of parallel render thread tasks at the end of the pre pass. A more granular version of r.RHICmdFlushRenderThreadTasks. If either r.RHICmdFlushRenderThreadTasks or r.RHICmdFlushRenderThreadTasksPrePass is > 0 we will flush."));
static int32 GEarlyZSortMasked = 1;
static FAutoConsoleVariableRef CVarSortPrepassMasked(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/DepthRendering.cpp:166
Scope (from outer to inner):
file
function static bool IsDepthPassWaitForTasksEnabled
Source code excerpt:
static bool IsDepthPassWaitForTasksEnabled()
{
return CVarRHICmdFlushRenderThreadTasksPrePass.GetValueOnRenderThread() > 0 || CVarRHICmdFlushRenderThreadTasks.GetValueOnRenderThread() > 0;
}
template <bool bPositionOnly>
bool GetDepthPassShaders(