r.RHICmdBypass

r.RHICmdBypass

#Overview

name: r.RHICmdBypass

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

This variable is created as a Console Variable (cvar).

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of r.RHICmdBypass is to control whether the RHI (Rendering Hardware Interface) command list is bypassed, sending RHI commands immediately instead of queuing them. This setting is primarily used for the rendering system in Unreal Engine 5.

The Unreal Engine subsystem that relies on this setting variable is the RHI module, specifically the command list execution system. This can be seen from the file location “Engine/Source/Runtime/RHI/Private/RHICommandList.cpp” where the variable is defined and used.

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

The associated variable CVarRHICmdBypass interacts directly with r.RHICmdBypass, as they share the same value. This console variable is used to get and set the bypass state throughout the code.

Developers must be aware that:

  1. Setting this variable to 1 (Enable) is useful for debugging low-level graphics API calls but can interfere with the multithreaded renderer.
  2. Setting it to 0 (Disable) is required for the multithreaded renderer to function correctly.
  3. The value can be forced by command line arguments: “forcerhibypass” sets it to 1, while “parallelrendering” sets it to 0.

Best practices when using this variable include:

  1. Keep it disabled (0) for normal operation to allow the multithreaded renderer to work efficiently.
  2. Enable it (1) only when debugging specific rendering issues or when you need to suppress artifacts from multithreaded renderer code.
  3. Be cautious when modifying this value, as it can significantly impact rendering performance and behavior.

Regarding the associated variable CVarRHICmdBypass:

The purpose of CVarRHICmdBypass is to provide a runtime-configurable way to control the RHI command bypassing behavior.

It is used within the RHI module to determine whether to bypass the command list or not. The value is checked in various places, particularly in the FRHICommandListExecutor::LatchBypass function.

The value of CVarRHICmdBypass is set when the console variable is created, and it can be modified through console commands or programmatically using the IConsoleVariable interface.

CVarRHICmdBypass interacts directly with the r.RHICmdBypass setting, effectively serving as its runtime representation.

Developers should be aware that changes to CVarRHICmdBypass will immediately affect the RHI command execution behavior, which can have significant performance and rendering implications.

Best practices for CVarRHICmdBypass include:

  1. Use it for debugging and testing purposes rather than in production builds.
  2. When modifying its value, consider the impact on multithreaded rendering and overall performance.
  3. Use the provided console variable interface for changing its value rather than modifying it directly in code.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:2217, section: [SystemSettingsEditor]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:36

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarRHICmdBypass(
	TEXT("r.RHICmdBypass"),
	0,
	TEXT("Whether to bypass the rhi command list and send the rhi commands immediately.\n")
	TEXT("0: Disable (required for the multithreaded renderer)\n")
	TEXT("1: Enable (convenient for debugging low level graphics API calls, can suppress artifacts from multithreaded renderer code)"));

TAutoConsoleVariable<int32> CVarRHICmdWidth(

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:944

Scope (from outer to inner):

file
function     void FRHICommandListExecutor::LatchBypass
function     FOnce

Source code excerpt:

				if (FParse::Param(FCommandLine::Get(), TEXT("forcerhibypass")) && CVarRHICmdBypass.GetValueOnRenderThread() == 0)
				{
					IConsoleVariable* BypassVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RHICmdBypass"));
					BypassVar->Set(1, ECVF_SetByCommandline);
				}
				else if (FParse::Param(FCommandLine::Get(), TEXT("parallelrendering")) && CVarRHICmdBypass.GetValueOnRenderThread() >= 1)
				{
					IConsoleVariable* BypassVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RHICmdBypass"));
					BypassVar->Set(0, ECVF_SetByCommandline);
				}
			}
		} static Once;

		check(!GDynamicRHI || IsInRenderingThread());

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:35

Scope: file

Source code excerpt:

#endif

static TAutoConsoleVariable<int32> CVarRHICmdBypass(
	TEXT("r.RHICmdBypass"),
	0,
	TEXT("Whether to bypass the rhi command list and send the rhi commands immediately.\n")
	TEXT("0: Disable (required for the multithreaded renderer)\n")
	TEXT("1: Enable (convenient for debugging low level graphics API calls, can suppress artifacts from multithreaded renderer code)"));

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:942

Scope (from outer to inner):

file
function     void FRHICommandListExecutor::LatchBypass
function     FOnce

Source code excerpt:

			FOnce()
			{
				if (FParse::Param(FCommandLine::Get(), TEXT("forcerhibypass")) && CVarRHICmdBypass.GetValueOnRenderThread() == 0)
				{
					IConsoleVariable* BypassVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RHICmdBypass"));
					BypassVar->Set(1, ECVF_SetByCommandline);
				}
				else if (FParse::Param(FCommandLine::Get(), TEXT("parallelrendering")) && CVarRHICmdBypass.GetValueOnRenderThread() >= 1)
				{
					IConsoleVariable* BypassVar = IConsoleManager::Get().FindConsoleVariable(TEXT("r.RHICmdBypass"));
					BypassVar->Set(0, ECVF_SetByCommandline);
				}
			}
		} static Once;

#Loc: <Workspace>/Engine/Source/Runtime/RHI/Private/RHICommandList.cpp:957

Scope (from outer to inner):

file
function     void FRHICommandListExecutor::LatchBypass

Source code excerpt:

		check(!GDynamicRHI || IsInRenderingThread());

		bool NewBypass = IsInGameThread() || (CVarRHICmdBypass.GetValueOnAnyThread() >= 1);
		if (NewBypass && !bLatchedBypass)
		{
			RHICmdList.ExecuteAndReset(true);
		}

		bLatchedBypass = NewBypass;