r.RHICmdWidth
r.RHICmdWidth
#Overview
name: r.RHICmdWidth
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Controls the task granularity of a great number of things in the parallel renderer.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.RHICmdWidth is to control the task granularity of various operations in the parallel renderer of Unreal Engine 5. This setting variable plays a crucial role in managing the parallelization of rendering tasks.
-
The RHI (Rendering Hardware Interface) subsystem of Unreal Engine 5 relies on this setting variable. It’s primarily used in the rendering pipeline to optimize parallel execution of rendering tasks.
-
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 8 in the RHICommandList.cpp file.
-
This variable interacts closely with its associated variable CVarRHICmdWidth. They share the same value and are used interchangeably in the codebase.
-
Developers must be aware that changing this value can significantly impact the performance and behavior of the parallel renderer. A higher value may increase parallelism but could also lead to increased overhead, while a lower value might reduce parallelism but potentially improve cache coherency.
-
Best practices when using this variable include:
- Profiling the application with different values to find the optimal setting for specific hardware and scene complexities.
- Considering the target hardware capabilities when adjusting this value.
- Testing thoroughly after changes, as it can affect rendering performance and potentially introduce artifacts if set inappropriately.
Regarding the associated variable CVarRHICmdWidth:
- It serves the same purpose as r.RHICmdWidth, controlling the task granularity in the parallel renderer.
- It’s defined as a TAutoConsoleVariable, allowing runtime modification of the value.
- This variable is used directly in the FParallelCommandListSet constructor to set the Width member, which likely determines the number of parallel command lists to be used.
- It’s exposed as an external variable in RHICommandList.h, allowing other parts of the engine to access and potentially modify its value.
- When working with CVarRHICmdWidth, developers should be cautious about thread safety, as it’s accessed on the render thread (GetValueOnRenderThread()).
In summary, both r.RHICmdWidth and CVarRHICmdWidth are critical for fine-tuning the parallel rendering performance in Unreal Engine 5, and their proper use requires careful consideration of the specific application requirements and target hardware capabilities.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:43
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarRHICmdWidth(
TEXT("r.RHICmdWidth"),
8,
TEXT("Controls the task granularity of a great number of things in the parallel renderer."));
TAutoConsoleVariable<int32> CVarRHICmdFlushRenderThreadTasks(
TEXT("r.RHICmdFlushRenderThreadTasks"),
0,
#Associated Variable and Callsites
This variable is associated with another variable named CVarRHICmdWidth
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:42
Scope: file
Source code excerpt:
TEXT("1: Enable (convenient for debugging low level graphics API calls, can suppress artifacts from multithreaded renderer code)"));
TAutoConsoleVariable<int32> CVarRHICmdWidth(
TEXT("r.RHICmdWidth"),
8,
TEXT("Controls the task granularity of a great number of things in the parallel renderer."));
TAutoConsoleVariable<int32> CVarRHICmdFlushRenderThreadTasks(
TEXT("r.RHICmdFlushRenderThreadTasks"),
#Loc: <Workspace>/Engine/Source/Runtime/RHI/Public/RHICommandList.h:169
Scope: file
Source code excerpt:
extern RHI_API bool GEnableAsyncCompute;
extern RHI_API TAutoConsoleVariable<int32> CVarRHICmdWidth;
extern RHI_API TAutoConsoleVariable<int32> CVarRHICmdFlushRenderThreadTasks;
struct FRHICopyTextureInfo
{
FIntRect GetSourceRect() const
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:755
Scope (from outer to inner):
file
function FParallelCommandListSet::FParallelCommandListSet
Source code excerpt:
, bHasRenderPasses(bInHasRenderPasses)
{
Width = CVarRHICmdWidth.GetValueOnRenderThread();
MinDrawsPerCommandList = CVarRHICmdMinDrawsPerParallelCmdList.GetValueOnRenderThread();
QueuedCommandLists.Reserve(Width * 8);
check(!GOutstandingParallelCommandListSet);
GOutstandingParallelCommandListSet = this;
}